Completed
Branch master (16224d)
by Josh
02:32
created
Admin/Admin.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@
 block discarded – undo
21 21
 
22 22
 	}
23 23
 
24
+	/**
25
+	 * @param string $current
26
+	 */
24 27
 	function Heading($current){
25 28
 		global $langmessage;
26 29
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@  discard block
 block discarded – undo
6 6
 gpPlugin_incl('Admin/SimpleBlogPage.php');
7 7
 
8 8
 
9
-class SimipleBlogAdmin extends AdminSimpleBlogPage{
9
+class SimipleBlogAdmin extends AdminSimpleBlogPage {
10 10
 
11
-	function __construct(){
11
+	function __construct() {
12 12
 		global $addonFolderName, $page;
13 13
 
14 14
 		SimpleBlogCommon::Init();
15 15
 
16 16
 		$page->css_admin[]	= '/include/css/addons.css'; //for hmargin css pre gpEasy 3.6
17
-		$page->head_js[]	= '/data/_addoncode/'.$addonFolderName.'/static/admin.js';
17
+		$page->head_js[] = '/data/_addoncode/'.$addonFolderName.'/static/admin.js';
18 18
 		$page->css_admin[]	= '/data/_addoncode/'.$addonFolderName.'/static/admin.css'; //gpPlugin::css('admin.css'); //gpeasy 4.0+
19 19
 
20 20
 
21 21
 
22 22
 	}
23 23
 
24
-	function Heading($current){
24
+	function Heading($current) {
25 25
 		global $langmessage;
26 26
 
27 27
 		$options = array(
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
 			);
33 33
 
34 34
 		$links = array();
35
-		foreach($options as $slug => $label){
36
-			if( $slug == $current ){
35
+		foreach ($options as $slug => $label) {
36
+			if ($slug == $current) {
37 37
 				$links[] = $label;
38
-			}else{
39
-				$links[] = common::Link($slug,$label);
38
+			}else {
39
+				$links[] = common::Link($slug, $label);
40 40
 			}
41 41
 		}
42 42
 
43
-		echo common::Link('Admin_Blog','New Blog Post','cmd=new_form',' class="gpsubmit" style="float:right"');
43
+		echo common::Link('Admin_Blog', 'New Blog Post', 'cmd=new_form', ' class="gpsubmit" style="float:right"');
44 44
 
45 45
 		echo '<h2 class="hmargin">';
46 46
 		$label = gpOutput::SelectText('Blog');
47
-		echo common::Link('Special_Blog',$label);
47
+		echo common::Link('Special_Blog', $label);
48 48
 		echo ' &#187; ';
49
-		echo implode('<span>|</span>',$links);
49
+		echo implode('<span>|</span>', $links);
50 50
 		echo '</h2>';
51 51
 	}
52 52
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 		foreach($options as $slug => $label){
36 36
 			if( $slug == $current ){
37 37
 				$links[] = $label;
38
-			}else{
38
+			} else{
39 39
 				$links[] = common::Link($slug,$label);
40 40
 			}
41 41
 		}
Please login to merge, or discard this patch.
Admin/Configuration.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -364,6 +364,9 @@
 block discarded – undo
364 364
 		echo '</select>';
365 365
 	}
366 366
 
367
+	/**
368
+	 * @param string $name
369
+	 */
367 370
 	function Radio($name,$options,$current){
368 371
 
369 372
 		foreach($options as $value => $label){
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,16 +5,16 @@  discard block
 block discarded – undo
5 5
 gpPlugin_incl('Admin/Admin.php');
6 6
 
7 7
 
8
-class AdminSimpleBlogConfig extends SimipleBlogAdmin{
8
+class AdminSimpleBlogConfig extends SimipleBlogAdmin {
9 9
 
10
-	function __construct(){
10
+	function __construct() {
11 11
 		global $langmessage;
12 12
 
13 13
 		parent::__construct();
14 14
 
15 15
 
16 16
 		$cmd = common::GetCommand();
17
-		switch($cmd){
17
+		switch ($cmd) {
18 18
 			//regen
19 19
 			case 'regen':
20 20
 				SimpleBlogCommon::GenStaticContent();
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 			//config
26 26
 			case 'save_config':
27
-				if( $this->SaveConfig() ){
27
+				if ($this->SaveConfig()) {
28 28
 					SimpleBlogCommon::GenStaticContent();
29 29
 				}
30 30
 			break;
@@ -41,49 +41,49 @@  discard block
 block discarded – undo
41 41
 	 * @return bool
42 42
 	 *
43 43
 	 */
44
-	function SaveConfig(){
44
+	function SaveConfig() {
45 45
 		global $langmessage;
46 46
 
47 47
 
48 48
 		$options = self::Options();
49
-		if( isset($_POST['urls']) && isset($options['urls'][$_POST['urls']]) ){
49
+		if (isset($_POST['urls']) && isset($options['urls'][$_POST['urls']])) {
50 50
 			SimpleBlogCommon::$data['urls'] = $_POST['urls'];
51 51
 		}
52 52
 
53
-		SimpleBlogCommon::$data['per_page']				= (int)$_POST['per_page'];
53
+		SimpleBlogCommon::$data['per_page'] = (int)$_POST['per_page'];
54 54
 
55
-		if( is_numeric($_POST['post_abbrev']) ){
55
+		if (is_numeric($_POST['post_abbrev'])) {
56 56
 			SimpleBlogCommon::$data['post_abbrev'] = (int)$_POST['post_abbrev'];
57
-		}elseif( empty($_POST['post_abbrev']) ){
57
+		}elseif (empty($_POST['post_abbrev'])) {
58 58
 			SimpleBlogCommon::$data['post_abbrev'] = '';
59 59
 		}
60 60
 
61 61
 
62
-		SimpleBlogCommon::$data['gadget_entries']		= (int)$_POST['gadget_entries'];
63
-		SimpleBlogCommon::$data['gadget_abbrev']		= (int)$_POST['gadget_abbrev'];
62
+		SimpleBlogCommon::$data['gadget_entries'] = (int)$_POST['gadget_entries'];
63
+		SimpleBlogCommon::$data['gadget_abbrev'] = (int)$_POST['gadget_abbrev'];
64 64
 
65 65
 		$format = htmlspecialchars($_POST['strftime_format']);
66
-		if( @strftime($format) ){
66
+		if (@strftime($format)) {
67 67
 			SimpleBlogCommon::$data['strftime_format'] = $format;
68 68
 		}
69 69
 
70 70
 
71 71
 		SimpleBlogCommon::$data['feed_entries']			= (int)$_POST['feed_entries'];
72
-		SimpleBlogCommon::$data['feed_abbrev']			= (int)$_POST['feed_abbrev'];
72
+		SimpleBlogCommon::$data['feed_abbrev'] = (int)$_POST['feed_abbrev'];
73 73
 
74 74
 		SimpleBlogCommon::$data['abbrev_image']			= isset($_POST['abbrev_image']);
75
-		SimpleBlogCommon::$data['abbrev_cat']			= isset($_POST['abbrev_cat']);
75
+		SimpleBlogCommon::$data['abbrev_cat'] = isset($_POST['abbrev_cat']);
76 76
 
77 77
 
78 78
 		//comments
79
-		SimpleBlogCommon::$data['allow_comments']		= isset($_POST['allow_comments']);
80
-		SimpleBlogCommon::$data['commenter_website']	= (string)$_POST['commenter_website'];
81
-		SimpleBlogCommon::$data['comment_captcha']		= isset($_POST['comment_captcha']);
79
+		SimpleBlogCommon::$data['allow_comments'] = isset($_POST['allow_comments']);
80
+		SimpleBlogCommon::$data['commenter_website'] = (string)$_POST['commenter_website'];
81
+		SimpleBlogCommon::$data['comment_captcha'] = isset($_POST['comment_captcha']);
82 82
 
83
-		SimpleBlogCommon::$data['subtitle_separator']	= (string)$_POST['subtitle_separator'];
84
-		SimpleBlogCommon::$data['email_comments']		= $_POST['email_comments'];
83
+		SimpleBlogCommon::$data['subtitle_separator'] = (string)$_POST['subtitle_separator'];
84
+		SimpleBlogCommon::$data['email_comments'] = $_POST['email_comments'];
85 85
 
86
-		if( !SimpleBlogCommon::SaveIndex() ){
86
+		if (!SimpleBlogCommon::SaveIndex()) {
87 87
 			message($langmessage['OOPS']);
88 88
 			return false;
89 89
 		}
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 	 * Show the configuration form
99 99
 	 *
100 100
 	 */
101
-	function Config(){
101
+	function Config() {
102 102
 		global $langmessage, $addonFolderName, $gpversion;
103 103
 
104 104
 
105 105
 		$defaults = SimpleBlogCommon::Defaults();
106
-		$array =& SimpleBlogCommon::$data;
106
+		$array = & SimpleBlogCommon::$data;
107 107
 
108 108
 		$label = gpOutput::SelectText('Blog');
109 109
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 
126 126
 		//Pretty Urls
127 127
 		echo '<tr><td>Urls</td><td>';
128
-		if( version_compare($gpversion,'4.0','>=') ){
129
-			self::Radio('urls',$options['urls'],$array['urls']);
130
-		}else{
128
+		if (version_compare($gpversion, '4.0', '>=')) {
129
+			self::Radio('urls', $options['urls'], $array['urls']);
130
+		}else {
131 131
 			echo 'Available in gpEasy 4.0+';
132 132
 		}
133 133
 		echo '</td><td>';
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 		echo '<tr><td>';
181 181
 		echo 'Image in Abbrevation';
182 182
 		echo '</td><td>';
183
-		if( $array['abbrev_image'] ){
183
+		if ($array['abbrev_image']) {
184 184
 			echo '<input type="checkbox" name="abbrev_image" value="allow" checked="checked" />';
185
-		}else{
185
+		}else {
186 186
 			echo '<input type="checkbox" name="abbrev_image" value="allow" />';
187 187
 		}
188 188
 		echo '</td><td></td></tr>';
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 		echo '<tr><td>';
193 193
 		echo 'Categories in Abbrevation';
194 194
 		echo '</td><td>';
195
-		if( $array['abbrev_cat'] ){
195
+		if ($array['abbrev_cat']) {
196 196
 			echo '<input type="checkbox" name="abbrev_cat" value="allow" checked="checked" />';
197
-		}else{
197
+		}else {
198 198
 			echo '<input type="checkbox" name="abbrev_cat" value="allow" />';
199 199
 		}
200 200
 		echo '</td><td></td></tr>';
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 		echo '<tr><td>';
261 261
 		echo 'Allow Comments';
262 262
 		echo '</td><td>';
263
-		if( $array['allow_comments'] ){
263
+		if ($array['allow_comments']) {
264 264
 			echo '<input type="checkbox" name="allow_comments" value="allow" checked="checked" />';
265
-		}else{
265
+		}else {
266 266
 			echo '<input type="checkbox" name="allow_comments" value="allow" />';
267 267
 		}
268 268
 		echo '</td><td></td></tr>';
@@ -281,15 +281,15 @@  discard block
 block discarded – undo
281 281
 		echo 'Commenter Website';
282 282
 		echo '</td><td>';
283 283
 		echo '<select name="commenter_website" class="gpselect">';
284
-			if( $array['commenter_website'] == 'nofollow' ){
284
+			if ($array['commenter_website'] == 'nofollow') {
285 285
 				echo '<option value="">Hide</option>';
286 286
 				echo '<option value="nofollow" selected="selected">Nofollow Link</option>';
287 287
 				echo '<option value="link">Follow Link</option>';
288
-			}elseif( $array['commenter_website'] == 'link' ){
288
+			}elseif ($array['commenter_website'] == 'link') {
289 289
 				echo '<option value="">Hide</option>';
290 290
 				echo '<option value="nofollow" selected="selected">Nofollow Link</option>';
291 291
 				echo '<option value="link" selected="selected">Follow Link</option>';
292
-			}else{
292
+			}else {
293 293
 				echo '<option value="">Hide</option>';
294 294
 				echo '<option value="nofollow">Nofollow Link</option>';
295 295
 				echo '<option value="link">Follow Link</option>';
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 		echo 'reCaptcha';
304 304
 		echo '</td><td>';
305 305
 
306
-		if( !gp_recaptcha::isActive() ){
306
+		if (!gp_recaptcha::isActive()) {
307 307
 			$disabled = ' disabled="disabled" ';
308
-		}else{
308
+		}else {
309 309
 			$disabled = '';
310 310
 		}
311 311
 
312
-		if( $array['comment_captcha'] ){
312
+		if ($array['comment_captcha']) {
313 313
 			echo '<input type="checkbox" name="comment_captcha" value="allow" checked="checked" '.$disabled.'/>';
314
-		}else{
314
+		}else {
315 315
 			echo '<input type="checkbox" name="comment_captcha" value="allow" '.$disabled.'/>';
316 316
 		}
317 317
 		echo '</td><td>';
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
 
330 330
 
331 331
 		echo '<p style="text-align:center">';
332
-			echo common::Link('Admin_Theme_Content',$langmessage['editable_text'],'cmd=addontext&addon='.urlencode($addonFolderName),' title="'.urlencode($langmessage['editable_text']).'" name="gpabox" ');
332
+			echo common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon='.urlencode($addonFolderName), ' title="'.urlencode($langmessage['editable_text']).'" name="gpabox" ');
333 333
 			echo ' &nbsp; &nbsp; ';
334
-			echo common::Link('Admin_BlogConfig','Regenerate Gadget','cmd=regen',' name="creq"');
334
+			echo common::Link('Admin_BlogConfig', 'Regenerate Gadget', 'cmd=regen', ' name="creq"');
335 335
 		echo '</p>';
336 336
 
337 337
 		echo '</form>';
338 338
 	}
339 339
 
340
-	static function Options(){
340
+	static function Options() {
341 341
 
342 342
 		return array(
343 343
 
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
 
353 353
 	}
354 354
 
355
-	function Select($name,$options,$current){
355
+	function Select($name, $options, $current) {
356 356
 		echo '<select name="'.$name.'" class="gpselect">';
357
-		foreach($options as $value => $label){
357
+		foreach ($options as $value => $label) {
358 358
 			$selected = '';
359
-			if( $current == $value){
359
+			if ($current == $value) {
360 360
 				$selected = ' selected="selected"';
361 361
 			}
362 362
 			echo '<option value="'.$value.'"'.$selected.'">'.$label.'</option>';
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
 		echo '</select>';
365 365
 	}
366 366
 
367
-	function Radio($name,$options,$current){
367
+	function Radio($name, $options, $current) {
368 368
 
369
-		foreach($options as $value => $label){
369
+		foreach ($options as $value => $label) {
370 370
 			echo '<div><label>';
371 371
 			$checked = '';
372
-			if( $current == $value){
372
+			if ($current == $value) {
373 373
 				$checked = ' checked';
374 374
 			}
375 375
 			echo '<input type="radio" name="'.$name.'" value="'.$value.'" '.$checked.' /> ';
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 		if( is_numeric($_POST['post_abbrev']) ){
56 56
 			SimpleBlogCommon::$data['post_abbrev'] = (int)$_POST['post_abbrev'];
57
-		}elseif( empty($_POST['post_abbrev']) ){
57
+		} elseif( empty($_POST['post_abbrev']) ){
58 58
 			SimpleBlogCommon::$data['post_abbrev'] = '';
59 59
 		}
60 60
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		echo '<tr><td>Urls</td><td>';
128 128
 		if( version_compare($gpversion,'4.0','>=') ){
129 129
 			self::Radio('urls',$options['urls'],$array['urls']);
130
-		}else{
130
+		} else{
131 131
 			echo 'Available in gpEasy 4.0+';
132 132
 		}
133 133
 		echo '</td><td>';
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		echo '</td><td>';
183 183
 		if( $array['abbrev_image'] ){
184 184
 			echo '<input type="checkbox" name="abbrev_image" value="allow" checked="checked" />';
185
-		}else{
185
+		} else{
186 186
 			echo '<input type="checkbox" name="abbrev_image" value="allow" />';
187 187
 		}
188 188
 		echo '</td><td></td></tr>';
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		echo '</td><td>';
195 195
 		if( $array['abbrev_cat'] ){
196 196
 			echo '<input type="checkbox" name="abbrev_cat" value="allow" checked="checked" />';
197
-		}else{
197
+		} else{
198 198
 			echo '<input type="checkbox" name="abbrev_cat" value="allow" />';
199 199
 		}
200 200
 		echo '</td><td></td></tr>';
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		echo '</td><td>';
263 263
 		if( $array['allow_comments'] ){
264 264
 			echo '<input type="checkbox" name="allow_comments" value="allow" checked="checked" />';
265
-		}else{
265
+		} else{
266 266
 			echo '<input type="checkbox" name="allow_comments" value="allow" />';
267 267
 		}
268 268
 		echo '</td><td></td></tr>';
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 				echo '<option value="">Hide</option>';
286 286
 				echo '<option value="nofollow" selected="selected">Nofollow Link</option>';
287 287
 				echo '<option value="link">Follow Link</option>';
288
-			}elseif( $array['commenter_website'] == 'link' ){
288
+			} elseif( $array['commenter_website'] == 'link' ){
289 289
 				echo '<option value="">Hide</option>';
290 290
 				echo '<option value="nofollow" selected="selected">Nofollow Link</option>';
291 291
 				echo '<option value="link" selected="selected">Follow Link</option>';
292
-			}else{
292
+			} else{
293 293
 				echo '<option value="">Hide</option>';
294 294
 				echo '<option value="nofollow">Nofollow Link</option>';
295 295
 				echo '<option value="link">Follow Link</option>';
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 
306 306
 		if( !gp_recaptcha::isActive() ){
307 307
 			$disabled = ' disabled="disabled" ';
308
-		}else{
308
+		} else{
309 309
 			$disabled = '';
310 310
 		}
311 311
 
312 312
 		if( $array['comment_captcha'] ){
313 313
 			echo '<input type="checkbox" name="comment_captcha" value="allow" checked="checked" '.$disabled.'/>';
314
-		}else{
314
+		} else{
315 315
 			echo '<input type="checkbox" name="comment_captcha" value="allow" '.$disabled.'/>';
316 316
 		}
317 317
 		echo '</td><td>';
Please login to merge, or discard this patch.
Admin/Posts.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -394,7 +394,7 @@
 block discarded – undo
394 394
 
395 395
 	/**
396 396
 	 * Save a new blog post
397
-	 * @return bool
397
+	 * @return false|null
398 398
 	 *
399 399
 	 */
400 400
 	function SaveNew(){
Please login to merge, or discard this patch.
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@  discard block
 block discarded – undo
5 5
 gpPlugin_incl('Admin/Admin.php');
6 6
 
7 7
 
8
-class AdminSimpleBlogPosts extends SimipleBlogAdmin{
8
+class AdminSimpleBlogPosts extends SimipleBlogAdmin {
9 9
 
10
-	public function __construct(){
10
+	public function __construct() {
11 11
 		global $langmessage, $page;
12 12
 		parent::__construct();
13 13
 
14 14
 
15 15
 		//post request
16
-		if( strpos($page->requested,'/') ){
17
-			$parts	= explode('/',$page->requested);
18
-			if( $this->AdminPost($parts[1])  ){
16
+		if (strpos($page->requested, '/')) {
17
+			$parts = explode('/', $page->requested);
18
+			if ($this->AdminPost($parts[1])) {
19 19
 				return;
20 20
 			}
21 21
 		}
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 		//general admin
25 25
 		$cmd = common::GetCommand();
26
-		switch( $cmd ){
26
+		switch ($cmd) {
27 27
 
28 28
 			//creating
29 29
 			case 'save_new';
@@ -56,44 +56,44 @@  discard block
 block discarded – undo
56 56
 	 * Show all blog posts
57 57
 	 *
58 58
 	 */
59
-	public function ShowPosts(){
59
+	public function ShowPosts() {
60 60
 		global $langmessage;
61 61
 
62 62
 		$this->Heading('Admin_Blog');
63 63
 
64
-		$post_ids			= SimpleBlogCommon::AStrToArray('str_index');
64
+		$post_ids = SimpleBlogCommon::AStrToArray('str_index');
65 65
 		$post_titles		= SimpleBlogCommon::AStrToArray('titles');
66 66
 		$post_times			= SimpleBlogCommon::AStrToArray('post_times');
67
-		$post_comments		= SimpleBlogCommon::AStrToArray('comment_counts');
67
+		$post_comments = SimpleBlogCommon::AStrToArray('comment_counts');
68 68
 		$post_drafts		= SimpleBlogCommon::AStrToArray('drafts');
69 69
 		$total_posts		= count($post_ids);
70
-		$per_page			= 20;
71
-		$total_pages		= ceil($total_posts/$per_page);
72
-		$offset				= 0;
70
+		$per_page = 20;
71
+		$total_pages		= ceil($total_posts / $per_page);
72
+		$offset = 0;
73 73
 
74 74
 
75 75
 		//offset
76
-		if( isset($_REQUEST['offset']) && ctype_digit($_REQUEST['offset']) && $_REQUEST['offset'] > 0 ){
77
-			$offset		= $_REQUEST['offset'];
76
+		if (isset($_REQUEST['offset']) && ctype_digit($_REQUEST['offset']) && $_REQUEST['offset'] > 0) {
77
+			$offset = $_REQUEST['offset'];
78 78
 		}
79
-		$post_ids			= array_slice($post_ids, $offset, $per_page);
79
+		$post_ids = array_slice($post_ids, $offset, $per_page);
80 80
 
81 81
 
82 82
 		//pagination links
83 83
 		echo '<div  style="float:right;margin:20px 0;">';
84 84
 		echo '<span class="page_count">';
85
-		echo ($offset+1).' to '.min($total_posts,$offset+$per_page).' of '.$total_posts;
85
+		echo ($offset+1).' to '.min($total_posts, $offset+$per_page).' of '.$total_posts;
86 86
 		echo '</span>';
87 87
 		echo '<ul class="pagination">';
88 88
 
89
-		if( $total_posts > $per_page ){
90
-			for($i = 0; $i < $total_pages; $i++){
91
-				$_offset = $i*$per_page;
89
+		if ($total_posts > $per_page) {
90
+			for ($i = 0; $i < $total_pages; $i++) {
91
+				$_offset = $i * $per_page;
92 92
 				$class = '';
93
-				if( $_offset == $offset ){
93
+				if ($_offset == $offset) {
94 94
 					$class = ' class="active"';
95 95
 				}
96
-				echo '<li '.$class.'>'.common::Link('Admin_Blog',$i+1,'offset='.($_offset)).'</li>';
96
+				echo '<li '.$class.'>'.common::Link('Admin_Blog', $i+1, 'offset='.($_offset)).'</li>';
97 97
 			}
98 98
 		}
99 99
 		echo '</ul>';
@@ -107,63 +107,63 @@  discard block
 block discarded – undo
107 107
 		echo '<th>Options</th>';
108 108
 		echo '</tr></thead>';
109 109
 		echo '<tbody>';
110
-		foreach($post_ids as $i => $post_id){
110
+		foreach ($post_ids as $i => $post_id) {
111 111
 
112 112
 			//draft/pending
113 113
 			echo '<tr><td width="1%">';
114
-			if( isset($post_drafts[$post_id]) ){
114
+			if (isset($post_drafts[$post_id])) {
115 115
 				echo 'Draft';
116
-			}elseif( $post_times[$post_id] > time() ){
116
+			}elseif ($post_times[$post_id] > time()) {
117 117
 				echo 'Pending';
118 118
 			}
119 119
 
120 120
 			//title
121 121
 			echo '</td><td>';
122 122
 			$title = $post_titles[$post_id];
123
-			echo SimpleBlogCommon::PostLink($post_id,$title);
123
+			echo SimpleBlogCommon::PostLink($post_id, $title);
124 124
 
125 125
 			//post time
126 126
 			echo '</td><td>';
127
-			if( isset($post_times[$post_id]) ){
128
-				echo strftime(SimpleBlogCommon::$data['strftime_format'],$post_times[$post_id]);
127
+			if (isset($post_times[$post_id])) {
128
+				echo strftime(SimpleBlogCommon::$data['strftime_format'], $post_times[$post_id]);
129 129
 			}
130 130
 
131 131
 			//comments
132 132
 			echo '</td><td>';
133 133
 			echo '<span style="display:inline-block;min-width:30px">';
134
-			if( isset($post_comments[$post_id]) ){
134
+			if (isset($post_comments[$post_id])) {
135 135
 				echo number_format($post_comments[$post_id]);
136
-			}else{
136
+			}else {
137 137
 				echo '0';
138 138
 			}
139 139
 			echo '</span>';
140 140
 
141 141
 
142
-			if( SimpleBlogCommon::$data['allow_comments'] ){
143
-				$comments_closed	= SimpleBlogCommon::AStrGet('comments_closed',$post_id);
144
-				$open				= gpOutput::SelectText('Open');
145
-				$close				= gpOutput::SelectText('Close');
142
+			if (SimpleBlogCommon::$data['allow_comments']) {
143
+				$comments_closed = SimpleBlogCommon::AStrGet('comments_closed', $post_id);
144
+				$open = gpOutput::SelectText('Open');
145
+				$close = gpOutput::SelectText('Close');
146 146
 
147
-				if( $comments_closed ){
148
-					echo common::Link('Admin_Blog',$open,'cmd=opencomments&id='.$post_id,'name="cnreq"');
147
+				if ($comments_closed) {
148
+					echo common::Link('Admin_Blog', $open, 'cmd=opencomments&id='.$post_id, 'name="cnreq"');
149 149
 					echo ' &nbsp; ';
150 150
 					echo gpOutput::SelectText('Closed');
151
-				}else{
151
+				}else {
152 152
 					echo $open;
153 153
 					echo ' &nbsp; ';
154
-					echo common::Link('Admin_Blog',$close,'cmd=closecomments&id='.$post_id,'name="cnreq"');
154
+					echo common::Link('Admin_Blog', $close, 'cmd=closecomments&id='.$post_id, 'name="cnreq"');
155 155
 				}
156
-			}else{
157
-				echo common::Link('Admin_BlogConfig','Disabled');
156
+			}else {
157
+				echo common::Link('Admin_BlogConfig', 'Disabled');
158 158
 			}
159 159
 
160 160
 
161 161
 			echo '</td><td>';
162
-			echo SimpleBlogCommon::PostLink($post_id,'View Post');
162
+			echo SimpleBlogCommon::PostLink($post_id, 'View Post');
163 163
 			echo ' &nbsp; ';
164
-			echo common::Link('Admin_Blog/'.$post_id,$langmessage['edit'],'cmd=edit_post');
164
+			echo common::Link('Admin_Blog/'.$post_id, $langmessage['edit'], 'cmd=edit_post');
165 165
 			echo ' &nbsp; ';
166
-			echo common::Link('Admin_Blog',$langmessage['delete'],'cmd=deleteentry&del_id='.$post_id,array('class'=>'delete gpconfirm','data-cmd'=>'cnreq','title'=>$langmessage['delete_confirm']));
166
+			echo common::Link('Admin_Blog', $langmessage['delete'], 'cmd=deleteentry&del_id='.$post_id, array('class'=>'delete gpconfirm', 'data-cmd'=>'cnreq', 'title'=>$langmessage['delete_confirm']));
167 167
 
168 168
 			echo '</td></tr>';
169 169
 		}
@@ -176,18 +176,18 @@  discard block
 block discarded – undo
176 176
 	 * Admin a blog post
177 177
 	 *
178 178
 	 */
179
-	public function AdminPost($id){
179
+	public function AdminPost($id) {
180 180
 		global $langmessage;
181 181
 
182
-		if( !ctype_digit($id) ){
182
+		if (!ctype_digit($id)) {
183 183
 			message($langmessage['OOPS'].' (Invalid Request)');
184 184
 			return false;
185 185
 		}
186 186
 
187 187
 
188
-		$this->post_id			= $id;
189
-		$this->post				= SimpleBlogCommon::GetPostContent($id);
190
-		if( !$this->post ){
188
+		$this->post_id = $id;
189
+		$this->post = SimpleBlogCommon::GetPostContent($id);
190
+		if (!$this->post) {
191 191
 			message($langmessage['OOPS'].' (No Post)');
192 192
 			return false;
193 193
 		}
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
 		return true;
198 198
 	}
199 199
 
200
-	private function _AdminPost(){
200
+	private function _AdminPost() {
201 201
 
202 202
 		$cmd = common::GetCommand();
203
-		switch( $cmd ){
203
+		switch ($cmd) {
204 204
 
205 205
 			//editing
206 206
 			case 'save_edit':
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
 	 * Display the form for editing an existing post
218 218
 	 *
219 219
 	 */
220
-	private function EditPost(){
220
+	private function EditPost() {
221 221
 		global $langmessage, $page;
222 222
 
223 223
 
224 224
 
225
-		$page->ajaxReplace	= array();
226
-		$post				= $this->post;
227
-		$_POST				+= $post;
225
+		$page->ajaxReplace = array();
226
+		$post = $this->post;
227
+		$_POST += $post;
228 228
 
229
-		$this->PostForm('Edit Post',$_POST,'save_edit',$this->post_id);
229
+		$this->PostForm('Edit Post', $_POST, 'save_edit', $this->post_id);
230 230
 	}
231 231
 
232 232
 
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	 * Display the form for creating a new post
235 235
 	 *
236 236
 	 */
237
-	private function NewForm(){
238
-		$this->PostForm('New Blog Post',$_POST);
237
+	private function NewForm() {
238
+		$this->PostForm('New Blog Post', $_POST);
239 239
 	}
240 240
 
241 241
 
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
 	 * @param string $cmd
248 248
 	 * @param int|string $post_id
249 249
 	 */
250
-	private function PostForm($label,&$array,$cmd='save_new',$post_id=null){
250
+	private function PostForm($label, &$array, $cmd = 'save_new', $post_id = null) {
251 251
 		global $langmessage;
252 252
 
253 253
 		includeFile('tool/editing.php');
254 254
 
255
-		$array 				+= array('title'=>'', 'content'=>'', 'subtitle'=>'', 'isDraft'=>false, 'categories'=>array(), 'time'=>time() );
256
-		if( $post_id ){
257
-			$array				+= array('isDraft'=>SimpleBlogCommon::AStrGet('drafts',$post_id));
255
+		$array 				+= array('title'=>'', 'content'=>'', 'subtitle'=>'', 'isDraft'=>false, 'categories'=>array(), 'time'=>time());
256
+		if ($post_id) {
257
+			$array				+= array('isDraft'=>SimpleBlogCommon::AStrGet('drafts', $post_id));
258 258
 		}
259
-		$array['title']		= SimpleBlogCommon::Underscores( $array['title'] );
259
+		$array['title'] = SimpleBlogCommon::Underscores($array['title']);
260 260
 
261 261
 		$action = common::GetUrl('Admin_Blog');
262
-		if( $post_id ){
262
+		if ($post_id) {
263 263
 			$action = common::GetUrl('Admin_Blog/'.$post_id);
264 264
 		}
265 265
 
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 		echo '<div style="float:right">';
271 271
 		echo '<input type="hidden" name="cmd" value="'.$cmd.'" />';
272 272
 		echo '<input class="gpsubmit" type="submit" name="" value="'.$langmessage['save'].'" /> ';
273
-		echo common::Link('Admin_Blog',$langmessage['cancel'],'',' class="gpcancel"');
273
+		echo common::Link('Admin_Blog', $langmessage['cancel'], '', ' class="gpcancel"');
274 274
 
275
-		if( $post_id ){
276
-			echo SimpleBlogCommon::PostLink($post_id,'View Post','','target="_blank"');
275
+		if ($post_id) {
276
+			echo SimpleBlogCommon::PostLink($post_id, 'View Post', '', 'target="_blank"');
277 277
 		}
278 278
 
279 279
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		echo '<div class="sb_edit_group">';
310 310
 		echo '<label>';
311 311
 		echo '<input type="checkbox" name="isDraft" value="on" data-cmd="DraftCheckbox" ';
312
-		if( $array['isDraft'] ) echo 'checked="true"';
312
+		if ($array['isDraft']) echo 'checked="true"';
313 313
 		echo '" /> Draft</label>';
314 314
 		echo '</div>';
315 315
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		//categories
322 322
 		echo '<div class="sb_edit_box">';
323 323
 		echo '<div class="sb_edit_group">';
324
-		self::ShowCategoryList($post_id,$array);
324
+		self::ShowCategoryList($post_id, $array);
325 325
 		echo '</div>';
326 326
 		echo '</div>';
327 327
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
 		//content
332 332
 		echo '<div class="sb_post_container_left">';
333
-		gp_edit::UseCK($array['content'],'content');
333
+		gp_edit::UseCK($array['content'], 'content');
334 334
 		echo '</div>';
335 335
 
336 336
 		echo '</div>';
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 	 * Display fields for setting publish date
351 351
 	 *
352 352
 	 */
353
-	public function FieldPublish($array){
353
+	public function FieldPublish($array) {
354 354
 
355 355
 		$style = '';
356
-		if( $array['isDraft'] ){
356
+		if ($array['isDraft']) {
357 357
 			$style = ' style="display:none"';
358 358
 		}
359 359
 
@@ -362,13 +362,13 @@  discard block
 block discarded – undo
362 362
 
363 363
 
364 364
 		//month
365
-		$pub_month	= date('n',$array['time']);
366
-		$months		= array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
365
+		$pub_month = date('n', $array['time']);
366
+		$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
367 367
 
368 368
 		echo '<select name="pub_month" style="width:4.3em">';
369
-		for($i = 1; $i <= 12; $i++){
369
+		for ($i = 1; $i <= 12; $i++) {
370 370
 			$selected = '';
371
-			if( $i == $pub_month ){
371
+			if ($i == $pub_month) {
372 372
 				$selected = 'selected';
373 373
 			}
374 374
 			echo '<option value="'.$i.'" '.$selected.'>'.$months[$i-1].' ('.$i.')</option>';
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
 		echo '</select>';
377 377
 
378 378
 		//day
379
-		echo '<input name="pub_day" value="'.date('d',$array['time']).'" style="width:2em"/>';
379
+		echo '<input name="pub_day" value="'.date('d', $array['time']).'" style="width:2em"/>';
380 380
 		echo ', ';
381
-		echo '<input name="pub_year" value="'.date('Y',$array['time']).'" style="width:4em"/>';
381
+		echo '<input name="pub_year" value="'.date('Y', $array['time']).'" style="width:4em"/>';
382 382
 
383 383
 		//time
384 384
 		echo '@';
385
-		echo '<input name="pub_hour" value="'.date('H',$array['time']).'" style="width:2em"/>';
385
+		echo '<input name="pub_hour" value="'.date('H', $array['time']).'" style="width:2em"/>';
386 386
 		echo ':';
387
-		echo '<input name="pub_min" value="'.date('i',$array['time']).'" style="width:2em"/>';
387
+		echo '<input name="pub_min" value="'.date('i', $array['time']).'" style="width:2em"/>';
388 388
 
389 389
 
390 390
 		echo '</div>';
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * @return bool
398 398
 	 *
399 399
 	 */
400
-	function SaveNew(){
400
+	function SaveNew() {
401 401
 		global $langmessage, $gpAdmin;
402 402
 
403 403
 		//use current data file or create new one
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
 
407 407
 		//add new_id to list of indeces
408 408
 		$str_index = SimpleBlogCommon::AStrToArray('str_index');
409
-		array_unshift($str_index,$new_id);
410
-		SimpleBlogCommon::$data['str_index']	= SimpleBlogCommon::AStrFromArray($str_index);
409
+		array_unshift($str_index, $new_id);
410
+		SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($str_index);
411 411
 
412 412
 
413 413
 		//save to data file
414 414
 		$post = array();
415
-		if( !self::SavePost($new_id, $post) ){
415
+		if (!self::SavePost($new_id, $post)) {
416 416
 			return false;
417 417
 		}
418 418
 
419 419
 		//redirect to new post
420
-		$url = common::GetUrl('Admin_Blog','',false);
420
+		$url = common::GetUrl('Admin_Blog', '', false);
421 421
 		common::Redirect($url);
422 422
 	}
423 423
 
@@ -429,18 +429,18 @@  discard block
 block discarded – undo
429 429
 	 * @return bool
430 430
 	 *
431 431
 	 */
432
-	private function SaveEdit(){
432
+	private function SaveEdit() {
433 433
 		global $langmessage;
434 434
 
435 435
 
436 436
 		//save to data file
437
-		if( !self::SavePost($this->post_id, $this->post) ){
437
+		if (!self::SavePost($this->post_id, $this->post)) {
438 438
 			message($langmessage['OOPS'].' (Post not saved)');
439 439
 			return false;
440 440
 		}
441 441
 
442 442
 
443
-		$this->post			= SimpleBlogCommon::GetPostContent($this->post_id);
443
+		$this->post = SimpleBlogCommon::GetPostContent($this->post_id);
444 444
 
445 445
 		return true;
446 446
 	}
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 	 * Save the post
451 451
 	 *
452 452
 	 */
453
-	public static function SavePost($post_id, $post){
453
+	public static function SavePost($post_id, $post) {
454 454
 		global $langmessage;
455 455
 
456
-		$_POST			+= array('title'=>'', 'content'=>'', 'subtitle'=>'', 'isDraft'=>'','category'=>array());
456
+		$_POST += array('title'=>'', 'content'=>'', 'subtitle'=>'', 'isDraft'=>'', 'category'=>array());
457 457
 		$title			= htmlspecialchars($_POST['title']);
458 458
 		$title			= trim($title);
459 459
 
460
-		if( empty($title) ){
460
+		if (empty($title)) {
461 461
 			message($langmessage['TITLE_REQUIRED']);
462 462
 			return false;
463 463
 		}
@@ -467,12 +467,12 @@  discard block
 block discarded – undo
467 467
 
468 468
 		//different time
469 469
 		//organize posts based on publish time
470
-		SimpleBlogCommon::AStrSet('post_times',$post_id,$_POST['time']);
471
-		$post_times			= SimpleBlogCommon::AStrToArray('post_times');
470
+		SimpleBlogCommon::AStrSet('post_times', $post_id, $_POST['time']);
471
+		$post_times = SimpleBlogCommon::AStrToArray('post_times');
472 472
 		arsort($post_times);
473 473
 
474
-		$str_index			= array_keys($post_times);
475
-		SimpleBlogCommon::$data['str_index']	= SimpleBlogCommon::AStrFromArray($str_index);
474
+		$str_index = array_keys($post_times);
475
+		SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($str_index);
476 476
 
477 477
 
478 478
 		//get next static gen time
@@ -480,33 +480,33 @@  discard block
 block discarded – undo
480 480
 
481 481
 
482 482
 		//create post array
483
-		$post['title']			= $title;
484
-		$post['content']		= $_POST['content'];
485
-		$post['subtitle']		= htmlspecialchars($_POST['subtitle']);
486
-		$post['categories']		= $_POST['category'];
487
-		$post['time']			= $_POST['time'];
483
+		$post['title'] = $title;
484
+		$post['content'] = $_POST['content'];
485
+		$post['subtitle'] = htmlspecialchars($_POST['subtitle']);
486
+		$post['categories'] = $_POST['category'];
487
+		$post['time'] = $_POST['time'];
488 488
 		unset($post['isDraft']);
489 489
 
490 490
 
491 491
 		//save to data file
492
-		if( !parent::SavePost($post_id, $post) ){
492
+		if (!parent::SavePost($post_id, $post)) {
493 493
 			return false;
494 494
 		}
495 495
 
496 496
 
497 497
 		//draft
498
-		if( $_POST['isDraft'] === 'on' ){
499
-			SimpleBlogCommon::AStrSet('drafts',$post_id,1);
500
-		}else{
501
-			SimpleBlogCommon::AStrRm('drafts',$post_id);
498
+		if ($_POST['isDraft'] === 'on') {
499
+			SimpleBlogCommon::AStrSet('drafts', $post_id, 1);
500
+		}else {
501
+			SimpleBlogCommon::AStrRm('drafts', $post_id);
502 502
 		}
503 503
 
504 504
 
505 505
 
506
-		SimpleBlogCommon::AStrSet('titles',$post_id,$title);
507
-		self::UpdatePostCategories($post_id);	//find and update the edited post in categories and archives
506
+		SimpleBlogCommon::AStrSet('titles', $post_id, $title);
507
+		self::UpdatePostCategories($post_id); //find and update the edited post in categories and archives
508 508
 
509
-		if( !SimpleBlogCommon::SaveIndex() ){
509
+		if (!SimpleBlogCommon::SaveIndex()) {
510 510
 			message($langmessage['OOPS'].' (Index not saved)');
511 511
 			return false;
512 512
 		}
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 	 * Get posted time
525 525
 	 *
526 526
 	 */
527
-	public static function GetPostedTime(){
528
-		$_POST['pub_year']		= ($_POST['pub_year'] <= 0 )	? date('Y') : $_POST['pub_year'];
529
-		$_POST['pub_month']		= ($_POST['pub_month'] <= 0 )	? date('n') : $_POST['pub_month'];
530
-		$_POST['pub_day']		= ($_POST['pub_day'] > 31 )		? 31 : $_POST['pub_day'];
531
-		$_POST['pub_day']		= ($_POST['pub_day'] <= 0 )		? date('j') : $_POST['pub_day'];
532
-		$_POST['pub_hour']		= ($_POST['pub_hour'] > 23 )	? $_POST['pub_hour'] -24 : $_POST['pub_hour'];
533
-		$_POST['pub_min']		= ($_POST['pub_min'] > 59 ) ? $_POST['pub_min'] -60 : $_POST['pub_min'];
534
-		$_POST['time']			= gmmktime( $_POST['pub_hour'], $_POST['pub_min'], 0, $_POST['pub_month'], $_POST['pub_day'], $_POST['pub_year'] );
527
+	public static function GetPostedTime() {
528
+		$_POST['pub_year'] = ($_POST['pub_year'] <= 0) ? date('Y') : $_POST['pub_year'];
529
+		$_POST['pub_month'] = ($_POST['pub_month'] <= 0) ? date('n') : $_POST['pub_month'];
530
+		$_POST['pub_day']		= ($_POST['pub_day'] > 31) ? 31 : $_POST['pub_day'];
531
+		$_POST['pub_day']		= ($_POST['pub_day'] <= 0) ? date('j') : $_POST['pub_day'];
532
+		$_POST['pub_hour'] = ($_POST['pub_hour'] > 23) ? $_POST['pub_hour']-24 : $_POST['pub_hour'];
533
+		$_POST['pub_min']		= ($_POST['pub_min'] > 59) ? $_POST['pub_min']-60 : $_POST['pub_min'];
534
+		$_POST['time'] = gmmktime($_POST['pub_hour'], $_POST['pub_min'], 0, $_POST['pub_month'], $_POST['pub_day'], $_POST['pub_year']);
535 535
 	}
536 536
 
537 537
 
@@ -539,25 +539,25 @@  discard block
 block discarded – undo
539 539
 	 * Show a list of all categories
540 540
 	 *
541 541
 	 */
542
-	public static function ShowCategoryList( $post_id, $post ){
542
+	public static function ShowCategoryList($post_id, $post) {
543 543
 
544 544
 		$_POST += array('category'=>array());
545 545
 
546 546
 		echo '<label>Category</label>';
547 547
 		echo '<select name="category[]" multiple="multiple"  class="gpinput">';
548 548
 
549
-		$categories = SimpleBlogCommon::AStrToArray( 'categories' );
550
-		foreach( $categories as $catindex => $catname ){
549
+		$categories = SimpleBlogCommon::AStrToArray('categories');
550
+		foreach ($categories as $catindex => $catname) {
551 551
 
552 552
 			$selected = '';
553 553
 			$label = $catname;
554
-			if( $post_id && in_array($catindex, $post['categories']) ){
554
+			if ($post_id && in_array($catindex, $post['categories'])) {
555 555
 				$selected = 'selected="selected"';
556
-			}elseif( in_array($catindex, $_POST['category']) ){
556
+			}elseif (in_array($catindex, $_POST['category'])) {
557 557
 				$selected = 'selected="selected"';
558 558
 			}
559 559
 
560
-			if( SimpleBlogCommon::AStrGet('categories_hidden', $catindex) ){
560
+			if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
561 561
 				$label .= ' (Hidden)';
562 562
 			}
563 563
 
@@ -573,26 +573,26 @@  discard block
 block discarded – undo
573 573
 	 * Update a category when a blog entry is edited
574 574
 	 *
575 575
 	 */
576
-	private static function UpdatePostCategories( $post_id ){
576
+	private static function UpdatePostCategories($post_id) {
577 577
 
578 578
 		$_POST += array('category'=>array());
579 579
 
580 580
 		//get order of all posts
581
-		$post_times = SimpleBlogCommon::AStrToArray( 'post_times' );
581
+		$post_times = SimpleBlogCommon::AStrToArray('post_times');
582 582
 		arsort($post_times);
583 583
 		$post_times = array_keys($post_times);
584 584
 
585 585
 
586 586
 		//loop through each category
587
-		$categories = SimpleBlogCommon::AStrToArray( 'categories' );
587
+		$categories = SimpleBlogCommon::AStrToArray('categories');
588 588
 
589
-		foreach( $categories as $catindex => $catname ){
589
+		foreach ($categories as $catindex => $catname) {
590 590
 
591
-			SimpleBlogCommon::AStrRmValue('category_posts_'.$catindex, $post_id );
592
-			if( in_array($catindex, $_POST['category']) ){
591
+			SimpleBlogCommon::AStrRmValue('category_posts_'.$catindex, $post_id);
592
+			if (in_array($catindex, $_POST['category'])) {
593 593
 
594 594
 				//add and order correctly
595
-				$category_posts = SimpleBlogCommon::AStrToArray( 'category_posts_'.$catindex );
595
+				$category_posts = SimpleBlogCommon::AStrToArray('category_posts_'.$catindex);
596 596
 				$category_posts[] = $post_id;
597 597
 				$category_posts = array_intersect($post_times, $category_posts);
598 598
 				SimpleBlogCommon::$data['category_posts_'.$catindex] = SimpleBlogCommon::AStrFromArray($category_posts);
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			echo '<tr><td width="1%">';
114 114
 			if( isset($post_drafts[$post_id]) ){
115 115
 				echo 'Draft';
116
-			}elseif( $post_times[$post_id] > time() ){
116
+			} elseif( $post_times[$post_id] > time() ){
117 117
 				echo 'Pending';
118 118
 			}
119 119
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			echo '<span style="display:inline-block;min-width:30px">';
134 134
 			if( isset($post_comments[$post_id]) ){
135 135
 				echo number_format($post_comments[$post_id]);
136
-			}else{
136
+			} else{
137 137
 				echo '0';
138 138
 			}
139 139
 			echo '</span>';
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 					echo common::Link('Admin_Blog',$open,'cmd=opencomments&id='.$post_id,'name="cnreq"');
149 149
 					echo ' &nbsp; ';
150 150
 					echo gpOutput::SelectText('Closed');
151
-				}else{
151
+				} else{
152 152
 					echo $open;
153 153
 					echo ' &nbsp; ';
154 154
 					echo common::Link('Admin_Blog',$close,'cmd=closecomments&id='.$post_id,'name="cnreq"');
155 155
 				}
156
-			}else{
156
+			} else{
157 157
 				echo common::Link('Admin_BlogConfig','Disabled');
158 158
 			}
159 159
 
@@ -309,7 +309,9 @@  discard block
 block discarded – undo
309 309
 		echo '<div class="sb_edit_group">';
310 310
 		echo '<label>';
311 311
 		echo '<input type="checkbox" name="isDraft" value="on" data-cmd="DraftCheckbox" ';
312
-		if( $array['isDraft'] ) echo 'checked="true"';
312
+		if( $array['isDraft'] ) {
313
+			echo 'checked="true"';
314
+		}
313 315
 		echo '" /> Draft</label>';
314 316
 		echo '</div>';
315 317
 
@@ -497,7 +499,7 @@  discard block
 block discarded – undo
497 499
 		//draft
498 500
 		if( $_POST['isDraft'] === 'on' ){
499 501
 			SimpleBlogCommon::AStrSet('drafts',$post_id,1);
500
-		}else{
502
+		} else{
501 503
 			SimpleBlogCommon::AStrRm('drafts',$post_id);
502 504
 		}
503 505
 
@@ -553,7 +555,7 @@  discard block
 block discarded – undo
553 555
 			$label = $catname;
554 556
 			if( $post_id && in_array($catindex, $post['categories']) ){
555 557
 				$selected = 'selected="selected"';
556
-			}elseif( in_array($catindex, $_POST['category']) ){
558
+			} elseif( in_array($catindex, $_POST['category']) ){
557 559
 				$selected = 'selected="selected"';
558 560
 			}
559 561
 
Please login to merge, or discard this patch.
Admin/SimpleBlogPage.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -47,6 +47,7 @@
 block discarded – undo
47 47
 	/**
48 48
 	 * Open/Close the comments for a blog post
49 49
 	 *
50
+	 * @param boolean $closed
50 51
 	 */
51 52
 	function ToggleComments($closed, $post_id ){
52 53
 		global $langmessage;
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@  discard block
 block discarded – undo
4 4
 
5 5
 gpPlugin_incl('SimpleBlogPage.php');
6 6
 
7
-class AdminSimpleBlogPage extends SimpleBlogPage{
7
+class AdminSimpleBlogPage extends SimpleBlogPage {
8 8
 
9
-	function ShowPost(){
9
+	function ShowPost() {
10 10
 
11 11
 
12 12
 		$cmd = common::GetCommand();
13 13
 
14
-		switch($cmd){
14
+		switch ($cmd) {
15 15
 
16 16
 			// inline editing
17 17
 			case 'inlineedit':
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 	 * Open/Close the comments for a blog post
49 49
 	 *
50 50
 	 */
51
-	function ToggleComments($closed, $post_id ){
51
+	function ToggleComments($closed, $post_id) {
52 52
 		global $langmessage;
53 53
 
54
-		if( $closed ){
55
-			SimpleBlogCommon::AStrSet('comments_closed',$post_id,1);
56
-		}else{
57
-			SimpleBlogCommon::AStrRm('comments_closed',$post_id);
54
+		if ($closed) {
55
+			SimpleBlogCommon::AStrSet('comments_closed', $post_id, 1);
56
+		}else {
57
+			SimpleBlogCommon::AStrRm('comments_closed', $post_id);
58 58
 		}
59 59
 
60 60
 
61
-		if( SimpleBlogCommon::SaveIndex() ){
61
+		if (SimpleBlogCommon::SaveIndex()) {
62 62
 			$this->comments_closed = $closed;
63 63
 			message($langmessage['SAVED']);
64
-		}else{
64
+		}else {
65 65
 			message($langmessage['OOPS']);
66 66
 		}
67 67
 	}
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 	 * Remove a comment entry from the comment data
72 72
 	 *
73 73
 	 */
74
-	function DeleteComment(){
74
+	function DeleteComment() {
75 75
 		global $langmessage;
76 76
 
77
-		$data		= SimpleBlogCommon::GetCommentData($this->post_id);
78
-		$comment	= $_POST['comment_index'];
77
+		$data = SimpleBlogCommon::GetCommentData($this->post_id);
78
+		$comment = $_POST['comment_index'];
79 79
 
80
-		if( !isset($data[$comment]) ){
80
+		if (!isset($data[$comment])) {
81 81
 			message($langmessage['OOPS']);
82 82
 			return;
83 83
 		}
84 84
 
85 85
 		unset($data[$comment]);
86 86
 
87
-		if( SimpleBlogCommon::SaveCommentData($this->post_id,$data) ){
87
+		if (SimpleBlogCommon::SaveCommentData($this->post_id, $data)) {
88 88
 			message($langmessage['SAVED']);
89 89
 			return true;
90
-		}else{
90
+		}else {
91 91
 			message($langmessage['OOPS']);
92 92
 			return false;
93 93
 		}
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 * Edit a post with inline editing
100 100
 	 *
101 101
 	 */
102
-	function InlineEdit(){
102
+	function InlineEdit() {
103 103
 
104 104
 
105
-		if( !$this->post ){
105
+		if (!$this->post) {
106 106
 			echo 'false';
107 107
 			return false;
108 108
 		}
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * Save an inline edit
120 120
 	 *
121 121
 	 */
122
-	function SaveInline(){
122
+	function SaveInline() {
123 123
 		global $page, $langmessage;
124 124
 		$page->ajaxReplace = array();
125 125
 
126
-		if( $this->post === false || empty($_POST['gpcontent']) ){
126
+		if ($this->post === false || empty($_POST['gpcontent'])) {
127 127
 			message($langmessage['OOPS'].' (No Post)');
128 128
 			return;
129 129
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		$this->post['content'] = $_POST['gpcontent'];
133 133
 
134 134
 		//save to data file
135
-		if( !self::SavePost($this->post_id, $this->post) ){
135
+		if (!self::SavePost($this->post_id, $this->post)) {
136 136
 			return false;
137 137
 		}
138 138
 
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 	 * Save a post
147 147
 	 *
148 148
 	 */
149
-	static function SavePost($post_index, $post){
149
+	static function SavePost($post_index, $post) {
150 150
 		global $gpAdmin;
151 151
 
152 152
 		gpFiles::cleanText($post['content']);
153
-		$post['username']		= $gpAdmin['username'];
154
-		$post_file				= SimpleBlogCommon::PostFilePath($post_index);
153
+		$post['username'] = $gpAdmin['username'];
154
+		$post_file = SimpleBlogCommon::PostFilePath($post_index);
155 155
 
156
-		if( !gpFiles::SaveArray($post_file,'post',$post) ){
156
+		if (!gpFiles::SaveArray($post_file, 'post', $post)) {
157 157
 			message($langmessage['OOPS'].' (Post not saved)');
158 158
 			return false;
159 159
 		}
160 160
 
161 161
 		//remove from old data file
162
-		$posts					= SimpleBlogCommon::GetPostFile($post_index,$post_file);
163
-		if( isset($posts[$post_index]) ){
162
+		$posts = SimpleBlogCommon::GetPostFile($post_index, $post_file);
163
+		if (isset($posts[$post_index])) {
164 164
 			unset($posts[$post_index]);
165
-			gpFiles::SaveArray($post_file,'posts',$posts);
165
+			gpFiles::SaveArray($post_file, 'posts', $posts);
166 166
 		}
167 167
 
168 168
 		return true;
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 		if( $closed ){
55 55
 			SimpleBlogCommon::AStrSet('comments_closed',$post_id,1);
56
-		}else{
56
+		} else{
57 57
 			SimpleBlogCommon::AStrRm('comments_closed',$post_id);
58 58
 		}
59 59
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		if( SimpleBlogCommon::SaveIndex() ){
62 62
 			$this->comments_closed = $closed;
63 63
 			message($langmessage['SAVED']);
64
-		}else{
64
+		} else{
65 65
 			message($langmessage['OOPS']);
66 66
 		}
67 67
 	}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		if( SimpleBlogCommon::SaveCommentData($this->post_id,$data) ){
88 88
 			message($langmessage['SAVED']);
89 89
 			return true;
90
-		}else{
90
+		} else{
91 91
 			message($langmessage['OOPS']);
92 92
 			return false;
93 93
 		}
Please login to merge, or discard this patch.
Admin/StaticGenerator.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -285,6 +285,8 @@
 block discarded – undo
285 285
 	/**
286 286
 	 * Change relative links to absolute links
287 287
 	 *
288
+	 * @param string $server
289
+	 * @param integer $offset
288 290
 	 */
289 291
 	public static function FixLinks(&$content,$server,$offset){
290 292
 
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 defined('is_running') or die('Not an entry point...');
3 3
 
4
-class StaticGenerator{
4
+class StaticGenerator {
5 5
 
6
-	static $months		= array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
6
+	static $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
7 7
 
8 8
 	/**
9 9
 	 * Regenerate all of the static content: gadget and feed
10 10
 	 *
11 11
 	 */
12
-	static function Generate(){
12
+	static function Generate() {
13 13
 		self::GenFeed();
14 14
 		self::GenGadget();
15 15
 		self::GenCategoryGadget();
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
 	 * Regenerate the atom.feed file
22 22
 	 *
23 23
 	 */
24
-	static function GenFeed(){
24
+	static function GenFeed() {
25 25
 		global $config, $addonFolderName, $dirPrefix;
26 26
 		ob_start();
27 27
 
28 28
 		$atomFormat = 'Y-m-d\TH:i:s\Z';
29
-		$show_posts = SimpleBlogCommon::WhichPosts(0,SimpleBlogCommon::$data['feed_entries']);
29
+		$show_posts = SimpleBlogCommon::WhichPosts(0, SimpleBlogCommon::$data['feed_entries']);
30 30
 
31 31
 
32
-		if( isset($_SERVER['HTTP_HOST']) ){
32
+		if (isset($_SERVER['HTTP_HOST'])) {
33 33
 			$server = 'http://'.$_SERVER['HTTP_HOST'];
34
-		}else{
34
+		}else {
35 35
 			$server = 'http://'.$_SERVER['SERVER_NAME'];
36 36
 		}
37 37
 		$serverWithDir = $server.$dirPrefix;
@@ -40,47 +40,47 @@  discard block
 block discarded – undo
40 40
 		echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
41 41
 		echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
42 42
 		echo '<title>'.$config['title'].'</title>'."\n";
43
-		echo '<link href="'.$serverWithDir.'/data/_addondata/'.str_replace(' ', '%20',$addonFolderName).'/feed.atom" rel="self" />'."\n";
43
+		echo '<link href="'.$serverWithDir.'/data/_addondata/'.str_replace(' ', '%20', $addonFolderName).'/feed.atom" rel="self" />'."\n";
44 44
 		echo '<link href="'.$server.common::GetUrl('Special_Blog').'" />'."\n";
45 45
 		echo '<id>urn:uuid:'.self::uuid($serverWithDir).'</id>'."\n";
46 46
 		echo '<updated>'.date($atomFormat, time()).'</updated>'."\n";
47 47
 		echo '<author><name>'.$config['title'].'</name></author>'."\n";
48 48
 
49 49
 
50
-		foreach($show_posts as $post_index){
50
+		foreach ($show_posts as $post_index) {
51 51
 
52 52
 			$post = SimpleBlogCommon::GetPostContent($post_index);
53 53
 
54
-			if( !$post ){
54
+			if (!$post) {
55 55
 				continue;
56 56
 			}
57 57
 
58 58
 			echo '<entry>'."\n";
59
-			echo '<title>'.SimpleBlogCommon::Underscores( $post['title'] ).'</title>'."\n";
59
+			echo '<title>'.SimpleBlogCommon::Underscores($post['title']).'</title>'."\n";
60 60
 			echo '<link href="'.$server.SimpleBlogCommon::PostUrl($post_index).'"></link>'."\n";
61 61
 			echo '<id>urn:uuid:'.self::uuid($post_index).'</id>'."\n";
62 62
 			echo '<updated>'.date($atomFormat, $post['time']).'</updated>'."\n";
63 63
 
64
-			$content =& $post['content'];
65
-			if( (SimpleBlogCommon::$data['feed_abbrev']> 0) && (mb_strlen($content) > SimpleBlogCommon::$data['feed_abbrev']) ){
66
-				$content = mb_substr($content,0,SimpleBlogCommon::$data['feed_abbrev']).' ... ';
64
+			$content = & $post['content'];
65
+			if ((SimpleBlogCommon::$data['feed_abbrev'] > 0) && (mb_strlen($content) > SimpleBlogCommon::$data['feed_abbrev'])) {
66
+				$content = mb_substr($content, 0, SimpleBlogCommon::$data['feed_abbrev']).' ... ';
67 67
 				$label = gpOutput::SelectText('Read More');
68
-				$content .= '<a href="'.$server.SimpleBlogCommon::PostUrl($post_index,$label).'">'.$label.'</a>';
68
+				$content .= '<a href="'.$server.SimpleBlogCommon::PostUrl($post_index, $label).'">'.$label.'</a>';
69 69
 			}
70 70
 
71 71
 			//old images
72 72
 			$replacement = $server.'/';
73
-			$content = str_replace('src="/', 'src="'.$replacement,$content);
73
+			$content = str_replace('src="/', 'src="'.$replacement, $content);
74 74
 
75 75
 			//new images
76
-			$content = str_replace('src="../', 'src="'.$serverWithDir,$content);
76
+			$content = str_replace('src="../', 'src="'.$serverWithDir, $content);
77 77
 
78 78
 			//images without /index.php/
79
-			$content = str_replace('src="./', 'src="'.$serverWithDir,$content);
79
+			$content = str_replace('src="./', 'src="'.$serverWithDir, $content);
80 80
 
81 81
 
82 82
 			//href
83
-			self::FixLinks($content,$server,0);
83
+			self::FixLinks($content, $server, 0);
84 84
 
85 85
 			echo '<summary type="html"><![CDATA['.$content.']]></summary>'."\n";
86 86
 			echo '</entry>'."\n";
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 		$feed = ob_get_clean();
92 92
 		$feedFile = SimpleBlogCommon::$data_dir.'/feed.atom';
93
-		gpFiles::Save($feedFile,$feed);
93
+		gpFiles::Save($feedFile, $feed);
94 94
 	}
95 95
 
96 96
 
@@ -100,51 +100,51 @@  discard block
 block discarded – undo
100 100
 	 * Regenerate the static content used to display the gadget
101 101
 	 *
102 102
 	 */
103
-	static function GenGadget(){
103
+	static function GenGadget() {
104 104
 		global $langmessage;
105 105
 
106 106
 		$posts = array();
107
-		$show_posts = SimpleBlogCommon::WhichPosts(0,SimpleBlogCommon::$data['gadget_entries']);
107
+		$show_posts = SimpleBlogCommon::WhichPosts(0, SimpleBlogCommon::$data['gadget_entries']);
108 108
 
109 109
 
110 110
 		ob_start();
111 111
 		$label = gpOutput::SelectText('Blog');
112
-		if( !empty($label) ){
112
+		if (!empty($label)) {
113 113
 			echo '<h3>';
114
-			echo common::Link('Special_Blog',$label);
114
+			echo common::Link('Special_Blog', $label);
115 115
 			echo '</h3>';
116 116
 		}
117 117
 
118
-		foreach($show_posts as $post_index){
118
+		foreach ($show_posts as $post_index) {
119 119
 
120
-			$post		= SimpleBlogCommon::GetPostContent($post_index);
120
+			$post = SimpleBlogCommon::GetPostContent($post_index);
121 121
 
122
-			if( !$post ){
122
+			if (!$post) {
123 123
 				continue;
124 124
 			}
125 125
 
126
-			$header		= '<b class="simple_blog_title">';
127
-			$label		= SimpleBlogCommon::Underscores( $post['title'] );
128
-			$header		.= SimpleBlogCommon::PostLink($post_index,$label);
126
+			$header = '<b class="simple_blog_title">';
127
+			$label = SimpleBlogCommon::Underscores($post['title']);
128
+			$header		.= SimpleBlogCommon::PostLink($post_index, $label);
129 129
 			$header		.= '</b>';
130 130
 
131
-			SimpleBlogCommon::BlogHead($header,$post_index,$post,true);
131
+			SimpleBlogCommon::BlogHead($header, $post_index, $post, true);
132 132
 
133 133
 
134 134
 			$content = strip_tags($post['content']);
135 135
 
136
-			if( SimpleBlogCommon::$data['gadget_abbrev'] > 6 && (mb_strlen($content) > SimpleBlogCommon::$data['gadget_abbrev']) ){
136
+			if (SimpleBlogCommon::$data['gadget_abbrev'] > 6 && (mb_strlen($content) > SimpleBlogCommon::$data['gadget_abbrev'])) {
137 137
 
138 138
 				$cut = SimpleBlogCommon::$data['gadget_abbrev'];
139 139
 
140
-				$pos = mb_strpos($content,' ',$cut-5);
141
-				if( ($pos > 0) && ($cut+20 > $pos) ){
140
+				$pos = mb_strpos($content, ' ', $cut-5);
141
+				if (($pos > 0) && ($cut+20 > $pos)) {
142 142
 					$cut = $pos;
143 143
 				}
144
-				$content = mb_substr($content,0,$cut).' ... ';
144
+				$content = mb_substr($content, 0, $cut).' ... ';
145 145
 
146 146
 				$label = gpOutput::SelectText('Read More');
147
-				$content .= SimpleBlogCommon::PostLink($post_index,$label);
147
+				$content .= SimpleBlogCommon::PostLink($post_index, $label);
148 148
 			}
149 149
 
150 150
 			echo '<p class="simple_blog_abbrev">';
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 
154 154
 		}
155 155
 
156
-		if( SimpleBlogCommon::$data['post_count'] > 3 ){
156
+		if (SimpleBlogCommon::$data['post_count'] > 3) {
157 157
 
158 158
 			$label = gpOutput::SelectText('More Blog Entries');
159
-			echo common::Link('Special_Blog',$label);
159
+			echo common::Link('Special_Blog', $label);
160 160
 		}
161 161
 
162 162
 		$gadget = ob_get_clean();
163 163
 		$gadgetFile = SimpleBlogCommon::$data_dir.'/gadget.php';
164
-		gpFiles::Save($gadgetFile,$gadget);
164
+		gpFiles::Save($gadgetFile, $gadget);
165 165
 	}
166 166
 
167 167
 
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
 	 * Regenerate the static content used to display the category gadget
170 170
 	 *
171 171
 	 */
172
-	static function GenCategoryGadget(){
172
+	static function GenCategoryGadget() {
173 173
 		global $addonPathData;
174 174
 
175
-		$categories = SimpleBlogCommon::AStrToArray( 'categories' );
175
+		$categories = SimpleBlogCommon::AStrToArray('categories');
176 176
 
177 177
 		ob_start();
178 178
 		echo '<ul>';
179
-		foreach($categories as $catindex => $catname){
179
+		foreach ($categories as $catindex => $catname) {
180 180
 
181 181
 			//skip hidden categories
182
-			if( SimpleBlogCommon::AStrGet('categories_hidden',$catindex) ){
182
+			if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
183 183
 				continue;
184 184
 			}
185 185
 
186 186
 			$posts = SimpleBlogCommon::AStrToArray('category_posts_'.$catindex);
187 187
 			$sum = count($posts);
188
-			if( !$sum ){
188
+			if (!$sum) {
189 189
 				continue;
190 190
 			}
191 191
 
192 192
 			echo '<li>';
193 193
 			echo '<a class="blog_gadget_link">'.$catname.' ('.$sum.')</a>';
194 194
 			echo '<ul class="nodisplay">';
195
-			foreach($posts as $post_id){
196
-				$post_title = SimpleBlogCommon::AStrGet('titles',$post_id);
195
+			foreach ($posts as $post_id) {
196
+				$post_title = SimpleBlogCommon::AStrGet('titles', $post_id);
197 197
 				echo '<li>';
198
-				echo SimpleBlogCommon::PostLink( $post_id, $post_title );
198
+				echo SimpleBlogCommon::PostLink($post_id, $post_title);
199 199
 				echo '</li>';
200 200
 			}
201 201
 			echo '</ul></li>';
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 
208 208
 		$gadgetFile = $addonPathData.'/gadget_categories.php';
209
-		gpFiles::Save( $gadgetFile, $content );
209
+		gpFiles::Save($gadgetFile, $content);
210 210
 	}
211 211
 
212 212
 
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	 * Regenerate the static content used to display the archive gadget
215 215
 	 *
216 216
 	 */
217
-	static function GenArchiveGadget(){
217
+	static function GenArchiveGadget() {
218 218
 		global $addonPathData;
219 219
 
220 220
 		//get list of posts and times
221
-		$list = SimpleBlogCommon::AStrToArray( 'post_times' );
222
-		if( !count($list) ) return;
221
+		$list = SimpleBlogCommon::AStrToArray('post_times');
222
+		if (!count($list)) return;
223 223
 
224 224
 		//get year counts
225 225
 		$archive = array();
226
-		foreach($list as $post_id => $time){
227
-			$ym = date('Ym',$time); //year&month
226
+		foreach ($list as $post_id => $time) {
227
+			$ym = date('Ym', $time); //year&month
228 228
 			$archive[$ym][] = $post_id;
229 229
 		}
230 230
 
@@ -233,28 +233,28 @@  discard block
 block discarded – undo
233 233
 
234 234
 		$prev_year = false;
235 235
 		echo '<ul>';
236
-		foreach( $archive as $ym => $posts ){
237
-			$y = floor($ym/100);
238
-			$m = $ym%100;
239
-			if( $y != $prev_year ){
240
-				if( $prev_year !== false ){
236
+		foreach ($archive as $ym => $posts) {
237
+			$y = floor($ym / 100);
238
+			$m = $ym % 100;
239
+			if ($y != $prev_year) {
240
+				if ($prev_year !== false) {
241 241
 					echo '</li>';
242 242
 				}
243 243
 				echo '<li><div class="simple_blog_gadget_year">'.$y.'</div>';
244 244
 				$prev_year = $y;
245 245
 			}
246 246
 			$sum = count($posts);
247
-			if( !$sum ){
247
+			if (!$sum) {
248 248
 				continue;
249 249
 			}
250 250
 
251 251
 			echo '<ul>';
252 252
 			echo '<li><a class="blog_gadget_link">'.self::$months[$m-1].' ('.$sum.')</a>';
253 253
 			echo '<ul class="simple_blog_category_posts nodisplay">';
254
-			foreach($posts as $post_id ){
255
-				$post_title = SimpleBlogCommon::AStrGet('titles',$post_id);
254
+			foreach ($posts as $post_id) {
255
+				$post_title = SimpleBlogCommon::AStrGet('titles', $post_id);
256 256
 				echo '<li>';
257
-				echo SimpleBlogCommon::PostLink($post_id, $post_title );
257
+				echo SimpleBlogCommon::PostLink($post_id, $post_title);
258 258
 				echo '</li>';
259 259
 			}
260 260
 			echo '</ul>';
@@ -267,16 +267,16 @@  discard block
 block discarded – undo
267 267
 		$content = ob_get_clean();
268 268
 
269 269
 		$gadgetFile = $addonPathData.'/gadget_archive.php';
270
-		gpFiles::Save( $gadgetFile, $content );
270
+		gpFiles::Save($gadgetFile, $content);
271 271
 	}
272 272
 
273
-	static function uuid($str){
273
+	static function uuid($str) {
274 274
 		$chars = md5($str);
275
-		return mb_substr($chars,0,8)
276
-				.'-'. mb_substr($chars,8,4)
277
-				.'-'. mb_substr($chars,12,4)
278
-				.'-'. mb_substr($chars,16,4)
279
-				.'-'. mb_substr($chars,20,12);
275
+		return mb_substr($chars, 0, 8)
276
+				.'-'.mb_substr($chars, 8, 4)
277
+				.'-'.mb_substr($chars, 12, 4)
278
+				.'-'.mb_substr($chars, 16, 4)
279
+				.'-'.mb_substr($chars, 20, 12);
280 280
 		return $uuid;
281 281
 	}
282 282
 
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 	 * Change relative links to absolute links
287 287
 	 *
288 288
 	 */
289
-	public static function FixLinks(&$content,$server,$offset){
289
+	public static function FixLinks(&$content, $server, $offset) {
290 290
 
291
-		preg_match_all('#href="([^<>"]+)"#i',$content,$matches,PREG_SET_ORDER);
292
-		foreach($matches as $match){
293
-			self::FixLink($content,$server,$match);
291
+		preg_match_all('#href="([^<>"]+)"#i', $content, $matches, PREG_SET_ORDER);
292
+		foreach ($matches as $match) {
293
+			self::FixLink($content, $server, $match);
294 294
 		}
295 295
 
296 296
 	}
@@ -300,24 +300,24 @@  discard block
 block discarded – undo
300 300
 	 * Change relative link to absolute link
301 301
 	 *
302 302
 	 */
303
-	public static function FixLink(&$content,$server,$match){
303
+	public static function FixLink(&$content, $server, $match) {
304 304
 
305
-		if( strpos($match[1],'mailto:') !== false ){
305
+		if (strpos($match[1], 'mailto:') !== false) {
306 306
 			return;
307 307
 		}
308
-		if( strpos($match[1],'://') !== false ){
308
+		if (strpos($match[1], '://') !== false) {
309 309
 			return;
310 310
 		}
311 311
 
312
-		if( mb_strpos($match[1],'/') === 0 ){
312
+		if (mb_strpos($match[1], '/') === 0) {
313 313
 			$replacement = $server.$match[1];
314
-		}else{
314
+		}else {
315 315
 			$replacement = $server.common::GetUrl($match[1]);
316 316
 		}
317 317
 
318
-		$replacement = str_replace($match[1],$replacement,$match[0]);
318
+		$replacement = str_replace($match[1], $replacement, $match[0]);
319 319
 
320
-		$content = str_replace($match[0],$replacement,$content);
320
+		$content = str_replace($match[0], $replacement, $content);
321 321
 	}
322 322
 
323 323
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 		if( isset($_SERVER['HTTP_HOST']) ){
33 33
 			$server = 'http://'.$_SERVER['HTTP_HOST'];
34
-		}else{
34
+		} else{
35 35
 			$server = 'http://'.$_SERVER['SERVER_NAME'];
36 36
 		}
37 37
 		$serverWithDir = $server.$dirPrefix;
@@ -219,7 +219,9 @@  discard block
 block discarded – undo
219 219
 
220 220
 		//get list of posts and times
221 221
 		$list = SimpleBlogCommon::AStrToArray( 'post_times' );
222
-		if( !count($list) ) return;
222
+		if( !count($list) ) {
223
+			return;
224
+		}
223 225
 
224 226
 		//get year counts
225 227
 		$archive = array();
@@ -311,7 +313,7 @@  discard block
 block discarded – undo
311 313
 
312 314
 		if( mb_strpos($match[1],'/') === 0 ){
313 315
 			$replacement = $server.$match[1];
314
-		}else{
316
+		} else{
315 317
 			$replacement = $server.common::GetUrl($match[1]);
316 318
 		}
317 319
 
Please login to merge, or discard this patch.
SimpleBlog.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -336,6 +336,8 @@
 block discarded – undo
336 336
 	/**
337 337
 	 * Get the edit links for the post
338 338
 	 *
339
+	 * @param string $class
340
+	 * @param string $id
339 341
 	 */
340 342
 	public static function EditLinks($post_index, &$class, &$id){
341 343
 		global $langmessage;
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -8,33 +8,33 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-class SimpleBlog extends SimpleBlogCommon{
11
+class SimpleBlog extends SimpleBlogCommon {
12 12
 
13 13
 	public $showing_category = false;
14 14
 
15
-	public function __construct(){
15
+	public function __construct() {
16 16
 		global $page, $langmessage, $addonFolderName;
17 17
 
18 18
 		SimpleBlogCommon::Init();
19 19
 
20 20
 		//get the post id
21
-		if( $page->pagetype == 'special_display' ){
22
-			$this->post_id	= $this->PostID($page->requested);
21
+		if ($page->pagetype == 'special_display') {
22
+			$this->post_id = $this->PostID($page->requested);
23 23
 		}
24 24
 
25 25
 
26
-		if( common::LoggedIn() ){
26
+		if (common::LoggedIn()) {
27 27
 
28
-			$page->admin_links[]		= array('Special_Blog','Blog Home');
29
-			$page->admin_links[]		= array('Admin_Blog','New Blog Post','cmd=new_form');
30
-			$page->admin_links[]		= array('Admin_Blog','Configuration');
31
-			$page->admin_links[]		= array('Admin_Theme_Content',$langmessage['editable_text'],'cmd=addontext&addon='.urlencode($addonFolderName),' name="gpabox" ');
32
-			$label						= 'Number of Posts: '. SimpleBlogCommon::$data['post_count'];
33
-			$page->admin_links[$label]	= '';
34
-			$cmd						= common::GetCommand();
28
+			$page->admin_links[]		= array('Special_Blog', 'Blog Home');
29
+			$page->admin_links[]		= array('Admin_Blog', 'New Blog Post', 'cmd=new_form');
30
+			$page->admin_links[]		= array('Admin_Blog', 'Configuration');
31
+			$page->admin_links[]		= array('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon='.urlencode($addonFolderName), ' name="gpabox" ');
32
+			$label = 'Number of Posts: '.SimpleBlogCommon::$data['post_count'];
33
+			$page->admin_links[$label] = '';
34
+			$cmd = common::GetCommand();
35 35
 
36 36
 
37
-			switch($cmd){
37
+			switch ($cmd) {
38 38
 
39 39
 
40 40
 				//delete
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 
49 49
 
50
-		if( $this->post_id ){
50
+		if ($this->post_id) {
51 51
 			$this->ShowPost();
52 52
 			return;
53 53
 		}
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 
56 56
 		$this->ShowPage();
57 57
 
58
-		if( common::LoggedIn() && !file_exists(self::$index_file) ){
58
+		if (common::LoggedIn() && !file_exists(self::$index_file)) {
59 59
 			echo '<p>Congratulations on successfully installing Simple Blog for gpEasy.</p> ';
60
-			echo '<p>You\'ll probably want to get started by '.common::Link('Special_Blog','creating a blog post','cmd=new_form').'.</p>';
60
+			echo '<p>You\'ll probably want to get started by '.common::Link('Special_Blog', 'creating a blog post', 'cmd=new_form').'.</p>';
61 61
 		}
62 62
 
63 63
 	}
@@ -67,28 +67,28 @@  discard block
 block discarded – undo
67 67
 	 * Get the post id from the requested url
68 68
 	 *
69 69
 	 */
70
-	public function PostID($requested){
70
+	public function PostID($requested) {
71 71
 
72 72
 
73
-		if( isset($_REQUEST['id']) && ctype_digit($_REQUEST['id']) ){
73
+		if (isset($_REQUEST['id']) && ctype_digit($_REQUEST['id'])) {
74 74
 			return $_REQUEST['id'];
75 75
 		}
76 76
 
77
-		if( strpos($requested,'/') === false ){
77
+		if (strpos($requested, '/') === false) {
78 78
 			return;
79 79
 		}
80 80
 
81
-		$parts	= explode('/',$requested);
81
+		$parts	= explode('/', $requested);
82 82
 
83
-		if( SimpleBlogCommon::$data['urls'] != 'Title' ){
84
-			$ints	= strspn($parts[1],'0123456789');
85
-			if( $ints ){
86
-				return substr($parts[1],0,$ints);
83
+		if (SimpleBlogCommon::$data['urls'] != 'Title') {
84
+			$ints	= strspn($parts[1], '0123456789');
85
+			if ($ints) {
86
+				return substr($parts[1], 0, $ints);
87 87
 			}
88 88
 		}
89 89
 
90
-		$id = SimpleBlogCommon::AStrKey('titles',$parts[1], true);
91
-		if( $id !== false ){
90
+		$id = SimpleBlogCommon::AStrKey('titles', $parts[1], true);
91
+		if ($id !== false) {
92 92
 			return $id;
93 93
 		}
94 94
 
@@ -100,28 +100,28 @@  discard block
 block discarded – undo
100 100
 	 * Get a id for the post that is most similar to the requested title
101 101
 	 *
102 102
 	 */
103
-	public function SimilarPost($title){
103
+	public function SimilarPost($title) {
104 104
 		global $config;
105 105
 
106 106
 		$titles				= SimpleBlogCommon::AStrToArray('titles');
107
-		$post_times			= SimpleBlogCommon::AStrToArray('post_times');
107
+		$post_times = SimpleBlogCommon::AStrToArray('post_times');
108 108
 		$similar			= array();
109
-		$lower				= str_replace(' ','_',strtolower($title));
109
+		$lower = str_replace(' ', '_', strtolower($title));
110 110
 
111
-		foreach($titles as $post_id => $title){
111
+		foreach ($titles as $post_id => $title) {
112 112
 
113
-			if( $post_times[$post_id] > time() ){
113
+			if ($post_times[$post_id] > time()) {
114 114
 				continue;
115 115
 			}
116 116
 
117
-			similar_text($lower,strtolower($title),$percent);
117
+			similar_text($lower, strtolower($title), $percent);
118 118
 			$similar[$percent] = $post_id; //if similarity is the same for two posts, the newer post will take precedence
119 119
 		}
120 120
 
121 121
 		krsort($similar);
122 122
 
123 123
 		$similarity = key($similar);
124
-		if( $config['auto_redir'] > 0 && $similarity >= $config['auto_redir'] ){
124
+		if ($config['auto_redir'] > 0 && $similarity >= $config['auto_redir']) {
125 125
 			return current($similar);
126 126
 		}
127 127
 	}
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 	 * Output the html for a single blog post
133 133
 	 * Handle comment actions
134 134
 	 */
135
-	public function ShowPost(){
135
+	public function ShowPost() {
136 136
 
137 137
 
138
-		if( common::LoggedIn() ){
138
+		if (common::LoggedIn()) {
139 139
 			gpPlugin_incl('Admin/SimpleBlogPage.php');
140 140
 			$blog_page = new AdminSimpleBlogPage($this->post_id);
141
-		}else{
141
+		}else {
142 142
 			gpPlugin_incl('SimpleBlogPage.php');
143 143
 			$blog_page = new SimpleBlogPage($this->post_id);
144 144
 		}
@@ -151,49 +151,49 @@  discard block
 block discarded – undo
151 151
 	 * Display a blog page with multiple blog posts
152 152
 	 *
153 153
 	 */
154
-	public function ShowPage(){
154
+	public function ShowPage() {
155 155
 		global $page;
156 156
 
157 157
 		$per_page		= SimpleBlogCommon::$data['per_page'];
158 158
 		$page_num		= 0;
159
-		$expected_q		= '';
160
-		if( isset($_GET['page']) && is_numeric($_GET['page']) ){
161
-			$page_num		= (int)$_GET['page'];
162
-			$expected_q		= 'page='.$page_num;
159
+		$expected_q = '';
160
+		if (isset($_GET['page']) && is_numeric($_GET['page'])) {
161
+			$page_num = (int)$_GET['page'];
162
+			$expected_q = 'page='.$page_num;
163 163
 		}
164 164
 
165 165
 
166 166
 		//redirect if the request isn't correct
167
-		if( $page->requested != SimpleBlogCommon::$root_url ){
168
-			$expected_url = common::GetUrl( SimpleBlogCommon::$root_url, $expected_q, false );
167
+		if ($page->requested != SimpleBlogCommon::$root_url) {
168
+			$expected_url = common::GetUrl(SimpleBlogCommon::$root_url, $expected_q, false);
169 169
 			common::Redirect($expected_url);
170 170
 		}
171 171
 
172 172
 
173
-		$start				= $page_num * $per_page;
174
-		$include_drafts		= common::LoggedIn();
175
-		$show_posts			= SimpleBlogCommon::WhichPosts($start,$per_page,$include_drafts);
173
+		$start = $page_num * $per_page;
174
+		$include_drafts = common::LoggedIn();
175
+		$show_posts = SimpleBlogCommon::WhichPosts($start, $per_page, $include_drafts);
176 176
 
177 177
 		$this->ShowPosts($show_posts);
178 178
 
179 179
 		//pagination links
180 180
 		echo '<p class="blog_nav_links">';
181 181
 
182
-		if( $page_num > 0 ){
182
+		if ($page_num > 0) {
183 183
 
184
-			$html = common::Link('Special_Blog','%s');
185
-			echo gpOutput::GetAddonText('Blog Home',$html);
184
+			$html = common::Link('Special_Blog', '%s');
185
+			echo gpOutput::GetAddonText('Blog Home', $html);
186 186
 			echo '&nbsp;';
187 187
 
188
-			$html = common::Link('Special_Blog','%s','page='.($page_num-1),'class="blog_newer"');
189
-			echo gpOutput::GetAddonText('Newer Entries',$html);
188
+			$html = common::Link('Special_Blog', '%s', 'page='.($page_num-1), 'class="blog_newer"');
189
+			echo gpOutput::GetAddonText('Newer Entries', $html);
190 190
 			echo '&nbsp;';
191 191
 
192 192
 		}
193 193
 
194
-		if( ( ($page_num+1) * $per_page) < SimpleBlogCommon::$data['post_count'] ){
195
-			$html = common::Link('Special_Blog','%s','page='.($page_num+1),'class="blog_older"');
196
-			echo gpOutput::GetAddonText('Older Entries',$html);
194
+		if ((($page_num+1) * $per_page) < SimpleBlogCommon::$data['post_count']) {
195
+			$html = common::Link('Special_Blog', '%s', 'page='.($page_num+1), 'class="blog_older"');
196
+			echo gpOutput::GetAddonText('Older Entries', $html);
197 197
 		}
198 198
 
199 199
 		echo '</p>';
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	 * Output the blog posts in the array $post_list
206 206
 	 *
207 207
 	 */
208
-	public function ShowPosts($post_list){
208
+	public function ShowPosts($post_list) {
209 209
 
210 210
 		$posts = array();
211
-		foreach($post_list as $post_index){
212
-			$this->ShowPostContent( $post_index );
211
+		foreach ($post_list as $post_index) {
212
+			$this->ShowPostContent($post_index);
213 213
 		}
214 214
 
215 215
 	}
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 	 * Display the html for a single blog post
219 219
 	 *
220 220
 	 */
221
-	public function ShowPostContent( $post_index ){
221
+	public function ShowPostContent($post_index) {
222 222
 
223
-		if( !common::LoggedIn() && SimpleBlogCommon::AStrGet('drafts',$post_index) ){
223
+		if (!common::LoggedIn() && SimpleBlogCommon::AStrGet('drafts', $post_index)) {
224 224
 			return false;
225 225
 		}
226 226
 
227
-		$post	= SimpleBlogCommon::GetPostContent($post_index);
228
-		$class	= $id = '';
227
+		$post = SimpleBlogCommon::GetPostContent($post_index);
228
+		$class = $id = '';
229 229
 
230
-		if( common::LoggedIn() ){
230
+		if (common::LoggedIn()) {
231 231
 			SimpleBlog::EditLinks($post_index, $class, $id);
232 232
 		}
233 233
 
@@ -235,52 +235,52 @@  discard block
 block discarded – undo
235 235
 		echo '<div class="blog_post post_list_item'.$class.'" '.$id.'>';
236 236
 
237 237
 		$header = '<h2 id="blog_post_'.$post_index.'">';
238
-		if( SimpleBlogCommon::AStrGet('drafts',$post_index) ){
238
+		if (SimpleBlogCommon::AStrGet('drafts', $post_index)) {
239 239
 			$header .= '<span style="opacity:0.3;">';
240 240
 			$header .= gpOutput::SelectText('Draft');
241 241
 			$header .= '</span> ';
242
-		}elseif( $post['time'] > time() ){
242
+		}elseif ($post['time'] > time()) {
243 243
 			$header .= '<span style="opacity:0.3;">';
244 244
 			$header .= gpOutput::SelectText('Pending');
245 245
 			$header .= '</span> ';
246 246
 		}
247 247
 
248
-		$label = SimpleBlogCommon::Underscores( $post['title'] );
249
-		$header .= SimpleBlogCommon::PostLink($post_index,$label);
248
+		$label = SimpleBlogCommon::Underscores($post['title']);
249
+		$header .= SimpleBlogCommon::PostLink($post_index, $label);
250 250
 		$header .= '</h2>';
251 251
 
252
-		SimpleBlogCommon::BlogHead($header,$post_index,$post);
252
+		SimpleBlogCommon::BlogHead($header, $post_index, $post);
253 253
 
254 254
 		echo '<div class="twysiwygr">';
255 255
 
256
-		if( SimpleBlogCommon::$data['abbrev_image'] ){
256
+		if (SimpleBlogCommon::$data['abbrev_image']) {
257 257
 			$this->GetImageFromPost($post['content']);
258 258
 		}
259 259
 
260
-		echo $this->AbbrevContent( $post['content'], $post_index, SimpleBlogCommon::$data['post_abbrev']);
260
+		echo $this->AbbrevContent($post['content'], $post_index, SimpleBlogCommon::$data['post_abbrev']);
261 261
 		echo '</div>';
262 262
 
263 263
 		echo '</div>';
264 264
 
265 265
 
266 266
 
267
-		if( SimpleBlogCommon::$data['abbrev_cat'] && isset($post['categories']) && count($post['categories']) ){
267
+		if (SimpleBlogCommon::$data['abbrev_cat'] && isset($post['categories']) && count($post['categories'])) {
268 268
 			$temp = array();
269
-			foreach($post['categories'] as $catindex){
270
-				$title = SimpleBlogCommon::AStrGet( 'categories', $catindex );
271
-				if( !$title ){
269
+			foreach ($post['categories'] as $catindex) {
270
+				$title = SimpleBlogCommon::AStrGet('categories', $catindex);
271
+				if (!$title) {
272 272
 					continue;
273 273
 				}
274
-				if( SimpleBlogCommon::AStrGet('categories_hidden',$catindex) ){
274
+				if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
275 275
 					continue;
276 276
 				}
277 277
 				$temp[] = SimpleBlogCommon::CategoryLink($catindex, $title, $title);
278 278
 			}
279 279
 
280
-			if( count($temp) ){
280
+			if (count($temp)) {
281 281
 				echo '<div class="category_container">';
282 282
 				echo gpOutput::GetAddonText('Categories').' ';
283
-				echo implode(', ',$temp);
283
+				echo implode(', ', $temp);
284 284
 				echo '</div>';
285 285
 			}
286 286
 		}
@@ -295,35 +295,35 @@  discard block
 block discarded – undo
295 295
 	 * Get the fist image from the blog post
296 296
 	 *
297 297
 	 */
298
-	public function GetImageFromPost($item){
298
+	public function GetImageFromPost($item) {
299 299
 
300
-		$img_pos = strpos($item,'<img');
301
-		if( $img_pos === false ){
300
+		$img_pos = strpos($item, '<img');
301
+		if ($img_pos === false) {
302 302
 			return;
303 303
 		}
304
-		$src_pos = strpos($item,'src=',$img_pos);
305
-		if( $src_pos === false ){
304
+		$src_pos = strpos($item, 'src=', $img_pos);
305
+		if ($src_pos === false) {
306 306
 			return;
307 307
 		}
308
-		$src = substr($item,$src_pos+4);
308
+		$src = substr($item, $src_pos+4);
309 309
 		$quote = $src[0];
310
-		if( $quote != '"' && $quote != "'" ){
310
+		if ($quote != '"' && $quote != "'") {
311 311
 			return;
312 312
 		}
313
-		$src_pos = strpos($src,$quote,1);
314
-		$src = substr($src,1,$src_pos-1);
313
+		$src_pos = strpos($src, $quote, 1);
314
+		$src = substr($src, 1, $src_pos-1);
315 315
 
316 316
 		// check for resized image, get original source if img is resized
317
-		if( strpos($src,'image.php') !== false && strpos($src,'img=') !== false ){
318
-			$src = $dirPrefix . '/data/_uploaded/' . urldecode(substr($src,strpos($src,'img=')+4));
317
+		if (strpos($src, 'image.php') !== false && strpos($src, 'img=') !== false) {
318
+			$src = $dirPrefix.'/data/_uploaded/'.urldecode(substr($src, strpos($src, 'img=')+4));
319 319
 		}
320 320
 
321
-		$thumb_path		= common::ThumbnailPath($src);
321
+		$thumb_path = common::ThumbnailPath($src);
322 322
 
323 323
 		//make it an absolute path
324
-		if( isset($_SERVER['HTTP_HOST']) ){
324
+		if (isset($_SERVER['HTTP_HOST'])) {
325 325
 			$server = $_SERVER['HTTP_HOST'];
326
-		}else{
326
+		}else {
327 327
 			$server = $_SERVER['SERVER_NAME'];
328 328
 		}
329 329
 
@@ -337,39 +337,39 @@  discard block
 block discarded – undo
337 337
 	 * Get the edit links for the post
338 338
 	 *
339 339
 	 */
340
-	public static function EditLinks($post_index, &$class, &$id){
340
+	public static function EditLinks($post_index, &$class, &$id) {
341 341
 		global $langmessage;
342 342
 
343
-		$query		= 'du'; //dummy parameter
343
+		$query = 'du'; //dummy parameter
344 344
 
345
-		SimpleBlogCommon::UrlQuery( $post_index, $url, $query );
345
+		SimpleBlogCommon::UrlQuery($post_index, $url, $query);
346 346
 
347
-		$edit_link	= gpOutput::EditAreaLink($edit_index,$url,$langmessage['edit'].' (TWYSIWYG)',$query,'name="inline_edit_generic" rel="text_inline_edit"');
348
-		$class 		= ' editable_area';
349
-		$id			= 'id="ExtraEditArea'.$edit_index.'"';
347
+		$edit_link = gpOutput::EditAreaLink($edit_index, $url, $langmessage['edit'].' (TWYSIWYG)', $query, 'name="inline_edit_generic" rel="text_inline_edit"');
348
+		$class = ' editable_area';
349
+		$id = 'id="ExtraEditArea'.$edit_index.'"';
350 350
 
351 351
 
352 352
 		echo '<span style="display:none;" id="ExtraEditLnks'.$edit_index.'">';
353 353
 		echo $edit_link;
354 354
 
355
-		echo common::Link('Admin_Blog/'.$post_index,$langmessage['edit'].' (All)','cmd=edit_post',' style="display:none"');
355
+		echo common::Link('Admin_Blog/'.$post_index, $langmessage['edit'].' (All)', 'cmd=edit_post', ' style="display:none"');
356 356
 
357
-		echo common::Link('Special_Blog',$langmessage['delete'],'cmd=deleteentry&del_id='.$post_index,array('class'=>'delete gpconfirm','data-cmd'=>'cnreq','title'=>$langmessage['delete_confirm']));
357
+		echo common::Link('Special_Blog', $langmessage['delete'], 'cmd=deleteentry&del_id='.$post_index, array('class'=>'delete gpconfirm', 'data-cmd'=>'cnreq', 'title'=>$langmessage['delete_confirm']));
358 358
 
359
-		if( SimpleBlogCommon::$data['allow_comments'] ){
359
+		if (SimpleBlogCommon::$data['allow_comments']) {
360 360
 
361
-			$comments_closed = SimpleBlogCommon::AStrGet('comments_closed',$post_index);
362
-			if( $comments_closed ){
361
+			$comments_closed = SimpleBlogCommon::AStrGet('comments_closed', $post_index);
362
+			if ($comments_closed) {
363 363
 				$label = gpOutput::SelectText('Open Comments');
364
-				echo SimpleBlogCommon::PostLink($post_index,$label,'cmd=opencomments','name="cnreq" style="display:none"');
365
-			}else{
364
+				echo SimpleBlogCommon::PostLink($post_index, $label, 'cmd=opencomments', 'name="cnreq" style="display:none"');
365
+			}else {
366 366
 				$label = gpOutput::SelectText('Close Comments');
367
-				echo SimpleBlogCommon::PostLink($post_index,$label,'cmd=closecomments','name="cnreq" style="display:none"');
367
+				echo SimpleBlogCommon::PostLink($post_index, $label, 'cmd=closecomments', 'name="cnreq" style="display:none"');
368 368
 			}
369 369
 		}
370 370
 
371
-		echo common::Link('Admin_Blog','New Blog Post','cmd=new_form',' style="display:none"');
372
-		echo common::Link('Admin_Blog',$langmessage['administration'],'',' style="display:none"');
371
+		echo common::Link('Admin_Blog', 'New Blog Post', 'cmd=new_form', ' style="display:none"');
372
+		echo common::Link('Admin_Blog', $langmessage['administration'], '', ' style="display:none"');
373 373
 		echo '</span>';
374 374
 	}
375 375
 
@@ -377,26 +377,26 @@  discard block
 block discarded – undo
377 377
 	 * Abbreviate $content if a $limit greater than zero is given
378 378
 	 *
379 379
 	 */
380
-	public function AbbrevContent( $content, $post_index, $limit = 0 ){
380
+	public function AbbrevContent($content, $post_index, $limit = 0) {
381 381
 
382
-		if( !is_numeric($limit) || $limit == 0 ){
382
+		if (!is_numeric($limit) || $limit == 0) {
383 383
 			return $content;
384 384
 		}
385 385
 
386 386
 		$content = strip_tags($content);
387 387
 
388
-		if( mb_strlen($content) < $limit ){
388
+		if (mb_strlen($content) < $limit) {
389 389
 			return $content;
390 390
 		}
391 391
 
392
-		$pos = mb_strpos($content,' ',$limit-5);
392
+		$pos = mb_strpos($content, ' ', $limit-5);
393 393
 
394
-		if( ($pos > 0) && ($limit+20 > $pos) ){
394
+		if (($pos > 0) && ($limit+20 > $pos)) {
395 395
 			$limit = $pos;
396 396
 		}
397
-		$content = mb_substr($content,0,$limit).' ... ';
397
+		$content = mb_substr($content, 0, $limit).' ... ';
398 398
 		$label = gpOutput::SelectText('Read More');
399
-		return $content . SimpleBlogCommon::PostLink($post_index,$label);
399
+		return $content.SimpleBlogCommon::PostLink($post_index, $label);
400 400
 	}
401 401
 
402 402
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		if( common::LoggedIn() ){
139 139
 			gpPlugin_incl('Admin/SimpleBlogPage.php');
140 140
 			$blog_page = new AdminSimpleBlogPage($this->post_id);
141
-		}else{
141
+		} else{
142 142
 			gpPlugin_incl('SimpleBlogPage.php');
143 143
 			$blog_page = new SimpleBlogPage($this->post_id);
144 144
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 			$header .= '<span style="opacity:0.3;">';
240 240
 			$header .= gpOutput::SelectText('Draft');
241 241
 			$header .= '</span> ';
242
-		}elseif( $post['time'] > time() ){
242
+		} elseif( $post['time'] > time() ){
243 243
 			$header .= '<span style="opacity:0.3;">';
244 244
 			$header .= gpOutput::SelectText('Pending');
245 245
 			$header .= '</span> ';
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		//make it an absolute path
324 324
 		if( isset($_SERVER['HTTP_HOST']) ){
325 325
 			$server = $_SERVER['HTTP_HOST'];
326
-		}else{
326
+		} else{
327 327
 			$server = $_SERVER['SERVER_NAME'];
328 328
 		}
329 329
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 			if( $comments_closed ){
363 363
 				$label = gpOutput::SelectText('Open Comments');
364 364
 				echo SimpleBlogCommon::PostLink($post_index,$label,'cmd=opencomments','name="cnreq" style="display:none"');
365
-			}else{
365
+			} else{
366 366
 				$label = gpOutput::SelectText('Close Comments');
367 367
 				echo SimpleBlogCommon::PostLink($post_index,$label,'cmd=closecomments','name="cnreq" style="display:none"');
368 368
 			}
Please login to merge, or discard this patch.
SimpleBlogCommon.php 3 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -511,6 +511,7 @@  discard block
 block discarded – undo
511 511
 	 * Potential method for allowing users to format the header area of their blog
512 512
 	 * However, this would make it more difficult for theme developers to design for the blog plugin
513 513
 	 *
514
+	 * @param string $header
514 515
 	 */
515 516
 	public static function BlogHead($header,$post_index,$post,$cacheable=false){
516 517
 
@@ -607,6 +608,9 @@  discard block
 block discarded – undo
607 608
 		return str_replace('_', ' ', $str);
608 609
 	}
609 610
 
611
+	/**
612
+	 * @param string $file
613
+	 */
610 614
 	public static function FileData($file){
611 615
 
612 616
 		if( !file_exists($file) ){
@@ -733,6 +737,9 @@  discard block
 block discarded – undo
733 737
 		}
734 738
 	}
735 739
 
740
+	/**
741
+	 * @param string $label
742
+	 */
736 743
 	public static function CategoryLink( $catindex, $cattitle, $label, $query = '', $attr = '' ){
737 744
 
738 745
 		$url = 'Special_Blog_Categories';
@@ -854,6 +861,7 @@  discard block
 block discarded – undo
854 861
 	 * Get the key for a given value
855 862
 	 * Should be changed to allow for non-numeric keys
856 863
 	 *
864
+	 * @param string $data_string
857 865
 	 */
858 866
 	public static function AStrKey( $data_string, $value, $url_search = false ){
859 867
 		static $integers = '0123456789';
@@ -886,6 +894,7 @@  discard block
 block discarded – undo
886 894
 	/**
887 895
 	 * Remove a key-value
888 896
 	 *
897
+	 * @param string $data_string
889 898
 	 */
890 899
 	public static function AStrRm( $data_string, $key ){
891 900
 
@@ -894,6 +903,9 @@  discard block
 block discarded – undo
894 903
 	}
895 904
 
896 905
 
906
+	/**
907
+	 * @param string $data_string
908
+	 */
897 909
 	public static function AStrRmValue( $data_string, $value ){
898 910
 
899 911
 		$string =& SimpleBlogCommon::$data[$data_string];
@@ -905,6 +917,7 @@  discard block
 block discarded – undo
905 917
 	/**
906 918
 	 * Convert an AStr to an array
907 919
 	 *
920
+	 * @param string $data_string
908 921
 	 */
909 922
 	public static function AStrToArray( $data_string ){
910 923
 
Please login to merge, or discard this patch.
Spacing   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
  *
12 12
  *
13 13
  */
14
-class SimpleBlogCommon{
14
+class SimpleBlogCommon {
15 15
 
16 16
 	public static $index_file;
17 17
 	public static $data;
18
-	public static $root_url		= 'Special_Blog';
18
+	public static $root_url = 'Special_Blog';
19 19
 
20
-	public $new_install			= false;
20
+	public $new_install = false;
21 21
 	public $addonPathData;
22
-	public $post_id				= null;
22
+	public $post_id = null;
23 23
 
24 24
 	public static $data_dir;
25 25
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * When SimpleBlogCommon is created as an object, it will regenerate the static files
30 30
 	 *
31 31
 	 */
32
-	public function __construct(){
32
+	public function __construct() {
33 33
 		self::Init();
34 34
 		self::GenStaticContent();
35 35
 	}
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 	 * Set variables for blog display
39 39
 	 *
40 40
 	 */
41
-	public static function Init(){
41
+	public static function Init() {
42 42
 		global $addonPathData;
43 43
 
44
-		if( isset(self::$data) ){
44
+		if (isset(self::$data)) {
45 45
 			return;
46 46
 		}
47 47
 
48
-		self::$data_dir			= $addonPathData;
49
-		self::$index_file		= self::$data_dir.'/index.php';
48
+		self::$data_dir = $addonPathData;
49
+		self::$index_file = self::$data_dir.'/index.php';
50 50
 
51 51
 
52 52
 		self::$root_url = 'Special_Blog';
53
-		if( is_callable( array('common','SpecialHref') ) ){
53
+		if (is_callable(array('common', 'SpecialHref'))) {
54 54
 			self::$root_url = common::SpecialHref('Special_Blog');
55 55
 		}
56 56
 
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
 		//regenerate if there are pending posts that need to be published
63
-		if( !is_null(SimpleBlogCommon::$data['next_regen']) && SimpleBlogCommon::$data['next_regen'] < time()  ){
64
-			if( @gpFiles::WriteLock() ){
63
+		if (!is_null(SimpleBlogCommon::$data['next_regen']) && SimpleBlogCommon::$data['next_regen'] < time()) {
64
+			if (@gpFiles::WriteLock()) {
65 65
 				self::GenStaticContent();
66 66
 				SimpleBlogCommon::NextGenTime();
67 67
 				SimpleBlogCommon::SaveIndex();
68
-				gpFiles::Unlock('write',gp_random);
68
+				gpFiles::Unlock('write', gp_random);
69 69
 			}
70 70
 		}
71 71
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * Regenerate feed and gadgets
77 77
 	 *
78 78
 	 */
79
-	public static function GenStaticContent(){
79
+	public static function GenStaticContent() {
80 80
 		gpPlugin_incl('Admin/StaticGenerator.php');
81 81
 		StaticGenerator::Generate();
82 82
 	}
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 	 * Get next static gen time
87 87
 	 *
88 88
 	 */
89
-	public static function NextGenTime(){
89
+	public static function NextGenTime() {
90 90
 
91
-		$post_times			= SimpleBlogCommon::AStrToArray('post_times');
91
+		$post_times = SimpleBlogCommon::AStrToArray('post_times');
92 92
 		arsort($post_times);
93 93
 
94 94
 
95 95
 		asort($post_times);
96 96
 		$next_regen = null;
97
-		foreach($post_times as $time){
98
-			if( $time > time() ){
97
+		foreach ($post_times as $time) {
98
+			if ($time > time()) {
99 99
 				$next_regen = $time;
100 100
 				break;
101 101
 			}
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
 	 * Add css and some js to the page
111 111
 	 *
112 112
 	 */
113
-	public static function AddCSS(){
114
-		global $addonFolderName,$page;
113
+	public static function AddCSS() {
114
+		global $addonFolderName, $page;
115 115
 
116
-		static $added			= false;
116
+		static $added = false;
117 117
 
118
-		if( !$added ){
119
-			$page->jQueryCode	.= '$(".blog_gadget_link").click(function(){ $(this).next(".nodisplay").toggle(); });';
120
-			$page->css_user[]	= '/data/_addoncode/'.$addonFolderName.'/static/style.css';
121
-			$added				= true;
118
+		if (!$added) {
119
+			$page->jQueryCode .= '$(".blog_gadget_link").click(function(){ $(this).next(".nodisplay").toggle(); });';
120
+			$page->css_user[] = '/data/_addoncode/'.$addonFolderName.'/static/style.css';
121
+			$added = true;
122 122
 		}
123 123
 	}
124 124
 
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
 	 * Get the user configuration and information about the current blog
128 128
 	 *
129 129
 	 */
130
-	public function GetBlogData(){
130
+	public function GetBlogData() {
131 131
 
132 132
 		$blogData = array();
133
-		if( file_exists(self::$index_file) ){
133
+		if (file_exists(self::$index_file)) {
134 134
 			require(self::$index_file);
135 135
 		}
136 136
 
137 137
 		//old twitter auth no longer works
138
-		if( isset($blogData['twitter_username']) || isset($blogData['twitter_password']) ){
138
+		if (isset($blogData['twitter_username']) || isset($blogData['twitter_password'])) {
139 139
 			unset($blogData['twitter_username']);
140 140
 			unset($blogData['twitter_password']);
141 141
 		}
142 142
 
143
-		SimpleBlogCommon::$data = $blogData + SimpleBlogCommon::Defaults();
143
+		SimpleBlogCommon::$data = $blogData+SimpleBlogCommon::Defaults();
144 144
 		self::GenIndexStr();
145 145
 
146 146
 		//update to simple blog 2.0 data
147
-		if( isset(SimpleBlogCommon::$data['post_info']) ){
147
+		if (isset(SimpleBlogCommon::$data['post_info'])) {
148 148
 			self::DataUpdate20();
149 149
 		}
150 150
 	}
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * As of 2.0, Uses " and > instead , and :
158 158
 	 */
159
-	public static function GenIndexStr(){
159
+	public static function GenIndexStr() {
160 160
 
161
-		if( !empty(SimpleBlogCommon::$data['str_index']) ){
162
-			if( SimpleBlogCommon::$data['str_index'][0] == ',' ){
163
-				SimpleBlogCommon::$data['str_index'] = str_replace( array(',',':'), array('"','>'), SimpleBlogCommon::$data['str_index']);
161
+		if (!empty(SimpleBlogCommon::$data['str_index'])) {
162
+			if (SimpleBlogCommon::$data['str_index'][0] == ',') {
163
+				SimpleBlogCommon::$data['str_index'] = str_replace(array(',', ':'), array('"', '>'), SimpleBlogCommon::$data['str_index']);
164 164
 			}
165 165
 			return;
166 166
 		}
167
-		if( !isset(SimpleBlogCommon::$data['post_list']) ){
167
+		if (!isset(SimpleBlogCommon::$data['post_list'])) {
168 168
 			return;
169 169
 		}
170 170
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
 	 * Serialize comment counts
177 177
 	 *
178 178
 	 */
179
-	public static function DataUpdate20(){
179
+	public static function DataUpdate20() {
180 180
 
181
-		$comment_counts	= array();
181
+		$comment_counts = array();
182 182
 		$comments_closed = array();
183
-		if( isset(SimpleBlogCommon::$data['post_info']) && is_array(SimpleBlogCommon::$data['post_info']) ){
184
-			foreach(SimpleBlogCommon::$data['post_info'] as $post_id => $info){
185
-				if( isset($info['comments']) ){
183
+		if (isset(SimpleBlogCommon::$data['post_info']) && is_array(SimpleBlogCommon::$data['post_info'])) {
184
+			foreach (SimpleBlogCommon::$data['post_info'] as $post_id => $info) {
185
+				if (isset($info['comments'])) {
186 186
 					$comment_counts[$post_id] = $info['comments'];
187 187
 				}
188 188
 
189
-				if( isset($info['closecomments']) ){
189
+				if (isset($info['closecomments'])) {
190 190
 					$comments_closed[$post_id] = 1;
191 191
 				}
192 192
 			}
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
 
200 200
 		//use AStr data for categories
201 201
 		$categories = $categories_hidden = $category_posts = $post_categories = array();
202
-		if( !isset(SimpleBlogCommon::$data['categories']) ){
202
+		if (!isset(SimpleBlogCommon::$data['categories'])) {
203 203
 			$old_categories = self::load_blog_categories();
204
-			foreach($old_categories as $key => $cat){
205
-				$cat['ct'] = htmlspecialchars($cat['ct'],ENT_COMPAT,'UTF-8',false);
204
+			foreach ($old_categories as $key => $cat) {
205
+				$cat['ct'] = htmlspecialchars($cat['ct'], ENT_COMPAT, 'UTF-8', false);
206 206
 				$categories[$key] = $cat['ct'];
207
-				if( isset($cat['visible']) && !$cat['visible'] ){
207
+				if (isset($cat['visible']) && !$cat['visible']) {
208 208
 					$categories_hidden[$key] = 1;
209 209
 				}
210 210
 
211
-				if( isset($cat['posts']) && is_array($cat['posts']) ){
211
+				if (isset($cat['posts']) && is_array($cat['posts'])) {
212 212
 					$category_posts[$key] = array();
213
-					foreach($cat['posts'] as $post => $title){
213
+					foreach ($cat['posts'] as $post => $title) {
214 214
 						$category_posts[$key][] = $post;
215 215
 						$post_categories[$post][] = $key;
216 216
 					}
@@ -225,31 +225,31 @@  discard block
 block discarded – undo
225 225
 		$post_times = array();
226 226
 
227 227
 		$i = 0;
228
-		do{
228
+		do {
229 229
 
230
-			$posts = self::GetPostFile($i,$post_file);
231
-			if( !$posts ){
230
+			$posts = self::GetPostFile($i, $post_file);
231
+			if (!$posts) {
232 232
 				break;
233 233
 			}
234 234
 
235
-			foreach($posts as $post_id => $post){
235
+			foreach ($posts as $post_id => $post) {
236 236
 
237
-				if( isset($post['isDraft']) && $post['isDraft'] ){
237
+				if (isset($post['isDraft']) && $post['isDraft']) {
238 238
 					$drafts[$post_id] = 1;
239 239
 				}
240 240
 				$titles[$post_id] = $post['title'];
241 241
 				$post_times[$post_id] = $post['time'];
242 242
 
243 243
 				$posts[$post_id]['categories'] = array();
244
-				if( isset($post_categories[$post_id]) ){
244
+				if (isset($post_categories[$post_id])) {
245 245
 					$posts[$post_id]['categories'] = $post_categories[$post_id];
246 246
 				}
247 247
 			}
248 248
 
249
-			gpFiles::SaveArray($post_file,'posts',$posts);
249
+			gpFiles::SaveArray($post_file, 'posts', $posts);
250 250
 
251
-			$i +=20 ;
252
-		}while( $posts );
251
+			$i += 20;
252
+		}while ($posts);
253 253
 
254 254
 
255 255
 		//convert arrays to astr
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
 		SimpleBlogCommon::$data['categories'] = SimpleBlogCommon::AStrFromArray($categories);
261 261
 		SimpleBlogCommon::$data['categories_hidden'] = SimpleBlogCommon::AStrFromArray($categories_hidden);
262
-		foreach($category_posts as $key => $posts){
262
+		foreach ($category_posts as $key => $posts) {
263 263
 			SimpleBlogCommon::$data['category_posts_'.$key] = SimpleBlogCommon::AStrFromArray($posts);
264 264
 		}
265 265
 
@@ -281,27 +281,27 @@  discard block
 block discarded – undo
281 281
 	 * Get a list of post indeces
282 282
 	 *
283 283
 	 */
284
-	public static function WhichPosts($start, $len, $include_drafts = false){
284
+	public static function WhichPosts($start, $len, $include_drafts = false) {
285 285
 
286
-		$posts		= array();
287
-		$end		= $start+$len;
288
-		for($i = $start; $i < $end; $i++){
286
+		$posts = array();
287
+		$end = $start+$len;
288
+		for ($i = $start; $i < $end; $i++) {
289 289
 
290 290
 			//get post id
291
-			$post_id = SimpleBlogCommon::AStrGet('str_index',$i);
292
-			if( !$post_id ){
291
+			$post_id = SimpleBlogCommon::AStrGet('str_index', $i);
292
+			if (!$post_id) {
293 293
 				continue;
294 294
 			}
295 295
 
296
-			if( !$include_drafts ){
296
+			if (!$include_drafts) {
297 297
 				//exclude drafts
298
-				if( SimpleBlogCommon::AStrGet('drafts',$post_id) ){
298
+				if (SimpleBlogCommon::AStrGet('drafts', $post_id)) {
299 299
 					continue;
300 300
 				}
301 301
 
302 302
 				//exclude future posts
303
-				$time = SimpleBlogCommon::AStrGet('post_times',$post_id);
304
-				if( $time > time() ){
303
+				$time = SimpleBlogCommon::AStrGet('post_times', $post_id);
304
+				if ($time > time()) {
305 305
 					continue;
306 306
 				}
307 307
 			}
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
 	 * Return the configuration defaults
319 319
 	 * @static
320 320
 	 */
321
-	public static function Defaults(){
321
+	public static function Defaults() {
322 322
 		global $config;
323 323
 
324
-		$zero_strip = stristr(PHP_OS,'win') ? '' : '-';
324
+		$zero_strip = stristr(PHP_OS, 'win') ? '' : '-';
325 325
 
326
-		return array(	'post_index'			=> 0,
326
+		return array('post_index'			=> 0,
327 327
 						'per_page'				=> 10,
328 328
 						'post_abbrev'			=> '',
329 329
 						'gadget_entries'		=> 3,
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	 * Save the blog configuration and details about the blog
355 355
 	 *
356 356
 	 */
357
-	public static function SaveIndex(){
357
+	public static function SaveIndex() {
358 358
 
359
-		SimpleBlogCommon::$data['str_index'] = '"'.trim(SimpleBlogCommon::$data['str_index'],'"').'"';
360
-		SimpleBlogCommon::$data['post_count'] = substr_count(SimpleBlogCommon::$data['str_index'],'>');
359
+		SimpleBlogCommon::$data['str_index'] = '"'.trim(SimpleBlogCommon::$data['str_index'], '"').'"';
360
+		SimpleBlogCommon::$data['post_count'] = substr_count(SimpleBlogCommon::$data['str_index'], '>');
361 361
 
362
-		return gpFiles::SaveArray(self::$index_file,'blogData',SimpleBlogCommon::$data);
362
+		return gpFiles::SaveArray(self::$index_file, 'blogData', SimpleBlogCommon::$data);
363 363
 	}
364 364
 
365 365
 
@@ -370,21 +370,21 @@  discard block
 block discarded – undo
370 370
 	 * @deprecated 3.0
371 371
 	 *
372 372
 	 */
373
-	public static function GetPostFile($post_index,&$post_file){
373
+	public static function GetPostFile($post_index, &$post_file) {
374 374
 
375
-		if( !is_numeric($post_index) ){
375
+		if (!is_numeric($post_index)) {
376 376
 			return false;
377 377
 		}
378 378
 
379
-		$file_index		= floor($post_index/20);
380
-		$post_file		= self::$data_dir.'/posts_'.$file_index.'.php';
379
+		$file_index = floor($post_index / 20);
380
+		$post_file = self::$data_dir.'/posts_'.$file_index.'.php';
381 381
 
382
-		if( !file_exists($post_file) ){
382
+		if (!file_exists($post_file)) {
383 383
 			return false;
384 384
 		}
385 385
 
386 386
 		require($post_file);
387
-		if( !is_array($posts) ){
387
+		if (!is_array($posts)) {
388 388
 			return false;
389 389
 		}
390 390
 
@@ -396,20 +396,20 @@  discard block
 block discarded – undo
396 396
 	 * Get the content from a single post
397 397
 	 *
398 398
 	 */
399
-	public static function GetPostContent($post_index){
399
+	public static function GetPostContent($post_index) {
400 400
 
401
-		$file		= self::PostFilePath($post_index);
402
-		if( file_exists($file) ){
401
+		$file = self::PostFilePath($post_index);
402
+		if (file_exists($file)) {
403 403
 			require($file);
404 404
 			return $post;
405 405
 		}
406 406
 
407
-		$posts = self::GetPostFile($post_index,$post_file);
408
-		if( $posts === false ){
407
+		$posts = self::GetPostFile($post_index, $post_file);
408
+		if ($posts === false) {
409 409
 			return false;
410 410
 		}
411 411
 
412
-		if( !isset($posts[$post_index]) ){
412
+		if (!isset($posts[$post_index])) {
413 413
 			return false;
414 414
 		}
415 415
 		return $posts[$post_index];
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 * @since 3.0
422 422
 	 *
423 423
 	 */
424
-	public static function PostFilePath($post_index){
424
+	public static function PostFilePath($post_index) {
425 425
 		return self::$data_dir.'/posts/'.$post_index.'.php'; //3.0+
426 426
 	}
427 427
 
@@ -431,24 +431,24 @@  discard block
 block discarded – undo
431 431
 	 * @return bool
432 432
 	 *
433 433
 	 */
434
-	public static function Delete(){
434
+	public static function Delete() {
435 435
 		global $langmessage;
436 436
 
437
-		$post_id		= $_POST['del_id'];
438
-		$posts			= false;
437
+		$post_id = $_POST['del_id'];
438
+		$posts = false;
439 439
 
440 440
 
441 441
 		//post in single file or collection
442
-		$post_file		= self::PostFilePath($post_id);
443
-		if( !file_exists($post_file) ){
442
+		$post_file = self::PostFilePath($post_id);
443
+		if (!file_exists($post_file)) {
444 444
 
445
-			$posts		= self::GetPostFile($post_id,$post_file);
446
-			if( $posts === false ){
445
+			$posts = self::GetPostFile($post_id, $post_file);
446
+			if ($posts === false) {
447 447
 				message($langmessage['OOPS']);
448 448
 				return false;
449 449
 			}
450 450
 
451
-			if( !isset($posts[$post_id]) ){
451
+			if (!isset($posts[$post_id])) {
452 452
 				message($langmessage['OOPS']);
453 453
 				return false;
454 454
 			}
@@ -463,30 +463,30 @@  discard block
 block discarded – undo
463 463
 		//reset the index string
464 464
 		$new_index = SimpleBlogCommon::$data['str_index'];
465 465
 		$new_index = preg_replace('#"\d+>'.$post_id.'"#', '"', $new_index);
466
-		preg_match_all('#(?:"\d+>)([^">]*)#',$new_index,$matches);
466
+		preg_match_all('#(?:"\d+>)([^">]*)#', $new_index, $matches);
467 467
 		SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($matches[1]);
468 468
 
469 469
 
470 470
 		//remove post from other index strings
471
-		SimpleBlogCommon::AStrRm('drafts',$post_id);
472
-		SimpleBlogCommon::AStrRm('comments_closed',$post_id);
473
-		SimpleBlogCommon::AStrRm('titles',$post_id);
474
-		SimpleBlogCommon::AStrRm('post_times',$post_id);
471
+		SimpleBlogCommon::AStrRm('drafts', $post_id);
472
+		SimpleBlogCommon::AStrRm('comments_closed', $post_id);
473
+		SimpleBlogCommon::AStrRm('titles', $post_id);
474
+		SimpleBlogCommon::AStrRm('post_times', $post_id);
475 475
 
476 476
 
477 477
 
478
-		if( !SimpleBlogCommon::SaveIndex() ){
478
+		if (!SimpleBlogCommon::SaveIndex()) {
479 479
 			message($langmessage['OOPS']);
480 480
 			return false;
481 481
 		}
482 482
 
483 483
 		//save data file or remove the file
484
-		if( $posts ){
485
-			if( !gpFiles::SaveArray($post_file,'posts',$posts) ){
484
+		if ($posts) {
485
+			if (!gpFiles::SaveArray($post_file, 'posts', $posts)) {
486 486
 				message($langmessage['OOPS']);
487 487
 				return false;
488 488
 			}
489
-		}elseif( !unlink($post_file) ){
489
+		}elseif (!unlink($post_file)) {
490 490
 			message($langmessage['OOPS']);
491 491
 			return false;
492 492
 		}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
 		//delete the comments
496 496
 		$commentDataFile = self::$data_dir.'/comments/'.$post_id.'.txt';
497
-		if( file_exists($commentDataFile) ){
497
+		if (file_exists($commentDataFile)) {
498 498
 			unlink($commentDataFile);
499 499
 			SimpleBlogCommon::ClearCommentCache();
500 500
 		}
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 	 * However, this would make it more difficult for theme developers to design for the blog plugin
513 513
 	 *
514 514
 	 */
515
-	public static function BlogHead($header,$post_index,$post,$cacheable=false){
515
+	public static function BlogHead($header, $post_index, $post, $cacheable = false) {
516 516
 
517 517
 
518 518
 		//subtitle
519 519
 		$blog_info = '{empty_blog_piece}';
520
-		if( !empty($post['subtitle']) ){
520
+		if (!empty($post['subtitle'])) {
521 521
 			$blog_info = '<span class="simple_blog_subtitle">';
522 522
 			$blog_info .= $post['subtitle'];
523 523
 			$blog_info .= '</span>';
@@ -525,18 +525,18 @@  discard block
 block discarded – undo
525 525
 
526 526
 		//blog date
527 527
 		$blog_date = '<span class="simple_blog_date">';
528
-		$blog_date .= strftime(SimpleBlogCommon::$data['strftime_format'],$post['time']);
528
+		$blog_date .= strftime(SimpleBlogCommon::$data['strftime_format'], $post['time']);
529 529
 		$blog_date .= '</span>';
530 530
 
531 531
 
532 532
 		//blog comments
533 533
 		$blog_comments = '{empty_blog_piece}';
534
-		$count = SimpleBlogCommon::AStrGet('comment_counts',$post_index);
535
-		if( $count > 0 ){
534
+		$count = SimpleBlogCommon::AStrGet('comment_counts', $post_index);
535
+		if ($count > 0) {
536 536
 			$blog_comments = '<span class="simple_blog_comments">';
537
-			if( $cacheable ){
537
+			if ($cacheable) {
538 538
 				$blog_comments .= gpOutput::SelectText('Comments');
539
-			}else{
539
+			}else {
540 540
 				$blog_comments .= gpOutput::GetAddonText('Comments');
541 541
 			}
542 542
 			$blog_comments .= ': '.$count;
@@ -550,16 +550,16 @@  discard block
 block discarded – undo
550 550
 		$search = array('{header}', '{blog_info}', '{blog_date}', '{blog_comments}');
551 551
 		$replace = array($header, $blog_info, $blog_date, $blog_comments);
552 552
 
553
-		$result = str_replace($search,$replace,$format);
553
+		$result = str_replace($search, $replace, $format);
554 554
 
555 555
 
556 556
 		$reg = '#\{empty_blog_piece\}(\s*)\{separator\}#';
557
-		$result = preg_replace($reg,'\1',$result);
557
+		$result = preg_replace($reg, '\1', $result);
558 558
 
559 559
 		$reg = '#\{separator\}(\s*){empty_blog_piece\}#';
560
-		$result = preg_replace($reg,'\1',$result);
560
+		$result = preg_replace($reg, '\1', $result);
561 561
 
562
-		echo str_replace('{separator}',SimpleBlogCommon::$data['subtitle_separator'],$result);
562
+		echo str_replace('{separator}', SimpleBlogCommon::$data['subtitle_separator'], $result);
563 563
 	}
564 564
 
565 565
 
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
 	 * @deprecated 2.0
576 576
 	 *
577 577
 	 */
578
-	public static function load_blog_categories(){
578
+	public static function load_blog_categories() {
579 579
 		global $addonPathData;
580 580
 		$categories_file = $addonPathData.'/categories.php';
581 581
 
582
-		$categories = array( 'a' => array( 'ct'=>'Unsorted posts', 'visible'=>false,'posts'=>array() ) );
583
-		if( file_exists($categories_file) ){
582
+		$categories = array('a' => array('ct'=>'Unsorted posts', 'visible'=>false, 'posts'=>array()));
583
+		if (file_exists($categories_file)) {
584 584
 			include($categories_file);
585 585
 		}
586 586
 		return $categories;
@@ -591,29 +591,29 @@  discard block
 block discarded – undo
591 591
 	 * Remove a blog entry from a category
592 592
 	 *
593 593
 	 */
594
-	public static function DeletePostFromCategories( $post_id ){
594
+	public static function DeletePostFromCategories($post_id) {
595 595
 
596
-		$categories = SimpleBlogCommon::AStrToArray( 'categories' );
597
-		foreach($categories as $catindex => $catname){
598
-			SimpleBlogCommon::AStrRmValue( 'category_posts_'.$catindex, $post_id );
596
+		$categories = SimpleBlogCommon::AStrToArray('categories');
597
+		foreach ($categories as $catindex => $catname) {
598
+			SimpleBlogCommon::AStrRmValue('category_posts_'.$catindex, $post_id);
599 599
 		}
600 600
 	}
601 601
 
602 602
 
603
-	public static function Underscores($str){
604
-		if( function_exists('mb_ereg_replace') ){
603
+	public static function Underscores($str) {
604
+		if (function_exists('mb_ereg_replace')) {
605 605
 			return mb_ereg_replace('_', ' ', $str);
606 606
 		}
607 607
 		return str_replace('_', ' ', $str);
608 608
 	}
609 609
 
610
-	public static function FileData($file){
610
+	public static function FileData($file) {
611 611
 
612
-		if( !file_exists($file) ){
612
+		if (!file_exists($file)) {
613 613
 			return false;
614 614
 		}
615 615
 		$dataTxt = file_get_contents($file);
616
-		if( empty($dataTxt) ){
616
+		if (empty($dataTxt)) {
617 617
 			return false;
618 618
 		}
619 619
 
@@ -625,19 +625,19 @@  discard block
 block discarded – undo
625 625
 	 * Get the comment data for a single post
626 626
 	 *
627 627
 	 */
628
-	public static function GetCommentData($post_id){
628
+	public static function GetCommentData($post_id) {
629 629
 
630 630
 		// pre 1.7.4
631 631
 		$file = self::$data_dir.'/comments_data_'.$post_id.'.txt';
632 632
 		$data = SimpleBlogCommon::FileData($file);
633
-		if( is_array($data) ){
633
+		if (is_array($data)) {
634 634
 			return $data;
635 635
 		}
636 636
 
637 637
 		// 1.7.4+
638 638
 		$file = self::$data_dir.'/comments/'.$post_id.'.txt';
639 639
 		$data = SimpleBlogCommon::FileData($file);
640
-		if( is_array($data) ){
640
+		if (is_array($data)) {
641 641
 			return $data;
642 642
 		}
643 643
 
@@ -651,30 +651,30 @@  discard block
 block discarded – undo
651 651
 	 * Save the comment data for a blog post
652 652
 	 *
653 653
 	 */
654
-	public static function SaveCommentData($post_index,$data){
654
+	public static function SaveCommentData($post_index, $data) {
655 655
 		global $langmessage;
656 656
 
657 657
 
658 658
 		// check directory
659 659
 		$dir = self::$data_dir.'/comments';
660
-		if( !gpFiles::CheckDir($dir) ){
660
+		if (!gpFiles::CheckDir($dir)) {
661 661
 			return false;
662 662
 		}
663 663
 
664 664
 		$commentDataFile = $dir.'/'.$post_index.'.txt';
665 665
 		$dataTxt = serialize($data);
666
-		if( !gpFiles::Save($commentDataFile,$dataTxt) ){
666
+		if (!gpFiles::Save($commentDataFile, $dataTxt)) {
667 667
 			return false;
668 668
 		}
669 669
 
670 670
 
671 671
 		// clean pre 1.7.4 files
672 672
 		$commentDataFile = self::$data_dir.'/comments_data_'.$post_index.'.txt';
673
-		if( file_exists($commentDataFile) ){
673
+		if (file_exists($commentDataFile)) {
674 674
 			unlink($commentDataFile);
675 675
 		}
676 676
 
677
-		SimpleBlogCommon::AStrSet('comment_counts',$post_index,count($data));
677
+		SimpleBlogCommon::AStrSet('comment_counts', $post_index, count($data));
678 678
 
679 679
 		SimpleBlogCommon::SaveIndex();
680 680
 
@@ -687,32 +687,32 @@  discard block
 block discarded – undo
687 687
 	 * Delete the comments cache
688 688
 	 *
689 689
 	 */
690
-	public static function ClearCommentCache(){
690
+	public static function ClearCommentCache() {
691 691
 		$cache_file = self::$data_dir.'/comments/cache.txt';
692
-		if( file_exists($cache_file) ){
692
+		if (file_exists($cache_file)) {
693 693
 			unlink($cache_file);
694 694
 		}
695 695
 	}
696 696
 
697
-	public static function PostLink($post,$label,$query='',$attr=''){
698
-		return '<a href="'.SimpleBlogCommon::PostUrl($post,$query,true).'" '.$attr.'>'.common::Ampersands($label).'</a>';
697
+	public static function PostLink($post, $label, $query = '', $attr = '') {
698
+		return '<a href="'.SimpleBlogCommon::PostUrl($post, $query, true).'" '.$attr.'>'.common::Ampersands($label).'</a>';
699 699
 	}
700 700
 
701
-	public static function PostUrl( $post = false, $query='' ){
702
-		SimpleBlogCommon::UrlQuery( $post, $url, $query );
703
-		return common::GetUrl( $url, $query );
701
+	public static function PostUrl($post = false, $query = '') {
702
+		SimpleBlogCommon::UrlQuery($post, $url, $query);
703
+		return common::GetUrl($url, $query);
704 704
 	}
705 705
 
706
-	public static function UrlQuery( $post_id = false, &$url, &$query ){
706
+	public static function UrlQuery($post_id = false, &$url, &$query) {
707 707
 
708 708
 		$url = SimpleBlogCommon::$root_url;
709 709
 
710
-		if( $post_id > 0 ){
711
-			switch( SimpleBlogCommon::$data['urls'] ){
710
+		if ($post_id > 0) {
711
+			switch (SimpleBlogCommon::$data['urls']) {
712 712
 
713 713
 				case 'Full':
714
-					$title = SimpleBlogCommon::AStrGet('titles',$post_id);
715
-					$title = str_replace(array('?',' '),array('','_'),$title);
714
+					$title = SimpleBlogCommon::AStrGet('titles', $post_id);
715
+					$title = str_replace(array('?', ' '), array('', '_'), $title);
716 716
 					$url .= '/'.$post_id.'_'.$title;
717 717
 				break;
718 718
 
@@ -721,26 +721,26 @@  discard block
 block discarded – undo
721 721
 				break;
722 722
 
723 723
 				case 'Title':
724
-					$title = SimpleBlogCommon::AStrGet('titles',$post_id);
725
-					$title = str_replace(array('?',' '),array('','_'),$title);
724
+					$title = SimpleBlogCommon::AStrGet('titles', $post_id);
725
+					$title = str_replace(array('?', ' '), array('', '_'), $title);
726 726
 					$url .= '/'.$title;
727 727
 				break;
728 728
 
729 729
 				default:
730
-				$query = trim($query.'&id='.$post_id,'&');
730
+				$query = trim($query.'&id='.$post_id, '&');
731 731
 				break;
732 732
 			}
733 733
 		}
734 734
 	}
735 735
 
736
-	public static function CategoryLink( $catindex, $cattitle, $label, $query = '', $attr = '' ){
736
+	public static function CategoryLink($catindex, $cattitle, $label, $query = '', $attr = '') {
737 737
 
738 738
 		$url = 'Special_Blog_Categories';
739
-		switch( SimpleBlogCommon::$data['urls'] ){
739
+		switch (SimpleBlogCommon::$data['urls']) {
740 740
 
741 741
 			case 'Title':
742 742
 			case 'Full':
743
-				$cattitle = str_replace(array('?',' '),array('','_'),$cattitle);
743
+				$cattitle = str_replace(array('?', ' '), array('', '_'), $cattitle);
744 744
 				$url .= '/'.$cattitle;
745 745
 			break;
746 746
 
@@ -749,11 +749,11 @@  discard block
 block discarded – undo
749 749
 			break;
750 750
 
751 751
 			default:
752
-				$query = trim('cat='.$catindex.'&'.$query,'&');
752
+				$query = trim('cat='.$catindex.'&'.$query, '&');
753 753
 			break;
754 754
 		}
755 755
 
756
-		return '<a href="'.common::GetUrl( $url, $query ).'" '.$attr.'>'.common::Ampersands($label).'</a>';
756
+		return '<a href="'.common::GetUrl($url, $query).'" '.$attr.'>'.common::Ampersands($label).'</a>';
757 757
 	}
758 758
 
759 759
 
@@ -771,11 +771,11 @@  discard block
 block discarded – undo
771 771
 	 * Serialize a simple array into a string
772 772
 	 *
773 773
 	 */
774
-	public static function AStrFromArray($array){
774
+	public static function AStrFromArray($array) {
775 775
 		$str = '';
776
-		foreach($array as $key => $value){
777
-			$key = str_replace(array('"','>'),'',$key);
778
-			$value = str_replace(array('"','>'),'',$value);
776
+		foreach ($array as $key => $value) {
777
+			$key = str_replace(array('"', '>'), '', $key);
778
+			$value = str_replace(array('"', '>'), '', $value);
779 779
 			$str .= '"'.$key.'>'.$value;
780 780
 		}
781 781
 		return $str.'"';
@@ -789,9 +789,9 @@  discard block
 block discarded – undo
789 789
 	 * @param mixed $new_value
790 790
 	 * @deprecated 3.0.1
791 791
 	 */
792
-	public static function AStrValue( $data_string, $key, $new_value = false ){
792
+	public static function AStrValue($data_string, $key, $new_value = false) {
793 793
 
794
-		if( $new_value === false ){
794
+		if ($new_value === false) {
795 795
 			return self::AStrGet($data_string, $key);
796 796
 		}
797 797
 
@@ -804,16 +804,16 @@  discard block
 block discarded – undo
804 804
 	 * @param string $data_string
805 805
 	 * @param int|string $key
806 806
 	 */
807
-	public static function AStrGet( $data_string, $key){
807
+	public static function AStrGet($data_string, $key) {
808 808
 
809 809
 		//get position of current value
810
-		$prev_key_str	= '"'.$key.'>';
811
-		$offset			= strpos(SimpleBlogCommon::$data[$data_string],$prev_key_str);
810
+		$prev_key_str = '"'.$key.'>';
811
+		$offset = strpos(SimpleBlogCommon::$data[$data_string], $prev_key_str);
812 812
 
813
-		if( $offset !== false ){
814
-			$offset		+= strlen($prev_key_str);
815
-			$length		= strpos(SimpleBlogCommon::$data[$data_string],'"',$offset) - $offset;
816
-			return substr(SimpleBlogCommon::$data[$data_string],$offset,$length);
813
+		if ($offset !== false) {
814
+			$offset += strlen($prev_key_str);
815
+			$length = strpos(SimpleBlogCommon::$data[$data_string], '"', $offset)-$offset;
816
+			return substr(SimpleBlogCommon::$data[$data_string], $offset, $length);
817 817
 		}
818 818
 
819 819
 		return false;
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
 	 * @param int|string $key
827 827
 	 * @param string $new_value
828 828
 	 */
829
-	public static function AStrSet( $data_string, $key, $new_value){
829
+	public static function AStrSet($data_string, $key, $new_value) {
830 830
 
831 831
 
832 832
 		//get position of current value
833
-		$prev_key_str	= '"'.$key.'>';
834
-		$offset			= strpos(SimpleBlogCommon::$data[$data_string],$prev_key_str);
833
+		$prev_key_str = '"'.$key.'>';
834
+		$offset = strpos(SimpleBlogCommon::$data[$data_string], $prev_key_str);
835 835
 
836 836
 		//setting values
837
-		if( $offset === false ){
838
-			if( empty(SimpleBlogCommon::$data[$data_string]) ){
839
-				SimpleBlogCommon::$data[$data_string]	= '"';
837
+		if ($offset === false) {
838
+			if (empty(SimpleBlogCommon::$data[$data_string])) {
839
+				SimpleBlogCommon::$data[$data_string] = '"';
840 840
 			}
841
-			$key										= str_replace(array('"','>'),'',$key);
842
-			SimpleBlogCommon::$data[$data_string]		.= $key.'>'.$new_value.'"';
843
-		}else{
844
-			$offset										+= strlen($prev_key_str);
845
-			$length										= strpos(SimpleBlogCommon::$data[$data_string],'"',$offset) - $offset;
846
-			SimpleBlogCommon::$data[$data_string]		= substr_replace(SimpleBlogCommon::$data[$data_string],$new_value,$offset,$length);
841
+			$key = str_replace(array('"', '>'), '', $key);
842
+			SimpleBlogCommon::$data[$data_string] .= $key.'>'.$new_value.'"';
843
+		}else {
844
+			$offset += strlen($prev_key_str);
845
+			$length = strpos(SimpleBlogCommon::$data[$data_string], '"', $offset)-$offset;
846
+			SimpleBlogCommon::$data[$data_string] = substr_replace(SimpleBlogCommon::$data[$data_string], $new_value, $offset, $length);
847 847
 		}
848 848
 
849 849
 		return true;
@@ -855,31 +855,31 @@  discard block
 block discarded – undo
855 855
 	 * Should be changed to allow for non-numeric keys
856 856
 	 *
857 857
 	 */
858
-	public static function AStrKey( $data_string, $value, $url_search = false ){
858
+	public static function AStrKey($data_string, $value, $url_search = false) {
859 859
 		static $integers = '0123456789';
860 860
 
861
-		if( !isset(SimpleBlogCommon::$data[$data_string]) ){
861
+		if (!isset(SimpleBlogCommon::$data[$data_string])) {
862 862
 			return false;
863 863
 		}
864 864
 
865 865
 		$string			= SimpleBlogCommon::$data[$data_string];
866 866
 
867
-		if( $url_search ){
868
-			$string		= str_replace(array('?',' '),array('','_'),$string);
867
+		if ($url_search) {
868
+			$string		= str_replace(array('?', ' '), array('', '_'), $string);
869 869
 		}
870 870
 
871
-		$len			= strlen($string);
872
-		$post_pos		= strpos($string,'>'.$value.'"');
871
+		$len = strlen($string);
872
+		$post_pos = strpos($string, '>'.$value.'"');
873 873
 
874
-		if( $post_pos === false ){
874
+		if ($post_pos === false) {
875 875
 			return false;
876 876
 		}
877 877
 
878
-		$offset			= $post_pos-$len;
879
-		$post_key_pos	= strrpos( $string, '"', $offset );
880
-		$post_key_len	= strspn( $string, $integers, $post_key_pos+1 );
878
+		$offset = $post_pos-$len;
879
+		$post_key_pos	= strrpos($string, '"', $offset);
880
+		$post_key_len	= strspn($string, $integers, $post_key_pos+1);
881 881
 
882
-		return substr( $string, $post_key_pos+1, $post_key_len );
882
+		return substr($string, $post_key_pos+1, $post_key_len);
883 883
 	}
884 884
 
885 885
 
@@ -887,16 +887,16 @@  discard block
 block discarded – undo
887 887
 	 * Remove a key-value
888 888
 	 *
889 889
 	 */
890
-	public static function AStrRm( $data_string, $key ){
890
+	public static function AStrRm($data_string, $key) {
891 891
 
892
-		$string =& SimpleBlogCommon::$data[$data_string];
892
+		$string = & SimpleBlogCommon::$data[$data_string];
893 893
 		$string = preg_replace('#"'.$key.'>[^">]*\"#', '"', $string);
894 894
 	}
895 895
 
896 896
 
897
-	public static function AStrRmValue( $data_string, $value ){
897
+	public static function AStrRmValue($data_string, $value) {
898 898
 
899
-		$string =& SimpleBlogCommon::$data[$data_string];
899
+		$string = & SimpleBlogCommon::$data[$data_string];
900 900
 		$string = preg_replace('#"[^">]*>'.$value.'\"#', '"', $string);
901 901
 
902 902
 	}
@@ -906,19 +906,19 @@  discard block
 block discarded – undo
906 906
 	 * Convert an AStr to an array
907 907
 	 *
908 908
 	 */
909
-	public static function AStrToArray( $data_string ){
909
+	public static function AStrToArray($data_string) {
910 910
 
911
-		$string =& SimpleBlogCommon::$data[$data_string];
911
+		$string = & SimpleBlogCommon::$data[$data_string];
912 912
 
913 913
 		$count = preg_match_all('#(?:([^">]*)>)([^">]*)#', $string, $matches);
914
-		if( !$count ){
914
+		if (!$count) {
915 915
 			return array();
916 916
 		}
917 917
 
918 918
 		$keys = $matches[1];
919 919
 		$values = $matches[2];
920 920
 
921
-		return array_combine($matches[1],$matches[2]);
921
+		return array_combine($matches[1], $matches[2]);
922 922
 	}
923 923
 
924 924
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 				message($langmessage['OOPS']);
487 487
 				return false;
488 488
 			}
489
-		}elseif( !unlink($post_file) ){
489
+		} elseif( !unlink($post_file) ){
490 490
 			message($langmessage['OOPS']);
491 491
 			return false;
492 492
 		}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 			$blog_comments = '<span class="simple_blog_comments">';
537 537
 			if( $cacheable ){
538 538
 				$blog_comments .= gpOutput::SelectText('Comments');
539
-			}else{
539
+			} else{
540 540
 				$blog_comments .= gpOutput::GetAddonText('Comments');
541 541
 			}
542 542
 			$blog_comments .= ': '.$count;
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 			}
841 841
 			$key										= str_replace(array('"','>'),'',$key);
842 842
 			SimpleBlogCommon::$data[$data_string]		.= $key.'>'.$new_value.'"';
843
-		}else{
843
+		} else{
844 844
 			$offset										+= strlen($prev_key_str);
845 845
 			$length										= strpos(SimpleBlogCommon::$data[$data_string],'"',$offset) - $offset;
846 846
 			SimpleBlogCommon::$data[$data_string]		= substr_replace(SimpleBlogCommon::$data[$data_string],$new_value,$offset,$length);
Please login to merge, or discard this patch.
Search.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,27 +3,27 @@
 block discarded – undo
3 3
 
4 4
 gpPlugin_incl('SimpleBlogCommon.php');
5 5
 
6
-class BlogSearch extends SimpleBlogCommon{
6
+class BlogSearch extends SimpleBlogCommon {
7 7
 
8
-	function __construct($args){
8
+	function __construct($args) {
9 9
 
10 10
 		SimpleBlogCommon::Init();
11 11
 
12 12
 		$search_obj		= $args[0];
13 13
 		$blog_label		= common::GetLabelIndex('special_blog');
14
-		$post_ids		= SimpleBlogCommon::AStrToArray('str_index');
14
+		$post_ids = SimpleBlogCommon::AStrToArray('str_index');
15 15
 
16
-		foreach($post_ids as $id){
17
-			$post		= SimpleBlogCommon::GetPostContent($id);
16
+		foreach ($post_ids as $id) {
17
+			$post = SimpleBlogCommon::GetPostContent($id);
18 18
 
19
-			if( !$post ){
19
+			if (!$post) {
20 20
 				continue;
21 21
 			}
22 22
 
23
-			$title		= $blog_label.': '.str_replace('_',' ',$post['title']);
24
-			$content	= str_replace('_',' ',$post['title']).' '.$post['content'];
23
+			$title = $blog_label.': '.str_replace('_', ' ', $post['title']);
24
+			$content = str_replace('_', ' ', $post['title']).' '.$post['content'];
25 25
 
26
-			SimpleBlogCommon::UrlQuery( $id, $url, $query );
26
+			SimpleBlogCommon::UrlQuery($id, $url, $query);
27 27
 			$search_obj->FindString($content, $title, $url, $query);
28 28
 		}
29 29
 
Please login to merge, or discard this patch.
ArchivesGadget.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,26 +3,26 @@
 block discarded – undo
3 3
 
4 4
 gpPlugin_incl('SimpleBlogCommon.php');
5 5
 
6
-class SimpleBlogArchives{
6
+class SimpleBlogArchives {
7 7
 
8
-	function __construct(){
8
+	function __construct() {
9 9
 		global $addonPathData;
10 10
 
11 11
 		SimpleBlogCommon::AddCSS();
12 12
 
13 13
 		$content = '';
14 14
 		$gadget_file = $addonPathData.'/gadget_archive.php';
15
-		if( file_exists($gadget_file) ){
15
+		if (file_exists($gadget_file)) {
16 16
 			$content = file_get_contents($gadget_file);
17 17
 		}
18 18
 
19 19
 		//fix edit links
20
-		if( strpos($content,'simple_blog_gadget_label') ){
20
+		if (strpos($content, 'simple_blog_gadget_label')) {
21 21
 			new SimpleBlogCommon();
22 22
 			$content = file_get_contents($gadget_file);
23 23
 		}
24 24
 
25
-		if( empty($content) ){
25
+		if (empty($content)) {
26 26
 			return;
27 27
 		}
28 28
 
Please login to merge, or discard this patch.