Exemplo n.º 1
0
 /**
  * @param ProfileRegstep|XoopsObject $obj
  */
 public function __construct(ProfileRegstep &$obj)
 {
     parent::__construct(_PROFILE_AM_STEP, 'stepform', 'step.php', 'post', true);
     if (!$obj->isNew()) {
         $this->addElement(new Xoops\Form\Hidden('id', $obj->getVar('step_id')));
     }
     $this->addElement(new Xoops\Form\Hidden('op', 'save'));
     $this->addElement(new Xoops\Form\Text(_PROFILE_AM_STEPNAME, 'step_name', 5, 255, $obj->getVar('step_name', 'e')), true);
     $this->addElement(new Xoops\Form\Text(_PROFILE_AM_STEPINTRO, 'step_desc', 5, 255, $obj->getVar('step_desc', 'e')));
     $order = new Xoops\Form\Text(_PROFILE_AM_STEPORDER, 'step_order', 1, 10, $obj->getVar('step_order', 'e'), '');
     $order->setPattern('^\\d+$', _PROFILE_AM_ERROR_WEIGHT);
     $this->addElement($order, true);
     $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_STEPSAVE, 'step_save', $obj->getVar('step_save', 'e')));
     $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
 }
Exemplo n.º 2
0
 public function __construct(AvatarsAvatar $obj)
 {
     if ($obj->isNew()) {
         $blank_img = 'blank.gif';
     } else {
         $blank_img = str_replace('avatars/', '', $obj->getVar('avatar_file', 'e'));
     }
     //$xoops = Xoops::getInstance();
     // New and edit form
     $title = $obj->isNew() ? XoopsLocale::A_ADD : XoopsLocale::A_EDIT;
     $action = $_SERVER['REQUEST_URI'];
     parent::__construct($title, 'avatar_form', $action, "post", true);
     $this->setExtra('enctype="multipart/form-data"');
     // Name
     $this->addElement(new Xoops\Form\Text(XoopsLocale::NAME, 'avatar_name', 5, 255, $obj->getVar('avatar_name', 'e')), true);
     // Upload part
     $imgtray_img = new Xoops\Form\ElementTray(XoopsLocale::FILE, '<br />');
     $avatars_path = \XoopsBaseConfig::get('uploads-path') . '/avatars';
     $imageselect_img = new Xoops\Form\Select(sprintf(XoopsLocale::F_FILE_EXISTS_IN, $avatars_path . '/'), 'avatar_file', $blank_img);
     $image_array_img = XoopsLists::getImgListAsArray($avatars_path);
     $imageselect_img->addOption("{$blank_img}", $blank_img);
     foreach ($image_array_img as $image_img) {
         $imageselect_img->addOption("{$image_img}", $image_img);
     }
     $xoops_upload_url = \XoopsBaseConfig::get('uploads-url');
     $imageselect_img->setExtra("onchange='showImgSelected(\"xo-avatar-img\", \"avatar_file\", \"avatars\", \"\", \"" . $xoops_upload_url . "\")'");
     $imgtray_img->addElement($imageselect_img, false);
     $imgtray_img->addElement(new Xoops\Form\Label('', "<br /><img src='" . $xoops_upload_url . "/avatars/" . $blank_img . "' name='image_img' id='xo-avatar-img' alt='' />"));
     $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
     $fileseltray_img->addElement(new Xoops\Form\File(XoopsLocale::A_UPLOAD, 'avatar_file'), false);
     // , $xoops->getModuleConfig('avatars_imagefilesize')
     $imgtray_img->addElement($fileseltray_img);
     $this->addElement($imgtray_img);
     // Weight
     $weight = new Xoops\Form\Text(XoopsLocale::DISPLAY_ORDER, 'avatar_weight', 1, 4, $obj->getVar('avatar_weight', 'e'), '');
     $weight->setPattern('^\\d+$', XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER);
     $this->addElement($weight, true);
     // Display
     $this->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::DISPLAY_THIS_ITEM, 'avatar_display', $obj->getVar('avatar_display', 'e'), XoopsLocale::YES, XoopsLocale::NO));
     // Hidden
     if ($obj->isNew()) {
         $this->addElement(new Xoops\Form\Hidden('avatar_type', 's'));
     }
     $this->addElement(new Xoops\Form\Hidden('op', 'save'));
     $this->addElement(new Xoops\Form\Hidden('avatar_id', $obj->getVar('avatar_id', 'e')));
     // Button
     $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
 }
