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


PHP DiscussHelper::setMeta方法代码示例

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


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

示例1: display

 function display($tpl = null)
 {
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     if (!$config->get('main_favorite')) {
         DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_FEATURE_IS_DISABLED'), DISCUSS_QUEUE_ERROR);
         $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss', false));
         $app->close();
     }
     DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_FAVOURITES_TITLE'));
     // @task: Add view
     $this->logView();
     DiscussHelper::setMeta();
     $postModel = DiscussHelper::getModel('Posts');
     $posts = $postModel->getData(true, 'latest', null, 'favourites');
     $posts = DiscussHelper::formatPost($posts);
     $theme = new DiscussThemes();
     $theme->set('posts', $posts);
     echo $theme->fetch('favourites.php');
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:20,代码来源:view.html.php

示例2: listings

 /**
  * Displays a list of recent discussions from a particular category.
  *
  * @since	3.0
  * @access	public
  */
 public function listings()
 {
     // Initialise variables
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     $registry = DiscussHelper::getRegistry();
     $categoryId = JRequest::getInt('category_id', 0);
     // Try to detect if there's any category id being set in the menu parameter.
     $activeMenu = $app->getMenu()->getActive();
     if ($activeMenu) {
         // Load menu params to the registry.
         $registry->loadString($activeMenu->params);
         // Set the active category id if exists.
         $categoryId = $registry->get('category_id') ? $registry->get('category_id') : $categoryId;
     }
     // Get the current logged in user's access.
     $acl = DiscussHelper::getHelper('ACL');
     // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort
     $activeFilter = JRequest::getString('filter', $registry->get('filter'));
     $sort = JRequest::getString('sort', $registry->get('sort'));
     // Get the pagination limit
     $limit = $registry->get('limit');
     $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit;
     $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit;
     // Get the active category id if there is any
     $activeCategory = DiscussHelper::getTable('Category');
     $activeCategory->load($categoryId);
     DiscussHelper::setPageTitle($activeCategory->title);
     // Add breadcrumbs for active category.
     if ($activeCategory->id != 0) {
         // Test if user is really allowed to access this category.
         if (!$activeCategory->canAccess()) {
             $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
             $app->close();
             return;
         }
         // Add pathway for category here.
         DiscussHelper::getHelper('Pathway')->setCategoryPathway($activeCategory);
     }
     // Add view to this page.
     $this->logView();
     // Set the meta of the page.
     DiscussHelper::setMeta();
     $doc = JFactory::getDocument();
     $doc->setMetadata('description', strip_tags($activeCategory->getDescription()));
     // Add rss feed into headers
     DiscussHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easydiscuss&view=index');
     // Get list of categories on the site.
     $catModel = $this->getModel('Categories');
     // Pagination is by default disabled.
     $pagination = false;
     if ($categoryId) {
         $category = DiscussHelper::getTable('Category');
         $category->load($categoryId);
         $categories[] = $category;
     } else {
         $categories = $catModel->getCategories($categoryId);
         if (count($categories) > 1) {
             $ids = array();
             foreach ($categories as $row) {
                 $ids[] = $row->id;
             }
             // iniCounts should only called in index page.
             $category = DiscussHelper::getTable('Category');
             $category->initCounts($ids, true);
         }
     }
     // Get the model.
     $postModel = DiscussHelper::getModel('Posts');
     $authorIds = array();
     $topicIds = array();
     for ($i = 0; $i < count($categories); $i++) {
         $category =& $categories[$i];
         // building category childs lickage.
         $category->childs = null;
         $nestedLinks = '';
         // In category page
         if ($config->get('layout_show_all_subcategories', '1')) {
             // By default show all the subcategories of the selected category
             DiscussHelper::buildNestedCategories($category->id, $category, false, true);
         } else {
             // Show one level of subcategories of the selected category only
             $category->childs = $catModel->getChildCategories($category->id);
         }
         DiscussHelper::accessNestedCategories($category, $nestedLinks, '0', '', 'listlink', ', ');
         $category->nestedLink = $nestedLinks;
         // Get featured posts from this particular category.
         $featured = $postModel->getDiscussions(array('pagination' => false, 'sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true));
         // Get normal discussion posts.
         $posts = $postModel->getDiscussions(array('sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $limit, 'featured' => false));
         $tmpPostsArr = array_merge($featured, $posts);
         if (count($tmpPostsArr) > 0) {
//.........这里部分代码省略.........
开发者ID:pguilford,项目名称:vcomcc,代码行数:101,代码来源:view.html.php

示例3: tags

 function tags($tmpl = null)
 {
     //initialise variables
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $tags = JRequest::getVar('ids');
     if (is_null($tags) || $tags == '') {
         $mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_INVALID_TAG'), 'error');
         $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index'));
     }
     $tags = explode('+', $tags);
     if (count($tags) < 2) {
         $tags = explode(' ', $tags[0]);
     }
     $dirtyTags = $tags;
     unset($tags);
     $tags = array();
     foreach ($dirtyTags as $dirtyTag) {
         $dirtyTag = (int) $dirtyTag;
         if (!empty($dirtyTag)) {
             $tags[] = $dirtyTag;
         }
     }
     if (empty($tags)) {
         $mainframe->enqueueMessage(JText::_('COM_EASYDISCUSS_INVALID_TAG'), 'error');
         $mainframe->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index'));
     }
     $this->setPathway(JText::_('COM_EASYDISCUSS_TAGS'), DiscussRouter::_('index.php?option=com_easydiscuss&view=tags'));
     DiscussHelper::setMeta();
     $tagNames = array();
     foreach ($tags as $tag) {
         $table = DiscussHelper::getTable('Tags');
         $table->load($tag);
         $tagNames[] = JText::_($table->title);
     }
     $this->setPathway(implode(' + ', $tagNames));
     $tagIDs = implode('+', $tags);
     $concatCode = DiscussHelper::getJConfig()->getValue('sef') ? '?' : '&';
     $document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=tags&ids=' . $tagIDs) . $concatCode . 'format=feed&type=rss', 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
     $document->addHeadLink(JRoute::_('index.php?option=com_easydiscuss&view=tags&ids=' . $tagIDs) . $concatCode . 'format=feed&type=atom', 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
     $filteractive = JRequest::getString('filter', 'allposts');
     $sort = JRequest::getString('sort', 'latest');
     if ($filteractive == 'unanswered' && ($sort == 'active' || $sort == 'popular')) {
         //reset the active to latest.
         $sort = 'latest';
     }
     $postModel = $this->getModel('Posts');
     $posts = $postModel->getTaggedPost($tags, $sort, $filteractive);
     $pagination = $postModel->getPagination($sort, $filteractive);
     $posts = DiscussHelper::formatPost($posts);
     $tagModel = $this->getModel('Tags');
     $currentTag = $tagModel->getTagNames($tags);
     $tpl = new DiscussThemes();
     $tpl->set('rssLink', JRoute::_('index.php?option=com_easydiscuss&view=tags&id=' . $tag . '&format=feed'));
     $tpl->set('posts', $posts);
     $tpl->set('paginationType', DISCUSS_TAGS_TYPE);
     $tpl->set('pagination', $pagination);
     $tpl->set('sort', $sort);
     $tpl->set('filter', $filteractive);
     $tpl->set('showEmailSubscribe', true);
     $tpl->set('currentTag', $currentTag);
     $tpl->set('parent_id', 0);
     $tpl->set('config', $config);
     echo $tpl->fetch('tag.php');
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:67,代码来源:view.html.php

示例4: display

 public function display($tmpl = null)
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $category = JRequest::getInt('category_id', 0);
     // Add breadcrumbs
     $this->setPathway(JText::_('COM_EASYDISCUSS_SEARCH'));
     DiscussHelper::setPageTitle();
     // Set the meta of the page.
     DiscussHelper::setMeta();
     $query = JRequest::getString('query', '');
     $limitstart = null;
     $posts = null;
     $pagination = null;
     if (!empty($query)) {
         $searchModel = DiscussHelper::getModel('Search');
         $posts = $searchModel->getData(true, 'latest', null, 'allposts', $category);
         $pagination = $searchModel->getPagination(0, 'latest', 'allposts', $category);
         $posts = DiscussHelper::formatPost($posts, true);
         $badgesTable = DiscussHelper::getTable('Profile');
         if (count($posts) > 0) {
             $searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $query);
             $searchwords = preg_split("/\\s+/u", $searchworda);
             $needle = $searchwords[0];
             $searchwords = array_unique($searchwords);
             for ($i = 0; $i < count($posts); $i++) {
                 $row =& $posts[$i];
                 if (!$row->isProtected()) {
                     if ($config->get('layout_editor') != 'bbcode') {
                         $introtext = strip_tags($row->content);
                         $introtext = preg_replace('/\\s+/', ' ', $introtext);
                     } else {
                         $introtext = preg_replace('/\\s+/', ' ', strip_tags(DiscussHelper::parseContent($row->content)));
                         // clean it to 1 liner
                     }
                     $pos = strpos($introtext, $needle);
                     if ($pos !== false) {
                         $text = '...';
                         $startpos = $pos - 10 >= 0 ? $pos - 10 : 0;
                         //$endpos     = ( $pos - 10 ) >= 0 ? 10 : JString::strlen($needle) + 1;
                         $endpos = $pos - 10 >= 0 ? 10 : $pos - $startpos;
                         $front = JString::substr($introtext, $startpos, $endpos);
                         if (JString::strlen($introtext) > $endpos) {
                             $endpos = $pos + JString::strlen($needle);
                             $end = JString::substr($introtext, $endpos, 10);
                             if (JString::strlen($front) > 0) {
                                 $text = $text . $front;
                             }
                             $text = $text . $needle;
                             if (JString::strlen($end) > 0) {
                                 $text = $text . $end . '...';
                             }
                         } else {
                             $text = $front;
                         }
                         $introtext = $text;
                     }
                 } else {
                     //password protected content.
                     $introtext = $row->content;
                     // when come to here, the content is already contain the password input form ( via formatPost function.)
                 }
                 //$introtext	= JString::substr($introtext, 0, $config->get( 'layout_introtextlength' ));
                 $searchRegex = '#(';
                 $x = 0;
                 foreach ($searchwords as $k => $hlword) {
                     $searchRegex .= $x == 0 ? '' : '|';
                     $searchRegex .= preg_quote($hlword, '#');
                     $x++;
                 }
                 $searchRegex .= '(?!(?>[^<]*(?:<(?!/?a\\b)[^<]*)*)</a>))#iu';
                 $row->title = preg_replace($searchRegex, '<span class="highlight">\\0</span>', $row->title);
                 $row->introtext = $row->isProtected() ? $introtext : preg_replace($searchRegex, '<span class="highlight">\\0</span>', $introtext);
                 //display password input form.
                 if ($row->isProtected()) {
                     $row->content = $row->content;
                     // when come to here, the content is already contain the password input form ( via formatPost function.)
                 } else {
                     $row->content = preg_replace($searchRegex, '<span class="highlight">\\0</span>', $introtext);
                 }
                 $badgesTable->load($row->user->id);
                 $row->badges = $badgesTable->getBadges();
             }
         }
     }
     $tpl = new DiscussThemes();
     $tpl->set('query', $query);
     $tpl->set('posts', $posts);
     $tpl->set('paginationType', DISCUSS_SEARCH_TYPE);
     $tpl->set('pagination', $pagination);
     $tpl->set('parent_id', $query);
     echo $tpl->fetch('search.php');
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:95,代码来源:view.html.php


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