| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: helper.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 6 * @license GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // no direct access 15 defined('_JEXEC') or die('Restricted access'); 16 17 require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); 18 19 class modLatestNewsHelper 20 { 21 function getList(&$params) 22 { 23 global $mainframe; 24 25 $db =& JFactory::getDBO(); 26 $user =& JFactory::getUser(); 27 $userId = (int) $user->get('id'); 28 29 $count = (int) $params->get('count', 5); 30 $catid = trim( $params->get('catid') ); 31 $secid = trim( $params->get('secid') ); 32 $show_front = $params->get('show_front', 1); 33 $aid = $user->get('aid', 0); 34 35 $contentConfig = &JComponentHelper::getParams( 'com_content' ); 36 $access = !$contentConfig->get('show_noauth'); 37 38 $nullDate = $db->getNullDate(); 39 40 $date =& JFactory::getDate(); 41 $now = $date->toMySQL(); 42 43 $where = 'a.state = 1' 44 . ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )' 45 . ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )' 46 ; 47 48 // User Filter 49 switch ($params->get( 'user_id' )) 50 { 51 case 'by_me': 52 $where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')'; 53 break; 54 case 'not_me': 55 $where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')'; 56 break; 57 } 58 59 // Ordering 60 switch ($params->get( 'ordering' )) 61 { 62 case 'm_dsc': 63 $ordering = 'a.modified DESC, a.created DESC'; 64 break; 65 case 'c_dsc': 66 default: 67 $ordering = 'a.created DESC'; 68 break; 69 } 70 71 if ($catid) 72 { 73 $ids = explode( ',', $catid ); 74 JArrayHelper::toInteger( $ids ); 75 $catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')'; 76 } 77 if ($secid) 78 { 79 $ids = explode( ',', $secid ); 80 JArrayHelper::toInteger( $ids ); 81 $secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')'; 82 } 83 84 // Content Items only 85 $query = 'SELECT a.*, ' . 86 ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'. 87 ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'. 88 ' FROM #__content AS a' . 89 ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . 90 ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . 91 ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . 92 ' WHERE '. $where .' AND s.id > 0' . 93 ($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : ''). 94 ($catid ? $catCondition : ''). 95 ($secid ? $secCondition : ''). 96 ($show_front == '0' ? ' AND f.content_id IS NULL ' : ''). 97 ' AND s.published = 1' . 98 ' AND cc.published = 1' . 99 ' ORDER BY '. $ordering; 100 $db->setQuery($query, 0, $count); 101 $rows = $db->loadObjectList(); 102 103 $i = 0; 104 $lists = array(); 105 foreach ( $rows as $row ) 106 { 107 if($row->access <= $aid) 108 { 109 $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)); 110 } else { 111 $lists[$i]->link = JRoute::_('index.php?option=com_user&view=login'); 112 } 113 $lists[$i]->text = htmlspecialchars( $row->title ); 114 $i++; 115 } 116 117 return $lists; 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |