@@ -237,6 +237,9 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | |
240 | + /** |
|
241 | + * @param string $pattern |
|
242 | + */ |
|
240 | 243 | function SearchPages($pattern){ |
241 | 244 | global $gp_titles, $gp_index; |
242 | 245 | |
@@ -288,6 +291,10 @@ discard block |
||
288 | 291 | |
289 | 292 | |
290 | 293 | //try to search in the blog |
294 | + |
|
295 | + /** |
|
296 | + * @param string $pattern |
|
297 | + */ |
|
291 | 298 | function SearchBlog($pattern){ |
292 | 299 | global $dataDir, $gp_index, $gp_titles, $config; |
293 | 300 | |
@@ -357,6 +364,10 @@ discard block |
||
357 | 364 | |
358 | 365 | // same as before in SerchPreg() but saves in $this->file |
359 | 366 | // and uses different links for blog findings |
367 | + |
|
368 | + /** |
|
369 | + * @param string $content |
|
370 | + */ |
|
360 | 371 | function findString(&$content, &$pattern, &$title, $link='', $link_query = ''){ |
361 | 372 | |
362 | 373 | $content = str_replace('>','> ',$content); |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | $this->GetConfig(); |
52 | 52 | |
53 | 53 | if( common::LoggedIn() ){ |
54 | - $page->admin_links[] = array('Special_Search','Configuration','cmd=config'); |
|
54 | + $page->admin_links[] = array('Special_Search', 'Configuration', 'cmd=config'); |
|
55 | 55 | $cmd = common::GetCommand(); |
56 | 56 | |
57 | - switch($cmd){ |
|
57 | + switch( $cmd ){ |
|
58 | 58 | case 'save_config': |
59 | 59 | if( $this->SaveConfig() ){ |
60 | 60 | break; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - $query =& $_GET['q']; |
|
70 | + $query = & $_GET['q']; |
|
71 | 71 | |
72 | 72 | echo '<div class="search_results">'; |
73 | 73 | echo '<form action="'.common::GetUrl('Special_Search').'" method="get">'; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | echo '<input name="q" type="text" class="text" value="'.htmlspecialchars($query).'"/>'; |
79 | 79 | echo '<input type="hidden" name="src" value="gadget" /> '; |
80 | 80 | $html = '<input type="submit" name="" class="submit" value="%s" />'; |
81 | - echo gpOutput::GetAddonText('Search',$html); |
|
81 | + echo gpOutput::GetAddonText('Search', $html); |
|
82 | 82 | echo '</h2>'; |
83 | 83 | echo '</form>'; |
84 | 84 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | |
91 | 91 | $pattern = '#('; |
92 | 92 | $bar = ''; |
93 | - foreach($words as $word){ |
|
94 | - $pattern .= $bar.preg_quote($word,'#'); |
|
93 | + foreach( $words as $word ){ |
|
94 | + $pattern .= $bar.preg_quote($word, '#'); |
|
95 | 95 | $bar = '|'; |
96 | 96 | } |
97 | 97 | $pattern .= ')#Si'; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | if( count($this->files) > 0 ){ |
104 | - foreach($this->files as $result){ |
|
104 | + foreach( $this->files as $result ){ |
|
105 | 105 | echo $result; |
106 | 106 | } |
107 | 107 | }else{ |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | include($this->config_file); |
124 | 124 | } |
125 | 125 | |
126 | - $search_config += array('search_blog'=>true,'search_hidden'=>false); |
|
126 | + $search_config += array('search_blog'=>true, 'search_hidden'=>false); |
|
127 | 127 | $this->search_config = $search_config; |
128 | 128 | |
129 | 129 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $search_config['search_blog'] = false; |
143 | 143 | } |
144 | 144 | |
145 | - if( gpFiles::SaveArray($this->config_file,'search_config',$search_config) ){ |
|
145 | + if( gpFiles::SaveArray($this->config_file, 'search_config', $search_config) ){ |
|
146 | 146 | message($langmessage['SAVED']); |
147 | 147 | $this->search_config = $search_config; |
148 | 148 | return true; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | - function Config($array=array()){ |
|
158 | + function Config($array = array()){ |
|
159 | 159 | global $langmessage, $addonFolderName, $gp_index; |
160 | 160 | |
161 | 161 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | echo '</table>'; |
231 | 231 | |
232 | - echo common::Link('Admin_Theme_Content',$langmessage['editable_text'],'cmd=addontext&addon='.urlencode($addonFolderName),' title="'.urlencode($langmessage['editable_text']).'" name="gpabox" '); |
|
232 | + echo common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon='.urlencode($addonFolderName), ' title="'.urlencode($langmessage['editable_text']).'" name="gpabox" '); |
|
233 | 233 | |
234 | 234 | echo '</form>'; |
235 | 235 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | |
245 | 245 | |
246 | 246 | ob_start(); |
247 | - foreach($gp_index as $title => $index){ |
|
248 | - $this->SearchPage($pattern,$title,$index); |
|
247 | + foreach( $gp_index as $title => $index ){ |
|
248 | + $this->SearchPage($pattern, $title, $index); |
|
249 | 249 | } |
250 | 250 | $empty = ob_get_clean(); |
251 | 251 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $this->ReduceResults(); |
254 | 254 | } |
255 | 255 | |
256 | - function SearchPage($pattern,$title,$index){ |
|
256 | + function SearchPage($pattern, $title, $index){ |
|
257 | 257 | global $gp_menu; |
258 | 258 | |
259 | 259 | $full_path = gpFiles::PageFile($title); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | return; |
274 | 274 | } |
275 | 275 | $content = ''; |
276 | - foreach($file_sections as $section){ |
|
276 | + foreach( $file_sections as $section ){ |
|
277 | 277 | if( !isset($section['content']) ){ |
278 | 278 | continue; |
279 | 279 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | - $slug = array_search($blog_index,$gp_index); |
|
303 | + $slug = array_search($blog_index, $gp_index); |
|
304 | 304 | $addon = $gp_titles[$blog_index]['addon']; |
305 | 305 | $blog_label = $gp_titles[$blog_index]['label']; |
306 | 306 | |
@@ -321,18 +321,18 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | require($full_path); |
324 | - $fileIndexMax = floor($blogData['post_index']/20); // '20' I found in SimpleBlogCommon.php function GetPostFile (line 62) |
|
324 | + $fileIndexMax = floor($blogData['post_index'] / 20); // '20' I found in SimpleBlogCommon.php function GetPostFile (line 62) |
|
325 | 325 | |
326 | - for ($fileIndex = 0; $fileIndex <= $fileIndexMax; $fileIndex++) { |
|
326 | + for( $fileIndex = 0; $fileIndex <= $fileIndexMax; $fileIndex++ ){ |
|
327 | 327 | $postFile = $blog_data_folder.'/posts_'.$fileIndex.'.php'; |
328 | 328 | if( !file_exists($postFile) ){ |
329 | 329 | continue; |
330 | 330 | } |
331 | 331 | require($postFile); |
332 | 332 | |
333 | - foreach($posts as $id => $post){ |
|
334 | - $title = $blog_label.': '.str_replace('_',' ',$post['title']); |
|
335 | - $content = str_replace('_',' ',$post['title']).' '.$post['content']; |
|
333 | + foreach( $posts as $id => $post ){ |
|
334 | + $title = $blog_label.': '.str_replace('_', ' ', $post['title']); |
|
335 | + $content = str_replace('_', ' ', $post['title']).' '.$post['content']; |
|
336 | 336 | $this->findString($content, $pattern, $title, $slug, '?cmd=post&id='.$id); |
337 | 337 | } |
338 | 338 | $posts = array(); |
@@ -357,29 +357,29 @@ discard block |
||
357 | 357 | |
358 | 358 | // same as before in SerchPreg() but saves in $this->file |
359 | 359 | // and uses different links for blog findings |
360 | - function findString(&$content, &$pattern, &$title, $link='', $link_query = ''){ |
|
360 | + function findString(&$content, &$pattern, &$title, $link = '', $link_query = ''){ |
|
361 | 361 | |
362 | - $content = str_replace('>','> ',$content); |
|
362 | + $content = str_replace('>', '> ', $content); |
|
363 | 363 | $content = strip_tags($content); |
364 | - $match_count = preg_match_all($pattern,$content,$matches,PREG_OFFSET_CAPTURE); |
|
364 | + $match_count = preg_match_all($pattern, $content, $matches, PREG_OFFSET_CAPTURE); |
|
365 | 365 | if( $match_count < 1 ){ |
366 | 366 | return; |
367 | 367 | } |
368 | - $rating = $match_count/strlen($content); |
|
368 | + $rating = $match_count / strlen($content); |
|
369 | 369 | |
370 | 370 | $result = '<div>'; |
371 | 371 | $result .= '<b>'; |
372 | 372 | $label = common::GetLabel($title); |
373 | - if(empty($link)){ |
|
374 | - $result .= common::Link($title,$label,$link_query); |
|
373 | + if( empty($link) ){ |
|
374 | + $result .= common::Link($title, $label, $link_query); |
|
375 | 375 | }else{ |
376 | - $result .= common::Link($link,$label,$link_query); |
|
376 | + $result .= common::Link($link, $label, $link_query); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $result .= '</b>'; |
380 | 380 | $result .= '<p>'; |
381 | 381 | |
382 | - $content = str_replace(array("\n","\r","\t"),array(' ',' ',' '),$content); |
|
382 | + $content = str_replace(array("\n", "\r", "\t"), array(' ', ' ', ' '), $content); |
|
383 | 383 | |
384 | 384 | //reduce a little bit |
385 | 385 | $start = $matches[0][0][1]; |
@@ -388,26 +388,26 @@ discard block |
||
388 | 388 | $i = 0; |
389 | 389 | do{ |
390 | 390 | $i++; |
391 | - $start_offset = $i*10; |
|
392 | - $start = max(0,$start-$start_offset); |
|
393 | - $trimmed = substr($content,$start,300); |
|
394 | - $space = strpos($trimmed,' '); |
|
391 | + $start_offset = $i * 10; |
|
392 | + $start = max(0, $start-$start_offset); |
|
393 | + $trimmed = substr($content, $start, 300); |
|
394 | + $space = strpos($trimmed, ' '); |
|
395 | 395 | if( $space < $start_offset ){ |
396 | - $content = substr($trimmed,$space); |
|
396 | + $content = substr($trimmed, $space); |
|
397 | 397 | break; |
398 | 398 | } |
399 | - }while( ($start-$start_offset) > 0); |
|
399 | + }while( ($start-$start_offset) > 0 ); |
|
400 | 400 | |
401 | 401 | |
402 | 402 | //find a space at the end |
403 | 403 | if( strlen($content) > 250 ){ |
404 | - $space2 = strpos($content,' ',$space+220); |
|
404 | + $space2 = strpos($content, ' ', $space+220); |
|
405 | 405 | if( $space2 > 0 ){ |
406 | - $content = substr($content,0,$space2); |
|
406 | + $content = substr($content, 0, $space2); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
410 | - $result .= preg_replace($pattern,'<b>\1</b>',$content); |
|
410 | + $result .= preg_replace($pattern, '<b>\1</b>', $content); |
|
411 | 411 | |
412 | 412 | $result .= '</p>'; |
413 | 413 | $result .= '</div>'; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | foreach($this->files as $result){ |
105 | 105 | echo $result; |
106 | 106 | } |
107 | - }else{ |
|
107 | + } else{ |
|
108 | 108 | echo '<p>'; |
109 | 109 | echo gpOutput::GetAddonText('Sorry, there weren\'t any results for your search. '); |
110 | 110 | echo '</p>'; |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | |
134 | 134 | if( isset($_POST['search_hidden']) ){ |
135 | 135 | $search_config['search_hidden'] = true; |
136 | - }else{ |
|
136 | + } else{ |
|
137 | 137 | $search_config['search_hidden'] = false; |
138 | 138 | } |
139 | 139 | if( isset($_POST['search_blog']) ){ |
140 | 140 | $search_config['search_blog'] = true; |
141 | - }else{ |
|
141 | + } else{ |
|
142 | 142 | $search_config['search_blog'] = false; |
143 | 143 | } |
144 | 144 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | echo '<td>'; |
183 | 183 | if( isset($array['search_hidden']) && $array['search_hidden'] ){ |
184 | 184 | echo '<input type="checkbox" name="search_hidden" checked="checked" value="true" />'; |
185 | - }else{ |
|
185 | + } else{ |
|
186 | 186 | echo '<input type="checkbox" name="search_hidden" value="true" />'; |
187 | 187 | } |
188 | 188 | echo '</td>'; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | if( isset($array['search_blog']) && $array['search_blog'] ){ |
206 | 206 | echo '<input type="checkbox" name="search_blog" checked="checked" value="true" '.$disabled.'/>'; |
207 | - }else{ |
|
207 | + } else{ |
|
208 | 208 | echo '<input type="checkbox" name="search_blog" value="true" '.$disabled.'/>'; |
209 | 209 | } |
210 | 210 | echo '</td>'; |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $addon_info = $config['addons'][$addon]; |
309 | 309 | if( isset($addon_info['data_folder']) ){ |
310 | 310 | $blog_data_folder = $dataDir.'/data/_addondata/'.$addon_info['data_folder']; |
311 | - }else{ |
|
311 | + } else{ |
|
312 | 312 | $blog_data_folder = $dataDir.'/data/_addondata/'.$addon; |
313 | 313 | } |
314 | 314 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $label = common::GetLabel($title); |
373 | 373 | if(empty($link)){ |
374 | 374 | $result .= common::Link($title,$label,$link_query); |
375 | - }else{ |
|
375 | + } else{ |
|
376 | 376 | $result .= common::Link($link,$label,$link_query); |
377 | 377 | } |
378 | 378 |
@@ -141,6 +141,7 @@ |
||
141 | 141 | /** |
142 | 142 | * Get a list of folders within $dir that |
143 | 143 | * |
144 | + * @param string $relative |
|
144 | 145 | */ |
145 | 146 | function GetCleanFolders($relative){ |
146 | 147 | global $dataDir; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | if( isset($info['disabled']) ){ |
214 | 214 | return \gp\tool::Link('Admin/Addons',str_replace('_',' ',$name).' ('.$langmessage['disabled'].')','cmd=enable&addon='.rawurlencode($info['addon']).'&gadget='.rawurlencode($name),'data-cmd="gpajax" class="gadget_link_'.md5($name).'"'); |
215 | - }else{ |
|
215 | + } else{ |
|
216 | 216 | return \gp\tool::Link('Admin/Addons',str_replace('_',' ',$name) .' ('.$langmessage['enabled'].')','cmd=disable&addon='.rawurlencode($info['addon']).'&gadget='.rawurlencode($name),'data-cmd="gpajax" class="gadget_link_'.md5($name).'"'); |
217 | 217 | } |
218 | 218 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | echo ' <input type="submit" value="'.$langmessage['Close'].'" class="admin_box_close" /> '; |
270 | 270 | echo '</p>'; |
271 | 271 | |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | |
274 | 274 | echo $langmessage['confirm_uninstall']; |
275 | 275 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $id = $info['Addon_Unique_ID']; |
385 | 385 | if( !isset($versions[$id]) ){ |
386 | 386 | $versions[$id] = $info['Addon_Version']; |
387 | - }elseif( version_compare($versions[$id],$info['Addon_Version'],'<') ){ |
|
387 | + } elseif( version_compare($versions[$id],$info['Addon_Version'],'<') ){ |
|
388 | 388 | $versions[$id] = $info['Addon_Version']; |
389 | 389 | continue; |
390 | 390 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | if( count($this->avail_addons) == 0 ){ |
459 | 459 | //echo ' -empty- '; |
460 | - }else{ |
|
460 | + } else{ |
|
461 | 461 | echo '<table class="bordered full_width">'; |
462 | 462 | echo '<tr><th>'; |
463 | 463 | echo $langmessage['name']; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public $dataFile; |
30 | 30 | |
31 | 31 | |
32 | - function __construct( $args ){ |
|
32 | + function __construct($args){ |
|
33 | 33 | global $langmessage; |
34 | 34 | |
35 | 35 | parent::__construct($args); |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | $this->InitRating(); |
38 | 38 | $this->GetData(); |
39 | 39 | |
40 | - $this->page->head_js[] = '/include/js/auto_width.js'; |
|
41 | - $this->avail_addons = $this->GetAvailAddons(); |
|
40 | + $this->page->head_js[] = '/include/js/auto_width.js'; |
|
41 | + $this->avail_addons = $this->GetAvailAddons(); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | 45 | function RunScript(){ |
46 | 46 | |
47 | 47 | $cmd = \gp\tool::GetCommand(); |
48 | - switch($cmd){ |
|
48 | + switch( $cmd ){ |
|
49 | 49 | |
50 | 50 | case 'LocalInstall': |
51 | 51 | $this->LocalInstall(); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | //single addon |
88 | - $request_parts = explode('/',$this->page->requested); |
|
88 | + $request_parts = explode('/', $this->page->requested); |
|
89 | 89 | if( count($request_parts) > 2 ){ |
90 | 90 | $this->ShowAddon($request_parts[2]); |
91 | 91 | return; |
@@ -114,19 +114,19 @@ discard block |
||
114 | 114 | |
115 | 115 | //check against folders used by addons |
116 | 116 | $addons = $config['addons']; |
117 | - foreach($addons as $addon_key => $info){ |
|
117 | + foreach( $addons as $addon_key => $info ){ |
|
118 | 118 | $addon_config = \gp\tool\Plugins::GetAddonConfig($addon_key); |
119 | - if( array_key_exists($addon_config['code_folder_part'],$code_folders) ){ |
|
119 | + if( array_key_exists($addon_config['code_folder_part'], $code_folders) ){ |
|
120 | 120 | $code_folders[$addon_config['code_folder_part']] = false; |
121 | 121 | } |
122 | - if( array_key_exists($addon_config['data_folder_part'],$data_folders) ){ |
|
122 | + if( array_key_exists($addon_config['data_folder_part'], $data_folders) ){ |
|
123 | 123 | $data_folders[$addon_config['data_folder_part']] = false; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | 127 | //remove unused folders |
128 | - $folders = array_filter($code_folders) + array_filter($data_folders); |
|
129 | - foreach($folders as $folder => $full_path){ |
|
128 | + $folders = array_filter($code_folders)+array_filter($data_folders); |
|
129 | + foreach( $folders as $folder => $full_path ){ |
|
130 | 130 | \gp\tool\Files::RmAll($full_path); |
131 | 131 | } |
132 | 132 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | if( file_exists($dir) ){ |
147 | 147 | $files = scandir($dir); |
148 | - foreach($files as $file){ |
|
148 | + foreach( $files as $file ){ |
|
149 | 149 | if( $file == '.' || $file == '..' ){ |
150 | 150 | continue; |
151 | 151 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | continue; |
155 | 155 | } |
156 | 156 | $mtime = filemtime($full_path); |
157 | - $diff = time() - $mtime; |
|
157 | + $diff = time()-$mtime; |
|
158 | 158 | if( $diff < 3600 ){ |
159 | 159 | continue; |
160 | 160 | } |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | - $gadgetInfo =& $config['gadgets'][$gadget]; |
|
180 | + $gadgetInfo = & $config['gadgets'][$gadget]; |
|
181 | 181 | |
182 | - switch($cmd){ |
|
182 | + switch( $cmd ){ |
|
183 | 183 | case 'enable': |
184 | 184 | unset($gadgetInfo['disabled']); |
185 | 185 | break; |
186 | 186 | case 'disable': |
187 | - $gadgetInfo['disabled'] = true; |
|
187 | + $gadgetInfo['disabled'] = true; |
|
188 | 188 | break; |
189 | 189 | |
190 | 190 | } |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | $link = $this->GadgetLink($gadget); |
197 | - $this->page->ajaxReplace[] = array('replace','.gadget_link_'.md5($gadget),$link); |
|
197 | + $this->page->ajaxReplace[] = array('replace', '.gadget_link_'.md5($gadget), $link); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | function GadgetLink($name){ |
201 | 201 | global $config, $langmessage; |
202 | - $info =& $config['gadgets'][$name]; |
|
202 | + $info = & $config['gadgets'][$name]; |
|
203 | 203 | if( !$info ){ |
204 | 204 | return ''; |
205 | 205 | } |
206 | 206 | |
207 | 207 | if( isset($info['disabled']) ){ |
208 | - return \gp\tool::Link('Admin/Addons',str_replace('_',' ',$name).' ('.$langmessage['disabled'].')','cmd=enable&addon='.rawurlencode($info['addon']).'&gadget='.rawurlencode($name),'data-cmd="gpajax" class="gadget_link_'.md5($name).'"'); |
|
208 | + return \gp\tool::Link('Admin/Addons', str_replace('_', ' ', $name).' ('.$langmessage['disabled'].')', 'cmd=enable&addon='.rawurlencode($info['addon']).'&gadget='.rawurlencode($name), 'data-cmd="gpajax" class="gadget_link_'.md5($name).'"'); |
|
209 | 209 | }else{ |
210 | - return \gp\tool::Link('Admin/Addons',str_replace('_',' ',$name) .' ('.$langmessage['enabled'].')','cmd=disable&addon='.rawurlencode($info['addon']).'&gadget='.rawurlencode($name),'data-cmd="gpajax" class="gadget_link_'.md5($name).'"'); |
|
210 | + return \gp\tool::Link('Admin/Addons', str_replace('_', ' ', $name).' ('.$langmessage['enabled'].')', 'cmd=disable&addon='.rawurlencode($info['addon']).'&gadget='.rawurlencode($name), 'data-cmd="gpajax" class="gadget_link_'.md5($name).'"'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | */ |
220 | 220 | function GetData(){ |
221 | - global $dataDir,$config; |
|
221 | + global $dataDir, $config; |
|
222 | 222 | |
223 | 223 | //new |
224 | 224 | if( !isset($config['addons']) ){ |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $firstValue = current($config['addons']); |
239 | 239 | if( is_string($firstValue) ){ |
240 | 240 | |
241 | - foreach($config['addons'] as $addon => $addonName){ |
|
241 | + foreach( $config['addons'] as $addon => $addonName ){ |
|
242 | 242 | $config['addons'][$addon] = array(); |
243 | 243 | $config['addons'][$addon]['name'] = $addonName; |
244 | 244 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | * Prompt User about uninstalling an addon |
251 | 251 | */ |
252 | 252 | function Uninstall(){ |
253 | - global $config,$langmessage; |
|
253 | + global $config, $langmessage; |
|
254 | 254 | |
255 | 255 | echo '<div class="inline_box">'; |
256 | 256 | echo '<h3>'.$langmessage['uninstall'].'</h3>'; |
257 | 257 | echo '<form action="'.\gp\tool::GetUrl('Admin/Addons').'" method="post">'; |
258 | 258 | |
259 | - $addon =& $_REQUEST['addon']; |
|
259 | + $addon = & $_REQUEST['addon']; |
|
260 | 260 | if( !isset($config['addons'][$addon]) ){ |
261 | 261 | echo $langmessage['OOPS']; |
262 | 262 | echo '<p>'; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | function Confirm_Uninstall(){ |
284 | 284 | |
285 | - $addon =& $_POST['addon']; |
|
285 | + $addon = & $_POST['addon']; |
|
286 | 286 | |
287 | 287 | $installer = new \gp\admin\Addon\Installer(); |
288 | 288 | $installer->Uninstall($addon); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | function ShowAddon($encoded_key){ |
298 | 298 | global $config, $langmessage; |
299 | 299 | |
300 | - $addon_key = \gp\admin\Tools::decode64($encoded_key); |
|
300 | + $addon_key = \gp\admin\Tools::decode64($encoded_key); |
|
301 | 301 | |
302 | 302 | if( !isset($config['addons'][$addon_key]) ){ |
303 | 303 | message($langmessage['OOPS'].'(Addon Not Found)'); |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | echo '<div id="adminlinks2">'; |
328 | 328 | |
329 | 329 | $format = array(); |
330 | - $format['end'] = '</div></div>'; |
|
331 | - $format['start'] = '<div class="panelgroup"><h3>%s</h3><div class="panelgroup2">'; |
|
330 | + $format['end'] = '</div></div>'; |
|
331 | + $format['start'] = '<div class="panelgroup"><h3>%s</h3><div class="panelgroup2">'; |
|
332 | 332 | |
333 | - $this->AddonPanel_Special($addon_key,$format); |
|
334 | - $this->AddonPanel_Admin($addon_key,$format); |
|
335 | - $this->AddonPanel_Gadget($addon_key,$format); |
|
333 | + $this->AddonPanel_Special($addon_key, $format); |
|
334 | + $this->AddonPanel_Admin($addon_key, $format); |
|
335 | + $this->AddonPanel_Gadget($addon_key, $format); |
|
336 | 336 | $this->AddonPanel_Hooks($addon_key, $format); |
337 | 337 | $this->OptionLinks($addon_key, $info, $format); |
338 | 338 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | function GetAvailAddons(){ |
351 | 351 | global $dataDir; |
352 | 352 | |
353 | - $addonPath = $dataDir.'/addons'; |
|
353 | + $addonPath = $dataDir.'/addons'; |
|
354 | 354 | |
355 | 355 | if( !file_exists($addonPath) ){ |
356 | 356 | message('Warning: The /addons folder "<em>'.$addonPath.'</em>" does not exist on your server.'); |
@@ -358,29 +358,29 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | |
361 | - $folders = \gp\tool\Files::ReadDir($addonPath,1); |
|
362 | - $versions = array(); |
|
363 | - $avail = array(); |
|
361 | + $folders = \gp\tool\Files::ReadDir($addonPath, 1); |
|
362 | + $versions = array(); |
|
363 | + $avail = array(); |
|
364 | 364 | |
365 | - foreach($folders as $value){ |
|
366 | - $fullPath = $addonPath .'/'.$value; |
|
367 | - $info = $this->GetAvailInstall($fullPath); |
|
365 | + foreach( $folders as $value ){ |
|
366 | + $fullPath = $addonPath.'/'.$value; |
|
367 | + $info = $this->GetAvailInstall($fullPath); |
|
368 | 368 | |
369 | 369 | if( !$info ){ |
370 | 370 | continue; |
371 | 371 | } |
372 | 372 | |
373 | 373 | |
374 | - $info['source_folder'] = $addonPath .'/'. $value; |
|
375 | - $info['upgrade_key'] = \gp\admin\Addon\Tools::UpgradePath($info); |
|
376 | - $avail[$value] = $info; |
|
374 | + $info['source_folder'] = $addonPath.'/'.$value; |
|
375 | + $info['upgrade_key'] = \gp\admin\Addon\Tools::UpgradePath($info); |
|
376 | + $avail[$value] = $info; |
|
377 | 377 | |
378 | 378 | if( isset($info['Addon_Version']) && isset($info['Addon_Unique_ID']) ){ |
379 | 379 | |
380 | 380 | $id = $info['Addon_Unique_ID']; |
381 | 381 | if( !isset($versions[$id]) ){ |
382 | 382 | $versions[$id] = $info['Addon_Version']; |
383 | - }elseif( version_compare($versions[$id],$info['Addon_Version'],'<') ){ |
|
383 | + }elseif( version_compare($versions[$id], $info['Addon_Version'], '<') ){ |
|
384 | 384 | $versions[$id] = $info['Addon_Version']; |
385 | 385 | continue; |
386 | 386 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | protected function FilterUnique($addons, $versions){ |
408 | 408 | |
409 | 409 | $temp = array(); |
410 | - foreach($addons as $key => $info){ |
|
410 | + foreach( $addons as $key => $info ){ |
|
411 | 411 | |
412 | 412 | if( !isset($info['Addon_Version']) || !isset($info['Addon_Unique_ID']) ){ |
413 | 413 | $temp[$key] = $info; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $id = $info['Addon_Unique_ID']; |
418 | 418 | $version = $info['Addon_Version']; |
419 | 419 | |
420 | - if( version_compare($versions[$id], $version,'>') ){ |
|
420 | + if( version_compare($versions[$id], $version, '>') ){ |
|
421 | 421 | continue; |
422 | 422 | } |
423 | 423 | |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | echo $langmessage['description']; |
466 | 466 | echo '</th></tr>'; |
467 | 467 | |
468 | - $i=0; |
|
469 | - foreach($this->avail_addons as $folder => $info ){ |
|
468 | + $i = 0; |
|
469 | + foreach( $this->avail_addons as $folder => $info ){ |
|
470 | 470 | |
471 | 471 | if( $info['upgrade_key'] ){ |
472 | 472 | continue; |
@@ -475,17 +475,17 @@ discard block |
||
475 | 475 | $info += array('About'=>''); |
476 | 476 | |
477 | 477 | echo '<tr class="'.($i % 2 ? 'even' : '').'"><td>'; |
478 | - echo str_replace(' ',' ',$info['Addon_Name']); |
|
478 | + echo str_replace(' ', ' ', $info['Addon_Name']); |
|
479 | 479 | echo '<br/><em class="admin_note">/addons/'.$folder.'</em>'; |
480 | 480 | echo '</td><td>'; |
481 | 481 | echo $info['Addon_Version']; |
482 | 482 | echo '</td><td>'; |
483 | - echo \gp\tool::Link('Admin/Addons',$langmessage['Install'],'cmd=LocalInstall&source='.$folder, array('data-cmd'=>'cnreq')); |
|
483 | + echo \gp\tool::Link('Admin/Addons', $langmessage['Install'], 'cmd=LocalInstall&source='.$folder, array('data-cmd'=>'cnreq')); |
|
484 | 484 | echo '</td><td>'; |
485 | 485 | echo $info['About']; |
486 | 486 | if( isset($info['Addon_Unique_ID']) && is_numeric($info['Addon_Unique_ID']) ){ |
487 | 487 | echo '<br/>'; |
488 | - echo $this->DetailLink('plugins', $info['Addon_Unique_ID'],'More Info...'); |
|
488 | + echo $this->DetailLink('plugins', $info['Addon_Unique_ID'], 'More Info...'); |
|
489 | 489 | } |
490 | 490 | echo '</td></tr>'; |
491 | 491 | $i++; |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | $show = $this->GetDisplayInfo(); |
510 | 510 | |
511 | 511 | echo '<div id="adminlinks2">'; |
512 | - foreach($show as $addon_key => $info){ |
|
513 | - $this->PluginPanelGroup($addon_key,$info); |
|
512 | + foreach( $show as $addon_key => $info ){ |
|
513 | + $this->PluginPanelGroup($addon_key, $info); |
|
514 | 514 | } |
515 | 515 | echo '</div>'; |
516 | 516 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | |
534 | 534 | |
535 | 535 | //set upgrade_from |
536 | - foreach($this->avail_addons as $folder => $info){ |
|
536 | + foreach( $this->avail_addons as $folder => $info ){ |
|
537 | 537 | if( !$info['upgrade_key'] ){ |
538 | 538 | continue; |
539 | 539 | } |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | if( !isset($show[$upgrade_key]['upgrade_version']) || version_compare($show[$upgrade_key]['upgrade_version'], $info['Addon_Version'], '<') ){ |
553 | - $show[$upgrade_key]['upgrade_from'] = $folder; |
|
554 | - $show[$upgrade_key]['upgrade_version'] = $info['Addon_Version']; |
|
553 | + $show[$upgrade_key]['upgrade_from'] = $folder; |
|
554 | + $show[$upgrade_key]['upgrade_version'] = $info['Addon_Version']; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | |
563 | - function PluginPanelGroup($addon_key,$info){ |
|
563 | + function PluginPanelGroup($addon_key, $info){ |
|
564 | 564 | global $langmessage, $gpLayouts; |
565 | 565 | |
566 | 566 | $addon_config = \gp\tool\Plugins::GetAddonConfig($addon_key); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | echo '<div class="panelgroup" id="panelgroup_'.md5($addon_key).'">'; |
571 | 571 | |
572 | 572 | echo '<h3>'; |
573 | - echo \gp\tool::Link('Admin/Addons/'.\gp\admin\Tools::encode64($addon_key),$addon_config['name']); |
|
573 | + echo \gp\tool::Link('Admin/Addons/'.\gp\admin\Tools::encode64($addon_key), $addon_config['name']); |
|
574 | 574 | echo '</h3>'; |
575 | 575 | |
576 | 576 | echo '<div class="panelgroup2">'; |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | |
596 | 596 | //upgrade local |
597 | 597 | if( isset($addon_config['upgrade_from']) && isset($addon_config['upgrade_version']) ){ |
598 | - if(version_compare($addon_config['upgrade_version'],$addon_config['version'] ,'>') ){ |
|
598 | + if( version_compare($addon_config['upgrade_version'], $addon_config['version'], '>') ){ |
|
599 | 599 | echo '<div class="gp_notice">'; |
600 | 600 | $label = $langmessage['new_version'].' '.$addon_config['upgrade_version']; |
601 | 601 | echo '<a href="?cmd=LocalInstall&source='.rawurlencode($addon_config['upgrade_from']).'" data-cmd="cnreq">'.$label.'</a>'; |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | |
609 | 609 | $new_version = \gp\admin\Tools::$new_versions[$addon_config['id']]; |
610 | 610 | |
611 | - if( version_compare($new_version['version'],$addon_config['version'],'>') ){ |
|
611 | + if( version_compare($new_version['version'], $addon_config['version'], '>') ){ |
|
612 | 612 | |
613 | 613 | echo '<div class="gp_notice">'; |
614 | 614 | echo '<a href="'.addon_browse_path.'/Plugins?id='.$addon_config['id'].'" data-cmd="remote">'; |
@@ -628,13 +628,13 @@ discard block |
||
628 | 628 | function OptionLinks($addon_key, $addon_config, $format = false){ |
629 | 629 | global $langmessage, $gpLayouts; |
630 | 630 | |
631 | - $list = array(); |
|
631 | + $list = array(); |
|
632 | 632 | |
633 | 633 | if( !isset($addon_config['is_theme']) || !$addon_config['is_theme'] ){ |
634 | 634 | |
635 | 635 | //editable text |
636 | 636 | if( isset($addon_config['editable_text']) && \gp\admin\Tools::HasPermission('Admin_Theme_Content') ){ |
637 | - $list[] = \gp\tool::Link('Admin_Theme_Content/Text',$langmessage['editable_text'],'cmd=AddonTextForm&addon='.urlencode($addon_key),array('title'=>urlencode($langmessage['editable_text']),'data-cmd'=>'gpabox')); |
|
637 | + $list[] = \gp\tool::Link('Admin_Theme_Content/Text', $langmessage['editable_text'], 'cmd=AddonTextForm&addon='.urlencode($addon_key), array('title'=>urlencode($langmessage['editable_text']), 'data-cmd'=>'gpabox')); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | //upgrade link |
@@ -643,12 +643,12 @@ discard block |
||
643 | 643 | } |
644 | 644 | |
645 | 645 | //uninstall |
646 | - $list[] = \gp\tool::Link('Admin/Addons',$langmessage['uninstall'],'cmd=uninstall&addon='.rawurlencode($addon_key),'data-cmd="gpabox"'); |
|
646 | + $list[] = \gp\tool::Link('Admin/Addons', $langmessage['uninstall'], 'cmd=uninstall&addon='.rawurlencode($addon_key), 'data-cmd="gpabox"'); |
|
647 | 647 | |
648 | 648 | |
649 | 649 | //version |
650 | 650 | if( !empty($addon_config['version']) ){ |
651 | - $list[] = '<a>'.$langmessage['Your_version'].' '.$addon_config['version']. '</a>'; |
|
651 | + $list[] = '<a>'.$langmessage['Your_version'].' '.$addon_config['version'].'</a>'; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | //rating |
@@ -659,30 +659,30 @@ discard block |
||
659 | 659 | if( isset($this->addonReviews[$id]) ){ |
660 | 660 | $rating = $this->addonReviews[$id]['rating']; |
661 | 661 | } |
662 | - $label = $langmessage['rate_this_addon'].' '.$this->ShowRating($id,$rating); |
|
663 | - $list[] = '<span>'.$label. '</span>'; |
|
662 | + $label = $langmessage['rate_this_addon'].' '.$this->ShowRating($id, $rating); |
|
663 | + $list[] = '<span>'.$label.'</span>'; |
|
664 | 664 | } |
665 | 665 | |
666 | - echo $this->FormatList($list,$langmessage['options'],$format); |
|
666 | + echo $this->FormatList($list, $langmessage['options'], $format); |
|
667 | 667 | return; |
668 | 668 | } |
669 | 669 | |
670 | 670 | //show list of themes using these addons |
671 | - foreach($gpLayouts as $layout_id => $layout_info){ |
|
671 | + foreach( $gpLayouts as $layout_id => $layout_info ){ |
|
672 | 672 | if( !isset($layout_info['addon_key']) || $layout_info['addon_key'] !== $addon_key ){ |
673 | 673 | continue; |
674 | 674 | } |
675 | 675 | |
676 | 676 | $item = '<span><span class="layout_color_id" style="background:'.$layout_info['color'].'"></span> '; |
677 | - $item .= \gp\tool::Link('Admin_Theme_Content',$layout_info['label']); |
|
677 | + $item .= \gp\tool::Link('Admin_Theme_Content', $layout_info['label']); |
|
678 | 678 | $item .= ' ( '; |
679 | - $item .= \gp\tool::Link('Admin_Theme_Content/Edit/'.$layout_id,$langmessage['edit']); |
|
679 | + $item .= \gp\tool::Link('Admin_Theme_Content/Edit/'.$layout_id, $langmessage['edit']); |
|
680 | 680 | $item .= ' )</span>'; |
681 | 681 | |
682 | 682 | $list[] = $item; |
683 | 683 | } |
684 | 684 | |
685 | - echo $this->FormatList($list,$langmessage['layouts'],$format); |
|
685 | + echo $this->FormatList($list, $langmessage['layouts'], $format); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | function LocalInstall(){ |
694 | 694 | global $dataDir, $langmessage; |
695 | 695 | |
696 | - $_REQUEST += array('source'=>''); |
|
696 | + $_REQUEST += array('source'=>''); |
|
697 | 697 | |
698 | 698 | if( !isset($this->avail_addons[$_REQUEST['source']]) ){ |
699 | 699 | message($langmessage['OOPS'].' (Invalid Request)'); |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | |
704 | - $installer = new \gp\admin\Addon\Installer(); |
|
705 | - $installer->source = $this->avail_addons[$_REQUEST['source']]['source_folder']; |
|
704 | + $installer = new \gp\admin\Addon\Installer(); |
|
705 | + $installer->source = $this->avail_addons[$_REQUEST['source']]['source_folder']; |
|
706 | 706 | |
707 | 707 | $installer->Install(); |
708 | 708 | $installer->OutputMessages(); |
@@ -384,6 +384,7 @@ discard block |
||
384 | 384 | /** |
385 | 385 | * Form Functions |
386 | 386 | * |
387 | + * @param string $key |
|
387 | 388 | */ |
388 | 389 | public function formCheckbox($key,$value){ |
389 | 390 | $checked = ''; |
@@ -394,12 +395,18 @@ discard block |
||
394 | 395 | echo '<input type="checkbox" name="'.$key.'" value="true" '.$checked.'/> '; |
395 | 396 | } |
396 | 397 | |
398 | + /** |
|
399 | + * @param string $name |
|
400 | + */ |
|
397 | 401 | public function formInput($name,$value,$type='text'){ |
398 | 402 | echo "\n<div>"; |
399 | 403 | echo '<input id="'.$name.'" name="'.$name.'" size="50" value="'.htmlspecialchars($value).'" type="'.$type.'" class="gpinput"/>'; |
400 | 404 | echo '</div>'; |
401 | 405 | } |
402 | 406 | |
407 | + /** |
|
408 | + * @param string $name |
|
409 | + */ |
|
403 | 410 | public function formTextarea($name,$value){ |
404 | 411 | global $langmessage; |
405 | 412 | $count_label = sprintf($langmessage['_characters'],'<span>'.strlen($value).'</span>'); |
@@ -409,6 +416,9 @@ discard block |
||
409 | 416 | echo '</span>'; |
410 | 417 | } |
411 | 418 | |
419 | + /** |
|
420 | + * @param string $name |
|
421 | + */ |
|
412 | 422 | public static function formSelect($name,$possible,$value=null){ |
413 | 423 | |
414 | 424 | echo '<div>'; |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | if( $curr_possible == 'boolean' ){ |
103 | 103 | if( isset($_POST[$key]) && ($_POST[$key] == 'true') ){ |
104 | 104 | $config[$key] = true; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | $config[$key] = false; |
107 | 107 | } |
108 | 108 | |
109 | - }elseif( $curr_possible == 'integer' ){ |
|
109 | + } elseif( $curr_possible == 'integer' ){ |
|
110 | 110 | if( isset($_POST[$key]) && is_numeric($_POST[$key]) ){ |
111 | 111 | $config[$key] = $_POST[$key]; |
112 | 112 | } |
113 | 113 | |
114 | - }elseif( isset($_POST[$key]) ){ |
|
114 | + } elseif( isset($_POST[$key]) ){ |
|
115 | 115 | $config[$key] = $_POST[$key]; |
116 | 116 | } |
117 | 117 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | if( isset($_GET['gpreq']) && $_GET['gpreq'] == 'json' ){ |
128 | 128 | message($langmessage['SAVED'].' '.$langmessage['REFRESH']); |
129 | - }else{ |
|
129 | + } else{ |
|
130 | 130 | message($langmessage['SAVED']); |
131 | 131 | } |
132 | 132 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | if( $_SERVER['REQUEST_METHOD'] != 'POST'){ |
142 | 142 | $show = $config; |
143 | - }else{ |
|
143 | + } else{ |
|
144 | 144 | $show = $_POST; |
145 | 145 | } |
146 | 146 | if( empty($show['recaptcha_language']) ){ |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | //tidy |
205 | 205 | if( function_exists('tidy_parse_string') ){ |
206 | 206 | $possible['HTML_Tidy'] = array('off'=>$langmessage['Off'],''=>$langmessage['On']); |
207 | - }else{ |
|
207 | + } else{ |
|
208 | 208 | $possible['HTML_Tidy'] = array(''=>'Unavailable'); |
209 | 209 | } |
210 | 210 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | echo '<h2>'; |
295 | 295 | if( isset($langmessage[$key]) ){ |
296 | 296 | echo $langmessage[$key]; |
297 | - }else{ |
|
297 | + } else{ |
|
298 | 298 | echo str_replace('_',' ',$key); |
299 | 299 | } |
300 | 300 | echo '</h2>'; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | if( isset($array[$key]) ){ |
307 | 307 | $value = $array[$key]; |
308 | - }else{ |
|
308 | + } else{ |
|
309 | 309 | $value = ''; |
310 | 310 | } |
311 | 311 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | echo '<tr><td style="white-space:nowrap">'; |
316 | 316 | if( isset($langmessage[$key]) ){ |
317 | 317 | echo $langmessage[$key]; |
318 | - }else{ |
|
318 | + } else{ |
|
319 | 319 | echo str_replace('_',' ',$key); |
320 | 320 | } |
321 | 321 | echo '</td><td>'; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | if( is_array($possible_value) ){ |
325 | 325 | self::formSelect($key,$possible_value,$value); |
326 | - }else{ |
|
326 | + } else{ |
|
327 | 327 | switch($possible_value){ |
328 | 328 | case 'boolean': |
329 | 329 | $this->formCheckbox($key,$value); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | |
366 | 366 | if( isset($_GET['gpreq']) && $_GET['gpreq'] == 'json' ){ |
367 | 367 | echo '<input value="'.$langmessage['save'].'" type="submit" name="aaa" accesskey="s" class="gppost gpsubmit" />'; |
368 | - }else{ |
|
368 | + } else{ |
|
369 | 369 | echo '<input value="'.$langmessage['save'].'" type="submit" name="aaa" accesskey="s" class="gpsubmit"/>'; |
370 | 370 | } |
371 | 371 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | |
436 | 436 | if($key == $current_value){ |
437 | 437 | $focus = ' selected="selected" '; |
438 | - }else{ |
|
438 | + } else{ |
|
439 | 439 | $focus = ''; |
440 | 440 | } |
441 | 441 | if( isset($languages[$value]) ){ |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | //add examples to smtp_hosts |
22 | - $langmessage['about_config']['smtp_hosts'] .= 'ssl://smtp.gmail.com:465 ; tls://smtp.live.com:587'; |
|
23 | - $langmessage['about_config']['showgplink'] = 'Showing the "powered by" link on your site is a great way to support '.CMS_NAME.' CMS.'; |
|
22 | + $langmessage['about_config']['smtp_hosts'] .= 'ssl://smtp.gmail.com:465 ; tls://smtp.live.com:587'; |
|
23 | + $langmessage['about_config']['showgplink'] = 'Showing the "powered by" link on your site is a great way to support '.CMS_NAME.' CMS.'; |
|
24 | 24 | $langmessage['about_config']['history_limit'] = 'Max: '.gp_backup_limit; |
25 | - $langmessage['about_config']['maxthumbsize'] .= ' '.\gp\tool::Link('Admin/Configuration','Recreate All Thumbnails','cmd=recreate_thumbs','class="" data-cmd="creq"'); |
|
25 | + $langmessage['about_config']['maxthumbsize'] .= ' '.\gp\tool::Link('Admin/Configuration', 'Recreate All Thumbnails', 'cmd=recreate_thumbs', 'class="" data-cmd="creq"'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | $this->variables = array( |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'desc' => 'textarea', |
39 | 39 | |
40 | 40 | 'Interface' => false, |
41 | - 'colorbox_style' => array('example1'=>'Example 1', 'example2'=>'Example 2', 'example3'=>'Example 3', 'example4'=>'Example 4', 'example5'=>'Example 5' ), |
|
41 | + 'colorbox_style' => array('example1'=>'Example 1', 'example2'=>'Example 2', 'example3'=>'Example 3', 'example4'=>'Example 4', 'example5'=>'Example 5'), |
|
42 | 42 | 'language' => '', |
43 | 43 | 'langeditor' => '', |
44 | 44 | 'showsitemap' => 'boolean', |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'combinecss' => 'boolean', |
57 | 57 | 'etag_headers' => 'boolean', |
58 | 58 | 'resize_images' => 'boolean', |
59 | - 'space_char' => array('_'=>'Undersorce "_"','-'=>'Dash "-"'), |
|
59 | + 'space_char' => array('_'=>'Undersorce "_"', '-'=>'Dash "-"'), |
|
60 | 60 | |
61 | 61 | |
62 | 62 | /* Contact Configuration */ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function RunScript(){ |
87 | 87 | |
88 | 88 | $cmd = \gp\tool::GetCommand(); |
89 | - switch($cmd){ |
|
89 | + switch( $cmd ){ |
|
90 | 90 | case 'save_config': |
91 | 91 | $this->SaveConfig(); |
92 | 92 | break; |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | protected function SaveConfig(){ |
107 | 107 | global $config, $langmessage; |
108 | 108 | |
109 | - $config_before = $config; |
|
110 | - $possible = $this->getPossible(); |
|
109 | + $config_before = $config; |
|
110 | + $possible = $this->getPossible(); |
|
111 | 111 | |
112 | - foreach($possible as $key => $curr_possible){ |
|
112 | + foreach( $possible as $key => $curr_possible ){ |
|
113 | 113 | |
114 | 114 | if( $curr_possible == 'boolean' ){ |
115 | 115 | if( isset($_POST[$key]) && ($_POST[$key] == 'true') ){ |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | - $config['history_limit'] = min($config['history_limit'],gp_backup_limit); |
|
132 | + $config['history_limit'] = min($config['history_limit'], gp_backup_limit); |
|
133 | 133 | |
134 | 134 | if( !\gp\admin\Tools::SaveConfig(true) ){ |
135 | 135 | return false; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | //resize thumbnails |
146 | 146 | if( $config_before['maxthumbsize'] !== $config['maxthumbsize'] ){ |
147 | - msg(\gp\tool::Link('Admin/Configuration','Recreate All Thumbnails?','cmd=recreate_thumbs','class="" data-cmd="creq"')); |
|
147 | + msg(\gp\tool::Link('Admin/Configuration', 'Recreate All Thumbnails?', 'cmd=recreate_thumbs', 'class="" data-cmd="creq"')); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $mailer = new \gp\tool\Emailer(); |
158 | 158 | |
159 | - if( $_SERVER['REQUEST_METHOD'] != 'POST'){ |
|
159 | + if( $_SERVER['REQUEST_METHOD'] != 'POST' ){ |
|
160 | 160 | $show = $config; |
161 | 161 | }else{ |
162 | 162 | $show = $_POST; |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * |
190 | 190 | */ |
191 | 191 | protected function getPossible(){ |
192 | - global $dataDir,$langmessage; |
|
192 | + global $dataDir, $langmessage; |
|
193 | 193 | |
194 | 194 | $possible = $this->variables; |
195 | 195 | |
196 | 196 | $langDir = $dataDir.'/include/thirdparty/ckeditor_34/lang'; //ckeditor |
197 | 197 | |
198 | - $possible['langeditor'] = \gp\tool\Files::readDir($langDir,'js'); |
|
198 | + $possible['langeditor'] = \gp\tool\Files::readDir($langDir, 'js'); |
|
199 | 199 | unset($possible['langeditor']['_languages']); |
200 | 200 | $possible['langeditor']['inherit'] = ' '.$langmessage['default']; //want it to be the first in the list |
201 | 201 | asort($possible['langeditor']); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | //tidy |
223 | 223 | if( function_exists('tidy_parse_string') ){ |
224 | - $possible['HTML_Tidy'] = array('off'=>$langmessage['Off'],''=>$langmessage['On']); |
|
224 | + $possible['HTML_Tidy'] = array('off'=>$langmessage['Off'], ''=>$langmessage['On']); |
|
225 | 225 | }else{ |
226 | 226 | $possible['HTML_Tidy'] = array(''=>'Unavailable'); |
227 | 227 | } |
@@ -229,36 +229,36 @@ discard block |
||
229 | 229 | |
230 | 230 | |
231 | 231 | //required email fields |
232 | - $possible['require_email'] = array( 'none' => 'None', |
|
232 | + $possible['require_email'] = array('none' => 'None', |
|
233 | 233 | '' => 'Subject & Message', |
234 | - 'email' => 'Subject, Message & Email' ); |
|
234 | + 'email' => 'Subject, Message & Email'); |
|
235 | 235 | |
236 | 236 | |
237 | 237 | //see xoopsmultimailer.php |
238 | - $possible['mail_method'] = array( 'mail' => 'PHP mail()', |
|
238 | + $possible['mail_method'] = array('mail' => 'PHP mail()', |
|
239 | 239 | 'sendmail' => 'sendmail', |
240 | 240 | 'smtp' => 'smtp', |
241 | - 'smtpauth' => 'SMTPAuth' ); |
|
241 | + 'smtpauth' => 'SMTPAuth'); |
|
242 | 242 | |
243 | 243 | //CDN |
244 | - foreach(\gp\tool\Output\Combine::$scripts as $key => $script_info){ |
|
244 | + foreach( \gp\tool\Output\Combine::$scripts as $key => $script_info ){ |
|
245 | 245 | if( !isset($script_info['cdn']) ){ |
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | |
249 | - $config_key = 'cdn_'.$key; |
|
249 | + $config_key = 'cdn_'.$key; |
|
250 | 250 | |
251 | 251 | if( !array_key_exists($config_key, $possible) ){ |
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | |
255 | - $opts = array_keys($script_info['cdn']); |
|
256 | - $possible[$config_key] = array_combine($opts, $opts); |
|
257 | - array_unshift($possible[$config_key],$langmessage['None']); |
|
255 | + $opts = array_keys($script_info['cdn']); |
|
256 | + $possible[$config_key] = array_combine($opts, $opts); |
|
257 | + array_unshift($possible[$config_key], $langmessage['None']); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | - gpSettingsOverride('configuration',$possible); |
|
261 | + gpSettingsOverride('configuration', $possible); |
|
262 | 262 | |
263 | 263 | |
264 | 264 | return $possible; |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | global $dataDir; |
275 | 275 | $lang_dir = $dataDir.'/include/languages'; |
276 | 276 | |
277 | - $files = scandir($lang_dir); |
|
278 | - $languages = array(); |
|
279 | - foreach($files as $file){ |
|
280 | - if( $file == '.' || $file == '..' || strpos($file,'main.inc') === false ){ |
|
277 | + $files = scandir($lang_dir); |
|
278 | + $languages = array(); |
|
279 | + foreach( $files as $file ){ |
|
280 | + if( $file == '.' || $file == '..' || strpos($file, 'main.inc') === false ){ |
|
281 | 281 | continue; |
282 | 282 | } |
283 | 283 | |
284 | - $languages[] = str_replace('.main.inc','',$file); |
|
284 | + $languages[] = str_replace('.main.inc', '', $file); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | return array_combine($languages, $languages); |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | protected function showForm(){ |
295 | 295 | global $langmessage; |
296 | 296 | |
297 | - $possible_values = $this->getPossible(); |
|
298 | - $array = $this->getValues(); |
|
297 | + $possible_values = $this->getPossible(); |
|
298 | + $array = $this->getValues(); |
|
299 | 299 | |
300 | 300 | echo '<form action="'.\gp\tool::GetUrl($this->page->requested).'" method="post">'; |
301 | 301 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | |
304 | 304 | //order by the possible values |
305 | 305 | $opened = false; |
306 | - foreach($possible_values as $key => $possible_value){ |
|
306 | + foreach( $possible_values as $key => $possible_value ){ |
|
307 | 307 | |
308 | 308 | if( $possible_value === false ){ |
309 | 309 | if( $opened ){ |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if( isset($langmessage[$key]) ){ |
314 | 314 | echo $langmessage[$key]; |
315 | 315 | }else{ |
316 | - echo str_replace('_',' ',$key); |
|
316 | + echo str_replace('_', ' ', $key); |
|
317 | 317 | } |
318 | 318 | echo '</h2>'; |
319 | 319 | echo '<table class="bordered configuration">'; |
@@ -334,23 +334,23 @@ discard block |
||
334 | 334 | if( isset($langmessage[$key]) ){ |
335 | 335 | echo $langmessage[$key]; |
336 | 336 | }else{ |
337 | - echo str_replace('_',' ',$key); |
|
337 | + echo str_replace('_', ' ', $key); |
|
338 | 338 | } |
339 | 339 | echo '</td><td>'; |
340 | 340 | |
341 | 341 | |
342 | 342 | if( is_array($possible_value) ){ |
343 | - self::formSelect($key,$possible_value,$value); |
|
343 | + self::formSelect($key, $possible_value, $value); |
|
344 | 344 | }else{ |
345 | - switch($possible_value){ |
|
345 | + switch( $possible_value ){ |
|
346 | 346 | case 'boolean': |
347 | - $this->formCheckbox($key,$value); |
|
347 | + $this->formCheckbox($key, $value); |
|
348 | 348 | break; |
349 | 349 | case 'textarea': |
350 | - $this->formTextarea($key,$value); |
|
350 | + $this->formTextarea($key, $value); |
|
351 | 351 | break; |
352 | 352 | default: |
353 | - $this->formInput($key,$value,$possible_value); |
|
353 | + $this->formInput($key, $value, $possible_value); |
|
354 | 354 | break; |
355 | 355 | } |
356 | 356 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | echo '<b>'; |
394 | 394 | echo $langmessage['see_also']; |
395 | 395 | echo '</b> '; |
396 | - echo \gp\tool::Link('Admin/Preferences',$langmessage['Preferences'],'','data-cmd="gpabox"'); |
|
396 | + echo \gp\tool::Link('Admin/Preferences', $langmessage['Preferences'], '', 'data-cmd="gpabox"'); |
|
397 | 397 | echo '</p>'; |
398 | 398 | |
399 | 399 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * |
405 | 405 | */ |
406 | 406 | |
407 | - public function formCheckbox($key,$value){ |
|
407 | + public function formCheckbox($key, $value){ |
|
408 | 408 | $checked = ''; |
409 | 409 | if( $value && $value !== 'false' ){ |
410 | 410 | $checked = ' checked="checked"'; |
@@ -413,22 +413,22 @@ discard block |
||
413 | 413 | echo '<input type="checkbox" name="'.$key.'" value="true" '.$checked.'/> '; |
414 | 414 | } |
415 | 415 | |
416 | - public function formInput($name,$value,$type='text'){ |
|
416 | + public function formInput($name, $value, $type = 'text'){ |
|
417 | 417 | echo "\n<div>"; |
418 | 418 | echo '<input id="'.$name.'" name="'.$name.'" size="50" value="'.htmlspecialchars($value).'" type="'.$type.'" class="gpinput"/>'; |
419 | 419 | echo '</div>'; |
420 | 420 | } |
421 | 421 | |
422 | - public function formTextarea($name,$value){ |
|
422 | + public function formTextarea($name, $value){ |
|
423 | 423 | global $langmessage; |
424 | - $count_label = sprintf($langmessage['_characters'],'<span>'.strlen($value).'</span>'); |
|
424 | + $count_label = sprintf($langmessage['_characters'], '<span>'.strlen($value).'</span>'); |
|
425 | 425 | echo '<span class="show_character_count gptextarea">'; |
426 | 426 | echo '<textarea id="'.$name.'" name="'.$name.'" cols="50" rows="2">'.htmlspecialchars($value).'</textarea>'; |
427 | 427 | echo '<span class="character_count">'.$count_label.'</span>'; |
428 | 428 | echo '</span>'; |
429 | 429 | } |
430 | 430 | |
431 | - public static function formSelect($name,$possible,$value=null){ |
|
431 | + public static function formSelect($name, $possible, $value = null){ |
|
432 | 432 | |
433 | 433 | echo '<div>'; |
434 | 434 | echo "\n".'<select name="'.$name.'" class="gpselect">'; |
@@ -436,23 +436,23 @@ discard block |
||
436 | 436 | echo '<option value="" selected="selected"></option>'; |
437 | 437 | } |
438 | 438 | |
439 | - self::formOptions($possible,$value); |
|
439 | + self::formOptions($possible, $value); |
|
440 | 440 | echo '</select>'; |
441 | 441 | echo '</div>'; |
442 | 442 | } |
443 | 443 | |
444 | - public static function formOptions($array,$current_value){ |
|
444 | + public static function formOptions($array, $current_value){ |
|
445 | 445 | global $languages; |
446 | 446 | |
447 | - foreach($array as $key => $value){ |
|
447 | + foreach( $array as $key => $value ){ |
|
448 | 448 | if( is_array($value) ){ |
449 | 449 | echo '<optgroup label="'.$value.'">'; |
450 | - self::formOptions($value,$current_value); |
|
450 | + self::formOptions($value, $current_value); |
|
451 | 451 | echo '</optgroup>'; |
452 | 452 | continue; |
453 | 453 | } |
454 | 454 | |
455 | - if($key == $current_value){ |
|
455 | + if( $key == $current_value ){ |
|
456 | 456 | $focus = ' selected="selected" '; |
457 | 457 | }else{ |
458 | 458 | $focus = ''; |
@@ -474,17 +474,17 @@ discard block |
||
474 | 474 | function RecreateThumbs($dir_rel = ''){ |
475 | 475 | global $dataDir; |
476 | 476 | |
477 | - $dir_full = $dataDir.'/data/_uploaded'.$dir_rel; |
|
478 | - $files = scandir($dir_full); |
|
477 | + $dir_full = $dataDir.'/data/_uploaded'.$dir_rel; |
|
478 | + $files = scandir($dir_full); |
|
479 | 479 | |
480 | - foreach($files as $file){ |
|
480 | + foreach( $files as $file ){ |
|
481 | 481 | |
482 | 482 | if( $file == '.' || $file == '..' || $file == 'thumbnails' ){ |
483 | 483 | continue; |
484 | 484 | } |
485 | 485 | |
486 | - $file_full = $dir_full.'/'.$file; |
|
487 | - $file_rel = $dir_rel.'/'.$file; |
|
486 | + $file_full = $dir_full.'/'.$file; |
|
487 | + $file_rel = $dir_rel.'/'.$file; |
|
488 | 488 | |
489 | 489 | if( is_dir($file_full) ){ |
490 | 490 | $this->RecreateThumbs($file_rel); |
@@ -366,6 +366,8 @@ |
||
366 | 366 | * - resized images |
367 | 367 | * - \gp\special\Galleries::UpdateGalleryInfo($title,$content) |
368 | 368 | * |
369 | + * @param string $title |
|
370 | + * @param string $file |
|
369 | 371 | */ |
370 | 372 | public static function RestoreFile($title,$file,$title_info){ |
371 | 373 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | if( strpos($file,'/') ){ |
99 | 99 | $existing[] = dirname($file); |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | $existing[] = $file; |
102 | 102 | } |
103 | 103 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | if( \gp\tool\Files::Exists($info_file) ){ |
119 | 119 | $info = \gp\tool\Files::Get($info_file,'deleted'); |
120 | 120 | $info['page_file'] = $dataDir.'/data/_pages/'.$file.'/page.php'; |
121 | - }else{ |
|
121 | + } else{ |
|
122 | 122 | $info['page_file'] = $dataDir.'/data/_pages/'.$file; |
123 | 123 | $info['time'] = filemtime($info['page_file']); |
124 | 124 | $info['orphaned'] = true; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if( isset($title_info['index']) ){ |
330 | 330 | $index = $title_info['index']; |
331 | 331 | $gp_index[$new_title] = $index; |
332 | - }else{ |
|
332 | + } else{ |
|
333 | 333 | $index = \gp\tool::NewFileIndex(); |
334 | 334 | $gp_index[$new_title] = $index; |
335 | 335 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | foreach($this->trash_files as $trash_index => $info){ |
460 | 460 | if( isset($info['orphaned']) ){ |
461 | 461 | $orphaned[$trash_index] = $info; |
462 | - }else{ |
|
462 | + } else{ |
|
463 | 463 | $this->TrashRow($trash_index, $info); |
464 | 464 | } |
465 | 465 | } |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | |
529 | 529 | if( \gp\admin\Tools::CheckPostedNewPage($info['title'], $msg) ){ |
530 | 530 | echo \gp\tool::Link('Admin/Trash',$langmessage['restore'],'cmd=RestoreDeleted&titles[]='.rawurlencode($trash_index),array('data-cmd'=>'postlink')); |
531 | - }else{ |
|
531 | + } else{ |
|
532 | 532 | echo '<span>'.$langmessage['restore'].'</span>'; |
533 | 533 | } |
534 | 534 | echo ' '; |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | |
632 | 632 | if( $file_sections ){ |
633 | 633 | echo \gp\tool\Output\Sections::Render($file_sections,$title_info['title']); |
634 | - }else{ |
|
634 | + } else{ |
|
635 | 635 | echo '<p>This page no longer has any content</p>'; |
636 | 636 | } |
637 | 637 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | parent::__construct($args); |
16 | 16 | |
17 | - $this->page->head_js[] = '/include/js/admin/trash.js'; |
|
18 | - $this->trash_files = self::TrashFiles(); |
|
17 | + $this->page->head_js[] = '/include/js/admin/trash.js'; |
|
18 | + $this->trash_files = self::TrashFiles(); |
|
19 | 19 | |
20 | 20 | $cmd = \gp\tool::GetCommand(); |
21 | - switch($cmd){ |
|
21 | + switch( $cmd ){ |
|
22 | 22 | |
23 | 23 | case 'RestoreDeleted': |
24 | 24 | $this->RestoreDeleted(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | //view a trash file |
33 | - $parts = explode('/',$this->page->requested); |
|
33 | + $parts = explode('/', $this->page->requested); |
|
34 | 34 | if( count($parts) > 2 ){ |
35 | 35 | $title = $parts[2]; |
36 | 36 | if( isset($this->trash_files[$title]) ){ |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | * Delete files in $remove_from_trash |
51 | 51 | * |
52 | 52 | */ |
53 | - public static function ModTrashData($add_to_trash,$remove_from_trash){ |
|
53 | + public static function ModTrashData($add_to_trash, $remove_from_trash){ |
|
54 | 54 | |
55 | 55 | $trash_titles = self::TrashFiles(); |
56 | 56 | |
57 | - foreach((array)$remove_from_trash as $title_index => $info){ |
|
57 | + foreach( (array)$remove_from_trash as $title_index => $info ){ |
|
58 | 58 | unset($trash_titles[$title_index]); |
59 | 59 | |
60 | 60 | //only delete the files if they're in the trash directory |
61 | - if( strpos($info['rm_path'],'/data/_trash') !== false ){ |
|
61 | + if( strpos($info['rm_path'], '/data/_trash') !== false ){ |
|
62 | 62 | \gp\tool\Files::RmAll($info['rm_path']); |
63 | 63 | } |
64 | 64 | } |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | public static function TrashFiles(){ |
76 | 76 | global $dataDir, $gp_index, $config; |
77 | 77 | |
78 | - $trash_titles = array(); |
|
78 | + $trash_titles = array(); |
|
79 | 79 | |
80 | 80 | // pre 4.6, deleted page info was stored |
81 | 81 | $trash_file = $dataDir.'/data/_site/trash.php'; |
82 | 82 | if( \gp\tool\Files::Exists($trash_file) ){ |
83 | - $trash_titles = \gp\tool\Files::Get($trash_file,'trash_titles'); |
|
83 | + $trash_titles = \gp\tool\Files::Get($trash_file, 'trash_titles'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | // get files associated existing titles |
88 | - $pages_dir = $dataDir.'/data/_pages/'; |
|
89 | - $pages_dir_len = strlen($pages_dir); |
|
90 | - $existing = array(); |
|
91 | - foreach($gp_index as $title => $index){ |
|
88 | + $pages_dir = $dataDir.'/data/_pages/'; |
|
89 | + $pages_dir_len = strlen($pages_dir); |
|
90 | + $existing = array(); |
|
91 | + foreach( $gp_index as $title => $index ){ |
|
92 | 92 | |
93 | 93 | if( \gp\tool::SpecialOrAdmin($title) !== false ){ |
94 | 94 | continue; |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | |
97 | 97 | |
98 | 98 | $file = \gp\tool\Files::PageFile($title); |
99 | - $file = substr($file,$pages_dir_len); |
|
99 | + $file = substr($file, $pages_dir_len); |
|
100 | 100 | |
101 | - if( strpos($file,'/') ){ |
|
101 | + if( strpos($file, '/') ){ |
|
102 | 102 | $existing[] = dirname($file); |
103 | 103 | }else{ |
104 | 104 | $existing[] = $file; |
@@ -108,49 +108,49 @@ discard block |
||
108 | 108 | |
109 | 109 | // post 4.6, deleted pages are left in the data/_pages folder |
110 | 110 | $files = scandir($pages_dir); |
111 | - $files = array_diff($files, array('.','..','index.html')); |
|
111 | + $files = array_diff($files, array('.', '..', 'index.html')); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | // add the new files to the list of $trash_titles |
115 | - $new_trash_files = array_diff($files,$existing); |
|
116 | - $page_prefix = substr($config['gpuniq'],0,7).'_'; |
|
117 | - foreach($new_trash_files as $file){ |
|
115 | + $new_trash_files = array_diff($files, $existing); |
|
116 | + $page_prefix = substr($config['gpuniq'], 0, 7).'_'; |
|
117 | + foreach( $new_trash_files as $file ){ |
|
118 | 118 | |
119 | 119 | $info = array(); |
120 | - $info_file = $dataDir.'/data/_pages/'.$file.'/deleted.php'; |
|
120 | + $info_file = $dataDir.'/data/_pages/'.$file.'/deleted.php'; |
|
121 | 121 | if( \gp\tool\Files::Exists($info_file) ){ |
122 | - $info = \gp\tool\Files::Get($info_file,'deleted'); |
|
122 | + $info = \gp\tool\Files::Get($info_file, 'deleted'); |
|
123 | 123 | $info['page_file'] = $dataDir.'/data/_pages/'.$file.'/page.php'; |
124 | 124 | }else{ |
125 | 125 | $info['page_file'] = $dataDir.'/data/_pages/'.$file; |
126 | - $info['time'] = filemtime($info['page_file']); |
|
127 | - $info['orphaned'] = true; |
|
126 | + $info['time'] = filemtime($info['page_file']); |
|
127 | + $info['orphaned'] = true; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | //get index |
131 | - if( strpos($file,$page_prefix) === 0 ){ |
|
132 | - $info['index'] = substr($file,8); // remove page_prefix |
|
131 | + if( strpos($file, $page_prefix) === 0 ){ |
|
132 | + $info['index'] = substr($file, 8); // remove page_prefix |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $info['rm_path'] = $dataDir.'/data/_pages/'.$file; |
136 | - $trash_titles[$file] = $info; |
|
136 | + $trash_titles[$file] = $info; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | //make sure we have a title |
140 | - foreach($trash_titles as $trash_index => &$info){ |
|
140 | + foreach( $trash_titles as $trash_index => &$info ){ |
|
141 | 141 | if( !isset($info['title']) ){ |
142 | - $info['title'] = str_replace('_',' ',$trash_index); |
|
142 | + $info['title'] = str_replace('_', ' ', $trash_index); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | - uasort($trash_titles,array('self','TitleSort')); |
|
146 | + uasort($trash_titles, array('self', 'TitleSort')); |
|
147 | 147 | |
148 | 148 | return $trash_titles; |
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | - public static function TitleSort($a,$b){ |
|
153 | - return strnatcasecmp($a['title'],$b['title']); |
|
152 | + public static function TitleSort($a, $b){ |
|
153 | + return strnatcasecmp($a['title'], $b['title']); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public static function SaveTrashTitles($trash_titles){ |
162 | 162 | global $dataDir; |
163 | 163 | $index_file = $dataDir.'/data/_site/trash.php'; |
164 | - return \gp\tool\Files::SaveData($index_file,'trash_titles',$trash_titles); |
|
164 | + return \gp\tool\Files::SaveData($index_file, 'trash_titles', $trash_titles); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -179,33 +179,33 @@ discard block |
||
179 | 179 | $trash_titles = self::TrashFiles(); |
180 | 180 | } |
181 | 181 | |
182 | - if( !array_key_exists($trash_index,$trash_titles) ){ |
|
182 | + if( !array_key_exists($trash_index, $trash_titles) ){ |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | |
186 | - $title_info = $trash_titles[$trash_index]; |
|
186 | + $title_info = $trash_titles[$trash_index]; |
|
187 | 187 | |
188 | 188 | |
189 | 189 | //make sure we have a file or dir |
190 | 190 | if( empty($title_info['rm_path']) ){ |
191 | 191 | |
192 | 192 | if( empty($title_info['file']) ){ |
193 | - $title_info['file'] = $trash_index.'.php'; |
|
193 | + $title_info['file'] = $trash_index.'.php'; |
|
194 | 194 | } |
195 | - $title_info['rm_path'] = $dataDir.'/data/_trash/'.$title_info['file']; |
|
196 | - $title_info['page_file'] = $dataDir.'/data/_trash/'.$title_info['file']; |
|
195 | + $title_info['rm_path'] = $dataDir.'/data/_trash/'.$title_info['file']; |
|
196 | + $title_info['page_file'] = $dataDir.'/data/_trash/'.$title_info['file']; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | 201 | //make sure we have a label |
202 | 202 | if( empty($title_info['label']) ){ |
203 | - $title_info['label'] = \gp\admin\Tools::LabelToSlug($trash_index); |
|
203 | + $title_info['label'] = \gp\admin\Tools::LabelToSlug($trash_index); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | //make sure we have a file_type |
207 | 207 | if( empty($title_info['type']) ){ |
208 | - $title_info['type'] = self::GetTypes($title_info['page_file']); |
|
208 | + $title_info['type'] = self::GetTypes($title_info['page_file']); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | $source_file = \gp\tool\Files::PageFile($title); |
227 | 227 | $source_dir = dirname($source_file); |
228 | 228 | $trash_file = $source_dir.'/deleted.php'; |
229 | - $file_sections = \gp\tool\Files::Get($source_file,'file_sections'); |
|
229 | + $file_sections = \gp\tool\Files::Get($source_file, 'file_sections'); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | //create trash info file |
233 | - $trash_info = $gp_titles[$index]; |
|
233 | + $trash_info = $gp_titles[$index]; |
|
234 | 234 | $trash_info['title'] = $title; |
235 | 235 | $trash_info['time'] = time(); |
236 | 236 | |
237 | - if( !\gp\tool\Files::SaveData($trash_file,'deleted',$trash_info) ){ |
|
237 | + if( !\gp\tool\Files::SaveData($trash_file, 'deleted', $trash_info) ){ |
|
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | if( count($file_sections) ){ |
244 | 244 | includeFile('image.php'); |
245 | 245 | \gp_resized::SetIndex(); |
246 | - foreach($file_sections as $section_data){ |
|
246 | + foreach( $file_sections as $section_data ){ |
|
247 | 247 | if( isset($section_data['resized_imgs']) ){ |
248 | - \gp\tool\Editing::ResizedImageUse($section_data['resized_imgs'],array()); |
|
248 | + \gp\tool\Editing::ResizedImageUse($section_data['resized_imgs'], array()); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * |
260 | 260 | */ |
261 | 261 | public function RestoreDeleted(){ |
262 | - global $langmessage,$gp_titles,$gp_index; |
|
262 | + global $langmessage, $gp_titles, $gp_index; |
|
263 | 263 | |
264 | 264 | if( empty($_POST['titles']) || !is_array($_POST['titles']) ){ |
265 | 265 | message($langmessage['OOPS'].' (No Titles)'); |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | |
281 | - self::ModTrashData(null,$titles); |
|
281 | + self::ModTrashData(null, $titles); |
|
282 | 282 | |
283 | 283 | $show_titles = array(); |
284 | - foreach($titles as $trash_index => $info){ |
|
285 | - $show_titles[] = \gp\tool::Link($info['title'],$info['title']); |
|
284 | + foreach( $titles as $trash_index => $info ){ |
|
285 | + $show_titles[] = \gp\tool::Link($info['title'], $info['title']); |
|
286 | 286 | unset($this->trash_files[$trash_index]); |
287 | 287 | } |
288 | - $title_string = implode(', ',$show_titles); |
|
288 | + $title_string = implode(', ', $show_titles); |
|
289 | 289 | |
290 | - $link = \gp\tool::GetUrl('Admin/Menu'); |
|
291 | - $message = sprintf($langmessage['file_restored'],$title_string,$link); |
|
290 | + $link = \gp\tool::GetUrl('Admin/Menu'); |
|
291 | + $message = sprintf($langmessage['file_restored'], $title_string, $link); |
|
292 | 292 | |
293 | 293 | message($message); |
294 | 294 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | $new_menu = array(); |
308 | 308 | $restored = array(); |
309 | - foreach($titles as $trash_index){ |
|
309 | + foreach( $titles as $trash_index ){ |
|
310 | 310 | |
311 | 311 | //get trash info about file |
312 | 312 | $title_info = self::GetInfo($trash_index); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | continue; |
315 | 315 | } |
316 | 316 | |
317 | - $new_title = \gp\admin\Tools::CheckPostedNewPage($title_info['title'],$message); |
|
317 | + $new_title = \gp\admin\Tools::CheckPostedNewPage($title_info['title'], $message); |
|
318 | 318 | if( empty($new_title) ){ |
319 | 319 | continue; |
320 | 320 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | // move the trash file to the /_pages directory if needed |
340 | 340 | $new_file = \gp\tool\Files::PageFile($new_title); |
341 | 341 | if( !\gp\tool\Files::Exists($new_file) ){ |
342 | - if( !\gp\tool\Files::Rename($title_info['page_file'],$new_file) ){ |
|
342 | + if( !\gp\tool\Files::Rename($title_info['page_file'], $new_file) ){ |
|
343 | 343 | unset($gp_index[$new_title]); |
344 | 344 | continue; |
345 | 345 | } |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | |
348 | 348 | |
349 | 349 | //add to $gp_titles |
350 | - $gp_titles[$index] = array(); |
|
351 | - $gp_titles[$index]['label'] = $title_info['label']; |
|
352 | - $gp_titles[$index]['type'] = $title_info['type']; |
|
350 | + $gp_titles[$index] = array(); |
|
351 | + $gp_titles[$index]['label'] = $title_info['label']; |
|
352 | + $gp_titles[$index]['type'] = $title_info['type']; |
|
353 | 353 | |
354 | - $new_menu[$index] = array(); |
|
355 | - $restored[$trash_index] = $title_info; |
|
354 | + $new_menu[$index] = array(); |
|
355 | + $restored[$trash_index] = $title_info; |
|
356 | 356 | |
357 | 357 | self::RestoreFile($new_title, $new_file, $title_info); |
358 | 358 | } |
@@ -368,39 +368,39 @@ discard block |
||
368 | 368 | * - \gp\special\Galleries::UpdateGalleryInfo($title,$content) |
369 | 369 | * |
370 | 370 | */ |
371 | - public static function RestoreFile($title,$file,$title_info){ |
|
371 | + public static function RestoreFile($title, $file, $title_info){ |
|
372 | 372 | |
373 | - $file_sections = \gp\tool\Files::Get($file,'file_sections'); |
|
373 | + $file_sections = \gp\tool\Files::Get($file, 'file_sections'); |
|
374 | 374 | |
375 | 375 | // Restore resized images |
376 | 376 | if( count($file_sections) ){ |
377 | 377 | includeFile('image.php'); |
378 | 378 | \gp_resized::SetIndex(); |
379 | - foreach($file_sections as $section => $section_data){ |
|
379 | + foreach( $file_sections as $section => $section_data ){ |
|
380 | 380 | |
381 | 381 | if( !isset($section_data['resized_imgs']) ){ |
382 | 382 | continue; |
383 | 383 | } |
384 | 384 | |
385 | - foreach($section_data['resized_imgs'] as $image_index => $sizes){ |
|
385 | + foreach( $section_data['resized_imgs'] as $image_index => $sizes ){ |
|
386 | 386 | if( !isset(\gp_resized::$index[$image_index]) ){ |
387 | 387 | continue; |
388 | 388 | } |
389 | 389 | $img = \gp_resized::$index[$image_index]; |
390 | - foreach($sizes as $size){ |
|
391 | - list($width,$height) = explode('x',$size); |
|
392 | - \gp\tool\Editing::CreateImage($img,$width,$height); |
|
390 | + foreach( $sizes as $size ){ |
|
391 | + list($width, $height) = explode('x', $size); |
|
392 | + \gp\tool\Editing::CreateImage($img, $width, $height); |
|
393 | 393 | } |
394 | 394 | } |
395 | - \gp\tool\Editing::ResizedImageUse(array(),$section_data['resized_imgs']); |
|
395 | + \gp\tool\Editing::ResizedImageUse(array(), $section_data['resized_imgs']); |
|
396 | 396 | } |
397 | 397 | \gp_resized::SaveIndex(); |
398 | 398 | } |
399 | 399 | |
400 | 400 | |
401 | 401 | // Restore Galleries |
402 | - if( strpos($title_info['type'],'gallery') !== false ){ |
|
403 | - \gp\special\Galleries::UpdateGalleryInfo($title,$file_sections); |
|
402 | + if( strpos($title_info['type'], 'gallery') !== false ){ |
|
403 | + \gp\special\Galleries::UpdateGalleryInfo($title, $file_sections); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public static function GetTypes($file){ |
415 | 415 | |
416 | - $types = array(); |
|
417 | - $file_sections = \gp\tool\Files::Get($file,'file_sections'); |
|
416 | + $types = array(); |
|
417 | + $file_sections = \gp\tool\Files::Get($file, 'file_sections'); |
|
418 | 418 | |
419 | - foreach($file_sections as $section){ |
|
419 | + foreach( $file_sections as $section ){ |
|
420 | 420 | $types[] = $section['type']; |
421 | 421 | } |
422 | 422 | $types = array_unique($types); |
423 | - return implode(',',$types); |
|
423 | + return implode(',', $types); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | * |
430 | 430 | */ |
431 | 431 | public function Trash(){ |
432 | - global $dataDir,$langmessage; |
|
432 | + global $dataDir, $langmessage; |
|
433 | 433 | |
434 | - $this->section_types = \gp\tool\Output\Sections::GetTypes(); |
|
434 | + $this->section_types = \gp\tool\Output\Sections::GetTypes(); |
|
435 | 435 | |
436 | 436 | echo '<h2>'.$langmessage['trash'].'</h2>'; |
437 | 437 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | // non-orphaned |
459 | 459 | $orphaned = array(); |
460 | - foreach($this->trash_files as $trash_index => $info){ |
|
460 | + foreach( $this->trash_files as $trash_index => $info ){ |
|
461 | 461 | if( isset($info['orphaned']) ){ |
462 | 462 | $orphaned[$trash_index] = $info; |
463 | 463 | }else{ |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | $q = array(); |
476 | 476 | $q['titles'] = array_keys($orphaned); |
477 | 477 | $q = 'cmd=DeleteFromTrash&'.http_build_query($q); |
478 | - echo \gp\tool::Link('Admin/Trash',$langmessage['delete'],$q,array('data-cmd'=>'postlink')); |
|
478 | + echo \gp\tool::Link('Admin/Trash', $langmessage['delete'], $q, array('data-cmd'=>'postlink')); |
|
479 | 479 | echo '</td></tr>'; |
480 | 480 | |
481 | - foreach($orphaned as $trash_index => $info){ |
|
481 | + foreach( $orphaned as $trash_index => $info ){ |
|
482 | 482 | $this->TrashRow($trash_index, $info); |
483 | 483 | } |
484 | 484 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | echo '</form>'; |
492 | 492 | } |
493 | 493 | |
494 | - public function TrashRow($trash_index, $info, $show_orphaned = false ){ |
|
494 | + public function TrashRow($trash_index, $info, $show_orphaned = false){ |
|
495 | 495 | global $langmessage; |
496 | 496 | |
497 | 497 | $class = ''; |
@@ -509,15 +509,15 @@ discard block |
||
509 | 509 | echo '(Orphaned) '; |
510 | 510 | } |
511 | 511 | |
512 | - echo \gp\tool::Link('Admin/Trash/'.$trash_index,str_replace('_',' ',$info['title'])); |
|
512 | + echo \gp\tool::Link('Admin/Trash/'.$trash_index, str_replace('_', ' ', $info['title'])); |
|
513 | 513 | echo '</label>'; |
514 | 514 | |
515 | 515 | //time |
516 | 516 | echo '</td><td>'; |
517 | 517 | |
518 | 518 | if( !empty($info['time']) ){ |
519 | - $elapsed = \gp\admin\Tools::Elapsed(time() - $info['time']); |
|
520 | - echo sprintf($langmessage['_ago'],$elapsed); |
|
519 | + $elapsed = \gp\admin\Tools::Elapsed(time()-$info['time']); |
|
520 | + echo sprintf($langmessage['_ago'], $elapsed); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | echo '</td><td>'; |
@@ -528,12 +528,12 @@ discard block |
||
528 | 528 | echo '</td><td>'; |
529 | 529 | |
530 | 530 | if( \gp\admin\Tools::CheckPostedNewPage($info['title'], $msg) ){ |
531 | - echo \gp\tool::Link('Admin/Trash',$langmessage['restore'],'cmd=RestoreDeleted&titles[]='.rawurlencode($trash_index),array('data-cmd'=>'postlink')); |
|
531 | + echo \gp\tool::Link('Admin/Trash', $langmessage['restore'], 'cmd=RestoreDeleted&titles[]='.rawurlencode($trash_index), array('data-cmd'=>'postlink')); |
|
532 | 532 | }else{ |
533 | 533 | echo '<span>'.$langmessage['restore'].'</span>'; |
534 | 534 | } |
535 | 535 | echo ' '; |
536 | - echo \gp\tool::Link('Admin/Trash',$langmessage['delete'],'cmd=DeleteFromTrash&titles[]='.rawurlencode($trash_index),array('data-cmd'=>'postlink')); |
|
536 | + echo \gp\tool::Link('Admin/Trash', $langmessage['delete'], 'cmd=DeleteFromTrash&titles[]='.rawurlencode($trash_index), array('data-cmd'=>'postlink')); |
|
537 | 537 | |
538 | 538 | echo '</td></tr>'; |
539 | 539 | } |
@@ -545,17 +545,17 @@ discard block |
||
545 | 545 | public function TitleTypes($types){ |
546 | 546 | global $gp_titles; |
547 | 547 | |
548 | - $types = explode(',',$types); |
|
548 | + $types = explode(',', $types); |
|
549 | 549 | $types = array_filter($types); |
550 | 550 | $types = array_unique($types); |
551 | 551 | |
552 | - foreach($types as $i => $type){ |
|
552 | + foreach( $types as $i => $type ){ |
|
553 | 553 | if( isset($this->section_types[$type]) && isset($this->section_types[$type]['label']) ){ |
554 | 554 | $types[$i] = $this->section_types[$type]['label']; |
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | - echo implode(', ',$types); |
|
558 | + echo implode(', ', $types); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -563,17 +563,17 @@ discard block |
||
563 | 563 | * |
564 | 564 | */ |
565 | 565 | public function DeleteFromTrash(){ |
566 | - global $dataDir,$langmessage; |
|
566 | + global $dataDir, $langmessage; |
|
567 | 567 | |
568 | 568 | if( empty($_POST['titles']) || !is_array($_POST['titles']) ){ |
569 | 569 | message($langmessage['OOPS'].' (No Titles)'); |
570 | 570 | return; |
571 | 571 | } |
572 | 572 | |
573 | - $titles = array(); |
|
573 | + $titles = array(); |
|
574 | 574 | $incomplete = false; |
575 | 575 | |
576 | - foreach($_POST['titles'] as $trash_index){ |
|
576 | + foreach( $_POST['titles'] as $trash_index ){ |
|
577 | 577 | $title_info = self::GetInfo($trash_index); |
578 | 578 | |
579 | 579 | if( $title_info === false ){ |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | $titles[$trash_index] = $title_info; |
584 | 584 | } |
585 | 585 | |
586 | - if( !self::ModTrashData(null,$titles) ){ |
|
586 | + if( !self::ModTrashData(null, $titles) ){ |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | 590 | |
591 | 591 | //remove the data |
592 | - foreach($titles as $trash_index => $info){ |
|
592 | + foreach( $titles as $trash_index => $info ){ |
|
593 | 593 | \gp\tool\Files::RmAll($info['rm_path']); |
594 | 594 | unset($this->trash_files[$trash_index]); |
595 | 595 | } |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | |
614 | 614 | //delete / restore links |
615 | 615 | echo '<div class="pull-right">'; |
616 | - echo \gp\tool::Link('Admin/Trash',$langmessage['restore'],'cmd=RestoreDeleted&titles[]='.rawurlencode($trash_index),array('data-cmd'=>'cnreq','class'=>'gpsubmit')); |
|
616 | + echo \gp\tool::Link('Admin/Trash', $langmessage['restore'], 'cmd=RestoreDeleted&titles[]='.rawurlencode($trash_index), array('data-cmd'=>'cnreq', 'class'=>'gpsubmit')); |
|
617 | 617 | echo ' '; |
618 | - echo \gp\tool::Link('Admin/Trash',$langmessage['delete'],'cmd=DeleteFromTrash&titles[]='.rawurlencode($trash_index),array('data-cmd'=>'cnreq','class'=>'gpsubmit')); |
|
618 | + echo \gp\tool::Link('Admin/Trash', $langmessage['delete'], 'cmd=DeleteFromTrash&titles[]='.rawurlencode($trash_index), array('data-cmd'=>'cnreq', 'class'=>'gpsubmit')); |
|
619 | 619 | echo '</div>'; |
620 | 620 | |
621 | 621 | |
622 | 622 | echo '<h2 class="hmargin">'; |
623 | - echo \gp\tool::Link('Admin/Trash',$langmessage['trash']); |
|
623 | + echo \gp\tool::Link('Admin/Trash', $langmessage['trash']); |
|
624 | 624 | echo ' » '; |
625 | 625 | echo htmlspecialchars($title_info['title']); |
626 | 626 | echo '</h2>'; |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | |
629 | 629 | |
630 | 630 | //get file sections |
631 | - $file_sections = \gp\tool\Files::Get($title_info['page_file'],'file_sections'); |
|
631 | + $file_sections = \gp\tool\Files::Get($title_info['page_file'], 'file_sections'); |
|
632 | 632 | |
633 | 633 | if( $file_sections ){ |
634 | - echo \gp\tool\Output\Sections::Render($file_sections,$title_info['title']); |
|
634 | + echo \gp\tool\Output\Sections::Render($file_sections, $title_info['title']); |
|
635 | 635 | }else{ |
636 | 636 | echo '<p>This page no longer has any content</p>'; |
637 | 637 | } |
@@ -184,6 +184,9 @@ |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | |
187 | + /** |
|
188 | + * @param string $name |
|
189 | + */ |
|
187 | 190 | public function Checked($name){ |
188 | 191 | |
189 | 192 | if( strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST' ) |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | \gp\tool::LoadComponents('gp-admin-css'); |
14 | 14 | |
15 | - $this->requested = str_replace(' ','_',$title); |
|
16 | - $this->title = $title; |
|
17 | - $this->get_theme_css = false; |
|
18 | - $_REQUEST['gpreq'] = 'admin'; |
|
15 | + $this->requested = str_replace(' ', '_', $title); |
|
16 | + $this->title = $title; |
|
17 | + $this->get_theme_css = false; |
|
18 | + $_REQUEST['gpreq'] = 'admin'; |
|
19 | 19 | |
20 | 20 | $this->head .= "\n".'<meta name="robots" content="noindex,nofollow" />'; |
21 | - @header( 'X-Frame-Options: SAMEORIGIN' ); |
|
21 | + @header('X-Frame-Options: SAMEORIGIN'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function RunScript(){} |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function GetGpxContent(){ |
27 | 27 | |
28 | 28 | |
29 | - $this->head .= "\n<script type=\"text/javascript\">var IE_LT_10 = false;</script><!--[if lt IE 10]>\n<script type=\"text/javascript\">IE_LT_10=true;</script>\n<![endif]-->"; |
|
29 | + $this->head .= "\n<script type=\"text/javascript\">var IE_LT_10 = false;</script><!--[if lt IE 10]>\n<script type=\"text/javascript\">IE_LT_10=true;</script>\n<![endif]-->"; |
|
30 | 30 | $this->head_js[] = '/include/js/login.js'; |
31 | 31 | $this->head_js[] = '/include/js/md5_sha.js'; |
32 | 32 | $this->head_js[] = '/include/thirdparty/js/jsSHA.js'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $_POST += array('username'=>''); |
36 | 36 | |
37 | 37 | $this->admin_js = true; |
38 | - \gp\tool\Session::cookie('g',2); |
|
38 | + \gp\tool\Session::cookie('g', 2); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | echo '<table><tr><td>'; |
47 | 47 | |
48 | 48 | $cmd = \gp\tool::GetCommand(); |
49 | - switch($cmd){ |
|
49 | + switch( $cmd ){ |
|
50 | 50 | case 'send_password'; |
51 | 51 | if( $this->SendPassword() ){ |
52 | 52 | $this->LoginForm(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | echo '<input type="hidden" name="cmd" value="send_password" />'; |
86 | 86 | echo '<input type="submit" name="aa" value="'.$langmessage['send_password'].'" class="login_submit" />'; |
87 | - echo ' <label>'. \gp\tool::Link('Admin',$langmessage['back']).'</label>'; |
|
87 | + echo ' <label>'.\gp\tool::Link('Admin', $langmessage['back']).'</label>'; |
|
88 | 88 | |
89 | 89 | echo '</form>'; |
90 | 90 | echo '</div>'; |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | |
101 | 101 | |
102 | 102 | echo '<div id="loginform">'; |
103 | - echo '<div id="login_timeout" class="nodisplay">Log in Timeout: '.\gp\tool::Link('Admin','Reload to continue...').'</div>'; |
|
103 | + echo '<div id="login_timeout" class="nodisplay">Log in Timeout: '.\gp\tool::Link('Admin', 'Reload to continue...').'</div>'; |
|
104 | 104 | |
105 | 105 | echo '<form action="'.\gp\tool::GetUrl('Admin').'" method="post" id="login_form">'; |
106 | - echo '<input type="hidden" name="file" value="'.htmlspecialchars($_REQUEST['file']).'">'; //for redirection |
|
106 | + echo '<input type="hidden" name="file" value="'.htmlspecialchars($_REQUEST['file']).'">'; //for redirection |
|
107 | 107 | |
108 | 108 | echo '<div>'; |
109 | 109 | echo '<input type="hidden" name="cmd" value="login" />'; |
110 | - echo '<input type="hidden" name="login_nonce" value="'.htmlspecialchars(\gp\tool::new_nonce('login_nonce',true,300)).'" />'; |
|
110 | + echo '<input type="hidden" name="login_nonce" value="'.htmlspecialchars(\gp\tool::new_nonce('login_nonce', true, 300)).'" />'; |
|
111 | 111 | echo '</div>'; |
112 | 112 | |
113 | 113 | echo '<p class="login_text">'; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | echo '<p>'; |
126 | 126 | echo '<input type="submit" class="login_submit" value="'.$langmessage['login'].'" />'; |
127 | 127 | echo ' '; |
128 | - echo \gp\tool::Link('',$langmessage['cancel']); |
|
128 | + echo \gp\tool::Link('', $langmessage['cancel']); |
|
129 | 129 | echo '</p>'; |
130 | 130 | |
131 | 131 | echo '<p>'; |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | |
143 | 143 | echo '<div>'; |
144 | 144 | echo '<label>'; |
145 | - $url = \gp\tool::GetUrl('Admin','cmd=forgotten'); |
|
146 | - echo sprintf($langmessage['forgotten_password'],$url); |
|
145 | + $url = \gp\tool::GetUrl('Admin', 'cmd=forgotten'); |
|
146 | + echo sprintf($langmessage['forgotten_password'], $url); |
|
147 | 147 | echo '</label>'; |
148 | 148 | echo '</div>'; |
149 | 149 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | public function SendPassword(){ |
200 | 200 | global $langmessage, $config; |
201 | 201 | |
202 | - $users = \gp\tool\Files::Get('_site/users'); |
|
203 | - $username = $_POST['username']; |
|
202 | + $users = \gp\tool\Files::Get('_site/users'); |
|
203 | + $username = $_POST['username']; |
|
204 | 204 | |
205 | 205 | if( !isset($users[$username]) ){ |
206 | 206 | message($langmessage['OOPS']); |
@@ -216,29 +216,29 @@ discard block |
||
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | |
219 | - $passwordChars = str_repeat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',3); |
|
219 | + $passwordChars = str_repeat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 3); |
|
220 | 220 | $newpass = str_shuffle($passwordChars); |
221 | - $newpass = substr($newpass,0,8); |
|
222 | - $pass_hash = \gp\tool\Session::PassAlgo($userinfo); |
|
221 | + $newpass = substr($newpass, 0, 8); |
|
222 | + $pass_hash = \gp\tool\Session::PassAlgo($userinfo); |
|
223 | 223 | |
224 | - $users[$username]['newpass'] = \gp\tool::hash($newpass,$pass_hash); |
|
225 | - if( !\gp\tool\Files::SaveData('_site/users','users',$users) ){ |
|
224 | + $users[$username]['newpass'] = \gp\tool::hash($newpass, $pass_hash); |
|
225 | + if( !\gp\tool\Files::SaveData('_site/users', 'users', $users) ){ |
|
226 | 226 | message($langmessage['OOPS']); |
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | 230 | $server = \gp\tool::ServerName(); |
231 | - $link = \gp\tool::AbsoluteLink('Admin',$langmessage['login']); |
|
232 | - $message = sprintf($langmessage['passwordremindertext'],$server,$link,$username,$newpass); |
|
231 | + $link = \gp\tool::AbsoluteLink('Admin', $langmessage['login']); |
|
232 | + $message = sprintf($langmessage['passwordremindertext'], $server, $link, $username, $newpass); |
|
233 | 233 | |
234 | 234 | |
235 | 235 | //send email |
236 | 236 | $mailer = new \gp\tool\Emailer(); |
237 | 237 | |
238 | 238 | if( $mailer->SendEmail($userinfo['email'], $langmessage['new_password'], $message) ){ |
239 | - list($namepart,$sitepart) = explode('@',$userinfo['email']); |
|
240 | - $showemail = substr($namepart,0,3).'...@'.$sitepart; |
|
241 | - message(sprintf($langmessage['password_sent'],$username,$showemail)); |
|
239 | + list($namepart, $sitepart) = explode('@', $userinfo['email']); |
|
240 | + $showemail = substr($namepart, 0, 3).'...@'.$sitepart; |
|
241 | + message(sprintf($langmessage['password_sent'], $username, $showemail)); |
|
242 | 242 | return true; |
243 | 243 | } |
244 | 244 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | case 'send_password'; |
51 | 51 | if( $this->SendPassword() ){ |
52 | 52 | $this->LoginForm(); |
53 | - }else{ |
|
53 | + } else{ |
|
54 | 54 | $this->FogottenPassword(); |
55 | 55 | } |
56 | 56 | break; |
@@ -186,11 +186,13 @@ discard block |
||
186 | 186 | |
187 | 187 | public function Checked($name){ |
188 | 188 | |
189 | - if( strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST' ) |
|
190 | - return ' checked="checked" '; |
|
189 | + if( strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST' ){ |
|
190 | + return ' checked="checked" '; |
|
191 | + } |
|
191 | 192 | |
192 | - if( !isset($_POST[$name]) ) |
|
193 | - return ''; |
|
193 | + if( !isset($_POST[$name]) ){ |
|
194 | + return ''; |
|
195 | + } |
|
194 | 196 | |
195 | 197 | return ' checked="checked" '; |
196 | 198 | } |
@@ -171,6 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * Message or redirect when file is saved |
173 | 173 | * |
174 | + * @param string $new_index |
|
174 | 175 | */ |
175 | 176 | public function HiddenSaved($new_index){ |
176 | 177 | global $langmessage, $page; |
@@ -565,6 +566,7 @@ discard block |
||
565 | 566 | /** |
566 | 567 | * Form for adding external link |
567 | 568 | * |
569 | + * @param string $cmd |
|
568 | 570 | */ |
569 | 571 | public function ExternalForm($cmd,$submit,$args){ |
570 | 572 | global $langmessage; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $url = \gp\tool::AbsoluteUrl($title,'',true,false); |
183 | 183 | msg(sprintf($langmessage['will_redirect'],\gp\tool::Link_Page($title))); |
184 | 184 | $page->ajaxReplace[] = array('location',$url,15000); |
185 | - }else{ |
|
185 | + } else{ |
|
186 | 186 | msg($langmessage['SAVED']); |
187 | 187 | } |
188 | 188 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | if( isset($_POST['insert_how']) ){ |
261 | 261 | $this->InsertDialog($_POST['insert_how']); |
262 | - }else{ |
|
262 | + } else{ |
|
263 | 263 | $this->AddHidden(); |
264 | 264 | } |
265 | 265 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | echo '<span class="slug">'; |
469 | 469 | if( isset($info['title']) ){ |
470 | 470 | echo '/'.$info['title']; |
471 | - }else{ |
|
471 | + } else{ |
|
472 | 472 | echo '/'.$title; |
473 | 473 | } |
474 | 474 | echo '</span>'; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | echo '</td><td>'; |
636 | 636 | if( isset($args['new_win']) ){ |
637 | 637 | echo '<input type="checkbox" name="new_win" value="new_win" checked="checked" />'; |
638 | - }else{ |
|
638 | + } else{ |
|
639 | 639 | echo '<input type="checkbox" name="new_win" value="new_win" />'; |
640 | 640 | } |
641 | 641 | echo '</td></tr>'; |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | $homepage_key = false; |
1018 | 1018 | if( isset($gp_index[$homepage]) ){ |
1019 | 1019 | $homepage_key = $gp_index[$homepage]; |
1020 | - }else{ |
|
1020 | + } else{ |
|
1021 | 1021 | |
1022 | 1022 | foreach($gp_titles as $index => $title){ |
1023 | 1023 | if( $title['label'] === $homepage ){ |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | - switch($this->cmd){ |
|
15 | + switch( $this->cmd ){ |
|
16 | 16 | |
17 | 17 | //adding new files |
18 | 18 | case 'AddHidden': |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | echo '<div class="inline_box">'; |
122 | 122 | |
123 | 123 | echo '<div class="layout_links" style="float:right">'; |
124 | - echo '<a href="#gp_new_copy" data-cmd="tabs" class="selected">'. $langmessage['Copy'] .'</a>'; |
|
125 | - echo '<a href="#gp_new_type" data-cmd="tabs">'. $langmessage['Content Type'] .'</a>'; |
|
124 | + echo '<a href="#gp_new_copy" data-cmd="tabs" class="selected">'.$langmessage['Copy'].'</a>'; |
|
125 | + echo '<a href="#gp_new_type" data-cmd="tabs">'.$langmessage['Content Type'].'</a>'; |
|
126 | 126 | echo '</div>'; |
127 | 127 | |
128 | 128 | |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | echo $langmessage['Copy']; |
152 | 152 | echo '</td><td>'; |
153 | 153 | \gp\admin\Menu\Tools::ScrollList($gp_index); |
154 | - echo sprintf($format_bottom,'CopyPage',$langmessage['create_new_file']); |
|
154 | + echo sprintf($format_bottom, 'CopyPage', $langmessage['create_new_file']); |
|
155 | 155 | |
156 | 156 | |
157 | 157 | //content type |
158 | 158 | echo '<tr id="gp_new_type" style="display:none"><td>'; |
159 | - echo str_replace(' ',' ',$langmessage['Content Type']); |
|
159 | + echo str_replace(' ', ' ', $langmessage['Content Type']); |
|
160 | 160 | echo '</td><td>'; |
161 | 161 | echo '<div id="new_section_links">'; |
162 | 162 | \gp\Page\Edit::NewSections(true); |
163 | 163 | echo '</div>'; |
164 | 164 | |
165 | - echo sprintf($format_bottom,'NewFile',$langmessage['create_new_file']); |
|
165 | + echo sprintf($format_bottom, 'NewFile', $langmessage['create_new_file']); |
|
166 | 166 | echo '</form>'; |
167 | 167 | echo '</div>'; |
168 | 168 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | $this->search_page = 0; //take user back to first page where the new page will be displayed |
179 | 179 | |
180 | 180 | if( isset($_REQUEST['redir']) ){ |
181 | - $title = \gp\tool::IndexToTitle($new_index); |
|
182 | - $url = \gp\tool::AbsoluteUrl($title,'',true,false); |
|
183 | - msg(sprintf($langmessage['will_redirect'],\gp\tool::Link_Page($title))); |
|
184 | - $this->page->ajaxReplace[] = array('location',$url,15000); |
|
181 | + $title = \gp\tool::IndexToTitle($new_index); |
|
182 | + $url = \gp\tool::AbsoluteUrl($title, '', true, false); |
|
183 | + msg(sprintf($langmessage['will_redirect'], \gp\tool::Link_Page($title))); |
|
184 | + $this->page->ajaxReplace[] = array('location', $url, 15000); |
|
185 | 185 | }else{ |
186 | 186 | msg($langmessage['SAVED']); |
187 | 187 | } |
@@ -272,29 +272,29 @@ discard block |
||
272 | 272 | msg($langmessage['OOPS_TITLE']); |
273 | 273 | return false; |
274 | 274 | } |
275 | - $from_index = $gp_index[$from_title]; |
|
276 | - $info = $gp_titles[$from_index]; |
|
275 | + $from_index = $gp_index[$from_title]; |
|
276 | + $info = $gp_titles[$from_index]; |
|
277 | 277 | |
278 | 278 | |
279 | 279 | //check the new title |
280 | 280 | $title = $_POST['title']; |
281 | - $title = \gp\admin\Tools::CheckPostedNewPage($title,$message); |
|
281 | + $title = \gp\admin\Tools::CheckPostedNewPage($title, $message); |
|
282 | 282 | if( $title === false ){ |
283 | 283 | msg($message); |
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
287 | 287 | //get the existing content |
288 | - $from_file = \gp\tool\Files::PageFile($from_title); |
|
289 | - $contents = file_get_contents($from_file); |
|
288 | + $from_file = \gp\tool\Files::PageFile($from_title); |
|
289 | + $contents = file_get_contents($from_file); |
|
290 | 290 | |
291 | 291 | |
292 | 292 | //add to $gp_index first! |
293 | - $index = \gp\tool::NewFileIndex(); |
|
294 | - $gp_index[$title] = $index; |
|
295 | - $file = \gp\tool\Files::PageFile($title); |
|
293 | + $index = \gp\tool::NewFileIndex(); |
|
294 | + $gp_index[$title] = $index; |
|
295 | + $file = \gp\tool\Files::PageFile($title); |
|
296 | 296 | |
297 | - if( !\gp\tool\Files::Save($file,$contents) ){ |
|
297 | + if( !\gp\tool\Files::Save($file, $contents) ){ |
|
298 | 298 | msg($langmessage['OOPS'].' (File not saved)'); |
299 | 299 | return false; |
300 | 300 | } |
@@ -363,16 +363,16 @@ discard block |
||
363 | 363 | |
364 | 364 | //tabs |
365 | 365 | echo '<div class="layout_links">'; |
366 | - echo ' <a href="#gp_Insert_Copy" data-cmd="tabs" class="selected">'. $langmessage['Copy'] .'</a>'; |
|
367 | - echo ' <a href="#gp_Insert_New" data-cmd="tabs">'. $langmessage['new_file'] .'</a>'; |
|
368 | - echo ' <a href="#gp_Insert_Hidden" data-cmd="tabs">'. $langmessage['Available'] .'</a>'; |
|
369 | - echo ' <a href="#gp_Insert_External" data-cmd="tabs">'. $langmessage['External Link'] .'</a>'; |
|
370 | - echo ' <a href="#gp_Insert_Deleted" data-cmd="tabs">'. $langmessage['trash'] .'</a>'; |
|
366 | + echo ' <a href="#gp_Insert_Copy" data-cmd="tabs" class="selected">'.$langmessage['Copy'].'</a>'; |
|
367 | + echo ' <a href="#gp_Insert_New" data-cmd="tabs">'.$langmessage['new_file'].'</a>'; |
|
368 | + echo ' <a href="#gp_Insert_Hidden" data-cmd="tabs">'.$langmessage['Available'].'</a>'; |
|
369 | + echo ' <a href="#gp_Insert_External" data-cmd="tabs">'.$langmessage['External Link'].'</a>'; |
|
370 | + echo ' <a href="#gp_Insert_Deleted" data-cmd="tabs">'.$langmessage['trash'].'</a>'; |
|
371 | 371 | echo '</div>'; |
372 | 372 | |
373 | 373 | |
374 | 374 | // Copy |
375 | - echo sprintf($format_top,'gp_Insert_Copy',''); |
|
375 | + echo sprintf($format_top, 'gp_Insert_Copy', ''); |
|
376 | 376 | echo '<table class="bordered full_width">'; |
377 | 377 | echo '<tr><td>'; |
378 | 378 | echo $langmessage['label']; |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | echo $langmessage['Copy']; |
384 | 384 | echo '</td><td>'; |
385 | 385 | $copy_list = array(); |
386 | - foreach($gp_index as $k => $v){ |
|
387 | - if( strpos($v,'special_') === 0 ){ |
|
386 | + foreach( $gp_index as $k => $v ){ |
|
387 | + if( strpos($v, 'special_') === 0 ){ |
|
388 | 388 | continue; |
389 | 389 | } |
390 | 390 | $copy_list[$k] = $v; |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | \gp\admin\Menu\Tools::ScrollList($copy_list); |
393 | 393 | echo '</td></tr>'; |
394 | 394 | echo '</table>'; |
395 | - echo sprintf($format_bottom,'CopyPage',$langmessage['Copy']); |
|
395 | + echo sprintf($format_bottom, 'CopyPage', $langmessage['Copy']); |
|
396 | 396 | |
397 | 397 | |
398 | 398 | // Insert New |
399 | - echo sprintf($format_top,'gp_Insert_New','nodisplay'); |
|
399 | + echo sprintf($format_top, 'gp_Insert_New', 'nodisplay'); |
|
400 | 400 | echo '<table class="bordered full_width">'; |
401 | 401 | echo '<tr><td>'; |
402 | 402 | echo $langmessage['label']; |
@@ -412,17 +412,17 @@ discard block |
||
412 | 412 | echo '</div>'; |
413 | 413 | echo '</td></tr>'; |
414 | 414 | echo '</table>'; |
415 | - echo sprintf($format_bottom,'NewFile',$langmessage['create_new_file']); |
|
415 | + echo sprintf($format_bottom, 'NewFile', $langmessage['create_new_file']); |
|
416 | 416 | |
417 | 417 | |
418 | 418 | // Insert Hidden |
419 | 419 | $avail = $this->GetAvail_Current(); |
420 | 420 | |
421 | 421 | if( !empty($avail) ){ |
422 | - echo sprintf($format_top,'gp_Insert_Hidden','nodisplay'); |
|
422 | + echo sprintf($format_top, 'gp_Insert_Hidden', 'nodisplay'); |
|
423 | 423 | $avail = array_flip($avail); |
424 | - \gp\admin\Menu\Tools::ScrollList($avail,'keys[]','checkbox',true); |
|
425 | - echo sprintf($format_bottom,'InsertFromHidden',$langmessage['insert_into_menu']); |
|
424 | + \gp\admin\Menu\Tools::ScrollList($avail, 'keys[]', 'checkbox', true); |
|
425 | + echo sprintf($format_bottom, 'InsertFromHidden', $langmessage['insert_into_menu']); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -430,18 +430,18 @@ discard block |
||
430 | 430 | // Insert Deleted / Restore from trash |
431 | 431 | $scroll_list = $this->TrashScrolllist(); |
432 | 432 | if( !empty($scroll_list) ){ |
433 | - echo sprintf($format_top,'gp_Insert_Deleted','nodisplay'); |
|
433 | + echo sprintf($format_top, 'gp_Insert_Deleted', 'nodisplay'); |
|
434 | 434 | echo $scroll_list; |
435 | - echo sprintf($format_bottom,'RestoreFromTrash',$langmessage['restore_from_trash']); |
|
435 | + echo sprintf($format_bottom, 'RestoreFromTrash', $langmessage['restore_from_trash']); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
439 | 439 | //Insert External |
440 | 440 | echo '<div id="gp_Insert_External" class="nodisplay">'; |
441 | - $args = array(); |
|
442 | - $args['insert_how'] = $cmd; |
|
443 | - $args['insert_where'] = $_REQUEST['insert_where']; |
|
444 | - $this->ExternalForm('NewExternal',$langmessage['insert_into_menu'],$args); |
|
441 | + $args = array(); |
|
442 | + $args['insert_how'] = $cmd; |
|
443 | + $args['insert_where'] = $_REQUEST['insert_where']; |
|
444 | + $this->ExternalForm('NewExternal', $langmessage['insert_into_menu'], $args); |
|
445 | 445 | echo '</div>'; |
446 | 446 | |
447 | 447 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | ob_start(); |
465 | 465 | echo '<div class="gp_scrolllist"><div>'; |
466 | 466 | echo '<input type="text" name="search" value="" class="gpsearch" placeholder="'.$langmessage['Search'].'" autocomplete="off" />'; |
467 | - foreach($trashtitles as $title => $info){ |
|
467 | + foreach( $trashtitles as $title => $info ){ |
|
468 | 468 | if( empty($info['label']) ){ |
469 | 469 | continue; |
470 | 470 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | //get list of titles from submitted indexes |
531 | 531 | $titles = array(); |
532 | 532 | if( isset($_POST['keys']) ){ |
533 | - foreach($_POST['keys'] as $index){ |
|
533 | + foreach( $_POST['keys'] as $index ){ |
|
534 | 534 | if( \gp\tool::IndexToTitle($index) !== false ){ |
535 | 535 | $titles[$index]['level'] = 0; |
536 | 536 | } |
@@ -571,8 +571,8 @@ discard block |
||
571 | 571 | |
572 | 572 | $this->CacheSettings(); |
573 | 573 | |
574 | - $titles = array(); |
|
575 | - $menu = \gp\admin\Content\Trash::RestoreTitles($_POST['titles']); |
|
574 | + $titles = array(); |
|
575 | + $menu = \gp\admin\Content\Trash::RestoreTitles($_POST['titles']); |
|
576 | 576 | |
577 | 577 | |
578 | 578 | if( empty($menu) ){ |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | - \gp\admin\Content\Trash::ModTrashData(null,$titles); |
|
590 | + \gp\admin\Content\Trash::ModTrashData(null, $titles); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * Form for adding external link |
596 | 596 | * |
597 | 597 | */ |
598 | - public function ExternalForm($cmd,$submit,$args){ |
|
598 | + public function ExternalForm($cmd, $submit, $args){ |
|
599 | 599 | global $langmessage; |
600 | 600 | |
601 | 601 | //these aren't all required for each usage of ExternalForm() |
@@ -675,9 +675,9 @@ discard block |
||
675 | 675 | return; |
676 | 676 | } |
677 | 677 | |
678 | - $key = $this->NewExternalKey(); |
|
679 | - $insert = array(); |
|
680 | - $insert[$key] = $array; |
|
678 | + $key = $this->NewExternalKey(); |
|
679 | + $insert = array(); |
|
680 | + $insert[$key] = $array; |
|
681 | 681 | |
682 | 682 | if( !$this->SaveNew($insert) ){ |
683 | 683 | $this->RestoreSettings(); |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | public function EditExternal(){ |
694 | 694 | global $langmessage; |
695 | 695 | |
696 | - $key =& $_REQUEST['key']; |
|
696 | + $key = & $_REQUEST['key']; |
|
697 | 697 | if( !isset($this->curr_menu_array[$key]) ){ |
698 | 698 | msg($langmessage['OOPS'].' (Current menu not set)'); |
699 | 699 | return false; |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | |
707 | 707 | echo '<h3>'.$langmessage['External Link'].'</h3>'; |
708 | 708 | |
709 | - $this->ExternalForm('SaveExternal',$langmessage['save'],$info); |
|
709 | + $this->ExternalForm('SaveExternal', $langmessage['save'], $info); |
|
710 | 710 | |
711 | 711 | echo '</div>'; |
712 | 712 | } |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | public function SaveExternal(){ |
720 | 720 | global $langmessage; |
721 | 721 | |
722 | - $key =& $_POST['key']; |
|
722 | + $key = & $_POST['key']; |
|
723 | 723 | if( !isset($this->curr_menu_array[$key]) ){ |
724 | 724 | msg($langmessage['OOPS'].' (Current menu not set)'); |
725 | 725 | return false; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | if( empty($_POST['url']) || $_POST['url'] == 'http://' ){ |
757 | 757 | return false; |
758 | 758 | } |
759 | - $array['url'] = htmlspecialchars($_POST['url']); |
|
759 | + $array['url'] = htmlspecialchars($_POST['url']); |
|
760 | 760 | $array['label'] = \gp\admin\Tools::PostedLabel($_POST['label']); |
761 | 761 | |
762 | 762 | if( empty($array['label']) ){ |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | $num_index = 0; |
778 | 778 | do{ |
779 | - $new_key = '_'.base_convert($num_index,10,36); |
|
779 | + $new_key = '_'.base_convert($num_index, 10, 36); |
|
780 | 780 | $num_index++; |
781 | 781 | }while( isset($this->curr_menu_array[$new_key]) ); |
782 | 782 | |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | //menu modification |
797 | 797 | if( isset($_POST['insert_where']) && isset($_POST['insert_how']) ){ |
798 | 798 | |
799 | - if( !$this->MenuInsert($titles,$_POST['insert_where'],$_POST['insert_how']) ){ |
|
799 | + if( !$this->MenuInsert($titles, $_POST['insert_where'], $_POST['insert_how']) ){ |
|
800 | 800 | msg($langmessage['OOPS'].' (Insert Failed)'); |
801 | 801 | return false; |
802 | 802 | } |
@@ -822,16 +822,16 @@ discard block |
||
822 | 822 | * Insert titles into the current menu if needed |
823 | 823 | * |
824 | 824 | */ |
825 | - public function MenuInsert($titles,$neighbor,$insert_how){ |
|
826 | - switch($insert_how){ |
|
825 | + public function MenuInsert($titles, $neighbor, $insert_how){ |
|
826 | + switch( $insert_how ){ |
|
827 | 827 | case 'insert_before': |
828 | - return $this->MenuInsert_Before($titles,$neighbor); |
|
828 | + return $this->MenuInsert_Before($titles, $neighbor); |
|
829 | 829 | |
830 | 830 | case 'insert_after': |
831 | - return $this->MenuInsert_After($titles,$neighbor); |
|
831 | + return $this->MenuInsert_After($titles, $neighbor); |
|
832 | 832 | |
833 | 833 | case 'insert_child': |
834 | - return $this->MenuInsert_After($titles,$neighbor,1); |
|
834 | + return $this->MenuInsert_After($titles, $neighbor, 1); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | return false; |
@@ -852,10 +852,10 @@ discard block |
||
852 | 852 | |
853 | 853 | $this->CacheSettings(); |
854 | 854 | |
855 | - $_POST += array('index'=>''); |
|
856 | - $indexes = explode(',',$_POST['index']); |
|
855 | + $_POST += array('index'=>''); |
|
856 | + $indexes = explode(',', $_POST['index']); |
|
857 | 857 | |
858 | - foreach($indexes as $index ){ |
|
858 | + foreach( $indexes as $index ){ |
|
859 | 859 | |
860 | 860 | if( count($this->curr_menu_array) == 1 ){ |
861 | 861 | break; |
@@ -894,17 +894,17 @@ discard block |
||
894 | 894 | $this->CacheSettings(); |
895 | 895 | |
896 | 896 | $_POST += array('index'=>''); |
897 | - $indexes = explode(',',$_POST['index']); |
|
898 | - $trash_data = array(); |
|
897 | + $indexes = explode(',', $_POST['index']); |
|
898 | + $trash_data = array(); |
|
899 | 899 | |
900 | 900 | |
901 | - foreach($indexes as $index){ |
|
901 | + foreach( $indexes as $index ){ |
|
902 | 902 | |
903 | - $title = \gp\tool::IndexToTitle($index); |
|
903 | + $title = \gp\tool::IndexToTitle($index); |
|
904 | 904 | |
905 | 905 | // Create file in trash |
906 | 906 | if( $title ){ |
907 | - if( !\gp\admin\Content\Trash::MoveToTrash_File($title,$index,$trash_data) ){ |
|
907 | + if( !\gp\admin\Content\Trash::MoveToTrash_File($title, $index, $trash_data) ){ |
|
908 | 908 | msg($langmessage['OOPS'].' (Not Moved)'); |
909 | 909 | $this->RestoreSettings(); |
910 | 910 | return false; |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | continue; |
920 | 920 | } |
921 | 921 | |
922 | - if( !$this->RmFromMenu($index,false) ){ |
|
922 | + if( !$this->RmFromMenu($index, false) ){ |
|
923 | 923 | msg($langmessage['OOPS']); |
924 | 924 | $this->RestoreSettings(); |
925 | 925 | return false; |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | $link = \gp\tool::GetUrl('Admin/Trash'); |
943 | - msg(sprintf($langmessage['MOVED_TO_TRASH'],$link)); |
|
943 | + msg(sprintf($langmessage['MOVED_TO_TRASH'], $link)); |
|
944 | 944 | |
945 | 945 | |
946 | - \gp\tool\Plugins::Action('MenuPageTrashed',array($indexes)); |
|
946 | + \gp\tool\Plugins::Action('MenuPageTrashed', array($indexes)); |
|
947 | 947 | |
948 | 948 | return true; |
949 | 949 | } |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | global $langmessage, $gp_index; |
962 | 962 | |
963 | 963 | //prepare variables |
964 | - $title =& $_REQUEST['title']; |
|
964 | + $title = & $_REQUEST['title']; |
|
965 | 965 | if( !isset($gp_index[$title]) ){ |
966 | 966 | msg($langmessage['OOPS'].' (R0)'); |
967 | 967 | return false; |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | * |
977 | 977 | */ |
978 | 978 | public function ToggleVisibility(){ |
979 | - $_REQUEST += array('index'=>'','visibility'=>''); |
|
979 | + $_REQUEST += array('index'=>'', 'visibility'=>''); |
|
980 | 980 | \gp\Page\Visibility::Toggle($_REQUEST['index'], $_REQUEST['visibility']); |
981 | 981 | } |
982 | 982 | |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | $homepage_key = $gp_index[$homepage]; |
1025 | 1025 | }else{ |
1026 | 1026 | |
1027 | - foreach($gp_titles as $index => $title){ |
|
1027 | + foreach( $gp_titles as $index => $title ){ |
|
1028 | 1028 | if( $title['label'] === $homepage ){ |
1029 | 1029 | $homepage_key = $index; |
1030 | 1030 | break; |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | $config['homepath_key'] = $homepage_key; |
1041 | - $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']); |
|
1041 | + $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']); |
|
1042 | 1042 | if( !\gp\admin\Tools::SaveConfig(true) ){ |
1043 | 1043 | return; |
1044 | 1044 | } |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | $this->HomepageDisplay(); |
1049 | 1049 | $content = ob_get_clean(); |
1050 | 1050 | |
1051 | - $this->page->ajaxReplace[] = array('inner','.homepage_setting',$content); |
|
1051 | + $this->page->ajaxReplace[] = array('inner', '.homepage_setting', $content); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 |
@@ -114,6 +114,7 @@ |
||
114 | 114 | /** |
115 | 115 | * Get the css class representing the current page's visibility |
116 | 116 | * |
117 | + * @param string $class |
|
117 | 118 | */ |
118 | 119 | public static function VisibilityClass($class, $index){ |
119 | 120 | global $gp_menu, $gp_titles; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $inherit_info = array(); |
36 | 36 | |
37 | 37 | |
38 | - foreach($gp_menu as $id => $titleInfo){ |
|
38 | + foreach( $gp_menu as $id => $titleInfo ){ |
|
39 | 39 | |
40 | 40 | $level = $titleInfo['level']; |
41 | 41 | $inherit_info[$id] = array(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - foreach($current_par_info as $parent_level => $parent_info){ |
|
53 | + foreach( $current_par_info as $parent_level => $parent_info ){ |
|
54 | 54 | $parent_id = $parent_info['id']; |
55 | 55 | |
56 | 56 | if( $parent_level < $level ){ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | */ |
88 | 88 | public static function CurrentLayout($index){ |
89 | - global $config, $gp_titles,$gpLayouts; |
|
89 | + global $config, $gp_titles, $gpLayouts; |
|
90 | 90 | static $Inherit_Info; |
91 | 91 | |
92 | 92 | if( is_null($Inherit_Info) ){ |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | return $class; |
124 | 124 | } |
125 | 125 | |
126 | - $parents = \gp\tool::Parents($index,$gp_menu); |
|
127 | - foreach($parents as $parent_index){ |
|
126 | + $parents = \gp\tool::Parents($index, $gp_menu); |
|
127 | + foreach( $parents as $parent_index ){ |
|
128 | 128 | if( isset($gp_titles[$parent_index]['vis']) ){ |
129 | 129 | $class .= ' private-inherited'; |
130 | 130 | break; |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function MenuLink($data, $class = ''){ |
143 | 143 | |
144 | - $class = 'gp_label sort '.$class; |
|
145 | - $json = \gp\tool::JsonEncode($data); |
|
144 | + $class = 'gp_label sort '.$class; |
|
145 | + $json = \gp\tool::JsonEncode($data); |
|
146 | 146 | |
147 | - echo '<a class="'.$class.'" data-cmd="menu_info" data-arg="'.str_replace('&','&',$data['key']).'" data-json=\''.htmlspecialchars($json,ENT_QUOTES & ~ENT_COMPAT).'\'>'; |
|
147 | + echo '<a class="'.$class.'" data-cmd="menu_info" data-arg="'.str_replace('&', '&', $data['key']).'" data-json=\''.htmlspecialchars($json, ENT_QUOTES & ~ENT_COMPAT).'\'>'; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | if( !isset($gp_titles[$config['homepath_key']]) ){ |
159 | 159 | $config['homepath_key'] = key($gp_menu); |
160 | - $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']); |
|
160 | + $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * @pearm string $type |
171 | 171 | * @param bool $index_as_value |
172 | 172 | */ |
173 | - public static function ScrollList($list, $name = 'from_title', $type = 'radio', $index_as_value = false ){ |
|
173 | + public static function ScrollList($list, $name = 'from_title', $type = 'radio', $index_as_value = false){ |
|
174 | 174 | global $langmessage; |
175 | 175 | |
176 | 176 | $list_out = array(); |
177 | - foreach($list as $title => $index){ |
|
177 | + foreach( $list as $title => $index ){ |
|
178 | 178 | ob_start(); |
179 | 179 | echo '<label>'; |
180 | 180 | if( $index_as_value ){ |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | $list_out[$title] = ob_get_clean(); |
195 | 195 | } |
196 | 196 | |
197 | - uksort($list_out,'strnatcasecmp'); |
|
197 | + uksort($list_out, 'strnatcasecmp'); |
|
198 | 198 | echo '<div class="gp_scrolllist"><div>'; |
199 | 199 | echo '<input type="text" name="search" value="" class="gpsearch" placeholder="'.$langmessage['Search'].'" autocomplete="off" />'; |
200 | - echo implode('',$list_out); |
|
200 | + echo implode('', $list_out); |
|
201 | 201 | echo '</div></div>'; |
202 | 202 | } |
203 | 203 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | //check title |
214 | 214 | $title = $_POST['title']; |
215 | - $title = \gp\admin\Tools::CheckPostedNewPage($title,$message); |
|
215 | + $title = \gp\admin\Tools::CheckPostedNewPage($title, $message); |
|
216 | 216 | if( $title === false ){ |
217 | 217 | msg($message); |
218 | 218 | return false; |
@@ -220,31 +220,31 @@ discard block |
||
220 | 220 | |
221 | 221 | |
222 | 222 | //multiple section types |
223 | - $type = $_POST['content_type']; |
|
223 | + $type = $_POST['content_type']; |
|
224 | 224 | |
225 | 225 | |
226 | 226 | // multiple wrapped sections |
227 | - if( strpos($type,'{') === 0 ){ |
|
228 | - $combo = json_decode($type,true); |
|
227 | + if( strpos($type, '{') === 0 ){ |
|
228 | + $combo = json_decode($type, true); |
|
229 | 229 | if( $combo ){ |
230 | 230 | |
231 | 231 | $combo += array('wrapper_class'=>'gpRow'); |
232 | - $content = self::GetComboContent($combo['types'],$combo['wrapper_class']); |
|
232 | + $content = self::GetComboContent($combo['types'], $combo['wrapper_class']); |
|
233 | 233 | |
234 | 234 | |
235 | 235 | $type = ''; |
236 | 236 | // borrowed from \gp\Page\Edit::ResetFileTypes() |
237 | - foreach($content as $section){ |
|
237 | + foreach( $content as $section ){ |
|
238 | 238 | $type[] = $section['type']; |
239 | 239 | } |
240 | 240 | $type = array_unique($type); |
241 | - $type = array_diff($type,array('')); |
|
241 | + $type = array_diff($type, array('')); |
|
242 | 242 | sort($type); |
243 | - $type = implode(',',$type); |
|
243 | + $type = implode(',', $type); |
|
244 | 244 | } |
245 | 245 | //single section type |
246 | 246 | }else{ |
247 | - $content = \gp\tool\Editing::DefaultContent($type, $_POST['title']); |
|
247 | + $content = \gp\tool\Editing::DefaultContent($type, $_POST['title']); |
|
248 | 248 | if( $content['content'] === false ){ |
249 | 249 | return false; |
250 | 250 | } |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | |
253 | 253 | |
254 | 254 | //add to $gp_index first! |
255 | - $index = \gp\tool::NewFileIndex(); |
|
256 | - $gp_index[$title] = $index; |
|
255 | + $index = \gp\tool::NewFileIndex(); |
|
256 | + $gp_index[$title] = $index; |
|
257 | 257 | |
258 | - if( !\gp\tool\Files::NewTitle($title,$content,$type) ){ |
|
258 | + if( !\gp\tool\Files::NewTitle($title, $content, $type) ){ |
|
259 | 259 | msg($langmessage['OOPS'].' (cn1)'); |
260 | 260 | unset($gp_index[$title]); |
261 | 261 | return false; |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | |
271 | 271 | //add to users editing |
272 | 272 | if( $gpAdmin['editing'] != 'all' ){ |
273 | - $gpAdmin['editing'] = rtrim($gpAdmin['editing'],',').','.$index.','; |
|
273 | + $gpAdmin['editing'] = rtrim($gpAdmin['editing'], ',').','.$index.','; |
|
274 | 274 | |
275 | 275 | |
276 | - $users = \gp\tool\Files::Get('_site/users'); |
|
276 | + $users = \gp\tool\Files::Get('_site/users'); |
|
277 | 277 | $users[$gpAdmin['username']]['editing'] = $gpAdmin['editing']; |
278 | - \gp\tool\Files::SaveData('_site/users','users',$users); |
|
278 | + \gp\tool\Files::SaveData('_site/users', 'users', $users); |
|
279 | 279 | |
280 | 280 | } |
281 | 281 | |
@@ -288,27 +288,27 @@ discard block |
||
288 | 288 | * Get nested Section Combo content |
289 | 289 | * |
290 | 290 | */ |
291 | - public static function GetComboContent($types, $wrapper_class, $content=array()){ |
|
291 | + public static function GetComboContent($types, $wrapper_class, $content = array()){ |
|
292 | 292 | |
293 | 293 | //$combo += array('label'=>$combo_label); // push the combo label through to all subsections if none (no sub-label) given |
294 | 294 | |
295 | 295 | // create wrapper section |
296 | - $section = \gp\tool\Editing::DefaultContent('wrapper_section'); |
|
297 | - $section['contains_sections'] = count($types); |
|
298 | - $section['attributes']['class'] = $wrapper_class; |
|
299 | - $content[] = $section; |
|
296 | + $section = \gp\tool\Editing::DefaultContent('wrapper_section'); |
|
297 | + $section['contains_sections'] = count($types); |
|
298 | + $section['attributes']['class'] = $wrapper_class; |
|
299 | + $content[] = $section; |
|
300 | 300 | |
301 | 301 | |
302 | - foreach($types as $type){ |
|
302 | + foreach( $types as $type ){ |
|
303 | 303 | if( is_array($type) ){ |
304 | 304 | $_wrapper_class = isset($type[1]) ? $type[1] : ''; |
305 | 305 | $content = self::GetComboContent($type[0], $_wrapper_class, $content); |
306 | 306 | }else{ |
307 | 307 | |
308 | - $class = \gp\Page\Edit::TypeClass($type); |
|
309 | - $section = \gp\tool\Editing::DefaultContent($type); |
|
310 | - $section['attributes']['class'] .= ' '.$class; |
|
311 | - $content[] = $section; |
|
308 | + $class = \gp\Page\Edit::TypeClass($type); |
|
309 | + $section = \gp\tool\Editing::DefaultContent($type); |
|
310 | + $section['attributes']['class'] .= ' '.$class; |
|
311 | + $content[] = $section; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if( $parent_level < $level ){ |
57 | 57 | if( isset($inherit_info[$parent_id]['children']) ){ |
58 | 58 | $inherit_info[$parent_id]['children']++; |
59 | - }else{ |
|
59 | + } else{ |
|
60 | 60 | $inherit_info[$parent_id]['children'] = 1; |
61 | 61 | } |
62 | 62 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | echo '<label>'; |
180 | 180 | if( $index_as_value ){ |
181 | 181 | echo '<input type="'.$type.'" name="'.$name.'" value="'.htmlspecialchars($index).'" />'; |
182 | - }else{ |
|
182 | + } else{ |
|
183 | 183 | echo '<input type="'.$type.'" name="'.$name.'" value="'.htmlspecialchars($title).'" />'; |
184 | 184 | } |
185 | 185 | echo '<span>'; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $type = implode(',',$type); |
244 | 244 | } |
245 | 245 | //single section type |
246 | - }else{ |
|
246 | + } else{ |
|
247 | 247 | $content = \gp\tool\Editing::DefaultContent($type, $_POST['title']); |
248 | 248 | if( $content['content'] === false ){ |
249 | 249 | return false; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | if( is_array($type) ){ |
304 | 304 | $_wrapper_class = isset($type[1]) ? $type[1] : ''; |
305 | 305 | $content = self::GetComboContent($type[0], $_wrapper_class, $content); |
306 | - }else{ |
|
306 | + } else{ |
|
307 | 307 | |
308 | 308 | $class = \gp\Page\Edit::TypeClass($type); |
309 | 309 | $section = \gp\tool\Editing::DefaultContent($type); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | if( count($gp_menu) ){ |
352 | 352 | reset($gp_menu); |
353 | 353 | $first_index = key($gp_menu); |
354 | - }else{ |
|
354 | + } else{ |
|
355 | 355 | reset($gp_titles); |
356 | 356 | $first_index = key($gp_titles); |
357 | 357 | } |
@@ -230,6 +230,7 @@ |
||
230 | 230 | /** |
231 | 231 | * Get admin script info if the request slug uses underscores or slashes |
232 | 232 | * |
233 | + * @param string $request_string |
|
233 | 234 | */ |
234 | 235 | private function GetScriptInfo(&$request_string){ |
235 | 236 |
@@ -75,7 +75,7 @@ |
||
75 | 75 | $this->config['content'] = $content; |
76 | 76 | if( $this->SaveConfig() ){ |
77 | 77 | message($langmessage['SAVED']); |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | message($langmessage['OOPS']); |
80 | 80 | } |
81 | 81 | } |
@@ -6,29 +6,29 @@ discard block |
||
6 | 6 | |
7 | 7 | class Page extends \gp\Page{ |
8 | 8 | |
9 | - public $pagetype = 'admin_display'; |
|
9 | + public $pagetype = 'admin_display'; |
|
10 | 10 | |
11 | - public $show_admin_content = true; |
|
12 | - public $non_admin_content = ''; |
|
13 | - public $admin_html = ''; |
|
11 | + public $show_admin_content = true; |
|
12 | + public $non_admin_content = ''; |
|
13 | + public $admin_html = ''; |
|
14 | 14 | |
15 | - private $scripts = array(); |
|
16 | - private $script_keys = array(); |
|
15 | + private $scripts = array(); |
|
16 | + private $script_keys = array(); |
|
17 | 17 | |
18 | 18 | |
19 | 19 | public function __construct($title){ |
20 | 20 | global $langmessage; |
21 | 21 | |
22 | 22 | |
23 | - $this->requested = str_replace(' ','_',$title); |
|
24 | - $this->label = $langmessage['administration']; |
|
25 | - $this->scripts = \gp\admin\Tools::AdminScripts(); |
|
23 | + $this->requested = str_replace(' ', '_', $title); |
|
24 | + $this->label = $langmessage['administration']; |
|
25 | + $this->scripts = \gp\admin\Tools::AdminScripts(); |
|
26 | 26 | $this->script_keys = array_keys($this->scripts); |
27 | - $this->script_keys = array_combine( str_replace('_','/',$this->script_keys), $this->script_keys); |
|
27 | + $this->script_keys = array_combine(str_replace('_', '/', $this->script_keys), $this->script_keys); |
|
28 | 28 | |
29 | 29 | |
30 | 30 | $this->head .= "\n".'<meta name="robots" content="noindex,nofollow" />'; |
31 | - @header( 'X-Frame-Options: SAMEORIGIN' ); |
|
31 | + @header('X-Frame-Options: SAMEORIGIN'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -114,24 +114,24 @@ discard block |
||
114 | 114 | |
115 | 115 | echo '<div id="admin_breadcrumbs" class="cf">'; |
116 | 116 | |
117 | - echo \gp\tool::Link('',$langmessage['Homepage']); |
|
117 | + echo \gp\tool::Link('', $langmessage['Homepage']); |
|
118 | 118 | echo ' » '; |
119 | - echo \gp\tool::Link('Admin',$langmessage['administration']); |
|
119 | + echo \gp\tool::Link('Admin', $langmessage['administration']); |
|
120 | 120 | |
121 | 121 | |
122 | - $crumbs = array(); |
|
123 | - $request_string = str_replace('_','/',$this->requested); |
|
124 | - $parts = explode('/',$request_string); |
|
122 | + $crumbs = array(); |
|
123 | + $request_string = str_replace('_', '/', $this->requested); |
|
124 | + $parts = explode('/', $request_string); |
|
125 | 125 | |
126 | 126 | do{ |
127 | 127 | |
128 | - $request_string = implode('/',$parts); |
|
129 | - $scriptinfo = $this->GetScriptInfo($request_string); |
|
128 | + $request_string = implode('/', $parts); |
|
129 | + $scriptinfo = $this->GetScriptInfo($request_string); |
|
130 | 130 | |
131 | 131 | if( is_array($scriptinfo) && isset($scriptinfo['label']) ){ |
132 | 132 | $crumbs[$request_string] = $scriptinfo['label']; |
133 | 133 | } |
134 | - }while(array_pop($parts)); |
|
134 | + }while( array_pop($parts) ); |
|
135 | 135 | |
136 | 136 | |
137 | 137 | //page label |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | |
141 | 141 | //add to breadcrumbs |
142 | 142 | $crumbs = array_reverse($crumbs); |
143 | - foreach($crumbs as $slug => $label){ |
|
143 | + foreach( $crumbs as $slug => $label ){ |
|
144 | 144 | echo ' » '; |
145 | - echo \gp\tool::Link($slug,$label); |
|
145 | + echo \gp\tool::Link($slug, $label); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | */ |
189 | 189 | private function RunAdminScript(){ |
190 | - global $dataDir,$langmessage; |
|
190 | + global $dataDir, $langmessage; |
|
191 | 191 | |
192 | 192 | |
193 | 193 | if( strtolower($this->requested) == 'admin' ){ |
@@ -197,19 +197,19 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234 |
200 | - $request_string = str_replace('_','/',$this->requested); |
|
201 | - $parts = explode('/',$request_string); |
|
200 | + $request_string = str_replace('_', '/', $this->requested); |
|
201 | + $parts = explode('/', $request_string); |
|
202 | 202 | |
203 | 203 | do{ |
204 | 204 | |
205 | - $request_string = implode('/',$parts); |
|
206 | - $scriptinfo = $this->GetScriptInfo($request_string); |
|
205 | + $request_string = implode('/', $parts); |
|
206 | + $scriptinfo = $this->GetScriptInfo($request_string); |
|
207 | 207 | if( is_array($scriptinfo) ){ |
208 | 208 | |
209 | 209 | if( \gp\admin\Tools::HasPermission($request_string) ){ |
210 | 210 | |
211 | 211 | $this->OrganizeFrequentScripts($request_string); |
212 | - \gp\tool\Output::ExecInfo($scriptinfo, array('page'=>$this) ); |
|
212 | + \gp\tool\Output::ExecInfo($scriptinfo, array('page'=>$this)); |
|
213 | 213 | |
214 | 214 | return; |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | |
223 | 223 | //these are here because they should be available to everyone |
224 | - switch($request_string){ |
|
224 | + switch( $request_string ){ |
|
225 | 225 | case 'Admin/Finder': |
226 | 226 | if( \gp\admin\Tools::HasPermission('Admin_Uploaded') ){ |
227 | 227 | includeFile('thirdparty/finder/connector.php'); |
@@ -262,21 +262,21 @@ discard block |
||
262 | 262 | |
263 | 263 | //find similar |
264 | 264 | $scripts = $this->scripts; |
265 | - $scripts['Admin'] = array(); |
|
265 | + $scripts['Admin'] = array(); |
|
266 | 266 | $similar = array(); |
267 | - $lower_req = strtolower($this->requested); |
|
267 | + $lower_req = strtolower($this->requested); |
|
268 | 268 | |
269 | - foreach($scripts as $key => $script_info){ |
|
270 | - $lower_key = strtolower($key); |
|
269 | + foreach( $scripts as $key => $script_info ){ |
|
270 | + $lower_key = strtolower($key); |
|
271 | 271 | |
272 | - similar_text($lower_req,$lower_key,$percent); |
|
272 | + similar_text($lower_req, $lower_key, $percent); |
|
273 | 273 | $similar[$key] = $percent; |
274 | 274 | } |
275 | 275 | |
276 | 276 | arsort($similar); |
277 | 277 | |
278 | - $redir_key = key($similar); |
|
279 | - $location = \gp\tool::GetUrl($redir_key,'',false); |
|
278 | + $redir_key = key($similar); |
|
279 | + $location = \gp\tool::GetUrl($redir_key, '', false); |
|
280 | 280 | \gp\tool::Redirect($location); |
281 | 281 | } |
282 | 282 | |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | global $langmessage; |
290 | 290 | |
291 | 291 | $cmd = \gp\tool::GetCommand(); |
292 | - switch($cmd){ |
|
292 | + switch( $cmd ){ |
|
293 | 293 | case 'embededcheck': |
294 | 294 | new \gp\admin\Update('embededcheck'); |
295 | 295 | return; |
296 | 296 | |
297 | 297 | case 'autocomplete-titles': |
298 | 298 | $opts = array('var_name'=>false); |
299 | - echo \gp\tool\Editing::AutoCompleteValues(false,$opts); |
|
299 | + echo \gp\tool\Editing::AutoCompleteValues(false, $opts); |
|
300 | 300 | die(); |
301 | 301 | } |
302 | 302 | |
@@ -343,15 +343,15 @@ discard block |
||
343 | 343 | //reduce to length of 5; |
344 | 344 | $count = count($gpAdmin['freq_scripts']); |
345 | 345 | if( $count > 3 ){ |
346 | - for($i=0;$i < ($count - 5);$i++){ |
|
346 | + for( $i = 0; $i < ($count-5); $i++ ){ |
|
347 | 347 | array_pop($gpAdmin['freq_scripts']); |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | 351 | //reduce the hit count on each of the top five |
352 | 352 | $min_value = end($gpAdmin['freq_scripts']); |
353 | - foreach($gpAdmin['freq_scripts'] as $page => $hits){ |
|
354 | - $gpAdmin['freq_scripts'][$page] = $hits - $min_value; |
|
353 | + foreach( $gpAdmin['freq_scripts'] as $page => $hits ){ |
|
354 | + $gpAdmin['freq_scripts'][$page] = $hits-$min_value; |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 |
@@ -314,6 +314,7 @@ |
||
314 | 314 | /** |
315 | 315 | * Get the plugin name from the plugin.js file |
316 | 316 | * use regular expression to look for "CKEDITOR.plugins.add('plugin-name'" |
317 | + * @param \gp\tool\Archive $archive |
|
317 | 318 | */ |
318 | 319 | function FindPluginName($archive, $name){ |
319 | 320 |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | echo $separator; |
89 | 89 | if( $slug == $this->current_subpage ){ |
90 | 90 | echo $label; |
91 | - }else{ |
|
91 | + } else{ |
|
92 | 92 | echo \gp\tool::Link( rtrim('Admin/CKEditor/'.$slug,'/'), $label ); |
93 | 93 | } |
94 | 94 | $separator = ' <span>|</span> '; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | unset( $this->cke_config['plugins'][$plugin] ); |
351 | 351 | if( !$this->SaveConfig() ){ |
352 | 352 | msg($langmessage['OOPS'].' (Not Saved)'); |
353 | - }else{ |
|
353 | + } else{ |
|
354 | 354 | msg($langmessage['SAVED']); |
355 | 355 | } |
356 | 356 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | echo '<textarea name="custom_config" class="custom_config full_width" placeholder="'.htmlspecialchars($placeholder).'">'; |
374 | 374 | if( isset($_POST['custom_config']) ){ |
375 | 375 | echo htmlspecialchars($_POST['custom_config']); |
376 | - }elseif( !empty($this->cke_config['custom_config']) ){ |
|
376 | + } elseif( !empty($this->cke_config['custom_config']) ){ |
|
377 | 377 | echo htmlspecialchars(self::ReadableJson($this->cke_config['custom_config'])); |
378 | 378 | } |
379 | 379 | echo '</textarea>'; |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | |
410 | 410 | if( !$this->SaveConfig() ){ |
411 | 411 | msg($langmessage['OOPS'].' (Not Saved)'); |
412 | - }else{ |
|
412 | + } else{ |
|
413 | 413 | msg($langmessage['SAVED']); |
414 | 414 | } |
415 | 415 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | foreach($mixed as $key => $value){ |
530 | 530 | if( !is_integer($key) && !ctype_digit($key) ){ |
531 | 531 | $indexed = false; |
532 | - }elseif( (int)$key !== $i ){ |
|
532 | + } elseif( (int)$key !== $i ){ |
|
533 | 533 | $indexed = false; |
534 | 534 | } |
535 | 535 | if( !$indexed || is_array($value) ){ |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | } |
548 | 548 | $output .= $separator.']'; |
549 | 549 | |
550 | - }else{ |
|
550 | + } else{ |
|
551 | 551 | $output = '{'; |
552 | 552 | foreach($mixed as $key => $value){ |
553 | 553 | $output .= $comma.$separator.self::ReadableJson($key).' :'.self::ReadableJson($value); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | class CKEditor extends \gp\admin\Base{ |
8 | 8 | |
9 | 9 | var $config_file; |
10 | - var $cke_config = array(); |
|
10 | + var $cke_config = array(); |
|
11 | 11 | var $build_config; |
12 | 12 | |
13 | 13 | var $subpages; |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | ); |
32 | 32 | |
33 | 33 | |
34 | - $parts = explode('/',$this->page->requested); |
|
34 | + $parts = explode('/', $this->page->requested); |
|
35 | 35 | |
36 | - if( count($parts) > 2 && array_key_exists( $parts[2], $this->subpages ) ){ |
|
36 | + if( count($parts) > 2 && array_key_exists($parts[2], $this->subpages) ){ |
|
37 | 37 | $this->current_subpage = $parts[2]; |
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | // commands |
42 | 42 | $cmd = \gp\tool::GetCommand(); |
43 | - switch($cmd){ |
|
43 | + switch( $cmd ){ |
|
44 | 44 | |
45 | 45 | case 'save_custom_config': |
46 | 46 | $this->SaveCustomConfig(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->Heading(); |
64 | 64 | |
65 | 65 | |
66 | - switch($this->current_subpage){ |
|
66 | + switch( $this->current_subpage ){ |
|
67 | 67 | case 'Example': |
68 | 68 | $this->Example(); |
69 | 69 | break; |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | echo '<h2 class="hmargin">CKEditor » '; |
87 | 87 | |
88 | 88 | $separator = ''; |
89 | - foreach($this->subpages as $slug => $label){ |
|
89 | + foreach( $this->subpages as $slug => $label ){ |
|
90 | 90 | echo $separator; |
91 | 91 | if( $slug == $this->current_subpage ){ |
92 | 92 | echo $label; |
93 | 93 | }else{ |
94 | - echo \gp\tool::Link( rtrim('Admin/CKEditor/'.$slug,'/'), $label ); |
|
94 | + echo \gp\tool::Link(rtrim('Admin/CKEditor/'.$slug, '/'), $label); |
|
95 | 95 | } |
96 | 96 | $separator = ' <span>|</span> '; |
97 | 97 | } |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | echo '<form method="post" action="'.\gp\tool::GetUrl($this->page->requested).'" enctype="multipart/form-data">'; |
111 | 111 | echo '<table class="bordered"><tr><th>'.$langmessage['name'].'</th><th>'.$langmessage['Modified'].'</th><th>'.$langmessage['options'].'</th></tr>'; |
112 | 112 | if( count($this->cke_config['plugins']) ){ |
113 | - foreach($this->cke_config['plugins'] as $plugin_name => $plugin_info){ |
|
113 | + foreach( $this->cke_config['plugins'] as $plugin_name => $plugin_info ){ |
|
114 | 114 | echo '<tr><td>'; |
115 | 115 | echo $plugin_name; |
116 | 116 | echo '</td><td>'; |
117 | - echo \gp\tool::date($langmessage['strftime_datetime'],$plugin_info['updated']); |
|
117 | + echo \gp\tool::date($langmessage['strftime_datetime'], $plugin_info['updated']); |
|
118 | 118 | echo '</td><td>'; |
119 | 119 | |
120 | - $attr = array('data-cmd'=>'postlink', 'class'=>'gpconfirm','title'=>sprintf($langmessage['generic_delete_confirm'],$plugin_name)); |
|
121 | - echo \gp\tool::Link($this->page->requested,$langmessage['delete'],'cmd=rmplugin&plugin='.rawurlencode($plugin_name), $attr ); |
|
120 | + $attr = array('data-cmd'=>'postlink', 'class'=>'gpconfirm', 'title'=>sprintf($langmessage['generic_delete_confirm'], $plugin_name)); |
|
121 | + echo \gp\tool::Link($this->page->requested, $langmessage['delete'], 'cmd=rmplugin&plugin='.rawurlencode($plugin_name), $attr); |
|
122 | 122 | echo '</td></tr>'; |
123 | 123 | |
124 | 124 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | |
142 | 142 | $ordered = array(); |
143 | 143 | $count = 0; |
144 | - foreach($this->build_config['plugins'] as $plugin => $status){ |
|
144 | + foreach( $this->build_config['plugins'] as $plugin => $status ){ |
|
145 | 145 | if( !$status ){ |
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - $char = strtoupper($plugin[0]); |
|
150 | - $ordered[$char][] = '<a href="http://ckeditor.com/addon/'.$plugin.'" target="_blank">'.ucfirst($plugin).'</a>'; |
|
149 | + $char = strtoupper($plugin[0]); |
|
150 | + $ordered[$char][] = '<a href="http://ckeditor.com/addon/'.$plugin.'" target="_blank">'.ucfirst($plugin).'</a>'; |
|
151 | 151 | $count++; |
152 | 152 | } |
153 | 153 | |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | echo '<p><br/></p>'; |
156 | 156 | echo '<table class="bordered">'; |
157 | 157 | echo '<tr><th colspan="2">'.$langmessage['Installed'].' ('.$count.')</th></tr>'; |
158 | - foreach($ordered as $char => $plugins){ |
|
158 | + foreach( $ordered as $char => $plugins ){ |
|
159 | 159 | echo '<tr><td>'; |
160 | 160 | echo '<b>'.$char.'</b>'; |
161 | 161 | echo '</td><td>'; |
162 | - echo implode(', ',$plugins); |
|
162 | + echo implode(', ', $plugins); |
|
163 | 163 | echo '</td></tr>'; |
164 | 164 | } |
165 | 165 | echo '</table>'; |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | |
184 | 184 | |
185 | 185 | // get plugin name and check file types |
186 | - $list = $archive->ListFiles(); |
|
186 | + $list = $archive->ListFiles(); |
|
187 | 187 | $plugin_name = ''; |
188 | 188 | $remove_path = ''; |
189 | 189 | |
190 | - foreach($list as $file){ |
|
190 | + foreach( $list as $file ){ |
|
191 | 191 | |
192 | 192 | //don't check extensions on folder |
193 | 193 | if( $file['size'] == 0 ){ |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | |
204 | 204 | //plugin name |
205 | - if( strpos($file['name'],'plugin.js') !== false ){ |
|
205 | + if( strpos($file['name'], 'plugin.js') !== false ){ |
|
206 | 206 | |
207 | 207 | $new_plugin_name = $this->FindPluginName($archive, $file['name']); |
208 | 208 | if( !$new_plugin_name ){ |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | //use the most relevant plugin name |
213 | - $new_path = dirname($file['name']); |
|
213 | + $new_path = dirname($file['name']); |
|
214 | 214 | if( !$plugin_name || strlen($new_path) < strlen($remove_path) ){ |
215 | 215 | $plugin_name = $new_plugin_name; |
216 | 216 | $remove_path = $new_path; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | //move to _ckeditor folder |
237 | 237 | $destination = $dataDir.'/data/_ckeditor/'.$plugin_name; |
238 | - $rename_from = $extract_temp.'/'.ltrim($remove_path,'/'); |
|
238 | + $rename_from = $extract_temp.'/'.ltrim($remove_path, '/'); |
|
239 | 239 | if( !\gp\tool\Files::Replace($rename_from, $destination) ){ |
240 | 240 | msg($langmessage['OOPS'].' (Not replaced)'); |
241 | 241 | return false; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | |
245 | 245 | // save configuration |
246 | - if( !array_key_exists( $plugin_name, $this->cke_config['plugins'] ) ){ |
|
246 | + if( !array_key_exists($plugin_name, $this->cke_config['plugins']) ){ |
|
247 | 247 | $this->cke_config['plugins'][$plugin_name] = array('installed'=>time()); |
248 | 248 | } |
249 | 249 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | |
269 | 269 | $plugin_file = $_FILES['plugin']; |
270 | 270 | |
271 | - if( strpos($plugin_file['name'],'.zip') === false ){ |
|
271 | + if( strpos($plugin_file['name'], '.zip') === false ){ |
|
272 | 272 | msg($langmessage['OOPS'].' (Not a zip file)'); |
273 | 273 | return; |
274 | 274 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | $pattern = '/CKEDITOR\s*\.\s*plugins\s*\.\s*add\s*\(\s*[\'"]([^\'"]+)[\'"]/'; |
330 | 330 | |
331 | - if( !preg_match($pattern,$content,$match) ){ |
|
331 | + if( !preg_match($pattern, $content, $match) ){ |
|
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | |
@@ -343,13 +343,13 @@ discard block |
||
343 | 343 | function RemovePlugin(){ |
344 | 344 | global $langmessage, $dataDir; |
345 | 345 | |
346 | - $plugin =& $_REQUEST['plugin']; |
|
347 | - if( !is_array($this->cke_config['plugins']) || !array_key_exists( $plugin, $this->cke_config['plugins'] ) ){ |
|
346 | + $plugin = & $_REQUEST['plugin']; |
|
347 | + if( !is_array($this->cke_config['plugins']) || !array_key_exists($plugin, $this->cke_config['plugins']) ){ |
|
348 | 348 | msg($langmessage['OOPS'].' ( )'); |
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | - unset( $this->cke_config['plugins'][$plugin] ); |
|
352 | + unset($this->cke_config['plugins'][$plugin]); |
|
353 | 353 | if( !$this->SaveConfig() ){ |
354 | 354 | msg($langmessage['OOPS'].' (Not Saved)'); |
355 | 355 | }else{ |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | |
359 | 359 | |
360 | 360 | $path = $dataDir.'/data/_ckeditor/'.$plugin; |
361 | - \gp\tool\Files::RmAll( $path ); |
|
361 | + \gp\tool\Files::RmAll($path); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | |
@@ -396,10 +396,10 @@ discard block |
||
396 | 396 | function SaveCustomConfig(){ |
397 | 397 | global $langmessage; |
398 | 398 | |
399 | - $custom_config =& $_REQUEST['custom_config']; |
|
399 | + $custom_config = & $_REQUEST['custom_config']; |
|
400 | 400 | $decoded = array(); |
401 | 401 | if( !empty($custom_config) ){ |
402 | - $decoded = json_decode($custom_config,true); |
|
402 | + $decoded = json_decode($custom_config, true); |
|
403 | 403 | if( !is_array($decoded) ){ |
404 | 404 | msg($langmessage['OOPS'].' (Invalid JSON String)'); |
405 | 405 | return false; |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | echo '<h3>'.$langmessage['Current Configuration'].'</h3>'; |
439 | 439 | |
440 | - $default_config = \gp\tool\Editing::CKConfig(array(),'array'); |
|
440 | + $default_config = \gp\tool\Editing::CKConfig(array(), 'array'); |
|
441 | 441 | echo '<pre class="json">'; |
442 | 442 | echo self::ReadableJson($default_config); |
443 | 443 | echo '</pre>'; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * |
450 | 450 | */ |
451 | 451 | function SaveConfig(){ |
452 | - return \gp\tool\Files::SaveData($this->config_file,'cke_config',$this->cke_config); |
|
452 | + return \gp\tool\Files::SaveData($this->config_file, 'cke_config', $this->cke_config); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | */ |
460 | 460 | function Init(){ |
461 | 461 | |
462 | - $this->config_file = '_ckeditor/config'; |
|
463 | - $this->cke_config = \gp\tool\Files::Get($this->config_file,'cke_config'); |
|
462 | + $this->config_file = '_ckeditor/config'; |
|
463 | + $this->cke_config = \gp\tool\Files::Get($this->config_file, 'cke_config'); |
|
464 | 464 | |
465 | 465 | //$this->cke_config += array('custom_config'=>array()); |
466 | - $this->cke_config += array('plugins'=>array()); |
|
466 | + $this->cke_config += array('plugins'=>array()); |
|
467 | 467 | |
468 | 468 | $this->BuildConfig(); |
469 | 469 | } |
@@ -479,30 +479,30 @@ discard block |
||
479 | 479 | |
480 | 480 | |
481 | 481 | //get data from build-config.js to determine which plugins are already included |
482 | - $build_file = $dataDir.'/include/thirdparty/ckeditor_34/build-config.js'; |
|
483 | - $build_config = file_get_contents($build_file); |
|
482 | + $build_file = $dataDir.'/include/thirdparty/ckeditor_34/build-config.js'; |
|
483 | + $build_config = file_get_contents($build_file); |
|
484 | 484 | if( !$build_config ){ |
485 | 485 | return; |
486 | 486 | } |
487 | 487 | |
488 | 488 | |
489 | 489 | // quotes |
490 | - $build_config = str_replace('\'','"',$build_config); |
|
490 | + $build_config = str_replace('\'', '"', $build_config); |
|
491 | 491 | $build_config = str_replace("\r\n", "\n", $build_config); |
492 | 492 | |
493 | 493 | // remove comments |
494 | - $build_config = preg_replace("/\/\*[\d\D]*?\*\//",'',$build_config); |
|
494 | + $build_config = preg_replace("/\/\*[\d\D]*?\*\//", '', $build_config); |
|
495 | 495 | |
496 | 496 | // remove "var CKBUILDER_CONFIG = " |
497 | - $pos = strpos($build_config,'{'); |
|
498 | - $build_config = substr($build_config,$pos); |
|
497 | + $pos = strpos($build_config, '{'); |
|
498 | + $build_config = substr($build_config, $pos); |
|
499 | 499 | $build_config = trim($build_config); |
500 | - $build_config = trim($build_config,';'); |
|
500 | + $build_config = trim($build_config, ';'); |
|
501 | 501 | |
502 | 502 | // fix variable names |
503 | - $build_config = preg_replace("/([a-zA-Z0-9_]+?)\s*:/" , "\"$1\":", $build_config); |
|
503 | + $build_config = preg_replace("/([a-zA-Z0-9_]+?)\s*:/", "\"$1\":", $build_config); |
|
504 | 504 | |
505 | - $this->build_config = json_decode($build_config,true); |
|
505 | + $this->build_config = json_decode($build_config, true); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | $i = 0; |
528 | 528 | $indexed = true; |
529 | 529 | $separator = ' '; |
530 | - foreach($mixed as $key => $value){ |
|
530 | + foreach( $mixed as $key => $value ){ |
|
531 | 531 | if( !is_integer($key) && !ctype_digit($key) ){ |
532 | 532 | $indexed = false; |
533 | 533 | }elseif( (int)$key !== $i ){ |
534 | 534 | $indexed = false; |
535 | 535 | } |
536 | 536 | if( !$indexed || is_array($value) ){ |
537 | - $separator = "\n".str_repeat(' ',$level); |
|
537 | + $separator = "\n".str_repeat(' ', $level); |
|
538 | 538 | } |
539 | 539 | $i++; |
540 | 540 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $comma = ''; |
543 | 543 | if( $indexed ){ |
544 | 544 | $output = '['; |
545 | - foreach($mixed as $key => $value){ |
|
545 | + foreach( $mixed as $key => $value ){ |
|
546 | 546 | $output .= $comma.$separator.self::ReadableJson($value); |
547 | 547 | $comma = ','; |
548 | 548 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | }else{ |
552 | 552 | $output = '{'; |
553 | - foreach($mixed as $key => $value){ |
|
553 | + foreach( $mixed as $key => $value ){ |
|
554 | 554 | $output .= $comma.$separator.self::ReadableJson($key).' :'.self::ReadableJson($value); |
555 | 555 | $comma = ','; |
556 | 556 | } |