Example #1
0
 /**
  * @param ImagesImage|XoopsObject $obj
  */
 public function __construct(ImagesImage $obj)
 {
     $xoops = Xoops::getInstance();
     $helper = Xoops\Module\Helper::getHelper('images');
     $groups = $xoops->getUserGroups();
     if ($obj->isNew()) {
         $title = _AM_IMAGES_IMG_ADD;
     } else {
         $title = _AM_IMAGES_IMG_EDIT;
     }
     parent::__construct('', 'image', $xoops->getEnv('PHP_SELF'), 'post', true);
     $this->setExtra('enctype="multipart/form-data"');
     $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
     $tab1 = new Xoops\Form\Tab($title, 'tabid-1');
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_NAME, 'image_nicename', 50, 255, $obj->getVar('image_nicename')), true);
     if ($obj->isNew()) {
         $categories = $helper->getHandlerCategories()->getListByPermission($groups, 'imgcat_write');
         $select = new Xoops\Form\Select(_AM_IMAGES_CAT_SELECT, 'imgcat_id', $obj->getVar('imgcat_id'));
         $select->addOption('', _AM_IMAGES_CAT_SELECT);
         $select->addOptionArray($categories);
         $tab1->addElement($select, true);
     } else {
         $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>'));
         $this->addElement(new Xoops\Form\Hidden('imgcat_id', $obj->getVar('imgcat_id')));
     }
     // warning
     $category = $helper->getHandlerCategories()->get($obj->getVar('imgcat_id'));
     $upload_msg[] = _AM_IMAGES_CAT_SIZE . ' : ' . $category->getVar('imgcat_maxsize');
     $upload_msg[] = _AM_IMAGES_CAT_WIDTH . ' : ' . $category->getVar('imgcat_maxwidth');
     $upload_msg[] = _AM_IMAGES_CAT_HEIGHT . ' : ' . $category->getVar('imgcat_maxheight');
     $image_tray = new Xoops\Form\File(_AM_IMAGES_IMG_FILE, 'image_file');
     $image_tray->setDescription(self::message($upload_msg, ''));
     $tab1->addElement($image_tray);
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_WEIGHT, 'image_weight', 1, 4, $obj->getVar('image_weight')));
     $tab1->addElement(new Xoops\Form\RadioYesNo(_AM_IMAGES_DISPLAY, 'image_display', $obj->getVar('image_display')));
     $tabtray->addElement($tab1);
     $this->addElement($tabtray);
     $this->addElement(new Xoops\Form\Hidden('image_name', $obj->getVar('image_name')));
     $this->addElement(new Xoops\Form\Hidden('image_id', $obj->getVar('image_id')));
     /**
      * Buttons
      */
     $button_tray = new Xoops\Form\ElementTray('', '');
     $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
     $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
     $button->setClass('btn btn-success');
     $button_tray->addElement($button);
     $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
     $button_2->setClass('btn btn-warning');
     $button_tray->addElement($button_2);
     $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
     $button_3->setExtra("onclick='javascript:history.go(-1);'");
     $button_3->setClass('btn btn-danger');
     $button_tray->addElement($button_3);
     $this->addElement($button_tray);
 }
