1: <?php
2: /**
3: * Smilies class manager
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14: * @author Kazumi Ono (AKA onokazu)
15: * @author Gregory Mage (AKA Mage)
16: * @package system
17: */
18:
19: // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
20:
21: /**
22: * System Smilies
23: *
24: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
25: * @package system
26: */
27: class SystemSmilies extends XoopsObject
28: {
29: //PHP 8.2 Dynamic properties deprecated
30: public $id;
31: public $code;
32: public $smile_url;
33: public $emotion;
34: public $display;
35:
36: /**
37: *
38: */
39: public function __construct()
40: {
41: parent::__construct();
42: $this->initVar('id', XOBJ_DTYPE_INT, null, false, 5);
43: $this->initVar('code', XOBJ_DTYPE_TXTBOX, null, false);
44: $this->initVar('smile_url', XOBJ_DTYPE_TXTBOX, null, false);
45: $this->initVar('emotion', XOBJ_DTYPE_TXTBOX, null, false);
46: $this->initVar('display', XOBJ_DTYPE_INT, null, false, 1);
47: }
48:
49: /**
50: * @param bool $action
51: *
52: * @return XoopsThemeForm
53: */
54: public function getForm($action = false)
55: {
56: if ($this->isNew()) {
57: $blank_img = 'blank.gif';
58: } else {
59: $blank_img = str_replace('smilies/', '', $this->getVar('smile_url', 'e'));
60: }
61: if ($action === false) {
62: $action = $_SERVER['REQUEST_URI'];
63: }
64:
65: $title = $this->isNew() ? sprintf(_AM_SYSTEM_SMILIES_ADD) : sprintf(_AM_SYSTEM_SMILIES_EDIT);
66:
67: $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
68: $form->setExtra('enctype="multipart/form-data"');
69: $form->addElement(new XoopsFormText(_AM_SYSTEM_SMILIES_CODE, 'code', 26, 25, $this->getVar('code')), true);
70: $form->addElement(new XoopsFormText(_AM_SYSTEM_SMILIES_DESCRIPTION, 'emotion', 50, 50, $this->getVar('emotion')), true);
71:
72: $imgtray_img = new XoopsFormElementTray(_AM_SYSTEM_SMILIES_FILE, '<br>');
73: $imgpath_img = sprintf(_AM_SYSTEM_SMILIES_IMAGE_PATH, XOOPS_UPLOAD_PATH . '/smilies/');
74: $imageselect_img = new XoopsFormSelect($imgpath_img, 'smile_url', $blank_img);
75: $image_array_img = XoopsLists::getImgListAsArray(XOOPS_UPLOAD_PATH . '/smilies');
76: $imageselect_img->addOption("$blank_img", $blank_img);
77: foreach ($image_array_img as $image_img) {
78: $imageselect_img->addOption("$image_img", $image_img);
79: }
80: $imageselect_img->setExtra('onchange="showImgSelected(\'xo-smilies-img\', \'smile_url\', \'smilies\', \'\', \'' . XOOPS_UPLOAD_URL . '\' )"');
81: $imgtray_img->addElement($imageselect_img, false);
82: $imgtray_img->addElement(new XoopsFormLabel('', "<br><img src='" . XOOPS_UPLOAD_URL . '/smilies/' . $blank_img . "' name='image_img' id='xo-smilies-img' alt='' />"));
83:
84: $fileseltray_img = new XoopsFormElementTray('<br>', '<br><br>');
85: $fileseltray_img->addElement(new XoopsFormFile(_AM_SYSTEM_SMILIES_UPLOADS, 'smile_url', 500000), false);
86: $fileseltray_img->addElement(new XoopsFormLabel(''), false);
87: $imgtray_img->addElement($fileseltray_img);
88: $form->addElement($imgtray_img);
89:
90: if (!$this->isNew()) {
91: $form->addElement(new XoopsFormHidden('smilies_id', $this->getVar('id')));
92: $display = $this->getVar('display');
93: } else {
94: $display = 0;
95: }
96:
97: $form->addElement(new XoopsFormRadioYN(_AM_SYSTEM_SMILIES_OFF, 'display', $display));
98:
99: $form->addElement(new XoopsFormHidden('op', 'save_smilie'));
100: $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
101:
102: return $form;
103: }
104: }
105:
106: /**
107: * System smilies handler class. (Singelton)
108: *
109: * This class is responsible for providing data access mechanisms to the data source
110: * of XOOPS block class objects.
111: *
112: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
113: * @package system
114: * @subpackage avatar
115: */
116: class SystemsmiliesHandler extends XoopsPersistableObjectHandler
117: {
118: /**
119: * @param null|XoopsDatabase $db
120: */
121: public function __construct(XoopsDatabase $db)
122: {
123: parent::__construct($db, 'smiles', 'SystemSmilies', 'id', 'code');
124: }
125: }
126: