/** * @param array $category * * @return array */ public function toArrayTable($category = array()) { $category['categoryid'] = $this->categoryid(); $category['categorylink'] = $this->getCategoryLink(); $category['total'] = $this->getVar('itemcount') > 0 ? $this->getVar('itemcount') : ''; $category['description'] = $this->description(); if ($this->getVar('last_itemid') > 0) { $category['last_itemid'] = $this->getVar('last_itemid', 'n'); $category['last_title_link'] = $this->getVar('last_title_link', 'n'); } if ($this->getImage() !== 'blank.png') { $category['image_path'] = publisherGetImageDir('category', false) . $this->getImage(); } else { $category['image_path'] = ''; } $category['lang_subcategories'] = sprintf(_CO_PUBLISHER_SUBCATEGORIES_INFO, $this->name()); return $category; }
public static function createDir() { // auto crate folders // $thePath = publisherGetUploadDir(); if (publisherGetPathStatus('root', true) < 0) { $thePath = publisherGetUploadDir(); $res = publisherMkdir($thePath); $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('images', true) < 0) { $thePath = publisherGetImageDir(); $res = publisherMkdir($thePath); if ($res) { $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; $dest = $thePath . 'blank.png'; publisherCopyr($source, $dest); } $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('images/category', true) < 0) { $thePath = publisherGetImageDir('category'); $res = publisherMkdir($thePath); if ($res) { $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; $dest = $thePath . 'blank.png'; publisherCopyr($source, $dest); } $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('images/item', true) < 0) { $thePath = publisherGetImageDir('item'); $res = publisherMkdir($thePath); if ($res) { $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; $dest = $thePath . 'blank.png'; publisherCopyr($source, $dest); } $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('content', true) < 0) { $thePath = publisherGetUploadDir(true, 'content'); $res = publisherMkdir($thePath); $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } }
/** * @return string */ public function getCategoryImagePath() { return publisherGetImageDir('category', false) . $this->getCategory()->getImage(); }
/** * @param $options * * @return array|bool */ function publisher_items_spot_show($options) { // global $xoTheme; $publisher =& PublisherPublisher::getInstance(); $optDisplayLast = $options[0]; $optItemsCount = $options[1]; $optCategoryId = $options[2]; $selItems = isset($options[3]) ? explode(',', $options[3]) : ''; $optDisplayPoster = $options[4]; $optDisplayComment = $options[5]; $optDisplayType = $options[6]; $optTruncate = (int) $options[7]; $optCatImage = $options[8]; if ($optCategoryId == 0) { $optCategoryId = -1; } $block = array(); if ($optDisplayLast == 1) { $itemsObj =& $publisher->getHandler('item')->getAllPublished($optItemsCount, 0, $optCategoryId, $sort = 'datesub', $order = 'DESC', 'summary'); $i = 1; $itemsCount = count($itemsObj); if ($itemsObj) { if ($optCategoryId != -1 && $optCatImage) { $cat =& $publisher->getHandler('category')->get($optCategoryId); $category['name'] = $cat->name(); $category['categoryurl'] = $cat->getCategoryUrl(); if ($cat->getImage() !== 'blank.png') { $category['image_path'] = publisherGetImageDir('category', false) . $cat->getImage(); } else { $category['image_path'] = ''; } $block['category'] = $category; } foreach ($itemsObj as $key => $thisitem) { $item = $thisitem->toArraySimple('default', 0, $optTruncate); if ($i < $itemsCount) { $item['showline'] = true; } else { $item['showline'] = false; } if ($optTruncate > 0) { $block['truncate'] = true; } $block['items'][] = $item; ++$i; } } } else { $i = 1; $itemsCount = count($selItems); foreach ($selItems as $itemId) { $itemObj =& $publisher->getHandler('item')->get($itemId); if (!$itemObj->notLoaded()) { $item = $itemObj->toArraySimple(); $item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $itemObj->posterName(), $itemObj->getDatesub()); if ($i < $itemsCount) { $item['showline'] = true; } else { $item['showline'] = false; } if ($optTruncate > 0) { $block['truncate'] = true; $item['summary'] = publisherTruncateTagSafe($item['summary'], $optTruncate); } $block['items'][] = $item; ++$i; } } } if (!isset($block['items']) || count($block['items']) == 0) { return false; } $block['lang_reads'] = _MB_PUBLISHER_READS; $block['lang_comments'] = _MB_PUBLISHER_COMMENTS; $block['lang_readmore'] = _MB_PUBLISHER_READMORE; $block['display_whowhen_link'] = $optDisplayPoster; $block['display_comment_link'] = $optDisplayComment; $block['display_type'] = $optDisplayType; $block['moduleUrl'] = PUBLISHER_URL; $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/assets/css/publisher.css'); 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)); }
$temp = XoopsRequest::getArray('image_file', '', 'FILES'); if ($image_file = $temp['name']) { // $filename = XoopsRequest::getArray('xoops_upload_file', array(), 'POST')[0]; $temp2 = XoopsRequest::getArray('xoops_upload_file', array(), 'POST'); if ($filename = $temp2[0]) { // TODO : implement publisher mimetype management $max_size = $publisher->getConfig('maximum_filesize'); $max_imgwidth = $publisher->getConfig('maximum_image_width'); $max_imgheight = $publisher->getConfig('maximum_image_height'); $allowed_mimetypes = publisherGetAllowedImagesTypes(); if (!is_readable($temp['tmp_name']) || $temp['tmp_name'] == '') { redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR); // exit(); } xoops_load('XoopsMediaUploader'); $uploader = new XoopsMediaUploader(publisherGetImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $categoryObj->setVar('image', $uploader->getSavedFileName()); } else { redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR . $uploader->getErrors()); // exit(); } } } else { $categoryObj->setVar('image', XoopsRequest::getString('image', '', 'POST')); } $categoryObj->setVar('parentid', XoopsRequest::getInt('parentid', 0, 'POST')); $applyall = XoopsRequest::getInt('applyall', 0, 'POST'); $categoryObj->setVar('weight', XoopsRequest::getInt('weight', 1, 'POST')); // Groups and permissions $grpread = XoopsRequest::getArray('groupsRead', array(), 'POST');