Commit | Line | Data |
---|---|---|
dcc2332d MW |
1 | <?php |
2 | namespace wcf\data\smiley; | |
3 | use wcf\data\category\Category; | |
4 | use wcf\data\smiley\category\SmileyCategory; | |
5 | use wcf\system\cache\builder\SmileyCacheBuilder; | |
6 | use wcf\system\category\CategoryHandler; | |
7 | use wcf\system\SingletonFactory; | |
8 | ||
9 | /** | |
10 | * Manages the smiley cache. | |
11 | * | |
12 | * @author Marcel Werk | |
ca4ba303 | 13 | * @copyright 2001-2014 WoltLab GmbH |
dcc2332d | 14 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
f4f05aa5 | 15 | * @package com.woltlab.wcf |
dcc2332d MW |
16 | * @subpackage data.smiley |
17 | * @category Community Framework | |
18 | */ | |
19 | class SmileyCache extends SingletonFactory { | |
20 | /** | |
21 | * cached smilies | |
22 | * @var array | |
23 | */ | |
24 | protected $cachedSmilies = array(); | |
25 | ||
26 | /** | |
27 | * cached smiley categories | |
0ad90fc3 | 28 | * @var array<\wcf\data\smiley\category\SmileyCategory> |
dcc2332d MW |
29 | */ |
30 | protected $cachedCategories = array(); | |
31 | ||
32 | /** | |
0ad90fc3 | 33 | * @see \wcf\system\SingletonFactory::init() |
dcc2332d MW |
34 | */ |
35 | protected function init() { | |
36 | // get smiley cache | |
37 | $this->cachedSmilies = SmileyCacheBuilder::getInstance()->getData(array(), 'smilies'); | |
38 | $smileyCategories = CategoryHandler::getInstance()->getCategories('com.woltlab.wcf.bbcode.smiley'); | |
39 | ||
40 | $this->cachedCategories[null] = new SmileyCategory(new Category(null, array( | |
41 | 'categoryID' => null, | |
42 | 'parentCategoryID' => 0, | |
43 | 'title' => 'wcf.acp.smiley.categoryID.default', | |
44 | 'description' => '', | |
45 | 'showOrder' => -1, | |
46 | 'isDisabled' => 0 | |
47 | ))); | |
48 | ||
49 | foreach ($smileyCategories as $key => $smileyCategory) { | |
50 | $this->cachedCategories[$key] = new SmileyCategory($smileyCategory); | |
51 | } | |
52 | } | |
53 | ||
54 | /** | |
55 | * Returns all smilies. | |
56 | * | |
57 | * @return array | |
58 | */ | |
59 | public function getSmilies() { | |
60 | return $this->cachedSmilies; | |
61 | } | |
62 | ||
63 | /** | |
64 | * Returns all smiley categories. | |
65 | * | |
0ad90fc3 | 66 | * @return array<\wcf\data\smiley\category\SmileyCategory> |
dcc2332d MW |
67 | */ |
68 | public function getCategories() { | |
69 | return $this->cachedCategories; | |
70 | } | |
71 | ||
72 | /** | |
73 | * Returns all the smilies of a category. | |
74 | * | |
75 | * @param integer $categoryID | |
76 | * @return array | |
77 | */ | |
78 | public function getCategorySmilies($categoryID = null) { | |
79 | if (isset($this->cachedSmilies[$categoryID])) return $this->cachedSmilies[$categoryID]; | |
80 | ||
81 | return array(); | |
82 | } | |
83 | } |