本文整理汇总了PHP中Publisher::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::getInstance方法的具体用法?PHP Publisher::getInstance怎么用?PHP Publisher::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publisher_pagewrap_upload
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;
}
}
示例2: publisher_latest_files_show
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;
}
示例3: publisher_date_to_date_show
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;
}
示例4: publisher_items_menu_show
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;
}
示例5: publisher_search
/**
* @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 <lusopoemas@gmail.com>
* @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;
}
示例6: __construct
/**
* @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);
}
示例7: waiting
/**
* @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;
}
示例8: __construct
/**
* @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);
}
示例9: publisher_items_random_item_show
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;
}
示例10: subMenus
/**
* 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;
}
示例11: publisher_items_recent_show
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;
}
示例12: searchAdvanced
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;
}
示例13: publisher_category_items_sel_show
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;
}
示例14: __construct
/**
* @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']);
}
}
}
示例15: publisher_editFile
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');
}
}