| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 global $mosConfig_offset, $mosConfig_live_site; 20 21 $type = intval( $params->get( 'type', 1 ) ); 22 $count = intval( $params->get( 'count', 5 ) ); 23 $catid = trim( $params->get( 'catid' ) ); 24 $secid = trim( $params->get( 'secid' ) ); 25 $hits = trim( $params->get( 'hits' ) ); 26 $show_front = $params->get( 'show_front', 1 ); 27 $class_sfx = $params->get( 'moduleclass_sfx' ); 28 29 $now = date( 'Y-m-d H:i:s', time()+$mosConfig_offset*60*60 ); 30 31 $access = !$mainframe->getCfg( 'shownoauth' ); 32 33 // select between Content Items, Static Content or both 34 switch ( $type ) { 35 case 2: 36 $query = "SELECT a.id, a.title, a.hits" 37 . "\n FROM #__content AS a" 38 . "\n WHERE ( a.state = '1' AND a.checked_out = '0' AND a.sectionid = '0' )" 39 . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" 40 . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" 41 . ( $access ? "\n AND a.access <= '". $my->gid ."'" : '' ) 42 . "\n ORDER BY a.hits DESC LIMIT $count" 43 ; 44 $database->setQuery( $query ); 45 $rows = $database->loadObjectList(); 46 break; 47 48 case 3: 49 $query = "SELECT a.id, a.title, a.sectionid, a.hits" 50 . "\n FROM #__content AS a" 51 . "\n WHERE ( a.state = '1' AND a.checked_out = '0' )" 52 . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" 53 . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" 54 . ( $access ? "\n AND a.access <= '". $my->gid ."'" : '' ) 55 . "\n ORDER BY a.hits DESC LIMIT $count" 56 ; 57 $database->setQuery( $query ); 58 $rows = $database->loadObjectList(); 59 break; 60 61 case 1: 62 default: 63 $query = "SELECT a.id, a.title, a.sectionid, a.catid, a.hits" 64 . "\n FROM #__content AS a" 65 . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id" 66 . "\n WHERE ( a.state = '1' AND a.checked_out = '0' AND a.sectionid > '0' )" 67 . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" 68 . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" 69 . ( $access ? "\n AND a.access <= '". $my->gid ."'" : '' ) 70 . ( $catid ? "\n AND ( a.catid IN (". $catid .") )" : '' ) 71 . ( $secid ? "\n AND ( a.sectionid IN (". $secid .") )" : '' ) 72 . ( $show_front == "0" ? "\n AND f.content_id IS NULL" : '' ) 73 . "\n ORDER BY a.hits DESC LIMIT $count" 74 ; 75 $database->setQuery( $query ); 76 $rows = $database->loadObjectList(); 77 78 break; 79 } 80 81 // needed to reduce queries used by getItemid for Content Items 82 if ( ( $type == 1 ) || ( $type == 3 ) ) { 83 require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); 84 $handler =& new contentHandler(); 85 $bs = $handler->getBlogSectionCount(); 86 $bc = $handler->getBlogCategoryCount(); 87 $gbs = $handler->getGlobalBlogSectionCount(); 88 } 89 90 // Output 91 ?> 92 <ul class="mostread<?php echo $class_sfx; ?>"> 93 <?php 94 $menuhandler =& mosMenuHandler::getInstance(); 95 if ($rows) foreach ($rows as $row) { 96 // get Itemid 97 switch ( $type ) { 98 case 2: 99 $Itemid = $menuhandler->getIDByTypeCid ('content_typed', $row->id); 100 break; 101 102 case 3: 103 if ( $row->sectionid ) { 104 $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); 105 } 106 else $Itemid = $menuhandler->getIDByTypeCid ('content_typed', $row->id); 107 break; 108 109 case 1: 110 default: 111 $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); 112 break; 113 } 114 115 // Blank itemid checker for SEF 116 if ($Itemid == NULL) { 117 $Itemid = ''; 118 } else { 119 $Itemid = '&Itemid='.$Itemid; 120 } 121 122 $link = sefRelToAbs( 'index.php?option=com_content&task=view&id='. $row->id . $Itemid ); 123 ?> 124 <li class="latestnews<?php echo $class_sfx; ?>"> 125 <a href="<?php echo $link; ?>" class="mostread<?php echo $class_sfx; ?>"> 126 <?php echo $row->title; ?> 127 </a> 128 <?php 129 $tag = $row->hits>1 ? ' hits)' : ' hit)'; 130 if($hits) echo ' ('.$row->hits.$tag ?> 131 </li> 132 <?php 133 } 134 ?> 135 </ul>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |