コード例 #1
0
ファイル: view.html.php プロジェクト: RuDers/JoomlaSQL
 /**
  * Display the view
  *
  * @return	mixed	False on error, null otherwise.
  */
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $state = $this->get('State');
     $items = $this->get('Items');
     $pagination = $this->get('Pagination');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $params =& $state->params;
     // PREPARE THE DATA
     // Get the metrics for the structural page layout.
     $numLeading = $params->def('num_leading_articles', 1);
     $numIntro = $params->def('num_intro_articles', 4);
     $numLinks = $params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     foreach ($items as $i => &$item) {
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->event = new stdClass();
         $dispatcher = JEventDispatcher::getInstance();
         $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'com_content.featured');
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     // Preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interogate the arrays.
     $max = count($items);
     // The first group is the leading articles.
     $limit = $numLeading;
     for ($i = 0; $i < $limit && $i < $max; $i++) {
         $this->lead_items[$i] =& $items[$i];
     }
     // The second group is the intro articles.
     $limit = $numLeading + $numIntro;
     // Order articles across, then down (or single column mode)
     for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
         $this->intro_items[$i] =& $items[$i];
     }
     $this->columns = max(1, $params->def('num_columns', 1));
     $order = $params->def('multi_column_order', 1);
     if ($order == 0 && $this->columns > 1) {
         // call order down helper
         $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
     }
     // The remainder are the links.
     for ($i = $numLeading + $numIntro; $i < $max; $i++) {
         $this->link_items[$i] =& $items[$i];
     }
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->params =& $params;
     $this->items =& $items;
     $this->pagination =& $pagination;
     $this->user =& $user;
     $this->_prepareDocument();
     parent::display($tpl);
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: educakanchay/kanchay
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     parent::commonCategoryDisplay();
     // Prepare the data
     // Get the metrics for the structural page layout.
     $params = $this->params;
     $numLeading = $params->def('num_leading_articles', 1);
     $numIntro = $params->def('num_intro_articles', 4);
     $numLinks = $params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     foreach ($this->items as $item) {
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->event = new stdClass();
         $dispatcher = JEventDispatcher::getInstance();
         // Old plugins: Ensure that text property is available
         if (!isset($item->text)) {
             $item->text = $item->introtext;
         }
         JPluginHelper::importPlugin('content');
         $dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$item->params, 0));
         // Old plugins: Use processed text as introtext
         $item->introtext = $item->text;
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     // Check for layout override only if this is not the active menu item
     // If it is the active menu item, then the view and category id will match
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $menus = $app->getMenu();
     $pathway = $app->getPathway();
     $title = null;
     if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&id=' . (string) $this->category->id) === false)) {
         // Get the layout from the merged category params
         if ($layout = $this->category->params->get('category_layout')) {
             $this->setLayout($layout);
         }
     } elseif (isset($active->query['layout'])) {
         // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout)
         $this->setLayout($active->query['layout']);
     }
     // For blog layouts, preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interrogate the arrays.
     if ($params->get('layout_type') == 'blog' || $this->getLayout() == 'blog') {
         foreach ($this->items as $i => $item) {
             if ($i < $numLeading) {
                 $this->lead_items[] = $item;
             } elseif ($i >= $numLeading && $i < $numLeading + $numIntro) {
                 $this->intro_items[] = $item;
             } elseif ($i < $numLeading + $numIntro + $numLinks) {
                 $this->link_items[] = $item;
             } else {
                 continue;
             }
         }
         $this->columns = max(1, $params->def('num_columns', 1));
         $order = $params->def('multi_column_order', 1);
         if ($order == 0 && $this->columns > 1) {
             // Call order down helper
             $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
         }
     }
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     }
     $title = $this->params->get('page_title', '');
     $id = (int) @$menu->query['id'];
     // Check for empty title and add site name if param is set
     if (empty($title)) {
         $title = $app->get('sitename');
     } elseif ($app->get('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
     } elseif ($app->get('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
     }
     if (empty($title)) {
         $title = $this->category->title;
     }
     $this->document->setTitle($title);
     if ($this->category->metadesc) {
         $this->document->setDescription($this->category->metadesc);
     } elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->category->metakey) {
         $this->document->setMetadata('keywords', $this->category->metakey);
     } elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) {
         $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
     if (!is_object($this->category->metadata)) {
         $this->category->metadata = new Registry($this->category->metadata);
     }
     if ($app->get('MetaAuthor') == '1' && $this->category->get('author', '')) {
         $this->document->setMetaData('author', $this->category->get('author', ''));
     }
     $mdata = $this->category->metadata->toArray();
     foreach ($mdata as $k => $v) {
         if ($v) {
             $this->document->setMetadata($k, $v);
         }
     }
     return parent::display($tpl);
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: rasiodesign/joomla-cms
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     // Get some data from the models
     $state = $this->get('State');
     $params = $state->params;
     $items = $this->get('Items');
     $category = $this->get('Category');
     $children = $this->get('Children');
     $parent = $this->get('Parent');
     $pagination = $this->get('Pagination');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($category == false) {
         return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
     }
     if ($parent == false) {
         return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
     }
     // Setup the category parameters.
     $cparams = $category->getParams();
     $category->params = clone $params;
     $category->params->merge($cparams);
     // Check whether category access level allows access.
     $user = JFactory::getUser();
     $groups = $user->getAuthorisedViewLevels();
     if (!in_array($category->access, $groups)) {
         return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // PREPARE THE DATA
     // Get the metrics for the structural page layout.
     $numLeading = $params->def('num_leading_articles', 1);
     $numIntro = $params->def('num_intro_articles', 4);
     $numLinks = $params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $item =& $items[$i];
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->event = new stdClass();
         $dispatcher = JEventDispatcher::getInstance();
         $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'com_content.category');
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     // Check for layout override only if this is not the active menu item
     // If it is the active menu item, then the view and category id will match
     $active = $app->getMenu()->getActive();
     if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&id=' . (string) $category->id) === false)) {
         // Get the layout from the merged category params
         if ($layout = $category->params->get('category_layout')) {
             $this->setLayout($layout);
         }
     } elseif (isset($active->query['layout'])) {
         // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout)
         $this->setLayout($active->query['layout']);
     }
     // For blog layouts, preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interrogate the arrays.
     if ($params->get('layout_type') == 'blog' || $this->getLayout() == 'blog') {
         $max = count($items);
         // The first group is the leading articles.
         $limit = $numLeading;
         for ($i = 0; $i < $limit && $i < $max; $i++) {
             $this->lead_items[$i] =& $items[$i];
         }
         // The second group is the intro articles.
         $limit = $numLeading + $numIntro;
         // Order articles across, then down (or single column mode)
         for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
             $this->intro_items[$i] =& $items[$i];
         }
         $this->columns = max(1, $params->def('num_columns', 1));
         $order = $params->def('multi_column_order', 1);
         if ($order == 0 && $this->columns > 1) {
             // call order down helper
             $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
         }
         $limit = $numLeading + $numIntro + $numLinks;
         // The remainder are the links.
         for ($i = $numLeading + $numIntro; $i < $limit && $i < $max; $i++) {
             $this->link_items[$i] =& $items[$i];
         }
     }
     $children = array($category->id => $children);
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->maxLevel = $params->get('maxLevel', -1);
     $this->state =& $state;
     $this->items =& $items;
     $this->category =& $category;
     $this->children =& $children;
     $this->params =& $params;
     $this->parent =& $parent;
     $this->pagination =& $pagination;
     $this->user =& $user;
     // Increment the category hit counter
     $model = $this->getModel();
     $model->hit();
     $this->_prepareDocument();
     parent::display($tpl);
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: 01J/skazkipronebo
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     parent::commonCategoryDisplay();
     // Prepare the data
     // Get the metrics for the structural page layout.
     $params = $this->params;
     $numLeading = $params->def('num_leading_articles', 1);
     $numIntro = $params->def('num_intro_articles', 4);
     $numLinks = $params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     foreach ($this->items as $item) {
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->event = new stdClass();
         $dispatcher = JEventDispatcher::getInstance();
         // Old plugins: Ensure that text property is available
         if (!isset($item->text)) {
             $item->text = $item->introtext;
         }
         JPluginHelper::importPlugin('content');
         $dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$item->params, 0));
         // Old plugins: Use processed text as introtext
         $item->introtext = $item->text;
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     // Check for layout override only if this is not the active menu item
     // If it is the active menu item, then the view and category id will match
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&id=' . (string) $this->category->id) === false)) {
         // Get the layout from the merged category params
         if ($layout = $this->category->params->get('category_layout')) {
             $this->setLayout($layout);
         }
     } elseif (isset($active->query['layout'])) {
         // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout)
         $this->setLayout($active->query['layout']);
     }
     // For blog layouts, preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interrogate the arrays.
     if ($params->get('layout_type') == 'blog' || $this->getLayout() == 'blog') {
         //$max = count($this->items);
         foreach ($this->items as $i => $item) {
             if ($i < $numLeading) {
                 $this->lead_items[] = $item;
             } elseif ($i >= $numLeading && $i < $numLeading + $numIntro) {
                 $this->intro_items[] = $item;
             } elseif ($i < $numLeading + $numIntro + $numLinks) {
                 $this->link_items[] = $item;
             } else {
                 continue;
             }
         }
         $this->columns = max(1, $params->def('num_columns', 1));
         $order = $params->def('multi_column_order', 1);
         if ($order == 0 && $this->columns > 1) {
             // call order down helper
             $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
         }
     }
     return parent::display($tpl);
 }
