public static function search() { $publisher =& PublisherPublisher::getInstance(); global $limit, $start, $imagearray, $aSearchBy, $aOrderBy, $aLimitBy, $aSortBy; if (XoopsRequest::getString('deleteMimes', '', 'POST')) { $aMimes = XoopsRequest::getArray('mimes', array(), 'POST'); $crit = new Criteria('mime_id', '(' . implode($aMimes, ',') . ')', 'IN'); if ($publisher->getHandler('mimetype')->deleteAll($crit)) { header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}"); } else { redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}", 3, _AM_PUBLISHER_MESSAGE_DELETE_MIME_ERROR); } } if (XoopsRequest::getString('add_mime', '', 'POST')) { // header("Location: " . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=add&start=$start&limit=$limit"); redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?op=add&start={$start}&limit={$limit}", 3, _AM_PUBLISHER_MIME_CREATEF); // exit(); } $order = XoopsRequest::getString('order', 'ASC', 'POST'); $sort = XoopsRequest::getString('sort', 'mime_name', 'POST'); publisherCpHeader(); //publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES . " > " . _AM_PUBLISHER_BUTTON_SEARCH); publisherOpenCollapsableBar('mimemsearchtable', 'mimesearchicon', _AM_PUBLISHER_MIME_SEARCH); if (!XoopsRequest::getString('mime_search', '', 'POST')) { echo "<form action='mimetypes.php?op=search' method='post'>"; echo "<table width='100%' cellspacing='1' class='outer'>"; echo "<tr><th colspan='2'>" . _AM_PUBLISHER_TEXT_SEARCH_MIME . '</th></tr>'; echo "<tr><td class='head' width='20%'>" . _AM_PUBLISHER_TEXT_SEARCH_BY . "</td>\n <td class='even'>\n <select name='search_by'>"; foreach ($aSortBy as $value => $text) { echo "<option value='{$value}'>{$text}</option>"; } unset($value, $text); echo '</select> </td> </tr>'; echo "<tr><td class='head'>" . _AM_PUBLISHER_TEXT_SEARCH_TEXT . "</td>\n <td class='even'>\n <input type='text' name='search_text' id='search_text' value='' />\n </td>\n </tr>"; echo "<tr class='foot'>\n <td colspan='2'>\n <input type='submit' name='mime_search' id='mime_search' value='" . _AM_PUBLISHER_BUTTON_SEARCH . "' />\n </td>\n </tr>"; echo '</table></form>'; } else { $searchField = XoopsRequest::getString('search_by', '', 'POST'); $searchText = XoopsRequest::getString('search_text', '', 'POST'); $crit = new Criteria($searchField, "%{$searchText}%", 'LIKE'); $crit->setSort($sort); $crit->setOrder($order); $crit->setLimit($limit); $crit->setStart($start); $mimeCount =& $publisher->getHandler('mimetype')->getCount($crit); $mimetypes =& $publisher->getHandler('mimetype')->getObjects($crit); $nav = new XoopsPageNav($mimeCount, $limit, $start, 'start', "op=search&limit={$limit}&order={$order}&sort={$sort}&mime_search=1&search_by={$searchField}&search_text={$searchText}"); // Display results echo '<script type="text/javascript" src="' . PUBLISHER_URL . '/include/functions.js"></script>'; echo "<table width='100%' cellspacing='1' class='outer'>"; echo "<tr><td colspan='6' align='right'>"; echo "<form action='" . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; echo '<table>'; echo '<tr>'; echo "<td align='right'>" . _AM_PUBLISHER_TEXT_SEARCH_BY . '</td>'; echo "<td align='left'><select name='search_by'>"; foreach ($aSearchBy as $value => $text) { $searchField == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } unset($value, $text); echo '</select></td>'; echo "<td align='right'>" . _AM_PUBLISHER_TEXT_SEARCH_TEXT . '</td>'; echo "<td align='left'><input type='text' name='search_text' id='search_text' value='{$searchText}' /></td>"; echo "<td><input type='submit' name='mime_search' id='mime_search' value='" . _AM_PUBLISHER_BUTTON_SEARCH . "' /></td>"; echo '</tr></table></form></td></tr>'; echo "<tr><td colspan='6'>"; echo "<form action='" . PUBLISHER_ADMIN_URL . "/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; echo "<table width='100%'>"; echo "<tr><td align='right'>" . _AM_PUBLISHER_TEXT_SORT_BY . "\n <select name='sort'>"; foreach ($aSortBy as $value => $text) { $sort == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } unset($value, $text); echo '</select> ' . _AM_PUBLISHER_TEXT_ORDER_BY . "\n <select name='order'>"; foreach ($aOrderBy as $value => $text) { $order == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } unset($value, $text); echo '</select> ' . _AM_PUBLISHER_TEXT_NUMBER_PER_PAGE . "\n <select name='limit'>"; foreach ($aLimitBy as $value => $text) { $limit == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } unset($value, $text); echo "</select>\n <input type='submit' name='mime_sort' id='mime_sort' value='" . _AM_PUBLISHER_BUTTON_SUBMIT . "' />\n <input type='hidden' name='mime_search' id='mime_search' value='1' />\n <input type='hidden' name='search_by' id='search_by' value='{$searchField}' />\n <input type='hidden' name='search_text' id='search_text' value='{$searchText}' />\n </td>\n </tr>"; echo '</table>'; echo '</td></tr>'; if (count($mimetypes) > 0) { echo "<tr><th colspan='6'>" . _AM_PUBLISHER_TEXT_SEARCH_MIME . '</th></tr>'; echo "<tr class='head'>\n <td>" . _AM_PUBLISHER_MIME_ID . '</td> <td>' . _AM_PUBLISHER_MIME_NAME . "</td>\n <td align='center'>" . _AM_PUBLISHER_MIME_EXT . "</td>\n <td align='center'>" . _AM_PUBLISHER_MIME_ADMIN . "</td>\n <td align='center'>" . _AM_PUBLISHER_MIME_USER . "</td>\n <td align='center'>" . _AM_PUBLISHER_MINDEX_ACTION . '</td> </tr>'; foreach ($mimetypes as $mime) { echo "<tr class='even'>\n <td><input type='checkbox' name='mimes[]' value='" . $mime->getVar('mime_id') . "' />" . $mime->getVar('mime_id') . '</td> <td>' . $mime->getVar('mime_name') . "</td>\n <td align='center'>" . $mime->getVar('mime_ext') . "</td>\n <td align='center'>\n <a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=updateMimeValue&id=' . $mime->getVar('mime_id') . '&mime_admin=' . $mime->getVar('mime_admin') . '&limit=' . $limit . '&start=' . $start . "'>\n " . ($mime->getVar('mime_admin') ? $imagearray['online'] : $imagearray['offline']) . "</a>\n </td>\n <td align='center'>\n <a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=updateMimeValue&id=' . $mime->getVar('mime_id') . '&mime_user='******'mime_user') . '&limit=' . $limit . '&start=' . $start . "'>\n " . ($mime->getVar('mime_user') ? $imagearray['online'] : $imagearray['offline']) . "</a>\n </td>\n <td align='center'>\n <a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=edit&id=' . $mime->getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $imagearray['editimg'] . "</a>\n <a href='" . PUBLISHER_ADMIN_URL . '/mimetypes.php?op=delete&id=' . $mime->getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $imagearray['deleteimg'] . '</a> </td> </tr>'; } // unset($mime); echo "<tr class='foot'>\n <td colspan='6' valign='top'>\n <a href='http://www.filext.com' style='float: right;' target='_blank'>" . _AM_PUBLISHER_MIME_FINDMIMETYPE . "</a>\n <input type='checkbox' name='checkAllMimes' value='0' onclick='selectAll(this.form,\"mimes[]\",this.checked);' />\n <input type='submit' name='deleteMimes' id='deleteMimes' value='" . _AM_PUBLISHER_BUTTON_DELETE . "' />\n <input type='submit' name='add_mime' id='add_mime' value='" . _AM_PUBLISHER_MIME_CREATEF . "' class='formButton' />\n </td>\n </tr>"; } else { echo '<tr><th>' . _AM_PUBLISHER_TEXT_SEARCH_MIME . '</th></tr>'; echo "<tr class='even'>\n <td>" . _AM_PUBLISHER_TEXT_NO_RECORDS . '</td> </tr>'; } echo '</table>'; echo "<div id='pagenav'>" . $nav->renderNav() . '</div>'; } publisherCloseCollapsableBar('mimesearchtable', 'mimesearchicon'); // include_once __DIR__ . '/admin_footer.php'; xoops_cp_footer(); }
if ($old_status == PublisherConstants::PUBLISHER_STATUS_NOTSET) { $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED; } else { $error_msg = _AM_PUBLISHER_ITEMNOTCREATED; } $redirect_msg = _AM_PUBLISHER_ITEM_REJECTED; break; } $itemObj->setVar('status', $newStatus); // Storing the item if (!$itemObj->store()) { redirect_header('javascript:history.go(-1)', 3, $error_msg . publisherFormatErrors($itemObj->getErrors())); // exit; } // attach file if any if (($item_upload_file = XoopsRequest::getArray('item_upload_file', '', 'FILES')) && $item_upload_file['name'] !== '') { $file_upload_result = publisherUploadFile(false, false, $itemObj); if ($file_upload_result !== true) { redirect_header('javascript:history.go(-1)', 3, $file_upload_result); // exit; } } // Send notifications if ($notifToDo) { $itemObj->sendNotifications($notifToDo); } redirect_header('item.php', 2, $redirect_msg); break; case 'del': $itemObj =& $publisher->getHandler('item')->get($itemid); $confirm = XoopsRequest::getInt('confirm', '', 'POST');
// exit(); } $GLOBALS['xoopsConfig']['module_cache'][$module_id] = 0; $xoopsOption['template_main'] = 'publisher_search.tpl'; include $GLOBALS['xoops']->path('header.php'); $module_info_search = $publisher->getModule()->getInfo('search'); include_once PUBLISHER_ROOT_PATH . '/' . $module_info_search['file']; $limit = 10; //$publisher->getConfig('idxcat_perpage'); $uid = 0; $queries = array(); $andor = XoopsRequest::getString('andor', '', 'POST'); $start = XoopsRequest::getInt('start', 0, 'POST'); $category = XoopsRequest::getArray('category', array(), 'POST'); $username = XoopsRequest::getString('uname', '', 'POST'); $searchin = XoopsRequest::getArray('searchin', array(), 'POST'); $sortby = XoopsRequest::getString('sortby', '', 'POST'); $term = XoopsRequest::getString('term', '', 'POST'); if (empty($category) || is_array($category) && in_array('all', $category)) { $category = array(); } else { $category = !is_array($category) ? explode(',', $category) : $category; $category = array_map('intval', $category); } $andor = in_array(strtoupper($andor), array('OR', 'AND', 'EXACT')) ? strtoupper($andor) : 'OR'; $sortby = in_array(strtolower($sortby), array('itemid', 'datesub', 'title', 'categoryid')) ? strtolower($sortby) : 'itemid'; if ($term && XoopsRequest::getString('submit', '', 'POST')) { $next_search['category'] = implode(',', $category); $next_search['andor'] = $andor; $next_search['term'] = $term; $query = trim($term);
/** * The name says it all */ public function setVarsFromRequest() { //Required fields // if (!empty($categoryid = XoopsRequest::getInt('categoryid', 0, 'POST'))) { // $this->setVar('categoryid', $categoryid);} $this->setVar('categoryid', XoopsRequest::getInt('categoryid', 0, 'POST')); $this->setVar('title', XoopsRequest::getString('title', '', 'POST')); $this->setVar('body', XoopsRequest::getText('body', '', 'POST')); //Not required fields $this->setVar('summary', XoopsRequest::getText('summary', '', 'POST')); $this->setVar('subtitle', XoopsRequest::getString('subtitle', '', 'POST')); $this->setVar('item_tag', XoopsRequest::getString('item_tag', '', 'POST')); if ($imageFeatured = XoopsRequest::getString('image_featured', '', 'POST')) { $imageItem = XoopsRequest::getArray('image_item', array(), 'POST'); // $imageFeatured = XoopsRequest::getString('image_featured', '', 'POST'); //Todo: get a better image class for xoops! //Image hack $imageItemIds = array(); $sql = 'SELECT image_id, image_name FROM ' . $GLOBALS['xoopsDB']->prefix('image'); $result = $GLOBALS['xoopsDB']->query($sql, 0, 0); while (($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) !== false) { $imageName = $myrow['image_name']; $id = $myrow['image_id']; if ($imageName == $imageFeatured) { $this->setVar('image', $id); } if (in_array($imageName, $imageItem)) { $imageItemIds[] = $id; } } $this->setVar('images', implode('|', $imageItemIds)); } if ($authorAlias = XoopsRequest::getString('author_alias', '', 'POST')) { $this->setVar('author_alias', $authorAlias); if ($this->getVar('author_alias') !== '') { $this->setVar('uid', 0); } } //mb TODO check on version if ($datesub = XoopsRequest::getString('datesub', '', 'POST')) { // if (version_compare(PHP_VERSION, '5.4.0') >= 0) { // $this->setVar('datesub', strtotime(XoopsRequest::getArray('datesub', array(), 'POST')['date']) + XoopsRequest::getArray('datesub', array(), 'POST')['time']); // } else { $resDate = XoopsRequest::getArray('datesub', array(), 'POST'); $resTime = XoopsRequest::getArray('datesub', array(), 'POST'); // $this->setVar('datesub', strtotime($resDate['date']) + $resTime['time']); $localTimestamp = strtotime($resDate['date']) + $resTime['time']; // get user Timezone offset and use it to find out the Timezone, needed for PHP DataTime $userTimeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset'); $tz = timezone_name_from_abbr(null, $userTimeoffset * 3600); if ($tz === false) { $tz = timezone_name_from_abbr(null, $userTimeoffset * 3600, false); } $userTimezone = new DateTimeZone($tz); $gmtTimezone = new DateTimeZone('GMT'); $myDateTime = new DateTime('now', $gmtTimezone); $offset = $userTimezone->getOffset($myDateTime); $gmtTimestamp = $localTimestamp - $offset; $this->setVar('datesub', $gmtTimestamp); // } } elseif ($this->isNew()) { $this->setVar('datesub', time()); } $this->setVar('short_url', XoopsRequest::getString('item_short_url', '', 'POST')); $this->setVar('meta_keywords', XoopsRequest::getString('item_meta_keywords', '', 'POST')); $this->setVar('meta_description', XoopsRequest::getString('item_meta_description', '', 'POST')); $this->setVar('weight', XoopsRequest::getInt('weight', 0, 'POST')); if ($this->isNew()) { $this->setVar('uid', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0); $this->setVar('cancoment', $this->publisher->getConfig('submit_allowcomments')); $this->setVar('status', $this->publisher->getConfig('submit_status')); $this->setVar('dohtml', $this->publisher->getConfig('submit_dohtml')); $this->setVar('dosmiley', $this->publisher->getConfig('submit_dosmiley')); $this->setVar('doxcode', $this->publisher->getConfig('submit_doxcode')); $this->setVar('doimage', $this->publisher->getConfig('submit_doimage')); $this->setVar('dobr', $this->publisher->getConfig('submit_dobr')); } else { $this->setVar('uid', XoopsRequest::getInt('uid', 0, 'POST')); $this->setVar('cancomment', XoopsRequest::getInt('allowcomments', 1, 'POST')); $this->setVar('status', XoopsRequest::getInt('status', 1, 'POST')); $this->setVar('dohtml', XoopsRequest::getInt('dohtml', 1, 'POST')); $this->setVar('dosmiley', XoopsRequest::getInt('dosmiley', 1, 'POST')); $this->setVar('doxcode', XoopsRequest::getInt('doxcode', 1, 'POST')); $this->setVar('doimage', XoopsRequest::getInt('doimage', 1, 'POST')); $this->setVar('dobr', XoopsRequest::getInt('dolinebreak', 1, 'POST')); } $this->setVar('notifypub', XoopsRequest::getString('notify', '', 'POST')); }
/** * @param $options * * @return array */ function publisher_search_show($options) { $block = array(); $publisher =& PublisherPublisher::getInstance(); $categories =& $publisher->getHandler('category')->getCategoriesForSearch(); if (count($categories) == 0) { return $block; } xoops_loadLanguage('search'); $andor = XoopsRequest::getString('andor', XoopsRequest::getString('andor', '', 'GET'), 'POST'); $username = XoopsRequest::getString('uname', XoopsRequest::getString('uname', null, 'GET'), 'POST'); // $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array()); // $searchin = XoopsRequest::getArray('searchin', (explode("|", XoopsRequest::getString('searchin', array(), 'GET'))), 'POST'); $searchin = XoopsRequest::getArray('searchin', '', 'POST'); if (!isset($searchin)) { $searchin = XoopsRequest::getString('searchin', array(), 'GET'); $searchin = isset($searchin) ? explode('|', $searchin) : array(); } $sortby = XoopsRequest::getString('sortby', XoopsRequest::getString('sortby', null, 'GET'), 'POST'); $term = XoopsRequest::getString('term', XoopsRequest::getString('term', '', 'GET')); //mb TODO simplify next lines with category $category = XoopsRequest::getArray('category', array(), 'POST') ?: XoopsRequest::getArray('category', null, 'GET'); if (empty($category) || is_array($category) && in_array('all', $category)) { $category = array(); } else { $category = !is_array($category) ? explode(',', $category) : $category; $category = array_map('intval', $category); } $andor = in_array(strtoupper($andor), array('OR', 'AND', 'EXACT')) ? strtoupper($andor) : 'OR'; $sortby = in_array(strtolower($sortby), array('itemid', 'datesub', 'title', 'categoryid')) ? strtolower($sortby) : 'itemid'; /* type */ $typeSelect = "<select name=\"andor\">"; $typeSelect .= "<option value=\"OR\""; if ('OR' === $andor) { $typeSelect .= " selected=\"selected\""; } $typeSelect .= '>' . _SR_ANY . '</option>'; $typeSelect .= "<option value=\"AND\""; if ('AND' === $andor) { $typeSelect .= " selected=\"selected\""; } $typeSelect .= '>' . _SR_ALL . '</option>'; $typeSelect .= "<option value=\"EXACT\""; if ('exact' === $andor) { $typeSelect .= " selected=\"selected\""; } $typeSelect .= '>' . _SR_EXACT . '</option>'; $typeSelect .= '</select>'; /* category */ $categorySelect = "<select name=\"category[]\" size=\"5\" multiple=\"multiple\" width=\"150\" style=\"width:150px;\">"; $categorySelect .= "<option value=\"all\""; if (empty($category) || count($category) == 0) { $categorySelect .= "selected=\"selected\""; } $categorySelect .= '>' . _ALL . '</option>'; foreach ($categories as $id => $cat) { $categorySelect .= "<option value=\"" . $id . "\""; if (in_array($id, $category)) { $categorySelect .= "selected=\"selected\""; } $categorySelect .= '>' . $cat . '</option>'; } unset($id, $cat); $categorySelect .= '</select>'; /* scope */ $searchSelect = ''; $searchSelect .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\""; if (is_array($searchin) && in_array('title', $searchin)) { $searchSelect .= ' checked'; } $searchSelect .= ' />' . _CO_PUBLISHER_TITLE . ' '; $searchSelect .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"subtitle\""; if (is_array($searchin) && in_array('subtitle', $searchin)) { $searchSelect .= ' checked'; } $searchSelect .= ' />' . _CO_PUBLISHER_SUBTITLE . ' '; $searchSelect .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"summary\""; if (is_array($searchin) && in_array('summary', $searchin)) { $searchSelect .= ' checked'; } $searchSelect .= ' />' . _CO_PUBLISHER_SUMMARY . ' '; $searchSelect .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\""; if (is_array($searchin) && in_array('body', $searchin)) { $searchSelect .= ' checked'; } $searchSelect .= ' />' . _CO_PUBLISHER_BODY . ' '; $searchSelect .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"keywords\""; if (is_array($searchin) && in_array('meta_keywords', $searchin)) { $searchSelect .= ' checked'; } $searchSelect .= ' />' . _CO_PUBLISHER_ITEM_META_KEYWORDS . ' '; $searchSelect .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\""; if (empty($searchin) || is_array($searchin) && in_array('all', $searchin)) { $searchSelect .= ' checked'; } $searchSelect .= ' />' . _ALL . ' '; /* sortby */ $sortbySelect = "<select name=\"sortby\">"; $sortbySelect .= "<option value=\"itemid\""; if ('itemid' === $sortby || empty($sortby)) { $sortbySelect .= " selected=\"selected\""; } $sortbySelect .= '>' . _NONE . '</option>'; $sortbySelect .= "<option value=\"datesub\""; if ('datesub' === $sortby) { $sortbySelect .= " selected=\"selected\""; } $sortbySelect .= '>' . _CO_PUBLISHER_DATESUB . '</option>'; $sortbySelect .= "<option value=\"title\""; if ('title' === $sortby) { $sortbySelect .= " selected=\"selected\""; } $sortbySelect .= '>' . _CO_PUBLISHER_TITLE . '</option>'; $sortbySelect .= "<option value=\"categoryid\""; if ('categoryid' === $sortby) { $sortbySelect .= " selected=\"selected\""; } $sortbySelect .= '>' . _CO_PUBLISHER_CATEGORY . '</option>'; $sortbySelect .= '</select>'; $block['typeSelect'] = $typeSelect; $block['searchSelect'] = $searchSelect; $block['categorySelect'] = $categorySelect; $block['sortbySelect'] = $sortbySelect; $block['search_term'] = $term; $block['search_user'] = $username; $block['moduleUrl'] = PUBLISHER_URL; return $block; }
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)); }
if (!$categoryObj->store()) { redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors())); // exit; } // TODO : put this function in the category class publisherSaveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read'); publisherSaveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit'); publisherSaveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation'); //Added by fx2024 $parentCat = $categoryObj->categoryid(); $sizeof = count(XoopsRequest::getString('scname', '', 'POST')); for ($i = 0; $i < $sizeof; ++$i) { $temp = XoopsRequest::getArray('scname', array(), 'POST'); if ($temp[$i] != '') { $categoryObj =& $publisher->getHandler('category')->create(); $temp2 = XoopsRequest::getArray('scname', array(), 'POST'); $categoryObj->setVar('name', $temp2[$i]); $categoryObj->setVar('parentid', $parentCat); if (!$categoryObj->store()) { redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors())); // exit; } // TODO : put this function in the category class publisherSaveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read'); publisherSaveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit'); publisherSaveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation'); } } //end of fx2024 code redirect_header($redirect_to, 2, $redirect_msg); // exit();
redirect_header('index.php', 1, _NOPERM); // exit(); } // Putting the values in the file object $fileObj->setVar('name', XoopsRequest::getString('name')); $fileObj->setVar('description', XoopsRequest::getString('description')); $fileObj->setVar('status', XoopsRequest::getInt('file_status', 0, 'GET')); // attach file if any if (XoopsRequest::getString('item_upload_file', '', 'FILES') != '') { $oldfile = $fileObj->getFilePath(); // Get available mimetypes for file uploading $allowed_mimetypes =& $publisher->getHandler('mimetype')->getArrayByType(); // TODO : display the available mimetypes to the user $errors = array(); // if ($publisher->getConfig('perm_upload') && is_uploaded_file(XoopsRequest::getArray('item_upload_file', array(), 'FILES')['tmp_name'])) { $temp = XoopsRequest::getArray('item_upload_file', array(), 'FILES'); if ($publisher->getConfig('perm_upload') && is_uploaded_file($temp['tmp_name'])) { if ($fileObj->checkUpload('item_upload_file', $allowed_mimetypes, $errors)) { if ($fileObj->storeUpload('item_upload_file', $allowed_mimetypes, $errors)) { unlink($oldfile); } } } } if (!$publisher->getHandler('file')->insert($fileObj)) { redirect_header('item.php?itemid=' . $fileObj->itemid(), 3, _AM_PUBLISHER_FILE_EDITING_ERROR . publisherFormatErrors($fileObj->getErrors())); // exit; } redirect_header('item.php?itemid=' . $fileObj->itemid(), 2, _AM_PUBLISHER_FILE_EDITING_SUCCESS); // exit(); break;