|
Revision 804, 1.4 kB
(checked in by d0nut, 4 years ago)
|
|
updated minversion dependencies to publicseorewriter
|
| Line | |
|---|
| 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 | |
|---|
| 8 | // seo imports |
|---|
| 9 | require_once(WBB_DIR.'lib/page/PublicSEORewriterTagging.class.php'); |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * cache |
|---|
| 13 | * |
|---|
| 14 | * @author Torben Brodt |
|---|
| 15 | * @package de.easy-coding.wcf.taggingreloaded |
|---|
| 16 | * @license GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> |
|---|
| 17 | */ |
|---|
| 18 | class CacheBuilderTaggingReloadedTagging implements CacheBuilder { |
|---|
| 19 | protected $rewriter; |
|---|
| 20 | |
|---|
| 21 | /** |
|---|
| 22 | * @see CacheBuilder::getData() |
|---|
| 23 | */ |
|---|
| 24 | public function getData($cacheResource) { |
|---|
| 25 | $this->rewriter = new PublicSEORewriterTagging(); |
|---|
| 26 | // order by weight and cut |
|---|
| 27 | $sql = "SELECT tag, |
|---|
| 28 | SUM(weight) AS weight |
|---|
| 29 | FROM wcf".WCF_N."_taggingreloaded wcf |
|---|
| 30 | GROUP BY tag |
|---|
| 31 | ORDER BY weight DESC |
|---|
| 32 | LIMIT 200"; |
|---|
| 33 | |
|---|
| 34 | return $this->query($sql); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | /** |
|---|
| 38 | * |
|---|
| 39 | * @param sql |
|---|
| 40 | */ |
|---|
| 41 | protected function query($sql) { |
|---|
| 42 | $data = array(); |
|---|
| 43 | |
|---|
| 44 | // order by tag |
|---|
| 45 | $sql = "SELECT tag,weight FROM ($sql) A ORDER BY tag ASC"; |
|---|
| 46 | |
|---|
| 47 | // query |
|---|
| 48 | $result = WCF::getDB()->sendQuery($sql); |
|---|
| 49 | while ($row = WCF::getDB()->fetchArray($result)) { |
|---|
| 50 | $data[$row['tag']] = array( |
|---|
| 51 | 'weight'=> $row['weight'], |
|---|
| 52 | 'color'=> 0, |
|---|
| 53 | 'size'=> 0, |
|---|
| 54 | 'url' => $this->rewriter->publicParseTagURLs($row['tag']) |
|---|
| 55 | |
|---|
| 56 | ); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | $data = TaggingReloadedUtil::beautify($data); |
|---|
| 60 | |
|---|
| 61 | return $data; |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | ?> |
|---|