1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18:
19:
20:
21: 22: 23: 24: 25: 26:
27: class SystemSmilies extends XoopsObject
28: {
29: 30: 31:
32: public function __construct()
33: {
34: parent::__construct();
35: $this->initVar('id', XOBJ_DTYPE_INT, null, false, 5);
36: $this->initVar('code', XOBJ_DTYPE_TXTBOX, null, false);
37: $this->initVar('smile_url', XOBJ_DTYPE_TXTBOX, null, false);
38: $this->initVar('emotion', XOBJ_DTYPE_TXTBOX, null, false);
39: $this->initVar('display', XOBJ_DTYPE_INT, null, false, 1);
40: }
41:
42: 43: 44: 45: 46:
47: public function getForm($action = false)
48: {
49: if ($this->isNew()) {
50: $blank_img = 'blank.gif';
51: } else {
52: $blank_img = str_replace('smilies/', '', $this->getVar('smile_url', 'e'));
53: }
54: if ($action === false) {
55: $action = $_SERVER['REQUEST_URI'];
56: }
57:
58: $title = $this->isNew() ? sprintf(_AM_SYSTEM_SMILIES_ADD) : sprintf(_AM_SYSTEM_SMILIES_EDIT);
59:
60: $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
61: $form->setExtra('enctype="multipart/form-data"');
62: $form->addElement(new XoopsFormText(_AM_SYSTEM_SMILIES_CODE, 'code', 26, 25, $this->getVar('code')), true);
63: $form->addElement(new XoopsFormText(_AM_SYSTEM_SMILIES_DESCRIPTION, 'emotion', 50, 50, $this->getVar('emotion')), true);
64:
65: $imgtray_img = new XoopsFormElementTray(_AM_SYSTEM_SMILIES_FILE, '<br>');
66: $imgpath_img = sprintf(_AM_SYSTEM_SMILIES_IMAGE_PATH, XOOPS_UPLOAD_PATH . '/smilies/');
67: $imageselect_img = new XoopsFormSelect($imgpath_img, 'smile_url', $blank_img);
68: $image_array_img = XoopsLists::getImgListAsArray(XOOPS_UPLOAD_PATH . '/smilies');
69: $imageselect_img->addOption("$blank_img", $blank_img);
70: foreach ($image_array_img as $image_img) {
71: $imageselect_img->addOption("$image_img", $image_img);
72: }
73: $imageselect_img->setExtra('onchange="showImgSelected(\'xo-smilies-img\', \'smile_url\', \'smilies\', \'\', \'' . XOOPS_UPLOAD_URL . '\' )"');
74: $imgtray_img->addElement($imageselect_img, false);
75: $imgtray_img->addElement(new XoopsFormLabel('', "<br><img src='" . XOOPS_UPLOAD_URL . '/smilies/' . $blank_img . "' name='image_img' id='xo-smilies-img' alt='' />"));
76:
77: $fileseltray_img = new XoopsFormElementTray('<br>', '<br><br>');
78: $fileseltray_img->addElement(new XoopsFormFile(_AM_SYSTEM_SMILIES_UPLOADS, 'smile_url', 500000), false);
79: $fileseltray_img->addElement(new XoopsFormLabel(''), false);
80: $imgtray_img->addElement($fileseltray_img);
81: $form->addElement($imgtray_img);
82:
83: if (!$this->isNew()) {
84: $form->addElement(new XoopsFormHidden('smilies_id', $this->getVar('id')));
85: $display = $this->getVar('display');
86: } else {
87: $display = 0;
88: }
89:
90: $form->addElement(new XoopsFormRadioYN(_AM_SYSTEM_SMILIES_OFF, 'display', $display));
91:
92: $form->addElement(new XoopsFormHidden('op', 'save_smilie'));
93: $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
94:
95: return $form;
96: }
97: }
98:
99: 100: 101: 102: 103: 104: 105: 106: 107: 108:
109: class SystemsmiliesHandler extends XoopsPersistableObjectHandler
110: {
111: 112: 113:
114: public function __construct(XoopsDatabase $db)
115: {
116: parent::__construct($db, 'smiles', 'SystemSmilies', 'id', 'code');
117: }
118: }
119: