function createElements() { global $xoopsDB, $xoopsUser; // NAME $name_text = new XoopsFormText(_CO_PUBLISHER_FILENAME, 'name', 50, 255, $this->targetObject->name()); $name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC); $this->addElement($name_text, true); // DESCRIPTION $description_text = new XoopsFormTextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'description', $this->targetObject->description()); $description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC); $this->addElement($description_text); // FILE TO UPLOAD //if (!$this->targetObject->fileid()) { $file_box = new XoopsFormFile(_CO_PUBLISHER_FILE_TO_UPLOAD, "item_upload_file", 0); $file_box->setExtra("size ='50'"); $this->addElement($file_box); //} $status_select = new XoopsFormRadioYN(_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 XoopsFormHidden('fileid', $this->targetObject->fileid())); // itemid $this->addElement(new XoopsFormHidden('itemid', $this->targetObject->itemid())); }
/** * @public */ public static function renderNone(&$html, $params) { if (!XC_CLASS_EXISTS('xoopsformelement')) { require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; } $form = new XoopsFormTextArea($params['name'], $params['name'], $params['value'], $params['rows'], $params['cols']); $form->setId($params['id']); if ($params['class'] != null) { $form->setClass($params['class']); } $html = $form->render(); }
/** * renderValidationJS * TEMPORARY SOLUTION to 'override' original renderValidationJS method * with custom XoopsEditor's renderValidationJS method */ function renderValidationJS() { if (is_object($this->editor) && $this->isRequired()) { if (method_exists($this->editor, 'renderValidationJS')) { $this->editor->setName($this->getName()); $this->editor->setCaption($this->getCaption()); $this->editor->_required = $this->isRequired(); $ret = $this->editor->renderValidationJS(); return $ret; } else { parent::renderValidationJS(); } } return ''; }
function setCaption($caption) { $this->mCaptionOrig = $caption; $nullLanguageManager =& new NBFrameLanguage(NBFrame::null()); $url = NBFrame::getCurrentURL(); $url = NBFrame::removeQueryArgs($url, array($this->mGetPrefix . '_html', $this->mGetPrefix . '_xcode')); if ($this->mUseHtmlEditor) { $url = NBFrame::addQueryArgs($url, array($this->mGetPrefix . '_xcode' => '1')); $desc = '<br /><small> <a href="' . $url . '">' . $nullLanguageManager->__l('Switching to XCode Editor') . '</a></small>'; } else { if ($this->mCanUseHtmlEditor) { $url = NBFrame::addQueryArgs($url, array($this->mGetPrefix . '_html' => '1')); $desc = '<br /><small> <a href="' . $url . '">' . $nullLanguageManager->__l('Switching to HTML Editor') . '</a></small>'; } else { $desc = ''; } } parent::setCaption($this->mCaptionOrig . $desc); }
$contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC); $form->addElement($contact_email_text, false); // EMAIL_PRIV $email_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_EMAILPRIV, 'email_priv', 0); $email_priv_radio->setDescription(_CO_SPARTNER_CONTACT_EMAILPRIV_DSC); $form->addElement($email_priv_radio); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, ''); $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC); $form->addElement($contact_phone_text, false); // PHONE_PRIV $phone_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_PHONEPRIV, 'phone_priv', 0); $phone_priv_radio->setDescription(_CO_SPARTNER_CONTACT_PHONEPRIV_DSC); $form->addElement($phone_priv_radio); // ADRESS $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', '', 4, 60); $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC); $form->addElement($adress_text, false); // ADRESS_PRIV $adress_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_ADRESSPRIV, 'adress_priv', 0); $adress_priv_radio->setDescription(_CO_SPARTNER_CONTACT_ADRESSPRIV_DSC); $form->addElement($adress_priv_radio); // NOTIFY ON PUBLISH if (is_object($xoopsUser) && $xoopsModuleConfig['autoapprove_submitted'] != 1) { $notify_checkbox = new XoopsFormCheckBox('', 'notifypub', 1); $notify_checkbox->addOption(1, _MD_SPARTNER_NOTIFY); $form->addElement($notify_checkbox); } $form->addElement(new SmartFormHidden('partial_view', $xoopsModuleConfig['default_part_view'])); $form->addElement(new SmartFormHidden('full_view', $xoopsModuleConfig['default_full_view'])); // BUTTONS
global $smartsection_file_handler; $fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : 0; if ($fileid != 0) { $fileObj = new ssFile($fileid); } else { $fileObj =& $smartsection_file_handler->create(); } // FILES UPLOAD FORM $files_form = new XoopsThemeForm(_MD_SS_UPLOAD_FILE, "files_form", xoops_getenv('PHP_SELF')); $files_form->setExtra("enctype='multipart/form-data'"); // NAME $name_text = new XoopsFormText(_MD_SS_FILENAME, 'name', 50, 255, $fileObj->name()); $name_text->setDescription(_MD_SS_FILE_NAME_DSC); $files_form->addElement($name_text, true); // DESCRIPTION $description_text = new XoopsFormTextArea(_MD_SS_FILE_DESCRIPTION, 'description', $fileObj->description()); $description_text->setDescription(_MD_SS_FILE_DESCRIPTION_DSC); $files_form->addElement($description_text, 7, 60); // FILE TO UPLOAD if ($fileid == 0) { $file_box = new XoopsFormFile(_MD_SS_FILE_TO_UPLOAD, "my_file", $max_imgsize); $file_box->setExtra("size ='50'"); $files_form->addElement($file_box); } $files_button_tray = new XoopsFormElementTray('', ''); $files_hidden = new XoopsFormHidden('op', 'uploadfile'); $files_button_tray->addElement($files_hidden); if ($fileid == 0) { $files_butt_create = new XoopsFormButton('', '', _MD_SS_UPLOAD, 'submit'); $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"'); $files_button_tray->addElement($files_butt_create);
function edititem($showmenu = false, $itemid = 0, $clone = false) { global $smartsection_current_page, $smartsection_file_handler, $smartsection_item_handler, $smartsection_category_handler, $xoopsUser, $xoopsModule, $xoopsConfig, $xoopsDB; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; include_once SMARTSECTION_ROOT_PATH . '/class/formdatetime.php'; // if there is a parameter, and the id exists, retrieve data: we're editing a item if ($itemid != 0) { // Creating the ITEM object $itemObj = $smartsection_item_handler->get($itemid); if (!$itemObj) { redirect_header("item.php", 1, _AM_SSECTION_NOITEMSELECTED); exit; } if ($clone) { $itemObj->setNew(); $itemObj->setVar('status', _SSECTION_STATUS_NOTSET); $itemObj->setVar('datesub', time()); } switch ($itemObj->status()) { case _SSECTION_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SSECTION_SUBMITTED; $breadcrumb_action2 = _AM_SSECTION_APPROVING; $page_title = _AM_SSECTION_SUBMITTED_TITLE; $page_info = _AM_SSECTION_SUBMITTED_INFO; $button_caption = _AM_SSECTION_APPROVE; $new_status = _SSECTION_STATUS_PUBLISHED; break; case _SSECTION_STATUS_PUBLISHED: $breadcrumb_action1 = _AM_SSECTION_PUBLISHED; $breadcrumb_action2 = _AM_SSECTION_EDITING; $page_title = _AM_SSECTION_PUBLISHEDEDITING; $page_info = _AM_SSECTION_PUBLISHEDEDITING_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_PUBLISHED; break; case _SSECTION_STATUS_OFFLINE: $breadcrumb_action1 = _AM_SSECTION_OFFLINE; $breadcrumb_action2 = _AM_SSECTION_EDITING; $page_title = _AM_SSECTION_OFFLINEEDITING; $page_info = _AM_SSECTION_OFFLINEEDITING_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_OFFLINE; break; case _SSECTION_STATUS_REJECTED: $breadcrumb_action1 = _AM_SSECTION_REJECTED; $breadcrumb_action2 = _AM_SSECTION_REJECTED; $page_title = _AM_SSECTION_REJECTED_EDIT; $page_info = _AM_SSECTION_REJECTED_EDIT_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_REJECTED; break; case _SSECTION_STATUS_NOTSET: // Then it's a clone... $breadcrumb_action1 = _AM_SSECTION_ITEMS; $breadcrumb_action2 = _AM_SSECTION_CLONE_NEW; $button_caption = _AM_SSECTION_CREATE; $new_status = _SSECTION_STATUS_PUBLISHED; $page_title = _AM_SSECTION_ITEM_DUPLICATING; $page_info = _AM_SSECTION_ITEM_DUPLICATING_DSC; break; case "default": default: $breadcrumb_action1 = _AM_SSECTION_ITEMS; $breadcrumb_action2 = _AM_SSECTION_EDITING; $page_title = _AM_SSECTION_PUBLISHEDEDITING; $page_info = _AM_SSECTION_PUBLISHEDEDITING_INFO; $button_caption = _AM_SSECTION_MODIFY; $new_status = _SSECTION_STATUS_PUBLISHED; break; } $categoryObj = $itemObj->category(); if ($showmenu) { smartsection_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartsection_collapsableBar('edititemtable', 'edititemicon', $page_title, $page_info); if (!$clone) { echo "<form><div style=\"margin-bottom: 10px;\">"; echo "<input type='button' name='button' onclick=\"location='item.php?op=clone&itemid=" . $itemObj->itemid() . "'\" value='" . _AM_SSECTION_CLONE_ITEM . "'> "; echo "</div></form>"; } } else { // there's no parameter, so we're adding an item $itemObj =& $smartsection_item_handler->create(); $itemObj->setVar('uid', $xoopsUser->uid()); $categoryObj =& $smartsection_category_handler->create(); $breadcrumb_action1 = _AM_SSECTION_ITEMS; $breadcrumb_action2 = _AM_SSECTION_CREATINGNEW; $button_caption = _AM_SSECTION_CREATE; $new_status = _SSECTION_STATUS_PUBLISHED; if ($showmenu) { smartsection_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0; $categoryObj->setVar('categoryid', $sel_categoryid); smartsection_collapsableBar('createitemtable', 'createitemicon', _AM_SSECTION_ITEM_CREATING, _AM_SSECTION_ITEM_CREATING_DSC); } // ITEM FORM $sform = new XoopsThemeForm(_AM_SSECTION_ITEMS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // CATEGORY $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid"); ob_start(); //$sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid())); $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid()); $category_label = new XoopsFormLabel(_AM_SSECTION_CATEGORY, ob_get_contents()); $category_label->setDescription(_AM_SSECTION_CATEGORY_DSC); $sform->addElement($category_label); ob_end_clean(); // TITLE $title_text = new XoopsFormText(_AM_SSECTION_TITLE, 'title', 50, 255, $itemObj->title(0, 'e')); $sform->addElement($title_text, true); if (SMARTSECTION_LEVEL >= 5) { // SUMMARY $summary_text = smartsection_getEditor(_AM_SSECTION_SUMMARY, 'summary', $itemObj->getVar('summary', 'e')); $summary_text->setDescription(_AM_SSECTION_SUMMARY_DSC); $sform->addElement($summary_text, false); // DISPLAY_SUMMARY $display_summary_radio = new XoopsFormRadioYN(_AM_SSECTION_DISPLAY_SUMMARY, 'display_summary', $itemObj->display_summary(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $sform->addElement($display_summary_radio); } // BODY /*if ($itemObj->address()) { // Main body : pagewrap $address_select = new XoopsFormSelect(_AM_SSECTION_BODY_SELECTFILE, "address", $itemObj->address()); $address_select->setDescription(_AM_SSECTION_BODY_SELECTFILE_DSC); $dir = smartsection_getUploadDir(true, 'content'); $folder = dir($dir); while($file = $folder->read()) { if ($file != "." && $file != "..") { $address_select->addOption($file, "".$file.""); } } $folder->close(); $sform->addElement($address_select); $sform->addElement(new XoopsFormHidden('body', '')); } else {*/ $body_text = smartsection_getEditor(_AM_SSECTION_BODY, 'body', $itemObj->getVar('body', 'e')); if (SMARTSECTION_LEVEL >= 5) { $body_text->setDescription(sprintf(_AM_SSECTION_BODY_DSC, SMARTSECTION_URL . "/admin/pagewrap_lookup.php")); } $sform->addElement($body_text); //} if (SMARTSECTION_LEVEL >= 5) { // Available pages to wrap $wrap_pages = XoopsLists::getHtmlListAsArray(smartsection_getUploadDir(true, 'content')); $available_wrap_pages_text = array(); foreach ($wrap_pages as $page) { $available_wrap_pages_text[] = "<span onclick='smartsectionPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>"; } $available_wrap_pages = new XoopsFormLabel(_AM_SSECTION_AVAILABLE_PAGE_WRAP, implode(', ', $available_wrap_pages_text)); $available_wrap_pages->setDescription(_AM_SSECTION_AVAILABLE_PAGE_WRAP_DSC); $sform->addElement($available_wrap_pages); // Tags if (smartsection_tag_module_included()) { include_once XOOPS_ROOT_PATH . "/modules/tag/include/formtag.php"; $text_tags = new XoopsFormTag("item_tag", 60, 255, $itemObj->getVar('item_tag', 'e'), 0); $sform->addElement($text_tags); } // IMAGE $image_array = XoopsLists::getImgListAsArray(smartsection_getImageDir('item')); $image_select = new XoopsFormSelect('', 'image', $itemObj->image()); //$image_select -> addOption ('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray(_AM_SSECTION_IMAGE_ITEM, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartsection_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_SSECTION_IMAGE_ITEM_DSC); $sform->addElement($image_tray); // IMAGE UPLOAD $max_size = 5000000; $image_file_box = new XoopsFormFile(_AM_SSECTION_IMAGE_UPLOAD, "image_file", $max_size); $image_file_box->setExtra("size ='50'"); $image_file_box->setDescription(_AM_SSECTION_IMAGE_UPLOAD_ITEM_DSC); $sform->addElement($image_file_box); } // File upload UPLOAD $file_box = new XoopsFormFile(smartsection_new_feature_tag() . _AM_SSECTION_ITEM_UPLOAD_FILE, "userfile", 0); $file_box->setDescription(_AM_SSECTION_ITEM_UPLOAD_FILE_DSC . smartsection_new_feature_tag()); $file_box->setExtra("size ='50'"); $sform->addElement($file_box); // Uid /* We need to retreive the users manually because for some reason, on the frxoops.org server, the method users::getobjects encounters a memory error */ $uid = $itemObj->uid(); $uid_select = new XoopsFormSelect(_AM_SSECTION_UID, 'uid', $uid, 1, false); $uid_select->setDescription(_AM_SSECTION_UID_DSC); $sql = "SELECT uid, uname FROM " . $xoopsDB->prefix('users') . " ORDER BY uname ASC"; $result = $xoopsDB->query($sql); $users_array = array(); $users_array[0] = $xoopsConfig['anonymous']; while ($myrow = $xoopsDB->fetchArray($result)) { $users_array[$myrow['uid']] = $myrow['uname']; } $uid_select->addOptionArray($users_array); $sform->addElement($uid_select); // Datesub $datesub = $itemObj->getVar('datesub') == 0 ? time() : $itemObj->getVar('datesub'); $datesub_datetime = new SmartsectionFormDateTime(_AM_SSECTION_DATESUB, 'datesub', $size = 15, $datesub); $datesub_datetime->setDescription(_AM_SSECTION_DATESUB_DSC); $sform->addElement($datesub_datetime); // STATUS $options = array(_SSECTION_STATUS_PUBLISHED => _AM_SSECTION_PUBLISHED, _SSECTION_STATUS_OFFLINE => _AM_SSECTION_OFFLINE, _SSECTION_STATUS_SUBMITTED => _AM_SSECTION_SUBMITTED, _SSECTION_STATUS_REJECTED => _AM_SSECTION_REJECTED); $status_select = new XoopsFormSelect(_AM_SSECTION_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SSECTION_STATUS_DSC); $sform->addElement($status_select); if (SMARTSECTION_LEVEL > 0) { // Short url $text_short_url = new XoopsFormText(_AM_SSECTION_ITEM_SHORT_URL, 'short_url', 50, 255, $itemObj->short_url('e')); $text_short_url->setDescription(_AM_SSECTION_ITEM_SHORT_URL_DSC); $sform->addElement($text_short_url); // Meta Keywords $text_meta_keywords = new XoopsFormTextArea(_AM_SSECTION_ITEM_META_KEYWORDS, 'meta_keywords', $itemObj->meta_keywords('e'), 7, 60); $text_meta_keywords->setDescription(_AM_SSECTION_ITEM_META_KEYWORDS_DSC); $sform->addElement($text_meta_keywords); // Meta Description $text_meta_description = new XoopsFormTextArea(_AM_SSECTION_ITEM_META_DESCRIPTION, 'meta_description', $itemObj->meta_description('e'), 7, 60); $text_meta_description->setDescription(_AM_SSECTION_ITEM_META_DESCRIPTION_DSC); $sform->addElement($text_meta_description); } // WEIGHT $sform->addElement(new XoopsFormText(_AM_SSECTION_WEIGHT, 'weight', 5, 5, $itemObj->weight()), true); if (SMARTSECTION_LEVEL >= 5) { // COMMENTS $addcomments_radio = new XoopsFormRadioYN(_AM_SSECTION_ALLOWCOMMENTS, 'cancomment', $itemObj->cancomment(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $sform->addElement($addcomments_radio); } // PER ITEM PERMISSIONS $member_handler =& xoops_gethandler('member'); $group_list = $member_handler->getGroupList(); $groups_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_ITEM, 'groups[]', $itemObj->getGroups_read()); $groups_checkbox->setDescription(_AM_SSECTION_PERMISSIONS_ITEM_DSC); foreach ($group_list as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $groups_checkbox->addOption($group_id, $group_name); } } $sform->addElement($groups_checkbox); $p_view_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PARTIAL_VIEW, 'partial_view[]', $itemObj->partial_view()); $p_view_checkbox->setDescription(_AM_SSECTION_PARTIAL_VIEWDSC); foreach ($group_list as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $p_view_checkbox->addOption($group_id, $group_name); } } $sform->addElement($p_view_checkbox); /*$partial_view_radio = new XoopsFormRadioYN(_AM_SSECTION_PARTIAL_VIEW, 'partial_view', $itemObj->partial_view(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $partial_view_radio->setDescription(_AM_SSECTION_PARTIAL_VIEWDSC); $sform->addElement($partial_view_radio);*/ if (SMARTSECTION_LEVEL >= 5) { // VARIOUS OPTIONS $options_tray = new XoopsFormElementTray(_AM_SSECTION_OPTIONS, '<br />'); $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $itemObj->dohtml()); $html_checkbox->addOption(1, _AM_SSECTION_DOHTML); $options_tray->addElement($html_checkbox); $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $itemObj->dosmiley()); $smiley_checkbox->addOption(1, _AM_SSECTION_DOSMILEY); $options_tray->addElement($smiley_checkbox); $xcodes_checkbox = new XoopsFormCheckBox('', 'doxcode', $itemObj->doxcode()); $xcodes_checkbox->addOption(1, _AM_SSECTION_DOXCODE); $options_tray->addElement($xcodes_checkbox); $images_checkbox = new XoopsFormCheckBox('', 'doimage', $itemObj->doimage()); $images_checkbox->addOption(1, _AM_SSECTION_DOIMAGE); $options_tray->addElement($images_checkbox); $linebreak_checkbox = new XoopsFormCheckBox('', 'dobr', $itemObj->dobr()); $linebreak_checkbox->addOption(1, _AM_SSECTION_DOLINEBREAK); $options_tray->addElement($linebreak_checkbox); $sform->addElement($options_tray); } // item ID if ($clone) { $itemid = 0; } $sform->addElement(new XoopsFormHidden('itemid', $itemid)); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'additem'); $button_tray->addElement($hidden); if (!$itemid) { // there's no itemid? Then it's a new item // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SSECTION_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SSECTION_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SSECTION_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); smartsection_close_collapsable('createitemtable', 'createitemicon'); } else { // else, we're editing an existing item // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SSECTION_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); smartsection_close_collapsable('edititemtable', 'edititemicon'); } if (SMARTSECTION_LEVEL >= 5) { smartsection_collapsableBar('pagewraptable', 'pagewrapicon', _AM_SSECTION_PAGEWRAP, _AM_SSECTION_PAGEWRAPDSC); $dir = smartsection_getUploadDir(true, 'content'); if (!eregi("777", decoct(fileperms($dir)))) { echo "<font color='FF0000'><h4>" . _AM_SSECTION_PERMERROR . "</h4></font>"; } // Upload File echo "<form name='form_name2' id='form_name2' action='pw_upload_file.php' method='post' enctype='multipart/form-data'>"; echo "<table cellspacing='1' width='100%' class='outer'>"; echo "<tr><th colspan='2'>" . _AM_SSECTION_UPLOAD_FILE . "</th></tr>"; echo "<tr valign='top' align='left'><td class='head'>" . _AM_SSECTION_SEARCH_PW . "</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='30' /></td></tr>"; echo "<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000' /></td><td class='even'><input type='submit' name='submit' value='" . _AM_SSECTION_UPLOAD . "' /></td></tr>"; echo "<input type='hidden' name='backto' value='{$smartsection_current_page}'/>"; echo "</table>"; echo "</form>"; // Delete File $form = new XoopsThemeForm(_AM_SSECTION_DELETEFILE, "form_name", "pw_delete_file.php"); $pWrap_select = new XoopsFormSelect(smartsection_getUploadDir(true, 'content'), "address"); $folder = dir($dir); while ($file = $folder->read()) { if ($file != "." && $file != "..") { $pWrap_select->addOption($file, $file); } } $folder->close(); $form->addElement($pWrap_select); $delfile = "delfile"; $form->addElement(new XoopsFormHidden('op', $delfile)); $submit = new XoopsFormButton("", "submit", _AM_SSECTION_BUTTON_DELETE, "submit"); $form->addElement($submit); $form->addElement(new XoopsFormHidden('backto', $smartsection_current_page)); $form->display(); smartsection_close_collapsable('pagewraptable', 'pagewrapicon'); } unset($hidden); if ($itemid != 0) { showfiles($itemObj); } }
// SPAW Config include XOOPS_ROOT_PATH . '/common/spaw/spaw_control.class.php'; if (tinyd_check_browser_can_use_spaw()) { ob_start(); $sw = new SPAW_Wysiwyg('message', $message); $sw->show(); $form->addElement(new XoopsFormLabel(_TC_CONTENT, ob_get_contents())); ob_end_clean(); $spaw_flag = true; } } if (!$spaw_flag) { if (empty($_GET['useplain'])) { $t_area = new XoopsFormDhtmlTextArea(_TC_CONTENT, 'message', htmlspecialchars($message, ENT_QUOTES), $body_tarea_height, $tarea_width); } else { $t_area = new XoopsFormTextArea(_TC_CONTENT . "<br /><br /><br /><br /><a href='{$mymodurl}/admin/text_wiki_sample.php?lang={$xoopsConfig['language']}' target='_blak'>Text_Wiki Sample</a>", 'message', htmlspecialchars($message, ENT_QUOTES), $body_tarea_height, $tarea_width); } $t_area->setExtra("style='width: {$tarea_width}em;'"); $form->addElement($t_area); } // options $option_tray = new XoopsFormElementTray(_OPTIONS, '<br />'); // smiley $smiley_checkbox = new XoopsFormCheckBox('', 'nosmiley', $nosmiley); $smiley_checkbox->addOption(1, _DISABLESMILEY); $option_tray->addElement($smiley_checkbox); // nobreaks if ($spaw_flag) { $form->addElement(new XoopsFormHidden('nobreaks', 1)); } else { $breaks_checkbox = new XoopsFormCheckBox('', 'nobreaks', $nobreaks);
function editfolder_text($showmenu = false, $folderid, $languageid) { global $xoopsDB, $smartmedia_folder_handler, $xoopsUser, $myts, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; echo "<script type=\"text/javascript\" src=\"funcs.js\"></script>"; echo "<style>"; echo "<!-- "; echo "select { width: 130px; }"; echo "-->"; echo "</style>"; $cat_sel = ''; $folderObj = $smartmedia_folder_handler->get($folderid, $languageid); if ($languageid == 'new') { $bread_lang = _AM_SMEDIA_CREATE; } else { $bread_lang = ucfirst($languageid); } if ($showmenu) { smartmedia_adminMenu(2, _AM_SMEDIA_FOLDERS . " > " . _AM_SMEDIA_LANGUAGE_INFO . " > " . $bread_lang); } echo "<br />\n"; smartmedia_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SMEDIA_FOLDER_LANGUAGE_INFO_EDITING . "</h3>"; echo "<div id='bottomtable'>"; echo "<span style=\"color: #567; margin: 3px 0 18px 0; font-size: small; display: block; \">" . _AM_SMEDIA_FOLDER_LANGUAGE_INFO_EDITING_INFO . "</span>"; // Start folder form $sform = new XoopsThemeForm(_AM_SMEDIA_FOLDER, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); $sform->addElement(new XoopsFormHidden('folderid', $folderid)); // Language $languageOptions = array(); $languageList = XoopsLists::getLangList(); $createdLanguages = $folderObj->getCreatedLanguages(); foreach ($languageList as $language) { if ($languageid != 'new' || !in_array($language, $createdLanguages)) { $languageOptions[$language] = $language; } } $language_select = new XoopsFormSelect(_AM_SMEDIA_LANGUAGE_ITEM, 'languageid', $languageid); $language_select->addOptionArray($languageOptions); $language_select->setDescription(_AM_SMEDIA_LANGUAGE_ITEM_DSC); if ($languageid != 'new') { $language_select->setExtra(smartmedia_make_control_disabled()); $sform->addElement(new XoopsFormHidden('languageid', $languageid)); } $sform->addElement($language_select, true); // title $sform->addElement(new XoopsFormText(_AM_SMEDIA_FOLDER_TITLE, 'title', 50, 255, $folderObj->title()), true); // title $sform->addElement(new XoopsFormText(_AM_SMEDIA_FOLDER_TITLE_REQ, 'title', 50, 255, $folderObj->title()), true); // short_title //$sform->addElement(new XoopsFormText(_AM_SMEDIA_FOLDER_SHORT_TITLE, 'short_title', 50, 255, $folderObj->short_title())); // summary $summary = new XoopsFormTextArea(_AM_SMEDIA_FOLDER_SUMMARY, 'summary', $folderObj->summary('e'), 3, 60); $summary->setDescription(_AM_SMEDIA_FOLDER_SUMMARYDSC); $sform->addElement($summary); // Description $description_text = new XoopsFormTextArea(_AM_SMEDIA_FOLDER_DESCRIPTION, 'description', $folderObj->description('e'), 7, 60); $description_text->setDescription(_AM_SMEDIA_FOLDER_DESCRIPTIONDSC); $sform->addElement($description_text); // Meta-Description $meta = new XoopsFormTextArea(_AM_SMEDIA_FOLDER_META_DESCRIPTION, 'meta_description', $folderObj->meta_description('e'), 7, 60); $meta->setDescription(_AM_SMEDIA_CLIP_META_DESCRIPTIONDSC); $sform->addElement($meta); $sform->addElement(new XoopsFormHidden('itemType', 'item_text')); // Action buttons tray $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addfolder_text'); $button_tray->addElement($hidden); if ($languageid == 'new') { // We are creating a new folder language info $butt_create = new XoopsFormButton('', '', _AM_SMEDIA_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addfolder_text\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SMEDIA_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SMEDIA_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // We are editing a folder language info $butt_create = new XoopsFormButton('', '', _AM_SMEDIA_MODIFY, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addfolder_text\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SMEDIA_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); echo "</div>"; unset($hidden); }
function editclient($showmenu = false, $id = 0) { global $client_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a client if ($id != 0) { // Creating the client object $clientObj = new SmartclientClient($id); if ($clientObj->notLoaded()) { redirect_header("client.php", 1, _AM_SCLIENT_NOCLIENTSELECTED); exit; } switch ($clientObj->status()) { case _SCLIENT_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SCLIENT_SUBMITTED_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_APPROVING; $page_title = _AM_SCLIENT_SUBMITTED_TITLE; $page_info = _AM_SCLIENT_SUBMITTED_INFO; $button_caption = _AM_SCLIENT_APPROVE; $new_status = _SCLIENT_STATUS_ACTIVE; break; case _SCLIENT_STATUS_ACTIVE: $breadcrumb_action1 = _AM_SCLIENT_ACTIVE_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_EDITING; $page_title = _AM_SCLIENT_ACTIVE_EDITING; $page_info = _AM_SCLIENT_ACTIVE_EDITING_INFO; $button_caption = _AM_SCLIENT_MODIFY; $new_status = _SCLIENT_STATUS_ACTIVE; break; case _SCLIENT_STATUS_INACTIVE: $breadcrumb_action1 = _AM_SCLIENT_INACTIVE_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_EDITING; $page_title = _AM_SCLIENT_INACTIVE_EDITING; $page_info = _AM_SCLIENT_INACTIVE_EDITING_INFO; $button_caption = _AM_SCLIENT_MODIFY; $new_status = _SCLIENT_STATUS_INACTIVE; break; case _SCLIENT_STATUS_REJECTED: $breadcrumb_action1 = _AM_SCLIENT_REJECTED_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_EDITING; $page_title = _AM_SCLIENT_REJECTED_EDITING; $page_info = _AM_SCLIENT_REJECTED_EDITING_INFO; $button_caption = _AM_SCLIENT_MODIFY; $new_status = _SCLIENT_STATUS_REJECTED; break; case "default": default: break; } if ($showmenu) { smartclient_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartclient_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . $page_title . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $page_info . "</span>"; echo "<div id='bottomtable'>"; } else { // there's no parameter, so we're adding a client $clientObj =& $client_handler->create(); $breadcrumb_action1 = _AM_SCLIENT_CLIENTS; $breadcrumb_action2 = _AM_SCLIENT_CREATE; $button_caption = _AM_SCLIENT_CREATE; $new_status = _SCLIENT_STATUS_ACTIVE; if ($showmenu) { smartclient_adminMenu(1, $breadcrumb_action1 . " > " . $breadcrumb_action2); } smartclient_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SCLIENT_CLIENT_CREATING . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SCLIENT_CLIENT_CREATING_DSC . "</span>"; echo "<div id='bottomtable'>"; } // CLIENT FORM $sform = new XoopsThemeForm(_AM_SCLIENT_CLIENTS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // TITLE $title_text = new XoopsFormText(_CO_SCLIENT_TITLE_REQ, 'title', 50, 255, $clientObj->title('e')); $sform->addElement($title_text, true); // LOGO $logo_array =& XoopsLists::getImgListAsArray(smartclient_getImageDir()); $logo_select = new XoopsFormSelect('', 'image', $clientObj->image()); $logo_select->addOption('-1', '---------------'); $logo_select->addOptionArray($logo_array); $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTCLIENT_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); $logo_tray = new XoopsFormElementTray(_AM_SCLIENT_LOGO, ' '); $logo_tray->addElement($logo_select); $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartclient_getImageDir('', false) . $clientObj->image() . "' name='image3' id='image3' alt='' />")); $logo_tray->setDescription(_AM_SCLIENT_LOGO_DSC); $sform->addElement($logo_tray); // LOGO UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SCLIENT_LOGO_UPLOAD, "logo_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(sprintf(_AM_SCLIENT_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); $sform->addElement($file_box); // IMAGE_URL $image_url_text = new XoopsFormText(_CO_SCLIENT_IMAGE_URL, 'image_url', 50, 255, $clientObj->image_url()); $image_url_text->setDescription(_CO_SCLIENT_IMAGE_URL_DSC); $sform->addElement($image_url_text, false); // URL $url_text = new XoopsFormText(_AM_SCLIENT_URL, 'url', 50, 255, $clientObj->url()); $url_text->setDescription(_AM_SCLIENT_URL_DSC); $sform->addElement($url_text, false); // SUMMARY $summary_text = new XoopsFormTextArea(_AM_SCLIENT_SUMMARY_REQ, 'summary', $clientObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_AM_SCLIENT_SUMMARY_DSC); $sform->addElement($summary_text, true); // DESCRIPTION $description_text = new XoopsFormDhtmlTextArea(_AM_SCLIENT_DESCRIPTION, 'description', $clientObj->description(0, 'e'), 15, 60); $description_text->setDescription(_AM_SCLIENT_DESCRIPTION_DSC); $sform->addElement($description_text, false); // CONTACT_NAME $contact_name_text = new XoopsFormText(_CO_SCLIENT_CONTACT_NAME, 'contact_name', 50, 255, $clientObj->contact_name('e')); $contact_name_text->setDescription(_CO_SCLIENT_CONTACT_NAME_DSC); $sform->addElement($contact_name_text, false); // CONTACT_EMAIL $contact_email_text = new XoopsFormText(_CO_SCLIENT_CONTACT_EMAIL, 'contact_email', 50, 255, $clientObj->contact_email('e')); $contact_email_text->setDescription(_CO_SCLIENT_CONTACT_EMAIL_DSC); $sform->addElement($contact_email_text, false); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SCLIENT_CONTACT_PHONE, 'contact_phone', 50, 255, $clientObj->contact_phone('e')); $contact_phone_text->setDescription(_CO_SCLIENT_CONTACT_PHONE_DSC); $sform->addElement($contact_phone_text, false); // ADRESS //$adress_text = new XoopsFormText(_CO_SCLIENT_ADRESS, 'adress', 50, 255, $clientObj->adress('e')); $adress_text = new XoopsFormTextArea(_CO_SCLIENT_ADRESS, 'adress', $clientObj->adress('e')); $adress_text->setDescription(_CO_SCLIENT_ADRESS_DSC); $sform->addElement($adress_text, false); // STATUS $options = $clientObj->getAvailableStatus(); $status_select = new XoopsFormSelect(_AM_SCLIENT_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SCLIENT_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $weight_text = new XoopsFormText(_AM_SCLIENT_WEIGHT, 'weight', 4, 4, $clientObj->weight()); $weight_text->setDescription(_AM_SCLIENT_WEIGHT_DSC); $sform->addElement($weight_text); // Client id $sform->addElement(new XoopsFormHidden('id', $clientObj->id())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addclient'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('original_status', $clientObj->status())); if (!$id) { // there's no id? Then it's a new client // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SCLIENT_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SCLIENT_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addclient\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SCLIENT_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SCLIENT_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing client // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SCLIENT_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addclient\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SCLIENT_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); unset($hidden); echo "</div>"; }
$fromname_text->setExtra($styleWidth); $fromemail_text = new XoopsFormText(_MI_TAF_FORMTHFROMEMAIL, "fromEmail", 40, 100, ''); $fromemail_text->setExtra($styleWidth); $_SESSION['usersSubject'] = $subject; $subject_text = new XoopsFormLabel(_MI_TAF_FORMTHSUBJ, $subject4show); $subject_text->setExtra($styleWidth); } else { $subject_text = new XoopsFormText(_MI_TAF_FORMTHSUBJ, "usersSubject", 50, 100, $subject4show); $subject_text->setExtra($styleWidth); } $to_text = new XoopsFormText(_MI_TAF_FORMTHTO, "usersTo", 40, 100, ''); $to_text->setExtra($styleWidth); $body_label = new XoopsFormLabel(_MI_TAF_FORMTHBODY, nl2br($comment4show)); $body_label->setExtra($styleWidth); $body_hidden = new XoopsFormHidden("usersComments", $comment4show); $comment_textarea = new XoopsFormTextArea(_MI_TAF_FORMTHBODY, "usersComments", $comment4show, 10, 40); $comment_textarea->setExtra($styleWidth); $ticket_hidden = $xoopsGTicket->getTicketXoopsForm(__LINE__); $submit_button = new XoopsFormButton("", "submit", _MI_TAF_BUTTONSEND, "submit"); $contact_form = new XoopsThemeForm(_MI_TAF_FORMTITLE, "tf_form", "index.php"); $contact_form->addElement($to_text, true); if (!is_object($xoopsUser)) { $contact_form->addElement($fromname_text, true); $contact_form->addElement($fromemail_text, true); } $contact_form->addElement($subject_text); if ($xoopsModuleConfig['can_bodyedit']) { $contact_form->addElement($comment_textarea, true); } else { $contact_form->addElement($body_label); $contact_form->addElement($body_hidden);
// This part is common to edit/add $sform -> addElement( new XoopsFormText( constant("_MD_{$MYDIRNAME}_ENTRY"), 'term', 40, 80, $term ), true ); $sform -> addElement( new XoopsFormText( constant("_MD_{$MYDIRNAME}_PROC").constant("_MD_{$MYDIRNAME}_HIRAGANA"), 'proc', 40, 80, $proc ), false ); if ( !$entryID && !$definition) // therez no entryID? Then itz a new entry { $definition = constant("_MD_{$MYDIRNAME}_WRITEHERE"); } if ( $xoopsModuleConfig['dhtmluse'] == '1' ) { $def_block = new XoopsFormDhtmlTextArea( constant("_MD_{$MYDIRNAME}_DEFINITION").constant("_MD_{$MYDIRNAME}_DONTUSETAG"), 'definition', $definition, 10, 40 ); } else { $def_block = new XoopsFormTextArea( constant("_MD_{$MYDIRNAME}_DEFINITION").constant("_MD_{$MYDIRNAME}_DONTUSETAG"), 'definition', $definition, 10, 40 ); } $def_block -> setExtra( 'onfocus="this.select()"' ); $sform -> addElement ( $def_block ); $sform -> addElement( new XoopsFormTextArea( constant("_MD_{$MYDIRNAME}_REFERENCE"), 'ref', $ref, 5, 40 ), false ); $sform -> addElement( new XoopsFormText( constant("_MD_{$MYDIRNAME}_URL"), 'url', 40, 80, $url ), false ); $button_tray = new XoopsFormElementTray( '', '' ); if ( is_object( $xoopsUser ) ) { $uid = $xoopsUser->getVar('uid'); $hidden_uid = new XoopsFormHidden( 'uid', intval($uid) ); $button_tray -> addElement( $hidden_uid );
function createElements() { global $xoopsDB; $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid"); // Parent Category ob_start(); $mytree->makeMySelBox("name", "weight", $this->targetObject->parentid(), 1, 'parentid'); //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") $this->addElement(new XoopsFormLabel(_AM_SSECTION_PARENT_CATEGORY_EXP, ob_get_contents())); ob_end_clean(); // Name $this->addElement(new XoopsFormText(_AM_SSECTION_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true); // Description $this->addElement(new XoopsFormTextArea(_AM_SSECTION_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60)); if (SMARTSECTION_LEVEL > 0) { // Header $text_header = smartsection_getEditor(_AM_SSECTION_CATEGORY_HEADER, 'header', $this->targetObject->header('e')); $text_header->setDescription(_AM_SSECTION_CATEGORY_HEADER_DSC); $this->addElement($text_header); } // IMAGE $image_array = XoopsLists::getImgListAsArray(smartsection_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/smartsection/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'"); $image_tray = new XoopsFormElementTray(_AM_SSECTION_IMAGE, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartsection_getImageDir('category', false) . $this->targetObject->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_SSECTION_IMAGE_DSC); $this->addElement($image_tray); // IMAGE UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SSECTION_IMAGE_UPLOAD, "image_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(_AM_SSECTION_IMAGE_UPLOAD_DSC); $this->addElement($file_box); if (SMARTSECTION_LEVEL > 0) { // Short url $text_short_url = new XoopsFormText(_AM_SSECTION_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e')); $text_short_url->setDescription(_AM_SSECTION_CATEGORY_SHORT_URL_DSC); $this->addElement($text_short_url); // Meta Keywords $text_meta_keywords = new XoopsFormTextArea(_AM_SSECTION_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->meta_keywords('e'), 7, 60); $text_meta_keywords->setDescription(_AM_SSECTION_CATEGORY_META_KEYWORDS_DSC); $this->addElement($text_meta_keywords); // Meta Description $text_meta_description = new XoopsFormTextArea(_AM_SSECTION_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60); $text_meta_description->setDescription(_AM_SSECTION_CATEGORY_META_DESCRIPTION_DSC); $this->addElement($text_meta_description); } // Weight $this->addElement(new XoopsFormText(_AM_SSECTION_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight())); if (SMARTSECTION_LEVEL > 0) { // Added by skalpa: custom template support $this->addElement(new XoopsFormText("Custom template", 'template', 50, 255, $this->targetObject->template('e')), false); } // READ PERMISSIONS $groups_read_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_CAT_READ, 'groups_read[]', $this->targetObject->getGroups_read()); foreach ($this->userGroups as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $groups_read_checkbox->addOption($group_id, $group_name); } } $this->addElement($groups_read_checkbox); // Apply permissions on all items $apply = isset($_POST['applyall']) ? intval($_POST['applyall']) : 0; $addapplyall_radio = new XoopsFormRadioYN(_AM_SSECTION_PERMISSIONS_APPLY_ON_ITEMS, 'applyall', $apply, ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . ''); $this->addElement($addapplyall_radio); // SUBMIT PERMISSIONS $groups_submit_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $this->targetObject->getGroups_submit()); $groups_submit_checkbox->setDescription(_AM_SSECTION_PERMISSIONS_CAT_SUBMIT_DSC); foreach ($this->userGroups as $group_id => $group_name) { if ($group_id != XOOPS_GROUP_ADMIN) { $groups_submit_checkbox->addOption($group_id, $group_name); } } $this->addElement($groups_submit_checkbox); if (SMARTSECTION_LEVEL > 0) { // Added by fx2024 // sub Categories $cat_tray = new XoopsFormElementTray(_AM_SSECTION_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), true); } $t = new XoopsFormText('', 'nb_subcats', 3, 2); $l = new XoopsFormLabel('', sprintf(_AM_SSECTION_ADD_OPT, $t->render())); $b = new XoopsFormButton('', 'submit', _AM_SSECTION_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); //End of fx2024 code } /* $module_id = $xoopsModule->getVar('mid'); $gperm_handler = &xoops_gethandler('groupperm'); $mod_perms = $gperm_handler->getGroupIds('category_moderation', $categoryid, $module_id); $moderators_select = new XoopsFormSelect('', 'moderators', $moderators, 5, true); $moderators_tray->addElement($moderators_select); $butt_mngmods = new XoopsFormButton('', '', 'Manage mods', 'button'); $butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"'); $moderators_tray->addElement($butt_mngmods); $butt_delmod = new XoopsFormButton('', '', 'Delete mod', 'button'); $butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"'); $moderators_tray->addElement($butt_delmod); $this->addElement($moderators_tray); */ $this->addElement(new XoopsFormHidden('categoryid', $this->targetObject->categoryid())); //$parentid = $this->targetObject->parentid('s'); //$this -> addElement( new XoopsFormHidden( 'parentid', $parentid ) ); $this->addElement(new XoopsFormHidden('nb_sub_yet', $this->subCatsCount)); }
function getTextArea($key) { $var = $this->targetObject->vars[$key]; // if no control has been created, let's create a default one if (!isset($this->targetObject->controls[$key])) { $control = array('name' => 'textarea', 'itemHandler' => false, 'method' => false, 'module' => false, 'form_editor' => 'default'); } else { $control = $this->targetObject->controls[$key]; } $xoops22 = smart_isXoops22(); $form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea'; /** * If the editor is 'default', retreive the default editor of this module */ if ($form_editor == 'default') { global $xoopsModuleConfig; $form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea'; } $caption = $var['form_caption']; $name = $key; $value = $this->targetObject->getVar($key); $value = $this->targetObject->getValueFor($key, true); $editor_configs = array(); $editor_configs["name"] = $name; $editor_configs["value"] = $value; if ($form_editor != 'textarea') { $editor_configs["rows"] = 35; $editor_configs["cols"] = 60; } if (isset($control['rows'])) { $editor_configs["rows"] = $control['rows']; } if (isset($control['cols'])) { $editor_configs["cols"] = $control['cols']; } $editor_configs["width"] = "100%"; $editor_configs["height"] = "400px"; $dhtml = true; $xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php'; if (file_exists($xoopseditorclass)) { include_once $xoopseditorclass; $editor = new XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = "textarea"); } else { switch ($form_editor) { case 'tiny': if (!$xoops22) { if (is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinytextarea.php")) { include_once XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinytextarea.php"; $editor = new XoopsFormTinyTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true); } else { if ($dhtml) { $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); } else { $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); } } } else { $editor = new XoopsFormEditor($caption, "tinyeditor", $editor_configs); } break; case 'dhtmltextarea': case 'dhtmltext': $editor = new XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60); if ($var['form_dsc']) { $editor->setDescription($var['form_dsc']); } break; case 'fckeditor': if (!$xoops22) { if (is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php")) { include_once XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php"; $editor = new XoopsFormFckeditor(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true); } else { if ($dhtml) { $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); } else { $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); } } } else { $editor = new XoopsFormEditor($caption, "fckeditor", $editor_configs); } break; case 'inbetween': if (!$xoops22) { if (is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php")) { include_once XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php"; $editor = new XoopsFormInbetweenTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true); } else { if ($dhtml) { $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); } else { $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); } } } else { $editor = new XoopsFormEditor($caption, "inbetween", $editor_configs); } break; case 'koivi': if (!$xoops22) { if (is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) { include_once XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php"; $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px'); } else { if ($dhtml) { $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); } else { $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); } } } else { $editor = new XoopsFormEditor($caption, "koivi", $editor_configs); } break; case "spaw": if (!$xoops22) { if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) { include_once XOOPS_ROOT_PATH . "/class/spaw/formspaw.php"; $editor = new XoopsFormSpaw($caption, $name, $value); } } else { $editor = new XoopsFormEditor($caption, "spaw", $editor_configs); } break; case "htmlarea": if (!$xoops22) { if (is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) { include_once XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php"; $editor = new XoopsFormHtmlarea($caption, $name, $value); } } else { $editor = new XoopsFormEditor($caption, "htmlarea", $editor_configs); } break; default: case 'textarea': $form_rows = isset($control['rows']) ? $control['rows'] : 5; $form_cols = isset($control['cols']) ? $control['cols'] : 60; $editor = new XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols); if ($var['form_dsc']) { $editor->setDescription($var['form_dsc']); } break; } } return $editor; }
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)); }
$category_label = new XoopsFormLabel(_MD_SF_CATEGORY_FAQ, ob_get_contents()); $category_label->setDescription(_MD_SF_CATEGORY_FAQ_DSC); $form->addElement($category_label); ob_end_clean(); // FAQ QUESTION $form->addElement(new XoopsFormTextArea(_MD_SF_QUESTION, 'question', $faqObj->question(), 7, 60), true); // ANSWER $answer_text = new XoopsFormDhtmlTextArea(_MD_SF_ANSWER_FAQ, 'answer', $answerObj->answer(), 15, 60); $answer_text->setDescription(_MD_SF_ANSWER_FAQ_DSC); $form->addElement($answer_text, true); // HOW DO I $howdoi_text = new XoopsFormText(_MD_SF_HOWDOI_FAQ, 'howdoi', 50, 255, $faqObj->howdoi()); $howdoi_text->setDescription(_MD_SF_HOWDOI_FAQ_DSC); $form->addElement($howdoi_text, false); // DIDUNO $diduno_text = new XoopsFormTextArea(_MD_SF_DIDUNO_FAQ, 'diduno', $faqObj->diduno(), 3, 60); $diduno_text->setDescription(_MD_SF_DIDUNO_FAQ_DSC); $form->addElement($diduno_text); // CONTEXT MODULE LINK // Retreive the list of module currently installed. The key value is the dirname /*$module_handler = &xoops_gethandler('module'); $modules_array = $module_handler->getList(null, true); $modulelink_select_array = array("url" => _MD_SF_SPECIFIC_URL_SELECT); $modulelink_select_array = array_merge($modules_array, $modulelink_select_array); $modulelink_select_array = array_merge(array("None" => _MD_SF_NONE, "All" => _MD_SF_ALL), $modulelink_select_array); $modulelink_select = new XoopsFormSelect('', 'modulelink', ''); $modulelink_select->addOptionArray($modulelink_select_array); $modulelink_tray = new XoopsFormElementTray(_MD_SF_CONTEXTMODULELINK_FAQ , ' '); $modulelink_tray->addElement($modulelink_select); $form->addElement($modulelink_tray);
function hypconfShowForm($config) { global $constpref, $mydirname, $mydirpath, $mytrustdirpath, $page, $xoopsConfig, $xoopsGTicket; if (!$config) { die('no configs'); } if (isset($config['error'])) { echo '<div class="error">' . join('</div><div class="error">', $config['error']) . '</div>'; unset($config['error']); } if (isset($config['contents'])) { echo $config['contents']; unset($config['contents']); } if ($config) { $count = count($config); include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; include_once dirname(dirname(__FILE__)) . '/class/formcheckbox.php'; if (!XC_CLASS_EXISTS('XoopsFormBreak')) { include_once dirname(dirname(__FILE__)) . '/class/formbreak.php'; } $form = new XoopsThemeForm(hypconf_constant($constpref . '_ADMENU_' . strtoupper($page)), 'pref_form', 'index.php'); $button_tray = new XoopsFormElementTray(""); for ($i = 0; $i < $count; $i++) { $description = defined($config[$i]['description']) ? constant($config[$i]['description']) : ''; //$title4tray = (!$description) ? hypconf_constant($config[$i]['title']) : hypconf_constant($config[$i]['title']).'<br /><br /><span style="font-weight:normal;">'.hypconf_constant($config[$i]['description']).'</span>'; // GIJ $title4tray = hypconf_constant($config[$i]['title']); $title = ''; // GIJ switch ($config[$i]['formtype']) { case 'textarea': $myts =& MyTextSanitizer::getInstance(); if ($config[$i]['valuetype'] == 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $config[$i]['value'] != '' ? new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars(implode('|', $config[$i]['value'])), 5, 50) : new XoopsFormTextArea($title, $config[$i]['name'], '', 5, 50); } else { $ele = new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars($config[$i]['value']), 5, 50); $ele->setExtra('class="norich"'); } break; case 'select': $size = 1; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size); $options = $config[$i]['options']; $opcount = count($options); foreach ($options as $option) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'select_multi': $size = 5; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size, true); $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'check': $ele = new HypconfFormCheckBox($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'yesno': $ele = new XoopsFormRadioYN($title, $config[$i]['name'], $config[$i]['value'], _YES, _NO); break; case 'password': $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $myts =& MyTextSanitizer::getInstance(); $ele = new XoopsFormPassword($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'])); break; case 'textbox': default: $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $myts =& MyTextSanitizer::getInstance(); $ele = new XoopsFormText($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'])); if ($config[$i]['valuetype'] === 'int') { $ele->setExtra(' style="text-align:right;"'); } break; } $ele_tray = new XoopsFormElementTray($title4tray, ''); $ele_tray->addElement($ele); $form->addElement($ele_tray); if ($description) { $form->insertBreak('<span style="font-weight:normal;">' . $description . '</span>', 'odd'); } unset($ele_tray); unset($ele); } $button_tray->addElement(new XoopsFormHidden('op', 'save')); $button_tray->addElement(new XoopsFormHidden('page', $page)); $xoopsGTicket->addTicketXoopsFormElement($button_tray, __LINE__, 1800, 'hypconf'); $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); $form->addElement($button_tray); $form->display(); } }
function hypconfShowForm($config) { global $constpref, $mydirname, $mydirpath, $mytrustdirpath, $page, $xoopsConfig, $xoopsGTicket; if (!$config) { die('no configs'); } if (isset($config['error'])) { echo '<div class="error">' . join('</div><div class="error">', $config['error']) . '</div>'; unset($config['error']); } if (isset($config['contents'])) { echo $config['contents']; unset($config['contents']); } $underContents = ''; if (isset($config['underContents'])) { $underContents = $config['underContents']; unset($config['underContents']); } if ($config) { $count = count($config); include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; include_once dirname(dirname(__FILE__)) . '/class/formcheckbox.php'; if (!XC_CLASS_EXISTS('XoopsFormBreak')) { include_once dirname(dirname(__FILE__)) . '/class/formbreak.php'; } $form = new XoopsThemeForm(hypconf_constant($constpref . '_ADMENU_' . strtoupper($page)), 'pref_form', 'index.php'); $button_tray = new XoopsFormElementTray(""); for ($i = 0; $i < $count; $i++) { $description = defined($config[$i]['description']) ? constant($config[$i]['description']) : ''; //$title4tray = (!$description) ? hypconf_constant($config[$i]['title']) : hypconf_constant($config[$i]['title']).'<br /><br /><span style="font-weight:normal;">'.hypconf_constant($config[$i]['description']).'</span>'; // GIJ $title4tray = hypconf_constant($config[$i]['title']); $title = ''; // GIJ switch ($config[$i]['formtype']) { case 'textarea': (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); if ($config[$i]['valuetype'] == 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $config[$i]['value'] != '' ? new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars(implode('|', $config[$i]['value'], _CHARSET)), 5, 50) : new XoopsFormTextArea($title, $config[$i]['name'], '', 5, 50); } else { $ele = new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET), 5, 50); $ele->setExtra('class="norich plain" spellcheck="false"'); } break; case 'select': $size = 1; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size); $options = $config[$i]['options']; $opcount = count($options); //var_dump($options); foreach ($options as $option) { if (isset($option['confop_value']) && isset($option['confop_name'])) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; } else { $optval = $optkey = $option; } $ele->addOption($optval, $optkey); } break; case 'select_multi': $size = 5; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size, true); $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'check': $ele = new HypconfFormCheckBox($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'radio': $ele = new XoopsFormRadio($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'yesno': $ele = new XoopsFormRadioYN($title, $config[$i]['name'], $config[$i]['value'], _YES, _NO); break; case 'password': $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ele = new XoopsFormPassword($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET)); break; case 'label': $ele = new XoopsFormLabel($title, $description); $description = ''; break; case 'theme': case 'theme_multi': $ele = $config[$i]['formtype'] !== 'theme_multi' ? new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value']) : new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], 5, true); $handle = opendir(XOOPS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^\\..*\$/", $file) && strtolower($file) != 'cvs') { $dirlist[$file] = $file; } } closedir($handle); $ele->addOption('', hypconf_constant($constpref . '_NOT_SPECIFY')); if (!empty($dirlist)) { asort($dirlist); $ele->addOptionArray($dirlist); } break; case 'tplset': $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value']); $tplset_handler =& xoops_gethandler('tplset'); $tplsetlist =& $tplset_handler->getList(); asort($tplsetlist); $ele->addOption('', hypconf_constant($constpref . '_NOT_SPECIFY')); foreach ($tplsetlist as $key => $name) { $ele->addOption($key, htmlspecialchars($name, ENT_QUOTES, _CHARSET)); } break; case 'textbox': default: $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ele = new XoopsFormText($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET)); if ($config[$i]['valuetype'] === 'int') { $ele->setExtra(' style="text-align:right;"'); } break; } $ele_tray = new XoopsFormElementTray($title4tray, ''); $ele_tray->addElement($ele); $form->addElement($ele_tray); if ($description) { $form->insertBreak('<span style="font-weight:normal;">' . $description . '</span>', 'odd'); } unset($ele_tray); unset($ele); } $button_tray->addElement(new XoopsFormHidden('op', 'save')); $button_tray->addElement(new XoopsFormHidden('page', $page)); $xoopsGTicket->addTicketXoopsFormElement($button_tray, __LINE__, 1800, 'hypconf'); $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); $form->addElement($button_tray); $form->display(); } if ($underContents) { echo '<div>' . $underContents . '</div>'; } }
function editfile($showmenu = false, $fileid = 0, $itemid = 0) { global $smartsection_file_handler, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // if there is a parameter, and the id exists, retrieve data: we're editing a file if ($fileid != 0) { // Creating the File object $fileObj = new smartsectionfile($fileid); if ($fileObj->notLoaded()) { redirect_header("javascript:history.go(-1)", 1, _AM_SSECTION_NOFILESELECTED); exit; } if ($showmenu) { smartsection_adminMenu(2, _AM_SSECTION_FILE . " > " . _AM_SSECTION_EDITING); } echo "<br />\n"; echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_SSECTION_FILE_EDITING . "</span>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SSECTION_FILE_EDITING_DSC . "</span>"; smartsection_collapsableBar('editfile', 'editfileicon', _AM_SSECTION_FILE_INFORMATIONS); } else { // there's no parameter, so we're adding an item $fileObj =& $smartsection_file_handler->create(); $fileObj->setVar('itemid', $itemid); if ($showmenu) { smartsection_adminMenu(2, _AM_SSECTION_FILE . " > " . _AM_SSECTION_FILE_ADD); } echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_SSECTION_FILE_ADDING . "</span>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SSECTION_FILE_ADDING_DSC . "</span>"; smartsection_collapsableBar('addfile', 'addfileicon', _AM_SSECTION_FILE_INFORMATIONS); } // FILES UPLOAD FORM $files_form = new XoopsThemeForm(_AM_SSECTION_UPLOAD_FILE, "files_form", xoops_getenv('PHP_SELF')); $files_form->setExtra("enctype='multipart/form-data'"); // NAME $name_text = new XoopsFormText(_AM_SSECTION_FILE_NAME, 'name', 50, 255, $fileObj->name()); $name_text->setDescription(_AM_SSECTION_FILE_NAME_DSC); $files_form->addElement($name_text, true); // DESCRIPTION $description_text = new XoopsFormTextArea(_AM_SSECTION_FILE_DESCRIPTION, 'description', $fileObj->description()); $description_text->setDescription(_AM_SSECTION_FILE_DESCRIPTION_DSC); $files_form->addElement($description_text, 7, 60); // FILE TO UPLOAD if ($fileid == 0) { $file_box = new XoopsFormFile(_AM_SSECTION_FILE_TO_UPLOAD, "userfile", 0); $file_box->setExtra("size ='50'"); $files_form->addElement($file_box); } $status_select = new XoopsFormRadioYN(_AM_SSECTION_FILE_STATUS, 'file_status', $fileObj->status()); $status_select->setDescription(_AM_SSECTION_FILE_STATUS_DSC); $files_form->addElement($status_select); $files_button_tray = new XoopsFormElementTray('', ''); $files_hidden = new XoopsFormHidden('op', 'uploadfile'); $files_button_tray->addElement($files_hidden); if ($fileid == 0) { $files_butt_create = new XoopsFormButton('', '', _AM_SSECTION_UPLOAD, 'submit'); $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"'); $files_button_tray->addElement($files_butt_create); $files_butt_another = new XoopsFormButton('', '', _AM_SSECTION_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 XoopsFormButton('', '', _AM_SSECTION_MODIFY, 'submit'); $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'modify\'"'); $files_button_tray->addElement($files_butt_create); } $files_butt_clear = new XoopsFormButton('', '', _AM_SSECTION_CLEAR, 'reset'); $files_button_tray->addElement($files_butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $files_button_tray->addElement($butt_cancel); $files_form->addElement($files_button_tray); // fileid $files_form->addElement(new XoopsFormHidden('fileid', $fileid)); // itemid $files_form->addElement(new XoopsFormHidden('itemid', $itemid)); $files_form->display(); if ($fileid != 0) { smartsection_close_collapsable('editfile', 'editfileicon'); } else { smartsection_close_collapsable('addfile', 'addfileicon'); } }
function editField() { global $oAdminButton; $eventsrv =& xhelpNewEventService(); $session =& Session::singleton(); $regex_array =& _getRegexArray(); if (!isset($_REQUEST['id'])) { redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'manageDepartments'), false), 3, _AM_XHELP_MESSAGE_NO_FIELD); } $fld_id = intval($_REQUEST['id']); $hField =& xhelpGetHandler('ticketField'); if (!($field =& $hField->get($fld_id))) { redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'manageDepartments'), false), 3, _AM_XHELP_MESSAGE_NO_FIELD); } if (!isset($_POST['editField'])) { //Get Custom Field From session (if exists) $field_info = $session->get('xhelp_editField_' . $fld_id); $field_errors = $session->get('xhelp_editFieldErrors_' . $fld_id); if (!$field_info === false) { $fld_controltype = $field_info['controltype']; $fld_datatype = $field_info['datatype']; $fld_departments = $field_info['departments']; $fld_name = $field_info['name']; $fld_fieldname = $field_info['fieldname']; $fld_description = $field_info['description']; $fld_required = $field_info['required']; $fld_length = $field_info['length']; $fld_weight = $field_info['weight']; $fld_defaultvalue = $field_info['defaultvalue']; $fld_values = $field_info['values']; $fld_validation = $field_info['validation']; } else { $hFDept =& xhelpGetHandler('ticketFieldDepartment'); $depts =& $hFDept->departmentsByField($field->getVar('id'), true); $fld_controltype = $field->getVar('controltype'); $fld_datatype = $field->getVar('datatype'); $fld_departments = array_keys($depts); $fld_name = $field->getVar('name'); $fld_fieldname = $field->getVar('fieldname'); $fld_description = $field->getVar('description'); $fld_required = $field->getVar('required'); $fld_length = $field->getVar('fieldlength'); $fld_weight = $field->getVar('weight'); $fld_defaultvalue = $field->getVar('defaultvalue'); $fld_values = _formatValues($field->getVar('fieldvalues')); $fld_validation = $field->getVar('validation'); } //Display Field modification xoops_cp_header(); echo $oAdminButton->renderButtons('manfields'); //Edit Field Form $controls = xhelpGetControlArray(); $control_select = new XoopsFormSelect(_AM_XHELP_TEXT_CONTROLTYPE, 'fld_controltype', $fld_controltype); $control_select->setDescription(_AM_XHELP_TEXT_CONTROLTYPE_DESC); foreach ($controls as $key => $control) { $control_select->addOption($key, $control['label']); } $datatypes = array(_XHELP_DATATYPE_TEXT => _XHELP_DATATYPE_TEXT, _XHELP_DATATYPE_NUMBER_INT => _XHELP_DATATYPE_NUMBER_INT, _XHELP_DATATYPE_NUMBER_DEC => _XHELP_DATATYPE_NUMBER_DEC); $datatype_select = new XoopsFormSelect(_AM_XHELP_TEXT_DATATYPE, 'fld_datatype', $fld_datatype); $datatype_select->setDescription(_AM_XHELP_TEXT_DATATYPE_DESC); $datatype_select->addOptionArray($datatypes); $hDepts =& xhelpGetHandler('department'); $depts =& $hDepts->getObjects(); $dept_select = new XoopsFormSelect(_AM_XHELP_TEXT_DEPARTMENTS, 'fld_departments', $fld_departments, 5, true); $dept_select->setDescription(_AM_XHELP_TEXT_DEPT_DESC); foreach ($depts as $obj) { $dept_select->addOption($obj->getVar('id'), $obj->getVar('department')); } unset($depts); if (!$field_errors === false) { xhelpRenderErrors($field_errors, xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'clearEditSession', 'id' => $fld_id))); } $form = new xhelpForm(_AM_XHELP_EDIT_FIELD, 'edit_field', xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fld_id))); $nameEle = new XoopsFormText(_AM_XHELP_TEXT_NAME, 'fld_name', 30, 64, $fld_name); $nameEle->setDescription(_AM_XHELP_TEXT_NAME_DESC); $form->addElement($nameEle); $fieldnameEle = new XoopsFormText(_AM_XHELP_TEXT_FIELDNAME, 'fld_fieldname', 30, 64, $fld_fieldname); $fieldnameEle->setDescription(_AM_XHELP_TEXT_FIELDNAME_DESC); $form->addElement($fieldnameEle); $descriptionEle = new XoopsFormTextArea(_AM_XHELP_TEXT_DESCRIPTION, 'fld_description', $fld_description, 5, 60); $descriptionEle->setDescription(_AM_XHELP_TEXT_DESCRIPTION_DESC); $form->addElement($descriptionEle); $form->addElement($dept_select); $form->addElement($control_select); $form->addElement($datatype_select); $required = new XoopsFormRadioYN(_AM_XHELP_TEXT_REQUIRED, 'fld_required', $fld_required); $required->setDescription(_AM_XHELP_TEXT_REQUIRED_DESC); $form->addElement($required); $lengthEle = new XoopsFormText(_AM_XHELP_TEXT_LENGTH, 'fld_length', 5, 5, $fld_length); $lengthEle->setDescription(_AM_XHELP_TEXT_LENGTH_DESC); $form->addElement($lengthEle); $widthEle = new XoopsFormText(_AM_XHELP_TEXT_WEIGHT, 'fld_weight', 5, 5, $fld_weight); $widthEle->setDescription(_AM_XHELP_TEXT_WEIGHT_DESC); $form->addElement($widthEle); $regex_control = new xhelpFormRegex(_AM_XHELP_TEXT_VALIDATION, 'fld_valid', $fld_validation); $regex_control->setDescription(_AM_XHELP_TEXT_VALIDATION_DESC); $regex_control->addOptionArray($regex_array); $form->addElement($regex_control); $defaultValueEle = new XoopsFormText(_AM_XHELP_TEXT_DEFAULTVALUE, 'fld_defaultvalue', 30, 100, $fld_defaultvalue); $defaultValueEle->setDescription(_AM_XHELP_TEXT_DEFAULTVALUE_DESC); $form->addElement($defaultValueEle); $values = new XoopsFormTextArea(_AM_XHELP_TEXT_FIELDVALUES, 'fld_values', $fld_values, 5, 60); $values->setDescription(_AM_XHELP_TEXT_FIELDVALUES_DESC); $form->addElement($values); $btn_tray = new XoopsFormElementTray(''); $btn_tray->addElement(new XoopsFormButton('', 'editField', _AM_XHELP_BUTTON_SUBMIT, 'submit')); $btn_tray->addElement(new XoopsFormButton('', 'cancel', _AM_XHELP_BUTTON_CANCEL)); $btn_tray->addElement(new XoopsFormHidden('id', $fld_id)); $form->addElement($btn_tray); echo $form->render(); xhelpAdminFooter(); xoops_cp_footer(); } else { //Validate Field Information $has_errors = false; $errors = array(); $values =& _parseValues($_POST['fld_values']); if (!($control = xhelpGetControl($_POST['fld_controltype']))) { $has_errors = true; $errors['fld_controltype'][] = _AM_XHELP_VALID_ERR_CONTROLTYPE; } $fld_needslength = $control['needs_length']; $fld_needsvalues = $control['needs_values']; //name field filled? if (trim($_POST['fld_name']) == '') { $has_errors = true; $errors['fld_name'][] = _AM_XHELP_VALID_ERR_NAME; } //fieldname filled if (trim($_POST['fld_fieldname']) == '') { $has_errors = true; $errors['fld_fieldname'][] = _AM_XHELP_VALID_ERR_FIELDNAME; } //fieldname unique? $crit = new CriteriaCompo(new Criteria('id', $fld_id, '!=')); $crit->add(new Criteria('fieldname', $_POST['fld_fieldname'])); if ($hField->getCount($crit)) { $has_errors = true; $errors['fld_fieldname'][] = _AM_XHELP_VALID_ERR_FIELDNAME_UNIQUE; } //Length filled if (intval($_POST['fld_length']) == 0 && $fld_needslength == true) { $has_errors = true; $errors['fld_length'][] = sprintf(_AM_XHELP_VALID_ERR_LENGTH, _XHELP_FIELD_MINLEN, _XHELP_FIELD_MAXLEN); } //default value in value set? if (count($values)) { if (!in_array($_POST['fld_defaultvalue'], $values, true) && !array_key_exists($_POST['fld_defaultvalue'], $values)) { $has_errors = true; $errors['fld_defaultvalue'][] = _AM_XHELP_VALID_ERR_DEFAULTVALUE; } //length larger than longest value? $length = intval($_POST['fld_length']); foreach ($values as $key => $value) { if (strlen($key) > $length) { $has_errors = true; $errors['fld_values'][] = sprintf(_AM_XHELP_VALID_ERR_VALUE_LENGTH, htmlentities($key), $length); } } } elseif ($fld_needsvalues) { $has_errors = true; $errors['fld_values'][] = _AM_XHELP_VALID_ERR_VALUE; } if ($has_errors) { $afield = array(); $afield['name'] = $_POST['fld_name']; $afield['description'] = $_POST['fld_description']; $afield['fieldname'] = $_POST['fld_fieldname']; $afield['departments'] = $_POST['fld_departments']; $afield['controltype'] = $_POST['fld_controltype']; $afield['datatype'] = $_POST['fld_datatype']; $afield['required'] = $_POST['fld_required']; $afield['weight'] = $_POST['fld_weight']; $afield['defaultvalue'] = $_POST['fld_defaultvalue']; $afield['values'] = $_POST['fld_values']; $afield['length'] = $_POST['fld_length']; $afield['validation'] = $_POST['fld_valid_select'] == $_POST['fld_valid_txtbox'] ? $_POST['fld_valid_select'] : $_POST['fld_valid_txtbox']; $session->set('xhelp_editField_' . $fld_id, $afield); $session->set('xhelp_editFieldErrors_' . $fld_id, $errors); //Redirect to edit page (display errors); header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fld_id), false)); exit; } //Store Modified Field info $field->setVar('name', $_POST['fld_name']); $field->setVar('description', $_POST['fld_description']); $field->setVar('fieldname', $_POST['fld_fieldname']); $field->setVar('controltype', $_POST['fld_controltype']); $field->setVar('datatype', $_POST['fld_datatype']); $field->setVar('fieldlength', $_POST['fld_length']); $field->setVar('required', $_POST['fld_required']); $field->setVar('weight', $_POST['fld_weight']); $field->setVar('defaultvalue', $_POST['fld_defaultvalue']); $field->setVar('validation', $_POST['fld_valid_select'] == $_POST['fld_valid_txtbox'] ? $_POST['fld_valid_select'] : $_POST['fld_valid_txtbox']); $field->setValues($values); $field->addDepartments($_POST['fld_departments']); if ($hField->insert($field)) { _clearEditSessionVars($fld_id); redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php'), 3, _AM_XHELP_MSG_FIELD_UPD_OK); } else { redirect_header(xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fld_id), false), 3, _AM_XHELP_MSG_FIELD_UPD_ERR); } } }
function editpartner($showmenu = false, $id = 0) { global $xoopsDB, $smartpartner_partner_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; if (!isset($smartpartner_partner_handler)) { $smartpartner_partner_handler =& smartpartner_gethandler('partner'); } include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a partner if ($id != 0) { // Creating the partner object $partnerObj = new SmartpartnerPartner($id); if ($partnerObj->notLoaded()) { redirect_header("partner.php", 1, _AM_SPARTNER_NOPARTNERSELECTED); exit; } switch ($partnerObj->status()) { case _SPARTNER_STATUS_SUBMITTED: $breadcrumb_action1 = _AM_SPARTNER_SUBMITTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_APPROVING; $page_title = _AM_SPARTNER_SUBMITTED_TITLE; $page_info = _AM_SPARTNER_SUBMITTED_INFO; $button_caption = _AM_SPARTNER_APPROVE; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_ACTIVE: $breadcrumb_action1 = _AM_SPARTNER_ACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_ACTIVE_EDITING; $page_info = _AM_SPARTNER_ACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_ACTIVE; break; case _SPARTNER_STATUS_INACTIVE: $breadcrumb_action1 = _AM_SPARTNER_INACTIVE_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_INACTIVE_EDITING; $page_info = _AM_SPARTNER_INACTIVE_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_INACTIVE; break; case _SPARTNER_STATUS_REJECTED: $breadcrumb_action1 = _AM_SPARTNER_REJECTED_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_EDITING; $page_title = _AM_SPARTNER_REJECTED_EDITING; $page_info = _AM_SPARTNER_REJECTED_EDITING_INFO; $button_caption = _AM_SPARTNER_MODIFY; $new_status = _SPARTNER_STATUS_REJECTED; break; case "default": default: break; } if ($showmenu) { smartpartner_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; smartpartner_collapsableBar('editpartner', 'editpartmericon', $page_title, $page_info); } else { // there's no parameter, so we're adding a partner $partnerObj =& $smartpartner_partner_handler->create(); $breadcrumb_action1 = _AM_SPARTNER_PARTNERS; $breadcrumb_action2 = _AM_SPARTNER_CREATE; $button_caption = _AM_SPARTNER_CREATE; $new_status = _SPARTNER_STATUS_ACTIVE; if ($showmenu) { smartpartner_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2); } smartpartner_collapsableBar('addpartner', 'addpartmericon', _AM_SPARTNER_PARTNER_CREATING, _AM_SPARTNER_PARTNER_CREATING_DSC); } // PARTNER FORM $sform = new XoopsThemeForm(_AM_SPARTNER_PARTNERS, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // TITLE $title_text = new XoopsFormText(_AM_SPARTNER_TITLE, 'title', 50, 255, $partnerObj->title('e')); $sform->addElement($title_text, true); // Parent Category $mytree = new SmartTree($xoopsDB->prefix("smartpartner_categories"), "categoryid", "parentid"); ob_start(); $mytree->makeMySelBox("name", "weight", explode('|', $partnerObj->categoryid()), 0, 'categoryid', '', true); //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") $parent_cat_select = new XoopsFormLabel(_AM_SPARTNER_CATEGORY_BELONG, ob_get_contents()); $parent_cat_select->setDescription(_AM_SPARTNER_BELONG_CATEGORY_DSC); $sform->addElement($parent_cat_select); ob_end_clean(); // LOGO $logo_array =& XoopsLists::getImgListAsArray(smartpartner_getImageDir()); $logo_select = new XoopsFormSelect('', 'image', $partnerObj->image()); $logo_select->addOption('-1', '---------------'); $logo_select->addOptionArray($logo_array); $logo_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . SMARTPARTNER_DIRNAME . '/images' . "\", \"\", \"" . XOOPS_URL . "\")'"); $logo_tray = new XoopsFormElementTray(_AM_SPARTNER_LOGO, ' '); $logo_tray->addElement($logo_select); $logo_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartpartner_getImageDir('', false) . $partnerObj->image() . "' name='image3' id='image3' alt='' />")); $logo_tray->setDescription(_AM_SPARTNER_LOGO_DSC); $sform->addElement($logo_tray); // LOGO UPLOAD $max_size = 5000000; $file_box = new XoopsFormFile(_AM_SPARTNER_LOGO_UPLOAD, "logo_file", $max_size); $file_box->setExtra("size ='45'"); $file_box->setDescription(sprintf(_AM_SPARTNER_LOGO_UPLOAD_DSC, $xoopsModuleConfig['img_max_width'], $xoopsModuleConfig['img_max_height'])); $sform->addElement($file_box); // IMAGE_URL $image_url_text = new XoopsFormText(_CO_SPARTNER_IMAGE_URL, 'image_url', 50, 255, $partnerObj->image_url()); $image_url_text->setDescription(_CO_SPARTNER_IMAGE_URL_DSC); $sform->addElement($image_url_text, false); // URL $url_text = new XoopsFormText(_AM_SPARTNER_URL, 'url', 50, 255, $partnerObj->url()); $url_text->setDescription(_AM_SPARTNER_URL_DSC); $sform->addElement($url_text, false); // SUMMARY $summary_text = new XoopsFormTextArea(_AM_SPARTNER_SUMMARY, 'summary', $partnerObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_AM_SPARTNER_SUMMARY_DSC); $sform->addElement($summary_text, true); // SHOW summary on partner page $showsum_radio = new XoopsFormRadioYN(_AM_SPARTNER_SHOW_SUMMARY, 'showsummary', $partnerObj->getVar('showsummary')); $showsum_radio->setDescription(_AM_SPARTNER_SHOW_SUMMARY_DSC); $sform->addElement($showsum_radio); // DESCRIPTION $description_text = new XoopsFormDhtmlTextArea(_AM_SPARTNER_DESCRIPTION, 'description', $partnerObj->description(0, 'e'), 15, 60); $description_text->setDescription(_AM_SPARTNER_DESCRIPTION_DSC); $sform->addElement($description_text, false); // CONTACT_NAME $contact_name_text = new XoopsFormText(_CO_SPARTNER_CONTACT_NAME, 'contact_name', 50, 255, $partnerObj->contact_name('e')); $contact_name_text->setDescription(_CO_SPARTNER_CONTACT_NAME_DSC); $sform->addElement($contact_name_text, false); // CONTACT_EMAIL $contact_email_text = new XoopsFormText(_CO_SPARTNER_CONTACT_EMAIL, 'contact_email', 50, 255, $partnerObj->contact_email('e')); $contact_email_text->setDescription(_CO_SPARTNER_CONTACT_EMAIL_DSC); $sform->addElement($contact_email_text, false); // EMAIL_PRIV $email_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_EMAILPRIV, 'email_priv', $partnerObj->email_priv('e')); $email_priv_radio->setDescription(_CO_SPARTNER_CONTACT_EMAILPRIV_DSC); $sform->addElement($email_priv_radio); // CONTACT_PHONE $contact_phone_text = new XoopsFormText(_CO_SPARTNER_CONTACT_PHONE, 'contact_phone', 50, 255, $partnerObj->contact_phone('e')); $contact_phone_text->setDescription(_CO_SPARTNER_CONTACT_PHONE_DSC); $sform->addElement($contact_phone_text, false); // PHONE_PRIV $phone_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_PHONEPRIV, 'phone_priv', $partnerObj->phone_priv('e')); $phone_priv_radio->setDescription(_CO_SPARTNER_CONTACT_PHONEPRIV_DSC); $sform->addElement($phone_priv_radio); // ADRESS //$adress_text = new XoopsFormText(_CO_SPARTNER_ADRESS, 'adress', 50, 255, $partnerObj->adress('e')); $adress_text = new XoopsFormTextArea(_CO_SPARTNER_ADRESS, 'adress', $partnerObj->adress('e')); $adress_text->setDescription(_CO_SPARTNER_ADRESS_DSC); $sform->addElement($adress_text, false); // ADRESS_PRIV $adress_priv_radio = new XoopsFormRadioYN(_CO_SPARTNER_CONTACT_ADRESSPRIV, 'adress_priv', $partnerObj->adress_priv('e')); $adress_priv_radio->setDescription(_CO_SPARTNER_CONTACT_ADRESSPRIV_DSC); $sform->addElement($adress_priv_radio); // STATUS $options = $partnerObj->getAvailableStatus(); $status_select = new XoopsFormSelect(_AM_SPARTNER_STATUS, 'status', $new_status); $status_select->addOptionArray($options); $status_select->setDescription(_AM_SPARTNER_STATUS_DSC); $sform->addElement($status_select); // WEIGHT $weight_text = new XoopsFormText(_AM_SPARTNER_WEIGHT, 'weight', 4, 4, $partnerObj->weight()); $weight_text->setDescription(_AM_SPARTNER_WEIGHT_DSC); $sform->addElement($weight_text); //perms global $smartpermissions_handler; include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php'; $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler); if ($partnerObj->id() != 0) { $grantedGroups = $smartpermissions_handler->getGrantedGroups('full_view', $partnerObj->id()); } else { $grantedGroups = $xoopsModuleConfig['default_full_view']; } $full_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_FULL_PERM_READ, 'full_view', true, $grantedGroups, 5, true); $full_view_select->setDescription(_CO_SPARTNER_FULL_PERM_READ_DSC); $sform->addElement($full_view_select); if ($partnerObj->id() != 0) { $partGrantedGroups = $smartpermissions_handler->getGrantedGroups('partial_view', $partnerObj->id()); } else { $partGrantedGroups = $xoopsModuleConfig['default_part_view']; } $part_view_select = new XoopsFormSelectGroup(_CO_SPARTNER_PART_PERM_READ, 'partial_view', true, $partGrantedGroups, 5, true); $part_view_select->setDescription(_CO_SPARTNER_PART_PERM_READ_DSC); $sform->addElement($part_view_select); // Partner id $sform->addElement(new XoopsFormHidden('id', $partnerObj->id())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addpartner'); $button_tray->addElement($hidden); $sform->addElement(new XoopsFormHidden('original_status', $partnerObj->status())); if (!$id) { // there's no id? Then it's a new partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_CREATE, 'submit' ) ); $butt_create = new XoopsFormButton('', '', _AM_SPARTNER_CREATE, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } else { // else, we're editing an existing partner // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SPARTNER_MODIFY, 'submit' ) ); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addpartner\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); } $sform->addElement($button_tray); $sform->display(); unset($hidden); if (!$id) { smartpartner_close_collapsable('addpartner', 'addpartnericon'); } else { smartpartner_close_collapsable('editpartner', 'editpartnericon'); } if ($id != 0) { showfiles($partnerObj); } }
/** * @param $obj * * @return $this */ public function createElements($obj) { $publisher =& PublisherPublisher::getInstance(); $allowedEditors = publisherGetEditors($publisher->getHandler('permission')->getGrantedItems('editors')); if (!is_object($GLOBALS['xoopsUser'])) { $group = array(XOOPS_GROUP_ANONYMOUS); } else { $group = $GLOBALS['xoopsUser']->getGroups(); } $this->setExtra('enctype="multipart/form-data"'); $this->startTab(_CO_PUBLISHER_TAB_MAIN); // Category $categoryFormSelect = new XoopsFormSelect(_CO_PUBLISHER_CATEGORY, 'categoryid', $obj->getVar('categoryid', 'e')); $categoryFormSelect->setDescription(_CO_PUBLISHER_CATEGORY_DSC); $categoryFormSelect->addOptionArray($publisher->getHandler('category')->getCategoriesForSubmit()); $this->addElement($categoryFormSelect); // ITEM TITLE $this->addElement(new XoopsFormText(_CO_PUBLISHER_TITLE, 'title', 50, 255, $obj->getVar('title', 'e')), true); // SUBTITLE if ($this->isGranted(PublisherConstants::PUBLISHER_SUBTITLE)) { $this->addElement(new XoopsFormText(_CO_PUBLISHER_SUBTITLE, 'subtitle', 50, 255, $obj->getVar('subtitle', 'e'))); } // SHORT URL if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_SHORT_URL)) { $textShortUrl = new XoopsFormText(_CO_PUBLISHER_ITEM_SHORT_URL, 'item_short_url', 50, 255, $obj->short_url('e')); $textShortUrl->setDescription(_CO_PUBLISHER_ITEM_SHORT_URL_DSC); $this->addElement($textShortUrl); } // TAGS if (xoops_isActiveModule('tag') && $this->isGranted(PublisherConstants::PUBLISHER_ITEM_TAG)) { include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); $textTags = new XoopsFormTag('item_tag', 60, 255, $obj->getVar('item_tag', 'e'), 0); $this->addElement($textTags); } // SELECT EDITOR $nohtml = !$obj->dohtml(); if (count($allowedEditors) === 1) { $editor = $allowedEditors[0]; } elseif (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 = @ $GLOBALS['xoopsUser']->getVar('publisher_editor'); // Need set through user profile $editor = null !== $GLOBALS['xoopsUser']->getVar('publisher_editor') ? $GLOBALS['xoopsUser']->getVar('publisher_editor') : ''; // Need set through user profile } } $editor = empty($editor) || !in_array($editor, $allowedEditors) ? $publisher->getConfig('submit_editor') : $editor; $formEditor = new XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors); $this->addElement($formEditor); } else { $editor = $publisher->getConfig('submit_editor'); } $editorConfigs = array(); $editorConfigs['rows'] = !$publisher->getConfig('submit_editor_rows') ? 35 : $publisher->getConfig('submit_editor_rows'); $editorConfigs['cols'] = !$publisher->getConfig('submit_editor_cols') ? 60 : $publisher->getConfig('submit_editor_cols'); $editorConfigs['width'] = !$publisher->getConfig('submit_editor_width') ? '100%' : $publisher->getConfig('submit_editor_width'); $editorConfigs['height'] = !$publisher->getConfig('submit_editor_height') ? '400px' : $publisher->getConfig('submit_editor_height'); // SUMMARY if ($this->isGranted(PublisherConstants::PUBLISHER_SUMMARY)) { // Description //$summaryText = new XoopsFormTextArea(_CO_PUBLISHER_SUMMARY, 'summary', $obj->getVar('summary', 'e'), 7, 60); $editorConfigs['name'] = 'summary'; $editorConfigs['value'] = $obj->getVar('summary', 'e'); $summaryText = new XoopsFormEditor(_CO_PUBLISHER_SUMMARY, $editor, $editorConfigs, $nohtml, $onfailure = null); $summaryText->setDescription(_CO_PUBLISHER_SUMMARY_DSC); $this->addElement($summaryText); } // BODY $editorConfigs['name'] = 'body'; $editorConfigs['value'] = $obj->getVar('body', 'e'); $bodyText = new XoopsFormEditor(_CO_PUBLISHER_BODY, $editor, $editorConfigs, $nohtml, $onfailure = null); $bodyText->setDescription(_CO_PUBLISHER_BODY_DSC); $this->addElement($bodyText); // VARIOUS OPTIONS if ($this->isGranted(PublisherConstants::PUBLISHER_DOHTML) || $this->isGranted(PublisherConstants::PUBLISHER_DOSMILEY) || $this->isGranted(PublisherConstants::PUBLISHER_DOXCODE) || $this->isGranted(PublisherConstants::PUBLISHER_DOIMAGE) || $this->isGranted(PublisherConstants::PUBLISHER_DOLINEBREAK)) { if ($this->isGranted(PublisherConstants::PUBLISHER_DOHTML)) { $html_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOHTML, 'dohtml', $obj->dohtml(), _YES, _NO); $this->addElement($html_radio); } if ($this->isGranted(PublisherConstants::PUBLISHER_DOSMILEY)) { $smiley_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOSMILEY, 'dosmiley', $obj->dosmiley(), _YES, _NO); $this->addElement($smiley_radio); } if ($this->isGranted(PublisherConstants::PUBLISHER_DOXCODE)) { $xcode_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOXCODE, 'doxcode', $obj->doxcode(), _YES, _NO); $this->addElement($xcode_radio); } if ($this->isGranted(PublisherConstants::PUBLISHER_DOIMAGE)) { $image_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOIMAGE, 'doimage', $obj->doimage(), _YES, _NO); $this->addElement($image_radio); } if ($this->isGranted(PublisherConstants::PUBLISHER_DOLINEBREAK)) { $linebreak_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOLINEBREAK, 'dolinebreak', $obj->dobr(), _YES, _NO); $this->addElement($linebreak_radio); } } // Available pages to wrap if ($this->isGranted(PublisherConstants::PUBLISHER_AVAILABLE_PAGE_WRAP)) { $wrapPages = XoopsLists::getHtmlListAsArray(publisherGetUploadDir(true, 'content')); $availableWrapPagesText = array(); foreach ($wrapPages as $page) { $availableWrapPagesText[] = "<span onclick='publisherPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>"; } $availableWrapPages = new XoopsFormLabel(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP, implode(', ', $availableWrapPagesText)); $availableWrapPages->setDescription(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP_DSC); $this->addElement($availableWrapPages); } // Uid /* We need to retreive 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(PublisherConstants::PUBLISHER_UID)) { $uidSelect = new XoopsFormSelect(_CO_PUBLISHER_UID, 'uid', $obj->uid(), 1, false); $uidSelect->setDescription(_CO_PUBLISHER_UID_DSC); $sql = 'SELECT uid, uname FROM ' . $obj->db->prefix('users') . ' ORDER BY uname ASC'; $result = $obj->db->query($sql); $usersArray = array(); $usersArray[0] = $GLOBALS['xoopsConfig']['anonymous']; while (($myrow = $obj->db->fetchArray($result)) !== false) { $usersArray[$myrow['uid']] = $myrow['uname']; } $uidSelect->addOptionArray($usersArray); $this->addElement($uidSelect); } /* else { $hidden = new XoopsFormHidden('uid', $obj->uid()); $this->addElement($hidden); unset($hidden); }*/ // Author ALias if ($this->isGranted(PublisherConstants::PUBLISHER_AUTHOR_ALIAS)) { $element = new XoopsFormText(_CO_PUBLISHER_AUTHOR_ALIAS, 'author_alias', 50, 255, $obj->getVar('author_alias', 'e')); $element->setDescription(_CO_PUBLISHER_AUTHOR_ALIAS_DSC); $this->addElement($element); unset($element); } // STATUS if ($this->isGranted(PublisherConstants::PUBLISHER_STATUS)) { $options = array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED => _CO_PUBLISHER_PUBLISHED, PublisherConstants::PUBLISHER_STATUS_OFFLINE => _CO_PUBLISHER_OFFLINE, PublisherConstants::PUBLISHER_STATUS_SUBMITTED => _CO_PUBLISHER_SUBMITTED, PublisherConstants::PUBLISHER_STATUS_REJECTED => _CO_PUBLISHER_REJECTED); $statusSelect = new XoopsFormSelect(_CO_PUBLISHER_STATUS, 'status', $obj->getVar('status')); $statusSelect->addOptionArray($options); $statusSelect->setDescription(_CO_PUBLISHER_STATUS_DSC); $this->addElement($statusSelect); unset($statusSelect); } // Datesub if ($this->isGranted(PublisherConstants::PUBLISHER_DATESUB)) { if ($obj->isNew()) { $datesub = time(); } else { $datesub = $obj->getVar('datesub') == 0 ? time() : $obj->getVar('datesub'); } $datesub_datetime = new PublisherFormDateTime(_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub, true, true); // $datesub_datetime = new XoopsFormDateTime(_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub, true, true); $datesub_datetime->setDescription(_CO_PUBLISHER_DATESUB_DSC); $this->addElement($datesub_datetime); } // NOTIFY ON PUBLISH if ($this->isGranted(PublisherConstants::PUBLISHER_NOTIFY)) { $notify_radio = new XoopsFormRadioYN(_CO_PUBLISHER_NOTIFY, 'notify', $obj->notifypub(), _YES, _NO); $this->addElement($notify_radio); } if ($this->hasTab(_CO_PUBLISHER_TAB_IMAGES)) { $this->startTab(_CO_PUBLISHER_TAB_IMAGES); } // IMAGE if ($this->isGranted(PublisherConstants::PUBLISHER_IMAGE_ITEM)) { $objimages = $obj->getImages(); $mainarray = is_object($objimages['main']) ? array($objimages['main']) : array(); $mergedimages = array_merge($mainarray, $objimages['others']); $objimage_array = array(); foreach ($mergedimages as $imageObj) { $objimage_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename'); } $imgcatHandler =& xoops_getHandler('imagecategory'); if (method_exists($imgcatHandler, 'getListByPermission')) { $catlist = $imgcatHandler->getListByPermission($group, 'imgcat_read', 1); } else { $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1); } $catids = array_keys($catlist); $imageObjs = array(); if (!empty($catids)) { $imageHandler =& xoops_getHandler('image'); $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 = $imageHandler->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); $imageSelect = new XoopsFormSelect('', 'image_notused', '', 5); $imageSelect->addOptionArray($image_array); $imageSelect->setExtra("onchange='showImgSelected(\"image_display\", \"image_notused\", \"uploads/\", \"\", \"" . XOOPS_URL . "\")'"); //$imageSelect->setExtra( "onchange='appendMySelectOption(\"image_notused\", \"image_item\")'"); unset($image_array); $imageSelect2 = new XoopsFormSelect('', 'image_item', '', 5, true); $imageSelect2->addOptionArray($objimage_array); $imageSelect2->setExtra("onchange='publisher_updateSelectOption(\"image_item\", \"image_featured\"), showImgSelected(\"image_display\", \"image_item\", \"uploads/\", \"\", \"" . XOOPS_URL . "\")'"); $buttonadd = new XoopsFormButton('', 'buttonadd', _CO_PUBLISHER_ADD); $buttonadd->setExtra("onclick='publisher_appendSelectOption(\"image_notused\", \"image_item\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'"); $buttonremove = new XoopsFormButton('', 'buttonremove', _CO_PUBLISHER_REMOVE); $buttonremove->setExtra("onclick='publisher_appendSelectOption(\"image_item\", \"image_notused\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'"); $opentable = new XoopsFormLabel('', '<table><tr><td>'); $addcol = new XoopsFormLabel('', '</td><td>'); $addbreak = new XoopsFormLabel('', '<br />'); $closetable = new XoopsFormLabel('', '</td></tr></table>'); $GLOBALS['xoTheme']->addScript(PUBLISHER_URL . '/assets/js/ajaxupload.3.9.js'); $js_data = new XoopsFormLabel('', ' <script type= "text/javascript">/*<![CDATA[*/ $publisher(document).ready(function () { var button = $publisher("#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("#publisher_upload_message").html(" "); button.html("<img src=\'' . PUBLISHER_URL . '/assets/images/loadingbar.gif\'/>"); this.setData({ "image_nicename": $publisher("#image_nicename").val(), "imgcat_id" : $publisher("#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 ("success" == result[0]) { $publisher("#image_item").append("<option value=\'" + result[1] + "\' selected=\'selected\'>" + result[2] + "</option>"); publisher_updateSelectOption(\'image_item\', \'image_featured\'); showImgSelected(\'image_display\', \'image_item\', \'uploads/\', \'\', \'' . XOOPS_URL . '\') } else { $publisher("#publisher_upload_message").html("<div class=\'errorMsg\'>" + result[1] + "</div>"); } } }); }); /*]]>*/</script> '); $messages = new XoopsFormLabel('', "<div id='publisher_upload_message'></div>"); $button = new XoopsFormLabel('', "<div id='publisher_upload_button'>" . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . '</div>'); $nicename = new XoopsFormText('', 'image_nicename', 30, 30, _CO_PUBLISHER_IMAGE_NICENAME); $imgcatHandler =& xoops_getHandler('imagecategory'); if (method_exists($imgcatHandler, 'getListByPermission')) { $catlist = $imgcatHandler->getListByPermission($group, 'imgcat_read', 1); } else { $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1); } $imagecat = new XoopsFormSelect('', 'imgcat_id', '', 1); $imagecat->addOptionArray($catlist); $imageUploadTray = new XoopsFormElementTray(_CO_PUBLISHER_IMAGE_UPLOAD, ''); $imageUploadTray->addElement($js_data); $imageUploadTray->addElement($messages); $imageUploadTray->addElement($opentable); $imageUploadTray->addElement($imagecat); $imageUploadTray->addElement($addbreak); $imageUploadTray->addElement($nicename); $imageUploadTray->addElement($addbreak); $imageUploadTray->addElement($button); $imageUploadTray->addElement($closetable); $this->addElement($imageUploadTray); $imageTray = new XoopsFormElementTray(_CO_PUBLISHER_IMAGE_ITEMS, ''); $imageTray->addElement($opentable); $imageTray->addElement($imageSelect); $imageTray->addElement($addbreak); $imageTray->addElement($buttonadd); $imageTray->addElement($addcol); $imageTray->addElement($imageSelect2); $imageTray->addElement($addbreak); $imageTray->addElement($buttonremove); $imageTray->addElement($closetable); $imageTray->setDescription(_CO_PUBLISHER_IMAGE_ITEMS_DSC); $this->addElement($imageTray); $imagename = is_object($objimages['main']) ? $objimages['main']->getVar('image_name') : ''; $imageforpath = $imagename != '' ? $imagename : 'blank.gif'; $imageSelect3 = new XoopsFormSelect(_CO_PUBLISHER_IMAGE_ITEM, 'image_featured', $imagename, 1); $imageSelect3->addOptionArray($objimage_array); $imageSelect3->setExtra("onchange='showImgSelected(\"image_display\", \"image_featured\", \"uploads/\", \"\", \"" . XOOPS_URL . "\")'"); $imageSelect3->setDescription(_CO_PUBLISHER_IMAGE_ITEM_DSC); $this->addElement($imageSelect3); $image_preview = new XoopsFormLabel(_CO_PUBLISHER_IMAGE_PREVIEW, "<img src='" . XOOPS_URL . '/uploads/' . $imageforpath . "' name='image_display' id='image_display' alt='' />"); $this->addElement($image_preview); } if ($this->hasTab(_CO_PUBLISHER_TAB_FILES)) { $this->startTab(_CO_PUBLISHER_TAB_FILES); } // File upload UPLOAD if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_UPLOAD_FILE)) { // NAME $nameText = new XoopsFormText(_CO_PUBLISHER_FILENAME, 'item_file_name', 50, 255, ''); $nameText->setDescription(_CO_PUBLISHER_FILE_NAME_DSC); $this->addElement($nameText); unset($nameText); // DESCRIPTION $descriptionText = new XoopsFormTextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'item_file_description', ''); $descriptionText->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC); $this->addElement($descriptionText); unset($descriptionText); $statusSelect = new XoopsFormRadioYN(_CO_PUBLISHER_FILE_STATUS, 'item_file_status', 1); //1 - active $statusSelect->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC); $this->addElement($statusSelect); unset($statusSelect); $fileBox = new XoopsFormFile(_CO_PUBLISHER_ITEM_UPLOAD_FILE, 'item_upload_file', 0); $fileBox->setDescription(_CO_PUBLISHER_ITEM_UPLOAD_FILE_DSC); $fileBox->setExtra("size ='50'"); $this->addElement($fileBox); unset($fileBox); if (!$obj->isNew()) { $filesObj =& $publisher->getHandler('file')->getAllFiles($obj->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>'; foreach ($filesObj as $fileObj) { $modify = "<a href='file.php?op=mod&fileid=" . $fileObj->fileid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif' title='" . _CO_PUBLISHER_EDITFILE . "' alt='" . _CO_PUBLISHER_EDITFILE . "' /></a>"; $delete = "<a href='file.php?op=del&fileid=" . $fileObj->fileid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _CO_PUBLISHER_DELETEFILE . "' alt='" . _CO_PUBLISHER_DELETEFILE . "'/></a>"; if ($fileObj->status() == 0) { $not_visible = "<img src='" . PUBLISHER_URL . "/assets/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->description() . '</td>'; $table .= "<td class='even' align='center'>" . $fileObj->counter() . ''; $table .= "<td class='even' align='center'>" . $fileObj->getDatesub() . '</td>'; $table .= "<td class='even' align='center'> {$modify} {$delete} </td>"; $table .= '</tr>'; } $table .= '</table>'; $files_box = new XoopsFormLabel(_CO_PUBLISHER_FILES_LINKED, $table); $this->addElement($files_box); unset($files_box, $filesObj, $fileObj); } } } if ($this->hasTab(_CO_PUBLISHER_TAB_OTHERS)) { $this->startTab(_CO_PUBLISHER_TAB_OTHERS); } //$this->startTab(_CO_PUBLISHER_TAB_META); // Meta Keywords if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_META_KEYWORDS)) { $text_meta_keywords = new XoopsFormTextArea(_CO_PUBLISHER_ITEM_META_KEYWORDS, 'item_meta_keywords', $obj->meta_keywords('e'), 7, 60); $text_meta_keywords->setDescription(_CO_PUBLISHER_ITEM_META_KEYWORDS_DSC); $this->addElement($text_meta_keywords); } // Meta Description if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_META_DESCRIPTION)) { $text_meta_description = new XoopsFormTextArea(_CO_PUBLISHER_ITEM_META_DESCRIPTION, 'item_meta_description', $obj->meta_description('e'), 7, 60); $text_meta_description->setDescription(_CO_PUBLISHER_ITEM_META_DESCRIPTION_DSC); $this->addElement($text_meta_description); } //$this->startTab(_CO_PUBLISHER_TAB_PERMISSIONS); // COMMENTS if ($this->isGranted(PublisherConstants::PUBLISHER_ALLOWCOMMENTS)) { $addcomments_radio = new XoopsFormRadioYN(_CO_PUBLISHER_ALLOWCOMMENTS, 'allowcomments', $obj->cancomment(), _YES, _NO); $this->addElement($addcomments_radio); } // WEIGHT if ($this->isGranted(PublisherConstants::PUBLISHER_WEIGHT)) { $this->addElement(new XoopsFormText(_CO_PUBLISHER_WEIGHT, 'weight', 5, 5, $obj->weight())); } $this->endTabs(); //COMMON TO ALL TABS $button_tray = new XoopsFormElementTray('', ''); if (!$obj->isNew()) { $button_tray->addElement(new XoopsFormButton('', 'additem', _SUBMIT, 'submit')); //orclone } else { $button_tray->addElement(new XoopsFormButton('', 'additem', _CO_PUBLISHER_CREATE, 'submit')); $button_tray->addElement(new XoopsFormButton('', '', _CO_PUBLISHER_CLEAR, 'reset')); } $button_tray->addElement(new XoopsFormButton('', 'preview', _CO_PUBLISHER_PREVIEW, 'submit')); $butt_cancel = new XoopsFormButton('', '', _CO_PUBLISHER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $this->addElement($button_tray); $hidden = new XoopsFormHidden('itemid', $obj->itemid()); $this->addElement($hidden); unset($hidden); return $this; }
/** * XoopsFormDhtmlTextArea::renderValidationJS() * * @return bool|string */ function renderValidationJS() { if ($this->htmlEditor && is_object($this->htmlEditor) && method_exists($this->htmlEditor, 'renderValidationJS')) { if (!isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) { return $this->htmlEditor->renderValidationJS(); } } return parent::renderValidationJS(); }
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)); }
include_once SMARTSECTION_ROOT_PATH . "include/functions.php"; $categoryid = isset($_GET['categoryid']) ? intval($_GET['categoryid']) : 0; $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid"); $sform = new XoopsThemeForm(_MD_SS_SUB_SMNAME, "form", xoops_getenv('PHP_SELF')); // Category ob_start(); $sform->addElement(new XoopsFormHidden('categoryid', $newItemObj->categoryid())); $mytree->makeMySelBox("name", "weight", $categoryid); $category_label = new XoopsFormLabel(_MD_SS_CATEGORY, ob_get_contents()); $category_label->setDescription(_MD_SS_CATEGORY_DSC); $sform->addElement($category_label); ob_end_clean(); // ITEM TITLE $sform->addElement(new XoopsFormText(_MD_SS_TITLE, 'title', 50, 255, $newItemObj->title('e')), true); // SUMMARY $summary_text = new XoopsFormTextArea(_MD_SS_SUMMARY, 'summary', $newItemObj->summary(0, 'e'), 7, 60); $summary_text->setDescription(_MD_SS_SUMMARY_DSC); $sform->addElement($summary_text, false); // BODY //$body_text = new XoopsFormDhtmlTextArea(_MD_SS_BODY, 'body', '', 15, 60); $body_text = ss_getEditor(_MD_SS_BODY_REQ, 'body', $newItemObj->body(0, 'e')); $body_text->setDescription(_MD_SS_BODY_DSC); $sform->addElement($body_text, true); // NOTIFY ON PUBLISH if (is_object($xoopsUser)) { $notify_checkbox = new XoopsFormCheckBox('', 'notifypub', $notifypub); $notify_checkbox->addOption(1, _MD_SS_NOTIFY); $sform->addElement($notify_checkbox); } $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'post');
function editformat($showmenu = false, $id = 0) { global $smartmedia_format_handler, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // If there is a parameter, and the id exists, retrieve data: we're editing a format if ($id != 0) { // Creating the format object $formatObj = new SmartmediaFormat($id); if (!$formatObj) { redirect_header("format.php", 1, _AM_SMEDIA_FORMAT_NOT_SELECTED); exit; } $breadcrumb_action1 = _AM_SMEDIA_FORMATS; $breadcrumb_action2 = _AM_SMEDIA_EDITING; $page_title = _AM_SMEDIA_FORMAT_EDITING; $page_info = _AM_SMEDIA_FORMAT_EDITING_INFO; $button_caption = _AM_SMEDIA_MODIFY; if ($showmenu) { smartmedia_adminMenu(4, $breadcrumb_action1 . " > " . $breadcrumb_action2); } echo "<br />\n"; } else { // there's no parameter, so we're adding a format $formatObj =& $smartmedia_format_handler->create(); $breadcrumb_action1 = _AM_SMEDIA_FORMATS; $breadcrumb_action2 = _AM_SMEDIA_CREATE; $button_caption = _AM_SMEDIA_CREATE; $page_title = _AM_SMEDIA_FORMAT_CREATING; $page_info = _AM_SMEDIA_FORMAT_CREATING_INFO; if ($showmenu) { smartmedia_adminMenu(4, $breadcrumb_action1 . " > " . $breadcrumb_action2); } } smartmedia_collapsableBar('bottomtable', 'bottomtableicon'); echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . $page_title . "</h3>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $page_info . "</span>"; echo "<div id='bottomtable'>"; // FORMAT FORM $sform = new XoopsThemeForm(_AM_SMEDIA_FORMAT, "op", xoops_getenv('PHP_SELF')); $sform->setExtra('enctype="multipart/form-data"'); // FORMAT $format_text = new XoopsFormText(_AM_SMEDIA_FORMAT, 'format', 50, 255, $formatObj->format('e')); $format_text->setDescription(_AM_SMEDIA_FORMAT_DSC); $sform->addElement($format_text, true); // EXT $ext_text = new XoopsFormText(_AM_SMEDIA_FORMAT_EXT, 'ext', 5, 10, $formatObj->ext()); $ext_text->setDescription(_AM_SMEDIA_FORMAT_EXT_DSC); $sform->addElement($ext_text, true); // TEMPLATE $template_text = new XoopsFormTextArea(_AM_SMEDIA_FORMAT_TEMPLATE, 'template', $formatObj->template('e'), 15, 60); $template_text->setDescription(_AM_SMEDIA_FORMAT_TEMPLATE_DSC); $sform->addElement($template_text, true); // FORMAT ID $sform->addElement(new XoopsFormHidden('formatid', $formatObj->formatid())); $button_tray = new XoopsFormElementTray('', ''); $hidden = new XoopsFormHidden('op', 'addformat'); $button_tray->addElement($hidden); $butt_create = new XoopsFormButton('', '', $button_caption, 'submit'); $butt_create->setExtra('onclick="this.form.elements.op.value=\'addformat\'"'); $button_tray->addElement($butt_create); $butt_cancel = new XoopsFormButton('', '', _AM_SMEDIA_CANCEL, 'button'); $butt_cancel->setExtra('onclick="location=\'format.php\'"'); $button_tray->addElement($butt_cancel); $sform->addElement($button_tray); $sform->display(); unset($hidden); echo "</div>"; }