@@ -15,11 +15,11 @@ discard block |
||
| 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 | |
@@ -45,12 +45,12 @@ discard block |
||
| 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 |
||
| 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() ){ |
|
| 63 | + if( !is_null(SimpleBlogCommon::$data['next_regen']) && SimpleBlogCommon::$data['next_regen'] < time() ){ |
|
| 64 | 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 | |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 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){ |
|
| 97 | + foreach( $post_times as $time ){ |
|
| 98 | 98 | if( $time > time() ){ |
| 99 | 99 | $next_regen = $time; |
| 100 | 100 | break; |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | */ |
| 113 | 113 | public static function AddCSS(){ |
| 114 | - global $addonFolderName,$page; |
|
| 114 | + global $addonFolderName, $page; |
|
| 115 | 115 | |
| 116 | - static $added = false; |
|
| 116 | + static $added = false; |
|
| 117 | 117 | |
| 118 | 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; |
|
| 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 | |
@@ -140,7 +140,7 @@ discard block |
||
| 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 |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | if( !empty(SimpleBlogCommon::$data['str_index']) ){ |
| 162 | 162 | if( SimpleBlogCommon::$data['str_index'][0] == ',' ){ |
| 163 | - SimpleBlogCommon::$data['str_index'] = str_replace( array(',',':'), array('"','>'), SimpleBlogCommon::$data['str_index']); |
|
| 163 | + SimpleBlogCommon::$data['str_index'] = str_replace(array(',', ':'), array('"', '>'), SimpleBlogCommon::$data['str_index']); |
|
| 164 | 164 | } |
| 165 | 165 | return; |
| 166 | 166 | } |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public static function DataUpdate20(){ |
| 180 | 180 | |
| 181 | - $comment_counts = array(); |
|
| 181 | + $comment_counts = array(); |
|
| 182 | 182 | $comments_closed = array(); |
| 183 | 183 | if( isset(SimpleBlogCommon::$data['post_info']) && is_array(SimpleBlogCommon::$data['post_info']) ){ |
| 184 | - foreach(SimpleBlogCommon::$data['post_info'] as $post_id => $info){ |
|
| 184 | + foreach( SimpleBlogCommon::$data['post_info'] as $post_id => $info ){ |
|
| 185 | 185 | if( isset($info['comments']) ){ |
| 186 | 186 | $comment_counts[$post_id] = $info['comments']; |
| 187 | 187 | } |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | $categories = $categories_hidden = $category_posts = $post_categories = array(); |
| 202 | 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 | 207 | if( isset($cat['visible']) && !$cat['visible'] ){ |
| 208 | 208 | $categories_hidden[$key] = 1; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 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 | } |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | $i = 0; |
| 228 | 228 | do{ |
| 229 | 229 | |
| 230 | - $posts = self::GetPostFile($i,$post_file); |
|
| 230 | + $posts = self::GetPostFile($i, $post_file); |
|
| 231 | 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 | 237 | if( isset($post['isDraft']) && $post['isDraft'] ){ |
| 238 | 238 | $drafts[$post_id] = 1; |
@@ -246,9 +246,9 @@ discard block |
||
| 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 ; |
|
| 251 | + $i += 20; |
|
| 252 | 252 | }while( $posts ); |
| 253 | 253 | |
| 254 | 254 | |
@@ -259,7 +259,7 @@ discard block |
||
| 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 | |
@@ -283,24 +283,24 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 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); |
|
| 291 | + $post_id = SimpleBlogCommon::AStrGet('str_index', $i); |
|
| 292 | 292 | if( !$post_id ){ |
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 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); |
|
| 303 | + $time = SimpleBlogCommon::AStrGet('post_times', $post_id); |
|
| 304 | 304 | if( $time > time() ){ |
| 305 | 305 | continue; |
| 306 | 306 | } |
@@ -321,9 +321,9 @@ discard block |
||
| 321 | 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, |
@@ -356,10 +356,10 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 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,14 +370,14 @@ discard block |
||
| 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 | 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 | 382 | if( !file_exists($post_file) ){ |
| 383 | 383 | return false; |
@@ -398,13 +398,13 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public static function GetPostContent($post_index){ |
| 400 | 400 | |
| 401 | - $file = self::PostFilePath($post_index); |
|
| 401 | + $file = self::PostFilePath($post_index); |
|
| 402 | 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); |
|
| 407 | + $posts = self::GetPostFile($post_index, $post_file); |
|
| 408 | 408 | if( $posts === false ){ |
| 409 | 409 | return false; |
| 410 | 410 | } |
@@ -434,15 +434,15 @@ discard block |
||
| 434 | 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); |
|
| 442 | + $post_file = self::PostFilePath($post_id); |
|
| 443 | 443 | if( !file_exists($post_file) ){ |
| 444 | 444 | |
| 445 | - $posts = self::GetPostFile($post_id,$post_file); |
|
| 445 | + $posts = self::GetPostFile($post_id, $post_file); |
|
| 446 | 446 | if( $posts === false ){ |
| 447 | 447 | message($langmessage['OOPS']); |
| 448 | 448 | return false; |
@@ -463,15 +463,15 @@ discard block |
||
| 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 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | //save data file or remove the file |
| 484 | 484 | if( $posts ){ |
| 485 | - if( !gpFiles::SaveArray($post_file,'posts',$posts) ){ |
|
| 485 | + if( !gpFiles::SaveArray($post_file, 'posts', $posts) ){ |
|
| 486 | 486 | message($langmessage['OOPS']); |
| 487 | 487 | return false; |
| 488 | 488 | } |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | * |
| 514 | 514 | * @param string $header |
| 515 | 515 | */ |
| 516 | - public static function BlogHead($header,$post_index,$post,$cacheable=false){ |
|
| 516 | + public static function BlogHead($header, $post_index, $post, $cacheable = false){ |
|
| 517 | 517 | |
| 518 | 518 | |
| 519 | 519 | //subtitle |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | //blog date |
| 528 | 528 | $blog_date = '<span class="simple_blog_date">'; |
| 529 | - $blog_date .= strftime(SimpleBlogCommon::$data['strftime_format'],$post['time']); |
|
| 529 | + $blog_date .= strftime(SimpleBlogCommon::$data['strftime_format'], $post['time']); |
|
| 530 | 530 | $blog_date .= '</span>'; |
| 531 | 531 | |
| 532 | 532 | |
| 533 | 533 | //blog comments |
| 534 | 534 | $blog_comments = '{empty_blog_piece}'; |
| 535 | - $count = SimpleBlogCommon::AStrGet('comment_counts',$post_index); |
|
| 535 | + $count = SimpleBlogCommon::AStrGet('comment_counts', $post_index); |
|
| 536 | 536 | if( $count > 0 ){ |
| 537 | 537 | $blog_comments = '<span class="simple_blog_comments">'; |
| 538 | 538 | if( $cacheable ){ |
@@ -551,16 +551,16 @@ discard block |
||
| 551 | 551 | $search = array('{header}', '{blog_info}', '{blog_date}', '{blog_comments}'); |
| 552 | 552 | $replace = array($header, $blog_info, $blog_date, $blog_comments); |
| 553 | 553 | |
| 554 | - $result = str_replace($search,$replace,$format); |
|
| 554 | + $result = str_replace($search, $replace, $format); |
|
| 555 | 555 | |
| 556 | 556 | |
| 557 | 557 | $reg = '#\{empty_blog_piece\}(\s*)\{separator\}#'; |
| 558 | - $result = preg_replace($reg,'\1',$result); |
|
| 558 | + $result = preg_replace($reg, '\1', $result); |
|
| 559 | 559 | |
| 560 | 560 | $reg = '#\{separator\}(\s*){empty_blog_piece\}#'; |
| 561 | - $result = preg_replace($reg,'\1',$result); |
|
| 561 | + $result = preg_replace($reg, '\1', $result); |
|
| 562 | 562 | |
| 563 | - echo str_replace('{separator}',SimpleBlogCommon::$data['subtitle_separator'],$result); |
|
| 563 | + echo str_replace('{separator}', SimpleBlogCommon::$data['subtitle_separator'], $result); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | global $addonPathData; |
| 581 | 581 | $categories_file = $addonPathData.'/categories.php'; |
| 582 | 582 | |
| 583 | - $categories = array( 'a' => array( 'ct'=>'Unsorted posts', 'visible'=>false,'posts'=>array() ) ); |
|
| 583 | + $categories = array('a' => array('ct'=>'Unsorted posts', 'visible'=>false, 'posts'=>array())); |
|
| 584 | 584 | if( file_exists($categories_file) ){ |
| 585 | 585 | include($categories_file); |
| 586 | 586 | } |
@@ -592,11 +592,11 @@ discard block |
||
| 592 | 592 | * Remove a blog entry from a category |
| 593 | 593 | * |
| 594 | 594 | */ |
| 595 | - public static function DeletePostFromCategories( $post_id ){ |
|
| 595 | + public static function DeletePostFromCategories($post_id){ |
|
| 596 | 596 | |
| 597 | - $categories = SimpleBlogCommon::AStrToArray( 'categories' ); |
|
| 598 | - foreach($categories as $catindex => $catname){ |
|
| 599 | - SimpleBlogCommon::AStrRmValue( 'category_posts_'.$catindex, $post_id ); |
|
| 597 | + $categories = SimpleBlogCommon::AStrToArray('categories'); |
|
| 598 | + foreach( $categories as $catindex => $catname ){ |
|
| 599 | + SimpleBlogCommon::AStrRmValue('category_posts_'.$catindex, $post_id); |
|
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | * Save the comment data for a blog post |
| 656 | 656 | * |
| 657 | 657 | */ |
| 658 | - public static function SaveCommentData($post_index,$data){ |
|
| 658 | + public static function SaveCommentData($post_index, $data){ |
|
| 659 | 659 | global $langmessage; |
| 660 | 660 | |
| 661 | 661 | |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | $commentDataFile = $dir.'/'.$post_index.'.txt'; |
| 669 | 669 | $dataTxt = serialize($data); |
| 670 | - if( !gpFiles::Save($commentDataFile,$dataTxt) ){ |
|
| 670 | + if( !gpFiles::Save($commentDataFile, $dataTxt) ){ |
|
| 671 | 671 | return false; |
| 672 | 672 | } |
| 673 | 673 | |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | unlink($commentDataFile); |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - SimpleBlogCommon::AStrSet('comment_counts',$post_index,count($data)); |
|
| 681 | + SimpleBlogCommon::AStrSet('comment_counts', $post_index, count($data)); |
|
| 682 | 682 | |
| 683 | 683 | SimpleBlogCommon::SaveIndex(); |
| 684 | 684 | |
@@ -698,16 +698,16 @@ discard block |
||
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - public static function PostLink($post,$label,$query='',$attr=''){ |
|
| 702 | - return '<a href="'.SimpleBlogCommon::PostUrl($post,$query,true).'" '.$attr.'>'.common::Ampersands($label).'</a>'; |
|
| 701 | + public static function PostLink($post, $label, $query = '', $attr = ''){ |
|
| 702 | + return '<a href="'.SimpleBlogCommon::PostUrl($post, $query, true).'" '.$attr.'>'.common::Ampersands($label).'</a>'; |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - public static function PostUrl( $post = false, $query='' ){ |
|
| 706 | - SimpleBlogCommon::UrlQuery( $post, $url, $query ); |
|
| 707 | - return common::GetUrl( $url, $query ); |
|
| 705 | + public static function PostUrl($post = false, $query = ''){ |
|
| 706 | + SimpleBlogCommon::UrlQuery($post, $url, $query); |
|
| 707 | + return common::GetUrl($url, $query); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - public static function UrlQuery( $post_id = false, &$url, &$query ){ |
|
| 710 | + public static function UrlQuery($post_id = false, &$url, &$query){ |
|
| 711 | 711 | |
| 712 | 712 | $url = SimpleBlogCommon::$root_url; |
| 713 | 713 | |
@@ -715,8 +715,8 @@ discard block |
||
| 715 | 715 | switch( SimpleBlogCommon::$data['urls'] ){ |
| 716 | 716 | |
| 717 | 717 | case 'Full': |
| 718 | - $title = SimpleBlogCommon::AStrGet('titles',$post_id); |
|
| 719 | - $title = str_replace(array('?',' '),array('','_'),$title); |
|
| 718 | + $title = SimpleBlogCommon::AStrGet('titles', $post_id); |
|
| 719 | + $title = str_replace(array('?', ' '), array('', '_'), $title); |
|
| 720 | 720 | $url .= '/'.$post_id.'_'.$title; |
| 721 | 721 | break; |
| 722 | 722 | |
@@ -725,13 +725,13 @@ discard block |
||
| 725 | 725 | break; |
| 726 | 726 | |
| 727 | 727 | case 'Title': |
| 728 | - $title = SimpleBlogCommon::AStrGet('titles',$post_id); |
|
| 729 | - $title = str_replace(array('?',' '),array('','_'),$title); |
|
| 728 | + $title = SimpleBlogCommon::AStrGet('titles', $post_id); |
|
| 729 | + $title = str_replace(array('?', ' '), array('', '_'), $title); |
|
| 730 | 730 | $url .= '/'.$title; |
| 731 | 731 | break; |
| 732 | 732 | |
| 733 | 733 | default: |
| 734 | - $query = trim($query.'&id='.$post_id,'&'); |
|
| 734 | + $query = trim($query.'&id='.$post_id, '&'); |
|
| 735 | 735 | break; |
| 736 | 736 | } |
| 737 | 737 | } |
@@ -740,14 +740,14 @@ discard block |
||
| 740 | 740 | /** |
| 741 | 741 | * @param string $label |
| 742 | 742 | */ |
| 743 | - public static function CategoryLink( $catindex, $cattitle, $label, $query = '', $attr = '' ){ |
|
| 743 | + public static function CategoryLink($catindex, $cattitle, $label, $query = '', $attr = ''){ |
|
| 744 | 744 | |
| 745 | 745 | $url = 'Special_Blog_Categories'; |
| 746 | 746 | switch( SimpleBlogCommon::$data['urls'] ){ |
| 747 | 747 | |
| 748 | 748 | case 'Title': |
| 749 | 749 | case 'Full': |
| 750 | - $cattitle = str_replace(array('?',' '),array('','_'),$cattitle); |
|
| 750 | + $cattitle = str_replace(array('?', ' '), array('', '_'), $cattitle); |
|
| 751 | 751 | $url .= '/'.$cattitle; |
| 752 | 752 | break; |
| 753 | 753 | |
@@ -756,11 +756,11 @@ discard block |
||
| 756 | 756 | break; |
| 757 | 757 | |
| 758 | 758 | default: |
| 759 | - $query = trim('cat='.$catindex.'&'.$query,'&'); |
|
| 759 | + $query = trim('cat='.$catindex.'&'.$query, '&'); |
|
| 760 | 760 | break; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - return '<a href="'.common::GetUrl( $url, $query ).'" '.$attr.'>'.common::Ampersands($label).'</a>'; |
|
| 763 | + return '<a href="'.common::GetUrl($url, $query).'" '.$attr.'>'.common::Ampersands($label).'</a>'; |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | |
@@ -780,9 +780,9 @@ discard block |
||
| 780 | 780 | */ |
| 781 | 781 | public static function AStrFromArray($array){ |
| 782 | 782 | $str = ''; |
| 783 | - foreach($array as $key => $value){ |
|
| 784 | - $key = str_replace(array('"','>'),'',$key); |
|
| 785 | - $value = str_replace(array('"','>'),'',$value); |
|
| 783 | + foreach( $array as $key => $value ){ |
|
| 784 | + $key = str_replace(array('"', '>'), '', $key); |
|
| 785 | + $value = str_replace(array('"', '>'), '', $value); |
|
| 786 | 786 | $str .= '"'.$key.'>'.$value; |
| 787 | 787 | } |
| 788 | 788 | return $str.'"'; |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @param mixed $new_value |
| 797 | 797 | * @deprecated 3.0.1 |
| 798 | 798 | */ |
| 799 | - public static function AStrValue( $data_string, $key, $new_value = false ){ |
|
| 799 | + public static function AStrValue($data_string, $key, $new_value = false){ |
|
| 800 | 800 | |
| 801 | 801 | if( $new_value === false ){ |
| 802 | 802 | return self::AStrGet($data_string, $key); |
@@ -811,18 +811,18 @@ discard block |
||
| 811 | 811 | * @param string $data_string |
| 812 | 812 | * @param int|string $key |
| 813 | 813 | */ |
| 814 | - public static function AStrGet( $data_string, $key){ |
|
| 814 | + public static function AStrGet($data_string, $key){ |
|
| 815 | 815 | |
| 816 | - $string =& SimpleBlogCommon::$data[$data_string]; |
|
| 816 | + $string = & SimpleBlogCommon::$data[$data_string]; |
|
| 817 | 817 | |
| 818 | 818 | //get position of current value |
| 819 | - $prev_key_str = '"'.$key.'>'; |
|
| 820 | - $offset = strpos($string,$prev_key_str); |
|
| 819 | + $prev_key_str = '"'.$key.'>'; |
|
| 820 | + $offset = strpos($string, $prev_key_str); |
|
| 821 | 821 | |
| 822 | 822 | if( $offset !== false ){ |
| 823 | - $offset += strlen($prev_key_str); |
|
| 824 | - $length = strpos($string,'"',$offset) - $offset; |
|
| 825 | - return substr($string,$offset,$length); |
|
| 823 | + $offset += strlen($prev_key_str); |
|
| 824 | + $length = strpos($string, '"', $offset)-$offset; |
|
| 825 | + return substr($string, $offset, $length); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | return false; |
@@ -835,25 +835,25 @@ discard block |
||
| 835 | 835 | * @param int|string $key |
| 836 | 836 | * @param string $new_value |
| 837 | 837 | */ |
| 838 | - public static function AStrSet( $data_string, $key, $new_value){ |
|
| 838 | + public static function AStrSet($data_string, $key, $new_value){ |
|
| 839 | 839 | |
| 840 | - $string =& SimpleBlogCommon::$data[$data_string]; |
|
| 840 | + $string = & SimpleBlogCommon::$data[$data_string]; |
|
| 841 | 841 | |
| 842 | 842 | //get position of current value |
| 843 | - $prev_key_str = '"'.$key.'>'; |
|
| 844 | - $offset = strpos($string,$prev_key_str); |
|
| 843 | + $prev_key_str = '"'.$key.'>'; |
|
| 844 | + $offset = strpos($string, $prev_key_str); |
|
| 845 | 845 | |
| 846 | 846 | //setting values |
| 847 | 847 | if( $offset === false ){ |
| 848 | 848 | if( empty($string) ){ |
| 849 | - $string = '"'; |
|
| 849 | + $string = '"'; |
|
| 850 | 850 | } |
| 851 | - $key = str_replace(array('"','>'),'',$key); |
|
| 851 | + $key = str_replace(array('"', '>'), '', $key); |
|
| 852 | 852 | $string .= $key.'>'.$new_value.'"'; |
| 853 | 853 | }else{ |
| 854 | 854 | $offset += strlen($prev_key_str); |
| 855 | - $length = strpos($string,'"',$offset) - $offset; |
|
| 856 | - $string = substr_replace($string,$new_value,$offset,$length); |
|
| 855 | + $length = strpos($string, '"', $offset)-$offset; |
|
| 856 | + $string = substr_replace($string, $new_value, $offset, $length); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | return true; |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | * |
| 867 | 867 | * @param string $data_string |
| 868 | 868 | */ |
| 869 | - public static function AStrKey( $data_string, $value, $url_search = false ){ |
|
| 869 | + public static function AStrKey($data_string, $value, $url_search = false){ |
|
| 870 | 870 | static $integers = '0123456789'; |
| 871 | 871 | |
| 872 | 872 | if( !isset(SimpleBlogCommon::$data[$data_string]) ){ |
@@ -876,21 +876,21 @@ discard block |
||
| 876 | 876 | $string = SimpleBlogCommon::$data[$data_string]; |
| 877 | 877 | |
| 878 | 878 | if( $url_search ){ |
| 879 | - $string = str_replace(array('?',' '),array('','_'),$string); |
|
| 879 | + $string = str_replace(array('?', ' '), array('', '_'), $string); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - $len = strlen($string); |
|
| 883 | - $post_pos = strpos($string,'>'.$value.'"'); |
|
| 882 | + $len = strlen($string); |
|
| 883 | + $post_pos = strpos($string, '>'.$value.'"'); |
|
| 884 | 884 | |
| 885 | 885 | if( $post_pos === false ){ |
| 886 | 886 | return false; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - $offset = $post_pos-$len; |
|
| 890 | - $post_key_pos = strrpos( $string, '"', $offset ); |
|
| 891 | - $post_key_len = strspn( $string, $integers, $post_key_pos+1 ); |
|
| 889 | + $offset = $post_pos-$len; |
|
| 890 | + $post_key_pos = strrpos($string, '"', $offset); |
|
| 891 | + $post_key_len = strspn($string, $integers, $post_key_pos+1); |
|
| 892 | 892 | |
| 893 | - return substr( $string, $post_key_pos+1, $post_key_len ); |
|
| 893 | + return substr($string, $post_key_pos+1, $post_key_len); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -899,9 +899,9 @@ discard block |
||
| 899 | 899 | * |
| 900 | 900 | * @param string $data_string |
| 901 | 901 | */ |
| 902 | - public static function AStrRm( $data_string, $key ){ |
|
| 902 | + public static function AStrRm($data_string, $key){ |
|
| 903 | 903 | |
| 904 | - $string =& SimpleBlogCommon::$data[$data_string]; |
|
| 904 | + $string = & SimpleBlogCommon::$data[$data_string]; |
|
| 905 | 905 | $string = preg_replace('#"'.$key.'>[^">]*\"#', '"', $string); |
| 906 | 906 | } |
| 907 | 907 | |
@@ -909,9 +909,9 @@ discard block |
||
| 909 | 909 | /** |
| 910 | 910 | * @param string $data_string |
| 911 | 911 | */ |
| 912 | - public static function AStrRmValue( $data_string, $value ){ |
|
| 912 | + public static function AStrRmValue($data_string, $value){ |
|
| 913 | 913 | |
| 914 | - $string =& SimpleBlogCommon::$data[$data_string]; |
|
| 914 | + $string = & SimpleBlogCommon::$data[$data_string]; |
|
| 915 | 915 | $string = preg_replace('#"[^">]*>'.$value.'\"#', '"', $string); |
| 916 | 916 | |
| 917 | 917 | } |
@@ -922,9 +922,9 @@ discard block |
||
| 922 | 922 | * |
| 923 | 923 | * @param string $data_string |
| 924 | 924 | */ |
| 925 | - public static function AStrToArray( $data_string ){ |
|
| 925 | + public static function AStrToArray($data_string){ |
|
| 926 | 926 | |
| 927 | - $string =& SimpleBlogCommon::$data[$data_string]; |
|
| 927 | + $string = & SimpleBlogCommon::$data[$data_string]; |
|
| 928 | 928 | |
| 929 | 929 | $count = preg_match_all('#(?:([^">]*)>)([^">]*)#', $string, $matches); |
| 930 | 930 | if( !$count ){ |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | $keys = $matches[1]; |
| 935 | 935 | $values = $matches[2]; |
| 936 | 936 | |
| 937 | - return array_combine($matches[1],$matches[2]); |
|
| 937 | + return array_combine($matches[1], $matches[2]); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | |