function publisher_pagewrap_upload(&$errors) { $publisher = Publisher::getInstance(); $post_field = 'fileupload'; $max_size = $publisher->getConfig('maximum_filesize'); $max_imgwidth = $publisher->getConfig('maximum_image_width'); $max_imgheight = $publisher->getConfig('maximum_image_height'); if (!is_dir(PublisherUtils::getUploadDir(true, 'content'))) { mkdir(PublisherUtils::getUploadDir(true, 'content'), 0757); } $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml'); $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($post_field)) { $uploader->setTargetFileName($uploader->getMediaName()); if ($uploader->upload()) { return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
function publisher_latest_files_show($options) { $publisher = Publisher::getInstance(); /** * $options[0] : Category * $options[1] : Sort order - datesub | counter * $options[2] : Number of files to display * $oprions[3] : bool TRUE to link to the file download, FALSE to link to the article */ $block = array(); $sort = $options[1]; $order = PublisherUtils::getOrderBy($sort); $limit = $options[2]; $directDownload = $options[3]; // creating the files objects $filesObj = $publisher->getFileHandler()->getAllFiles(0, _PUBLISHER_STATUS_FILE_ACTIVE, $limit, 0, $sort, $order, explode(',', $options[0])); /* @var $fileObj PublisherFile */ foreach ($filesObj as $fileObj) { $aFile = array(); $aFile['link'] = $directDownload ? $fileObj->getFileLink() : $fileObj->getItemLink(); if ($sort == "datesub") { $aFile['new'] = $fileObj->datesub(); } elseif ($sort == "counter") { $aFile['new'] = $fileObj->getVar('counter'); } elseif ($sort == "weight") { $aFile['new'] = $fileObj->getVar('weight'); } $block['files'][] = $aFile; } return $block; }
function publisher_date_to_date_show($options) { $myts = MyTextSanitizer::getInstance(); $publisher = Publisher::getInstance(); $block = array(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('datesub', strtotime($options[0]), '>')); $criteria->add(new Criteria('datesub', strtotime($options[1]), '<')); $criteria->setSort('datesub'); $criteria->setOrder('DESC'); // creating the ITEM objects that belong to the selected category $itemsObj = $publisher->getItemHandler()->getItemObjects($criteria); $totalItems = count($itemsObj); if ($itemsObj) { for ($i = 0; $i < $totalItems; ++$i) { $newItems['itemid'] = $itemsObj[$i]->getVar('itemid'); $newItems['title'] = $itemsObj[$i]->title(); $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); $newItems['categoryid'] = $itemsObj[$i]->getVar('categoryid'); $newItems['date'] = $itemsObj[$i]->datesub(); $newItems['poster'] = $itemsObj[$i]->linkedPosterName(); $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); $block['items'][] = $newItems; } $block['lang_title'] = _MB_PUBLISHER_ITEMS; $block['lang_category'] = _MB_PUBLISHER_CATEGORY; $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; $block['lang_date'] = _MB_PUBLISHER_DATE; $modulename = $myts->displayTarea($publisher->getModule()->getVar('name')); $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . " " . $modulename; $block['lang_articles_from_to'] = sprintf(_MB_PUBLISHER_ARTICLES_FROM_TO, $options[0], $options[1]); } return $block; }
function publisher_items_menu_show($options) { $block = array(); $publisher = Publisher::getInstance(); // Getting all top cats $block_categoriesObj = $publisher->getCategoryHandler()->getCategories(0, 0, 0); if (count($block_categoriesObj) == 0) { return $block; } // Are we in Publisher ? $block['inModule'] = $publisher->isCurrentModule(); $catlink_class = 'menuMain'; $categoryid = 0; if ($block['inModule']) { // Are we in a category and if yes, in which one ? $categoryid = isset($_GET['categoryid']) ? (int) $_GET['categoryid'] : 0; if ($categoryid != 0) { // if we are in a category, then the $categoryObj is already defined in publisher/category.php $categoryObj = $publisher->getCategoryHandler()->get($categoryid); $block['currentcat'] = $categoryObj->getCategoryLink('menuTop'); $catlink_class = 'menuSub'; } } /* @var $block_categoryObj PublisherCategory */ foreach ($block_categoriesObj as $catid => $block_categoryObj) { if ($catid != $categoryid) { $block['categories'][$catid]['categoryLink'] = $block_categoryObj->getCategoryLink($catlink_class); } } return $block; }
/** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package Publisher * @since 1.0 * @author trabis <*****@*****.**> * @version $Id$ */ function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "") { $publisher = Publisher::getInstance(); $ret = array(); if ($queryarray == '' || count($queryarray) == 0) { $hightlight_key = ''; } else { $keywords = implode('+', $queryarray); $hightlight_key = "&keywords=" . $keywords; } $itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra); $withCategoryPath = $publisher->getConfig('search_cat_path'); $usersIds = array(); /* @var $obj PublisherItem */ foreach ($itemsObjs as $obj) { $item['image'] = "images/item_icon.gif"; $item['link'] = $obj->getItemUrl(); $item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&') : $hightlight_key; if ($withCategoryPath) { $item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title(); } else { $item['title'] = $obj->title(); } $item['time'] = $obj->getVar('datesub'); //must go has unix timestamp $item['uid'] = $obj->getVar('uid'); //"Fulltext search/highlight $text = $obj->body(); $sanitized_text = ""; $text_i = strtolower($text); $queryarray = is_array($queryarray) ? $queryarray : array($queryarray); //@todo look into xoopslocal foreach ($queryarray as $query) { $pos = strpos($text_i, strtolower($query)); //xoops_local("strpos", $text_i, strtolower($query)); $start = max($pos - 100, 0); $length = strlen($query) + 200; //xoops_local("strlen", $query) + 200; $context = $obj->highlight(XoopsLocale::substr($text, $start, $length, " [...]"), $query); $sanitized_text .= "<p>[...] " . $context . "</p>"; } //End of highlight $item['text'] = $sanitized_text; $item['author'] = $obj->getVar('author_alias'); $item['datesub'] = $obj->datesub($publisher->getConfig('format_date')); $usersIds[$obj->getVar('uid')] = $obj->getVar('uid'); $ret[] = $item; unset($item, $sanitized_text); } $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true); foreach ($ret as $key => $item) { if ($item["author"] == '') { $ret[$key]["author"] = @$usersNames[$item["uid"]]; } } unset($usersNames, $usersIds); return $ret; }
/** * @param string $title * @param string $keywords * @param string $description * @param bool $categoryPath */ public function __construct($title, $keywords = '', $description = '', $categoryPath = false) { $this->publisher = Publisher::getInstance(); $this->_myts = MyTextSanitizer::getInstance(); $this->setCategoryPath($categoryPath); $this->setTitle($title); $this->setDescription($description); if ($keywords == '') { $keywords = $this->createMetaKeywords(); } $this->setKeywords($keywords); }
/** * @return array */ public function waiting() { $publisher = Publisher::getInstance(); $ret = array(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('status', 1)); $count = $publisher->getItemHandler()->getCount($criteria); if ($count) { $ret['count'] = $count; $ret['name'] = _MI_PUBLISHER_WAITING; $ret['link'] = $publisher->url('admin/item.php'); } return $ret; }
/** * @param PublisherFile $obj */ public function __construct(PublisherFile $obj) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $publisher->loadLanguage('main'); parent::__construct(_AM_PUBLISHER_UPLOAD_FILE, "form", $xoops->getEnv('PHP_SELF')); $this->setExtra('enctype="multipart/form-data"'); // NAME $name_text = new Xoops\Form\Text(_CO_PUBLISHER_FILENAME, 'name', 50, 255, $obj->getVar('name')); $name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC); $this->addElement($name_text, true); // DESCRIPTION $description_text = new Xoops\Form\TextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'description', $obj->getVar('description')); $description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC); $this->addElement($description_text); // FILE TO UPLOAD $file_box = new Xoops\Form\File(_CO_PUBLISHER_FILE_TO_UPLOAD, "item_upload_file"); $file_box->set('size', 50); $this->addElement($file_box); $status_select = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'file_status', _PUBLISHER_STATUS_FILE_ACTIVE); $status_select->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC); $this->addElement($status_select); // fileid $this->addElement(new Xoops\Form\Hidden('fileid', $obj->getVar('fileid'))); // itemid $this->addElement(new Xoops\Form\Hidden('itemid', $obj->getVar('itemid'))); $files_button_tray = new Xoops\Form\ElementTray('', ''); $files_hidden = new Xoops\Form\Hidden('op', 'uploadfile'); $files_button_tray->addElement($files_hidden); if (!$obj->getVar('fileid')) { $files_butt_create = new Xoops\Form\Button('', '', _MD_PUBLISHER_UPLOAD, 'submit'); $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"'); $files_button_tray->addElement($files_butt_create); $files_butt_another = new Xoops\Form\Button('', '', _CO_PUBLISHER_FILE_UPLOAD_ANOTHER, 'submit'); $files_butt_another->setExtra('onclick="this.form.elements.op.value=\'uploadanother\'"'); $files_button_tray->addElement($files_butt_another); } else { $files_butt_create = new Xoops\Form\Button('', '', _MD_PUBLISHER_MODIFY, 'submit'); $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'modify\'"'); $files_button_tray->addElement($files_butt_create); } $files_butt_clear = new Xoops\Form\Button('', '', _MD_PUBLISHER_CLEAR, 'reset'); $files_button_tray->addElement($files_butt_clear); $buttonCancel = new Xoops\Form\Button('', '', _MD_PUBLISHER_CANCEL, 'button'); $buttonCancel->setExtra('onclick="history.go(-1)"'); $files_button_tray->addElement($buttonCancel); $this->addElement($files_button_tray); }
function publisher_items_random_item_show($options) { $block = array(); $publisher = Publisher::getInstance(); // creating the ITEM object $itemsObj = $publisher->getItemHandler()->getRandomItem('', array(_PUBLISHER_STATUS_PUBLISHED)); if (!is_object($itemsObj)) { return $block; } $block['content'] = $itemsObj->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available $block['id'] = $itemsObj->getVar('itemid'); $block['url'] = $itemsObj->getItemUrl(); $block['lang_fullitem'] = _MB_PUBLISHER_FULLITEM; return $block; }
/** * expects an array of array containing: * name, Name of the submenu * url, Url of the submenu relative to the module * ex: return array(0 => array( * 'name' => _MI_PUBLISHER_SUB_SMNAME3; * 'url' => "search.php"; * )); * * @return array */ public function subMenus() { $ret = array(); $helper = Publisher::getInstance(); // Add the Submit new item button if ($helper->isUserAdmin() || $helper->getConfig('perm_submit') && ($helper->xoops()->isUser() || $helper->getConfig('permissions_anon_post'))) { $ret[] = array('name' => _MI_PUBLISHER_SUB_SMNAME1, 'url' => "submit.php?op=add"); } // DISABLED since the internal search doesn't work // Add the Search button if (false && $helper->getConfig('perm_search')) { $ret[] = array('name' => _MI_PUBLISHER_SUB_SMNAME3, 'url' => "search.php"); } // Add the Archive button $ret[] = array('name' => _MI_PUBLISHER_SUB_ARCHIVE, 'url' => "archive.php"); return $ret; }
function publisher_items_recent_show($options) { $publisher = Publisher::getInstance(); $myts = MyTextSanitizer::getInstance(); $block = array(); $selectedcatids = explode(',', $options[0]); if (in_array(0, $selectedcatids)) { $allcats = true; } else { $allcats = false; } $sort = $options[1]; $order = PublisherUtils::getOrderBy($sort); $limit = $options[2]; $start = 0; // creating the ITEM objects that belong to the selected category if ($allcats) { $criteria = null; } else { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN')); } $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); $totalItems = count($itemsObj); if ($itemsObj) { for ($i = 0; $i < $totalItems; ++$i) { $newItems['itemid'] = $itemsObj[$i]->getVar('itemid'); $newItems['title'] = $itemsObj[$i]->title(); $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); $newItems['categoryid'] = $itemsObj[$i]->getVar('categoryid'); $newItems['date'] = $itemsObj[$i]->datesub(); $newItems['poster'] = $itemsObj[$i]->linkedPosterName(); $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); $block['items'][] = $newItems; } $block['lang_title'] = _MB_PUBLISHER_ITEMS; $block['lang_category'] = _MB_PUBLISHER_CATEGORY; $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; $block['lang_date'] = _MB_PUBLISHER_DATE; $modulename = $myts->displayTarea($publisher->getModule()->getVar('name')); $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . " " . $modulename; } return $block; }
public function searchAdvanced($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "") { $publisher = Publisher::getInstance(); $ret = array(); if ($queryarray == '' || count($queryarray) == 0) { $hightlight_key = ''; } else { $keywords = implode('+', $queryarray); $hightlight_key = "&keywords=" . $keywords; } $itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra); $withCategoryPath = $publisher->getConfig('search_cat_path'); $usersIds = array(); /* @var $obj PublisherItem */ foreach ($itemsObjs as $obj) { $item['image'] = "images/item_icon.gif"; $item['link'] = $obj->getItemUrl(); $item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&') : $hightlight_key; if ($withCategoryPath) { $item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title(); } else { $item['title'] = $obj->title(); } $item['time'] = $obj->getVar('datesub'); //must go has unix timestamp $item['uid'] = $obj->getVar('uid'); $item['content'] = Metagen::getSearchSummary($obj->body(), $queryarray); $item['author'] = $obj->getVar('author_alias'); $item['datesub'] = $obj->datesub($publisher->getConfig('format_date')); $usersIds[$obj->getVar('uid')] = $obj->getVar('uid'); $ret[] = $item; unset($item, $sanitized_text); } $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true); foreach ($ret as $key => $item) { if ($item["author"] == '') { $ret[$key]["author"] = @$usersNames[$item["uid"]]; } } unset($usersNames, $usersIds); return $ret; }
function publisher_category_items_sel_show($options) { $publisher = Publisher::getInstance(); $block = array(); $categories = $publisher->getCategoryHandler()->getCategories(0, 0, -1); if (count($categories) == 0) { return $block; } $selectedcatids = explode(',', $options[0]); $sort = $options[1]; $order = PublisherUtils::getOrderBy($sort); $limit = $options[2]; $start = 0; // creating the ITEM objects that belong to the selected category $block['categories'] = array(); /* @var $catObj PublisherCategory */ foreach ($categories as $catID => $catObj) { if (!in_array(0, $selectedcatids) && !in_array($catID, $selectedcatids)) { continue; } $criteria = new Criteria('categoryid', $catID); $items = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); unset($criteria); if (count($items) == 0) { continue; } $item['title'] = $catObj->getVar('name'); $item['itemurl'] = 'none'; $block['categories'][$catID]['items'][] = $item; /* @var $itemObj PublisherItem */ foreach ($items as $itemObj) { $item['title'] = $itemObj->title(isset($options[3]) ? $options[3] : 0); $item['itemurl'] = $itemObj->getItemUrl(); $block['categories'][$catID]['items'][] = $item; } $block['categories'][$catID]['name'] = $catObj->getVar('name'); } unset($items, $categories); //if (count($block['categories']) == 0) return $block; return $block; }
/** * @param null|int $id */ public function __construct($id = null) { $this->publisher = Publisher::getInstance(); $this->initVar("fileid", XOBJ_DTYPE_INT, 0, false); $this->initVar("itemid", XOBJ_DTYPE_INT, null, true); $this->initVar("name", XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar("description", XOBJ_DTYPE_TXTBOX, null, false, 255); $this->initVar("filename", XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar("mimetype", XOBJ_DTYPE_TXTBOX, null, true, 64); $this->initVar("uid", XOBJ_DTYPE_INT, 0, false); $this->initVar("datesub", XOBJ_DTYPE_INT, null, false); $this->initVar("status", XOBJ_DTYPE_INT, 1, false); $this->initVar("notifypub", XOBJ_DTYPE_INT, 0, false); $this->initVar("counter", XOBJ_DTYPE_INT, null, false); if (isset($id)) { $file = $this->publisher->getFileHandler()->get($id); foreach ($file->vars as $k => $v) { $this->assignVar($k, $v['value']); } } }
function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0) { $publisher = Publisher::getInstance(); $xoops = Xoops::getInstance(); // if there is a parameter, and the id exists, retrieve data: we're editing a file if ($fileid != 0) { // Creating the File object /* @var $fileObj PublisherFile */ $fileObj = $publisher->getFileHandler()->get($fileid); if ($fileObj->notLoaded()) { $xoops->redirect("javascript:history.go(-1)", 1, _AM_PUBLISHER_NOFILESELECTED); } if ($showmenu) { //publisher_adminMenu(2, _AM_PUBLISHER_FILE . " > " . _AM_PUBLISHER_EDITING); } echo "<br />\n"; echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_PUBLISHER_FILE_EDITING . "</span>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_PUBLISHER_FILE_EDITING_DSC . "</span>"; PublisherUtils::openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS); } else { // there's no parameter, so we're adding an item $fileObj = $publisher->getFileHandler()->create(); $fileObj->setVar('itemid', $itemid); if ($showmenu) { //publisher_adminMenu(2, _AM_PUBLISHER_FILE . " > " . _AM_PUBLISHER_FILE_ADD); } echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_PUBLISHER_FILE_ADDING . "</span>"; echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_PUBLISHER_FILE_ADDING_DSC . "</span>"; PublisherUtils::openCollapsableBar('addfile', 'addfileicon', _AM_PUBLISHER_FILE_INFORMATIONS); } // FILES UPLOAD FORM $files_form = $publisher->getForm($fileObj, 'file'); $files_form->display(); if ($fileid != 0) { PublisherUtils::closeCollapsableBar('editfile', 'editfileicon'); } else { PublisherUtils::closeCollapsableBar('addfile', 'addfileicon'); } }
/** Get item fields: title, content, time, link, uid, uname, tags **/ function publisher_tag_iteminfo(&$items) { $publisher = Publisher::getInstance(); $items_id = array(); foreach (array_keys($items) as $cat_id) { // Some handling here to build the link upon catid // if catid is not used, just skip it foreach (array_keys($items[$cat_id]) as $item_id) { // In article, the item_id is "art_id" $items_id[] = (int) $item_id; } } $item_handler = $publisher->getItemHandler(); $criteria = new Criteria("itemid", "(" . implode(", ", $items_id) . ")", "IN"); $items_obj = $item_handler->getItemObjects($criteria, 'itemid'); /* @var $item_obj PublisherItem */ foreach (array_keys($items) as $cat_id) { foreach (array_keys($items[$cat_id]) as $item_id) { $item_obj = $items_obj[$item_id]; $items[$cat_id][$item_id] = array("title" => $item_obj->getVar("title"), "uid" => $item_obj->getVar("uid"), "link" => "item.php?itemid={$item_id}", "time" => $item_obj->getVar("datesub"), "tags" => tag_parse_tag($item_obj->getVar("item_tag", "n")), "content" => ""); } } unset($items_obj); }
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package Publisher * @since 1.0 * @author Bandit-X * @author trabis <*****@*****.**> * @author Xoops Modules Dev Team * @version $Id$ */ // ###################################################################### // # Original version: // # [11-may-2001] Kenneth Lee - http://www.nexgear.com/ // ###################################################################### include_once __DIR__ . '/header.php'; $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $xoops->header('module:publisher/publisher_archive.tpl'); $xoopsTpl = $xoops->tpl(); XoopsLoad::loadFile($publisher->path('footer.php')); $lastyear = 0; $lastmonth = 0; $months_arr = array(1 => XoopsLocale::L_MONTH_JANUARY, 2 => XoopsLocale::L_MONTH_FEBRUARY, 3 => XoopsLocale::L_MONTH_MARCH, 4 => XoopsLocale::L_MONTH_APRIL, 5 => XoopsLocale::L_MONTH_MAY, 6 => XoopsLocale::L_MONTH_JUNE, 7 => XoopsLocale::L_MONTH_JULY, 8 => XoopsLocale::L_MONTH_AUGUST, 9 => XoopsLocale::L_MONTH_SEPTEMBER, 10 => XoopsLocale::L_MONTH_OCTOBER, 11 => XoopsLocale::L_MONTH_NOVEMBER, 12 => XoopsLocale::L_MONTH_DECEMBER); $fromyear = Request::getInt('year'); $frommonth = Request::getInt('month'); $pgtitle = ''; if ($fromyear && $frommonth) { $pgtitle = sprintf(" - %d - %d", $fromyear, $frommonth); } $dateformat = $publisher->getConfig('format_date'); if ($dateformat == '') { $dateformat = 'm';
/** * @param PublisherCategory $obj */ public function __construct(PublisherCategory $obj) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $member_handler = $xoops->getHandlerMember(); $userGroups = $member_handler->getGroupList(); parent::__construct(_AM_PUBLISHER_CATEGORY, "form", $xoops->getEnv('PHP_SELF')); $this->setExtra('enctype="multipart/form-data"'); // Category $criteria = new Criteria(null); $criteria->setSort('weight'); $criteria->setOrder('ASC'); $categories = $publisher->getCategoryHandler()->getObjects($criteria); $mytree = new XoopsObjectTree($categories, "categoryid", "parentid"); $cat_select = $mytree->makeSelBox('parentid', 'name', '--', $obj->getVar('parentid'), true); $this->addElement(new Xoops\Form\Label(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $cat_select)); // Name $this->addElement(new Xoops\Form\Text(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $obj->getVar('name', 'e')), true); // Description $this->addElement(new Xoops\Form\TextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $obj->getVar('description', 'e'), 7, 60)); // EDITOR $groups = $xoops->getUserGroups(); $gperm_handler = $publisher->getGrouppermHandler(); $module_id = $publisher->getModule()->mid(); $allowed_editors = PublisherUtils::getEditors($gperm_handler->getItemIds('editors', $groups, $module_id)); $nohtml = false; if (count($allowed_editors) > 0) { $editor = @$_POST['editor']; if (!empty($editor)) { PublisherUtils::setCookieVar('publisher_editor', $editor); } else { $editor = PublisherUtils::getCookieVar('publisher_editor'); if (empty($editor) && $xoops->isUser()) { $editor = $xoops->user->getVar('publisher_editor'); // Need set through user profile } } $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $publisher->getConfig('submit_editor') : $editor; $form_editor = new Xoops\Form\SelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors); $this->addElement($form_editor); } else { $editor = $publisher->getConfig('submit_editor'); } $editor_configs = array(); $editor_configs['rows'] = $publisher->getConfig('submit_editor_rows') == '' ? 35 : $publisher->getConfig('submit_editor_rows'); $editor_configs['cols'] = $publisher->getConfig('submit_editor_cols') == '' ? 60 : $publisher->getConfig('submit_editor_cols'); $editor_configs['width'] = $publisher->getConfig('submit_editor_width') == '' ? "100%" : $publisher->getConfig('submit_editor_width'); $editor_configs['height'] = $publisher->getConfig('submit_editor_height') == '' ? "400px" : $publisher->getConfig('submit_editor_height'); $editor_configs['name'] = 'header'; $editor_configs['value'] = $obj->getVar('header', 'e'); $text_header = new Xoops\Form\Editor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editor_configs, $nohtml, $onfailure = null); $text_header->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC); $this->addElement($text_header); // IMAGE $image_array = XoopsLists::getImgListAsArray(PublisherUtils::getImageDir('category')); $image_select = new Xoops\Form\Select('', 'image', $obj->image()); //$image_select -> addOption ('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'"); $image_tray = new Xoops\Form\ElementTray(_AM_PUBLISHER_IMAGE, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new Xoops\Form\Label('', "<br /><br /><img src='" . PublisherUtils::getImageDir('category', false) . $obj->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_PUBLISHER_IMAGE_DSC); $this->addElement($image_tray); // IMAGE UPLOAD //$max_size = 5000000; $file_box = new Xoops\Form\File(_AM_PUBLISHER_IMAGE_UPLOAD, "image_file"); $file_box->setExtra("size ='45'"); $file_box->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC); $this->addElement($file_box); // Short url $text_short_url = new Xoops\Form\Text(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $obj->getVar('short_url', 'e')); $text_short_url->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC); $this->addElement($text_short_url); // Meta Keywords $text_meta_keywords = new Xoops\Form\TextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $obj->getVar('meta_keywords', 'e'), 7, 60); $text_meta_keywords->setDescription(_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC); $this->addElement($text_meta_keywords); // Meta Description $text_meta_description = new Xoops\Form\TextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $obj->getVar('meta_description', 'e'), 7, 60); $text_meta_description->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC); $this->addElement($text_meta_description); // Weight $this->addElement(new Xoops\Form\Text(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $obj->getVar('weight'))); // Added by skalpa: custom template support //todo, check this $this->addElement(new Xoops\Form\Text("Custom template", 'template', 50, 255, $obj->getVar('template', 'e')), false); // READ PERMISSIONS $groups_read_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_READ, 'groups_read[]', $obj->getGroups_read()); foreach ($userGroups as $group_id => $group_name) { $groups_read_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_read_checkbox); // SUBMIT PERMISSIONS $groups_submit_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $obj->getGroups_submit()); $groups_submit_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC); foreach ($userGroups as $group_id => $group_name) { $groups_submit_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_submit_checkbox); // MODERATION PERMISSIONS $groups_moderation_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, 'groups_moderation[]', $obj->getGroups_moderation()); $groups_moderation_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC); foreach ($userGroups as $group_id => $group_name) { $groups_moderation_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_moderation_checkbox); $moderator = new Xoops\Form\SelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $obj->getVar('moderator', 'e'), 1, false); $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC); $this->addElement($moderator); $cat_tray = new Xoops\Form\ElementTray(_AM_PUBLISHER_SCATEGORYNAME, '<br /><br />'); for ($i = 0; $i < $this->_subCatsCount; ++$i) { if ($i < (isset($_POST['scname']) ? sizeof($_POST['scname']) : 0)) { $subname = isset($_POST['scname']) ? $_POST['scname'][$i] : ''; } else { $subname = ''; } $cat_tray->addElement(new Xoops\Form\Text('', 'scname[' . $i . ']', 50, 255, $subname)); } $t = new Xoops\Form\Text('', 'nb_subcats', 3, 2); $l = new Xoops\Form\Label('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render())); $b = new Xoops\Form\Button('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit'); if (!$obj->getVar('categoryid')) { $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"'); } else { $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"'); } $r = new Xoops\Form\ElementTray(''); $r->addElement($l); $r->addElement($b); $cat_tray->addElement($r); $this->addElement($cat_tray); $this->addElement(new Xoops\Form\Hidden('categoryid', $obj->getVar('categoryid'))); $this->addElement(new Xoops\Form\Hidden('nb_sub_yet', $this->_subCatsCount)); // Action buttons tray $button_tray = new Xoops\Form\ElementTray('', ''); // No ID for category -- then it's new category, button says 'Create' if (!$obj->getVar('categoryid')) { $button_tray->addElement(new Xoops\Form\Button('', 'addcategory', _AM_PUBLISHER_CREATE, 'submit')); $butt_clear = new Xoops\Form\Button('', '', _AM_PUBLISHER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new Xoops\Form\Button('', '', _AM_PUBLISHER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $this->addElement($button_tray); } else { $button_tray->addElement(new Xoops\Form\Button('', 'addcategory', _AM_PUBLISHER_MODIFY, 'submit')); $butt_cancel = new Xoops\Form\Button('', '', _AM_PUBLISHER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $this->addElement($button_tray); } }
function publisher_editItem($showmenu = false, $itemid = 0, $clone = false) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); global $publisher_current_page; $formTpl = new XoopsTpl(); //publisher_submit.html // if there is a parameter, and the id exists, retrieve data: we're editing a item if ($itemid != 0) { // Creating the ITEM object /* @var $itemObj PublisherItem */ $itemObj = $publisher->getItemHandler()->get($itemid); if (!$itemObj) { $xoops->redirect("item.php", 1, _AM_PUBLISHER_NOITEMSELECTED); } if ($clone) { $itemObj->setNew(); $itemObj->setVar('itemid', 0); $itemObj->setVar('status', _PUBLISHER_STATUS_NOTSET); $itemObj->setVar('datesub', time()); } switch ($itemObj->getVar('status')) { case _PUBLISHER_STATUS_SUBMITTED: $page_title = _AM_PUBLISHER_SUBMITTED_TITLE; $page_info = _AM_PUBLISHER_SUBMITTED_INFO; break; case _PUBLISHER_STATUS_PUBLISHED: $page_title = _AM_PUBLISHER_PUBLISHEDEDITING; $page_info = _AM_PUBLISHER_PUBLISHEDEDITING_INFO; break; case _PUBLISHER_STATUS_OFFLINE: $page_title = _AM_PUBLISHER_OFFLINEEDITING; $page_info = _AM_PUBLISHER_OFFLINEEDITING_INFO; break; case _PUBLISHER_STATUS_REJECTED: $page_title = _AM_PUBLISHER_REJECTED_EDIT; $page_info = _AM_PUBLISHER_REJECTED_EDIT_INFO; break; case _PUBLISHER_STATUS_NOTSET: // Then it's a clone... $page_title = _AM_PUBLISHER_ITEM_DUPLICATING; $page_info = _AM_PUBLISHER_ITEM_DUPLICATING_DSC; break; case "default": default: $page_title = _AM_PUBLISHER_PUBLISHEDEDITING; $page_info = _AM_PUBLISHER_PUBLISHEDEDITING_INFO; break; } echo "<br />\n"; PublisherUtils::openCollapsableBar('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->getVar('itemid') . "'\" value='" . _AM_PUBLISHER_CLONE_ITEM . "'> "; echo "</div></form>"; } } else { // there's no parameter, so we're adding an item /* @var $itemObj PublisherItem */ $itemObj = $publisher->getItemHandler()->create(); $itemObj->setVarsFromRequest(); $categoryObj = $publisher->getCategoryHandler()->create(); $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0; $categoryObj->setVar('categoryid', $sel_categoryid); PublisherUtils::openCollapsableBar('createitemtable', 'createitemicon', _AM_PUBLISHER_ITEM_CREATING, _AM_PUBLISHER_ITEM_CREATING_DSC); } /* @var $sform PublisherItemForm */ $sform = $publisher->getForm($itemObj, 'item'); $sform->setTitle(_AM_PUBLISHER_ITEMS); $sform->assign($formTpl); $formTpl->display('module:publisher/publisher_submit.tpl'); PublisherUtils::closeCollapsableBar('edititemtable', 'edititemicon'); PublisherUtils::openCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC); $dir = PublisherUtils::getUploadDir(true, 'content'); if (!preg_match('/777/i', decoct(fileperms($dir)))) { echo "<font color='FF0000'><h4>" . _AM_PUBLISHER_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_PUBLISHER_UPLOAD_FILE . "</th></tr>"; echo "<tr valign='top' align='left'><td class='head'>" . _AM_PUBLISHER_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_PUBLISHER_UPLOAD . "' /></td></tr>"; echo "<input type='hidden' name='backto' value='{$publisher_current_page}'/>"; echo "</table>"; echo "</form>"; // Delete File $form = new Xoops\Form\ThemeForm(_CO_PUBLISHER_DELETEFILE, "form_name", "pw_delete_file.php"); $pWrap_select = new Xoops\Form\Select(PublisherUtils::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 Xoops\Form\Hidden('op', $delfile)); $submit = new Xoops\Form\Button("", "submit", _AM_PUBLISHER_BUTTON_DELETE, "submit"); $form->addElement($submit); $form->addElement(new Xoops\Form\Hidden('backto', $publisher_current_page)); $form->display(); PublisherUtils::closeCollapsableBar('pagewraptable', 'pagewrapicon'); }
/** * This method will be executed whenever a new comment form is displayed. * You can set a default title for the comment and a header to be displayed on top of the form * ex: return array( * 'title' => 'My Article Title', * 'text' => 'Content of the article'); * 'timestamp' => time(); //Date of the article in unix format * 'uid' => Id of the article author * * @param int $item_id The unique ID of an item * * @return array */ public function itemInfo($item_id) { $ret = array(); include_once dirname(dirname(__DIR__)) . '/include/common.php'; /* @var $itemObj PublisherItem */ $itemObj = Publisher::getInstance()->getItemHandler()->get((int) $item_id); $ret['text'] = ''; $summary = $itemObj->summary(); if ($summary != '') { $ret['text'] .= $summary . '<br /><br />'; } $ret['text'] .= $itemObj->body(); $ret['title'] = $itemObj->title(); $ret['uid'] = $itemObj->getVar('uid'); $ret['timestamp'] = $itemObj->getVar('datesub', 'n'); return $ret; }
function publisher_latest_news_show($options) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $publisher->loadLanguage('main'); $block = array(); $start = $options[0]; // You can show articles from specified range $limit = $options[1]; $column_count = $options[2]; $letters = $options[3]; $selected_stories = $options[4]; $sort = $options[9]; $order = PublisherUtils::getOrderBy($sort); $imgwidth = $options[11]; $imgheight = $options[12]; $border = $options[13]; $bordercolor = $options[14]; $block['spec']['columnwidth'] = (int) (1 / $column_count * 100); $allcats = false; if (!isset($options[29])) { $allcats = true; } elseif (in_array(0, explode(',', $options[29]))) { $allcats = true; } // creating the ITEM objects that belong to the selected category if ($allcats) { $criteria = null; } else { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', '(' . $options[29] . ')', 'IN')); } // Use specific ITEMS if ($selected_stories != 0) { unset($criteria); //removes category option $criteria = new CriteriaCompo(); $criteria->add(new Criteria('itemid', '(' . $selected_stories . ')', 'IN')); } $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, 'itemid'); $scount = count($itemsObj); if ($scount == 0) { return false; } $k = 0; $columns = array(); $thumbService = \Xoops::getInstance()->service('thumbnail'); /* @var $itemObj PublisherItem */ foreach ($itemsObj as $itemObj) { $item = array(); $item['itemurl'] = $itemObj->getItemUrl(); $item['title'] = $itemObj->getItemLink(); $item['alt'] = strip_tags($itemObj->getItemLink()); $mainImage = $itemObj->getMainImage(); $item['item_image'] = $thumbService->getImgUrl($mainImage['image_vpath'], $imgwidth, 0)->getValue(); $item['text'] = $itemObj->getBlockSummary($letters); $item = $itemObj->getMainImage($item); //returns an array $ls_height = ''; if ($options[12] != 0) { $ls_height = 'height="' . $imgheight . '" '; } if ($options[15] == 'LEFT') { $imgposition = "float: left"; $ls_margin = '-right'; } elseif ($options[15] == 'CENTER') { $imgposition = "text-align:center"; $ls_margin = ''; } else { $imgposition = "float: right"; $ls_margin = '-left'; } //Image if ($options[10] == 1 && $item['image_path'] != '') { $startdiv = '<div style="' . $imgposition . '"><a href="' . $item['itemurl'] . '">'; $style = 'style="margin' . $ls_margin . ': 10px; padding: 2px; border: ' . $border . 'px solid #' . $bordercolor . '"'; $enddiv = 'width="' . $imgwidth . '" ' . $ls_height . '/></a></div>'; $image = $startdiv . '<img ' . $style . ' src="' . $item['item_image'] . '" alt="' . $item['image_name'] . '" ' . $enddiv; $item['image'] = $image; } if ($publisher->isUserAdmin()) { $item['admin'] = "<a href='" . PUBLISHER_URL . "/submit.php?itemid=" . $itemObj->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "' /></a> "; $item['admin'] .= "<a href='" . PUBLISHER_URL . "/admin/item.php?op=del&itemid=" . $itemObj->getVar('itemid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png'" . " title='" . _CO_PUBLISHER_DELETE . "' alt='" . _CO_PUBLISHER_DELETE . "' /></a>"; } else { $item['admin'] = ''; } $block['topiclink'] = ''; /* if ($options[16] == 1) { $block['topiclink'] = '| <a href="'.\XoopsBaseConfig::get('url').'/modules/news/topics_directory.php">'._AM_NEWS_TOPICS_DIRECTORY.'</a> '; } */ $block['archivelink'] = ''; if ($options[17] == 1) { $block['archivelink'] = '| <a href="' . PUBLISHER_URL . '/archive.php">' . _MB_PUBLISHER_ARCHIVE . '</a> '; } //TODO: Should we not show link to Anonymous? $block['submitlink'] = ''; if ($options[18] == 1 && $xoops->isUser()) { $block['submitlink'] = '| <a href="' . PUBLISHER_URL . '/submit.php">' . _MB_PUBLISHER_SUBMITNEWS . '</a> '; } $item['poster'] = ''; if ($options[19] == 1) { $item['poster'] = _MB_PUBLISHER_POSTER . ' ' . $itemObj->posterName(); } $item['posttime'] = ''; if ($options[20] == 1) { //todo, check this concatenation $item['posttime'] = strtolower(XoopsLocale::ON) . ' ' . $itemObj->datesub(); } $item['topic_title'] = ''; if ($options[21] == 1) { $item['topic_title'] = $itemObj->getCategoryLink() . _MB_PUBLISHER_SP; } $item['read'] = ''; if ($options[22] == 1) { //todo, check this concatenation $item['read'] = ' (' . $itemObj->getVar('counter') . ' ' . strtolower(XoopsLocale::READS) . ')'; } $item['more'] = ''; if ($itemObj->body() != '' || $itemObj->getVar('comments') > 0) { $item['more'] = '<a class="publisher_spotlight_readmore" href="' . $itemObj->getItemUrl() . '">' . _MB_PUBLISHER_READMORE . '</a>'; } $comments = $itemObj->getVar('comments'); if ($options[23] == 1) { if ($comments > 0) { //shows 1 comment instead of 1 comm. if comments ==1 //langugage file modified accordingly if ($comments == 1) { $item['comment'] = ' ' . _MB_PUBLISHER_ONECOMMENT . ' '; } else { $item['comment'] = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; } } else { $item['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; } } $item['print'] = ''; if ($options[24] == 1) { $item['print'] = '<a href="' . PublisherUtils::seoGenUrl("print", $itemObj->getVar('itemid'), $itemObj->getVar('short_url')) . '" rel="nofollow"><img src="' . PUBLISHER_URL . '/images/links/print.gif" title="' . _CO_PUBLISHER_PRINT . '" alt="' . _CO_PUBLISHER_PRINT . '" /></a> '; } $item['pdf'] = ''; if ($options[25] == 1) { $item['pdf'] = "<a href='" . PUBLISHER_URL . "/makepdf.php?itemid=" . $itemObj->getVar('itemid') . "' rel='nofollow'><img src='" . PUBLISHER_URL . "/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a> "; } $item['email'] = ''; if ($options[26] == 1 && $xoops->isActiveModule('tellafriend')) { $subject = sprintf(_CO_PUBLISHER_INTITEMFOUND, $xoops->getConfig('sitename')); $subject = $itemObj->_convert_for_japanese($subject); $maillink = PublisherUtils::tellafriend($subject); $item['email'] = '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a> '; } $block['morelink'] = ''; if ($options[27] == 1) { $block['morelink'] = '<a href="' . PUBLISHER_URL . '/index.php">' . _MB_PUBLISHER_MORE_ITEMS . '</a> '; } $block['latestnews_scroll'] = false; if ($options[5] == 1) { $block['latestnews_scroll'] = true; } $block['scrollheight'] = $options[6]; $block['scrollspeed'] = $options[7]; $block['scrolldir'] = $options[8]; $block['template'] = $options[28]; $block['imgwidth'] = $options[11]; $block['imgheight'] = $options[12]; $block['letters'] = $letters; $columns[$k][] = $item; ++$k; if ($k == $column_count) { $k = 0; } } unset($item); $block['columns'] = $columns; return $block; }
function updateMimeValue() { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $start = $limit = 0; if (isset($_GET['limit'])) { $limit = (int) $_GET['limit']; } if (isset($_GET['start'])) { $start = (int) $_GET['start']; } if (!isset($_REQUEST['id'])) { $xoops->redirect(PUBLISHER_ADMIN_URL . "/mimetypes.php", 3, _AM_PUBLISHER_MESSAGE_NO_ID); } $mime_id = (int) $_REQUEST['id']; $mimetype = $publisher->getMimetypeHandler()->get($mime_id); if (isset($_REQUEST['mime_admin'])) { $mime_admin = (int) $_REQUEST['mime_admin']; $mime_admin = _changeMimeValue($mime_admin); $mimetype->setVar('mime_admin', $mime_admin); } if (isset($_REQUEST['mime_user'])) { $mime_user = (int) $_REQUEST['mime_user']; $mime_user = _changeMimeValue($mime_user); $mimetype->setVar('mime_user', $mime_user); } if ($publisher->getMimetypeHandler()->insert($mimetype, true)) { header("Location: " . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}"); } else { $xoops->redirect(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}", 3); } }
/** * @param Connection $db */ public function __construct(Connection $db) { parent::__construct($db, "publisher_items", 'PublisherItem', "itemid", "title"); $this->publisher = Publisher::getInstance(); }
function publisher_search_show($options) { $block = array(); $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $categories = $publisher->getCategoryHandler()->getCategoriesForSearch(); if (count($categories) == 0) { return $block; } $andor = isset($_POST["andor"]) ? $_POST["andor"] : (isset($_GET["andor"]) ? $_GET["andor"] : ""); $category = isset($_POST["category"]) ? $_POST["category"] : (isset($_GET["category"]) ? $_GET["category"] : null); $username = isset($_POST["uname"]) ? $_POST["uname"] : (isset($_GET["uname"]) ? $_GET["uname"] : null); $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array()); $sortby = isset($_POST["sortby"]) ? $_POST["sortby"] : (isset($_GET["sortby"]) ? $_GET["sortby"] : null); $term = isset($_POST["term"]) ? $_POST["term"] : (isset($_GET["term"]) ? $_GET["term"] : ""); 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 */ $type_select = "<select name=\"andor\">"; $type_select .= "<option value=\"OR\""; if ("OR" === $andor) { $type_select .= " selected=\"selected\""; } $type_select .= ">" . XoopsLocale::ANY_OR . "</option>"; $type_select .= "<option value=\"AND\""; if ("AND" === $andor) { $type_select .= " selected=\"selected\""; } $type_select .= ">" . XoopsLocale::ALL . "</option>"; $type_select .= "<option value=\"EXACT\""; if ("exact" === $andor) { $type_select .= " selected=\"selected\""; } $type_select .= ">" . XoopsLocale::EXACT_MATCH . "</option>"; $type_select .= "</select>"; /* category */ $select_category = "<select name=\"category[]\" size=\"5\" multiple=\"multiple\" width=\"150\" style=\"width:150px;\">"; $select_category .= "<option value=\"all\""; if (empty($category) || count($category) == 0) { $select_category .= "selected=\"selected\""; } $select_category .= ">" . XoopsLocale::ALL . "</option>"; foreach ($categories as $id => $cat) { $select_category .= "<option value=\"" . $id . "\""; if (in_array($id, $category)) { $select_category .= "selected=\"selected\""; } $select_category .= ">" . $cat . "</option>"; } $select_category .= "</select>"; /* scope */ $searchin_select = ""; $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\""; if (in_array("title", $searchin)) { $searchin_select .= " checked"; } $searchin_select .= " />" . _CO_PUBLISHER_TITLE . " "; $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"subtitle\""; if (in_array("subtitle", $searchin)) { $searchin_select .= " checked"; } $searchin_select .= " />" . _CO_PUBLISHER_SUBTITLE . " "; $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"summary\""; if (in_array("summary", $searchin)) { $searchin_select .= " checked"; } $searchin_select .= " />" . _CO_PUBLISHER_SUMMARY . " "; $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\""; if (in_array("body", $searchin)) { $searchin_select .= " checked"; } $searchin_select .= " />" . _CO_PUBLISHER_BODY . " "; $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"keywords\""; if (in_array("meta_keywords", $searchin)) { $searchin_select .= " checked"; } $searchin_select .= " />" . _CO_PUBLISHER_ITEM_META_KEYWORDS . " "; $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\""; if (in_array("all", $searchin) || empty($searchin)) { $searchin_select .= " checked"; } $searchin_select .= " />" . XoopsLocale::ALL . " "; /* sortby */ $sortby_select = "<select name=\"sortby\">"; $sortby_select .= "<option value=\"itemid\""; if ("itemid" === $sortby || empty($sortby)) { $sortby_select .= " selected=\"selected\""; } $sortby_select .= ">" . XoopsLocale::NONE . "</option>"; $sortby_select .= "<option value=\"datesub\""; if ("datesub" === $sortby) { $sortby_select .= " selected=\"selected\""; } $sortby_select .= ">" . _CO_PUBLISHER_DATESUB . "</option>"; $sortby_select .= "<option value=\"title\""; if ("title" === $sortby) { $sortby_select .= " selected=\"selected\""; } $sortby_select .= ">" . _CO_PUBLISHER_TITLE . "</option>"; $sortby_select .= "<option value=\"categoryid\""; if ("categoryid" === $sortby) { $sortby_select .= " selected=\"selected\""; } $sortby_select .= ">" . _CO_PUBLISHER_CATEGORY . "</option>"; $sortby_select .= "</select>"; $block["type_select"] = $type_select; $block["searchin_select"] = $searchin_select; $block["category_select"] = $select_category; $block["sortby_select"] = $sortby_select; $block["search_term"] = $term; $block["search_user"] = $username; $block["publisher_url"] = PUBLISHER_URL; return $block; }
/** * Function To Show Publisher Items From Categories In Their Own Columns * * @param array $options Block Options * * @return array|bool */ function publisher_items_columns_show($options) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $xoTheme = $xoops->theme(); //Column Settings $opt_num_columns = isset($options[0]) ? (int) $options[0] : '2'; $sel_categories = isset($options[1]) ? explode(',', $options[1]) : array(); $opt_cat_items = (int) $options[2]; $opt_cat_truncate = isset($options[3]) ? (int) $options[3] : '0'; $block = array(); $block['lang_reads'] = _MB_PUBLISHER_READS; $block['lang_comments'] = _MB_PUBLISHER_COMMENTS; $block['lang_readmore'] = _MB_PUBLISHER_READMORE; $sel_categories_obj = array(); //get permited categories only once $categories_obj = $publisher->getCategoryHandler()->getCategories(0, 0, -1); //if not selected 'all', let's get the selected ones if (!in_array(0, $sel_categories)) { foreach ($categories_obj as $key => $value) { if (in_array($key, $sel_categories)) { $sel_categories_obj[$key] = $value; } } } else { $sel_categories_obj = $categories_obj; } $ccount = count($sel_categories_obj); if ($ccount == 0) { return false; } if ($ccount < $opt_num_columns) { $opt_num_columns = $ccount; } $k = 0; $columns = array(); /* @var $mainitemCatObj PublisherCategory */ foreach ($sel_categories_obj as $categoryId => $mainitemCatObj) { $categoryItemsObj = $publisher->getItemHandler()->getAllPublished($opt_cat_items, 0, $categoryId); $scount = count($categoryItemsObj); if ($scount > 0 && is_array($categoryItemsObj)) { reset($categoryItemsObj); //First Item list($itemid, $thisitem) = each($categoryItemsObj); /* @var $thisitem PublisherItem */ $mainitem['item_title'] = $thisitem->title(); $mainitem['item_cleantitle'] = strip_tags($thisitem->title()); $mainitem['item_link'] = $thisitem->getVar('itemid'); $mainitem['itemurl'] = $thisitem->getItemUrl(); $mainImage = $thisitem->getMainImage(); $mainitem['item_image'] = $mainImage['image_path']; if (!empty($mainImage['image_path'])) { $mainitem['item_image'] = \Xoops::getInstance()->service('thumbnail')->getImgUrl($mainImage['image_vpath'], 100, 0)->getValue(); } $mainitem['item_summary'] = $thisitem->getBlockSummary($opt_cat_truncate); $mainitem['item_cat_name'] = $mainitemCatObj->getVar('name'); $mainitem['item_cat_description'] = $mainitemCatObj->getVar('description') != '' ? $mainitemCatObj->getVar('description') : $mainitemCatObj->getVar('name'); $mainitem['item_cat_link'] = $mainitemCatObj->getCategoryLink(); $mainitem['categoryurl'] = $mainitemCatObj->getCategoryUrl(); //The Rest if ($scount > 1) { while (list($itemid, $thisitem) = each($categoryItemsObj)) { $subitem['title'] = $thisitem->title(); $subitem['cleantitle'] = strip_tags($thisitem->title()); $subitem['link'] = $thisitem->getItemLink(); $subitem['itemurl'] = $thisitem->getItemUrl(); $subitem['summary'] = $thisitem->getBlockSummary($opt_cat_truncate); $mainitem['subitem'][] = $subitem; unset($subitem); } } $columns[$k][] = $mainitem; unset($thisitem); unset($mainitem); ++$k; if ($k == $opt_num_columns) { $k = 0; } } } $block['template'] = $options[4]; $block['columns'] = $columns; $block['columnwidth'] = (int) (100 / $opt_num_columns); $xoTheme->addStylesheet(\XoopsBaseConfig::get('url') . '/modules/' . PUBLISHER_DIRNAME . '/css/publisher.css'); return $block; }
private function _isGranted($item) { $publisher = Publisher::getInstance(); $ret = false; if (!$this->_checkperm || $publisher->getPermissionHandler()->isGranted('form_view', $item)) { $ret = true; } return $ret; }
function publisher_items_new_show($options) { $publisher = Publisher::getInstance(); $selectedcatids = explode(',', $options[0]); $block = array(); if (in_array(0, $selectedcatids)) { $allcats = true; } else { $allcats = false; } $sort = $options[1]; $order = PublisherUtils::getOrderBy($sort); $limit = $options[3]; $start = 0; $image = $options[5]; // creating the ITEM objects that belong to the selected category if ($allcats) { $criteria = null; } else { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN')); } $xoops = \Xoops::getInstance(); $thumbService = $xoops->service('thumbnail'); $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); $totalitems = count($itemsObj); if ($itemsObj) { for ($i = 0; $i < $totalitems; ++$i) { $item = array(); $item['link'] = $itemsObj[$i]->getItemLink(false, isset($options[4]) ? $options[4] : 65); $item['id'] = $itemsObj[$i]->getVar('itemid'); $item['poster'] = $itemsObj[$i]->posterName(); // for make poster name linked, use linkedPosterName() instead of posterName() if ($image == 'article') { $item['image'] = \XoopsBaseConfig::get('url') . '/uploads/blank.gif'; $item['image_name'] = ''; $images = $itemsObj[$i]->getImages(); if (is_object($images['main'])) { $item['image'] = $thumbService->getImgUrl('uploads/' . $images['main']->getVar('image_name'), 50, 0)->getValue(); $item['image_name'] = $images['main']->getVar('image_nicename'); } } elseif ($image == 'category') { $item['image'] = $itemsObj[$i]->getCategoryImagePath(); $item['image_name'] = $itemsObj[$i]->getCategoryName(); } elseif ($image == 'avatar') { $auid = $itemsObj[$i]->getVar('uid'); if ($auid == '0') { $item['image'] = \XoopsBaseConfig::get('url') . '/uploads/blank.gif'; $images = $itemsObj[$i]->getImages(); if (is_object($images['main'])) { $item['image'] = $thumbService->getImgUrl('uploads/' . $images['main']->getVar('image_name'), 50, 0)->getValue(); } } else { $item['image'] = $xoops->service('avatar')->getAvatarUrl($auid)->getValue(); } $item['image_name'] = $itemsObj[$i]->posterName(); } $item['title'] = $itemsObj[$i]->title(); if ($sort == "datesub") { $item['new'] = $itemsObj[$i]->datesub(); } elseif ($sort == "counter") { $item['new'] = $itemsObj[$i]->getVar('counter'); } elseif ($sort == "weight") { $item['new'] = $itemsObj[$i]->weight(); } $block['newitems'][] = $item; } } $block['show_order'] = $options[2]; return $block; }
function publisher_editCat($showmenu = false, $categoryid = 0, $nb_subcats = 4, $categoryObj = null) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); /* @var $categoryObj PublisherCategory */ // if there is a parameter, and the id exists, retrieve data: we're editing a category if ($categoryid != 0) { // Creating the category object for the selected category $categoryObj = $publisher->getCategoryHandler()->get($categoryid); if ($categoryObj->notLoaded()) { $xoops->redirect("category.php", 1, _AM_PUBLISHER_NOCOLTOEDIT); } } else { if (!$categoryObj) { $categoryObj = $publisher->getCategoryHandler()->create(); } } if ($categoryid != 0) { if ($showmenu) { //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_EDITING); } echo "<br />\n"; PublisherUtils::openCollapsableBar('edittable', 'edittableicon', _AM_PUBLISHER_EDITCOL, _AM_PUBLISHER_CATEGORY_EDIT_INFO); } else { if ($showmenu) { //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_CREATINGNEW); } PublisherUtils::openCollapsableBar('createtable', 'createtableicon', _AM_PUBLISHER_CATEGORY_CREATE, _AM_PUBLISHER_CATEGORY_CREATE_INFO); } /* @var $sform PublisherCategoryForm */ $sform = $publisher->getForm($categoryObj, 'category'); $sform->setSubCatsCount($nb_subcats); $sform->display(); if (!$categoryid) { PublisherUtils::closeCollapsableBar('createtable', 'createtableicon'); } else { PublisherUtils::closeCollapsableBar('edittable', 'edittableicon'); } //Added by fx2024 if ($categoryid) { $sel_cat = $categoryid; PublisherUtils::openCollapsableBar('subcatstable', 'subcatsicon', _AM_PUBLISHER_SUBCAT_CAT, _AM_PUBLISHER_SUBCAT_CAT_DSC); // Get the total number of sub-categories $categoriesObj = $publisher->getCategoryHandler()->get($sel_cat); $totalsubs = $publisher->getCategoryHandler()->getCategoriesCount($sel_cat); // creating the categories objects that are published $subcatsObj = $publisher->getCategoryHandler()->getCategories(0, 0, $categoriesObj->getVar('categoryid')); echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; echo "<tr>"; echo "<td width='60' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATID . "</strong></td>"; echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATCOLNAME . "</strong></td>"; echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_SUBDESCRIPT . "</strong></td>"; echo "<td width='60' class='bg3' align='right'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>"; echo "</tr>"; if ($totalsubs > 0) { /* @var $subcat PublisherCategory */ foreach ($subcatsObj as $subcat) { $modify = "<a href='category.php?op=mod&categoryid=" . $subcat->getVar('categoryid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_MODIFY . "' alt='" . _AM_PUBLISHER_MODIFY . "' /></a>"; $delete = "<a href='category.php?op=del&categoryid=" . $subcat->getVar('categoryid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETE . "' alt='" . _AM_PUBLISHER_DELETE . "' /></a>"; echo "<tr>"; echo "<td class='head' align='left'>" . $subcat->getVar('categoryid') . "</td>"; echo "<td class='even' align='left'><a href='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/category.php?categoryid=" . $subcat->getVar('categoryid') . "&parentid=" . $subcat->getVar('parentid') . "'>" . $subcat->getVar('name') . "</a></td>"; echo "<td class='even' align='left'>" . $subcat->getVar('description') . "</td>"; echo "<td class='even' align='right'> {$modify} {$delete} </td>"; echo "</tr>"; } } else { echo "<tr>"; echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOSUBCAT . "</td>"; echo "</tr>"; } echo "</table>\n"; echo "<br />\n"; PublisherUtils::closeCollapsableBar('subcatstable', 'subcatsicon'); PublisherUtils::openCollapsableBar('bottomtable', 'bottomtableicon', _AM_PUBLISHER_CAT_ITEMS, _AM_PUBLISHER_CAT_ITEMS_DSC); $startitem = Request::getInt('startitem'); // Get the total number of published ITEMS $totalitems = $publisher->getItemHandler()->getItemsCount($sel_cat, array(_PUBLISHER_STATUS_PUBLISHED)); // creating the items objects that are published $itemsObj = $publisher->getItemHandler()->getAllPublished($publisher->getConfig('idxcat_perpage'), $startitem, $sel_cat); $totalitemsOnPage = count($itemsObj); $allcats = $publisher->getCategoryHandler()->getObjects(null, true); echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; echo "<tr>"; echo "<td width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . "</strong></td>"; echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCOLNAME . "</strong></td>"; echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMDESC . "</strong></td>"; echo "<td width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . "</strong></td>"; echo "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>"; echo "</tr>"; if ($totalitems > 0) { for ($i = 0; $i < $totalitemsOnPage; ++$i) { $categoryObj = $allcats[$itemsObj[$i]->getVar('categoryid')]; $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITITEM . "' alt='" . _AM_PUBLISHER_EDITITEM . "' /></a>"; $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid') . "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'/></a>"; echo "<tr>"; echo "<td class='head' align='center'>" . $itemsObj[$i]->getVar('itemid') . "</td>"; echo "<td class='even' align='left'>" . $categoryObj->getVar('name') . "</td>"; echo "<td class='even' align='left'>" . $itemsObj[$i]->getitemLink() . "</td>"; echo "<td class='even' align='center'>" . $itemsObj[$i]->datesub('s') . "</td>"; echo "<td class='even' align='center'> {$modify} {$delete} </td>"; echo "</tr>"; } } else { echo "<tr>"; echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS . "</td>"; echo "</tr>"; } echo "</table>\n"; echo "<br />\n"; $parentid = Request::getInt('parentid'); $pagenav_extra_args = "op=mod&categoryid={$sel_cat}&parentid={$parentid}"; $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $startitem, 'startitem', $pagenav_extra_args); echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'; echo "<input type='button' name='button' onclick=\"location='item.php?op=mod&categoryid=" . $sel_cat . "'\" value='" . _AM_PUBLISHER_CREATEITEM . "'> "; echo "</div>"; } //end of fx2024 code }
/** * constructor */ public function __construct() { $this->publisher = Publisher::getInstance(); $this->db2 = \Xoops::getInstance()->db(); }
/** * @param Xoops\Core\Database\Connection $db */ public function __construct(Connection $db) { $this->publisher = Publisher::getInstance(); parent::__construct($db, "publisher_categories", 'PublisherCategory', "categoryid", "name"); }