| 1 | <?php |
|---|
| 2 | require_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 | */ |
|---|
| 11 | class 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 100"; |
|---|
| 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 | |
|---|
| 74 | WCF::getTPL()->assign(array( |
|---|
| 75 | 'title' => $title, |
|---|
| 76 | 'headline' => $headline, |
|---|
| 77 | 'desc' => $desc, |
|---|
| 78 | 'tags' => $this->tags, |
|---|
| 79 | 'specialStyles' => '<link rel="stylesheet" type="text/css" href="'.RELATIVE_WCF_DIR.'style/taggingreloaded.css" />', |
|---|
| 80 | 'allowSpidersToIndexThisPage' => true |
|---|
| 81 | )); |
|---|
| 82 | |
|---|
| 83 | WCF::getTPL()->append('additionalTaggingContents', WCF::getTPL()->fetch('taggingCloud')); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | /** |
|---|
| 87 | * @see Page::show() |
|---|
| 88 | */ |
|---|
| 89 | public function show() { |
|---|
| 90 | // set active header menu item |
|---|
| 91 | require_once(WCF_DIR.'lib/page/util/menu/HeaderMenu.class.php'); |
|---|
| 92 | HeaderMenu::setActiveMenuItem('wcf.header.menu.tagging'); |
|---|
| 93 | |
|---|
| 94 | parent::show(); |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | ?> |
|---|