Example #2
0
 /**
  * @param ImagesCategory|XoopsObject $obj
  */
 public function __construct(ImagesCategory $obj)
 {
     $xoops = Xoops::getInstance();
     $perm_handler = $xoops->getHandlerGroupperm();
     if ($obj->isNew()) {
         $title = _AM_IMAGES_CAT_ADD;
         $read = FixedGroups::ADMIN;
         $write = FixedGroups::ADMIN;
     } else {
         $title = _AM_IMAGES_CAT_EDIT;
         $read = $perm_handler->getGroupIds('imgcat_read', $obj->getVar('imgcat_id'), $xoops->module->getVar('mid'));
         $write = $perm_handler->getGroupIds('imgcat_write', $obj->getVar('imgcat_id'), $xoops->module->getVar('mid'));
     }
     parent::__construct($title, 'imagecat_form', $xoops->getEnv('PHP_SELF'), 'post', true);
     $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
     $tab1 = new Xoops\Form\Tab(_MI_IMAGES_CATEGORIES, 'tabid-1');
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_NAME, 'imgcat_name', 50, 255, $obj->getVar('imgcat_name')), true);
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_SIZE, 'imgcat_maxsize', 2, 8, $obj->getVar('imgcat_maxsize')));
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_WIDTH, 'imgcat_maxwidth', 1, 4, $obj->getVar('imgcat_maxwidth')));
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_HEIGHT, 'imgcat_maxheight', 1, 4, $obj->getVar('imgcat_maxheight')));
     $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_WEIGHT, 'imgcat_weight', 1, 5, $obj->getVar('imgcat_weight')));
     $tab1->addElement(new Xoops\Form\RadioYesNo(_AM_IMAGES_CAT_DISPLAY, 'imgcat_display', $obj->getVar('imgcat_display')));
     if ($obj->isNew()) {
         $store = new Xoops\Form\Radio(_AM_IMAGES_CAT_STR_TYPE . '<div class="red">' . _AM_IMAGES_CAT_STR_TYOPENG . '</div>', 'imgcat_storetype', 'file');
         $store->addOptionArray(array('file' => _AM_IMAGES_CAT_ASFILE, 'db' => _AM_IMAGES_CAT_INDB));
         $tab1->addElement($store);
     } else {
         $store = array('db' => _AM_IMAGES_CAT_INDB, 'file' => _AM_IMAGES_CAT_ASFILE);
         $tab1->addElement(new Xoops\Form\Label(_AM_IMAGES_CAT_STR_TYPE, $store[$obj->getVar('imgcat_storetype')]));
         $this->addElement(new Xoops\Form\Hidden('imgcat_storetype', $obj->getVar('imgcat_storetype')));
     }
     $tab2 = new Xoops\Form\Tab(_MI_IMAGES_PERMISSIONS, 'tabid-2');
     $tab2->addElement(new Xoops\Form\SelectGroup(_AM_IMAGES_CAT_READ_GRP, 'readgroup', true, $read, 5, true));
     $tab2->addElement(new Xoops\Form\SelectGroup(_AM_IMAGES_CAT_WRITE_GRP, 'writegroup', true, $write, 5, true));
     $tabtray->addElement($tab1);
     $tabtray->addElement($tab2);
     $this->addElement($tabtray);
     $this->addElement(new Xoops\Form\Hidden('imgcat_id', $obj->getVar('imgcat_id')));
     /**
      * Buttons
      */
     $button_tray = new Xoops\Form\ElementTray('', '');
     $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
     $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
     $button->setClass('btn btn-success');
     $button_tray->addElement($button);
     $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
     $button_2->setClass('btn btn-warning');
     $button_tray->addElement($button_2);
     $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
     $button_3->setExtra("onclick='javascript:history.go(-1);'");
     $button_3->setClass('btn btn-danger');
     $button_tray->addElement($button_3);
     $this->addElement($button_tray);
 }
Example #3
0
 /**
  * @param array       $obj
  * @param XoopsModule $mod
  */
 public function getForm(&$obj, XoopsModule $mod)
 {
     $xoops = Xoops::getInstance();
     $helper = Userconfigs::getInstance();
     $config_handler = $helper->getHandlerConfig();
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true);
         if ($mod->getVar('dirname') != 'system') {
             $xoops->loadLanguage('modinfo', $mod->getVar('dirname'));
             $xoops->loadLocale($mod->getVar('dirname'));
         }
         $configs = $plugin->configs();
         $configNames = array();
         foreach (array_keys($configs) as $i) {
             $configNames[$configs[$i]['name']] =& $configs[$i];
         }
         $configCats = $plugin->categories();
         if (!$configCats) {
             $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''));
         }
         if (!in_array('default', array_keys($configCats))) {
             $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '');
         }
         foreach (array_keys($configNames) as $name) {
             if (!isset($configNames[$name]['category'])) {
                 $configNames[$name]['category'] = 'default';
             }
         }
         $tabtray = new Xoops\Form\TabTray('', 'pref_tabtay', $xoops->getModuleConfig('jquery_theme', 'system'));
         $tabs = array();
         foreach ($configCats as $name => $info) {
             $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name);
             if (isset($info['description']) && $info['description'] != '') {
                 $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description']));
             }
         }
         $count = count($obj);
         for ($i = 0; $i < $count; ++$i) {
             $title = Xoops_Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname'));
             $desc = $obj[$i]->getVar('conf_desc') != '' ? Xoops_Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : '';
             switch ($obj[$i]->getVar('conf_formtype')) {
                 case 'textarea':
                     $myts = MyTextSanitizer::getInstance();
                     if ($obj[$i]->getVar('conf_valuetype') == 'array') {
                         // this is exceptional.. only when value type is arrayneed a smarter way for this
                         $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5);
                     } else {
                         $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5);
                     }
                     break;
                 case 'select':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'select_multi':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'yesno':
                     $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'theme':
                 case 'theme_multi':
                     $ele = $obj[$i]->getVar('conf_formtype') != 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $dirlist = XoopsLists::getThemesList();
                     if (!empty($dirlist)) {
                         asort($dirlist);
                         $ele->addOptionArray($dirlist);
                     }
                     break;
                 case 'tplset':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $tplset_handler = $xoops->getHandlerTplSet();
                     $tplsetlist = $tplset_handler->getNameList();
                     asort($tplsetlist);
                     foreach ($tplsetlist as $key => $name) {
                         $ele->addOption($key, $name);
                     }
                     break;
                 case 'cpanel':
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     /*
                                             $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
                                             XoopsLoad::load("cpanel", "system");
                                             $list = XoopsSystemCpanel::getGuis();
                                             $ele->addOptionArray($list);  */
                     break;
                 case 'timezone':
                     $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'language':
                     $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'locale':
                     $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'startpage':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $module_handler = $xoops->getHandlerModule();
                     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
                     $criteria->add(new Criteria('isactive', 1));
                     $moduleslist = $module_handler->getNameList($criteria, true);
                     $moduleslist['--'] = XoopsLocale::NONE;
                     $ele->addOptionArray($moduleslist);
                     break;
                 case 'group':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'group_multi':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                     // RMV-NOTIFY: added 'user' and 'user_multi'
                 // RMV-NOTIFY: added 'user' and 'user_multi'
                 case 'user':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'user_multi':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                 case 'module_cache':
                     $module_handler = $xoops->getHandlerModule();
                     $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true);
                     $currrent_val = $obj[$i]->getConfValueForOutput();
                     $cache_options = 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);
                     if (count($modules) > 0) {
                         $ele = new Xoops\Form\ElementTray($title, '<br />');
                         foreach (array_keys($modules) as $mid) {
                             $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null;
                             $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val);
                             $selform->addOptionArray($cache_options);
                             $ele->addElement($selform);
                             unset($selform);
                         }
                     } else {
                         $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE);
                     }
                     break;
                 case 'site_cache':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $ele->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));
                     break;
                 case 'password':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'color':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'hidden':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'textbox':
                 default:
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
             }
             $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id'));
             if (isset($ele)) {
                 $ele->setDescription($desc);
                 if ($obj[$i]->getVar('conf_formtype') != 'hidden') {
                     $name = 'default';
                     if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) {
                         $name = $configNames[$obj[$i]->getVar('conf_name')]['category'];
                     }
                     $tabs[$name]->addElement($ele);
                 } else {
                     $this->addElement($ele);
                 }
                 $this->addElement($hidden);
                 unset($ele);
                 unset($hidden);
             }
         }
         foreach (array_keys($tabs) as $name) {
             if ($tabs[$name]->getElements()) {
                 $tabtray->addElement($tabs[$name]);
             }
         }
         $this->addElement($tabtray);
         $this->addElement(new Xoops\Form\Hidden('op', 'save'));
         $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid')));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Example #4
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);
 }
Example #5
0
    /**
     * @param PublisherItem $obj
     */
    public function __construct(PublisherItem $obj)
    {
        $xoops = Xoops::getInstance();
        $publisher = Publisher::getInstance();
        $allowed_editors = PublisherUtils::getEditors($publisher->getPermissionHandler()->getGrantedItems('editors'));
        $group = $xoops->getUserGroups();
        parent::__construct('title', 'form', $xoops->getEnv('PHP_SELF'));
        $this->setExtra('enctype="multipart/form-data"');
        $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
        $mainTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_MAIN, 'maintab');
        // Category
        $category_select = new Xoops\Form\Select(_CO_PUBLISHER_CATEGORY, 'categoryid', $obj->getVar('categoryid', 'e'));
        $category_select->setDescription(_CO_PUBLISHER_CATEGORY_DSC);
        $category_select->addOptionArray($publisher->getCategoryHandler()->getCategoriesForSubmit());
        $mainTab->addElement($category_select);
        // ITEM TITLE
        $mainTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_TITLE, 'title', 50, 255, $obj->getVar('title', 'e')), true);
        // SUBTITLE
        if ($this->_isGranted(_PUBLISHER_SUBTITLE)) {
            $mainTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_SUBTITLE, 'subtitle', 50, 255, $obj->getVar('subtitle', 'e')));
        }
        // SHORT URL
        if ($this->_isGranted(_PUBLISHER_ITEM_SHORT_URL)) {
            $text_short_url = new Xoops\Form\Text(_CO_PUBLISHER_ITEM_SHORT_URL, 'item_short_url', 50, 255, $obj->getVar('short_url', 'e'));
            $text_short_url->setDescription(_CO_PUBLISHER_ITEM_SHORT_URL_DSC);
            $mainTab->addElement($text_short_url);
        }
        // TAGS
        if ($xoops->isActiveModule('tag') && $this->_isGranted(_PUBLISHER_ITEM_TAG)) {
            include_once \XoopsBaseConfig::get('root-path') . '/modules/tag/include/formtag.php';
            $text_tags = new Xoops\Form\Tag('item_tag', 60, 255, $obj->getVar('item_tag', 'e'), 0);
            $mainTab->addElement($text_tags);
        }
        // SELECT EDITOR
        $nohtml = false;
        if (count($allowed_editors) == 1) {
            $editor = $allowed_editors[0];
        } else {
            if (count($allowed_editors) > 0) {
                $editor = @$_POST['editor'];
                if (!empty($editor)) {
                    PublisherUtils::setCookieVar('publisher_editor', $editor);
                } else {
                    $editor = PublisherUtils::getCookieVar('publisher_editor');
                    if (empty($editor) && $xoops->isUser()) {
                        $editor = $xoops->user->getVar('publisher_editor');
                        // Need set through user profile
                    }
                }
                $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $publisher->getConfig('submit_editor') : $editor;
                $form_editor = new Xoops\Form\SelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors);
                $mainTab->addElement($form_editor);
            } else {
                $editor = $publisher->getConfig('submit_editor');
            }
        }
        $editor_configs = array();
        $editor_configs["rows"] = !$publisher->getConfig('submit_editor_rows') ? 35 : $publisher->getConfig('submit_editor_rows');
        $editor_configs["cols"] = !$publisher->getConfig('submit_editor_cols') ? 60 : $publisher->getConfig('submit_editor_cols');
        $editor_configs["width"] = !$publisher->getConfig('submit_editor_width') ? "100%" : $publisher->getConfig('submit_editor_width');
        $editor_configs["height"] = !$publisher->getConfig('submit_editor_height') ? "400px" : $publisher->getConfig('submit_editor_height');
        // SUMMARY
        if ($this->_isGranted(_PUBLISHER_SUMMARY)) {
            // Description
            //$summary_text = new Xoops\Form\TextArea(_CO_PUBLISHER_SUMMARY, 'summary', $obj->getVar('summary', 'e'), 7, 60);
            $editor_configs["name"] = "summary";
            $editor_configs["value"] = $obj->getVar('summary', 'e');
            $summary_text = new Xoops\Form\Editor(_CO_PUBLISHER_SUMMARY, $editor, $editor_configs, $nohtml, $onfailure = null);
            $summary_text->setDescription(_CO_PUBLISHER_SUMMARY_DSC);
            $mainTab->addElement($summary_text);
        }
        // BODY
        $editor_configs["name"] = "body";
        $editor_configs["value"] = $obj->getVar('body', 'e');
        $body_text = new Xoops\Form\Editor(_CO_PUBLISHER_BODY, $editor, $editor_configs, $nohtml, $onfailure = null);
        $body_text->setDescription(_CO_PUBLISHER_BODY_DSC);
        $mainTab->addElement($body_text);
        // VARIOUS OPTIONS
        if ($this->_isGranted(_PUBLISHER_DOHTML) || $this->_isGranted(_PUBLISHER_DOSMILEY) || $this->_isGranted(_PUBLISHER_DOXCODE) || $this->_isGranted(_PUBLISHER_DOIMAGE) || $this->_isGranted(_PUBLISHER_DOLINEBREAK)) {
            if ($this->_isGranted(_PUBLISHER_DOHTML)) {
                $html_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOHTML, 'dohtml', $obj->getVar('dohtml'));
                $mainTab->addElement($html_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOSMILEY)) {
                $smiley_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOSMILEY, 'dosmiley', $obj->getVar('dosmiley'));
                $mainTab->addElement($smiley_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOXCODE)) {
                $xcode_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOXCODE, 'doxcode', $obj->getVar('doxcode'));
                $mainTab->addElement($xcode_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOIMAGE)) {
                $image_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOIMAGE, 'doimage', $obj->getVar('doimage'));
                $mainTab->addElement($image_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOLINEBREAK)) {
                $linebreak_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOLINEBREAK, 'dolinebreak', $obj->getVar('dobr'));
                $mainTab->addElement($linebreak_radio);
            }
        }
        // Available pages to wrap
        if ($this->_isGranted(_PUBLISHER_AVAILABLE_PAGE_WRAP)) {
            $wrap_pages = XoopsLists::getHtmlListAsArray(PublisherUtils::getUploadDir(true, 'content'));
            $available_wrap_pages_text = array();
            foreach ($wrap_pages as $page) {
                $available_wrap_pages_text[] = "<span onclick='publisherPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>";
            }
            $available_wrap_pages = new Xoops\Form\Label(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP, implode(', ', $available_wrap_pages_text));
            $available_wrap_pages->setDescription(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP_DSC);
            $mainTab->addElement($available_wrap_pages);
        }
        // Uid
        /*  We need to retrieve the users manually because for some reason, on the frxoops.org server,
            the method users::getobjects encounters a memory error
            */
        // Trabis : well, maybe is because you are getting 6000 objects into memory , no??? LOL
        if ($this->_isGranted(_PUBLISHER_UID)) {
            $uid_select = new Xoops\Form\SelectUser(_CO_PUBLISHER_UID, 'uid', true, array($obj->getVar('uid', 'e')), 1, false);
            $uid_select->setDescription(_CO_PUBLISHER_UID_DSC);
            //$sql = "SELECT uid, uname FROM " . $obj->db->prefix('users') . " ORDER BY uname ASC";
            //$result = $obj->db->query($sql);
            //$users_array = array();
            //$users_array[0] = $xoops->getConfig('anonymous');
            //while ($myrow = $obj->db->fetchArray($result)) {
            //    $users_array[$myrow['uid']] = $myrow['uname'];
            //}
            //$uid_select->addOptionArray($users_array);
            $mainTab->addElement($uid_select);
        }
        /* else {
           $hidden = new Xoops\Form\Hidden('uid', $obj->getVar('uid'));
           $this->addElement($hidden);
           unset($hidden);
           }*/
        // Author Alias
        if ($this->_isGranted(_PUBLISHER_AUTHOR_ALIAS)) {
            $element = new Xoops\Form\Text(_CO_PUBLISHER_AUTHOR_ALIAS, 'author_alias', 50, 255, $obj->getVar('author_alias', 'e'));
            $element->setDescription(_CO_PUBLISHER_AUTHOR_ALIAS_DSC);
            $mainTab->addElement($element);
            unset($element);
        }
        // STATUS
        if ($this->_isGranted(_PUBLISHER_STATUS)) {
            $options = array(_PUBLISHER_STATUS_PUBLISHED => _CO_PUBLISHER_PUBLISHED, _PUBLISHER_STATUS_OFFLINE => _CO_PUBLISHER_OFFLINE, _PUBLISHER_STATUS_SUBMITTED => _CO_PUBLISHER_SUBMITTED, _PUBLISHER_STATUS_REJECTED => _CO_PUBLISHER_REJECTED);
            $status_select = new Xoops\Form\Select(_CO_PUBLISHER_STATUS, 'status', $obj->getVar('status'));
            $status_select->addOptionArray($options);
            $status_select->setDescription(_CO_PUBLISHER_STATUS_DSC);
            $mainTab->addElement($status_select);
            unset($status_select);
        }
        // Datesub
        if ($this->_isGranted(_PUBLISHER_DATESUB)) {
            $datesub = $obj->getVar('datesub') == 0 ? time() : $obj->getVar('datesub');
            $datesub_datetime = new PublisherFormDateTime(_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub);
            $datesub_datetime->setDescription(_CO_PUBLISHER_DATESUB_DSC);
            $mainTab->addElement($datesub_datetime);
        }
        // NOTIFY ON PUBLISH
        if ($this->_isGranted(_PUBLISHER_NOTIFY)) {
            $notify_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_NOTIFY, 'notify', $obj->getVar('notifypub'));
            $mainTab->addElement($notify_radio);
        }
        $tabtray->addElement($mainTab);
        if ($xoops->isActiveModule('images') && $this->_hasTab(_CO_PUBLISHER_TAB_IMAGES)) {
            $imagesTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_IMAGES, 'imagestab');
            // IMAGE
            if ($this->_isGranted(_PUBLISHER_IMAGE_ITEM)) {
                $imgcat_handler = Images::getInstance()->getHandlerCategories();
                $image_handler = Images::getInstance()->getHandlerImages();
                $objimages = $obj->getImages();
                $mainarray = is_object($objimages['main']) ? array($objimages['main']) : array();
                $mergedimages = array_merge($mainarray, $objimages['others']);
                $objimage_array = array();
                /* @var $imageObj ImagesImage */
                foreach ($mergedimages as $imageObj) {
                    $objimage_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
                }
                $catlist = $imgcat_handler->getListByPermission($group, 'imgcat_read', 1);
                $catids = array_keys($catlist);
                $imageObjs = array();
                if (!empty($catids)) {
                    $criteria = new CriteriaCompo(new Criteria('imgcat_id', '(' . implode(',', $catids) . ')', 'IN'));
                    $criteria->add(new Criteria('image_display', 1));
                    $criteria->setSort('image_nicename');
                    $criteria->setOrder('ASC');
                    $imageObjs = $image_handler->getObjects($criteria, true);
                    unset($criteria);
                }
                $image_array = array();
                foreach ($imageObjs as $imageObj) {
                    $image_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
                }
                $image_array = array_diff($image_array, $objimage_array);
                $image_select = new Xoops\Form\Select('', 'image_notused', '', 5);
                $image_select->addOptionArray($image_array);
                $image_select->setExtra("onchange='showImgSelected(\"image_display\", \"image_notused\", \"uploads/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
                //$image_select->setExtra( "onchange='appendMySelectOption(\"image_notused\", \"image_item\")'");
                unset($image_array);
                $image_select2 = new Xoops\Form\Select('', 'image_item', '', 5, true);
                $image_select2->addOptionArray($objimage_array);
                $image_select2->setExtra("onchange='publisher_updateSelectOption(\"image_item\", \"image_featured\"), showImgSelected(\"image_display\", \"image_item\", \"uploads/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
                $buttonadd = new Xoops\Form\Button('', 'buttonadd', _CO_PUBLISHER_ADD);
                $buttonadd->setExtra("onclick='publisher_appendSelectOption(\"image_notused\", \"image_item\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'");
                $buttonremove = new Xoops\Form\Button('', 'buttonremove', _CO_PUBLISHER_REMOVE);
                $buttonremove->setExtra("onclick='publisher_appendSelectOption(\"image_item\", \"image_notused\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'");
                $opentable = new Xoops\Form\Label('', "<table><tr><td>");
                $addcol = new Xoops\Form\Label('', "</td><td>");
                $addbreak = new Xoops\Form\Label('', "<br />");
                $closetable = new Xoops\Form\Label('', "</td></tr></table>");
                $xoops->theme()->addScript(PUBLISHER_URL . '/js/ajaxupload.3.9.js');
                //todo, find replacement for error class
                $js_data = new Xoops\Form\Label('', '
<script type= "text/javascript">/*<![CDATA[*/
$(document).ready(function(){
    var button = $("#publisher_upload_button"), interval;
    new AjaxUpload(button,{
        action: "' . PUBLISHER_URL . '/include/ajax_upload.php", // I disabled uploads in this example for security reasons
        responseType: "text/html",
        name: "publisher_upload_file",
        onSubmit : function(file, ext){
            // change button text, when user selects file
            $("#publisher_upload_message").html(" ");
            button.html("<img src=\'' . PUBLISHER_URL . '/images/loadingbar.gif\'/>"); this.setData({
                "image_nicename": $("#image_nicename").val(),
                "imgcat_id" : $("#imgcat_id").val()
            });
            // If you want to allow uploading only 1 file at time,
            // you can disable upload button
            this.disable();
            interval = window.setInterval(function(){
            }, 200);
        },
        onComplete: function(file, response){
            button.text("' . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . '");
            window.clearInterval(interval);
            // enable upload button
            this.enable();
            // add file to the list
            var result = eval(response);
            if (result[0] == "success") {
                 $("#image_item").append("<option value=\'" + result[1] + "\' selected=\'selected\'>" + result[2] + "</option>");
                 publisher_updateSelectOption(\'image_item\', \'image_featured\');
                 showImgSelected(\'image_display\', \'image_item\', \'uploads/\', \'\', \'' . \XoopsBaseConfig::get('url') . '\')
            } else {
                 $("#publisher_upload_message").html("<div class=\'errorMsg\'>" + result[1] + "</div>");
            }
        }
    });
});
/*]]>*/</script>
');
                $messages = new Xoops\Form\Label('', "<div id='publisher_upload_message'></div>");
                $button = new Xoops\Form\Label('', "<div id='publisher_upload_button'>" . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . "</div>");
                $nicename = new Xoops\Form\Text('', 'image_nicename', 30, 30, _CO_PUBLISHER_IMAGE_NICENAME);
                $catlist = $imgcat_handler->getListByPermission($group, 'imgcat_read', 1);
                $imagecat = new Xoops\Form\Select('', 'imgcat_id', '', 1);
                $imagecat->addOptionArray($catlist);
                $image_upload_tray = new Xoops\Form\ElementTray(_CO_PUBLISHER_IMAGE_UPLOAD, '');
                $image_upload_tray->addElement($js_data);
                $image_upload_tray->addElement($messages);
                $image_upload_tray->addElement($opentable);
                $image_upload_tray->addElement($imagecat);
                $image_upload_tray->addElement($addbreak);
                $image_upload_tray->addElement($nicename);
                $image_upload_tray->addElement($addbreak);
                $image_upload_tray->addElement($button);
                $image_upload_tray->addElement($closetable);
                $imagesTab->addElement($image_upload_tray);
                $image_tray = new Xoops\Form\ElementTray(_CO_PUBLISHER_IMAGE_ITEMS, '');
                $image_tray->addElement($opentable);
                $image_tray->addElement($image_select);
                $image_tray->addElement($addbreak);
                $image_tray->addElement($buttonadd);
                $image_tray->addElement($addcol);
                $image_tray->addElement($image_select2);
                $image_tray->addElement($addbreak);
                $image_tray->addElement($buttonremove);
                $image_tray->addElement($closetable);
                $image_tray->setDescription(_CO_PUBLISHER_IMAGE_ITEMS_DSC);
                $imagesTab->addElement($image_tray);
                $imagename = is_object($objimages['main']) ? $objimages['main']->getVar('image_name') : '';
                $imageforpath = $imagename != '' ? $imagename : 'blank.gif';
                $image_select3 = new Xoops\Form\Select(_CO_PUBLISHER_IMAGE_ITEM, 'image_featured', $imagename, 1);
                $image_select3->addOptionArray($objimage_array);
                $image_select3->setExtra("onchange='showImgSelected(\"image_display\", \"image_featured\", \"uploads/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
                $image_select3->setDescription(_CO_PUBLISHER_IMAGE_ITEM_DSC);
                $imagesTab->addElement($image_select3);
                $image_preview = new Xoops\Form\Label(_CO_PUBLISHER_IMAGE_PREVIEW, "<img width='500' src='" . \XoopsBaseConfig::get('url') . "/uploads/" . $imageforpath . "' name='image_display' id='image_display' alt='' />");
                $imagesTab->addElement($image_preview);
            }
            $tabtray->addElement($imagesTab);
        }
        if ($this->_hasTab(_CO_PUBLISHER_TAB_FILES)) {
            $filesTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_FILES, 'filestab');
            // File upload UPLOAD
            if ($this->_isGranted(_PUBLISHER_ITEM_UPLOAD_FILE)) {
                // NAME
                $name_text = new Xoops\Form\Text(_CO_PUBLISHER_FILENAME, 'item_file_name', 50, 255, '');
                $name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC);
                $filesTab->addElement($name_text);
                unset($name_text);
                // DESCRIPTION
                $description_text = new Xoops\Form\TextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'item_file_description', '');
                $description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC);
                $filesTab->addElement($description_text);
                unset($description_text);
                $status_select = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'item_file_status', 1);
                //1 - active
                $status_select->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC);
                $filesTab->addElement($status_select);
                unset($status_select);
                $file_box = new Xoops\Form\File(_CO_PUBLISHER_ITEM_UPLOAD_FILE, "item_upload_file");
                $file_box->setDescription(_CO_PUBLISHER_ITEM_UPLOAD_FILE_DSC);
                $file_box->setExtra("size ='50'");
                $filesTab->addElement($file_box);
                unset($file_box);
                if (!$obj->isNew()) {
                    $filesObj = $publisher->getFileHandler()->getAllFiles($obj->getVar('itemid'));
                    if (count($filesObj) > 0) {
                        $table = '';
                        $table .= "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
                        $table .= "<tr>";
                        $table .= "<td width='50' class='bg3' align='center'><strong>ID</strong></td>";
                        $table .= "<td width='150' class='bg3' align='left'><strong>" . _AM_PUBLISHER_FILENAME . "</strong></td>";
                        $table .= "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_DESCRIPTION . "</strong></td>";
                        $table .= "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_HITS . "</strong></td>";
                        $table .= "<td width='100' class='bg3' align='center'><strong>" . _AM_PUBLISHER_UPLOADED_DATE . "</strong></td>";
                        $table .= "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>";
                        $table .= "</tr>";
                        /* @var $fileObj PublisherFile */
                        foreach ($filesObj as $fileObj) {
                            $modify = "<a href='file.php?op=mod&fileid=" . $fileObj->getVar('fileid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif' title='" . _CO_PUBLISHER_EDITFILE . "' alt='" . _CO_PUBLISHER_EDITFILE . "' /></a>";
                            $delete = "<a href='file.php?op=del&fileid=" . $fileObj->getVar('fileid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png' title='" . _CO_PUBLISHER_DELETEFILE . "' alt='" . _CO_PUBLISHER_DELETEFILE . "'/></a>";
                            if ($fileObj->getVar('status') == 0) {
                                $not_visible = "<img src='" . PUBLISHER_URL . "/images/no.gif'/>";
                            } else {
                                $not_visible = '';
                            }
                            $table .= "<tr>";
                            $table .= "<td class='head' align='center'>" . $fileObj->getVar('fileid') . "</td>";
                            $table .= "<td class='odd' align='left'>" . $not_visible . $fileObj->getFileLink() . "</td>";
                            $table .= "<td class='even' align='left'>" . $fileObj->getVar('description') . "</td>";
                            $table .= "<td class='even' align='center'>" . $fileObj->getVar('counter') . "";
                            $table .= "<td class='even' align='center'>" . $fileObj->datesub() . "</td>";
                            $table .= "<td class='even' align='center'> {$modify} {$delete} </td>";
                            $table .= "</tr>";
                        }
                        $table .= "</table>";
                        $files_box = new Xoops\Form\Label(_CO_PUBLISHER_FILES_LINKED, $table);
                        $filesTab->addElement($files_box);
                        unset($files_box, $filesObj, $fileObj);
                    }
                }
            }
            $tabtray->addElement($filesTab);
        }
        if ($this->_hasTab(_CO_PUBLISHER_TAB_OTHERS)) {
            $othersTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_OTHERS, 'otherstab');
            // Meta Keywords
            if ($this->_isGranted(_PUBLISHER_ITEM_META_KEYWORDS)) {
                $text_meta_keywords = new Xoops\Form\TextArea(_CO_PUBLISHER_ITEM_META_KEYWORDS, 'item_meta_keywords', $obj->getVar('meta_keywords', 'e'), 7, 60);
                $text_meta_keywords->setDescription(_CO_PUBLISHER_ITEM_META_KEYWORDS_DSC);
                $othersTab->addElement($text_meta_keywords);
            }
            // Meta Description
            if ($this->_isGranted(_PUBLISHER_ITEM_META_DESCRIPTION)) {
                $text_meta_description = new Xoops\Form\TextArea(_CO_PUBLISHER_ITEM_META_DESCRIPTION, 'item_meta_description', $obj->getVar('meta_description', 'e'), 7, 60);
                $text_meta_description->setDescription(_CO_PUBLISHER_ITEM_META_DESCRIPTION_DSC);
                $othersTab->addElement($text_meta_description);
            }
            // COMMENTS
            if ($this->_isGranted(_PUBLISHER_ALLOWCOMMENTS)) {
                $addcomments_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_ALLOWCOMMENTS, 'allowcomments', $obj->getVar('cancomment'));
                $othersTab->addElement($addcomments_radio);
            }
            // WEIGHT
            if ($this->_isGranted(_PUBLISHER_WEIGHT)) {
                $othersTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_WEIGHT, 'weight', 5, 5, $obj->getVar('weight')));
            }
            $tabtray->addElement($othersTab);
        }
        $this->addElement($tabtray);
        //COMMON TO ALL TABS
        $button_tray = new Xoops\Form\ElementTray('', '');
        if (!$obj->isNew()) {
            $button_tray->addElement(new Xoops\Form\Button('', 'additem', XoopsLocale::A_SUBMIT, 'submit'));
            //orclone
        } else {
            $button_tray->addElement(new Xoops\Form\Button('', 'additem', _CO_PUBLISHER_CREATE, 'submit'));
            $button_tray->addElement(new Xoops\Form\Button('', '', _CO_PUBLISHER_CLEAR, 'reset'));
        }
        $button_tray->addElement(new Xoops\Form\Button('', 'preview', _CO_PUBLISHER_PREVIEW, 'submit'));
        $butt_cancel = new Xoops\Form\Button('', '', _CO_PUBLISHER_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $this->addElement($button_tray);
        $hidden = new Xoops\Form\Hidden('itemid', $obj->getVar('itemid'));
        $this->addElement($hidden);
        unset($hidden);
    }
