1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
<?php /** * @version $Id: mod_mostread.php 2483 2006-02-19 06:09:54Z stingrey $ * @package Joomla * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */
// no direct access defined( '_VALID_MOS' ) or die( 'Restricted access' );
global $mosConfig_offset, $mosConfig_live_site;
$type = intval( $params->get( 'type', 1 ) ); $count = intval( $params->get( 'count', 5 ) ); $catid = trim( $params->get( 'catid' ) ); $secid = trim( $params->get( 'secid' ) ); $show_front = $params->get( 'show_front', 1 ); $now = date( 'Y-m-d H:i:s', time() ); $access = !$mainframe->getCfg( 'shownoauth' );
$nullDate = $database->getNullDate(); // select between Content Items, Static Content or both switch ( $type ) { case 2: //Static Content only $query = "SELECT a.id, a.title" . "\n FROM #__content AS a" . "\n WHERE ( a.state = 1 AND a.sectionid = 0 )" . "\n AND ( a.publish_up = '$nullDate' OR a.publish_up <= '$now' )" . "\n AND ( a.publish_down = '$nullDate' OR a.publish_down >= '$now' )" . ( $access ? "\n AND a.access <= $my->gid" : '' ) . "\n ORDER BY a.hits DESC" . "\n LIMIT $count" ; $database->setQuery( $query ); $rows = $database->loadObjectList(); break;
case 3: //Both $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" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid" . "\n WHERE a.state = 1" . "\n AND ( a.publish_up = '$nullDate' OR a.publish_up <= '$now' )" . "\n AND ( a.publish_down = '$nullDate' OR a.publish_down >= '$now' )" . ( $access ? "\n AND a.access <= $my->gid" : '' ) . "\n ORDER BY a.hits DESC" . "\n LIMIT $count" ; $database->setQuery( $query ); $temp = $database->loadObjectList(); $rows = array(); if (count($temp)) { foreach ($temp as $row ) { 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)) { $rows[] = $row; } } } unset($temp); break;
case 1: default: //Content Items only $query = "SELECT a.id, a.title, a.sectionid, a.catid" . "\n FROM #__content AS a" . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id" . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" . "\n INNER JOIN #__sections AS s ON s.id = a.sectionid" . "\n WHERE ( a.state = 1 AND a.sectionid > 0 )" . "\n AND ( a.publish_up = '$nullDate' OR a.publish_up <= '$now' )" . "\n AND ( a.publish_down = '$nullDate' OR a.publish_down >= '$now' )" . ( $access ? "\n AND a.access <= $my->gid AND cc.access <= $my->gid AND s.access <= $my->gid" : '' ) . ( $catid ? "\n AND ( a.catid IN ( $catid ) )" : '' ) . ( $secid ? "\n AND ( a.sectionid IN ( $secid ) )" : '' ) . ( $show_front == "0" ? "\n AND f.content_id IS NULL" : '' ) . "\n AND s.published = 1" . "\n AND cc.published = 1" . "\n ORDER BY a.hits DESC" . "\n LIMIT $count" ; $database->setQuery( $query ); $rows = $database->loadObjectList();
break; }
// needed to reduce queries used by getItemid for Content Items if ( ( $type == 1 ) || ( $type == 3 ) ) { $bs = $mainframe->getBlogSectionCount(); $bc = $mainframe->getBlogCategoryCount(); $gbs = $mainframe->getGlobalBlogSectionCount(); }
// Output ?> <ul class="mostread<?php echo $moduleclass_sfx; ?>"> <?php foreach ($rows as $row) { // get Itemid switch ( $type ) { case 2: $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE type = 'content_typed'" . "\n AND componentid = $row->id" ; $database->setQuery( $query ); $Itemid = $database->loadResult(); break;
case 3: if ( $row->sectionid ) { $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); } else { $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE type = 'content_typed'" . "\n AND componentid = $row->id" ; $database->setQuery( $query ); $Itemid = $database->loadResult(); } break;
case 1: default: $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs ); break; }
// Blank itemid checker for SEF if ($Itemid == NULL) { $Itemid = ''; } else { $Itemid = '&Itemid='.$Itemid; }
$link = sefRelToAbs( 'index.php?option=com_content&task=view&id='. $row->id . $Itemid ); ?> <li class="mostread<?php echo $moduleclass_sfx; ?>"> <a href="<?php echo $link; ?>" class="mostread<?php echo $moduleclass_sfx; ?>"> <?php echo $row->title; ?></a> </li> <?php } ?> </ul>
|