Dotclear

Changeset 2683:fb8aa74332f1 for admin


Ignore:
Timestamp:
03/13/14 11:42:57 (11 years ago)
Author:
Dsls
Branch:
twig
Parents:
2656:95fe4eacc716 (diff), 2682:cac55fdd7178 (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:

Merge with default

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • admin/post.php

    r2650 r2683  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2014 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
  • admin/post.php

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

Sites map