| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Site 4 * @subpackage mod_weblinks 5 * @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 // no direct access 10 defined('_JEXEC') or die; 11 12 jimport('joomla.application.component.model'); 13 14 require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php'; 15 JModel::addIncludePath(JPATH_SITE . '/components/com_weblinks/models', 'WeblinksModel'); 16 17 class modWeblinksHelper 18 { 19 static function getList($params) 20 { 21 22 // Get an instance of the generic articles model 23 $model = JModel::getInstance('Category', 'WeblinksModel', array('ignore_request' => true)); 24 25 // Set application parameters in model 26 $app = JFactory::getApplication(); 27 $appParams = $app->getParams(); 28 $model->setState('params', $appParams); 29 30 // Set the filters based on the module params 31 $model->setState('list.start', 0); 32 $model->setState('list.limit', (int) $params->get('count', 5)); 33 34 $model->setState('filter.state', 1); 35 $model->setState('filter.archived', 0); 36 $model->setState('filter.approved', 1); 37 38 // Access filter 39 $access = !JComponentHelper::getParams('com_weblinks')->get('show_noauth'); 40 $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); 41 $model->setState('filter.access', $access); 42 43 $ordering = $params->get('ordering', 'ordering'); 44 $model->setState('list.ordering', $ordering == 'order' ? 'ordering' : $ordering); 45 $model->setState('list.direction', $params->get('direction', 'asc')); 46 47 $catid = (int) $params->get('catid', 0); 48 $model->setState('category.id', $catid); 49 50 // Create query object 51 $db = JFactory::getDbo(); 52 $query = $db->getQuery(true); 53 54 $case_when1 = ' CASE WHEN '; 55 $case_when1 .= $query->charLength('a.alias'); 56 $case_when1 .= ' THEN '; 57 $a_id = $query->castAsChar('a.id'); 58 $case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':'); 59 $case_when1 .= ' ELSE '; 60 $case_when1 .= $a_id.' END as slug'; 61 62 $case_when2 = ' CASE WHEN '; 63 $case_when2 .= $query->charLength('c.alias'); 64 $case_when2 .= ' THEN '; 65 $c_id = $query->castAsChar('c.id'); 66 $case_when2 .= $query->concatenate(array($c_id, 'c.alias'), ':'); 67 $case_when2 .= ' ELSE '; 68 $case_when2 .= $c_id.' END as catslug'; 69 70 $model->setState('list.select', 'a.*, c.published AS c_published,'.$case_when1.','.$case_when2.','. 71 'DATE_FORMAT(a.date, "%Y-%m-%d") AS created'); 72 73 $model->setState('filter.c.published', 1); 74 75 // Filter by language 76 $model->setState('filter.language', $app->getLanguageFilter()); 77 78 $items = $model->getItems(); 79 80 /* 81 * This was in the previous code before we changed over to using the 82 * weblinkscategory model but I don't see any models using checked_out filters 83 * in their getListQuery() methods so I believe we should not be adding this now 84 */ 85 86 /* 87 $query->where('(a.checked_out = 0 OR a.checked_out = '.$user->id.')'); 88 */ 89 for ($i =0, $count = count($items); $i < $count; $i++) { 90 $item = &$items[$i]; 91 if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1) { 92 $item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&catid='.$item->catslug.'&id='. $item->slug); 93 } else { 94 $item->link = $item->url; 95 } 96 } 97 return $items; 98 99 } 100 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |