XOOPS  2.6.0
image_imagemanager.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 {
22 
29  public function __construct($param)
30  {
33 
34  //todo, remove extract
35  extract($param);
36 
37  $groups = $xoops->getUserGroups();
38 
39  if ($obj->isNew()) {
41  } else {
43  }
44 
45  parent::__construct($title, 'image', $xoops->getEnv('PHP_SELF'), 'post', true);
46  $this->setExtra('enctype="multipart/form-data"');
47 
48  $this->addElement(new Xoops\Form\Text(_AM_IMAGES_NAME, 'image_nicename', 50, 255, $obj->getVar('image_nicename')), true);
49 
50  $categories = $helper->getHandlerCategories()->getListByPermission($groups, 'imgcat_write');
51  $select = new Xoops\Form\Select(_AM_IMAGES_CAT_SELECT, 'imgcat_id', $obj->getVar('imgcat_id'));
52  $select->addOption('', _AM_IMAGES_CAT_SELECT);
53  $select->addOptionArray($categories);
54  $this->addElement($select, true);
55 
56  $this->addElement(new Xoops\Form\File(_AM_IMAGES_IMG_FILE, 'image_file'));
57 
58  $this->addElement(new Xoops\Form\Hidden('image_weight', $obj->getVar('image_weight')));
59  $this->addElement(new Xoops\Form\Hidden('image_display', $obj->getVar('image_display')));
60  $this->addElement(new Xoops\Form\Hidden('image_name', $obj->getVar('image_name')));
61  $this->addElement(new Xoops\Form\Hidden('image_id', $obj->getVar('image_id')));
62  $this->addElement(new Xoops\Form\Hidden('target', $target));
63 
68  $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
69 
70  $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
71  $button->setClass('btn btn-success');
72  $button_tray->addElement($button);
73 
74  $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
75  $button_2->setClass('btn btn-warning');
76  $button_tray->addElement($button_2);
77 
78  switch (basename($xoops->getEnv('PHP_SELF'), '.php')) {
79  case 'xoops_images':
80  $button_3 = new Xoops\Form\Button('', 'button', XoopsLocale::A_CLOSE, 'button');
81  $button_3->setExtra('onclick="tinyMCEPopup.close();"');
82  $button_3->setClass('btn btn-danger');
83  $button_tray->addElement($button_3);
84  break;
85 
86  case 'images':
87  default:
88  $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
89  $button_3->setExtra("onclick='javascript:history.go(-1);'");
90  $button_3->setClass('btn btn-danger');
91  $button_tray->addElement($button_3);
92  break;
93  }
94 
95  $this->addElement($button_tray);
96  }
97 }
setExtra($extra)
Definition: Form.php:374
const A_SUBMIT
Definition: en_US.php:128
const A_RESET
Definition: en_US.php:121
static getInstance()
Definition: Xoops.php:160
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
$button
Definition: xoops_code.php:29
$xoops
Definition: admin.php:25
const _AM_IMAGES_IMG_ADD
Definition: admin.php:59
const A_CLOSE
Definition: en_US.php:87
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
static getHelper($dirname= 'system')
Definition: Helper.php:27
addOption($value, $name= '')
Definition: Select.php:113
$groups
$helper
$button_tray
Definition: xoops_code.php:26
$button_2
Definition: xoops_code.php:34
$button_3
Definition: xoops_code.php:38
$target