Exemplo n.º 3
0
 /**
  * @param UserrankRank|XoopsObject $obj
  */
 public function __construct(XoopsObject $obj)
 {
     if ($obj->isNew()) {
         $blank_img = 'blank.gif';
     } else {
         $blank_img = str_replace('ranks/', '', $obj->getVar('rank_image', 'e'));
     }
     $title = $obj->isNew() ? sprintf(_AM_USERRANK_ADD) : sprintf(_AM_USERRANK_EDIT);
     parent::__construct($title, 'form', 'userrank.php', 'post', true);
     $this->setExtra('enctype="multipart/form-data"');
     $this->addElement(new Xoops\Form\Text(_AM_USERRANK_TITLE, 'rank_title', 4, 50, $obj->getVar('rank_title')), true);
     $min = new Xoops\Form\Text(_AM_USERRANK_MINPOST, 'rank_min', 1, 10, $obj->getVar('rank_min'));
     $min->setPattern('^\\d+$', _AM_USERRANK_ERROR_POST);
     $this->addElement($min);
     $max = new Xoops\Form\Text(_AM_USERRANK_MAXPOST, 'rank_max', 1, 10, $obj->getVar('rank_max'));
     $max->setPattern('^\\d+$', _AM_USERRANK_ERROR_POST);
     $this->addElement($max);
     $imgtray_img = new Xoops\Form\ElementTray(_AM_USERRANK_IMAGE, '<br />');
     $imgpath_img = sprintf(_AM_USERRANK_IMAGE_PATH, \XoopsBaseConfig::get('uploads-path') . '/ranks/');
     $imageselect_img = new Xoops\Form\Select($imgpath_img, 'rank_image', $blank_img);
     $image_array_img = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('uploads-path') . '/ranks');
     $imageselect_img->addOption("{$blank_img}", $blank_img);
     foreach ($image_array_img as $image_img) {
         $imageselect_img->addOption("{$image_img}", $image_img);
     }
     $imageselect_img->setExtra("onchange='showImgSelected(\"xo-ranks-img\", \"rank_image\", \"ranks\", \"\", \"" . \XoopsBaseConfig::get('uploads-url') . "\")'");
     $imgtray_img->addElement($imageselect_img, false);
     $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='' />"));
     $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />');
     $fileseltray_img->addElement(new Xoops\Form\File(_AM_USERRANK_UPLOAD, 'rank_image'), false);
     $fileseltray_img->addElement(new Xoops\Form\Label(''), false);
     $imgtray_img->addElement($fileseltray_img);
     $this->addElement($imgtray_img);
     if (!$obj->isNew()) {
         $rank_special = $obj->getVar('rank_special');
     } else {
         $rank_special = 0;
     }
     $special_tray = new Xoops\Form\ElementTray(_AM_USERRANK_SPECIAL, '<br />');
     $special_tray->setDescription(_AM_USERRANK_SPECIAL_CAN);
     $special_tray->addElement(new Xoops\Form\RadioYesNo('', 'rank_special', $rank_special));
     $this->addElement($special_tray);
     if (!$obj->isNew()) {
         $this->addElement(new Xoops\Form\Hidden('rank_id', $obj->getVar('rank_id')));
     }
     $this->addElement(new Xoops\Form\Hidden('op', 'userrank_save'));
     $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
 }
