root/downloadDatabase/files/lib/page/DownloadDBDataPage.class.php @ 523

Revision 523, 5.4 kB (checked in by Tatzelwurm, 5 years ago)

Einige Änderungen wegen dem "/r/n Problem"
WYSIWYG im ACP hinzugefügt
Auswahl der Sprache hinzugefügt
Anzeige der Sprach-Flaggen im ACP und auf den Seiten (noch nicht fertig).

Line 
1<?php
2
3// wcf imports
4require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
5require_once(WCF_DIR.'lib/form/MessageForm.class.php');
6require_once(WCF_DIR.'lib/data/image/Thumbnail.class.php');
7require_once(WCF_DIR.'lib/data/downloadDB/DownloadDBData.class.php');
8
9/**
10 * Download Database Ansicht fÃŒr einzelne Kategorie(n) und Daten
11 *
12 * @author              Robert "Tatzelwurm" Hempel
13 * @copyright   2007/2008 INSIDE das Hörspiel
14 * @license     GNU LGPL http://www.gnu.org/licenses/lgpl.txt
15 * @package             de.inside.wcf.DownloadDatabase
16 */
17
18class DownloadDBDataPage extends MessageForm {
19
20        public $templateName = 'downloadDBViewData';
21        public $daten = array();
22        public $dataID;
23        public $action;
24       
25        public $parseURL = 1;
26        public $enableSmilies = 1;
27        public $enableHtml = 0;
28        public $enableBBCodes = 1;
29       
30        private $type;
31       
32        /**
33         * @see Page::readParameters()
34         */
35        public function readParameters() {
36                parent::readParameters();
37
38                if (isset($_REQUEST['dataID'])) $this->dataID = intval($_REQUEST['dataID']);
39                if (!$this->dataID){
40                        require_once(WCF_DIR.'lib/system/exception/NamedUserException.class.php');
41                        throw new NamedUserException(WCF::getLanguage()->get('wcf.dldb.wrongid'));
42                        exit;
43                }
44                WCF::getCache()->addResource('dldbData',
45                        WCF_DIR.'cache/cache.dldbData.php',
46                        WCF_DIR.'lib/system/cache/CacheBuilderDLDBData.class.php');
47        }
48
49        public function readData() {
50                parent::readData();
51                        $this->readDaten();
52        }
53       
54        /**
55         * @see Page::assignVariables();
56         */
57        public function assignVariables() {
58                parent::assignVariables();
59                if (DOWNLOADDB_OFFLINE) {
60                        $this->templateName = 'downloadDB_offline';
61                        WCF::getTPL()->assign('offlinemessage', DOWNLOADDB_OFFLINE_MESSAGE);
62                } else {
63                        WCF::getTPL()->assign(array(
64                                'dataID' => $this->dataID,
65                                'daten'  => $this->daten
66                                ));
67                }
68        }
69
70        /**
71         * @see Page::show()
72         */
73        public function show() {
74                require_once(WCF_DIR.'lib/page/util/menu/HeaderMenu.class.php');
75                HeaderMenu::setActiveMenuItem('wcf.header.menu.downloaddb');
76               
77                // check permission
78                WCF::getUser()->checkPermission('user.dldb.canUseDownloadDB');
79
80                parent::show();
81        }
82
83        protected function readDaten() {
84                // Cache lesen
85                $data = WCF::getCache()->get('dldbData');
86                foreach ($data as $daten) {
87                        if ($daten['dataID'] == $this->dataID && $daten['activ']) {
88                                if ($daten['mimeType']) {
89                                        $daten['type'] = DownloadDBData::setFileTypeIcon($daten['mimeType']);
90                                } else {
91                                        $daten['type'] = 'mime_default.gif';
92                                }
93                                $daten['groesse'] = FileUtil::formatFilesize($daten['groesse']);
94                                $IDs = explode(',',$daten['groupcheck']);
95                                $daten['canViewCat'] = false;
96                                foreach ($IDs as $gruppe) {
97                                        if (in_array($gruppe, WCF::getUser()->getGroupIDs())) { 
98                                                $daten['canViewCat'] = true;
99                                        }
100                                }
101                                if ($daten['canViewCat'] != true){
102                                        require_once(WCF_DIR.'lib/system/exception/PermissionDeniedException.class.php');
103                                        throw new PermissionDeniedException();
104                                }
105                                $daten['previewThumb'] = '';
106                                if ($daten['previewIMG']) {
107                                        if (@fopen(FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.$daten['previewFile']),'rb') == false) {
108                                                // make thumbnail
109                                                $thumb = new Thumbnail(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.$daten['previewFile'], DOWNLOADDB_PREVIEW_WIDTH, DOWNLOADDB_PREVIEW_HIGHT);
110                                               
111                                                // get thumbnail
112                                                if (($thumbnailData = $thumb->makeThumbnail(true))) {
113                                                        // save thumbnail
114                                                        $file = new File(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.$daten['previewFile']);
115                                                        $file->write($thumbnailData);
116                                                        unset($thumbnailData);
117                                                        $file->close();
118                                                        @chmod(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.$daten['previewFile'], 0666);
119                                                        $daten['previewThumb']  = FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.$daten['previewFile']);
120                                                        $daten['previewIMG']    = FileUtil::getRealPath(RELATIVE_WCF_DIR.$daten['previewIMG']);
121                                                } else {
122                                                        $daten['previewThumb']  = FileUtil::getRealPath(RELATIVE_WCF_DIR.$daten['previewIMG']);
123                                                        $daten['previewIMG']    = '';
124                                                }
125                                        } else {
126                                                $daten['previewIMG']    = FileUtil::getRealPath(RELATIVE_WCF_DIR.$daten['previewIMG']);
127                                                $daten['previewThumb']  = FileUtil::getRealPath(RELATIVE_WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.$daten['previewFile']);
128                                        }
129                                } elseif (DOWNLOADDB_SHOW_PREVIEW_NOPIC) {
130                                        $daten['previewIMG'] = $daten['previewThumb'] = RELATIVE_WCF_DIR.'icon/downloadDBnoPic.png';
131                                }
132                                // Beschreibung zur Ausgabe anpassen (BBCode+Smilies)
133                                $daten['name']                  = $this->getFormattedMessage($daten['name']);
134                                $daten['description']   = $this->getFormattedMessage($daten['description']);
135                                require_once(WCF_DIR.'lib/data/message/bbcode/URLParser.class.php');
136                                // URLs wandeln zur formatierten Ausgabe
137                                $daten['thread'] = $this->getFormattedMessage(URLParser::parse(StringUtil::decodeHTML($daten['thread'])));
138                                $this->daten = $daten;
139                                break;
140                        }
141                }
142        }
143
144        /**
145         * @see ViewablePost::getFormattedMessage()
146         */
147        protected function getFormattedMessage($text) {
148                // parse message
149                require_once(WCF_DIR.'lib/data/message/bbcode/MessageParser.class.php');
150                $parser = MessageParser::getInstance();
151                $parser->setOutputType('text/html');
152                return $parser->parse($text, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, false);
153        }
154       
155}
156?>
Note: See TracBrowser for help on using the browser.