コード例 #5
0
 /**
  * Get featured items
  * 
  */
 public function getData($pk)
 {
     JSNFactory::localimport('libraries.joomlashine.config');
     $params = JSNConfig::getMenuParams($pk['Itemid']);
     JSNConfig::megreGlobalParams('com_content', $params);
     $this->setState('params', $params);
     $data = new stdClass();
     $data->params = $params;
     $activeAllParams = new JRegistry();
     if ($params instanceof JRegistry) {
         foreach ($params->toArray() as $key => $val) {
             if (strpos($key, 'show_') !== false && (int) $params->get($key) == 0) {
                 $activeAllParams->set($key, 1);
             } else {
                 $activeAllParams->set($key, $val);
             }
         }
     }
     $limit = (int) $params->def('num_leading_articles', 1) + (int) $params->get('num_intro_articles', 4) + (int) $params->def('num_links', 4);
     $this->setState('params', $activeAllParams);
     $this->setState('filter.published', 1);
     $this->setState('filter.access', '');
     $this->setState('list.start', 0);
     $this->setState('list.limit', $limit);
     $this->setState('list.direction', '');
     $this->setState('list.filter', '');
     // filter.subcategories indicates whether to include articles from subcategories in the list or blog
     $this->setState('list.links', $activeAllParams->get('num_links'));
     if ($activeAllParams->get('featured_categories') && implode(',', $activeAllParams->get('featured_categories')) == true) {
         $this->setState('filter.frontpage.categories', $activeAllParams->get('featured_categories'));
     }
     $this->setState('filter.frontpage', 1);
     $items = parent::getItems();
     // PREPARE THE DATA
     // Get the metrics for the structural page layout.
     $numLeading = $params->def('num_leading_articles', 1);
     $numIntro = $params->def('num_intro_articles', 4);
     $numLinks = $params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     foreach ($items as $i => &$item) {
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         // Ignore content plugins on links.
         if ($i < $numLeading + $numIntro) {
             $item->introtext = JHtml::_('content.prepare', $item->introtext);
         }
     }
     // Preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interogate the arrays.
     $max = count($items);
     // The first group is the leading articles.
     $limit = $numLeading;
     for ($i = 0; $i < $limit && $i < $max; $i++) {
         $data->lead_items[$i] =& $items[$i];
     }
     // The second group is the intro articles.
     $limit = $numLeading + $numIntro;
     // Order articles across, then down (or single column mode)
     for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
         $data->intro_items[$i] =& $items[$i];
     }
     $data->columns = max(1, $params->def('num_columns', 1));
     $order = $params->def('multi_column_order', 1);
     if ($order == 0 && $data->columns > 1) {
         // call order down helper
         $data->intro_items = ContentHelperQuery::orderDownColumns($data->intro_items, $data->columns);
     }
     // The remainder are the links.
     for ($i = $numLeading + $numIntro; $i < $max; $i++) {
         $data->link_items[$i] =& $items[$i];
     }
     $data->pagination = $this->getPagination();
     //Escape strings for HTML output
     $data->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     return $data;
 }