Exemplo n.º 4
0
 /**
  * @param ProfileCategory|XoopsObject $obj
  */
 public function __construct(ProfileCategory &$obj)
 {
     $title = $obj->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_CATEGORY) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_CATEGORY);
     parent::__construct($title, 'form', false, 'post', true);
     $this->addElement(new Xoops\Form\Text(_PROFILE_AM_TITLE, 'cat_title', 5, 255, $obj->getVar('cat_title')), true);
     if (!$obj->isNew()) {
         //Load groups
         $this->addElement(new Xoops\Form\Hidden('id', $obj->getVar('cat_id')));
     }
     $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DESCRIPTION, 'cat_description', $obj->getVar('cat_description', 'e'), 5, 5));
     $weight = new Xoops\Form\Text(_PROFILE_AM_WEIGHT, 'cat_weight', 1, 5, $obj->getVar('cat_weight', 'e'), '');
     $weight->setPattern('^\\d+$', _PROFILE_AM_ERROR_WEIGHT);
     $this->addElement($weight, true);
     $this->addElement(new Xoops\Form\Hidden('op', 'save'));
     $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
 }
Exemplo n.º 5
0
$result['phpsessid_cookie'] = Request::getString('PHPSESSID', '', 'cookie');
$result['ip'] = $request->getClientIp();
$result['isget'] = 'GET' === Request::getMethod();
$result['ispost'] = 'POST' === Request::getMethod();
$result['ismobile'] = $request->is('mobile');
$result['isrobot'] = $request->is('robot');
$result['files'] = Request::getArray('file_identifier', array(), 'files');
\Xoops\Utils::dumpVar($result);
echo '<a href="?id=12&string=I love you&bool=everythingsistrue&order=DESC">Good uri</a>';
echo ' - <a href="?id=test&order=DESCENDING">Bad uri</a>';
// Form
$form = new Xoops\Form\SimpleForm('', 'form_id', 'request.php?id=666', true);
$form->setExtra('enctype="multipart/form-data"');
$code = new Xoops\Form\Text('String', 'string', 2, 25, '', 'string...');
$code->setDescription('Description text');
$code->setPattern('^.{3,}$', 'You need at least 3 characters');
$code->setDatalist(array('list 1', 'list 2', 'list 3'));
$form->addElement($code, true);
$select = new Xoops\Form\Select('Select', 'id', '', 1, false);
$select->addOption(1, 'Select 1');
$select->addOption(2, 'Select 2');
$select->addOption('somebad id here', 'Select with bad id');
$select->setDescription('Description Select');
$select->setClass('span2');
$form->addElement($select, true);
$file = new Xoops\Form\File('File', 'file_identifier');
$file->setDescription('Description File');
$form->addElement($file, true);
$buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
$form->addElement($buttonSubmit);
$form->display();
Exemplo n.º 6
0
 /**
  * @param ProfileField|XoopsObject $obj
  */
 public function __construct(ProfileField $obj)
 {
     $xoops = Xoops::getInstance();
     $title = $obj->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD);
     parent::__construct($title, 'form', '', 'post', true);
     $this->addElement(new Xoops\Form\Text(_PROFILE_AM_TITLE, 'field_title', 5, 255, $obj->getVar('field_title', 'e')), true);
     $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $obj->getVar('field_description', 'e'), 5, 5));
     if (!$obj->isNew()) {
         $fieldcat_id = $obj->getVar('cat_id');
     } else {
         $fieldcat_id = 0;
     }
     $category_handler = $xoops->getModuleHandler('category');
     $cat_select = new Xoops\Form\Select(_PROFILE_AM_CATEGORY, 'field_category', $fieldcat_id);
     $cat_select->addOption(0, _PROFILE_AM_DEFAULT);
     $cat_select->addOptionArray($category_handler->getList());
     $this->addElement($cat_select);
     $weight = new Xoops\Form\Text(_PROFILE_AM_WEIGHT, 'field_weight', 1, 10, $obj->getVar('field_weight', 'e'), '');
     $weight->setPattern('^\\d+$', _PROFILE_AM_ERROR_WEIGHT);
     $this->addElement($weight, true);
     if ($obj->getVar('field_config') || $obj->isNew()) {
         if (!$obj->isNew()) {
             $this->addElement(new Xoops\Form\Label(_PROFILE_AM_NAME, $obj->getVar('field_name')));
             $this->addElement(new Xoops\Form\Hidden('id', $obj->getVar('field_id')));
         } else {
             $this->addElement(new Xoops\Form\Text(_PROFILE_AM_NAME, 'field_name', 5, 255, $obj->getVar('field_name', 'e')), true);
         }
         //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
         $fieldtypes = array('checkbox' => _PROFILE_AM_CHECKBOX, 'date' => _PROFILE_AM_DATE, 'datetime' => _PROFILE_AM_DATETIME, 'longdate' => _PROFILE_AM_LONGDATE, 'group' => _PROFILE_AM_GROUP, 'group_multi' => _PROFILE_AM_GROUPMULTI, 'language' => _PROFILE_AM_LANGUAGE, 'radio' => _PROFILE_AM_RADIO, 'select' => _PROFILE_AM_SELECT, 'select_multi' => _PROFILE_AM_SELECTMULTI, 'textarea' => _PROFILE_AM_TEXTAREA, 'dhtml' => _PROFILE_AM_DHTMLTEXTAREA, 'textbox' => _PROFILE_AM_TEXTBOX, 'timezone' => _PROFILE_AM_TIMEZONE, 'yesno' => _PROFILE_AM_YESNO);
         $element_select = new Xoops\Form\Select(_PROFILE_AM_TYPE, 'field_type', $obj->getVar('field_type', 'e'));
         $element_select->addOptionArray($fieldtypes);
         $this->addElement($element_select);
         switch ($obj->getVar('field_type')) {
             case "textbox":
                 $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                 $type_select = new Xoops\Form\Select(_PROFILE_AM_VALUETYPE, 'field_valuetype', $obj->getVar('field_valuetype', 'e'), 5, 5);
                 $type_select->addOptionArray($valuetypes);
                 $this->addElement($type_select);
                 break;
             case "select":
             case "radio":
                 $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                 $type_select = new Xoops\Form\Select(_PROFILE_AM_VALUETYPE, 'field_valuetype', $obj->getVar('field_valuetype', 'e'));
                 $type_select->addOptionArray($valuetypes);
                 $this->addElement($type_select);
                 break;
         }
         //$this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_NOTNULL, 'field_notnull', $obj->getVar('field_notnull', 'e') ));
         if ($obj->getVar('field_type') == "select" || $obj->getVar('field_type') == "select_multi" || $obj->getVar('field_type') == "radio" || $obj->getVar('field_type') == "checkbox") {
             $options = $obj->getVar('field_options');
             if (count($options) > 0) {
                 $remove_options = new Xoops\Form\Checkbox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions');
                 //$remove_options->columns = 3;
                 asort($options);
                 foreach (array_keys($options) as $key) {
                     $options[$key] .= "[{$key}]";
                 }
                 $remove_options->addOptionArray($options);
                 $this->addElement($remove_options);
             }
             $option_text = "<table  cellspacing='1'><tr><td class='width20'>" . _PROFILE_AM_KEY . "</td><td>" . _PROFILE_AM_VALUE . "</td></tr>";
             for ($i = 0; $i < 3; ++$i) {
                 $option_text .= "<tr><td><input type='text' name='addOption[{$i}][key]' id='addOption[{$i}][key]' size='15' /></td><td><input type='text' name='addOption[{$i}][value]' id='addOption[{$i}][value]' size='35' /></td></tr>";
                 $option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
             }
             $option_text .= "</table>";
             $this->addElement(new Xoops\Form\Label(_PROFILE_AM_ADDOPTION, $option_text));
         }
     }
     if ($obj->getVar('field_edit')) {
         switch ($obj->getVar('field_type')) {
             case "textbox":
             case "textarea":
             case "dhtml":
                 $this->addElement(new Xoops\Form\Text(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 5, 5, $obj->getVar('field_maxlength', 'e')));
                 $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "checkbox":
             case "select_multi":
                 $def_value = $obj->getVar('field_default', 'e') != null ? unserialize($obj->getVar('field_default', 'n')) : null;
                 $element = new Xoops\Form\Select(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true);
                 $options = $obj->getVar('field_options');
                 asort($options);
                 // If options do not include an empty element, then add a blank option to prevent any default selection
                 if (!in_array('', array_keys($options))) {
                     $element->addOption('', XoopsLocale::NONE);
                 }
                 $element->addOptionArray($options);
                 $this->addElement($element);
                 break;
             case "select":
             case "radio":
                 $def_value = $obj->getVar('field_default', 'e') != null ? $obj->getVar('field_default') : null;
                 $element = new Xoops\Form\Select(_PROFILE_AM_DEFAULT, 'field_default', $def_value);
                 $options = $obj->getVar('field_options');
                 asort($options);
                 // If options do not include an empty element, then add a blank option to prevent any default selection
                 if (!in_array('', array_keys($options))) {
                     $element->addOption('', XoopsLocale::NONE);
                 }
                 $element->addOptionArray($options);
                 $this->addElement($element);
                 break;
             case "date":
                 $this->addElement(new Xoops\Form\DateSelect(_PROFILE_AM_DEFAULT, 'field_default', 2, $obj->getVar('field_default', 'e')));
                 break;
             case "longdate":
                 $this->addElement(new Xoops\Form\DateSelect(_PROFILE_AM_DEFAULT, 'field_default', 2, strtotime($obj->getVar('field_default', 'e'))));
                 break;
             case "datetime":
                 $this->addElement(new Xoops\Form\DateTime(_PROFILE_AM_DEFAULT, 'field_default', 2, $obj->getVar('field_default', 'e')));
                 break;
             case "yesno":
                 $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "timezone":
                 $this->addElement(new Xoops\Form\SelectTimeZone(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "language":
                 $this->addElement(new Xoops\Form\SelectLanguage(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "group":
                 $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $obj->getVar('field_default', 'e')));
                 break;
             case "group_multi":
                 $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, unserialize($obj->getVar('field_default', 'n')), 5, true));
                 break;
             case "theme":
                 $this->addElement(new Xoops\Form\SelectTheme(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "autotext":
                 $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
         }
     }
     $groupperm_handler = $xoops->getHandlerGroupperm();
     $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language');
     if (in_array($obj->getVar('field_type'), $searchable_types)) {
         $search_groups = $groupperm_handler->getGroupIds('profile_search', $obj->getVar('field_id'), $xoops->module->getVar('mid'));
         $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_PROF_SEARCH, 'profile_search', true, $search_groups, 5, true));
     }
     if ($obj->getVar('field_edit') || $obj->isNew()) {
         if (!$obj->isNew()) {
             //Load groups
             $editable_groups = $groupperm_handler->getGroupIds('profile_edit', $obj->getVar('field_id'), $xoops->module->getVar('mid'));
         } else {
             $editable_groups = array();
         }
         $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_PROF_EDITABLE, 'profile_edit', false, $editable_groups, 5, true));
         $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_REQUIRED, 'field_required', $obj->getVar('field_required', 'e')));
         $regstep_select = new Xoops\Form\Select(_PROFILE_AM_PROF_REGISTER, 'step_id', $obj->getVar('step_id', 'e'));
         $regstep_select->addOption(0, XoopsLocale::NO);
         $regstep_handler = $xoops->getModuleHandler('regstep');
         $regstep_select->addOptionArray($regstep_handler->getList());
         $this->addElement($regstep_select);
     }
     $this->addElement(new Xoops\Form\Hidden('op', 'save'));
     $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
 }
Exemplo n.º 7
0
 /**
  * @param PagePage_content|XoopsObject $obj
  */
 public function __construct(PagePage_content $obj)
 {
     $helper = Page::getInstance();
     $xoops = $helper->xoops();
     $xoops->theme()->addStylesheet('modules/page/css/styles.css');
     $title = $obj->isNew() ? PageLocale::A_ADD_CONTENT : PageLocale::A_EDIT_CONTENT;
     parent::__construct($title, 'form', 'content.php', 'post', true, 'raw');
     $tabTray = new Xoops\Form\TabTray('', 'uniqueid');
     /**
      * Main
      */
     $tab1 = new Xoops\Form\Tab(PageLocale::TAB_MAIN, 'main');
     //Author
     //        if ($helper->isUserAdmin()) {
     $content_author = $obj->isNew() ? $xoops->user->getVar('uid') : $obj->getVar('content_author');
     $tab1->addElement(new Xoops\Form\SelectUser(XoopsLocale::AUTHOR, 'content_author', true, $content_author, 1, false), true);
     //        }
     //date
     $tab1->addElement(new Xoops\Form\DateTime(XoopsLocale::DATE, 'content_create', $obj->getVar('content_create')));
     //title
     $tab1->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'content_title', 12, 255, $obj->getVar('content_title'), ''), true);
     // editor
     $editor_configs = array();
     $editor_configs['editor'] = $helper->getConfig('page_editor');
     $editor_configs['rows'] = 12;
     $editor_configs['cols'] = 12;
     //short text
     $editor_configs['name'] = 'content_shorttext';
     $editor_configs['value'] = $obj->getVar('content_shorttext', 'e');
     $tab1->addElement(new Xoops\Form\Editor(XoopsLocale::SHORT_TEXT, 'content_shorttext', $editor_configs), true);
     //text
     $editor_configs['name'] = 'content_text';
     $editor_configs['value'] = $obj->getVar('content_text', 'e');
     $text = new Xoops\Form\Editor(XoopsLocale::TEXT, 'content_text', $editor_configs);
     $text->setDescription(PageLocale::CONTENT_TEXT_DESC);
     $tab1->addElement($text, false);
     //Weight
     $weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'content_weight', 1, 5, $obj->getVar('content_weight'), '');
     $weight->setPattern('^\\d+$', PageLocale::E_WEIGHT);
     $tab1->addElement($weight, true);
     $tabTray->addElement($tab1);
     /**
      * Metas
      */
     $tab2 = new Xoops\Form\Tab(PageLocale::TAB_METAS, 'metas');
     //content_mkeyword
     $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_KEYWORDS, 'content_mkeyword', $obj->getVar('content_mkeyword'), 1, 11, PageLocale::CONTENT_META_KEYWORDS_DSC));
     //content_mdescription
     $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_DESCRIPTION, 'content_mdescription', $obj->getVar('content_mdescription'), 5, 11));
     $tabTray->addElement($tab2);
     /**
      * Options
      */
     $tab3 = new Xoops\Form\Tab(PageLocale::TAB_OPTIONS, 'options');
     //Options
     $content_option = $obj->getOptions();
     $checkbox = new Xoops\Form\Checkbox(XoopsLocale::OPTIONS, 'content_option', $content_option, false);
     $checkbox->setDescription(PageLocale::CONTENT_OPTIONS_DSC);
     foreach ($obj->options as $option) {
         $checkbox->addOption($option, \Xoops\Locale::translate('L_CONTENT_DO' . strtoupper($option), 'page'));
     }
     $tab3->addElement($checkbox);
     //maindisplay
     $tab3->addElement(new Xoops\Form\RadioYesNo(PageLocale::Q_ON_MAIN_PAGE, 'content_maindisplay', $obj->getVar('content_maindisplay')));
     //active
     $tab3->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::ACTIVE, 'content_status', $obj->getVar('content_status')));
     $tabTray->addElement($tab3);
     /**
      * Permissions
      */
     if ($helper->isUserAdmin()) {
         $tab4 = new Xoops\Form\Tab(PageLocale::TAB_PERMISSIONS, 'permissions');
         //permissions
         $group_list = $xoops->getHandlerMember()->getGroupList();
         $full_list = array_keys($group_list);
         if (!$obj->isNew()) {
             $module_id = $helper->getModule()->getVar('mid', 'n');
             $groups_ids_view = $helper->getGrouppermHandler()->getGroupIds('page_view_item', $obj->getVar('content_id'), $module_id);
             $groups_ids_view = array_values($groups_ids_view);
             $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $groups_ids_view, false);
         } else {
             $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $full_list, false);
         }
         $groups_can_view_checkbox->addOptionArray($group_list);
         $tab4->addElement($groups_can_view_checkbox);
         $tabTray->addElement($tab4);
     }
     $this->addElement($tabTray);
     $this->addElement(new Xoops\Form\Hidden('content_id', $obj->getVar('content_id')));
     /**
      * Buttons
      */
     $buttonTray = new Xoops\Form\ElementTray('', '');
     $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save'));
     $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
     $buttonSubmit->setClass('btn btn-success');
     $buttonTray->addElement($buttonSubmit);
     $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
     $buttonReset->setClass('btn btn-warning');
     $buttonTray->addElement($buttonReset);
     $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
     $buttonCancel->setExtra("onclick='javascript:history.go(-1);'");
     $buttonCancel->setClass('btn btn-danger');
     $buttonTray->addElement($buttonCancel);
     $this->addElement($buttonTray);
 }
