| 1 | <?php |
|---|
| 2 | require_once(WCF_DIR.'lib/acp/form/ACPForm.class.php'); |
|---|
| 3 | require_once(WCF_DIR.'lib/page/AbstractPage.class.php'); |
|---|
| 4 | require_once(WCF_DIR.'lib/page/SortablePage.class.php'); |
|---|
| 5 | |
|---|
| 6 | /** |
|---|
| 7 | * Download Database Admin Control Panel. |
|---|
| 8 | * Listet alle Kategorien und Subkategorien auf. |
|---|
| 9 | * (Sub-)Kategorien können hinzugefügt, bearbeitet und gelöscht werden. |
|---|
| 10 | * |
|---|
| 11 | * @author Robert "Tatzelwurm" Hempel |
|---|
| 12 | * @copyright 2007/2008 INSIDE das Hörspiel |
|---|
| 13 | * @license GNU LGPL http://www.gnu.org/licenses/lgpl.txt |
|---|
| 14 | * @package de.inside.wcf.downloaddb |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | class DownloadDBDataListPage extends SortablePage { |
|---|
| 18 | |
|---|
| 19 | public $templateName = 'downloadDBDataList'; |
|---|
| 20 | public $activeMenuItem = 'wcf.acp.menu.link.content.dldb'; |
|---|
| 21 | public $neededPermissions = 'admin.dldb.canChangeOptions'; |
|---|
| 22 | |
|---|
| 23 | public $itemsPerPage = DOWNLOADDB_VIEW_MAX_DATA; |
|---|
| 24 | public $defaultSortField = 'katID'; |
|---|
| 25 | public $deleteddataID = 0; |
|---|
| 26 | |
|---|
| 27 | // Datensatz Variablen |
|---|
| 28 | public $dataID; |
|---|
| 29 | public $dldbdata = array(); |
|---|
| 30 | |
|---|
| 31 | public $position; |
|---|
| 32 | |
|---|
| 33 | public $action; |
|---|
| 34 | private $valid = false; |
|---|
| 35 | |
|---|
| 36 | public $kategorien = array(); |
|---|
| 37 | public $subkategorien = array(); |
|---|
| 38 | |
|---|
| 39 | public function readParameters() { |
|---|
| 40 | parent::readParameters(); |
|---|
| 41 | if (isset($_REQUEST['dataID'])) $this->dataID = intval($_REQUEST['dataID']); |
|---|
| 42 | if (isset($_REQUEST['action'])) $this->action = escapeString($_REQUEST['action']); |
|---|
| 43 | // detect Data deletion |
|---|
| 44 | if (isset($_REQUEST['deleteddataID'])) { |
|---|
| 45 | $this->deleteddataID = intval($_REQUEST['deleteddataID']); |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | public function validateSortField() { |
|---|
| 50 | parent::validateSortField(); |
|---|
| 51 | |
|---|
| 52 | switch ($this->sortField) { |
|---|
| 53 | case 'dataID': |
|---|
| 54 | case 'katID': |
|---|
| 55 | case 'name': |
|---|
| 56 | case 'downloads': |
|---|
| 57 | case 'activ': |
|---|
| 58 | case 'fileName':break; |
|---|
| 59 | default: $this->sortField = $this->defaultSortField; |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | public function readData() { |
|---|
| 64 | parent::readData(); |
|---|
| 65 | $this->readDldbData(); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | public function assignVariables() { |
|---|
| 69 | parent::assignVariables(); |
|---|
| 70 | |
|---|
| 71 | WCF::getTPL()->assign(array( |
|---|
| 72 | 'dldbdata' => $this->dldbdata, |
|---|
| 73 | 'deleteddataID' => $this->deleteddataID |
|---|
| 74 | )); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | public function show() { |
|---|
| 78 | // enable menu item |
|---|
| 79 | WCFACP::getMenu()->setActiveMenuItem($this->activeMenuItem); |
|---|
| 80 | |
|---|
| 81 | parent::show(); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | public function countItems() { |
|---|
| 85 | $sql = "SELECT COUNT(dataID) AS position |
|---|
| 86 | FROM wcf".WCF_N."_dldb_data"; |
|---|
| 87 | $row = WCF::getDB()->getFirstRow($sql); |
|---|
| 88 | |
|---|
| 89 | return $row['position']; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | protected function readDldbData() { |
|---|
| 93 | $sql = "SELECT *, |
|---|
| 94 | (SELECT name |
|---|
| 95 | FROM wcf".WCF_N."_dldb_kats |
|---|
| 96 | WHERE `katID` = dldb_data.`katID`) |
|---|
| 97 | AS katName |
|---|
| 98 | FROM wcf".WCF_N."_dldb_data dldb_data |
|---|
| 99 | ORDER BY dldb_data.".$this->sortField." ".$this->sortOrder." |
|---|
| 100 | LIMIT ".$this->itemsPerPage." |
|---|
| 101 | OFFSET ".(($this->pageNo - 1) * $this->itemsPerPage); |
|---|
| 102 | $result = WCF::getDB()->sendQuery($sql); |
|---|
| 103 | while ($row = WCF::getDB()->fetchArray($result)) { |
|---|
| 104 | $this->dldbdata[] = $row; |
|---|
| 105 | } |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | } |
|---|
| 109 | ?> |
|---|