コード例 #6
0
 /**
  *
  * Get data
  *
  * @param Array $pk
  */
 public function getData($pk)
 {
     $this->_data = new stdClass();
     $this->_data->items = array();
     $this->_data->children = null;
     $this->_data->category = null;
     jimport('joomla.application.categories');
     $this->setState('category.id', $pk['id']);
     $this->_data->items = $this->getItems();
     // Get some data from the models
     if (isset($this->state->params)) {
         $this->_data->params = $this->state->params;
         $options = array();
         $options['countItems'] = $this->_data->params->get('show_cat_num_articles', 1) || !$this->_data->params->get('show_empty_categories_cat', 0);
     } else {
         $options['countItems'] = 0;
     }
     $categories = JCategories::getInstance('Content', $options);
     $this->_data->category = $categories->get($this->getState('category.id', 'root'));
     // Compute selected asset permissions.
     if (is_object($this->_data->category)) {
         // TODO: Why aren't we lazy loading the children and siblings?
         $this->_data->children = $this->_data->category->getChildren();
         $this->_data->parent = false;
         if ($this->_data->category->getParent()) {
             $this->_data->parent = $this->_data->category->getParent();
         }
         // Setup the category parameters.
         $cparams = $this->_data->category->getParams();
         $this->_data->category->params = clone $this->_data->params;
         $this->_data->category->params->merge($cparams);
     } else {
         $this->_data->children = false;
         $this->_data->parent = false;
     }
     // PREPARE THE DATA
     // Get the metrics for the structural page layout.
     $numLeading = $this->_data->params->def('num_leading_articles', 1);
     $numIntro = $this->_data->params->def('num_intro_articles', 4);
     $numLinks = $this->_data->params->def('num_links', 4);
     // Compute the article slugs and prepare introtext (runs content plugins).
     for ($i = 0, $n = count($this->_data->items); $i < $n; $i++) {
         $item =& $this->_data->items[$i];
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         // Ignore content plugins on links.
         if ($i < $numLeading + $numIntro) {
             $item->introtext = JHtml::_('content.prepare', $item->introtext);
         }
     }
     // For blog layouts, preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interrogate the arrays.
     if ($this->_data->params->get('layout_type') == 'blog' || @$pk['layout'] == 'blog') {
         $max = count($this->_data->items);
         // The first group is the leading articles.
         $limit = $numLeading;
         for ($i = 0; $i < $limit && $i < $max; $i++) {
             $this->_data->lead_items[$i] =& $this->_data->items[$i];
             // Add router helpers.
             $item =& $this->_data->lead_items[$i];
             $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
             $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
             $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         }
         // The second group is the intro articles.
         $limit = $numLeading + $numIntro;
         // Order articles across, then down (or single column mode)
         for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
             $this->_data->intro_items[$i] =& $this->_data->items[$i];
             // Add router helpers.
             $item =& $this->_data->intro_items[$i];
             $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
             $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
             $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         }
         $this->_data->columns = max(1, $this->_data->params->def('num_columns', 1));
         $order = $this->_data->params->def('multi_column_order', 1);
         if ($order == 0 && $this->_data->columns > 1) {
             // call order down helper
             $this->_data->intro_items = ContentHelperQuery::orderDownColumns($this->_data->intro_items, $this->_data->columns);
         }
         $limit = $numLeading + $numIntro + $numLinks;
         // The remainder are the links.
         for ($i = $numLeading + $numIntro; $i < $limit && $i < $max; $i++) {
             $this->_data->link_items[$i] =& $this->_data->items[$i];
         }
     }
     // Order subcategories
     if (sizeof($this->_data->children)) {
         if ($this->_data->params->get('orderby_pri') == 'alpha' || $this->_data->params->get('orderby_pri') == 'ralpha') {
             jimport('joomla.utilities.arrayhelper');
             JArrayHelper::sortObjects($this->_data->children, 'title', $this->_data->params->get('orderby_pri') == 'alpha' ? 1 : -1);
         }
     }
     if (isset($this->_data->category->id)) {
         $this->_data->children = array($this->_data->category->id => $this->_data->children);
     }
     //Escape strings for HTML output
     $this->_data->pageclass_sfx = htmlspecialchars($this->_data->params->get('pageclass_sfx'));
     $this->_data->maxLevel = $this->_data->params->get('maxLevel', -1);
     $this->_data->state = $this->state;
     return $this->_data;
 }
