Completed
Pull Request — master (#5)
by
unknown
11:47
created
Admin/StaticGenerator.php 2 patches
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		ob_start();
26 26
 
27 27
 		$atomFormat = 'Y-m-d\TH:i:s\Z';
28
-		$show_posts = SimpleBlogCommon::WhichPosts(0,SimpleBlogCommon::$data['feed_entries']);
28
+		$show_posts = SimpleBlogCommon::WhichPosts(0, SimpleBlogCommon::$data['feed_entries']);
29 29
 
30 30
 
31 31
 		if( isset($_SERVER['HTTP_HOST']) ){
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 		echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
40 40
 		echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
41 41
 		echo '<title>'.$config['title'].'</title>'."\n";
42
-		echo '<link href="'.$serverWithDir.'/data/_addondata/'.str_replace(' ', '%20',$addonFolderName).'/feed.atom" rel="self" />'."\n";
42
+		echo '<link href="'.$serverWithDir.'/data/_addondata/'.str_replace(' ', '%20', $addonFolderName).'/feed.atom" rel="self" />'."\n";
43 43
 		echo '<link href="'.$server.common::GetUrl('Special_Blog').'" />'."\n";
44 44
 		echo '<id>urn:uuid:'.self::uuid($serverWithDir).'</id>'."\n";
45 45
 		echo '<updated>'.date($atomFormat, time()).'</updated>'."\n";
46 46
 		echo '<author><name>'.$config['title'].'</name></author>'."\n";
47 47
 
48 48
 
49
-		foreach($show_posts as $post_index){
49
+		foreach( $show_posts as $post_index ){
50 50
 
51 51
 			$post = SimpleBlogCommon::GetPostContent($post_index);
52 52
 
@@ -55,31 +55,31 @@  discard block
 block discarded – undo
55 55
 			}
56 56
 
57 57
 			echo '<entry>'."\n";
58
-			echo '<title>'.SimpleBlogCommon::Underscores( $post['title'] ).'</title>'."\n";
58
+			echo '<title>'.SimpleBlogCommon::Underscores($post['title']).'</title>'."\n";
59 59
 			echo '<link href="'.$server.SimpleBlogCommon::PostUrl($post_index).'"></link>'."\n";
60 60
 			echo '<id>urn:uuid:'.self::uuid($post_index).'</id>'."\n";
61 61
 			echo '<updated>'.date($atomFormat, $post['time']).'</updated>'."\n";
62 62
 
63
-			$content =& $post['content'];
64
-			if( (SimpleBlogCommon::$data['feed_abbrev']> 0) && (mb_strlen($content) > SimpleBlogCommon::$data['feed_abbrev']) ){
65
-				$content = mb_substr($content,0,SimpleBlogCommon::$data['feed_abbrev']).' ... ';
63
+			$content = & $post['content'];
64
+			if( (SimpleBlogCommon::$data['feed_abbrev'] > 0) && (mb_strlen($content) > SimpleBlogCommon::$data['feed_abbrev']) ){
65
+				$content = mb_substr($content, 0, SimpleBlogCommon::$data['feed_abbrev']).' ... ';
66 66
 				$label = gpOutput::SelectText('Read More');
67
-				$content .= '<a href="'.$server.SimpleBlogCommon::PostUrl($post_index,$label).'">'.$label.'</a>';
67
+				$content .= '<a href="'.$server.SimpleBlogCommon::PostUrl($post_index, $label).'">'.$label.'</a>';
68 68
 			}
69 69
 
70 70
 			//old images
71 71
 			$replacement = $server.'/';
72
-			$content = str_replace('src="/', 'src="'.$replacement,$content);
72
+			$content = str_replace('src="/', 'src="'.$replacement, $content);
73 73
 
74 74
 			//new images
75
-			$content = str_replace('src="../', 'src="'.$serverWithDir,$content);
75
+			$content = str_replace('src="../', 'src="'.$serverWithDir, $content);
76 76
 
77 77
 			//images without /index.php/
78
-			$content = str_replace('src="./', 'src="'.$serverWithDir,$content);
78
+			$content = str_replace('src="./', 'src="'.$serverWithDir, $content);
79 79
 
80 80
 
81 81
 			//href
82
-			self::FixLinks($content,$server,0);
82
+			self::FixLinks($content, $server, 0);
83 83
 
84 84
 			echo '<summary type="html"><![CDATA['.$content.']]></summary>'."\n";
85 85
 			echo '</entry>'."\n";
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$feed = ob_get_clean();
91 91
 		$feedFile = SimpleBlogCommon::$data_dir.'/feed.atom';
92
-		gpFiles::Save($feedFile,$feed);
92
+		gpFiles::Save($feedFile, $feed);
93 93
 	}
94 94
 
95 95
 
@@ -103,31 +103,31 @@  discard block
 block discarded – undo
103 103
 		global $langmessage;
104 104
 
105 105
 		$posts = array();
106
-		$show_posts = SimpleBlogCommon::WhichPosts(0,SimpleBlogCommon::$data['gadget_entries']);
106
+		$show_posts = SimpleBlogCommon::WhichPosts(0, SimpleBlogCommon::$data['gadget_entries']);
107 107
 
108 108
 
109 109
 		ob_start();
110 110
 		$label = gpOutput::SelectText('Blog');
111 111
 		if( !empty($label) ){
112 112
 			echo '<h3>';
113
-			echo common::Link('Special_Blog',$label);
113
+			echo common::Link('Special_Blog', $label);
114 114
 			echo '</h3>';
115 115
 		}
116 116
 
117
-		foreach($show_posts as $post_index){
117
+		foreach( $show_posts as $post_index ){
118 118
 
119
-			$post		= SimpleBlogCommon::GetPostContent($post_index);
119
+			$post = SimpleBlogCommon::GetPostContent($post_index);
120 120
 
121 121
 			if( !$post ){
122 122
 				continue;
123 123
 			}
124 124
 
125
-			$header		= '<b class="simple_blog_title">';
126
-			$label		= SimpleBlogCommon::Underscores( $post['title'] );
127
-			$header		.= SimpleBlogCommon::PostLink($post_index,$label);
125
+			$header = '<b class="simple_blog_title">';
126
+			$label = SimpleBlogCommon::Underscores($post['title']);
127
+			$header		.= SimpleBlogCommon::PostLink($post_index, $label);
128 128
 			$header		.= '</b>';
129 129
 
130
-			SimpleBlogCommon::BlogHead($header,$post_index,$post,true);
130
+			SimpleBlogCommon::BlogHead($header, $post_index, $post, true);
131 131
 
132 132
 
133 133
 			$content = strip_tags($post['content']);
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 
137 137
 				$cut = SimpleBlogCommon::$data['gadget_abbrev'];
138 138
 
139
-				$pos = mb_strpos($content,' ',$cut-5);
139
+				$pos = mb_strpos($content, ' ', $cut-5);
140 140
 				if( ($pos > 0) && ($cut+20 > $pos) ){
141 141
 					$cut = $pos;
142 142
 				}
143
-				$content = mb_substr($content,0,$cut).' ... ';
143
+				$content = mb_substr($content, 0, $cut).' ... ';
144 144
 
145 145
 				$label = gpOutput::SelectText('Read More');
146
-				$content .= SimpleBlogCommon::PostLink($post_index,$label);
146
+				$content .= SimpleBlogCommon::PostLink($post_index, $label);
147 147
 			}
148 148
 
149 149
 			echo '<p class="simple_blog_abbrev">';
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 		if( SimpleBlogCommon::$data['post_count'] > 3 ){
156 156
 
157 157
 			$label = gpOutput::SelectText('More Blog Entries');
158
-			echo common::Link('Special_Blog',$label);
158
+			echo common::Link('Special_Blog', $label);
159 159
 		}
160 160
 
161 161
 		$gadget = ob_get_clean();
162 162
 		$gadgetFile = SimpleBlogCommon::$data_dir.'/gadget.php';
163
-		gpFiles::Save($gadgetFile,$gadget);
163
+		gpFiles::Save($gadgetFile, $gadget);
164 164
 	}
165 165
 
166 166
 
@@ -171,20 +171,20 @@  discard block
 block discarded – undo
171 171
 	static function GenCategoryGadget(){
172 172
 		global $addonPathData;
173 173
 
174
-		$categories = SimpleBlogCommon::AStrToArray( 'categories' );
174
+		$categories = SimpleBlogCommon::AStrToArray('categories');
175 175
 		$post_drafts = SimpleBlogCommon::AStrToArray('drafts');
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
-			foreach($posts as $key => $post_id){
187
+			foreach( $posts as $key => $post_id ){
188 188
 				if( isset($post_drafts[$post_id]) ){
189 189
 				  unset($posts[$key]);
190 190
 				}
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 			echo '<li>';
199 199
 			echo '<a class="blog_gadget_link">'.$catname.' ('.$sum.')</a>';
200 200
 			echo '<ul class="nodisplay">';
201
-			foreach($posts as $post_id){
202
-				$post_title = SimpleBlogCommon::AStrGet('titles',$post_id);
201
+			foreach( $posts as $post_id ){
202
+				$post_title = SimpleBlogCommon::AStrGet('titles', $post_id);
203 203
 				echo '<li>';
204
-				echo SimpleBlogCommon::PostLink( $post_id, $post_title );
204
+				echo SimpleBlogCommon::PostLink($post_id, $post_title);
205 205
 				echo '</li>';
206 206
 			}
207 207
 			echo '</ul></li>';
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
 
214 214
 		$gadgetFile = $addonPathData.'/gadget_categories.php';
215
-		gpFiles::Save( $gadgetFile, $content );
215
+		gpFiles::Save($gadgetFile, $content);
216 216
 	}
217 217
 
218 218
 
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
 		global $addonPathData;
225 225
 
226 226
 		//get list of posts and times
227
-		$list = SimpleBlogCommon::AStrToArray( 'post_times' );
227
+		$list = SimpleBlogCommon::AStrToArray('post_times');
228 228
 		$post_drafts = SimpleBlogCommon::AStrToArray('drafts');
229 229
 		if( !count($list) ) return;
230 230
 
231 231
 		//get year counts
232 232
 		$archive = array();
233
-		foreach($list as $post_id => $time){
233
+		foreach( $list as $post_id => $time ){
234 234
 		  if( !isset($post_drafts[$post_id]) ){
235
-			$ym = date('Y-m',$time); //year&month
235
+			$ym = date('Y-m', $time); //year&month
236 236
 			$archive[$ym][] = $post_id;
237 237
 		  }
238 238
 		}
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 		$prev_year = false;
244 244
 		echo '<ul>';
245 245
 		foreach( $archive as $ym => $posts ){
246
-			$y = substr($ym,0,4);
247
-			$m = substr($ym,-2);
246
+			$y = substr($ym, 0, 4);
247
+			$m = substr($ym, -2);
248 248
 			if( $y != $prev_year ){
249 249
 				if( $prev_year !== false ){
250 250
 					echo '</li>';
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
 			echo '<ul>';
262 262
 			echo '<li><a class="blog_gadget_link">';
263 263
 			$time = strtotime($ym.'-01');
264
-			echo strftime('%B',$time);
264
+			echo strftime('%B', $time);
265 265
 			echo ' ('.$sum.')</a>';
266 266
 			echo '<ul class="simple_blog_category_posts nodisplay">';
267
-			foreach($posts as $post_id ){
268
-				$post_title = SimpleBlogCommon::AStrGet('titles',$post_id);
267
+			foreach( $posts as $post_id ){
268
+				$post_title = SimpleBlogCommon::AStrGet('titles', $post_id);
269 269
 				echo '<li>';
270
-				echo SimpleBlogCommon::PostLink($post_id, $post_title );
270
+				echo SimpleBlogCommon::PostLink($post_id, $post_title);
271 271
 				echo '</li>';
272 272
 			}
273 273
 			echo '</ul>';
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 		$content = ob_get_clean();
281 281
 
282 282
 		$gadgetFile = $addonPathData.'/gadget_archive.php';
283
-		gpFiles::Save( $gadgetFile, $content );
283
+		gpFiles::Save($gadgetFile, $content);
284 284
 	}
285 285
 
286 286
 	static function uuid($str){
287 287
 		$chars = md5($str);
288
-		return mb_substr($chars,0,8)
289
-				.'-'. mb_substr($chars,8,4)
290
-				.'-'. mb_substr($chars,12,4)
291
-				.'-'. mb_substr($chars,16,4)
292
-				.'-'. mb_substr($chars,20,12);
288
+		return mb_substr($chars, 0, 8)
289
+				.'-'.mb_substr($chars, 8, 4)
290
+				.'-'.mb_substr($chars, 12, 4)
291
+				.'-'.mb_substr($chars, 16, 4)
292
+				.'-'.mb_substr($chars, 20, 12);
293 293
 		return $uuid;
294 294
 	}
295 295
 
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 	 * @param string $server
302 302
 	 * @param integer $offset
303 303
 	 */
304
-	public static function FixLinks(&$content,$server,$offset){
304
+	public static function FixLinks(&$content, $server, $offset){
305 305
 
306
-		preg_match_all('#href="([^<>"]+)"#i',$content,$matches,PREG_SET_ORDER);
307
-		foreach($matches as $match){
308
-			self::FixLink($content,$server,$match);
306
+		preg_match_all('#href="([^<>"]+)"#i', $content, $matches, PREG_SET_ORDER);
307
+		foreach( $matches as $match ){
308
+			self::FixLink($content, $server, $match);
309 309
 		}
310 310
 
311 311
 	}
@@ -315,24 +315,24 @@  discard block
 block discarded – undo
315 315
 	 * Change relative link to absolute link
316 316
 	 *
317 317
 	 */
318
-	public static function FixLink(&$content,$server,$match){
318
+	public static function FixLink(&$content, $server, $match){
319 319
 
320
-		if( strpos($match[1],'mailto:') !== false ){
320
+		if( strpos($match[1], 'mailto:') !== false ){
321 321
 			return;
322 322
 		}
323
-		if( strpos($match[1],'://') !== false ){
323
+		if( strpos($match[1], '://') !== false ){
324 324
 			return;
325 325
 		}
326 326
 
327
-		if( mb_strpos($match[1],'/') === 0 ){
327
+		if( mb_strpos($match[1], '/') === 0 ){
328 328
 			$replacement = $server.$match[1];
329 329
 		}else{
330 330
 			$replacement = $server.common::GetUrl($match[1]);
331 331
 		}
332 332
 
333
-		$replacement = str_replace($match[1],$replacement,$match[0]);
333
+		$replacement = str_replace($match[1], $replacement, $match[0]);
334 334
 
335
-		$content = str_replace($match[0],$replacement,$content);
335
+		$content = str_replace($match[0], $replacement, $content);
336 336
 	}
337 337
 
338 338
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 		if( isset($_SERVER['HTTP_HOST']) ){
32 32
 			$server = 'http://'.$_SERVER['HTTP_HOST'];
33
-		}else{
33
+		} else{
34 34
 			$server = 'http://'.$_SERVER['SERVER_NAME'];
35 35
 		}
36 36
 		$serverWithDir = $server.$dirPrefix;
@@ -226,7 +226,9 @@  discard block
 block discarded – undo
226 226
 		//get list of posts and times
227 227
 		$list = SimpleBlogCommon::AStrToArray( 'post_times' );
228 228
 		$post_drafts = SimpleBlogCommon::AStrToArray('drafts');
229
-		if( !count($list) ) return;
229
+		if( !count($list) ){
230
+			return;
231
+		}
230 232
 
231 233
 		//get year counts
232 234
 		$archive = array();
@@ -326,7 +328,7 @@  discard block
 block discarded – undo
326 328
 
327 329
 		if( mb_strpos($match[1],'/') === 0 ){
328 330
 			$replacement = $server.$match[1];
329
-		}else{
331
+		} else{
330 332
 			$replacement = $server.common::GetUrl($match[1]);
331 333
 		}
332 334
 
Please login to merge, or discard this patch.