예제 #1
0
    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
0
 /**
  * @param bool $onReady whether or not JS class should be instantiated after page is ready
  */
 public function instantiateJSClass($onReady = true)
 {
     parent::instantiateJSClass($onReady);
     if (isset($this->publisher)) {
         Yii::app()->clientScript->registerScript($this->namespace . get_class($this) . 'AddTabJS', ($onReady ? "\$(function () {" : "") . $this->publisher->getJSObjectName() . ".addTab (" . $this->getJSObjectName() . ");" . ($onReady ? "});" : ""), CClientScript::POS_END);
     }
 }
 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);
     }
 }
예제 #4
0
 /**
  * @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"));
 }
예제 #5
0
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})");
    }
}
예제 #6
0
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;
}
예제 #7
0
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;
}
예제 #8
0
 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');
 }
예제 #9
0
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;
}
예제 #10
0
 /**
  * 
  * @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;
 }
예제 #11
0
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;
    }
}
예제 #12
0
 /**
  * Delete all permission for a specific item
  *  deletePermissions()
  *
  * @param integer $itemid     id of the item for which to delete the permissions
  * @param string  $gperm_name permission name
  *
  * @return boolean : TRUE if the no errors occured
  */
 public function deletePermissions($itemid, $gperm_name)
 {
     $xoops = Xoops::getInstance();
     $result = true;
     $gperm_handler = $xoops->getHandlerGroupperm();
     $gperm_handler->deleteByModule($this->publisher->getModule()->getVar('mid'), $gperm_name, $itemid);
     return $result;
 }
예제 #13
0
/**
 * @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 = "&amp;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, '&amp;') : $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;
}
예제 #14
0
 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' => 'Добавление книги'));
     }
 }
예제 #15
0
 public static function getListPublishers()
 {
     $models = Publisher::model()->findAll();
     $list = array();
     foreach ($models as $key => $model) {
         $list[$model->id] = $model->name;
     }
     return $list;
 }
 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;
 }
예제 #17
0
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;
}
예제 #18
0
 public function afterSave($event)
 {
     if (!$this->Owner->isNewRecord) {
         $newAttrs = $this->Owner->getAttributes();
         $oldAttrs = $this->getOldAttributes();
         $isUpdated = false;
         foreach ($newAttrs as $key => $value) {
             if (!empty($oldAttrs)) {
                 if ($oldAttrs[$key] != $value) {
                     $isUpdated = true;
                 }
             }
         }
         if ($isUpdated) {
             if ($oldAttrs['publisher_id'] != $newAttrs['publisher_id']) {
                 # add a log when dataset publisher is updated
                 $publisher = Publisher::model()->findByPk($oldAttrs['publisher_id']);
                 if ($publisher) {
                     $this->createLog($this->Owner->id, 'Publisher name updated from : ' . $publisher->name);
                 }
             }
             if ($oldAttrs['submitter_id'] != $newAttrs['submitter_id']) {
                 $submitter = User::model()->findByPk($oldAttrs['submitter_id']);
                 if ($submitter) {
                     $this->createLog($this->Owner->id, 'Submitter updated from : ' . $submitter->first_name . ' ' . $submitter->last_name);
                 }
             }
             if ($oldAttrs['image_id'] != $newAttrs['image_id']) {
                 # add a log when dataset image is updated
                 $this->createLog($this->Owner->id, 'Update image');
             }
             if ($oldAttrs['upload_status'] != 'Published' and $newAttrs['upload_status'] == 'Published') {
                 # add a log when dataset is published
                 $this->createLog($this->Owner->id, 'Dataset publish');
             }
             if (preg_replace('/\\s+/', ' ', trim($oldAttrs['description'])) != preg_replace('/\\s+/', ' ', trim($newAttrs['description']))) {
                 $this->createLog($this->Owner->id, 'Description updated from : ' . $oldAttrs['description']);
             }
             if ($oldAttrs['title'] != $newAttrs['title']) {
                 $this->createLog($this->Owner->id, 'Title updated from : ' . $oldAttrs['title']);
             }
             if ($oldAttrs['dataset_size'] != $newAttrs['dataset_size']) {
                 $this->createLog($this->Owner->id, 'Dataset size updated from : ' . $oldAttrs['dataset_size'] . ' bytes');
             }
             if ($oldAttrs['modification_date'] != $newAttrs['modification_date']) {
                 $this->createLog($this->Owner->id, 'Modification date added : ' . $this->Owner->modification_date);
             }
             if ($oldAttrs['fairnuse'] != $newAttrs['fairnuse']) {
                 $this->createLog($this->Owner->id, 'Fair Use date added : ' . $this->Owner->fairnuse);
             }
         }
     } else {
         $this->createLog($this->Owner->id, 'Dataset Created');
     }
 }
예제 #19
0
 function __construct($query, $request_type = 'issn', $sr_api_key = '')
 {
     $query_string = 'versions=all&' . $request_type . '=' . urlencode($query);
     if ($sr_api_key) {
         $query_string .= '&ak=' . $sr_api_key;
     }
     $client = new Zend_HTTP_Client();
     $client->setUri('http://www.sherpa.ac.uk/romeo/api29.php?' . $query_string);
     $response = $client->request();
     if ($response->getStatus() == 200) {
         $sr = $response->getBody();
         $sr_xml = new DOMDocument();
         $sr_xml->loadXML($sr);
         $this->num_hits = $sr_xml->getElementsByTagName('numhits')->item(0)->nodeValue;
         $this->issn = $sr_xml->getElementsByTagName('issn')->item(0)->nodeValue;
         $this->jtitle = $sr_xml->getElementsByTagName('jtitle')->item(0)->nodeValue;
         $pubs = $sr_xml->getElementsByTagName('publisher');
         for ($i = 0; $i < $pubs->length; $i++) {
             $id = $pubs->item($i)->getAttribute('id');
             $name = $pubs->item($i)->getElementsByTagName('name')->item(0)->nodeValue;
             $p = new Publisher($id, $name);
             $p->setPrearchiving($pubs->item($i)->getElementsByTagName('prearchiving')->item(0)->nodeValue);
             $p->setPostarchiving($pubs->item($i)->getElementsByTagName('postarchiving')->item(0)->nodeValue);
             $p->setPdfarchiving($pubs->item($i)->getElementsByTagName('pdfarchiving')->item(0)->nodeValue);
             $prerestrictions_xml = $pubs->item($i)->getElementsByTagName('prerestriction');
             $prerestrictions = array();
             for ($j = 0; $j < $prerestrictions_xml->length; $j++) {
                 $prerestrictions[] = strip_tags(trim($prerestrictions_xml->item($j)->nodeValue));
             }
             $p->setPrerestrictions($prerestrictions);
             $postrestrictions_xml = $pubs->item($i)->getElementsByTagName('postrestriction');
             $postrestrictions = array();
             for ($j = 0; $j < $postrestrictions_xml->length; $j++) {
                 $postrestrictions[] = strip_tags(trim($postrestrictions_xml->item($j)->textContent));
             }
             $p->setPostrestrictions($postrestrictions);
             $pdfrestrictions_xml = $pubs->item($i)->getElementsByTagName('pdfrestriction');
             $pdfrestrictions = array();
             for ($j = 0; $j < $pdfrestrictions_xml->length; $j++) {
                 $pdfrestrictions[] = strip_tags(trim($pdfrestrictions_xml->item($j)->nodeValue));
             }
             $p->setPdfrestrictions($pdfrestrictions);
             $conditions_xml = $pubs->item($i)->getElementsByTagName('condition');
             $conditions = array();
             for ($j = 0; $j < $conditions_xml->length; $j++) {
                 $conditions[] = $conditions_xml->item($j)->nodeValue;
             }
             $p->setConditions($conditions);
             $this->publishers[$id] = $p;
         }
     }
 }
예제 #20
0
 /**
  * @return string
  */
 public function createMetaKeywords()
 {
     $keywords = $this->findMetaKeywords($this->_original_title . " " . $this->_description, $this->_minChar);
     $moduleKeywords = $this->publisher->getConfig('seo_meta_keywords');
     if ($moduleKeywords != '') {
         $moduleKeywords = explode(",", $moduleKeywords);
         $keywords = array_merge($keywords, array_map('trim', $moduleKeywords));
     }
     $ret = implode(',', $keywords);
     return $ret;
 }
예제 #21
0
 /**
  * Edit a publisher.
  */
 public function actionEdit($id = 0)
 {
     if ($id > 0) {
         $model = Publisher::model()->findByPk($id);
     } else {
         $model = new Publisher();
     }
     if (isset($_POST['Publisher'])) {
         $model->attributes = $_POST['Publisher'];
         if ($model->validate() && $model->save()) {
             Yii::app()->user->setFlash('successmsg', 'The changes have been saved.');
             $this->redirect('/publisher/index');
         } else {
             Yii::app()->user->setFlash('errormsg', 'Error saving the publisher page.');
             $this->render('edit', array('model' => $model, 'id' => $id));
         }
     } else {
         $this->render('edit', array('model' => $model, 'id' => $id));
     }
 }
 public function testUtf8()
 {
     $db = Propel::getDB(BookPeer::DATABASE_NAME);
     $title = "Смерть на брудершафт. Младенец и черт";
     //        1234567890123456789012345678901234567
     //                 1         2         3
     $a = new Author();
     $a->setFirstName("Б.");
     $a->setLastName("АКУНИН");
     $p = new Publisher();
     $p->setName("Детектив российский, остросюжетная проза");
     $b = new Book();
     $b->setTitle($title);
     $b->setISBN("B-59246");
     $b->setAuthor($a);
     $b->setPublisher($p);
     $b->save();
     $b->reload();
     $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title.");
     $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title.");
 }
예제 #23
0
 public function Index($params)
 {
     $this->view->Show('books.tpl', array('books' => Book::Find($this->conn, $params['pubId'], $params['catId'], $params['authId']), 'pubs' => array(-1 => '- Все -') + Publisher::GetAll($this->conn), 'pubId' => $params['pubId'], 'cats' => array(-1 => '- Все -') + Category::GetAll($this->conn), 'catId' => $params['catId'], 'auth' => array(-1 => '- Все -') + Author::GetAll($this->conn), 'authId' => $params['authId']));
     //        $this->smarty->assign('books', Book::Find($this->conn, $params['pubId'], $params['catId']));
     //
     //        $this->smarty->assign('pubs', array(-1 => '- Все -') + Publisher::GetAll($this->conn));
     //        $this->smarty->assign('pubId', $params['pubId']);
     //
     //        $this->smarty->assign('cats', array(-1 => '- Все -') + Category::GetAll($this->conn));
     //        $this->smarty->assign('catId', $params['catId']);
     //
     //        $this->smarty->display('books.tpl');
 }
예제 #24
0
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 list of hubs
    $hub_urls = get_pubsub_endpoints();
    // loop through each hub
    foreach ($hub_urls as $hub_url) {
        $p = new Publisher($hub_url);
        // publish the update to each hub
        if (!$p->publish_update($feed_urls, "http_post_wp")) {
            // TODO: add better error handling here
        }
    }
    return $post_id;
}
예제 #25
0
 /**
  * @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;
 }
예제 #26
0
파일: file.php 프로젝트: ming-hai/XoopsCore
 /**
  * @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);
 }
예제 #27
0
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;
}
예제 #28
0
 /**
  * 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;
 }
예제 #29
0
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;
}
예제 #30
0
파일: file.php 프로젝트: ming-hai/XoopsCore
 /**
  * @param null|array $allowed_mimetypes
  * @param bool       $force
  * @param bool       $doupload
  *
  * @return bool
  */
 public function store($allowed_mimetypes = null, $force = true, $doupload = true)
 {
     if ($this->isNew()) {
         $errors = array();
         if ($doupload) {
             $ret = $this->storeUpload('item_upload_file', $allowed_mimetypes, $errors);
         } else {
             $ret = true;
         }
         if (!$ret) {
             foreach ($errors as $error) {
                 $this->setErrors($error);
             }
             return false;
         }
     }
     return $this->publisher->getFileHandler()->insert($this, $force);
 }