コード例 #7
0
ファイル: view.html.php プロジェクト: xenten/swift-kanban
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $uri = JFactory::getURI();
     $document = JFactory::getDocument();
     $dispatcher = JDispatcher::getInstance();
     $pathway = $app->getPathway();
     // Get the menu item object
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $params = $app->getParams();
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     // Initialize variables
     $article = $this->get('Article');
     $state = $this->get('State');
     // Request variables
     $layout = $params->get('layout_type');
     $task = JRequest::getCmd('task');
     $numIntro = $params->get('num_intro_articles', 4);
     $numLeading = $params->get('num_leading_articles', 1);
     $numLinks = $params->get('num_links', 4);
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     $itemid = JRequest::getInt('Itemid', 0);
     $params->def('display_num', $app->getCfg('list_limit'));
     $default_limit = $params->get('display_num');
     if ($layout == 'blog') {
         $limit = $numIntro + $numLeading + $numLinks;
     } else {
         $params->def('display_num', $app->getCfg('list_limit'));
         $default_limit = $params->get('display_num');
         $limit = $app->getUserStateFromRequest('com_fjrelated.list.:' . $itemid . '.limit', 'limit', $default_limit, 'int');
     }
     JRequest::setVar('limit', (int) $limit);
     $contentConfig = JComponentHelper::getParams('com_content');
     $params->def('show_page_title', $contentConfig->get('show_title'));
     $menu_params = new JParameter($menu->params);
     if (!$menu_params->get('page_title')) {
         $params->set('page_title', $article->title ? $article->title : $menu->title);
     }
     $document->setTitle($params->get('page_title'));
     if ($article->metadesc) {
         $document->setDescription($article->metadesc);
     }
     if ($article->metakey) {
         $document->setMetadata('keywords', $article->metakey);
     }
     // Get some data from the model
     $items = $this->get('Data');
     if ($items) {
         $total = $this->get('Total');
         // only do count if there are items to count
     } else {
         $total = 0;
     }
     //add alternate feed link
     if ($params->get('show_feed_link', 1) == 1) {
         $link = '&format=feed&limitstart=';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     // Create a user access object for the user
     $access = new stdClass();
     $access->canEdit = $user->authorize('core.edit', 'com_content');
     $access->canEditOwn = $user->authorize('core.edit.own', 'com_content');
     $access->canPublish = $user->authorize('core.edit.state', 'com_content');
     jimport('joomla.html.pagination');
     //In case we are in a blog view set the limit
     if ($layout == 'blog') {
         $pagination = new JPagination($total, $limitstart, $limit - $numLinks);
     } else {
         $pagination = new JPagination($total, $limitstart, $limit);
     }
     // Compute the article slugs and prepare introtext (runs content plugins).
     foreach ($items as $i => &$item) {
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->event = new stdClass();
         $dispatcher = JDispatcher::getInstance();
         // Ignore content plugins on links.
         if ($i < $numLeading + $numIntro) {
             $item->introtext = JHtml::_('content.prepare', $item->introtext);
             $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0));
             $item->event->afterDisplayTitle = trim(implode("\n", $results));
             $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0));
             $item->event->beforeDisplayContent = trim(implode("\n", $results));
             $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0));
             $item->event->afterDisplayContent = trim(implode("\n", $results));
         }
     }
     // Preprocess the breakdown of leading, intro and linked articles.
     // This makes it much easier for the designer to just interogate the arrays.
     $max = count($items);
     // The first group is the leading articles.
     $limit = $numLeading;
     for ($i = 0; $i < $limit && $i < $max; $i++) {
         $this->lead_items[$i] =& $items[$i];
     }
     // The second group is the intro articles.
     $limit = $numLeading + $numIntro;
     // Order articles across, then down (or single column mode)
     for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
         $this->intro_items[$i] =& $items[$i];
     }
     $this->columns = max(1, $params->def('num_columns', 1));
     $order = $params->def('multi_column_order', 1);
     if ($order == 0 && $this->columns > 1) {
         // call order down helper
         $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
     }
     // The remainder are the links.
     for ($i = $numLeading + $numIntro; $i < $max; $i++) {
         $this->link_items[$i] =& $items[$i];
     }
     $this->assignRef('article', $article);
     $this->assignRef('params', $params);
     $this->assignRef('user', $user);
     $this->assignRef('access', $access);
     $this->assignRef('items', $items);
     $this->assign('total', $total);
     $this->assign('action', $uri->toString());
     $this->assignRef('pagination', $pagination);
     $this->assignRef('state', $state);
     parent::display($tpl);
 }
