本文整理汇总了PHP中Publisher类的典型用法代码示例。如果您正苦于以下问题:PHP Publisher类的具体用法?PHP Publisher怎么用?PHP Publisher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Publisher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToStringUsesDefaultStringFormat
public function testToStringUsesDefaultStringFormat()
{
$author = new Author();
$author->setFirstName('John');
$author->setLastName('Doe');
$expected = <<<EOF
Id: null
FirstName: John
LastName: Doe
Email: null
Age: null
EOF;
$this->assertEquals($expected, (string) $author, 'generated __toString() uses default string format and exportTo()');
$publisher = new Publisher();
$publisher->setId(345345);
$publisher->setName('Peguinoo');
$expected = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Id>345345</Id>
<Name><![CDATA[Peguinoo]]></Name>
</data>
EOF;
$this->assertEquals($expected, (string) $publisher, 'generated __toString() uses default string format and exportTo()');
}
示例2: post_to_endpoints
public function post_to_endpoints(Post $post)
{
$feeds = array(URL::get('atom_feed'));
foreach (Options::get('pubsubhubbub__endpoints') as $endpoint) {
$p = new Publisher($endpoint);
$p->publish_update($feeds);
}
}
示例3: testDetachUnattached
/**
* @covers Panadas\Event\Publisher::detach()
* @covers Panadas\Event\Publisher::unsubscribe()
*/
public function testDetachUnattached()
{
$publisher = new Publisher();
$subscriber = new FooBarSubscriber();
$publisher->detach($subscriber);
$events = $publisher->getEvents();
$this->assertFalse($events->has("foo"));
$this->assertFalse($events->has("bar"));
}
示例4: pubsub_post
function pubsub_post()
{
require_once mnminclude . 'pubsubhubbub/publisher.php';
global $globals;
if (!$globals['pubsub']) {
return false;
}
$rss = 'http://' . get_server_name() . $globals['base_url'] . 'rss2.php';
$p = new Publisher($globals['pubsub']);
if ($p->publish_update($rss)) {
syslog(LOG_NOTICE, "Meneame: posted to pubsub ({$rss})");
} else {
syslog(LOG_NOTICE, "Meneame: failed to post to pubsub ({$rss})");
}
}
示例5: 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;
}
示例6: 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;
}
示例7: action
private function action($form)
{
$session = session_currentSession();
$p = new Publisher();
$p->user = $session->id;
$p->label = $form->name;
$p->short_label = $form->shortname;
$p->key = $this->generateKey();
$p->secret = $this->generateSecret();
$p->domain = $form->domain;
// ISO-8601 2005-08-14T16:13:03+0000;
$time = time() + $value;
$p->created = date('c', $time);
$p->save();
header('location:/account/settings');
}
示例8: 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;
}
示例9: editTemplate
/**
*
* @url GET /editTemplate
*/
public function editTemplate($params)
{
// Action Validations
if (!isset($_REQUEST['TEMPLATE'])) {
$_REQUEST['TEMPLATE'] = '';
}
if ($_REQUEST['TEMPLATE'] == '') {
throw new Exception('The TEMPLATE parameter is empty.');
}
$data = array('CONTENT' => file_get_contents(PATH_DATA_MAILTEMPLATES . $_REQUEST['PRO_UID'] . PATH_SEP . $_REQUEST['TEMPLATE']), 'TEMPLATE' => $_REQUEST['TEMPLATE']);
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'actionsByEmail/actionsByEmail_FileEdit', '', $data);
G::RenderPage('publish', 'raw');
die;
}
示例10: 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;
}
}
示例11: 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;
}
示例12: Add
public function Add($params)
{
//print_r($_SESSION['user']);
if (user_admin()) {
$this->view->Show('book_add.tpl', array('books' => Book::Find($this->conn, $params['pubId'], $params['catId']), 'pubs' => array(-1 => '- Все -') + Publisher::GetAll($this->conn), 'pubId' => $params['pubId'], 'cats' => array(-1 => '- Все -') + Category::GetAll($this->conn), 'catId' => $params['catId']));
} else {
$this->view->Show('access_denied.tpl', array('mode' => 'Добавление книги'));
}
}
示例13: getListPublishers
public static function getListPublishers()
{
$models = Publisher::model()->findAll();
$list = array();
foreach ($models as $key => $model) {
$list[$model->id] = $model->name;
}
return $list;
}
示例14: setUp
protected function setUp()
{
parent::setUp();
$publisher = new Publisher();
$publisher->setId(1234);
$publisher->setName('Penguin');
$author = new Author();
$author->setId(5678);
$author->setFirstName('George');
$author->setLastName('Byron');
$book = new Book();
$book->setId(9012);
$book->setTitle('Don Juan');
$book->setISBN('0140422161');
$book->setPrice(12.99);
$book->setAuthor($author);
$book->setPublisher($publisher);
$this->book = $book;
}
示例15: publish_to_hub
function publish_to_hub($post_id)
{
// we want to notify the hub for every feed
$feed_urls = array();
$feed_urls[] = get_bloginfo('atom_url');
$feed_urls[] = get_bloginfo('rss_url');
$feed_urls[] = get_bloginfo('rdf_url');
$feed_urls[] = get_bloginfo('rss2_url');
// remove dups (ie. they all point to feedburner)
$feed_urls = array_unique($feed_urls);
// get the address of the publish endpoint on the hub
$hub_url = get_pubsub_endpoint();
$p = new Publisher($hub_url);
// need better error handling
if (!$p->publish_update($feed_urls, "http_post_wp")) {
print_r($p->last_response());
}
return $post_id;
}