root/taggingreloaded/optionals/de.easy-coding.wbb.taggingreloaded/files/lib/system/cache/CacheBuilderTaggingReloadedBoards.class.php @ 804

Revision 804, 1.8 kB (checked in by d0nut, 4 years ago)

updated minversion dependencies to publicseorewriter

Line 
1<?php
2// WCF include
3require_once(WCF_DIR.'lib/system/cache/CacheBuilder.class.php');
4
5// Tagging imports
6require_once(WCF_DIR.'lib/util/TaggingReloadedUtil.class.php');
7require_once(WBB_DIR.'lib/data/board/BoardListTaggingReloaded.class.php');
8
9// seo imports
10require_once(WBB_DIR.'lib/page/PublicSEORewriterTagging.class.php');
11
12/**
13 * cache
14 *
15 * @author      Torben Brodt
16 * @package     de.easy-coding.wbb.taggingreloaded
17 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html>
18 */
19class CacheBuilderTaggingReloadedBoards implements CacheBuilder {
20        protected $rewriter;
21
22        /**
23         * @see CacheBuilder::getData()
24         */
25        public function getData($cacheResource) {
26                $this->rewriter = new PublicSEORewriterTagging();
27                $tmp = explode(".",$cacheResource['cache']);
28                $boardIDs = substr($cacheResource['cache'], strrpos($cacheResource['cache'],".")+1);
29
30                // order by weight and cut
31                $sql = "SELECT          tag,
32                                        SUM(weight) AS weight
33                        FROM            wcf".WCF_N."_taggingreloaded wcf
34                        NATURAL JOIN    wbb".WBB_N."_taggingreloaded wbb
35                        JOIN            wbb".WBB_N."_post p
36                        ON              wbb.postID = p.postID
37                        JOIN            wbb".WBB_N."_thread t
38                        ON              p.threadID = t.threadID
39                        WHERE           t.boardID IN (".$boardIDs.")
40                        GROUP BY        tag
41                        ORDER BY        weight DESC
42                        LIMIT           50";
43
44                return $this->query($sql);
45        }
46       
47        /**
48         *
49         * @param sql
50         */
51        protected function query($sql) {
52                $data = array();
53
54                // order by tag
55                $sql = "SELECT tag,weight FROM ($sql) A ORDER BY tag ASC";
56               
57                // query
58                $result = WCF::getDB()->sendQuery($sql);
59                while ($row = WCF::getDB()->fetchArray($result)) {
60                        $data[$row['tag']] = array(
61                                        'weight'=> $row['weight'],
62                                        'color'=> 0,
63                                        'size'=> 0,
64                                        'url' => $this->rewriter->publicParseTagURLs($row['tag'])
65                                       
66                                );
67                }
68               
69                $data = TaggingReloadedUtil::beautify($data);
70
71                return $data;
72        }
73}
74?>
Note: See TracBrowser for help on using the browser.