| 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: | 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: | |
| 51: | |
| 52: | |
| 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: | |
| 108: | |
| 109: | |
| 110: | |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: |
|
| 116: | class SystemsmiliesHandler extends XoopsPersistableObjectHandler
|
| 117: | {
|
| 118: | |
| 119: | |
| 120: |
|
| 121: | public function __construct(XoopsDatabase $db)
|
| 122: | {
|
| 123: | parent::__construct($db, 'smiles', 'SystemSmilies', 'id', 'code');
|
| 124: | }
|
| 125: | }
|
| 126: | |