コード例 #8
0
 function onAfterDispatch()
 {
     if ($this->_admin) {
         return;
     }
     $app = JFactory::getApplication();
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     $layout = $app->input->get('layout');
     if ($option == 'com_content') {
         if ($view == 'category' && $layout == 'blog') {
             $this->_view = 'view_category';
         } else {
             if ($view == 'featured') {
                 $this->_view = 'view_featured';
             }
         }
     }
     if ($this->_view == null) {
         return;
     }
     $com_path = JPATH_SITE . '/components/com_content/';
     if (!class_exists('ContentBuildRoute')) {
         require_once $com_path . 'router.php';
     }
     if (!class_exists('ContentHelperRoute')) {
         require_once $com_path . 'helpers/route.php';
     }
     JModelLegacy::addIncludePath($com_path . '/models', 'ContentModel');
     $_cont_params = JComponentHelper::getParams('com_content');
     $menuParams = new JRegistry();
     if ($menu = $app->getMenu()->getActive()) {
         $menuParams->loadString($menu->params);
     }
     $cont_params = clone $_cont_params;
     $cont_params->merge($menuParams);
     $numLeading = $cont_params->get('num_leading_articles', 1);
     $numIntro = $cont_params->get('num_intro_articles', 4);
     $numLinks = $cont_params->get('num_links', 4);
     $limit = $numLeading + $numIntro + $numLinks;
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     $model->setState('params', $cont_params);
     if ($this->_view == 'view_category') {
         $model->setState('filter.category_id', JRequest::getVar('id'));
     } else {
         $model->setState('filter.category_id', JRequest::getVar('id', $cont_params->get('featured_categories')));
     }
     $model->setState('list.start', 0);
     $model->setState('list.limit', 0);
     $model->setState('filter.published', 1);
     $access = !$cont_params->get('show_noauth');
     $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
     $model->setState('filter.access', $access);
     $model->setState('filter.language', $app->getLanguageFilter());
     if ($this->_view == 'view_featured') {
         $articleOrderby = $cont_params->get('orderby_sec', 'rdate');
         $articleOrderDate = $cont_params->get('order_date');
         $categoryOrderby = $cont_params->def('orderby_pri', '');
         $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
         $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
         $orderby = $primary . ' ' . $secondary . ' a.created DESC ';
         $model->setState('filter.frontpage', true);
         $model->setState('list.ordering', $orderby);
         $model->setState('list.direction', '');
         $model->setState('filter.featured', 'only');
     } elseif ($this->_view == 'view_category') {
         $model->setState('list.ordering', $this->_buildContentOrderBy());
     }
     $numberitems = $model->getItems();
     $this->_total = count($numberitems);
     $this->_start = $limit;
     $this->_limit = $this->_limit > 0 ? $this->_limit : $limit;
     $this->tag_id = $view == 'category' ? '.blog' : '.blog-featured';
     if ($this->isAjax()) {
         $com_content_ajax = (int) JRequest::getVar('com_content_ajax', 0);
         $content_listing_ajax_com = JRequest::getVar('content_listing_ajax_com');
         $content_listing_ajax_view = JRequest::getVar('content_listing_ajax_view');
         $content_listing_ajax_layout = JRequest::getVar('content_listing_ajax_layout');
         if ($com_content_ajax == 1 && $content_listing_ajax_com == 'com_content' && ($content_listing_ajax_view == 'category' && $content_listing_ajax_layout == 'blog' || $content_listing_ajax_view == 'featured' && $content_listing_ajax_layout == 'featured')) {
             $task = JRequest::getCmd('task');
             $view = JRequest::getCmd('view');
             $result = new stdClass();
             $model->setState('filter.category_id', JRequest::getVar('id'));
             $model->setState('list.start', $app->input->getInt('limitstart', 0));
             $model->setState('list.limit', $this->_limit);
             $lead_items = array();
             $intro_items = array();
             $link_items = array();
             $items = $model->getItems();
             for ($i = 0, $n = count($items); $i < $n; $i++) {
                 $item =& $items[$i];
                 $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
                 $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
                 // No link for ROOT category
                 if ($item->parent_alias == 'root') {
                     $item->parent_slug = null;
                 }
                 $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
                 $item->event = new stdClass();
                 $dispatcher = JDispatcher::getInstance();
                 // Old plugins: Ensure that text property is available
                 if (!isset($item->text)) {
                     $item->text = $item->introtext;
                 }
                 JPluginHelper::importPlugin('content');
                 $results = $dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$this->params, 0));
                 // Old plugins: Use processed text as introtext
                 $item->introtext = $item->text;
                 $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0));
                 $item->event->afterDisplayTitle = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0));
                 $item->event->beforeDisplayContent = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0));
                 $item->event->afterDisplayContent = trim(implode("\n", $results));
             }
             if ($cont_params->get('layout_type') == 'blog' || $app->input->get('layout') == 'blog' || $content_listing_ajax_view == 'featured' && $content_listing_ajax_layout == 'featured') {
                 $max = count($items);
                 //$numLeading = ($numIntro + $numLinks <= 0 || $numLeading <= 0  )?$this->_limit:$numLeading;
                 $limit = $numLeading;
                 for ($i = 0; $i < $limit && $i < $max; $i++) {
                     $lead_items[$i] =& $items[$i];
                 }
                 $limit = $numLeading + $numIntro;
                 for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
                     $intro_items[$i] =& $items[$i];
                 }
                 $this->columns = max(1, $cont_params->get('num_columns', 1));
                 $order = $cont_params->get('multi_column_order', 1);
                 if ($order == 0 && $this->columns > 1) {
                     $intro_items = ContentHelperQuery::orderDownColumns($intro_items, $this->columns);
                 }
                 for ($i = $numLeading + $numIntro; $i < $max; $i++) {
                     $link_items[$i] =& $items[$i];
                 }
             }
             ob_start();
             if (!empty($lead_items) || !empty($intro_items) || !empty($link_items)) {
                 $buffer0 = $this->getViewHtml($lead_items, $intro_items, $link_items, $cont_params);
                 $result->items_markup = preg_replace(array('/ {2,}/', '/<!--.*?-->|\\t|(?:\\r?\\n[ \\t]*)+/s'), array(' ', ''), $buffer0);
             }
             ob_end_clean();
             die(json_encode($result));
         }
     }
 }