1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Database\Connection;
13: use Xoops\Core\Kernel\Criteria;
14: use Xoops\Core\Kernel\CriteriaCompo;
15: use Xoops\Core\Kernel\Dtype;
16: use Xoops\Core\Kernel\XoopsObject;
17: use Xoops\Core\Kernel\XoopsPersistableObjectHandler;
18:
19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29: class SmiliesSmiley extends XoopsObject
30: {
31: 32: 33:
34: public function __construct()
35: {
36: $this->initVar('smiley_id', Dtype::TYPE_INTEGER, null, false);
37: $this->initVar('smiley_code', Dtype::TYPE_TEXT_BOX, null, true, 100);
38: $this->initVar('smiley_url', Dtype::TYPE_OTHER, null, false, 30);
39: $this->initVar('smiley_emotion', Dtype::TYPE_TEXT_BOX, null, true, 100);
40: $this->initVar('smiley_display', Dtype::TYPE_INTEGER, 1, false);
41: }
42: }
43:
44: 45: 46: 47: 48: 49: 50: 51: 52: 53:
54: class SmiliesSmileyHandler extends XoopsPersistableObjectHandler
55: {
56: 57: 58: 59: 60:
61: public function __construct(Connection $db = null)
62: {
63: parent::__construct($db, 'smilies', 'SmiliesSmiley', 'smiley_id', 'smiley_emotion');
64: }
65:
66: 67: 68: 69: 70: 71: 72: 73: 74:
75: public function getSmilies($start = 0, $limit = 0, $fetchAsObjects = true)
76: {
77: $criteria = new CriteriaCompo();
78: $criteria->setSort('smiley_id');
79: $criteria->setOrder('ASC');
80: $criteria->setStart($start);
81: $criteria->setLimit($limit);
82: return $this->getAll($criteria, false, $fetchAsObjects);
83: }
84:
85: 86: 87: 88: 89: 90: 91:
92: public function getActiveSmilies($fetchAsObjects = true)
93: {
94: $criteria = new CriteriaCompo(new Criteria('smiley_display', 1));
95: $criteria->setSort('smiley_id');
96: $criteria->setOrder('ASC');
97: $results = $this->getAll($criteria, false, $fetchAsObjects);
98: $uploadPath = \XoopsBaseConfig::get('uploads-url') . '/';
99: foreach ($results as $i => $smile) {
100: $results[$i]['smiley_url'] = $uploadPath . $smile['smiley_url'];
101: }
102:
103: return $results;
104: }
105: }
106: