Пример #1
0
 /**
  * @param PublisherFile $obj
  */
 public function __construct(PublisherFile $obj)
 {
     $xoops = Xoops::getInstance();
     $publisher = Publisher::getInstance();
     $publisher->loadLanguage('main');
     parent::__construct(_AM_PUBLISHER_UPLOAD_FILE, "form", $xoops->getEnv('PHP_SELF'));
     $this->setExtra('enctype="multipart/form-data"');
     // NAME
     $name_text = new Xoops\Form\Text(_CO_PUBLISHER_FILENAME, 'name', 50, 255, $obj->getVar('name'));
     $name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC);
     $this->addElement($name_text, true);
     // DESCRIPTION
     $description_text = new Xoops\Form\TextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'description', $obj->getVar('description'));
     $description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC);
     $this->addElement($description_text);
     // FILE TO UPLOAD
     $file_box = new Xoops\Form\File(_CO_PUBLISHER_FILE_TO_UPLOAD, "item_upload_file");
     $file_box->set('size', 50);
     $this->addElement($file_box);
     $status_select = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'file_status', _PUBLISHER_STATUS_FILE_ACTIVE);
     $status_select->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC);
     $this->addElement($status_select);
     // fileid
     $this->addElement(new Xoops\Form\Hidden('fileid', $obj->getVar('fileid')));
     // itemid
     $this->addElement(new Xoops\Form\Hidden('itemid', $obj->getVar('itemid')));
     $files_button_tray = new Xoops\Form\ElementTray('', '');
     $files_hidden = new Xoops\Form\Hidden('op', 'uploadfile');
     $files_button_tray->addElement($files_hidden);
     if (!$obj->getVar('fileid')) {
         $files_butt_create = new Xoops\Form\Button('', '', _MD_PUBLISHER_UPLOAD, 'submit');
         $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"');
         $files_button_tray->addElement($files_butt_create);
         $files_butt_another = new Xoops\Form\Button('', '', _CO_PUBLISHER_FILE_UPLOAD_ANOTHER, 'submit');
         $files_butt_another->setExtra('onclick="this.form.elements.op.value=\'uploadanother\'"');
         $files_button_tray->addElement($files_butt_another);
     } else {
         $files_butt_create = new Xoops\Form\Button('', '', _MD_PUBLISHER_MODIFY, 'submit');
         $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'modify\'"');
         $files_button_tray->addElement($files_butt_create);
     }
     $files_butt_clear = new Xoops\Form\Button('', '', _MD_PUBLISHER_CLEAR, 'reset');
     $files_button_tray->addElement($files_butt_clear);
     $buttonCancel = new Xoops\Form\Button('', '', _MD_PUBLISHER_CANCEL, 'button');
     $buttonCancel->setExtra('onclick="history.go(-1)"');
     $files_button_tray->addElement($buttonCancel);
     $this->addElement($files_button_tray);
 }
