@@ -9,21 +9,24 @@ |
||
9 | 9 | $table_prefix = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_'; |
10 | 10 | } else { |
11 | 11 | $database_name = ''; |
12 | - if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
|
13 | - else { |
|
12 | + if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { |
|
13 | + $upgradeable = 0; |
|
14 | + } else { |
|
14 | 15 | // Include the file so we can test its validity |
15 | 16 | include($base_path.MGR_DIR.'/includes/config.inc.php'); |
16 | 17 | // We need to have all connection settings - but prefix may be empty so we have to ignore it |
17 | 18 | if ($dbase) { |
18 | 19 | $database_name = trim($dbase, '`'); |
19 | - if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
|
20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
23 | - else |
|
24 | - $upgradeable = 1; |
|
20 | + if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
21 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
22 | + } elseif (! mysqli_select_db($conn, trim($dbase, '`'))) { |
|
23 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
24 | + } else { |
|
25 | + $upgradeable = 1; |
|
26 | + } |
|
27 | + } else { |
|
28 | + $upgradable= 2; |
|
25 | 29 | } |
26 | - else $upgradable= 2; |
|
27 | 30 | } |
28 | 31 | } |
29 | 32 |
@@ -1,8 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | $userid = (int)$value; |
3 | 3 | if (!isset($modx->filter->cache['ui'][$userid])) { |
4 | - if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
|
5 | - else $user = $modx->getUserInfo($userid); |
|
4 | + if ($userid < 0) { |
|
5 | + $user = $modx->getWebUserInfo(abs($userid)); |
|
6 | + } else { |
|
7 | + $user = $modx->getUserInfo($userid); |
|
8 | + } |
|
6 | 9 | $modx->filter->cache['ui'][$userid] = $user; |
7 | 10 | } else { |
8 | 11 | $user = $modx->filter->cache['ui'][$userid]; |
@@ -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; |
@@ -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 | } |
@@ -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 |
@@ -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 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
4 | -}else{ |
|
4 | +} else { |
|
5 | 5 | define('MGR_DIR', 'manager'); |
6 | 6 | } |
7 | 7 | |
@@ -58,13 +58,15 @@ discard block |
||
58 | 58 | |
59 | 59 | // get base path and url |
60 | 60 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
61 | -if (count($a) > 1) |
|
61 | +if (count($a) > 1) { |
|
62 | 62 | array_pop($a); |
63 | +} |
|
63 | 64 | $url = implode("install", $a); |
64 | 65 | reset($a); |
65 | 66 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
66 | -if (count($a) > 1) |
|
67 | +if (count($a) > 1) { |
|
67 | 68 | array_pop($a); |
69 | +} |
|
68 | 70 | $pth = implode("install", $a); |
69 | 71 | unset ($a); |
70 | 72 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
86 | 88 | $create = true; |
87 | 89 | } else { |
88 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
90 | + if (function_exists('mysqli_set_charset')) { |
|
91 | + mysqli_set_charset($conn, $database_charset); |
|
92 | + } |
|
89 | 93 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
90 | 94 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
91 | 95 | } |
@@ -132,7 +136,8 @@ discard block |
||
132 | 136 | * @param string $propertyString |
133 | 137 | * @return array |
134 | 138 | */ |
135 | - function parseProperties($propertyString) { |
|
139 | + function parseProperties($propertyString) |
|
140 | + { |
|
136 | 141 | $parameter= array (); |
137 | 142 | if (!empty ($propertyString)) { |
138 | 143 | $tmpParams= explode("&", $propertyString); |
@@ -141,11 +146,14 @@ discard block |
||
141 | 146 | if (strpos($tmpParams[$x], '=', 0)) { |
142 | 147 | $pTmp= explode("=", $tmpParams[$x]); |
143 | 148 | $pvTmp= explode(";", trim($pTmp[1])); |
144 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
145 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
149 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
150 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
151 | + } |
|
152 | + //list default |
|
146 | 153 | else |
147 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
148 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
154 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
155 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
156 | + } |
|
149 | 157 | } |
150 | 158 | } |
151 | 159 | } |
@@ -216,7 +224,7 @@ discard block |
||
216 | 224 | // custom or not |
217 | 225 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
218 | 226 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
219 | -}else{ |
|
227 | +} else { |
|
220 | 228 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
221 | 229 | } |
222 | 230 | |
@@ -352,7 +360,9 @@ discard block |
||
352 | 360 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
353 | 361 | return; |
354 | 362 | } |
355 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
363 | + if(!is_null($save_sql_id_as)) { |
|
364 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
365 | + } |
|
356 | 366 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
357 | 367 | } |
358 | 368 | } |
@@ -446,9 +456,9 @@ discard block |
||
446 | 456 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
447 | 457 | $filecontent = $moduleChunk[2]; |
448 | 458 | |
449 | - if (!file_exists($filecontent)) |
|
450 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
451 | - else { |
|
459 | + if (!file_exists($filecontent)) { |
|
460 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
461 | + } else { |
|
452 | 462 | |
453 | 463 | // Create the category if it does not already exist |
454 | 464 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -500,9 +510,9 @@ discard block |
||
500 | 510 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
501 | 511 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
502 | 512 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
503 | - if (!file_exists($filecontent)) |
|
504 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
505 | - else { |
|
513 | + if (!file_exists($filecontent)) { |
|
514 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
515 | + } else { |
|
506 | 516 | |
507 | 517 | // Create the category if it does not already exist |
508 | 518 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -552,9 +562,9 @@ discard block |
||
552 | 562 | // parse comma-separated legacy names and prepare them for sql IN clause |
553 | 563 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
554 | 564 | } |
555 | - if (!file_exists($filecontent)) |
|
556 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
557 | - else { |
|
565 | + if (!file_exists($filecontent)) { |
|
566 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
567 | + } else { |
|
558 | 568 | |
559 | 569 | // disable legacy versions based on legacy_names provided |
560 | 570 | if(!empty($leg_names)) { |
@@ -573,7 +583,7 @@ discard block |
||
573 | 583 | $insert = true; |
574 | 584 | while($row = mysqli_fetch_assoc($rs)) { |
575 | 585 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
576 | - if($row['description'] == $desc){ |
|
586 | + if($row['description'] == $desc) { |
|
577 | 587 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
578 | 588 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
579 | 589 | return; |
@@ -631,9 +641,9 @@ discard block |
||
631 | 641 | $filecontent = $moduleSnippet[2]; |
632 | 642 | $properties = $moduleSnippet[3]; |
633 | 643 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
634 | - if (!file_exists($filecontent)) |
|
635 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
636 | - else { |
|
644 | + if (!file_exists($filecontent)) { |
|
645 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
646 | + } else { |
|
637 | 647 | |
638 | 648 | // Create the category if it does not already exist |
639 | 649 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -741,13 +751,16 @@ discard block |
||
741 | 751 | } |
742 | 752 | |
743 | 753 | // call back function |
744 | -if ($callBackFnc != "") |
|
754 | +if ($callBackFnc != "") { |
|
745 | 755 | $callBackFnc ($sqlParser); |
756 | +} |
|
746 | 757 | |
747 | 758 | // Setup the MODX API -- needed for the cache processor |
748 | 759 | define('MODX_API_MODE', true); |
749 | 760 | define('MODX_BASE_PATH', $base_path); |
750 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
761 | +if (!defined('MODX_MANAGER_PATH')) { |
|
762 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
763 | +} |
|
751 | 764 | $database_type = 'mysqli'; |
752 | 765 | // initiate a new document parser |
753 | 766 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -792,11 +805,12 @@ discard block |
||
792 | 805 | * @param string $old |
793 | 806 | * @return string |
794 | 807 | */ |
795 | -function propUpdate($new,$old){ |
|
808 | +function propUpdate($new,$old) |
|
809 | +{ |
|
796 | 810 | $newArr = parseProperties($new); |
797 | 811 | $oldArr = parseProperties($old); |
798 | - foreach ($oldArr as $k => $v){ |
|
799 | - if (isset($v['0']['options'])){ |
|
812 | + foreach ($oldArr as $k => $v) { |
|
813 | + if (isset($v['0']['options'])) { |
|
800 | 814 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
801 | 815 | } |
802 | 816 | } |
@@ -811,12 +825,17 @@ discard block |
||
811 | 825 | * @param bool|mixed $json |
812 | 826 | * @return string |
813 | 827 | */ |
814 | -function parseProperties($propertyString, $json=false) { |
|
828 | +function parseProperties($propertyString, $json=false) |
|
829 | +{ |
|
815 | 830 | $propertyString = str_replace('{}', '', $propertyString ); |
816 | 831 | $propertyString = str_replace('} {', ',', $propertyString ); |
817 | 832 | |
818 | - if(empty($propertyString)) return array(); |
|
819 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
833 | + if(empty($propertyString)) { |
|
834 | + return array(); |
|
835 | + } |
|
836 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
837 | + return array(); |
|
838 | + } |
|
820 | 839 | |
821 | 840 | $jsonFormat = isJson($propertyString, true); |
822 | 841 | $property = array(); |
@@ -858,7 +877,7 @@ discard block |
||
858 | 877 | |
859 | 878 | } |
860 | 879 | // new json-format |
861 | - } else if(!empty($jsonFormat)){ |
|
880 | + } else if(!empty($jsonFormat)) { |
|
862 | 881 | $property = $jsonFormat; |
863 | 882 | } |
864 | 883 | if ($json) { |
@@ -873,7 +892,8 @@ discard block |
||
873 | 892 | * @param bool $returnData |
874 | 893 | * @return bool|mixed |
875 | 894 | */ |
876 | -function isJson($string, $returnData=false) { |
|
895 | +function isJson($string, $returnData=false) |
|
896 | +{ |
|
877 | 897 | $data = json_decode($string, true); |
878 | 898 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
879 | 899 | } |
@@ -883,7 +903,8 @@ discard block |
||
883 | 903 | * @param SqlParser $sqlParser |
884 | 904 | * @return int |
885 | 905 | */ |
886 | -function getCreateDbCategory($category, $sqlParser) { |
|
906 | +function getCreateDbCategory($category, $sqlParser) |
|
907 | +{ |
|
887 | 908 | $dbase = $sqlParser->dbname; |
888 | 909 | $dbase = '`' . trim($dbase,'`') . '`'; |
889 | 910 | $table_prefix = $sqlParser->prefix; |
@@ -911,7 +932,8 @@ discard block |
||
911 | 932 | * @param string $type |
912 | 933 | * @return string |
913 | 934 | */ |
914 | -function removeDocblock($code, $type) { |
|
935 | +function removeDocblock($code, $type) |
|
936 | +{ |
|
915 | 937 | |
916 | 938 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
917 | 939 | |
@@ -932,8 +954,9 @@ discard block |
||
932 | 954 | default: |
933 | 955 | return $cleaned; |
934 | 956 | }; |
935 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
936 | - return $cleaned; |
|
957 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
958 | + return $cleaned; |
|
959 | + } |
|
937 | 960 | |
938 | 961 | // fileBinding not found - return code incl docblock |
939 | 962 | return $code; |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | * @param string $filename |
6 | 6 | * @return array of keys from a language file |
7 | 7 | */ |
8 | -function get_lang_keys($filename) |
|
9 | -{ |
|
8 | +function get_lang_keys($filename) |
|
9 | +{ |
|
10 | 10 | $file = MODX_MANAGER_PATH . 'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
11 | - if (is_file($file) && is_readable($file)) { |
|
11 | + if (is_file($file) && is_readable($file)) { |
|
12 | 12 | include($file); |
13 | 13 | $out = isset($_lang) ? array_keys($_lang) : array(); |
14 | - } else { |
|
14 | + } else { |
|
15 | 15 | $out = array(); |
16 | 16 | } |
17 | 17 | |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * @param string $key |
25 | 25 | * @return array of languages that define the key in their file |
26 | 26 | */ |
27 | -function get_langs_by_key($key) |
|
28 | -{ |
|
27 | +function get_langs_by_key($key) |
|
28 | +{ |
|
29 | 29 | global $lang_keys; |
30 | 30 | $lang_return = array(); |
31 | - foreach ($lang_keys as $lang => $keys) { |
|
32 | - if (in_array($key, $keys)) { |
|
31 | + foreach ($lang_keys as $lang => $keys) { |
|
32 | + if (in_array($key, $keys)) { |
|
33 | 33 | $lang_return[] = $lang; |
34 | 34 | } |
35 | 35 | } |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | * @param string $selected_lang specify language to select in option list, default none |
47 | 47 | * @return string html option list |
48 | 48 | */ |
49 | -function get_lang_options($key = '', $selected_lang = '') |
|
50 | -{ |
|
49 | +function get_lang_options($key = '', $selected_lang = '') |
|
50 | +{ |
|
51 | 51 | global $lang_keys, $_lang; |
52 | 52 | $lang_options = ''; |
53 | - if (!empty($key)) { |
|
53 | + if (!empty($key)) { |
|
54 | 54 | $languages = get_langs_by_key($key); |
55 | 55 | sort($languages); |
56 | 56 | $lang_options .= '<option value="">' . $_lang['language_title'] . '</option>'; |
57 | 57 | |
58 | - foreach ($languages as $language_name) { |
|
58 | + foreach ($languages as $language_name) { |
|
59 | 59 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
60 | 60 | $lang_options .= '<option value="' . $language_name . '">' . $uclanguage_name . '</option>'; |
61 | 61 | } |
62 | 62 | |
63 | 63 | return $lang_options; |
64 | - } else { |
|
64 | + } else { |
|
65 | 65 | $languages = array_keys($lang_keys); |
66 | 66 | sort($languages); |
67 | - foreach ($languages as $language_name) { |
|
67 | + foreach ($languages as $language_name) { |
|
68 | 68 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
69 | 69 | $sel = $language_name === $selected_lang ? ' selected="selected"' : ''; |
70 | 70 | $lang_options .= '<option value="' . $language_name . '" ' . $sel . '>' . $uclanguage_name . '</option>'; |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | * @param bool $disabled |
82 | 82 | * @return string |
83 | 83 | */ |
84 | -function form_radio($name, $value, $add = '', $disabled = false) |
|
85 | -{ |
|
84 | +function form_radio($name, $value, $add = '', $disabled = false) |
|
85 | +{ |
|
86 | 86 | global ${$name}; |
87 | 87 | $var = ${$name}; |
88 | 88 | $checked = ($var == $value) ? ' checked="checked"' : ''; |
89 | - if ($disabled) { |
|
89 | + if ($disabled) { |
|
90 | 90 | $disabled = ' disabled'; |
91 | - } else { |
|
91 | + } else { |
|
92 | 92 | $disabled = ''; |
93 | 93 | } |
94 | - if ($add) { |
|
94 | + if ($add) { |
|
95 | 95 | $add = ' ' . $add; |
96 | 96 | } |
97 | 97 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param string $object |
105 | 105 | * @return string |
106 | 106 | */ |
107 | -function wrap_label($str = '', $object) |
|
108 | -{ |
|
107 | +function wrap_label($str = '', $object) |
|
108 | +{ |
|
109 | 109 | return "<label>{$object}\n{$str}</label>"; |
110 | 110 | } |
111 | 111 | |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | * @param array $ph |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function parseText($tpl = '', $ph = array()) |
|
118 | -{ |
|
119 | - if (empty($ph) || empty($tpl)) { |
|
117 | +function parseText($tpl = '', $ph = array()) |
|
118 | +{ |
|
119 | + if (empty($ph) || empty($tpl)) { |
|
120 | 120 | return $tpl; |
121 | 121 | } |
122 | 122 | |
123 | - foreach ($ph as $k => $v) { |
|
123 | + foreach ($ph as $k => $v) { |
|
124 | 124 | $k = "[+{$k}+]"; |
125 | 125 | $tpl = str_replace($k, $v, $tpl); |
126 | 126 | } |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param bool $cond |
133 | 133 | * @return string |
134 | 134 | */ |
135 | -function showHide($cond = true) |
|
136 | -{ |
|
135 | +function showHide($cond = true) |
|
136 | +{ |
|
137 | 137 | global $displayStyle; |
138 | 138 | $showHide = $cond ? $displayStyle : 'none'; |
139 | 139 |