function createElements() { global $xoopsUser; // Category $criteria = new Criteria(null); $criteria->setSort('weight'); $criteria->setOrder('ASC'); $mytree = new XoopsObjectTree($this->publisher->getHandler('category')->getObjects($criteria), "categoryid", "parentid"); $cat_select = $mytree->makeSelBox('parentid', 'name', '--', $this->targetObject->parentid(), true); $this->addElement(new XoopsFormLabel(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $cat_select)); // Name $this->addElement(new XoopsFormText(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true); // Description $this->addElement(new XoopsFormTextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60)); // EDITOR $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; $gperm_handler = $this->publisher->getHandler('groupperm'); $module_id = $this->publisher->getModule()->mid(); $allowed_editors = publisher_getEditors($gperm_handler->getItemIds('editors', $groups, $module_id)); $nohtml = false; if (count($allowed_editors) > 0) { $editor = @$_POST['editor']; if (!empty($editor)) { publisher_setCookieVar('publisher_editor', $editor); } else { $editor = publisher_getCookieVar('publisher_editor'); if (empty($editor) && is_object($xoopsUser)) { $editor = @$xoopsUser->getVar('publisher_editor'); // Need set through user profile } } $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $this->publisher->getConfig('submit_editor') : $editor; $form_editor = new XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors); $this->addElement($form_editor); } else { $editor = $this->publisher->getConfig('submit_editor'); } $editor_configs = array(); $editor_configs['rows'] = $this->publisher->getConfig('submit_editor_rows') == '' ? 35 : $this->publisher->getConfig('submit_editor_rows'); $editor_configs['cols'] = $this->publisher->getConfig('submit_editor_cols') == '' ? 60 : $this->publisher->getConfig('submit_editor_cols'); $editor_configs['width'] = $this->publisher->getConfig('submit_editor_width') == '' ? "100%" : $this->publisher->getConfig('submit_editor_width'); $editor_configs['height'] = $this->publisher->getConfig('submit_editor_height') == '' ? "400px" : $this->publisher->getConfig('submit_editor_height'); $editor_configs['name'] = 'header'; $editor_configs['value'] = $this->targetObject->header('e'); $text_header = new XoopsFormEditor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editor_configs, $nohtml, $onfailure = null); $text_header->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC); $this->addElement($text_header); // IMAGE $image_array = XoopsLists::getImgListAsArray(publisher_getImageDir('category')); $image_select = new XoopsFormSelect('', 'image', $this->targetObject->image()); //$image_select -> addOption ('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray(_AM_PUBLISHER_IMAGE, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . publisher_getImageDir('category', false) . $this->targetObject->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 XoopsFormFile(_AM_PUBLISHER_IMAGE_UPLOAD, "image_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC); $this->addElement($file_box); // Short url $text_short_url = new XoopsFormText(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e')); $text_short_url->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC); $this->addElement($text_short_url); // Meta Keywords $text_meta_keywords = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->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 XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60); $text_meta_description->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC); $this->addElement($text_meta_description); // Weight $this->addElement(new XoopsFormText(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight())); // Added by skalpa: custom template support //todo, check this $this->addElement(new XoopsFormText("Custom template", 'template', 50, 255, $this->targetObject->template('e')), false); // READ PERMISSIONS $groups_read_checkbox = new XoopsFormCheckBox(_AM_PUBLISHER_PERMISSIONS_CAT_READ, 'groups_read[]', $this->targetObject->getGroups_read()); foreach ($this->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 XoopsFormCheckBox(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $this->targetObject->getGroups_submit()); $groups_submit_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC); foreach ($this->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 XoopsFormCheckBox(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, 'groups_moderation[]', $this->targetObject->getGroups_moderation()); $groups_moderation_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC); foreach ($this->userGroups as $group_id => $group_name) { $groups_moderation_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_moderation_checkbox); $moderator = new XoopsFormSelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $this->targetObject->moderator('e'), 1, false); $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC); $this->addElement($moderator); $cat_tray = new XoopsFormElementTray(_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 XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname)); } $t = new XoopsFormText('', 'nb_subcats', 3, 2); $l = new XoopsFormLabel('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render())); $b = new XoopsFormButton('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit'); if (!$this->targetObject->categoryid()) { $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"'); } else { $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"'); } $r = new XoopsFormElementTray(''); $r->addElement($l); $r->addElement($b); $cat_tray->addElement($r); $this->addElement($cat_tray); $this->addElement(new XoopsFormHidden('categoryid', $this->targetObject->categoryid())); $this->addElement(new XoopsFormHidden('nb_sub_yet', $this->subCatsCount)); }
public function createElements() { include_once dirname(dirname(__DIR__)) . '/include/common.php'; // Category $criteria = new Criteria(null); $criteria->setSort('weight'); $criteria->setOrder('ASC'); $myTree = new XoopsObjectTree($this->publisher->getHandler('category')->getObjects($criteria), 'categoryid', 'parentid'); $catSelect = $myTree->makeSelBox('parentid', 'name', '--', $this->targetObject->parentid(), true); $this->addElement(new XoopsFormLabel(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $catSelect)); // Name $this->addElement(new XoopsFormText(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true); // Description $this->addElement(new XoopsFormTextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60)); // EDITOR $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; $gpermHandler =& $this->publisher->getHandler('groupperm'); $moduleId = $this->publisher->getModule()->mid(); $allowedEditors = publisherGetEditors($gpermHandler->getItemIds('editors', $groups, $moduleId)); $nohtml = false; if (count($allowedEditors) > 0) { $editor = XoopsRequest::getString('editor', '', 'POST'); if (!empty($editor)) { publisherSetCookieVar('publisher_editor', $editor); } else { $editor = publisherGetCookieVar('publisher_editor'); if (empty($editor) && is_object($GLOBALS['xoopsUser'])) { $editor = null !== $GLOBALS['xoopsUser']->getVar('publisher_editor') ? $GLOBALS['xoopsUser']->getVar('publisher_editor') : ''; // Need set through user profile } } $editor = empty($editor) || !in_array($editor, $allowedEditors) ? $this->publisher->getConfig('submit_editor') : $editor; $formEditor = new XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors); $this->addElement($formEditor); } else { $editor = $this->publisher->getConfig('submit_editor'); } $editorConfigs = array(); $editorConfigs['rows'] = $this->publisher->getConfig('submit_editor_rows') == '' ? 35 : $this->publisher->getConfig('submit_editor_rows'); $editorConfigs['cols'] = $this->publisher->getConfig('submit_editor_cols') == '' ? 60 : $this->publisher->getConfig('submit_editor_cols'); $editorConfigs['width'] = $this->publisher->getConfig('submit_editor_width') == '' ? '100%' : $this->publisher->getConfig('submit_editor_width'); $editorConfigs['height'] = $this->publisher->getConfig('submit_editor_height') == '' ? '400px' : $this->publisher->getConfig('submit_editor_height'); $editorConfigs['name'] = 'header'; $editorConfigs['value'] = $this->targetObject->header('e'); $textHeader = new XoopsFormEditor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editorConfigs, $nohtml, $onfailure = null); $textHeader->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC); $this->addElement($textHeader); // IMAGE $imageArray = XoopsLists::getImgListAsArray(publisherGetImageDir('category')); $imageSelect = new XoopsFormSelect('', 'image', $this->targetObject->getImage()); //$imageSelect -> addOption ('-1', '---------------'); $imageSelect->addOptionArray($imageArray); $imageSelect->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $imageTray = new XoopsFormElementTray(_AM_PUBLISHER_IMAGE, ' '); $imageTray->addElement($imageSelect); $imageTray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . publisherGetImageDir('category', false) . $this->targetObject->getImage() . "' name='image3' id='image3' alt='' />")); $imageTray->setDescription(_AM_PUBLISHER_IMAGE_DSC); $this->addElement($imageTray); // IMAGE UPLOAD $max_size = 5000000; $fileBox = new XoopsFormFile(_AM_PUBLISHER_IMAGE_UPLOAD, 'image_file', $max_size); $fileBox->setExtra("size ='45'"); $fileBox->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC); $this->addElement($fileBox); // Short url $textShortUrl = new XoopsFormText(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e')); $textShortUrl->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC); $this->addElement($textShortUrl); // Meta Keywords $textMetaKeywords = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->meta_keywords('e'), 7, 60); $textMetaKeywords->setDescription(_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC); $this->addElement($textMetaKeywords); // Meta Description $textMetaDescription = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60); $textMetaDescription->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC); $this->addElement($textMetaDescription); // Weight $this->addElement(new XoopsFormText(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight())); // Added by skalpa: custom template support //todo, check this $this->addElement(new XoopsFormText('Custom template', 'template', 50, 255, $this->targetObject->template('e')), false); // READ PERMISSIONS $readPermissionsTray = new XoopsFormElementTray(_AM_PUBLISHER_PERMISSIONS_CAT_READ, ''); $selectAllReadCheckbox = new XoopsFormCheckBox('', "adminbox", 1); $selectAllReadCheckbox->addOption('allbox', _AM_SYSTEM_ALL); $selectAllReadCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox\" , \"groupsRead[]\");' "); $selectAllReadCheckbox->setClass('xo-checkall'); $readPermissionsTray->addElement($selectAllReadCheckbox); $groupsReadCheckbox = new XoopsFormCheckBox('', 'groupsRead[]', $this->targetObject->getGroupsRead()); foreach ($this->userGroups as $group_id => $group_name) { $groupsReadCheckbox->addOption($group_id, $group_name); } $readPermissionsTray->addElement($groupsReadCheckbox); $this->addElement($readPermissionsTray); // SUBMIT PERMISSIONS $submitPermissionsTray = new XoopsFormElementTray(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, ''); $submitPermissionsTray->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC); $selectAllSubmitCheckbox = new XoopsFormCheckBox('', "adminbox2", 1); $selectAllSubmitCheckbox->addOption('allbox', _AM_SYSTEM_ALL); $selectAllSubmitCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox2\" , \"groupsSubmit[]\");' "); $selectAllSubmitCheckbox->setClass('xo-checkall'); $submitPermissionsTray->addElement($selectAllSubmitCheckbox); $groupsSubmitCheckbox = new XoopsFormCheckBox('', 'groupsSubmit[]', $this->targetObject->getGroupsSubmit()); foreach ($this->userGroups as $group_id => $group_name) { $groupsSubmitCheckbox->addOption($group_id, $group_name); } $submitPermissionsTray->addElement($groupsSubmitCheckbox); $this->addElement($submitPermissionsTray); // MODERATION PERMISSIONS $moderatePermissionsTray = new XoopsFormElementTray(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, ''); $moderatePermissionsTray->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC); $selectAllModerateCheckbox = new XoopsFormCheckBox('', "adminbox3", 1); $selectAllModerateCheckbox->addOption('allbox', _AM_SYSTEM_ALL); $selectAllModerateCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox3\" , \"groupsModeration[]\");' "); $selectAllModerateCheckbox->setClass('xo-checkall'); $moderatePermissionsTray->addElement($selectAllModerateCheckbox); $groupsModerationCheckbox = new XoopsFormCheckBox('', 'groupsModeration[]', $this->targetObject->getGroupsModeration()); foreach ($this->userGroups as $group_id => $group_name) { $groupsModerationCheckbox->addOption($group_id, $group_name); } $moderatePermissionsTray->addElement($groupsModerationCheckbox); $this->addElement($moderatePermissionsTray); $moderator = new XoopsFormSelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $this->targetObject->moderator('e'), 1, false); $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC); $this->addElement($moderator); //SUBCATEGORY $catTray = new XoopsFormElementTray(_AM_PUBLISHER_SCATEGORYNAME, '<br /><br />'); for ($i = 0; $i < $this->subCatsCount; ++$i) { $subname = ''; if ($i < (($scname = XoopsRequest::getArray('scname', array(), 'POST')) ? count($scname) : 0)) { $temp = XoopsRequest::getArray('scname', array(), 'POST'); $subname = ($scname = XoopsRequest::getArray('scname', '', 'POST')) ? $temp[$i] : ''; } $catTray->addElement(new XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname)); } $t = new XoopsFormText('', 'nb_subcats', 3, 2); $l = new XoopsFormLabel('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render())); $b = new XoopsFormButton('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit'); if (!$this->targetObject->categoryid()) { $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"'); } else { $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"'); } $r = new XoopsFormElementTray(''); $r->addElement($l); $r->addElement($b); $catTray->addElement($r); $this->addElement($catTray); $this->addElement(new XoopsFormHidden('categoryid', $this->targetObject->categoryid())); $this->addElement(new XoopsFormHidden('nb_sub_yet', $this->subCatsCount)); }