Defined Moddynamicxmlsitemaphelper: or Die Class

You might also like

Download as pdf
Download as pdf
You are on page 1of 4

joomla/modules/mod_dynamic_xmlsitemap/helper.

php

1 of 4

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

<?php
/**
* @version
$Id: helper.php 2009-09-17 20:14:40Z diana $
* @package
Dynamic XML Sitemap
* @copyright Copyright (C) 2009-2010 - Diana Scherff (http://www.dianas
cherff.com). All rights reserved.
* @license
GNU/GPL
*/
/// no direct access
defined('_JEXEC') or die('access access');
class modDynamicXmlSitemapHelper
{
//get article data
function dataQuery(&$params)
{
global $mainframe;
$db
=& JFactory::getDBO();
$access
= intval($params->get('access', 1));
if ($access == 0) {
$accesstype = '= 0';
} else {
$accesstype = '>= 0';
}
$query = 'SELECT s.id AS sid, s.alias AS salias, c.id AS catid, c.alia
s AS catalias,'.
' d.id AS id, d.alias AS alias, d.created AS created, d.modified AS
modified'.
' FROM #__sections s'.
' LEFT JOIN #__categories c'.
' ON s.id = c.section'.
' RIGHT JOIN #__content d'.
' ON c.id = d.catid '.
' WHERE d.state = 1'.
' AND d.access '.$accesstype.
' AND c.published = 1'.
' AND c.access '.$accesstype.
' AND s.published = 1'.
' AND s.access '.$accesstype.
' ORDER BY d.ordering';
$db->setQuery($query);
$data = $db->loadObjectList();
return $data;
}
//get category data
function catQuery(&$params)
{
global $mainframe;
$db
=& JFactory::getDBO();
$access
= intval($params->get('access', 1));
if ($access == 0) {
$accesstype = '= 0';
} else {
$accesstype = '>= 0';
}

11/2/2011 7:33 PM

joomla/modules/mod_dynamic_xmlsitemap/helper.php

2 of 4

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

$query = 'SELECT s.id AS sid, s.alias AS salias, c.id AS catid, c.alia


s AS catalias,'.
' FROM #__sections s'.
' LEFT JOIN #__categories c'.
' ON s.id = c.section'.
' WHERE c.published = 1'.
' AND c.access '.$accesstype.
' AND s.published = 1'.
' AND s.access '.$accesstype.
' ORDER BY c.ordering';
$db->setQuery($query);
$catquery = $db->loadObjectList();
return $catquery;
}
//get section data
function secQuery(&$params)
{
global $mainframe;
$db
=& JFactory::getDBO();
$access
= intval($params->get('access', 1));
if ($access == 0) {
$accesstype = '= 0';
} else {
$accesstype = '>= 0';
}
$query = 'SELECT s.id AS sid, s.alias AS salias,'.
' FROM #__sections s'.
' WHERE s.published = 1'.
' AND s.access '.$accesstype.
' ORDER BY s.ordering';
$db->setQuery($query);
$secquery = $db->loadObjectList();
return $secquery;
}
//check if lastmod should be displayed
function lastMod(&$params)
{
global $mainframe;
$lastmod = intval($params->get('lastmod', 1));
return $lastmod;
}
//check if categories & sections should be displayed
function catSec(&$params)
{
global $mainframe;
$catsec = intval($params->get('catsec', 1));
return $catsec;
}
//get and format time offset
function timeOffset()
{
global $mainframe;

11/2/2011 7:33 PM

joomla/modules/mod_dynamic_xmlsitemap/helper.php

3 of 4

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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

$offset_cfg = $mainframe->getCfg('offset');
$pattern1 = '/^[0-9]$/';
$pattern2 = '/[0-9]{2}/';
$pattern3 = '/^\-/';
$pattern5 = '/\-/';
$replacement2 = '-0';
if (preg_match($pattern1, $offset_cfg)) {
if (preg_match($pattern2, $offset_cfg)) {
$offset = '+'.$offset_cfg.':00';
} else {
$offset = '+0'.$offset_cfg.':00';
}
} elseif (preg_match($pattern3, $offset_cfg)) {
if (preg_match($pattern2, $offset_cfg)) {
$offset = $offset_cfg.':00';
} else {
$offset_hrs = preg_replace($pattern5, $replacement2, $offset_cfg);
$offset = $offset_hrs.':00';
}
} else {
$offset = '+00:00';
}
return $offset;
}
//get live_site URL (location of Joomla! installation)
function liveSite(&$params)
{
global $mainframe;
$live_site_cfg = $mainframe->getCfg('live_site');
$live_site_param = trim($params->get('livesite'));
if (empty($live_site_cfg)) {
$site = $live_site_param;
} else {
$site = $live_site_cfg;
}
return $site;
}
//get SEF param and layout type
function sefSetting(&$params)
{
global $mainframe;
//SEF OFF = 0;
//SEF ON, NO SUFFIX, REWRITE = 1;
//SEF ON, SUFFIX, REWRITE = 2;
//SEF ON, NO SUFFIX, NO REWRITE = 3;
//SEF ON, SUFFIX, NO REWRITE = 4;
$global_sef = $mainframe->getCfg('sef');
$global_sefrewrite = $mainframe->getCfg('sef_rewrite');
$global_sefsuffix = $mainframe->getCfg('sef_suffix');
$param_sef = intval($params->get('psef', 10));
if ($param_sef == 0) { //hide SEF
$sef = 0;
} elseif ($param_sef == 2) { //show SEF
if ($global_sefsuffix == 1) { //SEF = 2 OR 4
if ($global_sefrewrite == 1) {
$sef = 2;
} else {
$sef = 4;
}

11/2/2011 7:33 PM

joomla/modules/mod_dynamic_xmlsitemap/helper.php

4 of 4

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

} else { //SEF = 1 OR 3
if ($global_sefrewrite == 1) {
$sef = 1;
} else {
$sef = 3;
}
}
} else { //$param_sef == 1 "global"
if ($global_sef == 0) {
$sef = 0;
} else {
if ($global_sefsuffix == 1) { //SEF = 2 OR 4
if ($global_sefrewrite == 1) {
$sef = 2;
} else {
$sef = 4;
}
} else { //SEF = 1 OR 3
if ($global_sefrewrite == 1) {
$sef = 1;
} else {
$sef = 3;
}
}
}
}
return $sef;
}
//get menu data
function menuQuery(&$params)
{
global $mainframe;
$db
=& JFactory::getDBO();
$access
= intval($params->get('access', 1));
if ($access == 0) {
$accesstype = '= 0';
} else {
$accesstype = '>= 0';
}
$query = 'SELECT id, alias, link, parent, componentid, sublevel, home'
.

230
231
232
233
234
235
236
237
238
239

' FROM #__menu'.


' WHERE published = 1'.
' AND access '.$accesstype.
' ORDER BY ordering';
$db->setQuery($query);
$menu = $db->loadObjectList();
return $menu;
}
}

11/2/2011 7:33 PM

You might also like