From ec80dc9d87ae49dd5b809a80bf1f0fd66257c3e0 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 26 Jul 2015 15:39:37 +0200 Subject: [PATCH] Importrun: allow to show it's rows --- .../controllers/ImportrunController.php | 25 ++++++++ application/tables/ImportedrowsTable.php | 60 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 application/controllers/ImportrunController.php create mode 100644 application/tables/ImportedrowsTable.php diff --git a/application/controllers/ImportrunController.php b/application/controllers/ImportrunController.php new file mode 100644 index 00000000..4aa418e2 --- /dev/null +++ b/application/controllers/ImportrunController.php @@ -0,0 +1,25 @@ +view->title = $this->translate('Import run'); + $this->view->table = $this->applyPaginationLimits( + $this->loadTable('importedrows') + ->setChecksum( + $this->db()->getImportrunRowsetChecksum($this->params->get('id')) + ) + ->setConnection($this->db()) + ); + $this->render('list/table', null, true); + } +} diff --git a/application/tables/ImportedrowsTable.php b/application/tables/ImportedrowsTable.php new file mode 100644 index 00000000..b5f6f1e0 --- /dev/null +++ b/application/tables/ImportedrowsTable.php @@ -0,0 +1,60 @@ +connection(); + return $db->listImportedRowsetColumnNames($this->checksum); + } + + public function setChecksum($checksum) + { + $this->checksum = $checksum; + return $this; + } + + public function getTitles() + { + $view = $this->view(); + $cols = $this->getColumns(); + return array( + 'object_name' => $view->translate('Object name'), + ) + array_combine($cols, $cols); + } + + public function count() + { + $db = $this->connection()->getConnection(); + $query = $db->select() + ->from('imported_rowset_row', 'COUNT(*)') + ->where('rowset_checksum = ?', $this->checksum); + + return $db->fetchOne($query); + } + + public function fetchData() + { + $db = $this->connection()->getConnection(); + $query = $this->getBaseQuery(); + + if ($this->hasLimit() || $this->hasOffset()) { + $query->limit($this->getLimit(), $this->getOffset()); + } + + return $db->fetchAll($query); + } + + public function getBaseQuery() + { + return $this->connection()->createImportedRowsetRowsQuery( + $this->checksum + )->order('object_name'); + } +}