Dotclear


Ignore:
Timestamp:
05/20/14 08:39:33 (11 years ago)
Author:
Dsls
Branch:
twig
Parents:
2683:fb8aa74332f1 (diff), 2714:eed2e5727277 (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 (admin/post.php still to update with editor preferences, in twig template)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/post.php

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