XOOPS  2.6.0
smilies.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
23 {
27  public function __construct(SmiliesSmiley $obj)
28  {
30  if ($obj->isNew()) {
31  $blank_img = 'blank.gif';
32  } else {
33  $blank_img = str_replace('smilies/', '', $obj->getVar('smiley_url', 'e'));
34  }
35 
36  $title = $obj->isNew() ? sprintf(_AM_SMILIES_ADD) : sprintf(_AM_SMILIES_EDIT);
37 
38  parent::__construct($title, 'form', $xoops->getEnv('PHP_SELF'), 'post', true);
39  $this->setExtra('enctype="multipart/form-data"');
40  $this->addElement(new Xoops\Form\Text(_AM_SMILIES_CODE, 'smiley_code', 2, 25, $obj->getVar('smiley_code')), true);
41  $this->addElement(new Xoops\Form\Text(_AM_SMILIES_DESCRIPTION, 'smiley_emotion', 4, 50, $obj->getVar('smiley_emotion')), true);
42 
43  $imgtray_img = new Xoops\Form\ElementTray(_AM_SMILIES_FILE, '<br />');
44  $imgpath_img = sprintf(_AM_SMILIES_IMAGE_PATH, \XoopsBaseConfig::get('uploads-url') . '/smilies/');
45  $imageselect_img = new Xoops\Form\Select($imgpath_img, 'smiley_url', $blank_img);
46  $image_array_img = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('uploads-url') . '/smilies');
47  $imageselect_img->addOptionArray($image_array_img);
48 
49  $imageselect_img->setExtra('onchange="showImgSelected(\'xo-smilies-img\', \'smiley_url\', \'smilies\', \'\', \'' . \XoopsBaseConfig::get('uploads-url') . '\' )"');
50  $imgtray_img->addElement($imageselect_img, false);
51  $imgtray_img->addElement(new Xoops\Form\Label('', "<br /><img src='" . \XoopsBaseConfig::get('uploads-url') . "/smilies/" . $blank_img . "' name='image_img' id='xo-smilies-img' alt=''>"));
52 
53  $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
54  $fileseltray_img->addElement(new Xoops\Form\File(_AM_SMILIES_UPLOADS, 'smiley_url'), false);
55  $fileseltray_img->addElement(new Xoops\Form\Label(''), false);
56  $imgtray_img->addElement($fileseltray_img);
57  $this->addElement($imgtray_img);
58 
59  $this->addElement(new Xoops\Form\RadioYesNo(_AM_SMILIES_OFF, 'smiley_display', $obj->getVar('smiley_display')));
60 
61  $this->addElement(new Xoops\Form\Hidden('smiley_id', $obj->getVar('smiley_id')));
62 
66  $button_tray = new Xoops\Form\ElementTray('', '');
67  $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
68 
69  $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
70  $button->setClass('btn btn-success');
71  $button_tray->addElement($button);
72 
73  $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
74  $button_2->setClass('btn btn-warning');
75  $button_tray->addElement($button_2);
76 
77  switch (basename($xoops->getEnv('PHP_SELF'), '.php')) {
78  case 'xoops_smilies':
79  $button_3 = new Xoops\Form\Button('', 'button', XoopsLocale::A_CLOSE, 'button');
80  $button_3->setExtra('onclick="tinyMCEPopup.close();"');
81  $button_3->setClass('btn btn-danger');
82  $button_tray->addElement($button_3);
83  break;
84 
85  case 'smilies':
86  default:
87  $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
88  $button_3->setExtra("onclick='javascript:history.go(-1);'");
89  $button_3->setClass('btn btn-danger');
90  $button_tray->addElement($button_3);
91  break;
92  }
93 
94  $this->addElement($button_tray);
95  }
96 }
const _AM_SMILIES_CODE
Definition: admin.php:24
const _AM_SMILIES_ADD
Definition: admin.php:23
setExtra($extra)
Definition: Form.php:374
static getInstance()
Definition: Xoops.php:160
addElement(Element $formElement, $required=false)
Definition: Form.php:206
const _AM_SMILIES_EDIT
Definition: admin.php:29
getVar($key, $format= 's')
$xoops
Definition: admin.php:25
const _AM_SMILIES_DESCRIPTION
Definition: admin.php:27
const _AM_SMILIES_FILE
Definition: admin.php:30
static get($name)
const _AM_SMILIES_IMAGE_PATH
Definition: admin.php:31
__construct(SmiliesSmiley $obj)
Definition: smilies.php:27