@@ -13,9 +13,9 @@ discard block |
||
| 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 | } |
@@ -61,39 +61,39 @@ discard block |
||
| 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 | 76 | if( isset($_REQUEST['offset']) && ctype_digit($_REQUEST['offset']) && $_REQUEST['offset'] > 0 ){ |
| 77 | - $offset = $_REQUEST['offset']; |
|
| 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 | 89 | if( $total_posts > $per_page ){ |
| 90 | - for($i = 0; $i < $total_pages; $i++){ |
|
| 91 | - $_offset = $i*$per_page; |
|
| 90 | + for( $i = 0; $i < $total_pages; $i++ ){ |
|
| 91 | + $_offset = $i * $per_page; |
|
| 92 | 92 | $class = ''; |
| 93 | 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,7 +107,7 @@ discard block |
||
| 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%">'; |
@@ -120,12 +120,12 @@ discard block |
||
| 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 | 127 | if( isset($post_times[$post_id]) ){ |
| 128 | - echo strftime(SimpleBlogCommon::$data['strftime_format'],$post_times[$post_id]); |
|
| 128 | + echo strftime(SimpleBlogCommon::$data['strftime_format'], $post_times[$post_id]); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | //comments |
@@ -140,30 +140,30 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | |
| 142 | 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'); |
|
| 143 | + $comments_closed = SimpleBlogCommon::AStrGet('comments_closed', $post_id); |
|
| 144 | + $open = gpOutput::SelectText('Open'); |
|
| 145 | + $close = gpOutput::SelectText('Close'); |
|
| 146 | 146 | |
| 147 | 147 | if( $comments_closed ){ |
| 148 | - echo common::Link('Admin_Blog',$open,'cmd=opencomments&id='.$post_id,'name="cnreq"'); |
|
| 148 | + echo common::Link('Admin_Blog', $open, 'cmd=opencomments&id='.$post_id, 'name="cnreq"'); |
|
| 149 | 149 | echo ' '; |
| 150 | 150 | echo gpOutput::SelectText('Closed'); |
| 151 | 151 | }else{ |
| 152 | 152 | echo $open; |
| 153 | 153 | echo ' '; |
| 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 | 156 | }else{ |
| 157 | - echo common::Link('Admin_BlogConfig','Disabled'); |
|
| 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 ' '; |
| 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 ' '; |
| 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 | } |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
| 188 | - $this->post_id = $id; |
|
| 189 | - $this->post = SimpleBlogCommon::GetPostContent($id); |
|
| 188 | + $this->post_id = $id; |
|
| 189 | + $this->post = SimpleBlogCommon::GetPostContent($id); |
|
| 190 | 190 | if( !$this->post ){ |
| 191 | 191 | message($langmessage['OOPS'].' (No Post)'); |
| 192 | 192 | return false; |
@@ -222,11 +222,11 @@ discard block |
||
| 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 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | */ |
| 237 | 237 | private function NewForm(){ |
| 238 | - $this->PostForm('New Blog Post',$_POST); |
|
| 238 | + $this->PostForm('New Blog Post', $_POST); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -247,16 +247,16 @@ discard block |
||
| 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() ); |
|
| 255 | + $array += array('title'=>'', 'content'=>'', 'subtitle'=>'', 'isDraft'=>false, 'categories'=>array(), 'time'=>time()); |
|
| 256 | 256 | if( $post_id ){ |
| 257 | - $array += array('isDraft'=>SimpleBlogCommon::AStrGet('drafts',$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 | 262 | if( $post_id ){ |
@@ -270,10 +270,10 @@ discard block |
||
| 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 | 275 | if( $post_id ){ |
| 276 | - echo SimpleBlogCommon::PostLink($post_id,'View Post','','target="_blank"'); |
|
| 276 | + echo SimpleBlogCommon::PostLink($post_id, 'View Post', '', 'target="_blank"'); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | |
@@ -321,7 +321,7 @@ discard block |
||
| 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 |
||
| 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>'; |
@@ -362,11 +362,11 @@ discard block |
||
| 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 | 371 | if( $i == $pub_month ){ |
| 372 | 372 | $selected = 'selected'; |
@@ -376,15 +376,15 @@ discard block |
||
| 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>'; |
@@ -406,8 +406,8 @@ discard block |
||
| 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 |
@@ -417,7 +417,7 @@ discard block |
||
| 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 | |
@@ -440,7 +440,7 @@ discard block |
||
| 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 | } |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 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 | |
@@ -467,12 +467,12 @@ discard block |
||
| 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,11 +480,11 @@ discard block |
||
| 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 | |
@@ -496,15 +496,15 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | //draft |
| 498 | 498 | if( $_POST['isDraft'] === 'on' ){ |
| 499 | - SimpleBlogCommon::AStrSet('drafts',$post_id,1); |
|
| 499 | + SimpleBlogCommon::AStrSet('drafts', $post_id, 1); |
|
| 500 | 500 | }else{ |
| 501 | - SimpleBlogCommon::AStrRm('drafts',$post_id); |
|
| 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 | 509 | if( !SimpleBlogCommon::SaveIndex() ){ |
| 510 | 510 | message($langmessage['OOPS'].' (Index not saved)'); |
@@ -525,13 +525,13 @@ discard block |
||
| 525 | 525 | * |
| 526 | 526 | */ |
| 527 | 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'] = mktime( $_POST['pub_hour'], $_POST['pub_min'], 0, $_POST['pub_month'], $_POST['pub_day'], $_POST['pub_year'] ); |
|
| 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'] = mktime($_POST['pub_hour'], $_POST['pub_min'], 0, $_POST['pub_month'], $_POST['pub_day'], $_POST['pub_year']); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -539,14 +539,14 @@ discard block |
||
| 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' ); |
|
| 549 | + $categories = SimpleBlogCommon::AStrToArray('categories'); |
|
| 550 | 550 | foreach( $categories as $catindex => $catname ){ |
| 551 | 551 | |
| 552 | 552 | $selected = ''; |
@@ -573,26 +573,26 @@ discard block |
||
| 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 | 589 | foreach( $categories as $catindex => $catname ){ |
| 590 | 590 | |
| 591 | - SimpleBlogCommon::AStrRmValue('category_posts_'.$catindex, $post_id ); |
|
| 591 | + SimpleBlogCommon::AStrRmValue('category_posts_'.$catindex, $post_id); |
|
| 592 | 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); |