root/taggingreloaded/files/lib/page/TaggingPage.class.php @ 57

Revision 57, 2.7 kB (checked in by d0nut, 6 years ago)

By using it in my forum, i discovered some small issues and optimized the look and feel. The site was updated with this version.

Line 
1<?php
2require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
3
4/**
5 * tagging page (extendable by mods)
6 *
7 * @author      Torben Brodt
8 * @package     de.easy-coding.wcf.taggingreloaded
9 * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
10 */
11class TaggingPage extends AbstractPage {
12        public $templateName = 'taggingReloaded'; 
13        protected $tag;
14        protected $tags = array();
15       
16        /**
17         * @see Page::readParameters()
18         */
19        public function readParameters() {
20                parent::readParameters();
21               
22                if(isset($_GET['tag'])) $this->tag = $_GET['tag'];
23        }
24       
25        /**
26         * @see Page::readData()
27         */
28        public function readData() {
29                parent::readData();
30               
31                if(empty($this->tag)) {
32                        // order by weight and cut
33                        $sql = "SELECT          tag,
34                                                SUM(weight) AS weight
35                                FROM            wcf".WCF_N."_taggingreloaded wcf
36                                GROUP BY        tag
37                                ORDER BY        weight DESC
38                                LIMIT           200";
39                        //      SUM( weight ) * IF(COUNT(tag), 1.2, 1 )
40
41                        // order by tag
42                        $sql = "SELECT tag,weight FROM ($sql) A ORDER BY tag ASC";
43                       
44                        // query
45                        $result = WCF::getDB()->sendQuery($sql);
46                        while ($row = WCF::getDB()->fetchArray($result)) {
47                                $this->tags[$row['tag']] = array(
48                                                'weight'=> $row['weight'],
49                                                'color'=> 0,
50                                                'size'=> 0
51                                        );
52                        }
53                       
54                        $this->tags = TaggingReloadedUtil::beautify($this->tags);
55                }
56        }
57       
58        /**
59         * @see Page::assignVariables()
60         */
61        public function assignVariables() {
62                parent::assignVariables();
63               
64                if(empty($this->tag)) {
65                        $title = WCF::getLanguage()->get('wcf.header.menu.tagging');
66                        $headline = WCF::getLanguage()->get('wcf.taggingreloaded.tagging');
67                        $desc = WCF::getLanguage()->get('wcf.taggingreloaded.description');
68                } else {
69                        $title = $this->tag . ' - ' . WCF::getLanguage()->get('wcf.header.menu.tagging');
70                        $headline = $this->tag;
71                        $desc = WCF::getLanguage()->get('wcf.taggingreloaded.tagging');
72
73                        WCF::getTPL()->append('additionalTaggingBreadCrumbs', '<li><a href="index.php?page=Tagging">'.
74                                '<img src="'.RELATIVE_WCF_DIR.'icon/tagging16.png" alt="" /> '.
75                                '<span>'.WCF::getLanguage()->get('wcf.header.menu.tagging').'</span></a> &raquo;</li>');
76                }
77
78                WCF::getTPL()->assign(array(
79                        'title' => $title,
80                        'headline' => $headline,
81                        'desc' => $desc,
82                        'tags' => $this->tags,
83                        'specialStyles' => '<link rel="stylesheet" type="text/css" href="'.RELATIVE_WCF_DIR.'style/taggingreloaded.css" />',
84                        'allowSpidersToIndexThisPage' => true
85                        ));
86               
87                WCF::getTPL()->append('additionalTaggingContents', WCF::getTPL()->fetch('taggingCloud'));
88        }
89       
90        /**
91         * @see Page::show()
92         */
93        public function show() {
94                // set active header menu item
95                require_once(WCF_DIR.'lib/page/util/menu/HeaderMenu.class.php');
96                HeaderMenu::setActiveMenuItem('wcf.header.menu.tagging');
97
98                parent::show();
99        }
100}
101?>
Note: See TracBrowser for help on using the browser.