@@ -1,9 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
4 | -else {$limit=124;$delim='';} |
|
2 | +if(strpos($opt,',')) { |
|
3 | + list($limit,$delim) = explode(',', $opt); |
|
4 | +} elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} else {$limit=124;$delim='';} |
|
5 | 5 | |
6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
6 | +if($delim==='') { |
|
7 | + $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
8 | +} |
|
7 | 9 | $limit = (int)$limit; |
8 | 10 | |
9 | 11 | $content = $modx->filter->parseDocumentSource($value); |
@@ -11,8 +13,9 @@ discard block |
||
11 | 13 | $content = strip_tags($content); |
12 | 14 | |
13 | 15 | $content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
14 | -if(preg_match('/\s+/',$content)) |
|
16 | +if(preg_match('/\s+/',$content)) { |
|
15 | 17 | $content = preg_replace('/\s+/',' ',$content); |
18 | +} |
|
16 | 19 | $content = trim($content); |
17 | 20 | |
18 | 21 | $pos = $modx->filter->strpos($content, $delim); |
@@ -21,23 +24,35 @@ discard block |
||
21 | 24 | $_ = explode($delim, $content); |
22 | 25 | $text = ''; |
23 | 26 | foreach($_ as $v) { |
24 | - if($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
27 | + if($limit <= $modx->filter->strlen($text.$v.$delim)) { |
|
28 | + break; |
|
29 | + } |
|
25 | 30 | $text .= $v.$delim; |
26 | 31 | } |
27 | - if($text) $content = $text; |
|
28 | -} |
|
32 | + if($text) { |
|
33 | + $content = $text; |
|
34 | + } |
|
35 | + } |
|
29 | 36 | |
30 | 37 | if($limit<$modx->filter->strlen($content) && strpos($content,' ')!==false) { |
31 | 38 | $_ = explode(' ', $content); |
32 | 39 | $text = ''; |
33 | 40 | foreach($_ as $v) { |
34 | - if($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
41 | + if($limit <= $modx->filter->strlen($text.$v.' ')) { |
|
42 | + break; |
|
43 | + } |
|
35 | 44 | $text .= $v . ' '; |
36 | 45 | } |
37 | - if($text!=='') $content = $text; |
|
38 | -} |
|
46 | + if($text!=='') { |
|
47 | + $content = $text; |
|
48 | + } |
|
49 | + } |
|
39 | 50 | |
40 | -if($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
41 | -if($modx->filter->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
51 | +if($limit < $modx->filter->strlen($content)) { |
|
52 | + $content = $modx->filter->substr($content, 0, $limit); |
|
53 | +} |
|
54 | +if($modx->filter->substr($content,-1)==$delim) { |
|
55 | + $content = rtrim($content,$delim) . $delim; |
|
56 | +} |
|
42 | 57 | |
43 | 58 | return $content; |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | public $ds; // datasource |
16 | 17 | public $id; |
@@ -72,7 +73,8 @@ discard block |
||
72 | 73 | */ |
73 | 74 | public $cdelim; |
74 | 75 | |
75 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
76 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
77 | + { |
|
76 | 78 | global $__DataGridCnt; |
77 | 79 | |
78 | 80 | // set id |
@@ -88,11 +90,13 @@ discard block |
||
88 | 90 | $this->pagerLocation = 'top-right'; |
89 | 91 | } |
90 | 92 | |
91 | - public function setDataSource($ds) { |
|
93 | + public function setDataSource($ds) |
|
94 | + { |
|
92 | 95 | $this->ds = $ds; |
93 | 96 | } |
94 | 97 | |
95 | - public function render() { |
|
98 | + public function render() |
|
99 | + { |
|
96 | 100 | global $modx; |
97 | 101 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
98 | 102 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -127,7 +131,9 @@ discard block |
||
127 | 131 | |
128 | 132 | if($this->_isDataset && !$this->columns) { |
129 | 133 | $cols = $modx->db->numFields($this->ds); |
130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
134 | + for($i = 0; $i < $cols; $i++) { |
|
135 | + $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
136 | + } |
|
131 | 137 | } |
132 | 138 | |
133 | 139 | // start grid |
@@ -207,7 +213,8 @@ discard block |
||
207 | 213 | |
208 | 214 | // format column values |
209 | 215 | |
210 | - public function RenderRowFnc($n, $row) { |
|
216 | + public function RenderRowFnc($n, $row) |
|
217 | + { |
|
211 | 218 | if($this->_alt == 0) { |
212 | 219 | $Style = $this->_itemStyle; |
213 | 220 | $Class = $this->_itemClass; |
@@ -237,7 +244,8 @@ discard block |
||
237 | 244 | return $o; |
238 | 245 | } |
239 | 246 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
247 | + public function formatColumnValue($row, $value, $type, &$align) |
|
248 | + { |
|
241 | 249 | if(strpos($type, ":") !== false) { |
242 | 250 | list($type, $type_format) = explode(":", $type, 2); |
243 | 251 | } |
@@ -3,7 +3,8 @@ discard block |
||
3 | 3 | global $ContextMenuCnt; |
4 | 4 | $ContextMenuCnt = 0; |
5 | 5 | |
6 | -class ContextMenu { |
|
6 | +class ContextMenu |
|
7 | +{ |
|
7 | 8 | public $id; |
8 | 9 | /** |
9 | 10 | * @var string |
@@ -18,7 +19,8 @@ discard block |
||
18 | 19 | */ |
19 | 20 | public $width = 120; |
20 | 21 | |
21 | - public function __construct($id = '', $width = 120, $visible = false) { |
|
22 | + public function __construct($id = '', $width = 120, $visible = false) |
|
23 | + { |
|
22 | 24 | global $ContextMenuCnt; |
23 | 25 | $ContextMenuCnt++; |
24 | 26 | $this->html = ""; |
@@ -27,7 +29,8 @@ discard block |
||
27 | 29 | $this->id = $id ? $id : "cntxMnu" . $ContextMenuCnt; // set id |
28 | 30 | } |
29 | 31 | |
30 | - public function addItem($text, $action = "", $img = "", $disabled = 0) { |
|
32 | + public function addItem($text, $action = "", $img = "", $disabled = 0) |
|
33 | + { |
|
31 | 34 | global $base_url, $_style; |
32 | 35 | if($disabled) { |
33 | 36 | return; |
@@ -52,13 +55,15 @@ discard block |
||
52 | 55 | $this->html .= $img . ' ' . $text . '</div>'; |
53 | 56 | } |
54 | 57 | |
55 | - public function addSeparator() { |
|
58 | + public function addSeparator() |
|
59 | + { |
|
56 | 60 | $this->html .= " |
57 | 61 | <div class='cntxMnuSeparator'></div> |
58 | 62 | "; |
59 | 63 | } |
60 | 64 | |
61 | - public function render() { |
|
65 | + public function render() |
|
66 | + { |
|
62 | 67 | global $ContextMenuScript; |
63 | 68 | |
64 | 69 | $html = $ContextMenuScript . "<div id='" . $this->id . "' class='contextMenu' style='width:" . $this->width . "px; visibility:" . ($this->visible ? 'visible' : 'hidden') . "'>" . $this->html . "</div>"; |
@@ -66,7 +71,8 @@ discard block |
||
66 | 71 | return $html; |
67 | 72 | } |
68 | 73 | |
69 | - public function getClientScriptObject() { |
|
74 | + public function getClientScriptObject() |
|
75 | + { |
|
70 | 76 | return "getCntxMenu('" . $this->id . "')"; |
71 | 77 | } |
72 | 78 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | public $ds; // datasource |
16 | 17 | public $pageSize; |
@@ -31,7 +32,8 @@ discard block |
||
31 | 32 | public $renderPagerFnc; |
32 | 33 | public $renderPagerFncArgs; |
33 | 34 | |
34 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
35 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
36 | + { |
|
35 | 37 | global $_PAGE; // use view state object |
36 | 38 | |
37 | 39 | global $__DataSetPagerCnt; |
@@ -61,35 +63,42 @@ discard block |
||
61 | 63 | $this->pager = ''; |
62 | 64 | } |
63 | 65 | |
64 | - public function getRenderedPager() { |
|
66 | + public function getRenderedPager() |
|
67 | + { |
|
65 | 68 | return $this->pager; |
66 | 69 | } |
67 | 70 | |
68 | - public function getRenderedRows() { |
|
71 | + public function getRenderedRows() |
|
72 | + { |
|
69 | 73 | return $this->rows; |
70 | 74 | } |
71 | 75 | |
72 | - public function setDataSource($ds) { |
|
76 | + public function setDataSource($ds) |
|
77 | + { |
|
73 | 78 | $this->ds = $ds; |
74 | 79 | } |
75 | 80 | |
76 | - public function setPageSize($ps) { |
|
81 | + public function setPageSize($ps) |
|
82 | + { |
|
77 | 83 | $this->pageSize = $ps; |
78 | 84 | } |
79 | 85 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
86 | + public function setRenderRowFnc($fncName, $args = "") |
|
87 | + { |
|
81 | 88 | $this->renderRowFnc = &$fncName; |
82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
83 | 90 | |
84 | 91 | |
85 | 92 | } |
86 | 93 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
95 | + { |
|
88 | 96 | $this->renderPagerFnc = $fncName; |
89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
90 | 98 | } |
91 | 99 | |
92 | - public function render() { |
|
100 | + public function render() |
|
101 | + { |
|
93 | 102 | global $modx, $_PAGE; |
94 | 103 | |
95 | 104 | $isDataset = $modx->db->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
143 | 152 | } |
144 | 153 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
154 | + foreach($_GET as $n => $v) { |
|
155 | + if($n != 'dpgn' . $this->id) { |
|
146 | 156 | $i++; |
157 | + } |
|
147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
148 | 159 | } |
149 | 160 | if($i >= 1) { |
@@ -9,39 +9,27 @@ discard block |
||
9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
10 | 10 | unset($_POST); |
11 | 11 | |
12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
13 | -{ |
|
12 | +if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) { |
|
14 | 13 | $htaccess = $modx->config['base_path'] . '.htaccess'; |
15 | 14 | $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
16 | 15 | $dir = '/' . trim($modx->config['base_url'],'/'); |
17 | - if(is_file($htaccess)) |
|
18 | - { |
|
16 | + if(is_file($htaccess)) { |
|
19 | 17 | $_ = file_get_contents($htaccess); |
20 | - if(strpos($_,'RewriteBase')===false) |
|
21 | - { |
|
18 | + if(strpos($_,'RewriteBase')===false) { |
|
22 | 19 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
23 | - } |
|
24 | - elseif(is_writable($htaccess)) |
|
25 | - { |
|
20 | + } elseif(is_writable($htaccess)) { |
|
26 | 21 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
27 | - if(!@file_put_contents($htaccess,$_)) |
|
28 | - { |
|
22 | + if(!@file_put_contents($htaccess,$_)) { |
|
29 | 23 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
30 | 24 | } |
31 | 25 | } |
32 | - } |
|
33 | - elseif(is_file($sample_htaccess)) |
|
34 | - { |
|
35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
36 | - { |
|
26 | + } elseif(is_file($sample_htaccess)) { |
|
27 | + if(!@rename($sample_htaccess,$htaccess)) { |
|
37 | 28 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
38 | - } |
|
39 | - elseif($modx->config['base_url']!=='/') |
|
40 | - { |
|
29 | + } elseif($modx->config['base_url']!=='/') { |
|
41 | 30 | $_ = file_get_contents($htaccess); |
42 | 31 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
43 | - if(!@file_put_contents($htaccess,$_)) |
|
44 | - { |
|
32 | + if(!@file_put_contents($htaccess,$_)) { |
|
45 | 33 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
46 | 34 | } |
47 | 35 | } |
@@ -70,7 +58,7 @@ discard block |
||
70 | 58 | foreach ($data as $k => $v) { |
71 | 59 | switch ($k) { |
72 | 60 | case 'settings_version':{ |
73 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
61 | + if($modx->getVersionData('version')!=$data['settings_version']) { |
|
74 | 62 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
75 | 63 | $v = $modx->getVersionData('version'); |
76 | 64 | } |
@@ -131,7 +119,9 @@ discard block |
||
131 | 119 | |
132 | 120 | $modx->config[$k] = $v; |
133 | 121 | |
134 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
122 | + if(!empty($k)) { |
|
123 | + $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
124 | + } |
|
135 | 125 | } |
136 | 126 | |
137 | 127 | // Run a single query to save all the values |
@@ -145,8 +135,11 @@ discard block |
||
145 | 135 | $oldtemplate = (int)$data['old_template']; |
146 | 136 | $tbl = $modx->getFullTableName('site_content'); |
147 | 137 | $reset = $data['reset_template']; |
148 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
149 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
138 | + if($reset==1) { |
|
139 | + $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
140 | + } else if($reset==2) { |
|
141 | + $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
142 | + } |
|
150 | 143 | } |
151 | 144 | |
152 | 145 | // empty cache |
@@ -177,7 +177,9 @@ discard block |
||
177 | 177 | // save selected system events |
178 | 178 | $formEventList = array(); |
179 | 179 | foreach ($sysevents as $evtId) { |
180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
180 | + if(!preg_match('@^[1-9][0-9]*$@',$evtId)) { |
|
181 | + $evtId = getEventIdByName($evtId); |
|
182 | + } |
|
181 | 183 | if ($mode == '101') { |
182 | 184 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
183 | 185 | } else { |
@@ -203,10 +205,14 @@ discard block |
||
203 | 205 | $dbEventList = array(); |
204 | 206 | $del = array(); |
205 | 207 | while($row = $modx->db->getRow($rs)) { |
206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
208 | + if(!in_array($row['evtid'], $evtids)) { |
|
209 | + $del[] = $row['evtid']; |
|
210 | + } |
|
207 | 211 | } |
208 | 212 | |
209 | - if(empty($del)) return; |
|
213 | + if(empty($del)) { |
|
214 | + return; |
|
215 | + } |
|
210 | 216 | |
211 | 217 | foreach($del as $delid) { |
212 | 218 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
@@ -218,7 +224,9 @@ discard block |
||
218 | 224 | global $modx; |
219 | 225 | static $eventIds=array(); |
220 | 226 | |
221 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
227 | + if(isset($eventIds[$name])) { |
|
228 | + return $eventIds[$name]; |
|
229 | + } |
|
222 | 230 | |
223 | 231 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
224 | 232 | while ($row = $modx->db->getRow($rs)) { |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
4 | 4 | } |
5 | 5 | |
6 | 6 | unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes |
7 | 7 | |
8 | -if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { |
|
8 | +if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { |
|
9 | 9 | // seems to be a new install - send the user to the configuration page |
10 | 10 | exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>'); |
11 | 11 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $_SESSION['nrnewmessages'] = 0; |
17 | 17 | |
18 | 18 | // setup message info |
19 | -if($modx->hasPermission('messages')) { |
|
19 | +if($modx->hasPermission('messages')) { |
|
20 | 20 | include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); |
21 | 21 | $_SESSION['nrtotalmessages'] = $nrtotalmessages; |
22 | 22 | $_SESSION['nrnewmessages'] = $nrnewmessages; |
@@ -32,46 +32,46 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | // setup icons |
35 | -if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { |
|
35 | +if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { |
|
36 | 36 | $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; |
37 | 37 | $ph['SecurityIcon'] = wrapIcon($icon, 75); |
38 | 38 | } |
39 | -if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { |
|
39 | +if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { |
|
40 | 40 | $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; |
41 | 41 | $ph['WebUserIcon'] = wrapIcon($icon, 99); |
42 | 42 | } |
43 | -if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { |
|
43 | +if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { |
|
44 | 44 | $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; |
45 | 45 | $ph['ModulesIcon'] = wrapIcon($icon, 106); |
46 | 46 | } |
47 | -if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { |
|
47 | +if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { |
|
48 | 48 | $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; |
49 | 49 | $ph['ResourcesIcon'] = wrapIcon($icon, 76); |
50 | 50 | } |
51 | -if($modx->hasPermission('bk_manager')) { |
|
51 | +if($modx->hasPermission('bk_manager')) { |
|
52 | 52 | $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; |
53 | 53 | $ph['BackupIcon'] = wrapIcon($icon, 93); |
54 | 54 | } |
55 | -if($modx->hasPermission('help')) { |
|
55 | +if($modx->hasPermission('help')) { |
|
56 | 56 | $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; |
57 | 57 | $ph['HelpIcon'] = wrapIcon($icon, 9); |
58 | 58 | } |
59 | 59 | // do some config checks |
60 | -if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { |
|
60 | +if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { |
|
61 | 61 | include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); |
62 | - if($config_check_results != $_lang['configcheck_ok']) { |
|
62 | + if($config_check_results != $_lang['configcheck_ok']) { |
|
63 | 63 | $ph['config_check_results'] = $config_check_results; |
64 | 64 | $ph['config_display'] = 'block'; |
65 | - } else { |
|
65 | + } else { |
|
66 | 66 | $ph['config_display'] = 'none'; |
67 | 67 | } |
68 | -} else { |
|
68 | +} else { |
|
69 | 69 | $ph['config_display'] = 'none'; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Check logout-reminder |
73 | -if(isset($_SESSION['show_logout_reminder'])) { |
|
74 | - switch($_SESSION['show_logout_reminder']['type']) { |
|
73 | +if(isset($_SESSION['show_logout_reminder'])) { |
|
74 | + switch($_SESSION['show_logout_reminder']['type']) { |
|
75 | 75 | case 'logout_reminder': |
76 | 76 | $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); |
77 | 77 | $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | $ph['show_logout_reminder'] = 'block'; |
81 | 81 | unset($_SESSION['show_logout_reminder']); |
82 | -} else { |
|
82 | +} else { |
|
83 | 83 | $ph['show_logout_reminder'] = 'none'; |
84 | 84 | } |
85 | 85 | |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'"; |
141 | 141 | $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC'); |
142 | 142 | |
143 | -if($modx->db->getRecordCount($rs) < 1) { |
|
143 | +if($modx->db->getRecordCount($rs) < 1) { |
|
144 | 144 | $html = '<p>[%no_active_users_found%]</p>'; |
145 | -} else { |
|
145 | +} else { |
|
146 | 146 | include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
147 | 147 | $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; |
148 | 148 | $ph['now'] = strftime('%H:%M:%S', $now); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $userList = array(); |
169 | 169 | $userCount = array(); |
170 | 170 | // Create userlist with session-count first before output |
171 | - while($activeusers = $modx->db->getRow($rs)) { |
|
171 | + while($activeusers = $modx->db->getRow($rs)) { |
|
172 | 172 | $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; |
173 | 173 | |
174 | 174 | $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $currentaction |
187 | 187 | ); |
188 | 188 | } |
189 | - foreach($userList as $params) { |
|
189 | + foreach($userList as $params) { |
|
190 | 190 | $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; |
191 | 191 | $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params); |
192 | 192 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | // invoke event OnManagerWelcomePrerender |
233 | 233 | $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender'); |
234 | -if(is_array($evtOut)) { |
|
234 | +if(is_array($evtOut)) { |
|
235 | 235 | $output = implode('', $evtOut); |
236 | 236 | $ph['OnManagerWelcomePrerender'] = $output; |
237 | 237 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | 'body' => '<div class="widget-stage">[+RecentInfo+]</div>', |
341 | 341 | 'hide'=>'0' |
342 | 342 | ); |
343 | -if ($modx->config['rss_url_news']) { |
|
343 | +if ($modx->config['rss_url_news']) { |
|
344 | 344 | $widgets['news'] = array( |
345 | 345 | 'menuindex' => '40', |
346 | 346 | 'id' => 'news', |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | 'hide'=>'0' |
352 | 352 | ); |
353 | 353 | } |
354 | -if ($modx->config['rss_url_security']) { |
|
354 | +if ($modx->config['rss_url_security']) { |
|
355 | 355 | $widgets['security'] = array( |
356 | 356 | 'menuindex' => '50', |
357 | 357 | 'id' => 'security', |
@@ -365,29 +365,29 @@ discard block |
||
365 | 365 | |
366 | 366 | // invoke OnManagerWelcomeHome event |
367 | 367 | $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets)); |
368 | -if(is_array($sitewidgets)) { |
|
368 | +if(is_array($sitewidgets)) { |
|
369 | 369 | $newwidgets = array(); |
370 | - foreach($sitewidgets as $widget){ |
|
370 | + foreach($sitewidgets as $widget) { |
|
371 | 371 | $newwidgets = array_merge($newwidgets, unserialize($widget)); |
372 | 372 | } |
373 | 373 | $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets; |
374 | 374 | } |
375 | 375 | |
376 | -usort($widgets, function ($a, $b) { |
|
376 | +usort($widgets, function ($a, $b){ |
|
377 | 377 | return $a['menuindex'] - $b['menuindex']; |
378 | 378 | }); |
379 | 379 | |
380 | 380 | $tpl = getTplWidget(); |
381 | 381 | $output = ''; |
382 | -foreach($widgets as $widget) { |
|
383 | - if ($widget['hide'] != '1'){ |
|
382 | +foreach($widgets as $widget) { |
|
383 | + if ($widget['hide'] != '1') { |
|
384 | 384 | $output .= $modx->parseText($tpl, $widget); |
385 | 385 | } |
386 | 386 | } |
387 | 387 | $ph['widgets'] = $output; |
388 | 388 | |
389 | 389 | // load template |
390 | -if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { |
|
390 | +if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { |
|
391 | 391 | $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; |
392 | 392 | } |
393 | 393 | |
@@ -395,26 +395,28 @@ discard block |
||
395 | 395 | $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target); |
396 | 396 | $target = $modx->mergeSettingsContent($target); |
397 | 397 | |
398 | -if(substr($target, 0, 1) === '@') { |
|
399 | - if(substr($target, 0, 6) === '@CHUNK') { |
|
398 | +if(substr($target, 0, 1) === '@') { |
|
399 | + if(substr($target, 0, 6) === '@CHUNK') { |
|
400 | 400 | $content = $modx->getChunk(trim(substr($target, 7))); |
401 | - } elseif(substr($target, 0, 5) === '@FILE') { |
|
401 | + } elseif(substr($target, 0, 5) === '@FILE') { |
|
402 | 402 | $content = file_get_contents(trim(substr($target, 6))); |
403 | - } else { |
|
403 | + } else { |
|
404 | 404 | $content = ''; |
405 | 405 | } |
406 | -} else { |
|
406 | +} else { |
|
407 | 407 | $chunk = $modx->getChunk($target); |
408 | - if($chunk !== false && !empty($chunk)) { |
|
408 | + if($chunk !== false && !empty($chunk)) { |
|
409 | 409 | $content = $chunk; |
410 | - } elseif(is_file(MODX_BASE_PATH . $target)) { |
|
410 | + } elseif(is_file(MODX_BASE_PATH . $target)) { |
|
411 | 411 | $content = file_get_contents(MODX_BASE_PATH . $target); |
412 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { |
|
412 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { |
|
413 | 413 | $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); |
414 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible |
|
414 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) { |
|
415 | + // ClipperCMS compatible |
|
415 | 416 | { |
416 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
417 | - } else { |
|
417 | + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
418 | + } |
|
419 | + } else { |
|
418 | 420 | $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); |
419 | 421 | } |
420 | 422 | } |
@@ -423,7 +425,7 @@ discard block |
||
423 | 425 | $content = $modx->mergeConditionalTagsContent($content); |
424 | 426 | $content = $modx->mergeSettingsContent($content); |
425 | 427 | $content = $modx->parseText($content, $ph); |
426 | -if(strpos($content, '[+') !== false) { |
|
428 | +if(strpos($content, '[+') !== false) { |
|
427 | 429 | $modx->toPlaceholders($ph); |
428 | 430 | $content = $modx->mergePlaceholderContent($content); |
429 | 431 | } |
@@ -432,7 +434,7 @@ discard block |
||
432 | 434 | $content = $modx->parseText($content, $_style, '[&', '&]'); |
433 | 435 | $content = $modx->cleanUpMODXTags($content); //cleanup |
434 | 436 | |
435 | -if($js = $modx->getRegisteredClientScripts()) { |
|
437 | +if($js = $modx->getRegisteredClientScripts()) { |
|
436 | 438 | $content .= $js; |
437 | 439 | } |
438 | 440 | |
@@ -442,7 +444,9 @@ discard block |
||
442 | 444 | // <a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a> |
443 | 445 | // <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a> |
444 | 446 | //</span> |
445 | -function getTplWidget() { // recent document info |
|
447 | +function getTplWidget() |
|
448 | +{ |
|
449 | +// recent document info |
|
446 | 450 | return ' |
447 | 451 | <div class="[+cols+]" id="[+id+]"> |
448 | 452 | <div class="card"[+cardAttr+]> |
@@ -453,7 +457,9 @@ discard block |
||
453 | 457 | '; |
454 | 458 | } |
455 | 459 | |
456 | -function getRecentInfo() { // recent document info |
|
460 | +function getRecentInfo() |
|
461 | +{ |
|
462 | +// recent document info |
|
457 | 463 | global $modx; |
458 | 464 | |
459 | 465 | $modx->addSnippet('recentInfoList', 'getRecentInfoList'); |
@@ -479,12 +485,13 @@ discard block |
||
479 | 485 | return $html; |
480 | 486 | } |
481 | 487 | |
482 | -function getRecentInfoList() { |
|
488 | +function getRecentInfoList() |
|
489 | +{ |
|
483 | 490 | global $modx; |
484 | 491 | |
485 | 492 | $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10); |
486 | 493 | |
487 | - if($modx->db->getRecordCount($rs) < 1) { |
|
494 | + if($modx->db->getRecordCount($rs) < 1) { |
|
488 | 495 | return '<tr><td>[%no_activity_message%]</td></tr>'; |
489 | 496 | } |
490 | 497 | |
@@ -494,22 +501,22 @@ discard block |
||
494 | 501 | $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; |
495 | 502 | |
496 | 503 | $output = array(); |
497 | - while($ph = $modx->db->getRow($rs)) { |
|
504 | + while($ph = $modx->db->getRow($rs)) { |
|
498 | 505 | $docid = $ph['id']; |
499 | 506 | $_ = $modx->getUserInfo($ph['editedby']); |
500 | 507 | $ph['username'] = $_['username']; |
501 | 508 | |
502 | - if($ph['deleted'] == 1) { |
|
509 | + if($ph['deleted'] == 1) { |
|
503 | 510 | $ph['status'] = 'deleted text-danger'; |
504 | - } elseif($ph['published'] == 0) { |
|
511 | + } elseif($ph['published'] == 0) { |
|
505 | 512 | $ph['status'] = 'unpublished font-italic text-muted'; |
506 | - } else { |
|
513 | + } else { |
|
507 | 514 | $ph['status'] = 'published'; |
508 | 515 | } |
509 | 516 | |
510 | - if($modx->hasPermission('edit_document')) { |
|
517 | + if($modx->hasPermission('edit_document')) { |
|
511 | 518 | $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']); |
512 | - } else { |
|
519 | + } else { |
|
513 | 520 | $ph['edit_btn'] = ''; |
514 | 521 | } |
515 | 522 | |
@@ -522,40 +529,40 @@ discard block |
||
522 | 529 | $preview_disabled |
523 | 530 | ), $btntpl['preview_btn']); |
524 | 531 | |
525 | - if($modx->hasPermission('delete_document')) { |
|
526 | - if($ph['deleted'] == 0) { |
|
532 | + if($modx->hasPermission('delete_document')) { |
|
533 | + if($ph['deleted'] == 0) { |
|
527 | 534 | $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; |
528 | - } else { |
|
535 | + } else { |
|
529 | 536 | $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; |
530 | 537 | } |
531 | 538 | $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn); |
532 | - } else { |
|
539 | + } else { |
|
533 | 540 | $ph['delete_btn'] = ''; |
534 | 541 | } |
535 | 542 | |
536 | - if($ph['deleted'] == 1 && $ph['published'] == 0) { |
|
543 | + if($ph['deleted'] == 1 && $ph['published'] == 0) { |
|
537 | 544 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
538 | - } elseif($ph['deleted'] == 1 && $ph['published'] == 1) { |
|
545 | + } elseif($ph['deleted'] == 1 && $ph['published'] == 1) { |
|
539 | 546 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
540 | - } elseif($ph['deleted'] == 0 && $ph['published'] == 0) { |
|
547 | + } elseif($ph['deleted'] == 0 && $ph['published'] == 0) { |
|
541 | 548 | $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
542 | - } else { |
|
549 | + } else { |
|
543 | 550 | $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
544 | 551 | } |
545 | 552 | $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn); |
546 | 553 | |
547 | 554 | $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>'); |
548 | 555 | |
549 | - if($ph['longtitle'] == '') { |
|
556 | + if($ph['longtitle'] == '') { |
|
550 | 557 | $ph['longtitle'] = '(<i>[%not_set%]</i>)'; |
551 | 558 | } |
552 | - if($ph['description'] == '') { |
|
559 | + if($ph['description'] == '') { |
|
553 | 560 | $ph['description'] = '(<i>[%not_set%]</i>)'; |
554 | 561 | } |
555 | - if($ph['introtext'] == '') { |
|
562 | + if($ph['introtext'] == '') { |
|
556 | 563 | $ph['introtext'] = '(<i>[%not_set%]</i>)'; |
557 | 564 | } |
558 | - if($ph['alias'] == '') { |
|
565 | + if($ph['alias'] == '') { |
|
559 | 566 | $ph['alias'] = '(<i>[%not_set%]</i>)'; |
560 | 567 | } |
561 | 568 | |
@@ -564,7 +571,8 @@ discard block |
||
564 | 571 | return implode("\n", $output); |
565 | 572 | } |
566 | 573 | |
567 | -function getRecentInfoRowTpl() { |
|
574 | +function getRecentInfoRowTpl() |
|
575 | +{ |
|
568 | 576 | $tpl = ' |
569 | 577 | <tr> |
570 | 578 | <td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td> |
@@ -593,11 +601,13 @@ discard block |
||
593 | 601 | } |
594 | 602 | |
595 | 603 | // setup icons |
596 | -function wrapIcon($i, $action) { |
|
604 | +function wrapIcon($i, $action) |
|
605 | +{ |
|
597 | 606 | return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i); |
598 | 607 | } |
599 | 608 | |
600 | -function getStartUpScript() { |
|
609 | +function getStartUpScript() |
|
610 | +{ |
|
601 | 611 | $script = ' |
602 | 612 | <script type="text/javascript"> |
603 | 613 | function hideConfigCheckWarning(key) { |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | * see: rss_fetch.inc for a simpler interface with integrated caching support |
32 | 32 | * |
33 | 33 | */ |
34 | -class MagpieRSS { |
|
34 | +class MagpieRSS |
|
35 | +{ |
|
35 | 36 | var $parser; |
36 | 37 | |
37 | 38 | var $current_item = array(); // item currently being parsed |
@@ -143,7 +144,8 @@ discard block |
||
143 | 144 | $this->normalize(); |
144 | 145 | } |
145 | 146 | |
146 | - function feed_start_element($p, $element, &$attrs) { |
|
147 | + function feed_start_element($p, $element, &$attrs) |
|
148 | + { |
|
147 | 149 | $el = $element = strtolower($element); |
148 | 150 | $attrs = array_change_key_case($attrs, CASE_LOWER); |
149 | 151 | |
@@ -163,12 +165,10 @@ discard block |
||
163 | 165 | if ( $el == 'rdf' ) { |
164 | 166 | $this->feed_type = RSS; |
165 | 167 | $this->feed_version = '1.0'; |
166 | - } |
|
167 | - elseif ( $el == 'rss' ) { |
|
168 | + } elseif ( $el == 'rss' ) { |
|
168 | 169 | $this->feed_type = RSS; |
169 | 170 | $this->feed_version = $attrs['version']; |
170 | - } |
|
171 | - elseif ( $el == 'feed' ) { |
|
171 | + } elseif ( $el == 'feed' ) { |
|
172 | 172 | $this->feed_type = ATOM; |
173 | 173 | $this->feed_version = $attrs['version']; |
174 | 174 | $this->inchannel = true; |
@@ -176,12 +176,9 @@ discard block |
||
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
179 | - if ( $el == 'channel' ) |
|
180 | - { |
|
179 | + if ( $el == 'channel' ) { |
|
181 | 180 | $this->inchannel = true; |
182 | - } |
|
183 | - elseif ($el == 'item' or $el == 'entry' ) |
|
184 | - { |
|
181 | + } elseif ($el == 'item' or $el == 'entry' ) { |
|
185 | 182 | $this->initem = true; |
186 | 183 | if ( isset($attrs['rdf:about']) ) { |
187 | 184 | $this->current_item['about'] = $attrs['rdf:about']; |
@@ -193,22 +190,17 @@ discard block |
||
193 | 190 | elseif ( |
194 | 191 | $this->feed_type == RSS and |
195 | 192 | $this->current_namespace == '' and |
196 | - $el == 'textinput' ) |
|
197 | - { |
|
193 | + $el == 'textinput' ) { |
|
198 | 194 | $this->intextinput = true; |
199 | - } |
|
200 | - |
|
201 | - elseif ( |
|
195 | + } elseif ( |
|
202 | 196 | $this->feed_type == RSS and |
203 | 197 | $this->current_namespace == '' and |
204 | - $el == 'image' ) |
|
205 | - { |
|
198 | + $el == 'image' ) { |
|
206 | 199 | $this->inimage = true; |
207 | 200 | } |
208 | 201 | |
209 | 202 | # handle atom content constructs |
210 | - elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
211 | - { |
|
203 | + elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { |
|
212 | 204 | // avoid clashing w/ RSS mod_content |
213 | 205 | if ($el == 'content' ) { |
214 | 206 | $el = 'atom_content'; |
@@ -220,8 +212,7 @@ discard block |
||
220 | 212 | } |
221 | 213 | |
222 | 214 | // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
223 | - elseif ($this->feed_type == ATOM and $this->incontent ) |
|
224 | - { |
|
215 | + elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
225 | 216 | // if tags are inlined, then flatten |
226 | 217 | $attrs_str = implode(' ', |
227 | 218 | array_map('map_attrs', |
@@ -237,13 +228,10 @@ discard block |
||
237 | 228 | // Magpie treats link elements of type rel='alternate' |
238 | 229 | // as being equivalent to RSS's simple link element. |
239 | 230 | // |
240 | - elseif ($this->feed_type == ATOM and $el == 'link' ) |
|
241 | - { |
|
242 | - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
|
243 | - { |
|
231 | + elseif ($this->feed_type == ATOM and $el == 'link' ) { |
|
232 | + if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) { |
|
244 | 233 | $link_el = 'link'; |
245 | - } |
|
246 | - else { |
|
234 | + } else { |
|
247 | 235 | $link_el = 'link_' . $attrs['rel']; |
248 | 236 | } |
249 | 237 | |
@@ -257,63 +245,51 @@ discard block |
||
257 | 245 | |
258 | 246 | |
259 | 247 | |
260 | - function feed_cdata ($p, $text) { |
|
261 | - if ($this->feed_type == ATOM and $this->incontent) |
|
262 | - { |
|
248 | + function feed_cdata ($p, $text) |
|
249 | + { |
|
250 | + if ($this->feed_type == ATOM and $this->incontent) { |
|
263 | 251 | $this->append_content( $text ); |
264 | - } |
|
265 | - else { |
|
252 | + } else { |
|
266 | 253 | $current_el = implode('_', array_reverse($this->stack)); |
267 | 254 | $this->append($current_el, $text); |
268 | 255 | } |
269 | 256 | } |
270 | 257 | |
271 | - function feed_end_element ($p, $el) { |
|
258 | + function feed_end_element ($p, $el) |
|
259 | + { |
|
272 | 260 | $el = strtolower($el); |
273 | 261 | |
274 | - if ( $el == 'item' or $el == 'entry' ) |
|
275 | - { |
|
262 | + if ( $el == 'item' or $el == 'entry' ) { |
|
276 | 263 | $this->items[] = $this->current_item; |
277 | 264 | $this->current_item = array(); |
278 | 265 | $this->initem = false; |
279 | - } |
|
280 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
281 | - { |
|
266 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) { |
|
282 | 267 | $this->intextinput = false; |
283 | - } |
|
284 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
285 | - { |
|
268 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) { |
|
286 | 269 | $this->inimage = false; |
287 | - } |
|
288 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
289 | - { |
|
270 | + } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { |
|
290 | 271 | $this->incontent = false; |
291 | - } |
|
292 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
293 | - { |
|
272 | + } elseif ($el == 'channel' or $el == 'feed' ) { |
|
294 | 273 | $this->inchannel = false; |
295 | - } |
|
296 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
274 | + } elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
297 | 275 | // balance tags properly |
298 | 276 | // note: i don't think this is actually neccessary |
299 | - if ( $this->stack[0] == $el ) |
|
300 | - { |
|
277 | + if ( $this->stack[0] == $el ) { |
|
301 | 278 | $this->append_content("</$el>"); |
302 | - } |
|
303 | - else { |
|
279 | + } else { |
|
304 | 280 | $this->append_content("<$el />"); |
305 | 281 | } |
306 | 282 | |
307 | 283 | array_shift( $this->stack ); |
308 | - } |
|
309 | - else { |
|
284 | + } else { |
|
310 | 285 | array_shift( $this->stack ); |
311 | 286 | } |
312 | 287 | |
313 | 288 | $this->current_namespace = false; |
314 | 289 | } |
315 | 290 | |
316 | - function concat (&$str1, $str2="") { |
|
291 | + function concat (&$str1, $str2="") |
|
292 | + { |
|
317 | 293 | if (!isset($str1) ) { |
318 | 294 | $str1=""; |
319 | 295 | } |
@@ -322,53 +298,46 @@ discard block |
||
322 | 298 | |
323 | 299 | |
324 | 300 | |
325 | - function append_content($text) { |
|
301 | + function append_content($text) |
|
302 | + { |
|
326 | 303 | if ( $this->initem ) { |
327 | 304 | $this->concat( $this->current_item[ $this->incontent ], $text ); |
328 | - } |
|
329 | - elseif ( $this->inchannel ) { |
|
305 | + } elseif ( $this->inchannel ) { |
|
330 | 306 | $this->concat( $this->channel[ $this->incontent ], $text ); |
331 | 307 | } |
332 | 308 | } |
333 | 309 | |
334 | 310 | // smart append - field and namespace aware |
335 | - function append($el, $text) { |
|
311 | + function append($el, $text) |
|
312 | + { |
|
336 | 313 | if (!$el) { |
337 | 314 | return; |
338 | 315 | } |
339 | - if ( $this->current_namespace ) |
|
340 | - { |
|
316 | + if ( $this->current_namespace ) { |
|
341 | 317 | if ( $this->initem ) { |
342 | 318 | $this->concat( |
343 | 319 | $this->current_item[ $this->current_namespace ][ $el ], $text); |
344 | - } |
|
345 | - elseif ($this->inchannel) { |
|
320 | + } elseif ($this->inchannel) { |
|
346 | 321 | $this->concat( |
347 | 322 | $this->channel[ $this->current_namespace][ $el ], $text ); |
348 | - } |
|
349 | - elseif ($this->intextinput) { |
|
323 | + } elseif ($this->intextinput) { |
|
350 | 324 | $this->concat( |
351 | 325 | $this->textinput[ $this->current_namespace][ $el ], $text ); |
352 | - } |
|
353 | - elseif ($this->inimage) { |
|
326 | + } elseif ($this->inimage) { |
|
354 | 327 | $this->concat( |
355 | 328 | $this->image[ $this->current_namespace ][ $el ], $text ); |
356 | 329 | } |
357 | - } |
|
358 | - else { |
|
330 | + } else { |
|
359 | 331 | if ( $this->initem ) { |
360 | 332 | $this->concat( |
361 | 333 | $this->current_item[ $el ], $text); |
362 | - } |
|
363 | - elseif ($this->intextinput) { |
|
334 | + } elseif ($this->intextinput) { |
|
364 | 335 | $this->concat( |
365 | 336 | $this->textinput[ $el ], $text ); |
366 | - } |
|
367 | - elseif ($this->inimage) { |
|
337 | + } elseif ($this->inimage) { |
|
368 | 338 | $this->concat( |
369 | 339 | $this->image[ $el ], $text ); |
370 | - } |
|
371 | - elseif ($this->inchannel) { |
|
340 | + } elseif ($this->inchannel) { |
|
372 | 341 | $this->concat( |
373 | 342 | $this->channel[ $el ], $text ); |
374 | 343 | } |
@@ -376,16 +345,19 @@ discard block |
||
376 | 345 | } |
377 | 346 | } |
378 | 347 | |
379 | - function normalize () { |
|
348 | + function normalize () |
|
349 | + { |
|
380 | 350 | // if atom populate rss fields |
381 | 351 | if ( $this->is_atom() ) { |
382 | 352 | $this->channel['description'] = $this->channel['tagline']; |
383 | 353 | for ( $i = 0; $i < count($this->items); $i++) { |
384 | 354 | $item = $this->items[$i]; |
385 | - if ( isset($item['summary']) ) |
|
386 | - $item['description'] = $item['summary']; |
|
387 | - if ( isset($item['atom_content'])) |
|
388 | - $item['content']['encoded'] = $item['atom_content']; |
|
355 | + if ( isset($item['summary']) ) { |
|
356 | + $item['description'] = $item['summary']; |
|
357 | + } |
|
358 | + if ( isset($item['atom_content'])) { |
|
359 | + $item['content']['encoded'] = $item['atom_content']; |
|
360 | + } |
|
389 | 361 | |
390 | 362 | $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified']; |
391 | 363 | if ( $atom_date ) { |
@@ -397,23 +369,23 @@ discard block |
||
397 | 369 | |
398 | 370 | $this->items[$i] = $item; |
399 | 371 | } |
400 | - } |
|
401 | - elseif ( $this->is_rss() ) { |
|
372 | + } elseif ( $this->is_rss() ) { |
|
402 | 373 | $this->channel['tagline'] = $this->channel['description']; |
403 | 374 | for ( $i = 0; $i < count($this->items); $i++) { |
404 | 375 | $item = $this->items[$i]; |
405 | - if ( isset($item['description'])) |
|
406 | - $item['summary'] = $item['description']; |
|
407 | - if ( isset($item['content']['encoded'] ) ) |
|
408 | - $item['atom_content'] = $item['content']['encoded']; |
|
376 | + if ( isset($item['description'])) { |
|
377 | + $item['summary'] = $item['description']; |
|
378 | + } |
|
379 | + if ( isset($item['content']['encoded'] ) ) { |
|
380 | + $item['atom_content'] = $item['content']['encoded']; |
|
381 | + } |
|
409 | 382 | |
410 | 383 | if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) { |
411 | 384 | $epoch = @parse_w3cdtf($item['dc']['date']); |
412 | 385 | if ($epoch and $epoch > 0) { |
413 | 386 | $item['date_timestamp'] = $epoch; |
414 | 387 | } |
415 | - } |
|
416 | - elseif ( isset($item['pubdate']) ) { |
|
388 | + } elseif ( isset($item['pubdate']) ) { |
|
417 | 389 | $epoch = @strtotime($item['pubdate']); |
418 | 390 | if ($epoch > 0) { |
419 | 391 | $item['date_timestamp'] = $epoch; |
@@ -426,20 +398,20 @@ discard block |
||
426 | 398 | } |
427 | 399 | |
428 | 400 | |
429 | - function is_rss () { |
|
401 | + function is_rss () |
|
402 | + { |
|
430 | 403 | if ( $this->feed_type == RSS ) { |
431 | 404 | return $this->feed_version; |
432 | - } |
|
433 | - else { |
|
405 | + } else { |
|
434 | 406 | return false; |
435 | 407 | } |
436 | 408 | } |
437 | 409 | |
438 | - function is_atom() { |
|
410 | + function is_atom() |
|
411 | + { |
|
439 | 412 | if ( $this->feed_type == ATOM ) { |
440 | 413 | return $this->feed_version; |
441 | - } |
|
442 | - else { |
|
414 | + } else { |
|
443 | 415 | return false; |
444 | 416 | } |
445 | 417 | } |
@@ -448,11 +420,11 @@ discard block |
||
448 | 420 | * return XML parser, and possibly re-encoded source |
449 | 421 | * |
450 | 422 | */ |
451 | - function create_parser($source, $out_enc, $in_enc, $detect) { |
|
423 | + function create_parser($source, $out_enc, $in_enc, $detect) |
|
424 | + { |
|
452 | 425 | if ( substr(phpversion(),0,1) == 5) { |
453 | 426 | $parser = $this->php5_create_parser($in_enc, $detect); |
454 | - } |
|
455 | - else { |
|
427 | + } else { |
|
456 | 428 | list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
457 | 429 | } |
458 | 430 | if ($out_enc) { |
@@ -472,12 +444,12 @@ discard block |
||
472 | 444 | * All hail libxml2! |
473 | 445 | * |
474 | 446 | */ |
475 | - function php5_create_parser($in_enc, $detect) { |
|
447 | + function php5_create_parser($in_enc, $detect) |
|
448 | + { |
|
476 | 449 | // by default php5 does a fine job of detecting input encodings |
477 | 450 | if(!$detect && $in_enc) { |
478 | 451 | return xml_parser_create($in_enc); |
479 | - } |
|
480 | - else { |
|
452 | + } else { |
|
481 | 453 | return xml_parser_create(''); |
482 | 454 | } |
483 | 455 | } |
@@ -497,7 +469,8 @@ discard block |
||
497 | 469 | * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
498 | 470 | * |
499 | 471 | */ |
500 | - function php4_create_parser($source, $in_enc, $detect) { |
|
472 | + function php4_create_parser($source, $in_enc, $detect) |
|
473 | + { |
|
501 | 474 | if ( !$detect ) { |
502 | 475 | return array(xml_parser_create($in_enc), $source); |
503 | 476 | } |
@@ -506,8 +479,7 @@ discard block |
||
506 | 479 | if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
507 | 480 | $in_enc = strtoupper($m[1]); |
508 | 481 | $this->source_encoding = $in_enc; |
509 | - } |
|
510 | - else { |
|
482 | + } else { |
|
511 | 483 | $in_enc = 'UTF-8'; |
512 | 484 | } |
513 | 485 | } |
@@ -522,7 +494,7 @@ discard block |
||
522 | 494 | // cast the XML to a known encoding |
523 | 495 | // @see http://php.net/iconv |
524 | 496 | |
525 | - if (function_exists('iconv')) { |
|
497 | + if (function_exists('iconv')) { |
|
526 | 498 | $encoded_source = iconv($in_enc,'UTF-8', $source); |
527 | 499 | if ($encoded_source) { |
528 | 500 | return array(xml_parser_create('UTF-8'), $encoded_source); |
@@ -546,25 +518,25 @@ discard block |
||
546 | 518 | return array(xml_parser_create(), $source); |
547 | 519 | } |
548 | 520 | |
549 | - function known_encoding($enc) { |
|
521 | + function known_encoding($enc) |
|
522 | + { |
|
550 | 523 | $enc = strtoupper($enc); |
551 | 524 | if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) { |
552 | 525 | return $enc; |
553 | - } |
|
554 | - else { |
|
526 | + } else { |
|
555 | 527 | return false; |
556 | 528 | } |
557 | 529 | } |
558 | 530 | |
559 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
531 | + function error ($errormsg, $lvl=E_USER_WARNING) |
|
532 | + { |
|
560 | 533 | // append PHP's error message if track_errors enabled |
561 | 534 | if ( isset($php_errormsg) ) { |
562 | 535 | $errormsg .= " ($php_errormsg)"; |
563 | 536 | } |
564 | 537 | if ( MAGPIE_DEBUG ) { |
565 | 538 | trigger_error( $errormsg, $lvl); |
566 | - } |
|
567 | - else { |
|
539 | + } else { |
|
568 | 540 | error_log( $errormsg, 0); |
569 | 541 | } |
570 | 542 | |
@@ -579,7 +551,8 @@ discard block |
||
579 | 551 | |
580 | 552 | } // end class RSS |
581 | 553 | |
582 | -function map_attrs($k, $v) { |
|
554 | +function map_attrs($k, $v) |
|
555 | +{ |
|
583 | 556 | return "$k=\"$v\""; |
584 | 557 | } |
585 | 558 | |
@@ -591,9 +564,10 @@ discard block |
||
591 | 564 | define('CASE_LOWER', 0); |
592 | 565 | |
593 | 566 | |
594 | - function array_change_key_case($array, $case=CASE_LOWER) { |
|
567 | + function array_change_key_case($array, $case=CASE_LOWER) |
|
568 | + { |
|
595 | 569 | $output = array(); |
596 | - switch($case){ |
|
570 | + switch($case) { |
|
597 | 571 | case CASE_LOWER: |
598 | 572 | $cmd='strtolower'; |
599 | 573 | break; |
@@ -16,12 +16,14 @@ discard block |
||
16 | 16 | * |
17 | 17 | */ |
18 | 18 | |
19 | -class RSSCache { |
|
19 | +class RSSCache |
|
20 | +{ |
|
20 | 21 | var $BASE_CACHE = './cache'; // where the cache files are stored |
21 | 22 | var $MAX_AGE = 3600; // when are files stale, default one hour |
22 | 23 | var $ERROR = ""; // accumulate error messages |
23 | 24 | |
24 | - function __construct($base='', $age='') { |
|
25 | + function __construct($base='', $age='') |
|
26 | + { |
|
25 | 27 | if ( $base ) { |
26 | 28 | $this->BASE_CACHE = $base; |
27 | 29 | } |
@@ -48,7 +50,8 @@ discard block |
||
48 | 50 | Input: url from wich the rss file was fetched |
49 | 51 | Output: true on sucess |
50 | 52 | \*=======================================================================*/ |
51 | - function set ($url, $rss) { |
|
53 | + function set ($url, $rss) |
|
54 | + { |
|
52 | 55 | $this->ERROR = ""; |
53 | 56 | $cache_file = $this->file_name( $url ); |
54 | 57 | $fp = @fopen( $cache_file, 'w' ); |
@@ -74,7 +77,8 @@ discard block |
||
74 | 77 | Input: url from wich the rss file was fetched |
75 | 78 | Output: cached object on HIT, false on MISS |
76 | 79 | \*=======================================================================*/ |
77 | - function get ($url) { |
|
80 | + function get ($url) |
|
81 | + { |
|
78 | 82 | $this->ERROR = ""; |
79 | 83 | $cache_file = $this->file_name( $url ); |
80 | 84 | |
@@ -110,7 +114,8 @@ discard block |
||
110 | 114 | Input: url from wich the rss file was fetched |
111 | 115 | Output: cached object on HIT, false on MISS |
112 | 116 | \*=======================================================================*/ |
113 | - function check_cache ( $url ) { |
|
117 | + function check_cache ( $url ) |
|
118 | + { |
|
114 | 119 | $this->ERROR = ""; |
115 | 120 | $filename = $this->file_name( $url ); |
116 | 121 | |
@@ -122,26 +127,24 @@ discard block |
||
122 | 127 | if ( $this->MAX_AGE > $age ) { |
123 | 128 | // object exists and is current |
124 | 129 | return 'HIT'; |
125 | - } |
|
126 | - else { |
|
130 | + } else { |
|
127 | 131 | // object exists but is old |
128 | 132 | return 'STALE'; |
129 | 133 | } |
130 | - } |
|
131 | - else { |
|
134 | + } else { |
|
132 | 135 | // object does not exist |
133 | 136 | return 'MISS'; |
134 | 137 | } |
135 | 138 | } |
136 | 139 | |
137 | - function cache_age( $cache_key ) { |
|
140 | + function cache_age( $cache_key ) |
|
141 | + { |
|
138 | 142 | $filename = $this->file_name( $url ); |
139 | 143 | if ( file_exists( $filename ) ) { |
140 | 144 | $mtime = filemtime( $filename ); |
141 | 145 | $age = time() - $mtime; |
142 | 146 | return $age; |
143 | - } |
|
144 | - else { |
|
147 | + } else { |
|
145 | 148 | return -1; |
146 | 149 | } |
147 | 150 | } |
@@ -149,14 +152,16 @@ discard block |
||
149 | 152 | /*=======================================================================*\ |
150 | 153 | Function: serialize |
151 | 154 | \*=======================================================================*/ |
152 | - function serialize ( $rss ) { |
|
155 | + function serialize ( $rss ) |
|
156 | + { |
|
153 | 157 | return serialize( $rss ); |
154 | 158 | } |
155 | 159 | |
156 | 160 | /*=======================================================================*\ |
157 | 161 | Function: unserialize |
158 | 162 | \*=======================================================================*/ |
159 | - function unserialize ( $data ) { |
|
163 | + function unserialize ( $data ) |
|
164 | + { |
|
160 | 165 | return unserialize( $data ); |
161 | 166 | } |
162 | 167 | |
@@ -166,7 +171,8 @@ discard block |
||
166 | 171 | Input: url from wich the rss file was fetched |
167 | 172 | Output: a file name |
168 | 173 | \*=======================================================================*/ |
169 | - function file_name ($url) { |
|
174 | + function file_name ($url) |
|
175 | + { |
|
170 | 176 | $filename = md5( $url ); |
171 | 177 | return implode( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) ); |
172 | 178 | } |
@@ -175,7 +181,8 @@ discard block |
||
175 | 181 | Function: error |
176 | 182 | Purpose: register error |
177 | 183 | \*=======================================================================*/ |
178 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
184 | + function error ($errormsg, $lvl=E_USER_WARNING) |
|
185 | + { |
|
179 | 186 | // append PHP's error message if track_errors enabled |
180 | 187 | if ( isset($php_errormsg) ) { |
181 | 188 | $errormsg .= " ($php_errormsg)"; |
@@ -183,13 +190,13 @@ discard block |
||
183 | 190 | $this->ERROR = $errormsg; |
184 | 191 | if ( MAGPIE_DEBUG ) { |
185 | 192 | trigger_error( $errormsg, $lvl); |
186 | - } |
|
187 | - else { |
|
193 | + } else { |
|
188 | 194 | error_log( $errormsg, 0); |
189 | 195 | } |
190 | 196 | } |
191 | 197 | |
192 | - function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
198 | + function debug ($debugmsg, $lvl=E_USER_NOTICE) |
|
199 | + { |
|
193 | 200 | if ( MAGPIE_DEBUG ) { |
194 | 201 | $this->error("MagpieRSS [debug] $debugmsg", $lvl); |
195 | 202 | } |