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

Revision 172, 3.2 kB (checked in by d0nut, 5 years ago)

some more fixes for correct redirect

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