当前位置: 首页>>代码示例>>PHP>>正文


PHP Editor::setContentUrl方法代码示例

本文整理汇总了PHP中Editor::setContentUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Editor::setContentUrl方法的具体用法?PHP Editor::setContentUrl怎么用?PHP Editor::setContentUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Editor的用法示例。


在下文中一共展示了Editor::setContentUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayArticles

 /**
  * Displays published articles for a given category (if any)
  *
  * @param string $category
  * @param bool $catSelector	Toggles the category selector
  * @return string
  */
 protected function displayArticles($category = false, $catSelector = true)
 {
     $this->setOutputType(self::_OT_CONTENT_INDEX);
     if (empty($category)) {
         $this->setTitle(t('Latest articles'));
         $categories = $this->_model()->getAllCategories();
         $cid = null;
     } else {
         /**
          * Attempt to get the single article category details, and check permission
          */
         try {
             $category = $this->_model()->getCategory($category, false);
             $this->setTitle($category['title']);
             $categories = array($category['id'] => $category);
             $cid = $category['id'];
             $resource = 'article-cat-' . $category['id'];
             if (!$this->_acl->resourceExists($resource) || !$this->_acl->check($resource)) {
                 throw new Module_NoPermission();
             }
         } catch (Article_CatNoExist $e) {
             throw new Module_ControllerNoExist();
         }
     }
     /**
      * Check how many to display per page, and what page we are on
      */
     try {
         $perPage = abs($this->_config->get('article/per_page'));
     } catch (Input_KeyNoExist $e) {
         $perPage = 12;
     }
     if ($this->inSector('SC') && $this->_input->has('get', 'page')) {
         $curPage = abs($this->_input->get('page') - 1);
     } else {
         $curPage = 0;
     }
     // Get the required articles and parse their first article part body
     $maxDisplayAge = $this->_config->get('article/max_display_age');
     $articles = array();
     foreach ($this->_model()->getAllArticles($perPage, $curPage * $perPage, $cid, false, $maxDisplayAge) as $tmpArticle) {
         if (isset($categories[$tmpArticle['cat_id']])) {
             $parts = $this->_model()->getArticleParts($tmpArticle['id']);
             $firstPart = current($parts);
             $editor = new Editor($firstPart['body']);
             $editor->setContentUrl($this->_router->makeUrl('article', 'view', $tmpArticle['identifier']));
             $tmpArticle['body'] = $editor->parse(true);
             $tmpArticle['category_title'] = $categories[$tmpArticle['cat_id']]['title'];
             $tmpArticle['category_identifier'] = $categories[$tmpArticle['cat_id']]['identifier'];
             $articles[] = $tmpArticle;
         }
     }
     $articleCount = $this->_model()->getCount();
     if ($articleCount > 0) {
         $pagination = new Pagination($articleCount, $perPage);
     }
     // Build up the view
     $view = $this->loadView('index/latest.html');
     $view->assign(array('META_FORMAT' => $this->getMetaFormat($this->_config->get('article/meta_format')), 'CAT_DETAILS' => $cid ? $category : null));
     $view->assignHtml(array('ARTICLES' => $articles, 'PAGINATION' => isset($pagination) ? $pagination->build() : null));
     if ($cid == false && $catSelector) {
         /** Prepend the category selector */
         $catSelectorView = $this->loadView('index/category_selector.html');
         $catSelectorView->assign(array('CATEGORIES' => $categories));
         return $catSelectorView->getOutput() . $view->getOutput(true);
     } else {
         return $view->getOutput(true);
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:76,代码来源:index.php

示例2: prepareDescription

 /**
  * Prepares a description by cutting it down to a max length, removing
  * possible shebang (from editor) and other small jazzy things
  *
  * @param string $str
  * @param string $link
  * @return string
  */
 protected function prepareDescription($str, $link)
 {
     $editor = new Editor($str);
     $editor->preParse();
     $editor->setContentUrl($link);
     return $editor->parse(true);
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:15,代码来源:Rss.php


注:本文中的Editor::setContentUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。