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