modules/mod_related_items/helper.php. Joomla mod php


modules/mod_related_items/helper.php (Документация по Joomla 2.5.4)

Вернуться к записям по теме Joomla. <?php /** * @package Joomla.Site * @subpackage mod_related_items * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */   // no direct access defined('_JEXEC') or die;   require_once JPATH_SITE.'/components/com_content/helpers/route.php';   abstract class modRelatedItemsHelper { public static function getList($params) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $userId = (int) $user->get('id'); $count = intval($params->get('count', 5)); $groups = implode(',', $user->getAuthorisedViewLevels()); $date = JFactory::getDate();   $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view');   $temp = JRequest::getString('id'); $temp = explode(':', $temp); $id = $temp[0];   $showDate = $params->get('showDate', 0); $nullDate = $db->getNullDate(); $now = $date->toSql(); $related = array(); $query = $db->getQuery(true);   if ($option == 'com_content' && $view == 'article' && $id) { // select the meta keywords from the item   $query->select('metakey'); $query->from('#__content'); $query->where('id = ' . (int) $id); $db->setQuery($query);   if ($metakey = trim($db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); $likes = array ();   // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { $likes[] = $db->escape($key); } }   if (count($likes)) { // select other items based on the metakey field 'like' the keys found $query->clear(); $query->select('a.id'); $query->select('a.title'); $query->select('DATE_FORMAT(a.created, "%Y-%m-%d") as created'); $query->select('a.catid'); $query->select('cc.access AS cat_access'); $query->select('cc.published AS cat_state');   //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $query->select($case_when);   $case_when = ' CASE WHEN '; $case_when .= $query->charLength('cc.alias'); $case_when .= ' THEN '; $c_id = $query->castAsChar('cc.id'); $case_when .= $query->concatenate(array($c_id, 'cc.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id.' END as catslug'; $query->select($case_when); $query->from('#__content AS a'); $query->leftJoin('#__content_frontpage AS f ON f.content_id = a.id'); $query->leftJoin('#__categories AS cc ON cc.id = a.catid'); $query->where('a.id != ' . (int) $id); $query->where('a.state = 1'); $query->where('a.access IN (' . $groups . ')'); $concat_string = $query->concatenate(array('","', ' REPLACE(a.metakey, ", ", ",")', ' ","')); $query->where('('.$concat_string.' LIKE "%'.implode('%" OR '.$concat_string.' LIKE "%', $likes).'%")'); //remove single space after commas in keywords) $query->where('(a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).')'); $query->where('(a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')');   // Filter by language if ($app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); }   $db->setQuery($query); $qstring = $db->getQuery(); $temp = $db->loadObjectList();   if (count($temp)) { foreach ($temp as $row) { if ($row->cat_state == 1) { $row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug)); $related[] = $row; } } } unset ($temp); } } }   return $related; } }   Вернуться к записям по теме Joomla.

ya.samposebe.ru

modules/mod_related_items/helper.php *Документация по Joomla 3.0.2

