[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: mod_latestnews.php 5071 2006-09-15 16:16:55Z friesengeist $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 6 * @license http://www.gnu.org/copyleft/gpl.html 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( '_VALID_MOS' ) or die( 'Restricted access' ); 16 17 global $mosConfig_offset, $mosConfig_live_site, $mainframe; 18 19 $type = intval( $params->get( 'type', 1 ) ); 20 $count = intval( $params->get( 'count', 5 ) ); 21 $catid = trim( $params->get( 'catid' ) ); 22 $secid = trim( $params->get( 'secid' ) ); 23 $show_front = $params->get( 'show_front', 1 ); 24 25 $now = _CURRENT_SERVER_TIME; 26 $access = !$mainframe->getCfg( 'shownoauth' ); 27 $nullDate = $database->getNullDate(); 28 29 // select between Content Items, Static Content or both 30 switch ( $type ) { 31 case 2: 32 //Static Content only 33 $query = "SELECT a.id, a.title" 34 . "\n FROM #__content AS a" 35 . "\n WHERE ( a.state = 1 AND a.sectionid = 0 )" 36 . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )" 37 . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )" 38 . ( $access ? "\n AND a.access <= " . (int) $my->gid : '' ) 39 . "\n ORDER BY a.created DESC" 40 ; 41 $database->setQuery( $query, 0, $count ); 42 $rows = $database->loadObjectList(); 43 break; 44 45 case 3: 46 //Both 47 $whereCatid = ''; 48 if ($catid) { 49 $catids = explode( ',', $catid ); 50 mosArrayToInts( $catids ); 51 $whereCatid = "\n AND ( a.catid=" . implode( " OR a.catid=", $catids ) . " )"; 52 } 53 $whereSecid = ''; 54 if ($secid) { 55 $secids = explode( ',', $secid ); 56 mosArrayToInts( $secids ); 57 $whereSecid = "\n AND ( a.sectionid=" . implode( " OR a.sectionid=", $secids ) . " )"; 58 } 59 $query = "SELECT a.id, a.title, a.sectionid, a.catid, cc.access AS cat_access, s.access AS sec_access, cc.published AS cat_state, s.published AS sec_state" 60 . "\n FROM #__content AS a" 61 . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id" 62 . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" 63 . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid" 64 . "\n WHERE a.state = 1" 65 . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )" 66 . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )" 67 . ( $access ? "\n AND a.access <= " . (int) $my->gid : '' ) 68 . $whereCatid 69 . $whereSecid 70 . ( $show_front == '0' ? "\n AND f.content_id IS NULL" : '' ) 71 . "\n ORDER BY a.created DESC" 72 ; 73 $database->setQuery( $query, 0, $count ); 74 $temp = $database->loadObjectList(); 75 76 $rows = array(); 77 if (count($temp)) { 78 foreach ($temp as $row ) { 79 if (($row->cat_state == 1 || $row->cat_state == '') && ($row->sec_state == 1 || $row->sec_state == '') && ($row->cat_access <= $my->gid || $row->cat_access == '' || !$access) && ($row->sec_access <= $my->gid || $row->sec_access == '' || !$access)) { 80 $rows[] = $row; 81 } 82 } 83 } 84 unset($temp); 85 break; 86 87 case 1: 88 default: 89 //Content Items only 90 $whereCatid = ''; 91 if ($catid) { 92 $catids = explode( ',', $catid ); 93 mosArrayToInts( $catids ); 94 $whereCatid = "\n AND ( a.catid=" . implode( " OR a.catid=", $catids ) . " )"; 95 } 96 $whereSecid = ''; 97 if ($secid) { 98 $secids = explode( ',', $secid ); 99 mosArrayToInts( $secids ); 100 $whereSecid = "\n AND ( a.sectionid=" . implode( " OR a.sectionid=", $secids ) . " )"; 101 } 102 $query = "SELECT a.id, a.title, a.sectionid, a.catid" 103 . "\n FROM #__content AS a" 104 . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id" 105 . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" 106 . "\n INNER JOIN #__sections AS s ON s.id = a.sectionid" 107 . "\n WHERE ( a.state = 1 AND a.sectionid > 0 )" 108 . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )" 109 . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )" 110 . ( $access ? "\n AND a.access <= " . (int) $my->gid . " AND cc.access <= " . (int) $my->gid . " AND s.access <= " . (int) $my->gid : '' ) 111 . $whereCatid 112 . $whereSecid 113 . ( $show_front == '0' ? "\n AND f.content_id IS NULL" : '' ) 114 . "\n AND s.published = 1" 115 . "\n AND cc.published = 1" 116 . "\n ORDER BY a.created DESC" 117 ; 118 $database->setQuery( $query, 0, $count ); 119 $rows = $database->loadObjectList(); 120 break; 121 } 122 123 124 // needed to reduce queries used by getItemid for Content Items 125 if ( ( $type == 1 ) || ( $type == 3 ) ) { 126 $bs = $mainframe->getBlogSectionCount(); 127 $bc = $mainframe->getBlogCategoryCount(); 128 $gbs = $mainframe->getGlobalBlogSectionCount(); 129 } 130 131 // Output 132 ?> 133 <ul class="latestnews<?php echo $moduleclass_sfx; ?>"> 134 <?php 135 foreach ( $rows as $row ) { 136 // get Itemid 137 switch ( $type ) { 138 case 2: 139 $query = "SELECT id" 140 . "\n FROM #__menu" 141 . "\n WHERE type = 'content_typed'" 142 . "\n AND componentid = " . (int) $row->id 143 ; 144 $database->setQuery( $query ); 145 $Itemid = $database->loadResult(); 146 break; 147 148 case 3: 149 if ( $row->sectionid ) { 150 $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); 151 } else { 152 $query = "SELECT id" 153 . "\n FROM #__menu" 154 . "\n WHERE type = 'content_typed'" 155 . "\n AND componentid = " . (int) $row->id 156 ; 157 $database->setQuery( $query ); 158 $Itemid = $database->loadResult(); 159 } 160 break; 161 162 case 1: 163 default: 164 $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); 165 break; 166 } 167 168 // Blank itemid checker for SEF 169 if ($Itemid == NULL) { 170 $Itemid = ''; 171 } else { 172 $Itemid = '&Itemid='. $Itemid; 173 } 174 175 $link = sefRelToAbs( 'index.php?option=com_content&task=view&id='. $row->id . $Itemid ); 176 ?> 177 <li class="latestnews<?php echo $moduleclass_sfx; ?>"> 178 <a href="<?php echo $link; ?>" class="latestnews<?php echo $moduleclass_sfx; ?>"> 179 <?php echo $row->title; ?></a> 180 </li> 181 <?php 182 } 183 ?> 184 </ul>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |