XOOPS  2.6.0
ranks.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 
24 {
28  public function __construct(XoopsObject $obj)
29  {
30  if ($obj->isNew()) {
31  $blank_img = 'blank.gif';
32  } else {
33  $blank_img = str_replace('ranks/', '', $obj->getVar('rank_image', 'e'));
34  }
35 
36  $title = $obj->isNew() ? sprintf(_AM_USERRANK_ADD) : sprintf(_AM_USERRANK_EDIT);
37 
38  parent::__construct($title, 'form', 'userrank.php', 'post', true);
39  $this->setExtra('enctype="multipart/form-data"');
40 
41  $this->addElement(new Xoops\Form\Text(_AM_USERRANK_TITLE, 'rank_title', 4, 50, $obj->getVar('rank_title')), true);
42  $min = new Xoops\Form\Text(_AM_USERRANK_MINPOST, 'rank_min', 1, 10, $obj->getVar('rank_min'));
43  $min->setPattern('^\d+$', _AM_USERRANK_ERROR_POST);
44  $this->addElement($min);
45  $max = new Xoops\Form\Text(_AM_USERRANK_MAXPOST, 'rank_max', 1, 10, $obj->getVar('rank_max'));
46  $max->setPattern('^\d+$', _AM_USERRANK_ERROR_POST);
47  $this->addElement($max);
48 
49  $imgtray_img = new Xoops\Form\ElementTray(_AM_USERRANK_IMAGE, '<br />');
50  $imgpath_img = sprintf(_AM_USERRANK_IMAGE_PATH, \XoopsBaseConfig::get('uploads-path') . '/ranks/');
51  $imageselect_img = new Xoops\Form\Select($imgpath_img, 'rank_image', $blank_img);
52  $image_array_img = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('uploads-path') . '/ranks');
53  $imageselect_img->addOption("$blank_img", $blank_img);
54  foreach ($image_array_img as $image_img) {
55  $imageselect_img->addOption("$image_img", $image_img);
56  }
57  $imageselect_img->setExtra("onchange='showImgSelected(\"xo-ranks-img\", \"rank_image\", \"ranks\", \"\", \"" . \XoopsBaseConfig::get('uploads-url') . "\")'");
58  $imgtray_img->addElement($imageselect_img, false);
59  $imgtray_img->addElement(new Xoops\Form\Label('', "<br /><img src='" . \XoopsBaseConfig::get('uploads-url') . "/ranks/" . $blank_img . "' name='image_img' id='xo-ranks-img' alt='' />"));
60 
61  $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
62  $fileseltray_img->addElement(new Xoops\Form\File(_AM_USERRANK_UPLOAD, 'rank_image'), false);
63  $fileseltray_img->addElement(new Xoops\Form\Label(''), false);
64  $imgtray_img->addElement($fileseltray_img);
65  $this->addElement($imgtray_img);
66 
67  if (!$obj->isNew()) {
68  $rank_special = $obj->getVar('rank_special');
69  } else {
70  $rank_special = 0;
71  }
72 
73  $special_tray = new Xoops\Form\ElementTray(_AM_USERRANK_SPECIAL, '<br />');
74  $special_tray->setDescription(_AM_USERRANK_SPECIAL_CAN);
75  $special_tray->addElement(new Xoops\Form\RadioYesNo('', 'rank_special', $rank_special));
76  $this->addElement($special_tray);
77  if (!$obj->isNew()) {
78  $this->addElement(new Xoops\Form\Hidden('rank_id', $obj->getVar('rank_id')));
79  }
80  $this->addElement(new Xoops\Form\Hidden('op', 'userrank_save'));
81  $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
82  }
83 }
const _AM_USERRANK_UPLOAD
Definition: admin.php:38
setExtra($extra)
Definition: Form.php:374
const A_SUBMIT
Definition: en_US.php:128
__construct(XoopsObject $obj)
Definition: ranks.php:28
const _AM_USERRANK_MAXPOST
Definition: admin.php:29
const _AM_USERRANK_ADD
Definition: admin.php:23
const _AM_USERRANK_SPECIAL_CAN
Definition: admin.php:35
addElement(Element $formElement, $required=false)
Definition: Form.php:206
const _AM_USERRANK_MINPOST
Definition: admin.php:30
getVar($key, $format= 's')
const _AM_USERRANK_SPECIAL
Definition: admin.php:34
const _AM_USERRANK_IMAGE
Definition: admin.php:26
const _AM_USERRANK_EDIT
Definition: admin.php:25
const _AM_USERRANK_ERROR_POST
Definition: admin.php:39
static get($name)
const _AM_USERRANK_IMAGE_PATH
Definition: admin.php:27
const _AM_USERRANK_TITLE
Definition: admin.php:37
setPattern($pattern, $pattern_description= '')
Definition: Element.php:310