Вернуться к записям по теме Joomla. <?php /** * @package Joomla.Site * @subpackage mod_related_items * * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */   defined('_JEXEC') or die;   require_once JPATH_SITE.'/components/com_content/helpers/route.php';   /** * Helper for mod_related_items * * @package Joomla.Site * @subpackage mod_related_items * @since 1.5 */ abstract class modRelatedItemsHelper { public static function getList($params) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $date = JFactory::getDate();   $option = $app->input->get('option'); $view = $app->input->get('view');   $temp = $app->input->getString('id'); $temp = explode(':', $temp); $id = $temp[0];   $nullDate = $db->getNullDate(); $now = $date->toSql(); $related = array(); $query = $db->getQuery(true);   if ($option == 'com_content' && $view == 'article' && $id) { // select the meta keywords from the item   $query->select('metakey'); $query->from('#__content'); $query->where('id = ' . (int) $id); $db->setQuery($query);   if ($metakey = trim($db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); $likes = array ();   // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { $likes[] = $db->escape($key); } }   if (count($likes)) { // select other items based on the metakey field 'like' the keys found $query->clear(); $query->select('a.id'); $query->select('a.title'); $query->select('DATE_FORMAT(a.created, "%Y-%m-%d") as created'); $query->select('a.catid'); $query->select('cc.access AS cat_access'); $query->select('cc.published AS cat_state');   // Sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias', '!=', '0'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $query->select($case_when);   $case_when = ' CASE WHEN '; $case_when .= $query->charLength('cc.alias', '!=', '0'); $case_when .= ' THEN '; $c_id = $query->castAsChar('cc.id'); $case_when .= $query->concatenate(array($c_id, 'cc.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id.' END as catslug'; $query->select($case_when); $query->from('#__content AS a'); $query->leftJoin('#__content_frontpage AS f ON f.content_id = a.id'); $query->leftJoin('#__categories AS cc ON cc.id = a.catid'); $query->where('a.id != ' . (int) $id); $query->where('a.state = 1'); $query->where('a.access IN (' . $groups . ')'); $concat_string = $query->concatenate(array('","', ' REPLACE(a.metakey, ", ", ",")', ' ","')); $query->where('('.$concat_string.' LIKE "%'.implode('%" OR '.$concat_string.' LIKE "%', $likes).'%")'); //remove single space after commas in keywords) $query->where('(a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).')'); $query->where('(a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')');   // Filter by language if ($app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); }   $db->setQuery($query); $temp = $db->loadObjectList();   if (count($temp)) { foreach ($temp as $row) { if ($row->cat_state == 1) { $row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug)); $related[] = $row; } } } unset ($temp); } } }   return $related; } }   Вернуться к записям по теме Joomla.

ya.samposebe.ru

administrator/modules/mod_latest/helper.php *Документация по Joomla 3.0.2

Вернуться к записям по теме Joomla. <?php /** * @package Joomla.Administrator * @subpackage mod_latest * * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */   defined('_JEXEC') or die;   JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_content/models', 'ContentModel');   /** * Helper for mod_latest * * @package Joomla.Administrator * @subpackage mod_latest */ abstract class modLatestHelper { /** * Get a list of articles. * * @param JObject The module parameters. * * @return mixed An array of articles, or false on error. */ public static function getList($params) { $user = JFactory::getuser();   // Get an instance of the generic articles model $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));   // Set List SELECT $model->setState('list.select', 'a.id, a.title, a.checked_out, a.checked_out_time, ' . ' a.access, a.created, a.created_by, a.created_by_alias, a.featured, a.state');   // Set Ordering filter switch ($params->get('ordering')) { case 'm_dsc': $model->setState('list.ordering', 'modified DESC, created'); $model->setState('list.direction', 'DESC'); break;   case 'c_dsc': default: $model->setState('list.ordering', 'created'); $model->setState('list.direction', 'DESC'); break; }   // Set Category Filter $categoryId = $params->get('catid'); if (is_numeric($categoryId)){ $model->setState('filter.category_id', $categoryId); }   // Set User Filter. $userId = $user->get('id'); switch ($params->get('user_id')) { case 'by_me': $model->setState('filter.author_id', $userId); break;   case 'not_me': $model->setState('filter.author_id', $userId); $model->setState('filter.author_id.include', false); break; }   // Set the Start and Limit $model->setState('list.start', 0); $model->setState('list.limit', $params->get('count', 5));   $items = $model->getItems();   if ($error = $model->getError()) { JError::raiseError(500, $error); return false; }   // Set the links foreach ($items as &$item) { if ($user->authorise('core.edit', 'com_content.article.'.$item->id)){ $item->link = JRoute::_('index.php?option=com_content&task=article.edit&id='.$item->id); } else { $item->link = ''; } }   return $items; }   /** * Get the alternate title for the module * * @param JObject The module parameters. * @return string The alternate title for the module. */ public static function getTitle($params) { $who = $params->get('user_id'); $catid = (int) $params->get('catid'); $type = $params->get('ordering') == 'c_dsc' ? '_CREATED' : '_MODIFIED'; if ($catid) { $category = JCategories::getInstance('Content')->get($catid); if ($category) { $title = $category->title; } else { $title = JText::_('MOD_POPULAR_UNEXISTING'); } } else { $title = ''; } return JText::plural('MOD_LATEST_TITLE' . $type. ($catid ? "_CATEGORY" : '') . ($who != '0' ? "_$who" : ''), (int) $params->get('count'), $title); } }   Вернуться к записям по теме Joomla.

ya.samposebe.ru


Prostoy-Site | Все права защищены © 2018 | Карта сайта