Dotclear


Ignore:
Timestamp:
10/08/13 15:27:39 (12 years ago)
Author:
Dsls
Branch:
twig
Parents:
1524:913f5a36bbb0 (diff), 2312:d01c85eaa37d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Twig merge - lots of things to adapt yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/post.php

    r2256 r2313  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1515dcPage::check('usage,contentadmin'); 
    1616 
    17 $post_id = ''; 
    18 $cat_id = ''; 
    19 $post_dt = ''; 
    20 $post_format = $core->auth->getOption('post_format'); 
    21 $post_password = ''; 
    22 $post_url = ''; 
    23 $post_lang = $core->auth->getInfo('user_lang'); 
    24 $post_title = ''; 
    25 $post_excerpt = ''; 
    26 $post_excerpt_xhtml = ''; 
    27 $post_content = ''; 
    28 $post_content_xhtml = ''; 
    29 $post_notes = ''; 
    30 $post_status = $core->auth->getInfo('user_post_status'); 
    31 $post_selected = false; 
    32 $post_open_comment = $core->blog->settings->system->allow_comments; 
    33 $post_open_tb = $core->blog->settings->system->allow_trackbacks; 
     17class PostActions  
     18{ 
     19     public static function savePost($form) { 
     20          global $_ctx, $core; 
     21          if (!$form->can_edit_post) { 
     22               return; 
     23          } 
     24          try { 
     25               $form->check($_ctx); 
     26               $form->cat_id = (integer) $form->cat_id; 
     27      
     28               if (!empty($form->post_dt)) { 
     29                    try 
     30                    { 
     31                         $post_dt = strtotime($form->post_dt); 
     32                         if ($post_dt == false || $post_dt == -1) { 
     33                              $bad_dt = true; 
     34                              throw new Exception(__('Invalid publication date')); 
     35                         } 
     36                         $form->post_dt = date('Y-m-d H:i',$post_dt); 
     37                    } 
     38                    catch (Exception $e) 
     39                    { 
     40                         $core->error->add($e->getMessage()); 
     41                    } 
     42               } 
     43               $post_excerpt = $form->post_excerpt; 
     44               $post_content = $form->post_content; 
     45               $post_excerpt_xhtml = ''; 
     46               $post_content_xhtml = ''; 
     47               $core->blog->setPostContent( 
     48                    $form->id,$form->post_format,$form->post_lang, 
     49                    $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
     50               ); 
     51               $form->post_excerpt = $post_excerpt; 
     52               $form->post_content = $post_content; 
     53               $form->post_excerpt_xhtml = $post_excerpt_xhtml; 
     54               $form->post_content_xhtml = $post_content_xhtml; 
     55                
     56               $cur = $core->con->openCursor($core->prefix.'post'); 
     57      
     58               $cur->post_title = $form->post_title; 
     59               $cur->cat_id = $form->cat_id ? $form->cat_id : null; 
     60               $cur->post_dt = $form->post_dt ? date('Y-m-d H:i:00',strtotime($form->post_dt)) : ''; 
     61               $cur->post_format = $form->post_format; 
     62               $cur->post_password = $form->post_password; 
     63               $cur->post_lang = $form->post_lang; 
     64               $cur->post_title = $form->post_title; 
     65               $cur->post_excerpt = $form->post_excerpt; 
     66               $cur->post_excerpt_xhtml = $form->post_excerpt_xhtml; 
     67               $cur->post_content = $form->post_content; 
     68               $cur->post_content_xhtml = $form->post_content_xhtml; 
     69               $cur->post_notes = $form->post_notes; 
     70               $cur->post_status = $form->post_status; 
     71               $cur->post_selected = (integer) $form->post_selected; 
     72               $cur->post_open_comment = (integer) $form->post_open_comment; 
     73               $cur->post_open_tb = (integer) $form->post_open_tb; 
     74      
     75               if (!empty($form->post_url)) { 
     76                    $cur->post_url = $form->post_url; 
     77               } 
     78      
     79               # Update post 
     80               if ($form->id) 
     81               { 
     82                    # --BEHAVIOR-- adminBeforePostUpdate 
     83                    $core->callBehavior('adminBeforePostUpdate',$cur,$form->id); 
     84                     
     85                    $core->blog->updPost($form->id,$cur); 
     86                     
     87                    # --BEHAVIOR-- adminAfterPostUpdate 
     88                    $core->callBehavior('adminAfterPostUpdate',$cur,$form->id); 
     89                    http::redirect('post.php?id='.$form->id.'&upd=1'); 
     90               } 
     91               else 
     92               { 
     93                    $cur->user_id = $core->auth->userID(); 
     94                                        # --BEHAVIOR-- adminBeforePostCreate 
     95                    $core->callBehavior('adminBeforePostCreate',$cur); 
     96                     
     97                    $return_id = $core->blog->addPost($cur); 
     98                     
     99                    # --BEHAVIOR-- adminAfterPostCreate 
     100                    $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
     101                     
     102                    http::redirect('post.php?id='.$return_id.'&crea=1'); 
     103               } 
     104 
     105          } catch (Exception $e) { 
     106               $_ctx->addError($e->getMessage()); 
     107          } 
     108     } 
     109     public static function deletePost($form) { 
     110          global $core,$_ctx; 
     111          if ($form->can_delete) { 
     112               try { 
     113                    $post_id = $form->id; 
     114                    $core->callBehavior('adminBeforePostDelete',$post_id); 
     115                    $core->blog->delPost($post_id); 
     116                    http::redirect('posts.php'); 
     117                    exit; 
     118               } catch (Exception $e) { 
     119                    $_ctx->addError($e->getMessage()); 
     120               } 
     121          } 
     122     } 
     123} 
    34124 
    35125$page_title = __('New entry'); 
    36  
     126$post_id=''; 
    37127$can_view_page = true; 
    38128$can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id); 
     
    47137# If user can't publish 
    48138if (!$can_publish) { 
    49      $post_status = -2; 
     139     $form->post_status = -2; 
    50140} 
    51141 
    52142# Getting categories 
    53 $categories_combo = dcAdminCombos::getCategoriesCombo( 
    54      $core->blog->getCategories(array('post_type'=>'post')) 
    55 ); 
    56  
    57 $status_combo = dcAdminCombos::getPostStatusesCombo(); 
    58  
    59 $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     143$categories_combo = array('&nbsp;' => ''); 
     144try { 
     145     $categories = $core->blog->getCategories(array('post_type'=>'post')); 
     146     while ($categories->fetch()) { 
     147          $categories_combo[$categories->cat_id] =  
     148               str_repeat('&nbsp;&nbsp;',$categories->level-1). 
     149               ($categories->level-1 == 0 ? '' : '&bull; '). 
     150               html::escapeHTML($categories->cat_title); 
     151     } 
     152} catch (Exception $e) { } 
     153 
     154# Status combo 
     155foreach ($core->blog->getAllPostStatus() as $k => $v) { 
     156     $status_combo[$k] = $v; 
     157} 
    60158 
    61159# Formaters combo 
    62 $formaters_combo = dcAdminCombos::getFormatersCombo(); 
     160foreach ($core->getFormaters() as $v) { 
     161     $formaters_combo[$v] = $v; 
     162} 
    63163 
    64164# Languages combo 
    65165$rs = $core->blog->getLangs(array('order'=>'asc')); 
    66 $lang_combo = dcAdminCombos::getLangsCombo($rs,true); 
    67  
    68 # Validation flag 
    69 $bad_dt = false; 
    70  
    71 # Trackbacks 
    72 $TB = new dcTrackback($core); 
    73 $tb_urls = $tb_excerpt = ''; 
    74  
     166$all_langs = l10n::getISOcodes(0,1); 
     167$lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(0,1)); 
     168while ($rs->fetch()) { 
     169     if (isset($all_langs[$rs->post_lang])) { 
     170          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
     171          unset($lang_combo[__('Available')][$rs->post_lang]); 
     172     } else { 
     173          $lang_combo[__('Most used')][$rs->post_lang] = $all_langs[$rs->post_lang]; 
     174     } 
     175} 
     176unset($all_langs); 
     177unset($rs); 
     178 
     179$form = new dcForm($core,'post','post.php'); 
     180$form 
     181     ->addField( 
     182          new dcFieldText('post_title','', array( 
     183               'maxlength'         => 255, 
     184               'required'     => true, 
     185               'label'        => __('Title:')))) 
     186     ->addField( 
     187          new dcFieldTextArea('post_excerpt','', array( 
     188               'cols'         => 50, 
     189               'rows'         => 5, 
     190               'label'        => __("Excerpt:").'<span class="form-note">'. 
     191               __('Add an introduction to the post.').'</span>'))) 
     192     ->addField( 
     193          new dcFieldTextArea('post_content','', array( 
     194               'required'     => true, 
     195               'label'        => __("Content:")))) 
     196     ->addField( 
     197          new dcFieldTextArea('post_notes','', array( 
     198               'label'        => __("Notes")))) 
     199     ->addField( 
     200          new dcFieldSubmit('save',__('Save'),array( 
     201               'action' => array('PostActions','savePost')))) 
     202     ->addField( 
     203          new dcFieldSubmit('delete',__('Delete'),array( 
     204               'action' => array('PostActions','deletePost')))) 
     205     ->addField( 
     206          new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( 
     207               'disabled' => !$can_publish, 
     208               'label' => __('Entry status')))) 
     209     ->addField( 
     210          new dcFieldCombo('cat_id','',$categories_combo,array( 
     211               "label" => __('Category')))) 
     212     ->addField( 
     213          new dcFieldCombo('new_cat_parent','',$categories_combo,array( 
     214               "label" => __('Parent:')))) 
     215     ->addField( 
     216          new dcFieldText('new_cat_title','', array( 
     217               'maxlength'         => 255, 
     218               'label'        => __('Title')))) 
     219           
     220     ->addField( 
     221          new dcFieldText('post_dt','',array( 
     222               "label" => __('Publication date and hour')))) 
     223     ->addField( 
     224          new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( 
     225               "label" => __('Text formating')))) 
     226     ->addField( 
     227          new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( 
     228               "label" => __('Accept comments')))) 
     229     ->addField( 
     230          new dcFieldCheckbox ('post_open_tb',$core->blog->settings->system->allow_trackbacks,array( 
     231               "label" => __('Accept trackbacks')))) 
     232     ->addField( 
     233          new dcFieldCheckbox ('post_selected',array(1=>false),array( 
     234               "label" => __('Selected entry')))) 
     235     ->addField( 
     236          new dcFieldCombo ('post_lang',$core->auth->getInfo('user_lang'),$lang_combo, array( 
     237               "label" => __('Entry lang:')))) 
     238     ->addField( 
     239          new dcFieldText('post_password','',array( 
     240               "maxlength" => 32, 
     241               "label" => __('Entry password:')))) 
     242     ->addField( 
     243          new dcFieldText('post_url','',array( 
     244               "maxlength" => 255, 
     245               "label" => __('Basename:')))) 
     246     ->addField( 
     247          new dcFieldHidden ('id','')) 
     248; 
    75249# Get entry informations 
    76250if (!empty($_REQUEST['id'])) 
    77251{ 
    78      $page_title = __('Edit entry'); 
    79       
    80252     $params['post_id'] = $_REQUEST['id']; 
    81253      
     
    89261     else 
    90262     { 
    91           $post_id = $post->post_id; 
    92           $cat_id = $post->cat_id; 
    93           $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
    94           $post_format = $post->post_format; 
    95           $post_password = $post->post_password; 
    96           $post_url = $post->post_url; 
    97           $post_lang = $post->post_lang; 
    98           $post_title = $post->post_title; 
    99           $post_excerpt = $post->post_excerpt; 
    100           $post_excerpt_xhtml = $post->post_excerpt_xhtml; 
    101           $post_content = $post->post_content; 
    102           $post_content_xhtml = $post->post_content_xhtml; 
    103           $post_notes = $post->post_notes; 
    104           $post_status = $post->post_status; 
    105           $post_selected = (boolean) $post->post_selected; 
    106           $post_open_comment = (boolean) $post->post_open_comment; 
    107           $post_open_tb = (boolean) $post->post_open_tb; 
    108            
    109           $can_edit_post = $post->isEditable(); 
    110           $can_delete= $post->isDeletable(); 
    111            
     263          $form->id = $post_id = $post->post_id; 
     264          $form->cat_id = $post->cat_id; 
     265          $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
     266          $form->post_format = $post->post_format; 
     267          $form->post_password = $post->post_password; 
     268          $form->post_url = $post->post_url; 
     269          $form->post_lang = $post->post_lang; 
     270          $form->post_title = $post->post_title; 
     271          $form->post_excerpt = $post->post_excerpt; 
     272          $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; 
     273          $form->post_content = $post->post_content; 
     274          $form->post_content_xhtml = $post->post_content_xhtml; 
     275          $form->post_notes = $post->post_notes; 
     276          $form->post_status = $post->post_status; 
     277          $form->post_selected = (boolean) $post->post_selected; 
     278          $form->post_open_comment = (boolean) $post->post_open_comment; 
     279          $form->post_open_tb = (boolean) $post->post_open_tb; 
     280          $form->can_edit_post = $post->isEditable(); 
     281          $form->can_delete= $post->isDeletable(); 
    112282          $next_rs = $core->blog->getNextPost($post,1); 
    113283          $prev_rs = $core->blog->getNextPost($post,-1); 
    114284           
    115285          if ($next_rs !== null) { 
    116                $next_link = sprintf($post_link,$next_rs->post_id, 
    117                     html::escapeHTML($next_rs->post_title),__('Next entry').'&nbsp;&#187;'); 
    118                $next_headlink = sprintf($post_headlink,'next', 
    119                     html::escapeHTML($next_rs->post_title),$next_rs->post_id); 
    120           } 
     286               $_ctx->next_post = array('id' => $next_rs->post_id,'title' => $next_rs->post_title); 
     287          } 
     288          if ($prev_rs !== null) { 
     289               $_ctx->prev_post = array('id' => $prev_rs->post_id,'title' => $prev_rs->post_title); 
     290          } 
     291          $page_title = __('Edit entry'); 
     292 
     293     } 
     294} 
     295if ($post_id) { 
     296     $_ctx->post_id = $post->post_id; 
     297 
     298     $_ctx->preview_url = 
     299          $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 
     300          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
     301          '/'.$post->post_url); 
    121302           
    122           if ($prev_rs !== null) { 
    123                $prev_link = sprintf($post_link,$prev_rs->post_id, 
    124                     html::escapeHTML($prev_rs->post_title),'&#171;&nbsp;'.__('Previous entry')); 
    125                $prev_headlink = sprintf($post_headlink,'previous', 
    126                     html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); 
    127           } 
    128            
    129           try { 
    130                $core->media = new dcMedia($core); 
    131           } catch (Exception $e) { 
    132                $core->error->add($e->getMessage()); 
    133           } 
    134  
    135           # Sanitize trackbacks excerpt 
    136           $tb_excerpt = empty($_POST['tb_excerpt']) ?  
    137                $post_excerpt_xhtml.' '.$post_content_xhtml : 
    138                $_POST['tb_excerpt']; 
    139           $tb_excerpt = html::decodeEntities(html::clean($tb_excerpt)); 
    140           $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt), 255); 
    141           $tb_excerpt = preg_replace('/\s+/ms', ' ', $tb_excerpt); 
    142      } 
    143 } 
    144 if (isset($_REQUEST['section']) && $_REQUEST['section']=='trackbacks') { 
    145      $anchor = 'trackbacks'; 
    146 } else { 
    147      $anchor = 'comments'; 
    148 }     
    149  
    150 $comments_actions_page = new dcCommentsActionsPage($core,'post.php',array('id' => $post_id, '_ANCHOR'=>$anchor,'section' => $anchor)); 
    151  
    152 if ($comments_actions_page->process()) { 
    153      return; 
    154 } 
    155  
    156 # Ping blogs 
    157 if (!empty($_POST['ping'])) 
    158 { 
    159      if (!empty($_POST['tb_urls']) && $post_id && $post_status == 1 && $can_edit_post) 
    160      { 
    161           $tb_urls = $_POST['tb_urls']; 
    162           $tb_urls = str_replace("\r", '', $tb_urls); 
    163           $tb_post_title = html::escapeHTML(trim(html::clean($post_title))); 
    164            
    165           foreach (explode("\n", $tb_urls) as $tb_url) 
    166           { 
    167                try { 
    168                     $TB->ping($tb_url, $post_id, $tb_post_title, $tb_excerpt, $post_url); 
    169                } catch (Exception $e) { 
    170                     $core->error->add($e->getMessage()); 
    171                } 
    172           } 
    173            
    174           if (!$core->error->flag()) { 
    175                dcPage::addSuccessNotice(__('All pings sent.')); 
    176                http::redirect('post.php?id='.$post_id.'&tb=1'); 
    177           } 
    178      } 
    179 } 
    180  
    181 # Format excerpt and content 
    182 elseif (!empty($_POST) && $can_edit_post) 
    183 { 
    184      $post_format = $_POST['post_format']; 
    185      $post_excerpt = $_POST['post_excerpt']; 
    186      $post_content = $_POST['post_content']; 
    187       
    188      $post_title = $_POST['post_title']; 
    189       
    190      $cat_id = (integer) $_POST['cat_id']; 
    191       
    192      if (isset($_POST['post_status'])) { 
    193           $post_status = (integer) $_POST['post_status']; 
    194      } 
    195       
    196      if (empty($_POST['post_dt'])) { 
    197           $post_dt = ''; 
    198      } else { 
    199           try 
    200           { 
    201                $post_dt = strtotime($_POST['post_dt']); 
    202                if ($post_dt == false || $post_dt == -1) { 
    203                     $bad_dt = true; 
    204                     throw new Exception(__('Invalid publication date')); 
    205                } 
    206                $post_dt = date('Y-m-d H:i',$post_dt); 
    207           } 
    208           catch (Exception $e) 
    209           { 
    210                $core->error->add($e->getMessage()); 
    211           } 
    212      } 
    213       
    214      $post_open_comment = !empty($_POST['post_open_comment']); 
    215      $post_open_tb = !empty($_POST['post_open_tb']); 
    216      $post_selected = !empty($_POST['post_selected']); 
    217      $post_lang = $_POST['post_lang']; 
    218      $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 
    219       
    220      $post_notes = $_POST['post_notes']; 
    221       
    222      if (isset($_POST['post_url'])) { 
    223           $post_url = $_POST['post_url']; 
    224      } 
    225       
    226      $core->blog->setPostContent( 
    227           $post_id,$post_format,$post_lang, 
    228           $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 
    229      ); 
    230 } 
    231  
    232 # Delete post 
    233 if (!empty($_POST['delete']) && $can_delete) 
    234 { 
    235      try { 
    236           # --BEHAVIOR-- adminBeforePostDelete 
    237           $core->callBehavior('adminBeforePostDelete',$post_id); 
    238           $core->blog->delPost($post_id); 
    239           http::redirect('posts.php'); 
    240      } catch (Exception $e) { 
    241           $core->error->add($e->getMessage()); 
    242      } 
    243 } 
    244  
    245 # Create or update post 
    246 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 
    247 { 
    248      # Create category 
    249      if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { 
    250       
    251           $cur_cat = $core->con->openCursor($core->prefix.'category'); 
    252           $cur_cat->cat_title = $_POST['new_cat_title']; 
    253           $cur_cat->cat_url = ''; 
    254            
    255           $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : ''; 
    256            
    257           # --BEHAVIOR-- adminBeforeCategoryCreate 
    258           $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); 
    259            
    260           $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat); 
    261            
    262           # --BEHAVIOR-- adminAfterCategoryCreate 
    263           $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id); 
    264      } 
    265       
    266      $cur = $core->con->openCursor($core->prefix.'post'); 
    267       
    268      $cur->post_title = $post_title; 
    269      $cur->cat_id = ($cat_id ? $cat_id : null); 
    270      $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 
    271      $cur->post_format = $post_format; 
    272      $cur->post_password = $post_password; 
    273      $cur->post_lang = $post_lang; 
    274      $cur->post_title = $post_title; 
    275      $cur->post_excerpt = $post_excerpt; 
    276      $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 
    277      $cur->post_content = $post_content; 
    278      $cur->post_content_xhtml = $post_content_xhtml; 
    279      $cur->post_notes = $post_notes; 
    280      $cur->post_status = $post_status; 
    281      $cur->post_selected = (integer) $post_selected; 
    282      $cur->post_open_comment = (integer) $post_open_comment; 
    283      $cur->post_open_tb = (integer) $post_open_tb; 
    284       
    285      if (isset($_POST['post_url'])) { 
    286           $cur->post_url = $post_url; 
    287      } 
    288       
    289      # Update post 
    290      if ($post_id) 
    291      { 
    292           try 
    293           { 
    294                # --BEHAVIOR-- adminBeforePostUpdate 
    295                $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); 
    296                 
    297                $core->blog->updPost($post_id,$cur); 
    298                 
    299                # --BEHAVIOR-- adminAfterPostUpdate 
    300                $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); 
    301                dcPage::addSuccessNotice (sprintf('The post "%s" has been successfully updated',html::escapeHTML($cur->post_title))); 
    302                http::redirect('post.php?id='.$post_id); 
    303           } 
    304           catch (Exception $e) 
    305           { 
    306                $core->error->add($e->getMessage()); 
    307           } 
    308      } 
    309      else 
    310      { 
    311           $cur->user_id = $core->auth->userID(); 
    312            
    313           try 
    314           { 
    315                # --BEHAVIOR-- adminBeforePostCreate 
    316                $core->callBehavior('adminBeforePostCreate',$cur); 
    317                 
    318                $return_id = $core->blog->addPost($cur); 
    319                 
    320                # --BEHAVIOR-- adminAfterPostCreate 
    321                $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 
    322  
    323                dcPage::addSuccessNotice(__('Entry has been successfully created.')); 
    324                http::redirect('post.php?id='.$return_id); 
    325           } 
    326           catch (Exception $e) 
    327           { 
    328                $core->error->add($e->getMessage()); 
    329           } 
    330      } 
    331 } 
    332  
    333 # Getting categories 
    334 $categories_combo = dcAdminCombos::getCategoriesCombo( 
    335      $core->blog->getCategories(array('post_type'=>'post')) 
    336 ); 
     303      
     304     $form_comment = new dcForm($core,'add-comment','comment.php'); 
     305     $form_comment 
     306          ->addField( 
     307               new dcFieldText('comment_author','', array( 
     308                    'maxlength'         => 255, 
     309                    'required'     => true, 
     310                    'label'        => __('Name:')))) 
     311          ->addField( 
     312               new dcFieldText('comment_email','', array( 
     313                    'maxlength'         => 255, 
     314                    'required'     => true, 
     315                    'label'        => __('Email:')))) 
     316          ->addField( 
     317               new dcFieldText('comment_site','', array( 
     318                    'maxlength'         => 255, 
     319                    'label'        => __('Web site:')))) 
     320          ->addField( 
     321               new dcFieldTextArea('comment_content','', array( 
     322                    'required'     => true, 
     323                    'label'        => __('Comment:')))) 
     324          ->addField( 
     325               new dcFieldHidden('post_id',$post_id)) 
     326          ->addField( 
     327               new dcFieldSubmit('add',__('Save'),array( 
     328                    'action' => 'addComment'))) 
     329          ; 
     330 
     331      
     332} 
     333 
     334$form->setup(); 
     335 
     336$sidebar_blocks = new ArrayObject(array( 
     337     'status-box' => array( 
     338          'title' => __('Status'), 
     339          'items' => array('post_status','post_dt','post_lang','post_format')), 
     340     'metas-box' => array( 
     341          'title' => __('Ordering'), 
     342          'items' => array('post_selected','cat_id')), 
     343     'options-box' => array( 
     344          'title' => __('Options'), 
     345          'items' => array('post_open_comment','post_open_tb','post_password','post_url')) 
     346)); 
     347 
     348$main_blocks = new ArrayObject(array( 
     349     "post_title","post_excerpt","post_content","post_notes" 
     350)); 
     351 
     352 
     353$_ctx->sidebar_blocks = $sidebar_blocks; 
     354$_ctx->main_blocks = $main_blocks; 
     355 
    337356/* DISPLAY 
    338357-------------------------------------------------------- */ 
     
    344363     $default_tab = 'comments'; 
    345364} 
    346 elseif (!empty($_GET['tb'])) { 
    347      $default_tab = 'trackbacks'; 
    348 } 
    349  
    350 if ($post_id) { 
    351      switch ($post_status) { 
    352           case 1: 
    353                $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png'); 
    354                break; 
    355           case 0: 
    356                $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png'); 
    357                break; 
    358           case -1: 
    359                $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png'); 
    360                break; 
    361           case -2: 
    362                $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png'); 
    363                break; 
    364           default: 
    365                $img_status = ''; 
    366      } 
    367      $edit_entry_str = __('&ldquo;%s&rdquo;'); 
    368      $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status; 
    369 } else { 
    370      $img_status = ''; 
    371 } 
    372  
    373  
    374 dcPage::open($page_title.' - '.__('Entries'), 
    375      dcPage::jsDatePicker(). 
    376      dcPage::jsToolBar(). 
    377      dcPage::jsModal(). 
    378      dcPage::jsMetaEditor(). 
    379      dcPage::jsLoad('js/_post.js'). 
    380      dcPage::jsConfirmClose('entry-form','comment-form'). 
    381      # --BEHAVIOR-- adminPostHeaders 
    382      $core->callBehavior('adminPostHeaders'). 
    383      dcPage::jsPageTabs($default_tab). 
    384      $next_headlink."\n".$prev_headlink, 
    385      dcPage::breadcrumb( 
     365$page_title_edit = __('Edit entry'); 
     366$_ctx 
     367     ->setBreadCrumb( 
    386368          array( 
    387369               html::escapeHTML($core->blog->name) => '', 
    388370               __('Entries') => 'posts.php', 
    389371               ($post_id ? $page_title_edit : $page_title) => '' 
    390           )) 
    391 ); 
     372     )) 
     373     ->default_tab = $default_tab; 
     374$_ctx->post_status = $form->post_status; 
     375$_ctx->post_title = $form->post_title; 
     376if ($form->post_status == 1) { 
     377     $_ctx->post_url = $post->getURL(); 
     378} 
    392379 
    393380if (!empty($_GET['upd'])) { 
    394      dcPage::success(__('Entry has been successfully updated.')); 
     381     $_ctx->setAlert(__('Entry has been successfully updated.')); 
    395382} 
    396383elseif (!empty($_GET['crea'])) { 
    397      dcPage::success(__('Entry has been successfully created.')); 
     384     $_ctx->setAlert(__('Entry has been successfully created.')); 
    398385} 
    399386elseif (!empty($_GET['attached'])) { 
    400      dcPage::success(__('File has been successfully attached.')); 
     387     $_ctx->setAlert(__('File has been successfully attached.')); 
    401388} 
    402389elseif (!empty($_GET['rmattach'])) { 
    403      dcPage::success(__('Attachment has been successfully removed.')); 
    404 } 
    405  
     390     $_ctx->setAlert(__('Attachment has been successfully removed.')); 
     391} 
    406392if (!empty($_GET['creaco'])) { 
    407      dcPage::success(__('Comment has been successfully created.')); 
    408 } 
    409 if (!empty($_GET['tbsent'])) { 
    410      dcPage::success(__('All pings sent.')); 
    411 } 
    412  
    413 # XHTML conversion 
    414 if (!empty($_GET['xconv'])) 
    415 { 
    416      $post_excerpt = $post_excerpt_xhtml; 
    417      $post_content = $post_content_xhtml; 
    418      $post_format = 'xhtml'; 
    419       
    420      dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 
    421 } 
    422  
    423 if ($post_id && $post->post_status == 1) { 
    424      echo '<p><a class="onblog_link outgoing" href="'.$post->getURL().'" title="'.$post_title.'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; 
    425 } 
    426 if ($post_id) 
    427 { 
    428      echo '<p class="nav_prevnext">'; 
    429      if ($prev_link) { echo $prev_link; } 
    430      if ($next_link && $prev_link) { echo ' | '; } 
    431      if ($next_link) { echo $next_link; } 
    432       
    433      # --BEHAVIOR-- adminPostNavLinks 
    434      $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null); 
    435       
    436      echo '</p>'; 
    437 } 
    438  
    439 # Exit if we cannot view page 
    440 if (!$can_view_page) { 
    441      dcPage::helpBlock('core_post'); 
    442      dcPage::close(); 
    443      exit; 
    444 } 
    445 /* Post form if we can edit post 
    446 -------------------------------------------------------- */ 
    447 if ($can_edit_post) 
    448 { 
    449      $sidebar_items = new ArrayObject(array( 
    450           'status-box' => array( 
    451                'title' => __('Status'), 
    452                'items' => array( 
    453                     'post_status' =>  
    454                          '<p class="entry-status"><label for="post_status" class="ib">'.__('Entry status').' '.$img_status.'</label>'. 
    455                          form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish). 
    456                          '</p>', 
    457                     'post_dt' =>  
    458                          '<p><label for="post_dt" class="ib">'.__('Publication date and hour').'</label>'. 
    459                          form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 
    460                          '</p>', 
    461                     'post_lang' => 
    462                          '<p><label for="post_lang" class="ib">'.__('Entry language').'</label>'. 
    463                          form::combo('post_lang',$lang_combo,$post_lang). 
    464                          '</p>', 
    465                     'post_format' => 
    466                          '<div>'. 
    467                          '<h5 id="label_format"><label for="post_format" class="ib">'.__('Text formatting').'</label></h5>'. 
    468                          '<p>'.form::combo('post_format',$formaters_combo,$post_format,'maximal'). 
    469                          '</p>'. 
    470                          '<p class="format_control control_no_xhtml">'. 
    471                          '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').'" href="post.php?id='.$post_id.'&amp;xconv=1">'. 
    472                          __('Convert to XHTML').'</a></p></div>')), 
    473           'metas-box' => array( 
    474                'title' => __('Filing'), 
    475                'items' => array( 
    476                     'post_selected' =>  
    477                          '<p><label for="post_selected" class="classic">'. 
    478                          form::checkbox('post_selected',1,$post_selected).' '. 
    479                          __('Selected entry').'</label></p>', 
    480                     'cat_id' => 
    481                          '<div>'. 
    482                          '<h5 id="label_cat_id">'.__('Category').'</h5>'. 
    483                          '<p><label for="cat_id">'.__('Category:').'</label>'. 
    484                          form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 
    485                          '</p>'. 
    486                          ($core->auth->check('categories', $core->blog->id) ? 
    487                               '<div>'. 
    488                               '<h5 id="create_cat">'.__('Add a new category').'</h5>'. 
    489                               '<p><label for="new_cat_title">'.__('Title:').' '. 
    490                               form::field('new_cat_title',30,255,'','maximal').'</label></p>'. 
    491                               '<p><label for="new_cat_parent">'.__('Parent:').' '. 
    492                               form::combo('new_cat_parent',$categories_combo,'','maximal'). 
    493                               '</label></p>'. 
    494                               '</div>' 
    495                          : ''). 
    496                          '</div>')), 
    497           'options-box' => array( 
    498                'title' => __('Options'), 
    499                'items' => array( 
    500                     'post_open_comment_tb' => 
    501                          '<div>'. 
    502                          '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'. 
    503                          '<p><label for="post_open_comment" class="classic">'. 
    504                          form::checkbox('post_open_comment',1,$post_open_comment).' '. 
    505                          __('Accept comments').'</label></p>'. 
    506                          ($core->blog->settings->system->allow_comments ?  
    507                               (isContributionAllowed($post_id,strtotime($post_dt),true) ?  
    508                                    '' : 
    509                                    '<p class="form-note warn">'. 
    510                                    __('Warning: Comments are not more accepted for this entry.').'</p>') :  
    511                               '<p class="form-note warn">'. 
    512                               __('Comments are not accepted on this blog so far.').'</p>'). 
    513                          '<p><label for="post_open_tb" class="classic">'. 
    514                          form::checkbox('post_open_tb',1,$post_open_tb).' '. 
    515                          __('Accept trackbacks').'</label></p>'. 
    516                          ($core->blog->settings->system->allow_trackbacks ?  
    517                               (isContributionAllowed($post_id,strtotime($post_dt),false) ?  
    518                                    '' : 
    519                                    '<p class="form-note warn">'. 
    520                                    __('Warning: Trackbacks are not more accepted for this entry.').'</p>') :  
    521                               '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>'). 
    522                          '</div>', 
    523                     'post_password' => 
    524                          '<p><label for="post_password" class="ib">'.__('Password').'</label>'. 
    525                          form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 
    526                          '</p>', 
    527                     'post_url' => 
    528                          '<div class="lockable">'. 
    529                          '<p><label for="post_url" class="ib">'.__('Edit basename').'</label>'. 
    530                          form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 
    531                          '</p>'. 
    532                          '<p class="form-note warn">'. 
    533                          __('Warning: If you set the URL manually, it may conflict with another entry.'). 
    534                          '</p></div>' 
    535      )))); 
    536  
    537      $main_items = new ArrayObject(array( 
    538           "post_title" => 
    539                '<p class="col">'. 
    540                '<label class="required no-margin"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 
    541                form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). 
    542                '</p>', 
    543            
    544           "post_excerpt" => 
    545                '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').' <span class="form-note">'. 
    546                __('Introduction to the post.').'</span></label> '. 
    547                form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 
    548                '</p>', 
    549            
    550           "post_content" => 
    551                '<p class="area" id="content-area"><label class="required" '. 
    552                'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 
    553                form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). 
    554                '</p>', 
    555            
    556           "post_notes" => 
    557                '<p class="area" id="notes-area"><label for="post_notes">'.__('Personal notes:').' <span class="form-note">'. 
    558                __('Unpublished notes.').'</span></label>'. 
    559                form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 
    560                '</p>' 
    561           ) 
    562      ); 
    563       
    564      # --BEHAVIOR-- adminPostFormItems 
    565      $core->callBehavior('adminPostFormItems',$main_items,$sidebar_items, isset($post) ? $post : null); 
    566  
    567      echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')).'" id="edit-entry">'; 
    568      echo '<form action="post.php" method="post" id="entry-form">'; 
    569      echo '<div id="entry-wrapper">'; 
    570      echo '<div id="entry-content"><div class="constrained">'; 
    571  
    572      echo '<h3 class="out-of-screen-if-js">'.__('Edit post').'</h3>'; 
    573       
    574      foreach ($main_items as $id => $item) { 
    575           echo $item; 
    576      } 
    577  
    578      # --BEHAVIOR-- adminPostForm (may be deprecated) 
    579      $core->callBehavior('adminPostForm',isset($post) ? $post : null); 
    580       
    581      echo 
    582      '<p class="border-top">'. 
    583      ($post_id ? form::hidden('id',$post_id) : ''). 
    584      '<input type="submit" value="'.__('Save').' (s)" '. 
    585      'accesskey="s" name="save" /> '; 
    586      if ($post_id) { 
    587           $preview_url = 
    588           $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 
    589           http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
    590           '/'.$post->post_url); 
    591           echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a> '; 
    592      } else { 
    593           echo 
    594           '<a id="post-cancel" href="index.php" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; 
    595      } 
    596  
    597      echo 
    598      ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 
    599      $core->formNonce(). 
    600      '</p>'; 
    601       
    602      echo '</div></div>';          // End #entry-content 
    603      echo '</div>';      // End #entry-wrapper 
    604  
    605      echo '<div id="entry-sidebar">'; 
    606       
    607      foreach ($sidebar_items as $id => $c) { 
    608           echo '<div id="'.$id.'" class="sb-box">'. 
    609                '<h4>'.$c['title'].'</h4>'; 
    610           foreach ($c['items'] as $e_name=>$e_content) { 
    611                echo $e_content; 
    612           } 
    613           echo '</div>'; 
    614      } 
    615       
    616       
    617      # --BEHAVIOR-- adminPostFormSidebar (may be deprecated) 
    618      $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 
    619      echo '</div>';      // End #entry-sidebar 
    620  
    621      echo '</form>'; 
    622       
    623      # --BEHAVIOR-- adminPostForm 
    624      $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null); 
    625       
    626      echo '</div>'; 
    627 } 
    628  
    629 if ($post_id) 
    630 { 
    631      /* Comments 
    632      -------------------------------------------------------- */ 
    633  
    634      $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 
    635       
    636      $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 
    637            
    638      echo 
    639      '<div id="comments" class="clear multi-part" title="'.__('Comments').'">'; 
    640      $combo_action = $comments_actions_page->getCombo();     
    641      $has_action = !empty($combo_action) && !$comments->isEmpty(); 
    642      echo  
    643      '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>'; 
    644       
    645      if ($has_action) { 
    646           echo '<form action="post.php" id="form-comments" method="post">'; 
    647      } 
    648       
    649      echo '<h3>'.__('Comments').'</h3>'; 
    650      if (!$comments->isEmpty()) { 
    651           showComments($comments,$has_action); 
    652      } else { 
    653           echo '<p>'.__('No comment').'</p>'; 
    654      } 
    655       
    656      if ($has_action) { 
    657           echo 
    658           '<div class="two-cols">'. 
    659           '<p class="col checkboxes-helpers"></p>'. 
    660            
    661           '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 
    662           form::combo('action',$combo_action). 
    663           form::hidden(array('section'),'comments'). 
    664           form::hidden(array('id'),$post_id). 
    665           $core->formNonce(). 
    666           '<input type="submit" value="'.__('ok').'" /></p>'. 
    667           '</div>'. 
    668           '</form>'; 
    669      } 
    670      /* Add a comment 
    671      -------------------------------------------------------- */ 
    672  
    673      echo 
    674      '<div class="fieldset clear">'. 
    675      '<h3>'.__('Add a comment').'</h3>'. 
    676       
    677      '<form action="comment.php" method="post" id="comment-form">'. 
    678      '<div class="constrained">'. 
    679      '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. 
    680      form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). 
    681      '</p>'. 
    682       
    683      '<p><label for="comment_email">'.__('Email:').'</label>'. 
    684      form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 
    685      '</p>'. 
    686       
    687      '<p><label for="comment_site">'.__('Web site:').'</label>'. 
    688      form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 
    689      '</p>'. 
    690       
    691      '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 
    692      __('Comment:').'</label> '. 
    693      form::textarea('comment_content',50,8,html::escapeHTML('')). 
    694      '</p>'. 
    695       
    696      '<p>'. 
    697      form::hidden('post_id',$post_id). 
    698      $core->formNonce(). 
    699      '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 
    700      '</div>'. #constrained 
    701  
    702      '</form>'. 
    703      '</div>'. #add comment 
    704      '</div>'; #comments 
    705 } 
    706  
    707 if ($post_id && $post_status == 1) 
    708 { 
    709      /* Trackbacks 
    710      -------------------------------------------------------- */ 
    711  
    712      $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 
    713      $trackbacks = $core->blog->getComments(array_merge($params, array('comment_trackback' => 1))); 
    714       
    715      # Actions combo box 
    716      $combo_action = $comments_actions_page->getCombo();     
    717      $has_action = !empty($combo_action) && !$trackbacks->isEmpty(); 
    718       
    719      if (!empty($_GET['tb_auto'])) { 
    720           $tb_urls = implode("\n", $TB->discover($post_excerpt_xhtml.' '.$post_content_xhtml)); 
    721      } 
    722       
    723      # Display tab 
    724      echo 
    725      '<div id="trackbacks" class="clear multi-part" title="'.__('Trackbacks').'">'; 
    726       
    727      # tracbacks actions 
    728      if ($has_action) { 
    729           echo '<form action="post.php" id="form-trackbacks" method="post">'; 
    730      } 
    731       
    732      echo '<h3>'.__('Trackbacks received').'</h3>'; 
    733       
    734      if (!$trackbacks->isEmpty()) { 
    735           showComments($trackbacks, $has_action, true); 
    736      } else { 
    737           echo '<p>'.__('No trackback').'</p>'; 
    738      } 
    739       
    740      if ($has_action) { 
    741           echo 
    742           '<div class="two-cols">'. 
    743           '<p class="col checkboxes-helpers"></p>'. 
    744            
    745           '<p class="col right"><label for="action" class="classic">'.__('Selected trackbacks action:').'</label> '. 
    746           form::combo('action', $combo_action). 
    747           form::hidden('id',$post_id). 
    748           form::hidden(array('section'),'trackbacks'). 
    749           $core->formNonce(). 
    750           '<input type="submit" value="'.__('ok').'" /></p>'. 
    751           '</div>'. 
    752           '</form>'; 
    753      } 
    754       
    755      /* Add trackbacks 
    756      -------------------------------------------------------- */ 
    757      if ($can_edit_post && $post->post_status) { 
    758           echo 
    759           '<div class="fieldset clear">'; 
    760  
    761           echo 
    762           '<h3>'.__('Ping blogs').'</h3>'. 
    763           '<form action="post.php?id='.$post_id.'" id="trackback-form" method="post">'. 
    764           '<p><label for="tb_urls" class="area">'.__('URLs to ping:').'</label>'. 
    765           form::textarea('tb_urls', 60, 5, $tb_urls). 
    766           '</p>'. 
    767  
    768           '<p><label for="tb_excerpt" class="area">'.__('Excerpt to send:').'</label>'. 
    769           form::textarea('tb_excerpt', 60, 5, $tb_excerpt).'</p>'. 
    770  
    771           '<p>'. 
    772           $core->formNonce(). 
    773           '<input type="submit" name="ping" value="'.__('Ping blogs').'" />'. 
    774           (empty($_GET['tb_auto']) ?  
    775                '&nbsp;&nbsp;<a class="button" href="'. 
    776                'post.php?id='.$post_id.'&amp;tb_auto=1&amp;tb=1'. 
    777                '">'.__('Auto discover ping URLs').'</a>' 
    778           : ''). 
    779           '</p>'. 
    780           '</form>'; 
    781  
    782           $pings = $TB->getPostPings($post_id); 
    783  
    784           if (!$pings->isEmpty()) 
    785           { 
    786                echo '<h3>'.__('Previously sent pings').'</h3>'; 
    787                 
    788                echo '<ul class="nice">'; 
    789                while ($pings->fetch()) { 
    790                     echo 
    791                     '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'), $pings->ping_dt).' - '. 
    792                     $pings->ping_url.'</li>'; 
    793                } 
    794                echo '</ul>'; 
    795           } 
    796  
    797           echo '</div>'; 
    798      } 
    799  
    800      echo '</div>'; #trackbacks 
    801 } 
    802  
    803 # Controls comments or trakbacks capabilities 
    804 function isContributionAllowed($id,$dt,$com=true) 
    805 { 
    806      global $core; 
    807  
    808      if (!$id) { 
    809           return true; 
    810      } 
    811      if ($com) { 
    812           if (($core->blog->settings->system->comments_ttl == 0) ||  
    813                (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 
    814                return true; 
    815           } 
    816      } else { 
    817           if (($core->blog->settings->system->trackbacks_ttl == 0) ||  
    818                (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 
    819                return true; 
    820           } 
    821      } 
    822      return false; 
    823 } 
    824  
    825 # Show comments or trackbacks 
    826 function showComments($rs,$has_action,$tb=false) 
    827 { 
    828      echo 
    829      '<div class="table-outer">'. 
    830      '<table class="comments-list"><tr>'. 
    831      '<th colspan="2" class="first">'.__('Author').'</th>'. 
    832      '<th>'.__('Date').'</th>'. 
    833      '<th class="nowrap">'.__('IP address').'</th>'. 
    834      '<th>'.__('Status').'</th>'. 
    835      '<th>'.__('Edit').'</th>'. 
    836      '</tr>'; 
    837      $comments = array(); 
    838      if (isset($_REQUEST['comments'])) { 
    839           foreach ($_REQUEST['comments'] as $v) { 
    840                $comments[(integer)$v]=true; 
    841           } 
    842      }               
    843       
    844      while($rs->fetch()) 
    845      { 
    846           $comment_url = 'comment.php?id='.$rs->comment_id; 
    847            
    848           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    849           switch ($rs->comment_status) { 
    850                case 1: 
    851                     $img_status = sprintf($img,__('Published'),'check-on.png'); 
    852                     break; 
    853                case 0: 
    854                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 
    855                     break; 
    856                case -1: 
    857                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 
    858                     break; 
    859                case -2: 
    860                     $img_status = sprintf($img,__('Junk'),'junk.png'); 
    861                     break; 
    862           } 
    863            
    864           echo 
    865           '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 
    866           ' id="c'.$rs->comment_id.'">'. 
    867            
    868           '<td class="nowrap">'. 
    869           ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,isset($comments[$rs->comment_id]),'','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 
    870           '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 
    871           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 
    872           '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. 
    873           '<td class="nowrap status">'.$img_status.'</td>'. 
    874           '<td class="nowrap status"><a href="'.$comment_url.'">'. 
    875           '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'. 
    876            
    877           '</tr>'; 
    878      } 
    879       
    880      echo '</table></div>'; 
    881 } 
    882  
    883 dcPage::helpBlock('core_post','core_trackbacks','core_wiki'); 
    884 dcPage::close(); 
     393     $_ctx->setAlert(__('Comment has been successfully created.')); 
     394}     
     395      
     396$core->tpl->display('post.html.twig'); 
    885397?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map