Exemplo n.º 8
0
 /**
  * getForm - get block edit form
  *
  * @param string $mode mode for form, edit or clone
  *
  * @return void
  */
 public function getForm($mode = 'edit')
 {
     $xoops = Xoops::getInstance();
     $xoops->loadLanguage('blocks', 'system');
     if ($this->obj->isNew()) {
         $title = SystemLocale::ADD_BLOCK;
         $modules = array(-1);
         $groups = array(FixedGroups::USERS, FixedGroups::ANONYMOUS, FixedGroups::ADMIN);
         $this->obj->setVar('block_type', 'C');
         $this->obj->setVar('visible', 1);
         $op = 'save';
     } else {
         $title = '';
         $modules = array();
         // Search modules
         $blockmodulelink_handler = $xoops->getHandlerBlockmodulelink();
         $criteria = new CriteriaCompo(new Criteria('block_id', $this->obj->getVar('bid')));
         $blockmodulelink = $blockmodulelink_handler->getObjects($criteria);
         /* @var $link XoopsBlockmodulelink */
         foreach ($blockmodulelink as $link) {
             $modules[] = $link->getVar('module_id');
         }
         // Search perms
         $groupperm_handler = $xoops->getHandlerGroupperm();
         $groups = $groupperm_handler->getGroupIds('block_read', $this->obj->getVar('bid'));
         switch ($mode) {
             case 'edit':
                 $title = SystemLocale::EDIT_BLOCK;
                 break;
             case 'clone':
                 $title = SystemLocale::CLONE_BLOCK;
                 $this->obj->setVar('bid', 0);
                 if ($this->obj->isCustom()) {
                     $this->obj->setVar('block_type', 'C');
                 } else {
                     $this->obj->setVar('block_type', 'D');
                 }
                 break;
         }
         $op = 'save';
     }
     parent::__construct($title, 'blockform', 'admin.php', 'post', true);
     if (!$this->obj->isNew()) {
         $this->addElement(new Xoops\Form\Label(XoopsLocale::NAME, $this->obj->getVar('name')));
     }
     // Side position
     $side_select = new Xoops\Form\Select(XoopsLocale::SIDE, 'side', $this->obj->getVar('side'));
     $side_select->addOptionArray(array(0 => XoopsLocale::LEFT, 1 => XoopsLocale::RIGHT, 3 => SystemLocale::TOP_LEFT, 4 => SystemLocale::TOP_RIGHT, 5 => SystemLocale::TOP_CENTER, 7 => SystemLocale::BOTTOM_LEFT, 8 => SystemLocale::BOTTOM_RIGHT, 9 => SystemLocale::BOTTOM_CENTER));
     $this->addElement($side_select);
     // Order
     $weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'weight', 1, 5, $this->obj->getVar('weight'), '');
     $weight->setPattern('^\\d+$', XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER);
     $this->addElement($weight, true);
     // Display
     $this->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::VISIBLE, 'visible', $this->obj->getVar('visible')));
     // Visible In
     $mod_select = new Xoops\Form\Select(XoopsLocale::VISIBLE_IN, 'modules', $modules, 5, true);
     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
     $criteria->add(new Criteria('isactive', 1));
     $module_list = $xoops->getHandlerModule()->getNameList($criteria);
     $module_list[-1] = XoopsLocale::TOP_PAGE;
     $module_list[0] = XoopsLocale::ALL_PAGES;
     ksort($module_list);
     $mod_select->addOptionArray($module_list);
     $this->addElement($mod_select);
     // Title
     $this->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'title', 5, 255, $this->obj->getVar('title')), false);
     if ($this->obj->isNew() || $this->obj->isCustom()) {
         $editor_configs = array();
         $editor_configs["name"] = "content_block";
         $editor_configs["value"] = $this->obj->getVar('content', 'e');
         $editor_configs["rows"] = 15;
         $editor_configs["cols"] = 6;
         $editor_configs["editor"] = $xoops->getModuleConfig('blocks_editor', 'system');
         $this->addElement(new Xoops\Form\Editor(XoopsLocale::CONTENT, "content_block", $editor_configs), true);
         if (in_array($editor_configs["editor"], array('dhtmltextarea', 'textarea'))) {
             $ctype_select = new Xoops\Form\Select(SystemLocale::CONTENT_TYPE, 'c_type', $this->obj->getVar('c_type'));
             $ctype_select->addOptionArray(array('H' => XoopsLocale::HTML, 'P' => SystemLocale::PHP_SCRIPT, 'S' => SystemLocale::AUTO_FORMAT_SMILIES_ENABLED, 'T' => SystemLocale::AUTO_FORMAT_SMILIES_DISABLED));
             $this->addElement($ctype_select);
         } else {
             $this->addElement(new Xoops\Form\Hidden('c_type', 'H'));
         }
     } else {
         if ($this->obj->getVar('template') != '') {
             $tplfile_handler = $xoops->getHandlerTplfile();
             $btemplate = $tplfile_handler->find($xoops->getConfig('template_set'), 'block', $this->obj->getVar('bid'));
             if (count($btemplate) > 0) {
                 $this->addElement(new Xoops\Form\Label(XoopsLocale::CONTENT, '<a href="' . \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
             } else {
                 $btemplate2 = $tplfile_handler->find('default', 'block', $this->obj->getVar('bid'));
                 if (count($btemplate2) > 0) {
                     $this->addElement(new Xoops\Form\Label(XoopsLocale::CONTENT, '<a href="' . \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" rel="external">' . SystemLocale::EDIT_TEMPLATE . '</a>'));
                 }
             }
         }
         if ($this->obj->getOptions() != false) {
             $this->addElement(new Xoops\Form\Label(XoopsLocale::OPTIONS, $this->obj->getOptions()));
         } else {
             $this->addElement(new Xoops\Form\Hidden('options', $this->obj->getVar('options')));
         }
         $this->addElement(new Xoops\Form\Hidden('c_type', 'H'));
     }
     $cache_select = new Xoops\Form\Select(SystemLocale::CACHE_LIFETIME, 'bcachetime', $this->obj->getVar('bcachetime'));
     $cache_select->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH));
     $this->addElement($cache_select);
     // Groups
     $this->addElement(new Xoops\Form\SelectGroup(XoopsLocale::GROUPS, 'groups', true, $groups, 5, true));
     $this->addElement(new Xoops\Form\Hidden('block_type', $this->obj->getVar('block_type')));
     $this->addElement(new Xoops\Form\Hidden('mid', $this->obj->getVar('mid')));
     $this->addElement(new Xoops\Form\Hidden('func_num', $this->obj->getVar('func_num')));
     $this->addElement(new Xoops\Form\Hidden('func_file', $this->obj->getVar('func_file')));
     $this->addElement(new Xoops\Form\Hidden('show_func', $this->obj->getVar('show_func')));
     $this->addElement(new Xoops\Form\Hidden('edit_func', $this->obj->getVar('edit_func')));
     $this->addElement(new Xoops\Form\Hidden('template', $this->obj->getVar('template')));
     $this->addElement(new Xoops\Form\Hidden('dirname', $this->obj->getVar('dirname')));
     $this->addElement(new Xoops\Form\Hidden('name', $this->obj->getVar('name')));
     $this->addElement(new Xoops\Form\Hidden('bid', $this->obj->getVar('bid')));
     $this->addElement(new Xoops\Form\Hidden('op', $op));
     $this->addElement(new Xoops\Form\Hidden('fct', 'blocksadmin'));
     $button_tray = new Xoops\Form\ElementTray('', '&nbsp;');
     if ($this->obj->isNew() || $this->obj->isCustom()) {
         $preview = new Xoops\Form\Button('', 'previewblock', XoopsLocale::A_PREVIEW, 'preview');
         $preview->setExtra("onclick=\"blocks_preview();\"");
         $button_tray->addElement($preview);
     }
     $button_tray->addElement(new Xoops\Form\Button('', 'submitblock', XoopsLocale::A_SUBMIT, 'submit'));
     $this->addElement($button_tray);
 }