| 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 | $languagesArray = WCF::getLanguage()->getAvailableLanguages(); |
|---|
| 72 | |
|---|
| 73 | for ($i = 0; $i < count($languagesArray); $i++) { |
|---|
| 74 | $languageItems = $languagesArray[$i]; |
|---|
| 75 | |
|---|
| 76 | $languageArray[] = array( |
|---|
| 77 | 'languageID' => $languageItems['languageID'], |
|---|
| 78 | 'languageCode' => ucfirst($languageItems['languageCode']) |
|---|
| 79 | ); |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | WCF::getTPL()->assign(array( |
|---|
| 83 | 'dldbdata' => $this->dldbdata, |
|---|
| 84 | 'deleteddataID' => $this->deleteddataID, |
|---|
| 85 | 'languageArray' => $languageArray |
|---|
| 86 | )); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | public function show() { |
|---|
| 90 | // enable menu item |
|---|
| 91 | WCFACP::getMenu()->setActiveMenuItem($this->activeMenuItem); |
|---|
| 92 | |
|---|
| 93 | parent::show(); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | public function countItems() { |
|---|
| 97 | $sql = "SELECT COUNT(dataID) AS position |
|---|
| 98 | FROM wcf".WCF_N."_dldb_data"; |
|---|
| 99 | $row = WCF::getDB()->getFirstRow($sql); |
|---|
| 100 | |
|---|
| 101 | return $row['position']; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | protected function readDldbData() { |
|---|
| 105 | $sql = "SELECT *, |
|---|
| 106 | (SELECT name |
|---|
| 107 | FROM wcf".WCF_N."_dldb_kats |
|---|
| 108 | WHERE `katID` = dldb_data.`katID`) |
|---|
| 109 | AS katName |
|---|
| 110 | FROM wcf".WCF_N."_dldb_data dldb_data |
|---|
| 111 | ORDER BY dldb_data.".$this->sortField." ".$this->sortOrder." |
|---|
| 112 | LIMIT ".$this->itemsPerPage." |
|---|
| 113 | OFFSET ".(($this->pageNo - 1) * $this->itemsPerPage); |
|---|
| 114 | $result = WCF::getDB()->sendQuery($sql); |
|---|
| 115 | while ($row = WCF::getDB()->fetchArray($result)) { |
|---|
| 116 | $this->dldbdata[] = $row; |
|---|
| 117 | } |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | } |
|---|
| 121 | ?> |
|---|