Пример #2
0
 /**
  * @param PublisherCategory $obj
  */
 public function __construct(PublisherCategory $obj)
 {
     $xoops = Xoops::getInstance();
     $publisher = Publisher::getInstance();
     $member_handler = $xoops->getHandlerMember();
     $userGroups = $member_handler->getGroupList();
     parent::__construct(_AM_PUBLISHER_CATEGORY, "form", $xoops->getEnv('PHP_SELF'));
     $this->setExtra('enctype="multipart/form-data"');
     // Category
     $criteria = new Criteria(null);
     $criteria->setSort('weight');
     $criteria->setOrder('ASC');
     $categories = $publisher->getCategoryHandler()->getObjects($criteria);
     $mytree = new XoopsObjectTree($categories, "categoryid", "parentid");
     $cat_select = $mytree->makeSelBox('parentid', 'name', '--', $obj->getVar('parentid'), true);
     $this->addElement(new Xoops\Form\Label(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $cat_select));
     // Name
     $this->addElement(new Xoops\Form\Text(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $obj->getVar('name', 'e')), true);
     // Description
     $this->addElement(new Xoops\Form\TextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $obj->getVar('description', 'e'), 7, 60));
     // EDITOR
     $groups = $xoops->getUserGroups();
     $gperm_handler = $publisher->getGrouppermHandler();
     $module_id = $publisher->getModule()->mid();
     $allowed_editors = PublisherUtils::getEditors($gperm_handler->getItemIds('editors', $groups, $module_id));
     $nohtml = false;
     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);
         $this->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');
     $editor_configs['name'] = 'header';
     $editor_configs['value'] = $obj->getVar('header', 'e');
     $text_header = new Xoops\Form\Editor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editor_configs, $nohtml, $onfailure = null);
     $text_header->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC);
     $this->addElement($text_header);
     // IMAGE
     $image_select = new Xoops\Form\Select('', 'image', $obj->image());
     \Xoops\Core\Lists\ImageFile::setOptionsArray($image_select, PublisherUtils::getImageDir('category'));
     $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
     $image_tray = new Xoops\Form\ElementTray(_AM_PUBLISHER_IMAGE, ' ');
     $image_tray->addElement($image_select);
     $image_tray->addElement(new Xoops\Form\Label('', "<br /><br /><img src='" . PublisherUtils::getImageDir('category', false) . $obj->image() . "' name='image3' id='image3' alt='' />"));
     $image_tray->setDescription(_AM_PUBLISHER_IMAGE_DSC);
     $this->addElement($image_tray);
     // IMAGE UPLOAD
     //$max_size = 5000000;
     $file_box = new Xoops\Form\File(_AM_PUBLISHER_IMAGE_UPLOAD, "image_file");
     $file_box->set('size', 45);
     $file_box->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC);
     $this->addElement($file_box);
     // Short url
     $text_short_url = new Xoops\Form\Text(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $obj->getVar('short_url', 'e'));
     $text_short_url->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC);
     $this->addElement($text_short_url);
     // Meta Keywords
     $text_meta_keywords = new Xoops\Form\TextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $obj->getVar('meta_keywords', 'e'), 7, 60);
     $text_meta_keywords->setDescription(_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC);
     $this->addElement($text_meta_keywords);
     // Meta Description
     $text_meta_description = new Xoops\Form\TextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $obj->getVar('meta_description', 'e'), 7, 60);
     $text_meta_description->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC);
     $this->addElement($text_meta_description);
     // Weight
     $this->addElement(new Xoops\Form\Text(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $obj->getVar('weight')));
     // Added by skalpa: custom template support
     //todo, check this
     $this->addElement(new Xoops\Form\Text("Custom template", 'template', 50, 255, $obj->getVar('template', 'e')), false);
     // READ PERMISSIONS
     $groups_read_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_READ, 'groups_read[]', $obj->getGroups_read());
     foreach ($userGroups as $group_id => $group_name) {
         $groups_read_checkbox->addOption($group_id, $group_name);
     }
     $this->addElement($groups_read_checkbox);
     // SUBMIT PERMISSIONS
     $groups_submit_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $obj->getGroups_submit());
     $groups_submit_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC);
     foreach ($userGroups as $group_id => $group_name) {
         $groups_submit_checkbox->addOption($group_id, $group_name);
     }
     $this->addElement($groups_submit_checkbox);
     // MODERATION PERMISSIONS
     $groups_moderation_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, 'groups_moderation[]', $obj->getGroups_moderation());
     $groups_moderation_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC);
     foreach ($userGroups as $group_id => $group_name) {
         $groups_moderation_checkbox->addOption($group_id, $group_name);
     }
     $this->addElement($groups_moderation_checkbox);
     $moderator = new Xoops\Form\SelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $obj->getVar('moderator', 'e'), 1, false);
     $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC);
     $this->addElement($moderator);
     $cat_tray = new Xoops\Form\ElementTray(_AM_PUBLISHER_SCATEGORYNAME, '<br /><br />');
     for ($i = 0; $i < $this->_subCatsCount; ++$i) {
         if ($i < (isset($_POST['scname']) ? sizeof($_POST['scname']) : 0)) {
             $subname = isset($_POST['scname']) ? $_POST['scname'][$i] : '';
         } else {
             $subname = '';
         }
         $cat_tray->addElement(new Xoops\Form\Text('', 'scname[' . $i . ']', 50, 255, $subname));
     }
     $t = new Xoops\Form\Text('', 'nb_subcats', 3, 2);
     $l = new Xoops\Form\Label('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render()));
     $b = new Xoops\Form\Button('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit');
     if (!$obj->getVar('categoryid')) {
         $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"');
     } else {
         $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"');
     }
     $r = new Xoops\Form\ElementTray('');
     $r->addElement($l);
     $r->addElement($b);
     $cat_tray->addElement($r);
     $this->addElement($cat_tray);
     $this->addElement(new Xoops\Form\Hidden('categoryid', $obj->getVar('categoryid')));
     $this->addElement(new Xoops\Form\Hidden('nb_sub_yet', $this->_subCatsCount));
     // Action buttons tray
     $buttonTray = new Xoops\Form\ElementTray('', '');
     // No ID for category -- then it's new category, button says 'Create'
     if (!$obj->getVar('categoryid')) {
         $buttonTray->addElement(new Xoops\Form\Button('', 'addcategory', _AM_PUBLISHER_CREATE, 'submit'));
         $buttonClear = new Xoops\Form\Button('', '', _AM_PUBLISHER_CLEAR, 'reset');
         $buttonTray->addElement($buttonClear);
         $buttonCancel = new Xoops\Form\Button('', '', _AM_PUBLISHER_CANCEL, 'button');
         $buttonCancel->setExtra('onclick="history.go(-1)"');
         $buttonTray->addElement($buttonCancel);
         $this->addElement($buttonTray);
     } else {
         $buttonTray->addElement(new Xoops\Form\Button('', 'addcategory', _AM_PUBLISHER_MODIFY, 'submit'));
         $buttonCancel = new Xoops\Form\Button('', '', _AM_PUBLISHER_CANCEL, 'button');
         $buttonCancel->setExtra('onclick="history.go(-1)"');
         $buttonTray->addElement($buttonCancel);
         $this->addElement($buttonTray);
     }
 }
Пример #3
0
 /**
  * Build the files tab
  *
  * @param PublisherItem      $obj      data source
  * @param ContainerInterface $filesTab add elements to this tab/form
  *
  * @return void
  */
 private function buildFilesTab(PublisherItem $obj, ContainerInterface $filesTab)
 {
     $publisher = Publisher::getInstance();
     // 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);
         //1 - active
         $status_select = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'item_file_status', 1);
         $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->set('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) {
                         $notVisible = "<img src='" . PUBLISHER_URL . "/images/no.gif'/>";
                     } else {
                         $notVisible = '';
                     }
                     $table .= "<tr>";
                     $table .= "<td class='head' align='center'>" . $fileObj->getVar('fileid') . "</td>";
                     $table .= "<td class='odd' align='left'>" . $notVisible . $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);
             }
         }
     }
 }