XOOPS  2.6.0
image.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 
21 {
25  public function __construct(ImagesImage $obj)
26  {
29 
30  $groups = $xoops->getUserGroups();
31 
32  if ($obj->isNew()) {
34  } else {
36  }
37 
38  parent::__construct('', 'image', $xoops->getEnv('PHP_SELF'), 'post', true);
39  $this->setExtra('enctype="multipart/form-data"');
40 
41  $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
42  $tab1 = new Xoops\Form\Tab($title, 'tabid-1');
43 
44  $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_NAME, 'image_nicename', 50, 255, $obj->getVar('image_nicename')), true);
45 
46  if ($obj->isNew()) {
47  $categories = $helper->getHandlerCategories()->getListByPermission($groups, 'imgcat_write');
48  $select = new Xoops\Form\Select(_AM_IMAGES_CAT_SELECT, 'imgcat_id', $obj->getVar('imgcat_id'));
49  $select->addOption('', _AM_IMAGES_CAT_SELECT);
50  $select->addOptionArray($categories);
51  $tab1->addElement($select, true);
52  } else {
53  $tab1->addElement(new Xoops\Form\Label(_AM_IMAGES_CAT_SELECT, '<span class="red bold">' . $helper->getHandlerCategories()->get($obj->getVar('imgcat_id'))->getVar('imgcat_name') . '</span>'));
54  $this->addElement(new Xoops\Form\Hidden('imgcat_id', $obj->getVar('imgcat_id')));
55  }
56 
57  // warning
58  $category = $helper->getHandlerCategories()->get($obj->getVar('imgcat_id'));
59  $upload_msg[] = _AM_IMAGES_CAT_SIZE . ' : ' . $category->getVar('imgcat_maxsize');
60  $upload_msg[] = _AM_IMAGES_CAT_WIDTH . ' : ' . $category->getVar('imgcat_maxwidth');
61  $upload_msg[] = _AM_IMAGES_CAT_HEIGHT . ' : ' . $category->getVar('imgcat_maxheight');
62 
63  $image_tray = new Xoops\Form\File(_AM_IMAGES_IMG_FILE, 'image_file');
64  $image_tray->setDescription(self::message($upload_msg, ''));
65  $tab1->addElement($image_tray);
66 
67  $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_WEIGHT, 'image_weight', 1, 4, $obj->getVar('image_weight')));
68 
69  $tab1->addElement(new Xoops\Form\RadioYesNo(_AM_IMAGES_DISPLAY, 'image_display', $obj->getVar('image_display')));
70 
71  $tabtray->addElement($tab1);
72  $this->addElement($tabtray);
73 
74  $this->addElement(new Xoops\Form\Hidden('image_name', $obj->getVar('image_name')));
75  $this->addElement(new Xoops\Form\Hidden('image_id', $obj->getVar('image_id')));
76 
81  $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
82 
83  $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
84  $button->setClass('btn btn-success');
85  $button_tray->addElement($button);
86 
87  $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
88  $button_2->setClass('btn btn-warning');
89  $button_tray->addElement($button_2);
90 
91  $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
92  $button_3->setExtra("onclick='javascript:history.go(-1);'");
93  $button_3->setClass('btn btn-danger');
94  $button_tray->addElement($button_3);
95 
96  $this->addElement($button_tray);
97  }
98 
102  public function message($msg, $title = '', $class = 'errorMsg')
103  {
104  $ret = "<div class='" . $class . "'>";
105  if ($title != '') {
106  $ret .= "<strong>" . $title . "</strong>";
107  }
108  if (is_array($msg) || is_object($msg)) {
109  $ret .= implode('<br />', $msg);
110  } else {
111  $ret .= $msg;
112  }
113  $ret .= "</div>";
114  return $ret;
115  }
116 }
setExtra($extra)
Definition: Form.php:374
const A_SUBMIT
Definition: en_US.php:128
const _AM_IMAGES_CAT_HEIGHT
Definition: admin.php:56
const A_RESET
Definition: en_US.php:121
static getInstance()
Definition: Xoops.php:160
__construct(ImagesImage $obj)
Definition: image.php:25
const _AM_IMAGES_NAME
Definition: admin.php:27
addElement(Element $formElement, $required=false)
Definition: Form.php:206
const _AM_IMAGES_CAT_SELECT
Definition: admin.php:38
const _AM_IMAGES_WEIGHT
Definition: admin.php:29
const _AM_IMAGES_CAT_WIDTH
Definition: admin.php:55
getVar($key, $format= 's')
$button
Definition: xoops_code.php:29
message($msg, $title= '', $class= 'errorMsg')
Definition: image.php:102
const _AM_IMAGES_IMG_ADD
Definition: admin.php:59
const _AM_IMAGES_CAT_SIZE
Definition: admin.php:54
$xoops
Definition: image.php:25
const _AM_IMAGES_IMG_EDIT
Definition: admin.php:60
const _AM_IMAGES_IMG_FILE
Definition: admin.php:64
const A_CANCEL
Definition: en_US.php:82
$helper
Definition: image.php:28
static getHelper($dirname= 'system')
Definition: Helper.php:27
addOption($value, $name= '')
Definition: Select.php:113
$groups
$button_tray
Definition: xoops_code.php:26
$button_2
Definition: xoops_code.php:34
if(!is_object($module)||!$module->getVar('isactive')) $msg
Definition: groupperm.php:38
$button_3
Definition: xoops_code.php:38
const _AM_IMAGES_DISPLAY
Definition: admin.php:28