Example #6
0
*/
/**
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author          trabis <*****@*****.**>
 * @version         $Id$
 */
include dirname(dirname(__DIR__)) . '/mainfile.php';
$xoops = Xoops::getInstance();
$xoops->header();
// We are using Simple Form, this way we can hide the names of the tabtray and form
$form = new Xoops\Form\SimpleForm('', 'form_id', 'form-tab.php');
//tabtray is the tabs holder,
//if you are using many tabtrays, or even nested tabtrays, you should use diferent ids
//we are going to use the theme we have selected in system preferences
$tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
//Now we create our tabs
//Tabs should also have unique ids
//First tab
$tab1 = new Xoops\Form\Tab('Caption-1', 'tabid-1');
//Second tab
$tab2 = new Xoops\Form\Tab('Caption-2', 'tabid-2');
//Third tab
$tab3 = new Xoops\Form\Tab('Caption-3', 'tabid-3');
// Create the elements and assign them to the corresponding tabs
$code = new Xoops\Form\Text('Code', 'code', 2, 25, '', 'Code...');
$code->setDescription('Description code');
$code->setPattern('^.{3,}$', 'You need at least 3 characters');
$code->setDatalist(array('list 1', 'list 2', 'list 3'));
$tab1->addElement($code, true);
$password = new Xoops\Form\Password('Password', 'password', 3, 25, '', false, 'Your Password');