Changeset 848:ad18a33a3cef
- Timestamp:
- 07/31/12 13:18:23 (13 years ago)
- Branch:
- sexy
- Files:
-
- 4 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/blog_pref.php
r557 r848 135 135 if ($nb_post_per_feed <= 1) { $nb_post_per_feed = 1; } 136 136 137 $nb_comment_per_feed = abs((integer) $_POST['nb_comment_per_feed']);138 if ($nb_comment_per_feed <= 1) { $nb_comment_per_feed = 1; }139 140 137 try 141 138 { … … 182 179 $blog_settings->system->put('date_format',$_POST['date_format']); 183 180 $blog_settings->system->put('time_format',$_POST['time_format']); 184 $blog_settings->system->put('comments_ttl',abs((integer) $_POST['comments_ttl']));185 $blog_settings->system->put('trackbacks_ttl',abs((integer) $_POST['trackbacks_ttl']));186 $blog_settings->system->put('allow_comments',!empty($_POST['allow_comments']));187 $blog_settings->system->put('allow_trackbacks',!empty($_POST['allow_trackbacks']));188 $blog_settings->system->put('comments_pub',empty($_POST['comments_pub']));189 $blog_settings->system->put('trackbacks_pub',empty($_POST['trackbacks_pub']));190 $blog_settings->system->put('comments_nofollow',!empty($_POST['comments_nofollow']));191 $blog_settings->system->put('wiki_comments',!empty($_POST['wiki_comments']));192 181 $blog_settings->system->put('enable_xmlrpc',!empty($_POST['enable_xmlrpc'])); 193 182 … … 199 188 $blog_settings->system->put('media_img_title_pattern',$_POST['media_img_title_pattern']); 200 189 $blog_settings->system->put('nb_post_per_feed',$nb_post_per_feed); 201 $blog_settings->system->put('nb_comment_per_feed',$nb_comment_per_feed);202 190 $blog_settings->system->put('short_feed_items',!empty($_POST['short_feed_items'])); 203 191 … … 331 319 332 320 echo 333 '<fieldset><legend>'.__('Comments and trackbacks').'</legend>'.334 '<div class="two-cols">'.335 '<div class="col">'.336 '<p><label for="allow_comments" class="classic">'.337 form::checkbox('allow_comments','1',$blog_settings->system->allow_comments).338 __('Accept comments').'</label></p>'.339 340 '<p><label for="comments_pub" class="classic">'.341 form::checkbox('comments_pub','1',!$blog_settings->system->comments_pub).342 __('Moderate comments').'</label></p>'.343 344 '<p><label for="comments_ttl" class="classic">'.sprintf(__('Leave comments open for %s days'),345 form::field('comments_ttl',2,3,$blog_settings->system->comments_ttl)).346 '</label></p>'.347 '<p class="form-note">'.__('Leave blank to disable this feature.').'</p>'.348 349 '<p><label for="wiki_comments" class="classic">'.350 form::checkbox('wiki_comments','1',$blog_settings->system->wiki_comments).351 __('Wiki syntax for comments').'</label></p>'.352 '</div>'.353 354 '<div class="col">'.355 '<p><label for="allow_trackbacks" class="classic">'.356 form::checkbox('allow_trackbacks','1',$blog_settings->system->allow_trackbacks).357 __('Accept trackbacks').'</label></p>'.358 359 '<p><label for="trackbacks_pub" class="classic">'.360 form::checkbox('trackbacks_pub','1',!$blog_settings->system->trackbacks_pub).361 __('Moderate trackbacks').'</label></p>'.362 363 '<p><label for="trackbacks_ttl" class="classic">'.sprintf(__('Leave trackbacks open for %s days'),364 form::field('trackbacks_ttl',2,3,$blog_settings->system->trackbacks_ttl)).'</label></p>'.365 '<p class="form-note">'.__('Leave blank to disable this feature.').'</p>'.366 367 '<p><label for="comments_nofollow" class="classic">'.368 form::checkbox('comments_nofollow','1',$blog_settings->system->comments_nofollow).369 __('Add "nofollow" relation on comments and trackbacks links').'</label></p>'.370 '</div>'.371 '</div>'.372 '<br class="clear" />'. //Opera sucks373 '</fieldset>';374 375 echo376 321 '<fieldset><legend>'.__('Blog presentation').'</legend>'. 377 322 '<div class="two-cols">'. … … 397 342 '<p><label for="nb_post_per_feed" class="classic">'.sprintf(__('Display %s entries per feed'), 398 343 form::field('nb_post_per_feed',2,3,$blog_settings->system->nb_post_per_feed)). 399 '</label></p>'.400 401 '<p><label for="nb_comment_per_feed" class="classic">'.sprintf(__('Display %s comments per feed'),402 form::field('nb_comment_per_feed',2,3,$blog_settings->system->nb_comment_per_feed)).403 344 '</label></p>'. 404 345 -
admin/index.php
r691 r848 71 71 $str_entries = ($post_count > 1) ? __('%d entries') : __('%d entry'); 72 72 73 $comment_count = $core->blog->getComments(array(),true)->f(0);74 $str_comments = ($comment_count > 1) ? __('%d comments') : __('%d comment');75 76 73 $ws = $core->auth->user_prefs->addWorkspace('favorites'); 77 74 $count = 0; … … 83 80 $count++; 84 81 $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) : 85 ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title']));82 $fav['title']); 86 83 $__dashboard_icons[$fav['name']] = new ArrayObject(array(__($title),$fav['url'],$fav['large-icon'])); 87 84 … … 98 95 $count++; 99 96 $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) : 100 ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title']));97 $fav['title']); 101 98 $__dashboard_icons[$fav['name']] = new ArrayObject(array(__($title),$fav['url'],$fav['large-icon'])); 102 99 -
admin/install/index.php
r557 r848 166 166 $cur->post_content_xhtml = $cur->post_content; 167 167 $cur->post_status = 1; 168 $cur->post_open_comment = 1;169 $cur->post_open_tb = 0;170 168 $post_id = $core->blog->addPost($cur); 171 172 # Add a comment to it173 $cur = $core->con->openCursor($core->prefix.'comment');174 $cur->post_id = $post_id;175 $cur->comment_tz = $default_tz;176 $cur->comment_author = __('Dotclear Team');177 $cur->comment_email = 'contact@dotclear.net';178 $cur->comment_site = 'http://www.dotclear.org/';179 $cur->comment_content = __("<p>This is a comment.</p>\n<p>To delete it, log in and ".180 "view your blog's comments. Then you might remove or edit it.</p>");181 $core->blog->addComment($cur);182 169 183 170 # Plugins initialization … … 210 197 $init_fav['posts'] = array('posts','Entries','posts.php', 211 198 'images/menu/entries.png','images/menu/entries-b.png', 212 'usage,contentadmin',null,null);213 $init_fav['comments'] = array('comments','Comments','comments.php',214 'images/menu/comments.png','images/menu/comments-b.png',215 199 'usage,contentadmin',null,null); 216 200 $init_fav['prefs'] = array('prefs','My preferences','preferences.php', -
admin/post.php
r776 r848 30 30 $post_status = $core->auth->getInfo('user_post_status'); 31 31 $post_selected = false; 32 $post_open_comment = $core->blog->settings->system->allow_comments;33 $post_open_tb = $core->blog->settings->system->allow_trackbacks;34 32 35 33 $page_title = __('New entry'); … … 117 115 $post_status = $post->post_status; 118 116 $post_selected = (boolean) $post->post_selected; 119 $post_open_comment = (boolean) $post->post_open_comment;120 $post_open_tb = (boolean) $post->post_open_tb;121 117 122 118 $page_title = __('Edit entry'); … … 170 166 } 171 167 172 $post_open_comment = !empty($_POST['post_open_comment']);173 $post_open_tb = !empty($_POST['post_open_tb']);174 168 $post_selected = !empty($_POST['post_selected']); 175 169 $post_lang = $_POST['post_lang']; … … 207 201 $cur->post_status = $post_status; 208 202 $cur->post_selected = (integer) $post_selected; 209 $cur->post_open_comment = (integer) $post_open_comment;210 $cur->post_open_tb = (integer) $post_open_tb;211 203 212 204 if (isset($_POST['post_url'])) { … … 275 267 $default_tab = ''; 276 268 } 277 if (!empty($_GET['co'])) {278 $default_tab = 'comments';279 }280 269 281 270 dcPage::open($page_title.' - '.__('Entries'), … … 285 274 dcPage::jsMetaEditor(). 286 275 dcPage::jsLoad('js/_post.js'). 287 dcPage::jsConfirmClose('entry-form' ,'comment-form').276 dcPage::jsConfirmClose('entry-form'). 288 277 # --BEHAVIOR-- adminPostHeaders 289 278 $core->callBehavior('adminPostHeaders'). … … 305 294 } 306 295 307 if (!empty($_GET['creaco'])) {308 echo '<p class="message">'.__('Comment has been successfully created.').'</p>';309 }310 296 311 297 # XHTML conversion … … 421 407 '<p>'.($post_id && $post_format != 'xhtml' ? '<a id="convert-xhtml" class="button" href="post.php?id='.$post_id.'&xconv=1">'.__('Convert to XHTML').'</a>' : '').'</p>'. 422 408 423 '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '.424 __('Accept comments').'</label></p>'.425 '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '.426 __('Accept trackbacks').'</label></p>'.427 409 '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. 428 410 __('Selected entry').'</label></p>'. … … 457 439 echo '</div>'; 458 440 459 if ($post_id && $post->post_status == 1) {460 echo '<p><a href="trackbacks.php?id='.$post_id.'" class="multi-part">'.461 __('Ping blogs').'</a></p>';462 }463 464 }465 466 467 /* Comments and trackbacks468 -------------------------------------------------------- */469 if ($post_id)470 {471 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');472 473 $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0)));474 $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1)));475 476 # Actions combo box477 $combo_action = array();478 if ($can_edit_post && $core->auth->check('publish,contentadmin',$core->blog->id))479 {480 $combo_action[__('publish')] = 'publish';481 $combo_action[__('unpublish')] = 'unpublish';482 $combo_action[__('mark as pending')] = 'pending';483 $combo_action[__('mark as junk')] = 'junk';484 }485 486 if ($can_edit_post && $core->auth->check('delete,contentadmin',$core->blog->id))487 {488 $combo_action[__('Delete')] = 'delete';489 }490 491 # --BEHAVIOR-- adminCommentsActionsCombo492 $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));493 494 $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty());495 496 echo497 '<div id="comments" class="multi-part" title="'.__('Comments').'">';498 499 if ($has_action) {500 echo '<form action="comments_actions.php" id="form-comments" method="post">';501 }502 503 echo '<h3>'.__('Trackbacks').'</h3>';504 505 if (!$trackbacks->isEmpty()) {506 showComments($trackbacks,$has_action,true);507 } else {508 echo '<p>'.__('No trackback').'</p>';509 }510 511 echo '<h3>'.__('Comments').'</h3>';512 if (!$comments->isEmpty()) {513 showComments($comments,$has_action);514 } else {515 echo '<p>'.__('No comment').'</p>';516 }517 518 if ($has_action) {519 echo520 '<div class="two-cols">'.521 '<p class="col checkboxes-helpers"></p>'.522 523 '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.524 form::combo('action',$combo_action).525 form::hidden('redir','post.php?id='.$post_id.'&co=1').526 $core->formNonce().527 '<input type="submit" value="'.__('ok').'" /></p>'.528 '</div>'.529 '</form>';530 }531 532 echo '</div>';533 }534 535 /* Add a comment536 -------------------------------------------------------- */537 if ($post_id)538 {539 echo540 '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'.541 '<h3>'.__('Add a comment').'</h3>'.542 543 '<form action="comment.php" method="post" id="comment-form">'.544 '<div class="constrained">'.545 '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').546 form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))).547 '</label></p>'.548 549 '<p><label for="comment_email">'.__('Email:').550 form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))).551 '</label></p>'.552 553 '<p><label for="comment_site">'.__('Web site:').554 form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))).555 '</label></p>'.556 557 '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.558 __('Comment:').'</label> '.559 form::textarea('comment_content',50,8,html::escapeHTML('')).560 '</p>'.561 562 '<p>'.form::hidden('post_id',$post_id).563 $core->formNonce().564 '<input type="submit" name="add" value="'.__('Save').'" /></p>'.565 '</div>'.566 '</form>'.567 '</div>';568 }569 570 571 # Show comments or trackbacks572 function showComments($rs,$has_action,$tb=false)573 {574 echo575 '<table class="comments-list"><tr>'.576 '<th colspan="2">'.__('Author').'</th>'.577 '<th>'.__('Date').'</th>'.578 '<th class="nowrap">'.__('IP address').'</th>'.579 '<th>'.__('Status').'</th>'.580 '<th> </th>'.581 '</tr>';582 583 while($rs->fetch())584 {585 $comment_url = 'comment.php?id='.$rs->comment_id;586 587 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';588 switch ($rs->comment_status) {589 case 1:590 $img_status = sprintf($img,__('published'),'check-on.png');591 break;592 case 0:593 $img_status = sprintf($img,__('unpublished'),'check-off.png');594 break;595 case -1:596 $img_status = sprintf($img,__('pending'),'check-wrn.png');597 break;598 case -2:599 $img_status = sprintf($img,__('junk'),'junk.png');600 break;601 }602 603 echo604 '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'.605 ' id="c'.$rs->comment_id.'">'.606 607 '<td class="nowrap">'.608 ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'.609 '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'.610 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'.611 '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'.612 '<td class="nowrap status">'.$img_status.'</td>'.613 '<td class="nowrap status"><a href="'.$comment_url.'">'.614 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'.615 616 '</tr>';617 }618 619 echo '</table>';620 441 } 621 442 -
admin/search.php
r747 r848 49 49 } 50 50 } 51 # Get comments52 elseif ($qtype == 'c')53 {54 $starting_scripts .= dcPage::jsLoad('js/_comments.js');55 56 $params['search'] = $q;57 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);58 $params['no_content'] = true;59 $params['order'] = 'comment_dt DESC';60 61 try {62 $comments = $core->blog->getComments($params);63 $counter = $core->blog->getComments($params,true);64 $comment_list = new adminCommentList($core,$comments,$counter->f(0));65 } catch (Exception $e) {66 $core->error->add($e->getMessage());67 }68 }69 51 } 70 52 … … 78 60 '<p><label for="q">'.__('Query:').' </label>'.form::field('q',30,255,html::escapeHTML($q)).'</p>'. 79 61 '<p><label for="qtype1" class="classic">'.form::radio(array('qtype','qtype1'),'p',$qtype == 'p').' '.__('Search entries').'</label> '. 80 '< label for="qtype2" class="classic">'.form::radio(array('qtype','qtype2'),'c',$qtype == 'c').' '.__('Search comments').'</label></p>'.62 '</p>'. 81 63 '</p><input type="submit" value="'.__('Search').'" /></p>'. 82 64 '</div>'. … … 134 116 ); 135 117 } 136 # Show posts137 elseif ($qtype == 'c')138 {139 # Actions combo box140 $combo_action = array();141 if ($core->auth->check('publish,contentadmin',$core->blog->id))142 {143 $combo_action[__('publish')] = 'publish';144 $combo_action[__('unpublish')] = 'unpublish';145 $combo_action[__('mark as pending')] = 'pending';146 $combo_action[__('mark as junk')] = 'junk';147 }148 if ($core->auth->check('delete,contentadmin',$core->blog->id))149 {150 $combo_action[__('Delete')] = 'delete';151 }152 153 if ($counter->f(0) > 0) {154 printf('<h3>'.155 ($counter->f(0) == 1 ? __('%d comment found') : __('%d comments found')).156 '</h3>',$counter->f(0));157 }158 159 $comment_list->display($page,$nb_per_page,160 '<form action="comments_actions.php" method="post" id="form-comments">'.161 162 '%s'.163 164 '<div class="two-cols">'.165 '<p class="col checkboxes-helpers"></p>'.166 167 '<p class="col right"><label for="action2" class="classic">'.__('Selected comments action:').'</label> '.168 form::combo(array('action','action2'),$combo_action).169 '<input type="submit" value="'.__('ok').'" /></p>'.170 form::hidden('redir',preg_replace('/%/','%%',$redir)).171 $core->formNonce().172 '</div>'.173 '</form>'174 );175 }176 118 } 177 119 -
admin/services.php
r323 r848 18 18 19 19 $core->rest->addFunction('getPostById',array('dcRestMethods','getPostById')); 20 $core->rest->addFunction('getCommentById',array('dcRestMethods','getCommentById'));21 20 $core->rest->addFunction('quickPost',array('dcRestMethods','quickPost')); 22 21 $core->rest->addFunction('validatePostMarkup',array('dcRestMethods','validatePostMarkup')); … … 70 69 $rsp->post_status($rs->post_status); 71 70 $rsp->post_selected($rs->post_selected); 72 $rsp->post_open_comment($rs->post_open_comment);73 $rsp->post_open_tb($rs->post_open_tb);74 $rsp->nb_comment($rs->nb_comment);75 $rsp->nb_trackback($rs->nb_trackback);76 71 $rsp->user_name($rs->user_name); 77 72 $rsp->user_firstname($rs->user_firstname); … … 100 95 } 101 96 102 public static function getCommentById($core,$get)103 {104 if (empty($get['id'])) {105 throw new Exception('No comment ID');106 }107 108 $rs = $core->blog->getComments(array('comment_id' => (integer) $get['id']));109 110 if ($rs->isEmpty()) {111 throw new Exception('No comment for this ID');112 }113 114 $rsp = new xmlTag('post');115 $rsp->id = $rs->comment_id;116 117 $rsp->comment_dt($rs->comment_dt);118 $rsp->comment_upddt($rs->comment_upddt);119 $rsp->comment_author($rs->comment_author);120 $rsp->comment_site($rs->comment_site);121 $rsp->comment_content($rs->comment_content);122 $rsp->comment_trackback($rs->comment_trackback);123 $rsp->comment_status($rs->comment_status);124 $rsp->post_title($rs->post_title);125 $rsp->post_url($rs->post_url);126 $rsp->post_id($rs->post_id);127 $rsp->post_dt($rs->post_dt);128 $rsp->user_id($rs->user_id);129 130 $rsp->comment_display_content($rs->getContent(true));131 132 if ($core->auth->userID()) {133 $rsp->comment_ip($rs->comment_ip);134 $rsp->comment_email($rs->comment_email);135 $rsp->comment_spam_disp(dcAntispam::statusMessage($rs));136 }137 138 return $rsp;139 }140 97 141 98 public static function quickPost($core,$get,$post) … … 150 107 $cur->post_lang = !empty($post['post_lang']) ? $post['post_lang'] : ''; 151 108 $cur->post_status = !empty($post['post_status']) ? (integer) $post['post_status'] : 0; 152 $cur->post_open_comment = (integer) $core->blog->settings->system->allow_comments;153 $cur->post_open_tb = (integer) $core->blog->settings->system->allow_trackbacks;154 109 155 110 # --BEHAVIOR-- adminBeforePostCreate -
inc/admin/lib.dc.page.php
r812 r848 410 410 self::jsVar('dotclear.msg.confirm_delete_post', 411 411 __("Are you sure you want to delete this entry?")). 412 self::jsVar('dotclear.msg.confirm_delete_comments',413 __('Are you sure you want to delete selected comments (%s)?')).414 self::jsVar('dotclear.msg.confirm_delete_comment',415 __('Are you sure you want to delete this comment?')).416 412 self::jsVar('dotclear.msg.cannot_delete_users', 417 413 __('Users with posts cannot be deleted.')). -
inc/admin/lib.pager.php
r270 r848 49 49 '<th>'.__('Category').'</th>'. 50 50 '<th>'.__('Author').'</th>'. 51 '<th>'.__('Comments').'</th>'.52 '<th>'.__('Trackbacks').'</th>'.53 51 '<th>'.__('Status').'</th>'. 54 52 '</tr>%s</table>'; … … 134 132 '<td class="nowrap">'.$cat_title.'</td>'. 135 133 '<td class="nowrap">'.$this->rs->user_id.'</td>'. 136 '<td class="nowrap">'.$this->rs->nb_comment.'</td>'.137 '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.138 134 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. 139 135 '</tr>'; … … 233 229 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. 234 230 '</tr>'; 235 236 return $res;237 }238 }239 240 class adminCommentList extends adminGenericList241 {242 public function display($page,$nb_per_page,$enclose_block='')243 {244 if ($this->rs->isEmpty())245 {246 echo '<p><strong>'.__('No comment').'</strong></p>';247 }248 else249 {250 $pager = new pager($page,$this->rs_count,$nb_per_page,10);251 $pager->html_prev = $this->html_prev;252 $pager->html_next = $this->html_next;253 $pager->var_page = 'page';254 255 $html_block =256 '<table><tr>'.257 '<th colspan="2">'.__('Title').'</th>'.258 '<th>'.__('Date').'</th>'.259 '<th>'.__('Author').'</th>'.260 '<th>'.__('Type').'</th>'.261 '<th>'.__('Status').'</th>'.262 '<th> </th>'.263 '</tr>%s</table>';264 265 if ($enclose_block) {266 $html_block = sprintf($enclose_block,$html_block);267 }268 269 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';270 271 $blocks = explode('%s',$html_block);272 273 echo $blocks[0];274 275 while ($this->rs->fetch())276 {277 echo $this->commentLine();278 }279 280 echo $blocks[1];281 282 echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';283 }284 }285 286 private function commentLine()287 {288 global $author, $status, $sortby, $order, $nb_per_page;289 290 $author_url =291 'comments.php?n='.$nb_per_page.292 '&status='.$status.293 '&sortby='.$sortby.294 '&order='.$order.295 '&author='.rawurlencode($this->rs->comment_author);296 297 $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id);298 299 $comment_url = 'comment.php?id='.$this->rs->comment_id;300 301 $comment_dt =302 dt::dt2str($this->core->blog->settings->system->date_format.' - '.303 $this->core->blog->settings->system->time_format,$this->rs->comment_dt);304 305 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';306 switch ($this->rs->comment_status) {307 case 1:308 $img_status = sprintf($img,__('published'),'check-on.png');309 break;310 case 0:311 $img_status = sprintf($img,__('unpublished'),'check-off.png');312 break;313 case -1:314 $img_status = sprintf($img,__('pending'),'check-wrn.png');315 break;316 case -2:317 $img_status = sprintf($img,__('junk'),'junk.png');318 break;319 }320 321 $comment_author = html::escapeHTML($this->rs->comment_author);322 if (mb_strlen($comment_author) > 20) {323 $comment_author = mb_strcut($comment_author,0,17).'...';324 }325 326 $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'.327 ' id="c'.$this->rs->comment_id.'">';328 329 $res .=330 '<td class="nowrap">'.331 form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'</td>'.332 '<td class="maximal"><a href="'.$post_url.'">'.333 html::escapeHTML($this->rs->post_title).'</a>'.334 ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'.335 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'.336 '<td class="nowrap"><a href="'.$author_url.'">'.$comment_author.'</a></td>'.337 '<td class="nowrap">'.($this->rs->comment_trackback ? __('trackback') : __('comment')).'</td>'.338 '<td class="nowrap status">'.$img_status.'</td>'.339 '<td class="nowrap status"><a href="'.$comment_url.'">'.340 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>';341 342 $res .= '</tr>';343 231 344 232 return $res; -
inc/admin/prepend.php
r821 r848 234 234 $_fav['posts'] = new ArrayObject(array('posts','Entries','posts.php', 235 235 'images/menu/entries.png','images/menu/entries-b.png', 236 'usage,contentadmin',null,null));237 $_fav['comments'] = new ArrayObject(array('comments','Comments','comments.php',238 'images/menu/comments.png','images/menu/comments-b.png',239 236 'usage,contentadmin',null,null)); 240 237 $_fav['search'] = new ArrayObject(array('search','Search','search.php', … … 311 308 preg_match('/search.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 312 309 $core->auth->check('usage,contentadmin',$core->blog->id)); 313 $_menu['Blog']->prependItem(__('Comments'),'comments.php','images/menu/comments.png',314 preg_match('/comments.php(\?.*)?$/',$_SERVER['REQUEST_URI']),315 $core->auth->check('usage,contentadmin',$core->blog->id));316 310 $_menu['Blog']->prependItem(__('Entries'),'posts.php','images/menu/entries.png', 317 311 preg_match('/posts.php(\?.*)?$/',$_SERVER['REQUEST_URI']), -
inc/core/class.dc.blog.php
r836 r848 55 55 56 56 private $post_status = array(); 57 private $comment_status = array();58 57 59 58 private $categories; … … 95 94 $this->post_status['0'] = __('unpublished'); 96 95 $this->post_status['1'] = __('published'); 97 98 $this->comment_status['-2'] = __('junk'); 99 $this->comment_status['-1'] = __('pending'); 100 $this->comment_status['0'] = __('unpublished'); 101 $this->comment_status['1'] = __('published'); 102 96 103 97 # --BEHAVIOR-- coreBlogConstruct 104 98 $this->core->callBehavior('coreBlogConstruct',$this); … … 145 139 } 146 140 147 /**148 Returns an array of available comment status codes and names.149 150 @return <b>array</b> Simple array with codes in keys and names in value151 */152 public function getAllCommentStatus()153 {154 return $this->comment_status;155 }156 141 157 142 /** … … 184 169 $this->core->callBehavior('coreBlogAfterTriggerBlog',$cur); 185 170 } 186 187 /** 188 Updates comment and trackback counters in post table. Should be called 189 every time a comment or trackback is added, removed or changed its status. 190 191 @param id <b>integer</b> Comment ID 192 @param del <b>boolean</b> If comment is delete, set this to true 193 */ 194 public function triggerComment($id,$del=false) 195 { 196 $id = (integer) $id; 197 198 $strReq = 'SELECT post_id, comment_trackback '. 199 'FROM '.$this->prefix.'comment '. 200 'WHERE comment_id = '.$id.' '; 201 202 $rs = $this->con->select($strReq); 203 204 $post_id = $rs->post_id; 205 $tb = (boolean) $rs->comment_trackback; 206 207 $strReq = 'SELECT COUNT(post_id) '. 208 'FROM '.$this->prefix.'comment '. 209 'WHERE post_id = '.(integer) $post_id.' '. 210 'AND comment_trackback = '.(integer) $tb.' '. 211 'AND comment_status = 1 '; 212 213 if ($del) { 214 $strReq .= 'AND comment_id <> '.$id.' '; 215 } 216 217 $rs = $this->con->select($strReq); 218 219 $cur = $this->con->openCursor($this->prefix.'post'); 220 221 if ($rs->isEmpty()) { 222 return; 223 } 224 225 if ($tb) { 226 $cur->nb_trackback = (integer) $rs->f(0); 227 } else { 228 $cur->nb_comment = (integer) $rs->f(0); 229 } 230 231 $cur->update('WHERE post_id = '.(integer) $post_id); 232 } 233 //@} 234 171 235 172 /// @name Categories management methods 236 173 //@{ … … 701 638 'post_url, post_lang, post_title, '.$content_req. 702 639 'post_type, post_meta, post_status, post_selected, post_position, '. 703 'post_open_comment, post_open_tb, nb_comment, nb_trackback, '.704 640 'U.user_name, U.user_firstname, U.user_displayname, U.user_email, '. 705 641 'U.user_url, '. … … 1714 1650 } 1715 1651 //@} 1716 1717 /// @name Comments management methods1718 //@{1719 /**1720 Retrieves comments. <b>$params</b> is an array taking the following1721 optionnal parameters:1722 1723 - no_content: Don't retrieve comment content1724 - post_type: Get only entries with given type (default no type, array for many types)1725 - post_id: (integer) Get comments belonging to given post_id1726 - cat_id: (integer or array) Get comments belonging to entries of given category ID1727 - comment_id: (integer) Get comment with given ID1728 - comment_status: (integer) Get comments with given comment_status1729 - comment_trackback: (integer) Get only comments (0) or trackbacks (1)1730 - comment_ip: (string) Get comments with given IP address1731 - post_url: Get entry with given post_url field1732 - user_id: (integer) Get entries belonging to given user ID1733 - q_author: Search comments by author1734 - sql: Append SQL string at the end of the query1735 - from: Append SQL string after "FROM" statement in query1736 - order: Order of results (default "ORDER BY comment_dt DES")1737 - limit: Limit parameter1738 - sql_only : return the sql request instead of results. Only ids are selected1739 1740 @param params <b>array</b> Parameters1741 @param count_only <b>boolean</b> Only counts results1742 @return <b>record</b> A record with some more capabilities1743 */1744 public function getComments($params=array(),$count_only=false)1745 {1746 if ($count_only)1747 {1748 $strReq = 'SELECT count(comment_id) ';1749 }1750 elseif (!empty($params['sql_only']))1751 {1752 $strReq = 'SELECT P.post_id ';1753 }1754 else1755 {1756 if (!empty($params['no_content'])) {1757 $content_req = '';1758 } else {1759 $content_req = 'comment_content, ';1760 }1761 1762 if (!empty($params['columns']) && is_array($params['columns'])) {1763 $content_req .= implode(', ',$params['columns']).', ';1764 }1765 1766 $strReq =1767 'SELECT C.comment_id, comment_dt, comment_tz, comment_upddt, '.1768 'comment_author, comment_email, comment_site, '.1769 $content_req.' comment_trackback, comment_status, '.1770 'comment_spam_status, comment_spam_filter, comment_ip, '.1771 'P.post_title, P.post_url, P.post_id, P.post_password, P.post_type, '.1772 'P.post_dt, P.user_id, U.user_email, U.user_url ';1773 }1774 1775 $strReq .=1776 'FROM '.$this->prefix.'comment C '.1777 'INNER JOIN '.$this->prefix.'post P ON C.post_id = P.post_id '.1778 'INNER JOIN '.$this->prefix.'user U ON P.user_id = U.user_id ';1779 1780 if (!empty($params['from'])) {1781 $strReq .= $params['from'].' ';1782 }1783 1784 $strReq .=1785 "WHERE P.blog_id = '".$this->con->escape($this->id)."' ";1786 1787 if (!$this->core->auth->check('contentadmin',$this->id)) {1788 $strReq .= 'AND ((comment_status = 1 AND P.post_status = 1 ';1789 1790 if ($this->without_password) {1791 $strReq .= 'AND post_password IS NULL ';1792 }1793 $strReq .= ') ';1794 1795 if ($this->core->auth->userID()) {1796 $strReq .= "OR P.user_id = '".$this->con->escape($this->core->auth->userID())."')";1797 } else {1798 $strReq .= ') ';1799 }1800 }1801 1802 if (!empty($params['post_type']))1803 {1804 $strReq .= 'AND post_type '.$this->con->in($params['post_type']);1805 }1806 1807 if (isset($params['post_id']) && $params['post_id'] !== '') {1808 $strReq .= 'AND P.post_id = '.(integer) $params['post_id'].' ';1809 }1810 1811 if (isset($params['cat_id']) && $params['cat_id'] !== '') {1812 $strReq .= 'AND P.cat_id = '.(integer) $params['cat_id'].' ';1813 }1814 1815 if (isset($params['comment_id']) && $params['comment_id'] !== '') {1816 $strReq .= 'AND comment_id = '.(integer) $params['comment_id'].' ';1817 }1818 1819 if (isset($params['comment_status'])) {1820 $strReq .= 'AND comment_status = '.(integer) $params['comment_status'].' ';1821 }1822 1823 if (!empty($params['comment_status_not']))1824 {1825 $strReq .= 'AND comment_status <> '.(integer) $params['comment_status_not'].' ';1826 }1827 1828 if (isset($params['comment_trackback'])) {1829 $strReq .= 'AND comment_trackback = '.(integer) (boolean) $params['comment_trackback'].' ';1830 }1831 1832 if (isset($params['comment_ip'])) {1833 $strReq .= "AND comment_ip = '".$this->con->escape($params['comment_ip'])."' ";1834 }1835 1836 if (isset($params['q_author'])) {1837 $q_author = $this->con->escape(str_replace('*','%',strtolower($params['q_author'])));1838 $strReq .= "AND LOWER(comment_author) LIKE '".$q_author."' ";1839 }1840 1841 if (!empty($params['search']))1842 {1843 $words = text::splitWords($params['search']);1844 1845 if (!empty($words))1846 {1847 # --BEHAVIOR coreCommentSearch1848 if ($this->core->hasBehavior('coreCommentSearch')) {1849 $this->core->callBehavior('coreCommentSearch',$this->core,array(&$words,&$strReq,&$params));1850 }1851 1852 if ($words)1853 {1854 foreach ($words as $i => $w) {1855 $words[$i] = "comment_words LIKE '%".$this->con->escape($w)."%'";1856 }1857 $strReq .= 'AND '.implode(' AND ',$words).' ';1858 }1859 }1860 }1861 1862 if (!empty($params['sql'])) {1863 $strReq .= $params['sql'].' ';1864 }1865 1866 if (!$count_only)1867 {1868 if (!empty($params['order'])) {1869 $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' ';1870 } else {1871 $strReq .= 'ORDER BY comment_dt DESC ';1872 }1873 }1874 1875 if (!$count_only && !empty($params['limit'])) {1876 $strReq .= $this->con->limit($params['limit']);1877 }1878 1879 if (!empty($params['sql_only'])) {1880 return $strReq;1881 }1882 1883 $rs = $this->con->select($strReq);1884 $rs->core = $this->core;1885 $rs->extend('rsExtComment');1886 1887 # --BEHAVIOR-- coreBlogGetComments1888 $this->core->callBehavior('coreBlogGetComments',$rs);1889 1890 return $rs;1891 }1892 1893 /**1894 Creates a new comment. Takes a cursor as input and returns the new comment1895 ID.1896 1897 @param cur <b>cursor</b> Comment cursor1898 @return <b>integer</b> New comment ID1899 */1900 public function addComment($cur)1901 {1902 $this->con->writeLock($this->prefix.'comment');1903 try1904 {1905 # Get ID1906 $rs = $this->con->select(1907 'SELECT MAX(comment_id) '.1908 'FROM '.$this->prefix.'comment '1909 );1910 1911 $cur->comment_id = (integer) $rs->f(0) + 1;1912 $cur->comment_upddt = date('Y-m-d H:i:s');1913 1914 $offset = dt::getTimeOffset($this->settings->system->blog_timezone);1915 $cur->comment_dt = date('Y-m-d H:i:s',time() + $offset);1916 $cur->comment_tz = $this->settings->system->blog_timezone;1917 1918 $this->getCommentCursor($cur);1919 1920 if ($cur->comment_ip === null) {1921 $cur->comment_ip = http::realIP();1922 }1923 1924 # --BEHAVIOR-- coreBeforeCommentCreate1925 $this->core->callBehavior('coreBeforeCommentCreate',$this,$cur);1926 1927 $cur->insert();1928 $this->con->unlock();1929 }1930 catch (Exception $e)1931 {1932 $this->con->unlock();1933 throw $e;1934 }1935 1936 # --BEHAVIOR-- coreAfterCommentCreate1937 $this->core->callBehavior('coreAfterCommentCreate',$this,$cur);1938 1939 $this->triggerComment($cur->comment_id);1940 if ($cur->comment_status != -2) {1941 $this->triggerBlog();1942 }1943 return $cur->comment_id;1944 }1945 1946 /**1947 Updates an existing comment.1948 1949 @param id <b>integer</b> Comment ID1950 @param cur <b>cursor</b> Comment cursor1951 */1952 public function updComment($id,$cur)1953 {1954 if (!$this->core->auth->check('usage,contentadmin',$this->id)) {1955 throw new Exception(__('You are not allowed to update comments'));1956 }1957 1958 $id = (integer) $id;1959 1960 if (empty($id)) {1961 throw new Exception(__('No such comment ID'));1962 }1963 1964 $rs = $this->getComments(array('comment_id' => $id));1965 1966 if ($rs->isEmpty()) {1967 throw new Exception(__('No such comment ID'));1968 }1969 1970 #If user is only usage, we need to check the post's owner1971 if (!$this->core->auth->check('contentadmin',$this->id))1972 {1973 if ($rs->user_id != $this->core->auth->userID()) {1974 throw new Exception(__('You are not allowed to update this comment'));1975 }1976 }1977 1978 $this->getCommentCursor($cur);1979 1980 $cur->comment_upddt = date('Y-m-d H:i:s');1981 1982 if (!$this->core->auth->check('publish,contentadmin',$this->id)) {1983 $cur->unsetField('comment_status');1984 }1985 1986 # --BEHAVIOR-- coreBeforeCommentUpdate1987 $this->core->callBehavior('coreBeforeCommentUpdate',$this,$cur,$rs);1988 1989 $cur->update('WHERE comment_id = '.$id.' ');1990 1991 # --BEHAVIOR-- coreAfterCommentUpdate1992 $this->core->callBehavior('coreAfterCommentUpdate',$this,$cur,$rs);1993 1994 $this->triggerComment($id);1995 $this->triggerBlog();1996 }1997 1998 /**1999 Updates comment status.2000 2001 @param id <b>integer</b> Comment ID2002 @param status <b>integer</b> Comment status2003 */2004 public function updCommentStatus($id,$status)2005 {2006 if (!$this->core->auth->check('publish,contentadmin',$this->id)) {2007 throw new Exception(__("You are not allowed to change this comment's status"));2008 }2009 2010 $cur = $this->con->openCursor($this->prefix.'comment');2011 $cur->comment_status = (integer) $status;2012 $this->updComment($id,$cur);2013 }2014 2015 /**2016 Delete a comment2017 2018 @param id <b>integer</b> Comment ID2019 */2020 public function delComment($id)2021 {2022 if (!$this->core->auth->check('delete,contentadmin',$this->id)) {2023 throw new Exception(__('You are not allowed to delete comments'));2024 }2025 2026 $id = (integer) $id;2027 2028 if (empty($id)) {2029 throw new Exception(__('No such comment ID'));2030 }2031 2032 #If user can only delete, we need to check the post's owner2033 if (!$this->core->auth->check('contentadmin',$this->id))2034 {2035 $strReq = 'SELECT P.post_id '.2036 'FROM '.$this->prefix.'post P, '.$this->prefix.'comment C '.2037 'WHERE P.post_id = C.post_id '.2038 "AND P.blog_id = '".$this->con->escape($this->id)."' ".2039 'AND comment_id = '.$id.' '.2040 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' ";2041 2042 $rs = $this->con->select($strReq);2043 2044 if ($rs->isEmpty()) {2045 throw new Exception(__('You are not allowed to delete this comment'));2046 }2047 }2048 2049 $strReq = 'DELETE FROM '.$this->prefix.'comment '.2050 'WHERE comment_id = '.$id.' ';2051 2052 $this->triggerComment($id,true);2053 $this->con->execute($strReq);2054 $this->triggerBlog();2055 }2056 2057 private function getCommentCursor($cur)2058 {2059 if ($cur->comment_content !== null && $cur->comment_content == '') {2060 throw new Exception(__('You must provide a comment'));2061 }2062 2063 if ($cur->comment_author !== null && $cur->comment_author == '') {2064 throw new Exception(__('You must provide an author name'));2065 }2066 2067 if ($cur->comment_email != '' && !text::isEmail($cur->comment_email)) {2068 throw new Exception(__('Email address is not valid.'));2069 }2070 2071 if ($cur->comment_site !== null && $cur->comment_site != '') {2072 if (!preg_match('|^http(s?)://|',$cur->comment_site)) {2073 $cur->comment_site = 'http://'.$cur->comment_site;2074 }2075 }2076 2077 if ($cur->comment_status === null) {2078 $cur->comment_status = (integer) $this->settings->system->comments_pub;2079 }2080 2081 # Words list2082 if ($cur->comment_content !== null)2083 {2084 $cur->comment_words = implode(' ',text::splitWords($cur->comment_content));2085 }2086 }2087 //@}2088 1652 } 2089 1653 ?> -
inc/core/class.dc.core.php
r706 r848 1141 1141 } 1142 1142 1143 /**1144 Inits <var>wiki2xhtml</var> property for simple blog comment (basic syntax).1145 */1146 public function initWikiSimpleComment()1147 {1148 $this->initWiki();1149 1150 $this->wiki2xhtml->setOpts(array(1151 'active_title' => 0,1152 'active_setext_title' => 0,1153 'active_hr' => 0,1154 'active_lists' => 0,1155 'active_quote' => 0,1156 'active_pre' => 0,1157 'active_empty' => 0,1158 'active_auto_br' => 1,1159 'active_auto_urls' => 1,1160 'active_urls' => 0,1161 'active_auto_img' => 0,1162 'active_img' => 0,1163 'active_anchor' => 0,1164 'active_em' => 0,1165 'active_strong' => 0,1166 'active_br' => 0,1167 'active_q' => 0,1168 'active_code' => 0,1169 'active_acronym' => 0,1170 'active_ins' => 0,1171 'active_del' => 0,1172 'active_footnotes' => 0,1173 'active_wikiwords' => 0,1174 'active_macros' => 0,1175 'parse_pre' => 0,1176 'active_fr_syntax' => 01177 ));1178 1179 # --BEHAVIOR-- coreInitWikiSimpleComment1180 $this->callBehavior('coreInitWikiSimpleComment',$this->wiki2xhtml);1181 }1182 1183 /**1184 Inits <var>wiki2xhtml</var> property for blog comment.1185 */1186 public function initWikiComment()1187 {1188 $this->initWiki();1189 1190 $this->wiki2xhtml->setOpts(array(1191 'active_title' => 0,1192 'active_setext_title' => 0,1193 'active_hr' => 0,1194 'active_lists' => 1,1195 'active_quote' => 0,1196 'active_pre' => 1,1197 'active_empty' => 0,1198 'active_auto_br' => 1,1199 'active_auto_urls' => 1,1200 'active_urls' => 1,1201 'active_auto_img' => 0,1202 'active_img' => 0,1203 'active_anchor' => 0,1204 'active_em' => 1,1205 'active_strong' => 1,1206 'active_br' => 1,1207 'active_q' => 1,1208 'active_code' => 1,1209 'active_acronym' => 1,1210 'active_ins' => 1,1211 'active_del' => 1,1212 'active_footnotes' => 0,1213 'active_wikiwords' => 0,1214 'active_macros' => 0,1215 'parse_pre' => 0,1216 'active_fr_syntax' => 01217 ));1218 1219 # --BEHAVIOR-- coreInitWikiComment1220 $this->callBehavior('coreInitWikiComment',$this->wiki2xhtml);1221 }1222 1223 1143 public function wikiPostLink($url,$content) 1224 1144 { … … 1269 1189 { 1270 1190 $defaults = array( 1271 array('allow_comments','boolean',true,1272 'Allow comments on blog'),1273 array('allow_trackbacks','boolean',true,1274 'Allow trackbacks on blog'),1275 1191 array('blog_timezone','string','Europe/London', 1276 1192 'Blog timezone'), 1277 array('comments_nofollow','boolean',true,1278 'Add rel="nofollow" to comments URLs'),1279 array('comments_pub','boolean',true,1280 'Publish comments immediately'),1281 array('comments_ttl','integer',0,1282 'Number of days to keep comments open (0 means no ttl)'),1283 1193 array('copyright_notice','string','','Copyright notice (simple text)'), 1284 1194 array('date_format','string','%A, %B %e %Y', … … 1306 1216 array('nb_post_per_feed','integer',20, 1307 1217 'Number of entries on feeds'), 1308 array('nb_comment_per_feed','integer',20,1309 'Number of comments on feeds'),1310 1218 array('post_url_format','string','{y}/{m}/{d}/{t}', 1311 1219 'Post URL format. {y}: year, {m}: month, {d}: day, {id}: post id, {t}: entry title'), … … 1330 1238 array('tpl_use_cache','boolean',true, 1331 1239 'Use template caching'), 1332 array('trackbacks_pub','boolean',true,1333 'Publish trackbacks immediately'),1334 array('trackbacks_ttl','integer',0,1335 'Number of days to keep trackbacks open (0 means no ttl)'),1336 1240 array('url_scan','string','query_string', 1337 1241 'URL handle mode (path_info or query_string)'), 1338 1242 array('use_smilies','boolean',false, 1339 1243 'Show smilies on entries and comments'), 1340 array('wiki_comments','boolean',false,1341 'Allow commenters to use a subset of wiki syntax')1342 1244 ); 1343 1245 } … … 1394 1296 1395 1297 /** 1396 Recreates comments search engine index.1397 1398 @param start <b>integer</b> Start comment index1399 @param limit <b>integer</b> Number of comments to index1400 1401 @return <b>integer</b> <var>$start</var> and <var>$limit</var> sum1402 */1403 public function indexAllComments($start=null,$limit=null)1404 {1405 $strReq = 'SELECT COUNT(comment_id) '.1406 'FROM '.$this->prefix.'comment';1407 $rs = $this->con->select($strReq);1408 $count = $rs->f(0);1409 1410 $strReq = 'SELECT comment_id, comment_content '.1411 'FROM '.$this->prefix.'comment ';1412 1413 if ($start !== null && $limit !== null) {1414 $strReq .= $this->con->limit($start,$limit);1415 }1416 1417 $rs = $this->con->select($strReq);1418 1419 $cur = $this->con->openCursor($this->prefix.'comment');1420 1421 while ($rs->fetch())1422 {1423 $cur->comment_words = implode(' ',text::splitWords($rs->comment_content));1424 $cur->update('WHERE comment_id = '.(integer) $rs->comment_id);1425 $cur->clean();1426 }1427 1428 if ($start+$limit > $count) {1429 return null;1430 }1431 return $start+$limit;1432 }1433 1434 /**1435 Reinits nb_comment and nb_trackback in post table.1436 */1437 public function countAllComments()1438 {1439 1440 $updCommentReq = 'UPDATE '.$this->prefix.'post P '.1441 'SET nb_comment = ('.1442 'SELECT COUNT(C.comment_id) from '.$this->prefix.'comment C '.1443 'WHERE C.post_id = P.post_id AND C.comment_trackback <> 1 '.1444 'AND C.comment_status = 1 '.1445 ')';1446 $updTrackbackReq = 'UPDATE '.$this->prefix.'post P '.1447 'SET nb_trackback = ('.1448 'SELECT COUNT(C.comment_id) from '.$this->prefix.'comment C '.1449 'WHERE C.post_id = P.post_id AND C.comment_trackback = 1 '.1450 'AND C.comment_status = 1 '.1451 ')';1452 $this->con->execute($updCommentReq);1453 $this->con->execute($updTrackbackReq);1454 }1455 1456 /**1457 1298 Empty templates cache directory 1458 1299 */ -
inc/core/class.dc.meta.php
r270 r848 247 247 248 248 /** 249 Retrieves comments to posts corresponding to given meta criteria.250 <b>$params</b> is an array taking the following optional parameters:251 - meta_id : get comments to posts having meta id252 - meta_type : get comments to posts having meta type253 254 @param params <b>array</b> Parameters255 @param count_only <b>boolean</b> Only counts results256 257 @return <b>record</b> the resulting comments record258 */259 public function getCommentsByMeta($params=array(),$count_only=false)260 {261 if (!isset($params['meta_id'])) {262 return null;263 }264 265 $params['from'] = ', '.$this->table.' META ';266 $params['sql'] = 'AND META.post_id = P.post_id ';267 $params['sql'] .= "AND META.meta_id = '".$this->con->escape($params['meta_id'])."' ";268 269 if (!empty($params['meta_type'])) {270 $params['sql'] .= "AND META.meta_type = '".$this->con->escape($params['meta_type'])."' ";271 unset($params['meta_type']);272 }273 274 return $this->core->blog->getComments($params,$count_only);275 }276 277 /**278 249 @deprecated since 2.2. Use getMetadata and computeMetaStats instead. 279 250 Generic-purpose metadata retrieval : gets metadatas according to given -
inc/core/class.dc.rs.extensions.php
r776 r848 117 117 118 118 /** 119 Returns whether comments are enabled on post.120 121 @param rs Invisible parameter122 @return <b>boolean</b>123 */124 public static function commentsActive($rs)125 {126 return127 $rs->core->blog->settings->system->allow_comments128 && $rs->post_open_comment129 && ($rs->core->blog->settings->system->comments_ttl == 0 ||130 time()-($rs->core->blog->settings->system->comments_ttl*86400) < $rs->getTS());131 }132 133 /**134 Returns whether trackbacks are enabled on post.135 136 @param rs Invisible parameter137 @return <b>boolean</b>138 */139 public static function trackbacksActive($rs)140 {141 return142 $rs->core->blog->settings->system->allow_trackbacks143 && $rs->post_open_tb144 && ($rs->core->blog->settings->system->trackbacks_ttl == 0 ||145 time()-($rs->core->blog->settings->system->trackbacks_ttl*86400) < $rs->getTS());146 }147 148 /**149 Returns whether post has at least one comment.150 151 @param rs Invisible parameter152 @return <b>boolean</b>153 */154 public static function hasComments($rs)155 {156 return $rs->nb_comment > 0;157 }158 159 /**160 Returns whether post has at least one trackbacks.161 162 @return <b>boolean</b>163 */164 public static function hasTrackbacks($rs)165 {166 return $rs->nb_trackback > 0;167 }168 169 /**170 119 Returns full post URL. 171 120 … … 361 310 362 311 return 'tag:'.$url['host'].','.$date_part.':'.$rs->post_id; 363 }364 365 /**366 Returns trackback RDF information block in HTML comment.367 368 @param rs Invisible parameter369 @return <b>string</b>370 */371 public static function getTrackbackData($rs)372 {373 return374 "<![CDATA[>\n".375 "<!--[\n".376 '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n".377 ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n".378 ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n".379 "<rdf:Description\n".380 ' rdf:about="'.$rs->getURL().'"'."\n".381 ' dc:identifier="'.$rs->getURL().'"'."\n".382 ' dc:title="'.htmlspecialchars($rs->post_title,ENT_COMPAT,'UTF-8').'"'."\n".383 ' trackback:ping="'.$rs->getTrackbackLink().'" />'."\n".384 "</rdf:RDF>\n".385 "<!]]><!---->\n";386 }387 388 /**389 Returns post trackback full URL.390 391 @param rs Invisible parameter392 @return <b>string</b>393 */394 public static function getTrackbackLink($rs)395 {396 return $rs->core->blog->url.$rs->core->url->getURLFor('trackback',$rs->post_id);397 312 } 398 313 … … 459 374 /** 460 375 @ingroup DC_CORE 461 @brief Dotclear comment record helpers.462 463 This class adds new methods to database comment results.464 You can call them on every record comming from dcBlog::getComments and similar465 methods.466 467 @warning You should not give the first argument (usualy $rs) of every described468 function.469 */470 class rsExtComment471 {472 /**473 Returns comment date with <var>$format</var> as formatting pattern. If474 format is empty, uses <var>date_format</var> blog setting.475 476 @param rs Invisible parameter477 @param format <b>string</b> Date format pattern478 @param type <b>string</b> (dt|upddt) defaults to comment_dt479 @return <b>string</b>480 */481 public static function getDate($rs,$format,$type='')482 {483 if (!$format) {484 $format = $rs->core->blog->settings->system->date_format;485 }486 487 if ($type == 'upddt') {488 return dt::dt2str($format,$rs->comment_upddt,$rs->comment_tz);489 } else {490 return dt::dt2str($format,$rs->comment_dt);491 }492 }493 494 /**495 Returns comment time with <var>$format</var> as formatting pattern. If496 format is empty, uses <var>time_format</var> blog setting.497 498 @param rs Invisible parameter499 @param format <b>string</b> Date format pattern500 @param type <b>string</b> (dt|upddt) defaults to comment_dt501 @return <b>string</b>502 */503 public static function getTime($rs,$format,$type='')504 {505 if (!$format) {506 $format = $rs->core->blog->settings->system->time_format;507 }508 509 if ($type == 'upddt') {510 return dt::dt2str($format,$rs->comment_updt,$rs->comment_tz);511 } else {512 return dt::dt2str($format,$rs->comment_dt);513 }514 }515 516 /**517 Returns comment timestamp.518 519 @param rs Invisible parameter520 @param type <b>string</b> (dt|upddt) defaults to comment_dt521 @return <b>integer</b>522 */523 public static function getTS($rs,$type='')524 {525 if ($type == 'upddt') {526 return strtotime($rs->comment_upddt);527 } else {528 return strtotime($rs->comment_dt);529 }530 }531 532 /**533 Returns comment date formating according to the ISO 8601 standard.534 535 @param rs Invisible parameter536 @param type <b>string</b> (dt|upddt) defaults to comment_dt537 @return <b>string</b>538 */539 public static function getISO8601Date($rs,$type='')540 {541 if ($type == 'upddt') {542 return dt::iso8601($rs->getTS($type)+dt::getTimeOffset($rs->comment_tz),$rs->comment_tz);543 } else {544 return dt::iso8601($rs->getTS(),$rs->comment_tz);545 }546 }547 548 /**549 Returns comment date formating according to RFC 822.550 551 @param rs Invisible parameter552 @param type <b>string</b> (dt|upddt) defaults to comment_dt553 @return <b>string</b>554 */555 public static function getRFC822Date($rs,$type='')556 {557 if ($type == 'upddt') {558 return dt::rfc822($rs->getTS($type)+dt::getTimeOffset($rs->comment_tz),$rs->comment_tz);559 } else {560 return dt::rfc822($rs->getTS(),$rs->comment_tz);561 }562 }563 564 /**565 Returns comment content. If <var>$absolute_urls</var> is true, appends full566 blog URL to each relative post URLs.567 568 @param rs Invisible parameter569 @param absolute_urls <b>boolean</b> With absolute URLs570 @return <b>string</b>571 */572 public static function getContent($rs,$absolute_urls=false)573 {574 $res = $rs->comment_content;575 576 if ($rs->core->blog->settings->system->comments_nofollow) {577 $res = preg_replace_callback('#<a(.*?href=".*?".*?)>#ms',array('self','noFollowURL'),$res);578 }579 580 if ($absolute_urls) {581 $res = html::absoluteURLs($res,$rs->getPostURL());582 }583 584 return $res;585 }586 587 private static function noFollowURL($m)588 {589 if (preg_match('/rel="nofollow"/',$m[1])) {590 return $m[0];591 }592 593 return '<a'.$m[1].' rel="nofollow">';594 }595 596 /**597 Returns comment author link to his website if he specified one.598 599 @param rs Invisible parameter600 @return <b>string</b>601 */602 public static function getAuthorURL($rs)603 {604 if (trim($rs->comment_site)) {605 return trim($rs->comment_site);606 }607 }608 609 /**610 Returns comment post full URL.611 612 @param rs Invisible parameter613 @return <b>string</b>614 */615 public static function getPostURL($rs)616 {617 return $rs->core->blog->url.$rs->core->getPostPublicURL(618 $rs->post_type,html::sanitizeURL($rs->post_url)619 );620 }621 622 /**623 Returns comment author name in a link to his website if he specified one.624 625 @param rs Invisible parameter626 @return <b>string</b>627 */628 public static function getAuthorLink($rs)629 {630 $res = '%1$s';631 $url = $rs->getAuthorURL();632 if ($url) {633 $res = '<a href="%2$s"%3$s>%1$s</a>';634 }635 636 $nofollow = '';637 if ($rs->core->blog->settings->system->comments_nofollow) {638 $nofollow = ' rel="nofollow"';639 }640 641 return sprintf($res,html::escapeHTML($rs->comment_author),html::escapeHTML($url),$nofollow);642 }643 644 /**645 Returns comment author e-mail address. If <var>$encoded</var> is true,646 "@" sign is replaced by "%40" and "." by "%2e".647 648 @param rs Invisible parameter649 @param encoded <b>boolean</b> Encode address.650 @return <b>string</b>651 */652 public static function getEmail($rs,$encoded=true)653 {654 if ($encoded) {655 return strtr($rs->comment_email,array('@'=>'%40','.'=>'%2e'));656 }657 return $rs->comment_email;658 }659 660 /**661 Returns trackback site title if comment is a trackback.662 663 @param rs Invisible parameter664 @return <b>string</b>665 */666 public static function getTrackbackTitle($rs)667 {668 if ($rs->comment_trackback == 1 &&669 preg_match('|<p><strong>(.*?)</strong></p>|msU',$rs->comment_content,670 $match)) {671 return html::decodeEntities($match[1]);672 }673 }674 675 /**676 Returns trackback content if comment is a trackback.677 678 @param rs Invisible parameter679 @return <b>string</b>680 */681 public static function getTrackbackContent($rs)682 {683 if ($rs->comment_trackback == 1) {684 return preg_replace('|<p><strong>.*?</strong></p>|msU','',685 $rs->comment_content);686 }687 }688 689 /**690 Returns comment feed unique ID.691 692 @param rs Invisible parameter693 @return <b>string</b>694 */695 public static function getFeedID($rs)696 {697 return 'urn:md5:'.md5($rs->core->blog->uid.$rs->comment_id);698 699 $url = parse_url($rs->core->blog->url);700 $date_part = date('Y-m-d',strtotime($rs->comment_dt));701 702 return 'tag:'.$url['host'].','.$date_part.':'.$rs->comment_id;703 }704 705 /**706 Returns whether comment is from the post author.707 708 @param rs Invisible parameter709 @return <b>boolean</b>710 */711 public static function isMe($rs)712 {713 return714 $rs->comment_email && $rs->comment_site &&715 $rs->comment_email == $rs->user_email &&716 $rs->comment_site == $rs->user_url;717 }718 }719 720 /**721 @ingroup DC_CORE722 376 @brief Dotclear dates record helpers. 723 377 -
inc/core/class.dc.xmlrpc.php
r776 r848 187 187 'Update blog options'); 188 188 189 $this->addCallback('wp.getComment',array($this,'wp_getComment'),190 array('struct','integer','string','string','integer'),191 "Gets a comment, given it's comment ID.");192 193 $this->addCallback('wp.getCommentCount',array($this,'wp_getCommentCount'),194 array('array','integer','string','string','integer'),195 'Retrieve comment count.');196 197 $this->addCallback('wp.getComments',array($this,'wp_getComments'),198 array('array','integer','string','string','struct'),199 'Gets a set of comments for a given post.');200 201 $this->addCallback('wp.deleteComment',array($this,'wp_deleteComment'),202 array('boolean','integer','string','string','integer'),203 'Delete a comment with given ID.');204 205 $this->addCallback('wp.editComment',array($this,'wp_editComment'),206 array('boolean','integer','string','string','integer','struct'),207 'Edit a comment with given ID.');208 209 $this->addCallback('wp.newComment',array($this,'wp_newComment'),210 array('integer','integer','string','string','integer','struct'),211 'Create a new comment for a given post ID.');212 213 $this->addCallback('wp.getCommentStatusList',array($this,'wp_getCommentStatusList'),214 array('array','integer','string','string'),215 'Retrieve all of the comment statuses.');216 189 } 217 190 … … 335 308 $description = !empty($struct['description']) ? $struct['description'] : null; 336 309 $dateCreated = !empty($struct['dateCreated']) ? $struct['dateCreated'] : null; 337 $open_comment = isset($struct['mt_allow_comments']) ? $struct['mt_allow_comments'] : 1;338 $open_tb = isset($struct['mt_allow_pings']) ? $struct['mt_allow_pings'] : 1;339 310 340 311 if ($description !== null) { … … 362 333 $cur->post_content_xhtml = $content_xhtml; 363 334 $cur->post_excerpt_xhtml = $excerpt_xhtml; 364 $cur->post_open_comment = (integer) ($open_comment == 1);365 $cur->post_open_tb = (integer) ($open_tb == 1);366 335 $cur->post_status = (integer) $publish; 367 336 $cur->post_format = 'xhtml'; … … 440 409 $description = (!empty($struct['description'])) ? $struct['description'] : null; 441 410 $dateCreated = !empty($struct['dateCreated']) ? $struct['dateCreated'] : null; 442 $open_comment = (isset($struct['mt_allow_comments'])) ? $struct['mt_allow_comments'] : 1;443 $open_tb = (isset($struct['mt_allow_pings'])) ? $struct['mt_allow_pings'] : 1;444 411 445 412 if ($description !== null) { … … 466 433 $cur->post_content_xhtml = $content_xhtml; 467 434 $cur->post_excerpt_xhtml = $excerpt_xhtml; 468 $cur->post_open_comment = (integer) ($open_comment == 1);469 $cur->post_open_tb = (integer) ($open_tb == 1);470 435 $cur->post_status = (integer) $publish; 471 436 $cur->post_format = 'xhtml'; … … 557 522 $res['mt_excerpt'] = $post->post_excerpt_xhtml; 558 523 $res['mt_text_more'] = ''; 559 $res['mt_allow_comments'] = (integer) $post->post_open_comment;560 $res['mt_allow_pings'] = (integer) $post->post_open_tb;561 524 $res['mt_convert_breaks'] = ''; 562 525 $res['mt_keywords'] = ''; … … 621 584 $tres['mt_excerpt'] = $posts->post_excerpt_xhtml; 622 585 $tres['mt_text_more'] = ''; 623 $tres['mt_allow_comments'] = (integer) $posts->post_open_comment;624 $tres['mt_allow_pings'] = (integer) $posts->post_open_tb;625 586 $tres['mt_convert_breaks'] = ''; 626 587 $tres['mt_keywords'] = ''; … … 832 793 } 833 794 834 private function translateWpCommentstatus($s)835 {836 $status = array(837 'hold' => -1,838 'approve' => 0,839 'spam' => -2840 );841 842 if (is_int($s)) {843 $status = array_flip($status);844 return isset($status[$s]) ? $status[$s] : $status[0];845 } else {846 return isset($status[$s]) ? $status[$s] : $status['approve'];847 }848 }849 795 850 796 private function translateWpOptions($options=array()) … … 986 932 "excerpt" => $posts->post_excerpt_xhtml, 987 933 "text_more" => '', 988 "mt_allow_comments" => (integer) $posts->post_open_comment,989 "mt_allow_pings" => (integer) $posts->post_open_tb,990 934 "wp_slug" => $posts->post_url, 991 935 "wp_password" => $posts->post_password, … … 1159 1103 } 1160 1104 return $res; 1161 }1162 1163 private function countComments($user,$pwd,$post_id)1164 {1165 $this->setUser($user,$pwd);1166 $this->setBlog();1167 1168 $res = array(1169 'approved' => 0,1170 'awaiting_moderation' => 0,1171 'spam' => 0,1172 'total' => 01173 );1174 $rs = $this->core->blog->getComments(array('post_id' => $post_id));1175 1176 while ($rs->fetch()) {1177 $res['total']++;1178 if ($rs->comment_status == 1) {1179 $res['approved']++;1180 } elseif ($rs->comment_status == -2) {1181 $res['spam']++;1182 } else {1183 $res['awaiting_moderation']++;1184 }1185 }1186 return $res;1187 }1188 1189 private function getComments($user,$pwd,$struct,$id=null)1190 {1191 $this->setUser($user,$pwd);1192 $this->setBlog();1193 1194 $params = array();1195 1196 if (!empty($struct['status'])) {1197 $params['comment_status'] = $this->translateWpCommentstatus($struct['status']);1198 }1199 1200 if (!empty($struct['post_id'])) {1201 $params['post_id'] = (integer) $struct['post_id'];1202 }1203 1204 if (isset($id)) {1205 $params['comment_id'] = $id;1206 }1207 1208 $offset = !empty($struct['offset']) ? (integer) $struct['offset'] : 0;1209 $limit = !empty($struct['number']) ? (integer) $struct['number'] : 10;1210 $params['limit'] = array($offset,$limit);1211 1212 $rs = $this->core->blog->getComments($params);1213 $res = array();1214 while ($rs->fetch())1215 {1216 $res[] = array(1217 'date_created_gmt' => new xmlrpcDate($rs->getTS()),1218 'user_id' => $rs->user_id,1219 'comment_id' => $rs->comment_id,1220 'parent' => 0,1221 'status' => $this->translateWpCommentstatus((integer) $rs->comment_status),1222 'content' => $rs->comment_content,1223 'link' => $rs->getPostURL().'#c'.$rs->comment_id,1224 'post_id' => $rs->post_id,1225 'post_title' => $rs->post_title,1226 'author' => $rs->comment_author,1227 'author_url' => $rs->comment_site,1228 'author_email' => $rs->comment_email,1229 'author_ip' => $rs->comment_ip1230 );1231 }1232 return $res;1233 }1234 1235 private function addComment($user,$pwd,$post_id,$struct)1236 {1237 $this->setUser($user,$pwd);1238 $this->setBlog();1239 1240 if (empty($struct['content'])) {1241 throw new Exception('Sorry, you cannot post an empty comment',401);1242 }1243 1244 if (is_numeric($post_id)) {1245 $p['post_id'] = $post_id;1246 } else {1247 $p['post_url'] = $post_id;1248 }1249 $rs = $this->core->blog->getPosts($p);1250 if ($rs->isEmpty()) {1251 throw new Exception('Sorry, no such post.',404);1252 }1253 1254 $cur = $this->core->con->openCursor($this->core->prefix.'comment');1255 1256 $cur->comment_author = $this->core->auth->getInfo('user_cn');1257 $cur->comment_email = $this->core->auth->getInfo('user_email');1258 $cur->comment_site = $this->core->auth->getInfo('user_url');1259 1260 $cur->comment_content = $struct['content'];1261 $cur->post_id = (integer) $post_id;1262 1263 $id = $this->core->blog->addComment($cur);1264 return $id;1265 }1266 1267 private function updComment($user,$pwd,$comment_id,$struct)1268 {1269 $this->setUser($user,$pwd);1270 $this->setBlog();1271 1272 $cur = $this->core->con->openCursor($this->core->prefix.'comment');1273 1274 if (isset($struct['status'])) {1275 $cur->comment_status = $this->translateWpCommentstatus($struct['status']);1276 }1277 1278 if (isset($struct['date_created_gmt'])) {1279 if ($struct['date_created_gmt'] instanceof xmlrpcDate) {1280 $cur->comment_dt = date('Y-m-d H:i:00',$struct['date_created_gmt']->getTimestamp());1281 } elseif (is_string($struct['date_created_gmt']) && @strtotime($struct['date_created_gmt'])) {1282 $cur->comment_dt = date('Y-m-d H:i:00',strtotime($struct['date_created_gmt']));1283 }1284 $cur->comment_dt = $struct['date_created_gmt'];1285 }1286 1287 if (isset($struct['content'])) {1288 $cur->comment_content = $struct['content'];1289 }1290 1291 if (isset($struct['author'])) {1292 $cur->comment_author = $struct['author'];1293 }1294 1295 if (isset($struct['author_url'])) {1296 $cur->comment_site = $struct['author_url'];1297 }1298 1299 if (isset($struct['author_email'])) {1300 $cur->comment_email = $struct['author_email'];1301 }1302 1303 $this->core->blog->updComment($comment_id,$cur);1304 return true;1305 }1306 1307 private function delComment($user,$pwd,$comment_id)1308 {1309 $this->setUser($user,$pwd);1310 $this->setBlog();1311 1312 $this->core->blog->delComment($comment_id);1313 return true;1314 1105 } 1315 1106 … … 1582 1373 } 1583 1374 1584 public function wp_getComment($blogid,$username,$password,$commentid)1585 {1586 $res = $this->getComments($username,$password,array(),$commentid);1587 1588 if (empty($res)) {1589 throw new Exception('Sorry, no such comment',404);1590 }1591 1592 return $res[0];1593 }1594 1595 public function wp_getCommentCount($blogid,$username,$password,$postid)1596 {1597 return $this->countComments($username,$password,$postid);1598 }1599 1600 public function wp_getComments($blogid,$username,$password,$struct)1601 {1602 return $this->getComments($username,$password,$struct);1603 }1604 1605 public function wp_deleteComment($blogid,$username,$password,$commentid)1606 {1607 return $this->delComment($username,$password,$commentid);1608 }1609 1610 public function wp_editComment($blogid,$username,$password,$commentid,$content)1611 {1612 return $this->updComment($username,$password,$commentid,$content);1613 }1614 1615 public function wp_newComment($blogid,$username,$password,$postid,$content)1616 {1617 return $this->addComment($username,$password,$postid,$content);1618 }1619 1620 public function wp_getCommentStatusList($blogid,$username,$password)1621 {1622 $this->setUser($username,$password);1623 $this->setBlog();1624 1625 return array(1626 'hold' => 'Unapproved',1627 'approve' => 'Approved',1628 'spam' => 'Spam'1629 );1630 }1631 1375 } 1632 1376 ?> -
inc/dbschema/db-schema.php
r407 r848 123 123 ->post_selected ('smallint', 0, false, 0) 124 124 ->post_position ('integer', 0, false, 0) 125 ->post_open_comment ('smallint', 0, false, 0)126 ->post_open_tb ('smallint', 0, false, 0)127 ->nb_comment ('integer', 0, false, 0)128 ->nb_trackback ('integer', 0, false, 0)129 130 125 ->primary('pk_post','post_id') 131 126 … … 174 169 175 170 ->primary('pk_version','module') 176 ;177 178 $_s->ping179 ->post_id ('bigint', 0, false)180 ->ping_url ('varchar', 255, false)181 ->ping_dt ('timestamp', 0, false, 'now()')182 183 ->primary('pk_ping','post_id','ping_url')184 ;185 186 $_s->comment187 ->comment_id ('bigint', 0, false)188 ->post_id ('bigint', 0, false)189 ->comment_dt ('timestamp', 0, false, 'now()')190 ->comment_tz ('varchar', 128, false, "'UTC'")191 ->comment_upddt ('timestamp', 0, false, 'now()')192 ->comment_author ('varchar', 255, true, null)193 ->comment_email ('varchar', 255, true, null)194 ->comment_site ('varchar', 255, true, null)195 ->comment_content ('text', 0, true)196 ->comment_words ('text', 0, true, null)197 ->comment_ip ('varchar', 39, true, null)198 ->comment_status ('smallint', 0, true, 0)199 ->comment_spam_status ('varchar', 128, true, 0)200 ->comment_spam_filter ('varchar', 32, true, null)201 ->comment_trackback ('smallint', 0, false, 0)202 203 ->primary('pk_comment','comment_id')204 171 ; 205 172 … … 238 205 $_s->post_media->index ('idx_post_media_media_id', 'btree', 'media_id'); 239 206 $_s->log->index ('idx_log_user_id', 'btree', 'user_id'); 240 $_s->comment->index ('idx_comment_post_id', 'btree', 'post_id');241 207 $_s->meta->index ('idx_meta_post_id', 'btree','post_id'); 242 208 $_s->meta->index ('idx_meta_meta_type', 'btree','meta_type'); … … 245 211 /* Performance indexes 246 212 -------------------------------------------------------- */ 247 $_s->comment->index ('idx_comment_post_id_dt_status', 'btree', 'post_id', 'comment_dt', 'comment_status');248 213 $_s->post->index ('idx_post_post_dt', 'btree', 'post_dt'); 249 214 $_s->post->index ('idx_post_post_dt_post_id', 'btree', 'post_dt','post_id'); … … 266 231 $_s->post_media->reference('fk_media','media_id','media','media_id','cascade','cascade'); 267 232 $_s->post_media->reference('fk_media_post','post_id','post','post_id','cascade','cascade'); 268 $_s->ping->reference('fk_ping_post','post_id','post','post_id','cascade','cascade');269 $_s->comment->reference('fk_comment_post','post_id','post','post_id','cascade','cascade');270 233 $_s->log->reference('fk_log_blog','blog_id','blog','blog_id','cascade','set null'); 271 234 $_s->meta->reference('fk_meta_post','post_id','post','post_id','cascade','cascade'); -
inc/dbschema/upgrade.php
r706 r848 154 154 $init_fav['posts'] = array('posts','Entries','posts.php', 155 155 'images/menu/entries.png','images/menu/entries-b.png', 156 'usage,contentadmin',null,null);157 $init_fav['comments'] = array('comments','Comments','comments.php',158 'images/menu/comments.png','images/menu/comments-b.png',159 156 'usage,contentadmin',null,null); 160 157 $init_fav['prefs'] = array('prefs','My preferences','preferences.php', -
inc/prepend.php
r801 r848 39 39 $__autoload['dcNamespace'] = dirname(__FILE__).'/core/class.dc.namespace.php'; 40 40 $__autoload['dcSettings'] = dirname(__FILE__).'/core/class.dc.settings.php'; 41 $__autoload['dcTrackback'] = dirname(__FILE__).'/core/class.dc.trackback.php';42 41 $__autoload['dcUpdate'] = dirname(__FILE__).'/core/class.dc.update.php'; 43 42 $__autoload['dcUtils'] = dirname(__FILE__).'/core/class.dc.utils.php'; … … 48 47 49 48 $__autoload['rsExtPost'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 50 $__autoload['rsExtComment'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php';51 49 $__autoload['rsExtDates'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 52 50 $__autoload['rsExtUser'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; … … 57 55 $__autoload['adminPostList'] = dirname(__FILE__).'/admin/lib.pager.php'; 58 56 $__autoload['adminPostMiniList'] = dirname(__FILE__).'/admin/lib.pager.php'; 59 $__autoload['adminCommentList'] = dirname(__FILE__).'/admin/lib.pager.php';60 57 $__autoload['adminUserList'] = dirname(__FILE__).'/admin/lib.pager.php'; 61 58 … … 209 206 210 207 $core->url->register('feed','feed','^feed/(.+)$',array('dcUrlHandlers','feed')); 211 $core->url->register('trackback','trackback','^trackback/(.+)$',array('dcUrlHandlers','trackback'));212 208 $core->url->register('rsd','rsd','^rsd$',array('dcUrlHandlers','rsd')); 213 209 $core->url->register('xmlrpc','xmlrpc','^xmlrpc/(.+)$',array('dcUrlHandlers','xmlrpc')); -
inc/public/class.dc.template.php
r833 r848 32 32 $this->core =& $core; 33 33 34 # Transitional tags35 $this->addValue('EntryTrackbackCount',array($this,'EntryPingCount'));36 $this->addValue('EntryTrackbackData',array($this,'EntryPingData'));37 $this->addValue('EntryTrackbackLink',array($this,'EntryPingLink'));38 39 34 # l10n 40 35 $this->addValue('lang',array($this,'l10n')); … … 85 80 $this->addValue('CategoryDescription',array($this,'CategoryDescription')); 86 81 $this->addValue('CategoryTitle',array($this,'CategoryTitle')); 87 88 # Comments89 $this->addBlock('Comments',array($this,'Comments'));90 $this->addValue('CommentAuthor',array($this,'CommentAuthor'));91 $this->addValue('CommentAuthorDomain',array($this,'CommentAuthorDomain'));92 $this->addValue('CommentAuthorLink',array($this,'CommentAuthorLink'));93 $this->addValue('CommentAuthorMailMD5',array($this,'CommentAuthorMailMD5'));94 $this->addValue('CommentAuthorURL',array($this,'CommentAuthorURL'));95 $this->addValue('CommentContent',array($this,'CommentContent'));96 $this->addValue('CommentDate',array($this,'CommentDate'));97 $this->addValue('CommentTime',array($this,'CommentTime'));98 $this->addValue('CommentEmail',array($this,'CommentEmail'));99 $this->addValue('CommentEntryTitle',array($this,'CommentEntryTitle'));100 $this->addValue('CommentFeedID',array($this,'CommentFeedID'));101 $this->addValue('CommentID',array($this,'CommentID'));102 $this->addBlock('CommentIf',array($this,'CommentIf'));103 $this->addValue('CommentIfFirst',array($this,'CommentIfFirst'));104 $this->addValue('CommentIfMe',array($this,'CommentIfMe'));105 $this->addValue('CommentIfOdd',array($this,'CommentIfOdd'));106 $this->addValue('CommentIP',array($this,'CommentIP'));107 $this->addValue('CommentOrderNumber',array($this,'CommentOrderNumber'));108 $this->addBlock('CommentsFooter',array($this,'CommentsFooter'));109 $this->addBlock('CommentsHeader',array($this,'CommentsHeader'));110 $this->addValue('CommentPostURL',array($this,'CommentPostURL'));111 $this->addBlock('IfCommentAuthorEmail',array($this,'IfCommentAuthorEmail'));112 $this->addValue('CommentHelp',array($this,'CommentHelp'));113 114 # Comment preview115 $this->addBlock('IfCommentPreview',array($this,'IfCommentPreview'));116 $this->addValue('CommentPreviewName',array($this,'CommentPreviewName'));117 $this->addValue('CommentPreviewEmail',array($this,'CommentPreviewEmail'));118 $this->addValue('CommentPreviewSite',array($this,'CommentPreviewSite'));119 $this->addValue('CommentPreviewContent',array($this,'CommentPreviewContent'));120 $this->addValue('CommentPreviewCheckRemember',array($this,'CommentPreviewCheckRemember'));121 82 122 83 # Entries … … 139 100 $this->addValue('EntryCategoryURL',array($this,'EntryCategoryURL')); 140 101 $this->addValue('EntryCategoryShortURL',array($this,'EntryCategoryShortURL')); 141 $this->addValue('EntryCommentCount',array($this,'EntryCommentCount'));142 102 $this->addValue('EntryContent',array($this,'EntryContent')); 143 103 $this->addValue('EntryDate',array($this,'EntryDate')); … … 151 111 $this->addValue('EntryLang',array($this,'EntryLang')); 152 112 $this->addBlock('EntryNext',array($this,'EntryNext')); 153 $this->addValue('EntryPingCount',array($this,'EntryPingCount'));154 $this->addValue('EntryPingData',array($this,'EntryPingData'));155 $this->addValue('EntryPingLink',array($this,'EntryPingLink'));156 113 $this->addBlock('EntryPrevious',array($this,'EntryPrevious')); 157 114 $this->addValue('EntryTitle',array($this,'EntryTitle')); … … 174 131 $this->addValue('PaginationURL',array($this,'PaginationURL')); 175 132 176 # Trackbacks177 $this->addValue('PingBlogName',array($this,'PingBlogName'));178 $this->addValue('PingContent',array($this,'PingContent'));179 $this->addValue('PingDate',array($this,'PingDate'));180 $this->addValue('PingEntryTitle',array($this,'PingEntryTitle'));181 $this->addValue('PingFeedID',array($this,'PingFeedID'));182 $this->addValue('PingID',array($this,'PingID'));183 $this->addValue('PingIfFirst',array($this,'PingIfFirst'));184 $this->addValue('PingIfOdd',array($this,'PingIfOdd'));185 $this->addValue('PingIP',array($this,'PingIP'));186 $this->addValue('PingNoFollow',array($this,'PingNoFollow'));187 $this->addValue('PingOrderNumber',array($this,'PingOrderNumber'));188 $this->addValue('PingPostURL',array($this,'PingPostURL'));189 $this->addBlock('Pings',array($this,'Pings'));190 $this->addBlock('PingsFooter',array($this,'PingsFooter'));191 $this->addBlock('PingsHeader',array($this,'PingsHeader'));192 $this->addValue('PingTime',array($this,'PingTime'));193 $this->addValue('PingTitle',array($this,'PingTitle'));194 $this->addValue('PingAuthorURL',array($this,'PingAuthorURL'));195 196 133 # System 197 134 $this->addValue('SysBehavior',array($this,'SysBehavior')); 198 135 $this->addBlock('SysIf',array($this,'SysIf')); 199 $this->addBlock('SysIfCommentPublished',array($this,'SysIfCommentPublished'));200 $this->addBlock('SysIfCommentPending',array($this,'SysIfCommentPending'));201 136 $this->addBlock('SysIfFormError',array($this,'SysIfFormError')); 202 137 $this->addValue('SysFeedSubtitle',array($this,'SysFeedSubtitle')); … … 430 365 'date' => 'post_dt', 431 366 'id' => 'post_id', 432 'comment' => 'nb_comment',433 'trackback' => 'nb_trackback'434 ),435 'comment' => array(436 'author' => 'comment_author',437 'date' => 'comment_dt',438 'id' => 'comment_id'439 367 ) 440 368 ); … … 1265 1193 has_category (0|1) #IMPLIED -- post has a category (value : 1) or not (value : 0) 1266 1194 has_attachment (0|1) #IMPLIED -- post has attachments (value : 1) or not (value : 0) (see Attachment plugin for code) 1267 comments_active (0|1) #IMPLIED -- comments are active for this post (value : 1) or not (value : 0)1268 pings_active (0|1) #IMPLIED -- trackbacks are active for this post (value : 1) or not (value : 0)1269 show_comments (0|1) #IMPLIED -- there are comments for this post (value : 1) or not (value : 0)1270 show_pings (0|1) #IMPLIED -- there are trackbacks for this post (value : 1) or not (value : 0)1271 1195 operator (and|or) #IMPLIED -- combination of conditions, if more than 1 specifiec (default: and) 1272 1196 url CDATA #IMPLIED -- post has given url … … 1332 1256 } 1333 1257 1334 if (isset($attr['comments_active'])) {1335 $sign = (boolean) $attr['comments_active'] ? '' : '!';1336 $if[] = $sign.'$_ctx->posts->commentsActive()';1337 }1338 1339 if (isset($attr['pings_active'])) {1340 $sign = (boolean) $attr['pings_active'] ? '' : '!';1341 $if[] = $sign.'$_ctx->posts->trackbacksActive()';1342 }1343 1344 if (isset($attr['has_comment'])) {1345 $sign = (boolean) $attr['has_comment'] ? '' : '!';1346 $if[] = $sign.'$_ctx->posts->hasComments()';1347 }1348 1349 if (isset($attr['has_ping'])) {1350 $sign = (boolean) $attr['has_ping'] ? '' : '!';1351 $if[] = $sign.'$_ctx->posts->hasTrackbacks()';1352 }1353 1354 if (isset($attr['show_comments'])) {1355 if ((boolean) $attr['show_comments']) {1356 $if[] = '($_ctx->posts->hasComments() || $_ctx->posts->commentsActive())';1357 } else {1358 $if[] = '(!$_ctx->posts->hasComments() && !$_ctx->posts->commentsActive())';1359 }1360 }1361 1362 if (isset($attr['show_pings'])) {1363 if ((boolean) $attr['show_pings']) {1364 $if[] = '($_ctx->posts->hasTrackbacks() || $_ctx->posts->trackbacksActive())';1365 } else {1366 $if[] = '(!$_ctx->posts->hasTrackbacks() && !$_ctx->posts->trackbacksActive())';1367 }1368 }1369 1370 1258 $this->core->callBehavior('tplIfConditions','EntryIf',$attr,$content,$if); 1371 1259 1372 1260 if (count($if) != 0) { 1373 1261 return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; 1374 } else { 1262 } /* 1263 else { 1264 // Nothing in if statement => do not display content... 1375 1265 return $content; 1376 1266 } 1267 */ 1377 1268 } 1378 1269 … … 1776 1667 } 1777 1668 1778 /*dtd1779 <!ELEMENT tpl:EntryCommentCount - O -- Number of comments for entry -->1780 <!ATTLIST tpl:EntryCommentCount1781 none CDATA #IMPLIED -- text to display for "no comment" (default: no comment)1782 one CDATA #IMPLIED -- text to display for "one comment" (default: one comment)1783 more CDATA #IMPLIED -- text to display for "more comments" (default: %s comments, %s is replaced by the number of comment)1784 count_all CDATA #IMPLIED -- count comments and trackbacks1785 >1786 */1787 public function EntryCommentCount($attr)1788 {1789 $none = 'no comment';1790 $one = 'one comment';1791 $more = '%d comments';1792 1793 if (isset($attr['none'])) {1794 $none = addslashes($attr['none']);1795 }1796 if (isset($attr['one'])) {1797 $one = addslashes($attr['one']);1798 }1799 if (isset($attr['more'])) {1800 $more = addslashes($attr['more']);1801 }1802 1803 if (empty($attr['count_all'])) {1804 $operation = '$_ctx->posts->nb_comment';1805 } else {1806 $operation = '($_ctx->posts->nb_comment + $_ctx->posts->nb_trackback)';1807 }1808 1809 return1810 "<?php if (".$operation." == 0) {\n".1811 " printf(__('".$none."'),".$operation.");\n".1812 "} elseif (".$operation." == 1) {\n".1813 " printf(__('".$one."'),".$operation.");\n".1814 "} else {\n".1815 " printf(__('".$more."'),".$operation.");\n".1816 "} ?>";1817 }1818 1819 /*dtd1820 <!ELEMENT tpl:EntryPingCount - O -- Number of trackbacks for entry -->1821 <!ATTLIST tpl:EntryPingCount1822 none CDATA #IMPLIED -- text to display for "no ping" (default: no ping)1823 one CDATA #IMPLIED -- text to display for "one ping" (default: one ping)1824 more CDATA #IMPLIED -- text to display for "more pings" (default: %s trackbacks, %s is replaced by the number of pings)1825 >1826 */1827 public function EntryPingCount($attr)1828 {1829 $none = 'no trackback';1830 $one = 'one trackback';1831 $more = '%d trackbacks';1832 1833 if (isset($attr['none'])) {1834 $none = addslashes($attr['none']);1835 }1836 if (isset($attr['one'])) {1837 $one = addslashes($attr['one']);1838 }1839 if (isset($attr['more'])) {1840 $more = addslashes($attr['more']);1841 }1842 1843 return1844 "<?php if (\$_ctx->posts->nb_trackback == 0) {\n".1845 " printf(__('".$none."'),(integer) \$_ctx->posts->nb_trackback);\n".1846 "} elseif (\$_ctx->posts->nb_trackback == 1) {\n".1847 " printf(__('".$one."'),(integer) \$_ctx->posts->nb_trackback);\n".1848 "} else {\n".1849 " printf(__('".$more."'),(integer) \$_ctx->posts->nb_trackback);\n".1850 "} ?>";1851 }1852 1853 /*dtd1854 <!ELEMENT tpl:EntryPingData - O -- Display trackback RDF information -->1855 */1856 public function EntryPingData($attr)1857 {1858 return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackData(); } ?>\n";1859 }1860 1861 /*dtd1862 <!ELEMENT tpl:EntryPingLink - O -- Entry trackback link -->1863 */1864 public function EntryPingLink($attr)1865 {1866 return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackLink(); } ?>\n";1867 }1868 1869 1669 /* Languages -------------------------------------- */ 1870 1670 /*dtd … … 2052 1852 $f = $this->getFilters($attr); 2053 1853 return '<?php echo '.sprintf($f,"context::PaginationURL(".$offset.")").'; ?>'; 2054 }2055 2056 /* Comments --------------------------------------- */2057 /*dtd2058 <!ELEMENT tpl:Comments - - -- Comments container -->2059 <!ATTLIST tpl:Comments2060 with_pings (0|1) #IMPLIED -- include trackbacks in request2061 lastn CDATA #IMPLIED -- restrict the number of entries2062 no_context (1|0) #IMPLIED -- Override context information2063 sortby (title|selected|author|date|id) #IMPLIED -- specify comments sort criteria (default : date) (multiple comma-separated sortby can be specified. Use "?asc" or "?desc" as suffix to provide an order for each sorby)2064 order (desc|asc) #IMPLIED -- result ordering (default: asc)2065 age CDATA #IMPLIED -- retrieve comments by maximum age (ex: -2 days, last month, last week)2066 >2067 */2068 public function Comments($attr,$content)2069 {2070 $p = "";2071 if (empty($attr['with_pings'])) {2072 $p .= "\$params['comment_trackback'] = false;\n";2073 }2074 2075 $lastn = 0;2076 if (isset($attr['lastn'])) {2077 $lastn = abs((integer) $attr['lastn'])+0;2078 }2079 2080 if ($lastn > 0) {2081 $p .= "\$params['limit'] = ".$lastn.";\n";2082 } else {2083 $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n";2084 }2085 2086 if (empty($attr['no_context']))2087 {2088 $p .=2089 "if (\$_ctx->posts !== null) { ".2090 "\$params['post_id'] = \$_ctx->posts->post_id; ".2091 "\$core->blog->withoutPassword(false);\n".2092 "}\n";2093 $p .=2094 'if ($_ctx->exists("categories")) { '.2095 "\$params['cat_id'] = \$_ctx->categories->cat_id; ".2096 "}\n";2097 2098 $p .=2099 'if ($_ctx->exists("langs")) { '.2100 "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ".2101 "}\n";2102 }2103 2104 if (!isset($attr['order'])) {2105 $attr['order'] = 'asc';2106 }2107 2108 $p .= "\$params['order'] = '".$this->getSortByStr($attr,'comment')."';\n";2109 2110 if (isset($attr['no_content']) && $attr['no_content']) {2111 $p .= "\$params['no_content'] = true;\n";2112 }2113 2114 if (isset($attr['age'])) {2115 $age = $this->getAge($attr);2116 $p .= !empty($age) ? "@\$params['sql'] .= ' AND P.post_dt > \'".$age."\'';\n" : '';2117 }2118 2119 $res = "<?php\n";2120 $res .= $this->core->callBehavior("templatePrepareParams",2121 array("tag" => "Comments","method" => "blog::getComments"),2122 $attr,$content);2123 $res .= $p;2124 $res .= '$_ctx->comments = $core->blog->getComments($params); unset($params);'."\n";2125 $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n";2126 2127 if (!empty($attr['with_pings'])) {2128 $res .= '$_ctx->pings = $_ctx->comments;'."\n";2129 }2130 2131 $res .= "?>\n";2132 2133 $res .=2134 '<?php while ($_ctx->comments->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->comments = null; ?>';2135 2136 return $res;2137 }2138 2139 /*dtd2140 <!ELEMENT tpl:CommentAuthor - O -- Comment author -->2141 */2142 public function CommentAuthor($attr)2143 {2144 $f = $this->getFilters($attr);2145 return '<?php echo '.sprintf($f,"\$_ctx->comments->comment_author").'; ?>';2146 }2147 2148 /*dtd2149 <!ELEMENT tpl:CommentAuthorDomain - O -- Comment author website domain -->2150 */2151 public function CommentAuthorDomain($attr)2152 {2153 return '<?php echo preg_replace("#^http(?:s?)://(.+?)/.*$#msu",\'$1\',$_ctx->comments->comment_site); ?>';2154 }2155 2156 /*dtd2157 <!ELEMENT tpl:CommentAuthorLink - O -- Comment author link -->2158 */2159 public function CommentAuthorLink($attr)2160 {2161 $f = $this->getFilters($attr);2162 return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorLink()').'; ?>';2163 }2164 2165 /*dtd2166 <!ELEMENT tpl:CommentAuthorMailMD5 - O -- Comment author email MD5 sum -->2167 */2168 public function CommentAuthorMailMD5($attr)2169 {2170 return '<?php echo md5($_ctx->comments->comment_email) ; ?>';2171 }2172 2173 /*dtd2174 <!ELEMENT tpl:CommentAuthorURL - O -- Comment author URL -->2175 */2176 public function CommentAuthorURL($attr)2177 {2178 $f = $this->getFilters($attr);2179 return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorURL()').'; ?>';2180 }2181 2182 /*dtd2183 <!ELEMENT tpl:CommentContent - O -- Comment content -->2184 <!ATTLIST tpl:CommentContent2185 absolute_urls (0|1) #IMPLIED -- convert URLS to absolute urls2186 >2187 */2188 public function CommentContent($attr)2189 {2190 $urls = '0';2191 if (!empty($attr['absolute_urls'])) {2192 $urls = '1';2193 }2194 2195 $f = $this->getFilters($attr);2196 return '<?php echo '.sprintf($f,'$_ctx->comments->getContent('.$urls.')').'; ?>';2197 }2198 2199 /*dtd2200 <!ELEMENT tpl:CommentDate - O -- Comment date -->2201 <!ATTLIST tpl:CommentDate2202 format CDATA #IMPLIED -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified)2203 iso8601 CDATA #IMPLIED -- if set, tells that date format is ISO 86012204 rfc822 CDATA #IMPLIED -- if set, tells that date format is RFC 8222205 upddt CDATA #IMPLIED -- if set, uses the comment update time2206 >2207 */2208 public function CommentDate($attr)2209 {2210 $format = '';2211 if (!empty($attr['format'])) {2212 $format = addslashes($attr['format']);2213 }2214 2215 $iso8601 = !empty($attr['iso8601']);2216 $rfc822 = !empty($attr['rfc822']);2217 $type = (!empty($attr['upddt']) ? 'upddt' : '');2218 2219 $f = $this->getFilters($attr);2220 2221 if ($rfc822) {2222 return '<?php echo '.sprintf($f,"\$_ctx->comments->getRFC822Date('".$type."')").'; ?>';2223 } elseif ($iso8601) {2224 return '<?php echo '.sprintf($f,"\$_ctx->comments->getISO8601Date('".$type."')").'; ?>';2225 } else {2226 return '<?php echo '.sprintf($f,"\$_ctx->comments->getDate('".$format."','".$type."')").'; ?>';2227 }2228 }2229 2230 /*dtd2231 <!ELEMENT tpl:CommentTime - O -- Comment date -->2232 <!ATTLIST tpl:CommentTime2233 format CDATA #IMPLIED -- time format2234 upddt CDATA #IMPLIED -- if set, uses the comment update time2235 >2236 */2237 public function CommentTime($attr)2238 {2239 $format = '';2240 if (!empty($attr['format'])) {2241 $format = addslashes($attr['format']);2242 }2243 $type = (!empty($attr['upddt']) ? 'upddt' : '');2244 2245 $f = $this->getFilters($attr);2246 return '<?php echo '.sprintf($f,"\$_ctx->comments->getTime('".$format."','".$type."')").'; ?>';2247 }2248 2249 /*dtd2250 <!ELEMENT tpl:CommentEmail - O -- Comment author email -->2251 <!ATTLIST tpl:CommentEmail2252 spam_protected (0|1) #IMPLIED -- protect email from spam (default: 1)2253 >2254 */2255 public function CommentEmail($attr)2256 {2257 $p = 'true';2258 if (isset($attr['spam_protected']) && !$attr['spam_protected']) {2259 $p = 'false';2260 }2261 2262 $f = $this->getFilters($attr);2263 return '<?php echo '.sprintf($f,"\$_ctx->comments->getEmail(".$p.")").'; ?>';2264 }2265 2266 /*dtd2267 <!ELEMENT tpl:CommentEntryTitle - O -- Title of the comment entry -->2268 */2269 public function CommentEntryTitle($attr)2270 {2271 $f = $this->getFilters($attr);2272 return '<?php echo '.sprintf($f,'$_ctx->comments->post_title').'; ?>';2273 }2274 2275 /*dtd2276 <!ELEMENT tpl:CommentFeedID - O -- Comment feed ID -->2277 */2278 public function CommentFeedID($attr)2279 {2280 $f = $this->getFilters($attr);2281 return '<?php echo '.sprintf($f,'$_ctx->comments->getFeedID()').'; ?>';2282 }2283 2284 /*dtd2285 <!ELEMENT tpl:CommentID - O -- Comment ID -->2286 */2287 public function CommentID($attr)2288 {2289 return '<?php echo $_ctx->comments->comment_id; ?>';2290 }2291 2292 /*dtd2293 <!ELEMENT tpl:CommentIf - - -- test container for comments -->2294 <!ATTLIST tpl:CommentIf2295 is_ping (0|1) #IMPLIED -- test if comment is a trackback (value : 1) or not (value : 0)2296 >2297 */2298 public function CommentIf($attr,$content)2299 {2300 $if = array();2301 $is_ping = null;2302 2303 if (isset($attr['is_ping'])) {2304 $sign = (boolean) $attr['is_ping'] ? '' : '!';2305 $if[] = $sign.'$_ctx->comments->comment_trackback';2306 }2307 2308 $this->core->callBehavior('tplIfConditions','CommentIf',$attr,$content,$if);2309 2310 if (count($if) != 0) {2311 return '<?php if('.implode(' && ', (array) $if).') : ?>'.$content.'<?php endif; ?>';2312 } else {2313 return $content;2314 }2315 }2316 2317 /*dtd2318 <!ELEMENT tpl:CommentIfFirst - O -- displays value if comment is the first one -->2319 <!ATTLIST tpl:CommentIfFirst2320 return CDATA #IMPLIED -- value to display in case of success (default: first)2321 >2322 */2323 public function CommentIfFirst($attr)2324 {2325 $ret = isset($attr['return']) ? $attr['return'] : 'first';2326 $ret = html::escapeHTML($ret);2327 2328 return2329 '<?php if ($_ctx->comments->index() == 0) { '.2330 "echo '".addslashes($ret)."'; } ?>";2331 }2332 2333 /*dtd2334 <!ELEMENT tpl:CommentIfMe - O -- displays value if comment is the from the entry author -->2335 <!ATTLIST tpl:CommentIfMe2336 return CDATA #IMPLIED -- value to display in case of success (default: me)2337 >2338 */2339 public function CommentIfMe($attr)2340 {2341 $ret = isset($attr['return']) ? $attr['return'] : 'me';2342 $ret = html::escapeHTML($ret);2343 2344 return2345 '<?php if ($_ctx->comments->isMe()) { '.2346 "echo '".addslashes($ret)."'; } ?>";2347 }2348 2349 /*dtd2350 <!ELEMENT tpl:CommentIfOdd - O -- displays value if comment is at an odd position -->2351 <!ATTLIST tpl:CommentIfOdd2352 return CDATA #IMPLIED -- value to display in case of success (default: odd)2353 >2354 */2355 public function CommentIfOdd($attr)2356 {2357 $ret = isset($attr['return']) ? $attr['return'] : 'odd';2358 $ret = html::escapeHTML($ret);2359 2360 return2361 '<?php if (($_ctx->comments->index()+1)%2) { '.2362 "echo '".addslashes($ret)."'; } ?>";2363 }2364 2365 /*dtd2366 <!ELEMENT tpl:CommentIP - O -- Comment author IP -->2367 */2368 public function CommentIP($attr)2369 {2370 return '<?php echo $_ctx->comments->comment_ip; ?>';2371 }2372 2373 /*dtd2374 <!ELEMENT tpl:CommentOrderNumber - O -- Comment order in page -->2375 */2376 public function CommentOrderNumber($attr)2377 {2378 return '<?php echo $_ctx->comments->index()+1; ?>';2379 }2380 2381 /*dtd2382 <!ELEMENT tpl:CommentsFooter - - -- Last comments result container -->2383 */2384 public function CommentsFooter($attr,$content)2385 {2386 return2387 "<?php if (\$_ctx->comments->isEnd()) : ?>".2388 $content.2389 "<?php endif; ?>";2390 }2391 2392 /*dtd2393 <!ELEMENT tpl:CommentsHeader - - -- First comments result container -->2394 */2395 public function CommentsHeader($attr,$content)2396 {2397 return2398 "<?php if (\$_ctx->comments->isStart()) : ?>".2399 $content.2400 "<?php endif; ?>";2401 }2402 2403 /*dtd2404 <!ELEMENT tpl:CommentPostURL - O -- Comment Entry URL -->2405 */2406 public function CommentPostURL($attr)2407 {2408 $f = $this->getFilters($attr);2409 return '<?php echo '.sprintf($f,'$_ctx->comments->getPostURL()').'; ?>';2410 }2411 2412 /*dtd2413 <!ELEMENT tpl:IfCommentAuthorEmail - - -- Container displayed if comment author email is set -->2414 */2415 public function IfCommentAuthorEmail($attr,$content)2416 {2417 return2418 "<?php if (\$_ctx->comments->comment_email) : ?>".2419 $content.2420 "<?php endif; ?>";2421 }2422 2423 /*dtd2424 <!ELEMENT tpl:CommentHelp - 0 -- Comment syntax mini help -->2425 */2426 public function CommentHelp($attr,$content)2427 {2428 return2429 "<?php if (\$core->blog->settings->system->wiki_comments) {\n".2430 " echo __('Comments can be formatted using a simple wiki syntax.');\n".2431 "} else {\n".2432 " echo __('HTML code is displayed as text and web addresses are automatically converted.');\n".2433 "} ?>";2434 }2435 2436 /* Comment preview -------------------------------- */2437 /*dtd2438 <!ELEMENT tpl:IfCommentPreview - - -- Container displayed if comment is being previewed -->2439 */2440 public function IfCommentPreview($attr,$content)2441 {2442 return2443 '<?php if ($_ctx->comment_preview !== null && $_ctx->comment_preview["preview"]) : ?>'.2444 $content.2445 '<?php endif; ?>';2446 }2447 2448 /*dtd2449 <!ELEMENT tpl:CommentPreviewName - O -- Author name for the previewed comment -->2450 */2451 public function CommentPreviewName($attr)2452 {2453 $f = $this->getFilters($attr);2454 return '<?php echo '.sprintf($f,'$_ctx->comment_preview["name"]').'; ?>';2455 }2456 2457 /*dtd2458 <!ELEMENT tpl:CommentPreviewEmail - O -- Author email for the previewed comment -->2459 */2460 public function CommentPreviewEmail($attr)2461 {2462 $f = $this->getFilters($attr);2463 return '<?php echo '.sprintf($f,'$_ctx->comment_preview["mail"]').'; ?>';2464 }2465 2466 /*dtd2467 <!ELEMENT tpl:CommentPreviewSite - O -- Author site for the previewed comment -->2468 */2469 public function CommentPreviewSite($attr)2470 {2471 $f = $this->getFilters($attr);2472 return '<?php echo '.sprintf($f,'$_ctx->comment_preview["site"]').'; ?>';2473 }2474 2475 /*dtd2476 <!ELEMENT tpl:CommentPreviewContent - O -- Content of the previewed comment -->2477 <!ATTLIST tpl:CommentPreviewContent2478 raw (0|1) #IMPLIED -- display comment in raw content2479 >2480 */2481 public function CommentPreviewContent($attr)2482 {2483 $f = $this->getFilters($attr);2484 2485 if (!empty($attr['raw'])) {2486 $co = '$_ctx->comment_preview["rawcontent"]';2487 } else {2488 $co = '$_ctx->comment_preview["content"]';2489 }2490 2491 return '<?php echo '.sprintf($f,$co).'; ?>';2492 }2493 2494 /*dtd2495 <!ELEMENT tpl:CommentPreviewCheckRemember - O -- checkbox attribute for "remember me" (same value as before preview) -->2496 */2497 public function CommentPreviewCheckRemember($attr)2498 {2499 return2500 "<?php if (\$_ctx->comment_preview['remember']) { echo ' checked=\"checked\"'; } ?>";2501 }2502 2503 /* Trackbacks ------------------------------------- */2504 /*dtd2505 <!ELEMENT tpl:PingBlogName - O -- Trackback blog name -->2506 */2507 public function PingBlogName($attr)2508 {2509 $f = $this->getFilters($attr);2510 return '<?php echo '.sprintf($f,'$_ctx->pings->comment_author').'; ?>';2511 }2512 2513 /*dtd2514 <!ELEMENT tpl:PingContent - O -- Trackback content -->2515 */2516 public function PingContent($attr)2517 {2518 $f = $this->getFilters($attr);2519 return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackContent()').'; ?>';2520 }2521 2522 /*dtd2523 <!ELEMENT tpl:PingDate - O -- Trackback date -->2524 <!ATTLIST tpl:PingDate2525 format CDATA #IMPLIED -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified)2526 iso8601 CDATA #IMPLIED -- if set, tells that date format is ISO 86012527 rfc822 CDATA #IMPLIED -- if set, tells that date format is RFC 8222528 upddt CDATA #IMPLIED -- if set, uses the comment update time2529 >2530 */2531 public function PingDate($attr,$type='')2532 {2533 $format = '';2534 if (!empty($attr['format'])) {2535 $format = addslashes($attr['format']);2536 }2537 2538 $iso8601 = !empty($attr['iso8601']);2539 $rfc822 = !empty($attr['rfc822']);2540 $type = (!empty($attr['upddt']) ? 'upddt' : '');2541 2542 $f = $this->getFilters($attr);2543 2544 if ($rfc822) {2545 return '<?php echo '.sprintf($f,"\$_ctx->pings->getRFC822Date('".$type."')").'; ?>';2546 } elseif ($iso8601) {2547 return '<?php echo '.sprintf($f,"\$_ctx->pings->getISO8601Date('".$type."')").'; ?>';2548 } else {2549 return '<?php echo '.sprintf($f,"\$_ctx->pings->getDate('".$format."','".$type."')").'; ?>';2550 }2551 }2552 2553 /*dtd2554 <!ELEMENT tpl:PingTime - O -- Trackback date -->2555 <!ATTLIST tpl:PingTime2556 format CDATA #IMPLIED -- time format2557 upddt CDATA #IMPLIED -- if set, uses the comment update time2558 >2559 */2560 public function PingTime($attr)2561 {2562 $format = '';2563 if (!empty($attr['format'])) {2564 $format = addslashes($attr['format']);2565 }2566 $type = (!empty($attr['upddt']) ? 'upddt' : '');2567 2568 $f = $this->getFilters($attr);2569 return '<?php echo '.sprintf($f,"\$_ctx->pings->getTime('".$format."','".$type."')").'; ?>';2570 }2571 2572 /*dtd2573 <!ELEMENT tpl:PingEntryTitle - O -- Trackback entry title -->2574 */2575 public function PingEntryTitle($attr)2576 {2577 $f = $this->getFilters($attr);2578 return '<?php echo '.sprintf($f,'$_ctx->pings->post_title').'; ?>';2579 }2580 2581 /*dtd2582 <!ELEMENT tpl:PingFeedID - O -- Trackback feed ID -->2583 */2584 public function PingFeedID($attr)2585 {2586 $f = $this->getFilters($attr);2587 return '<?php echo '.sprintf($f,'$_ctx->pings->getFeedID()').'; ?>';2588 }2589 2590 /*dtd2591 <!ELEMENT tpl:PingID - O -- Trackback ID -->2592 */2593 public function PingID($attr)2594 {2595 return '<?php echo $_ctx->pings->comment_id; ?>';2596 }2597 2598 /*dtd2599 <!ELEMENT tpl:PingIfFirst - O -- displays value if trackback is the first one -->2600 <!ATTLIST tpl:PingIfFirst2601 return CDATA #IMPLIED -- value to display in case of success (default: first)2602 >2603 */2604 public function PingIfFirst($attr)2605 {2606 $ret = isset($attr['return']) ? $attr['return'] : 'first';2607 $ret = html::escapeHTML($ret);2608 2609 return2610 '<?php if ($_ctx->pings->index() == 0) { '.2611 "echo '".addslashes($ret)."'; } ?>";2612 }2613 2614 /*dtd2615 <!ELEMENT tpl:PingIfOdd - O -- displays value if trackback is at an odd position -->2616 <!ATTLIST tpl:PingIfOdd2617 return CDATA #IMPLIED -- value to display in case of success (default: odd)2618 >2619 */2620 public function PingIfOdd($attr)2621 {2622 $ret = isset($attr['return']) ? $attr['return'] : 'odd';2623 $ret = html::escapeHTML($ret);2624 2625 return2626 '<?php if (($_ctx->pings->index()+1)%2) { '.2627 "echo '".addslashes($ret)."'; } ?>";2628 }2629 2630 /*dtd2631 <!ELEMENT tpl:PingIP - O -- Trackback author IP -->2632 */2633 public function PingIP($attr)2634 {2635 return '<?php echo $_ctx->pings->comment_ip; ?>';2636 }2637 2638 /*dtd2639 <!ELEMENT tpl:PingNoFollow - O -- displays 'rel="nofollow"' if set in blog -->2640 */2641 public function PingNoFollow($attr)2642 {2643 return2644 '<?php if($core->blog->settings->system->comments_nofollow) { '.2645 'echo \' rel="nofollow"\';'.2646 '} ?>';2647 }2648 2649 /*dtd2650 <!ELEMENT tpl:PingOrderNumber - O -- Trackback order in page -->2651 */2652 public function PingOrderNumber($attr)2653 {2654 return '<?php echo $_ctx->pings->index()+1; ?>';2655 }2656 2657 /*dtd2658 <!ELEMENT tpl:PingPostURL - O -- Trackback Entry URL -->2659 */2660 public function PingPostURL($attr)2661 {2662 $f = $this->getFilters($attr);2663 return '<?php echo '.sprintf($f,'$_ctx->pings->getPostURL()').'; ?>';2664 }2665 2666 /*dtd2667 <!ELEMENT tpl:Pings - - -- Trackbacks container -->2668 <!ATTLIST tpl:Pings2669 with_pings (0|1) #IMPLIED -- include trackbacks in request2670 lastn CDATA #IMPLIED -- restrict the number of entries2671 no_context (1|0) #IMPLIED -- Override context information2672 order (desc|asc) #IMPLIED -- result ordering (default: asc)2673 >2674 */2675 public function Pings($attr,$content)2676 {2677 $p =2678 "if (\$_ctx->posts !== null) { ".2679 "\$params['post_id'] = \$_ctx->posts->post_id; ".2680 "\$core->blog->withoutPassword(false);\n".2681 "}\n";2682 2683 $p .= "\$params['comment_trackback'] = true;\n";2684 2685 $lastn = 0;2686 if (isset($attr['lastn'])) {2687 $lastn = abs((integer) $attr['lastn'])+0;2688 }2689 2690 if ($lastn > 0) {2691 $p .= "\$params['limit'] = ".$lastn.";\n";2692 } else {2693 $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n";2694 }2695 2696 if (empty($attr['no_context']))2697 {2698 $p .=2699 'if ($_ctx->exists("categories")) { '.2700 "\$params['cat_id'] = \$_ctx->categories->cat_id; ".2701 "}\n";2702 2703 $p .=2704 'if ($_ctx->exists("langs")) { '.2705 "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ".2706 "}\n";2707 }2708 2709 $order = 'asc';2710 if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) {2711 $order = $attr['order'];2712 }2713 2714 $p .= "\$params['order'] = 'comment_dt ".$order."';\n";2715 2716 if (isset($attr['no_content']) && $attr['no_content']) {2717 $p .= "\$params['no_content'] = true;\n";2718 }2719 2720 $res = "<?php\n";2721 $res .= $p;2722 $res .= $this->core->callBehavior("templatePrepareParams",2723 array("tag" => "Pings","method" => "blog::getComments"),2724 $attr,$content);2725 $res .= '$_ctx->pings = $core->blog->getComments($params); unset($params);'."\n";2726 $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n";2727 $res .= "?>\n";2728 2729 $res .=2730 '<?php while ($_ctx->pings->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->pings = null; ?>';2731 2732 return $res;2733 }2734 2735 /*dtd2736 <!ELEMENT tpl:PingsFooter - - -- Last trackbacks result container -->2737 */2738 public function PingsFooter($attr,$content)2739 {2740 return2741 "<?php if (\$_ctx->pings->isEnd()) : ?>".2742 $content.2743 "<?php endif; ?>";2744 }2745 2746 /*dtd2747 <!ELEMENT tpl:PingsHeader - - -- First trackbacks result container -->2748 */2749 public function PingsHeader($attr,$content)2750 {2751 return2752 "<?php if (\$_ctx->pings->isStart()) : ?>".2753 $content.2754 "<?php endif; ?>";2755 }2756 2757 /*dtd2758 <!ELEMENT tpl:PingTitle - O -- Trackback title -->2759 */2760 public function PingTitle($attr)2761 {2762 $f = $this->getFilters($attr);2763 return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackTitle()').'; ?>';2764 }2765 2766 /*dtd2767 <!ELEMENT tpl:PingAuthorURL - O -- Trackback author URL -->2768 */2769 public function PingAuthorURL($attr)2770 {2771 $f = $this->getFilters($attr);2772 return '<?php echo '.sprintf($f,'$_ctx->pings->getAuthorURL()').'; ?>';2773 1854 } 2774 1855 … … 2804 1885 has_tag CDATA #IMPLIED -- tests if a named template tag exists (see Tag plugin for code) 2805 1886 blog_id CDATA #IMPLIED -- tests if current blog ID is the one given in parameter 2806 comments_active (0|1) #IMPLIED -- test if comments are enabled blog-wide2807 pings_active (0|1) #IMPLIED -- test if trackbacks are enabled blog-wide2808 wiki_comments (0|1) #IMPLIED -- test if wiki syntax is enabled for comments2809 1887 operator (and|or) #IMPLIED -- combination of conditions, if more than 1 specifiec (default: and) 2810 1888 > … … 2867 1945 } 2868 1946 2869 if (isset($attr['comments_active'])) {2870 $sign = (boolean) $attr['comments_active'] ? '' : '!';2871 $if[] = $sign.'$core->blog->settings->system->allow_comments';2872 }2873 2874 if (isset($attr['pings_active'])) {2875 $sign = (boolean) $attr['pings_active'] ? '' : '!';2876 $if[] = $sign.'$core->blog->settings->system->allow_trackbacks';2877 }2878 2879 if (isset($attr['wiki_comments'])) {2880 $sign = (boolean) $attr['wiki_comments'] ? '' : '!';2881 $if[] = $sign.'$core->blog->settings->system->wiki_comments';2882 }2883 2884 1947 if (isset($attr['search_count']) && 2885 1948 preg_match('/^((=|!|>|<)=|(>|<))\s*[0-9]+$/',trim($attr['search_count']))) { … … 2894 1957 return $content; 2895 1958 } 2896 }2897 2898 /*dtd2899 <!ELEMENT tpl:SysIfCommentPublished - - -- Container displayed if comment has been published -->2900 */2901 public function SysIfCommentPublished($attr,$content)2902 {2903 return2904 '<?php if (!empty($_GET[\'pub\'])) : ?>'.2905 $content.2906 '<?php endif; ?>';2907 }2908 2909 /*dtd2910 <!ELEMENT tpl:SysIfCommentPending - - -- Container displayed if comment is pending after submission -->2911 */2912 public function SysIfCommentPending($attr,$content)2913 {2914 return2915 '<?php if (isset($_GET[\'pub\']) && $_GET[\'pub\'] == 0) : ?>'.2916 $content.2917 '<?php endif; ?>';2918 1959 } 2919 1960 -
inc/public/lib.urlhandlers.php
r779 r848 339 339 340 340 $_ctx->posts = $core->blog->getPosts($params); 341 342 $_ctx->comment_preview = new ArrayObject();343 $_ctx->comment_preview['content'] = '';344 $_ctx->comment_preview['rawcontent'] = '';345 $_ctx->comment_preview['name'] = '';346 $_ctx->comment_preview['mail'] = '';347 $_ctx->comment_preview['site'] = '';348 $_ctx->comment_preview['preview'] = false;349 $_ctx->comment_preview['remember'] = false;350 341 351 342 $core->blog->withoutPassword(true); … … 385 376 } 386 377 387 $post_comment =388 isset($_POST['c_name']) && isset($_POST['c_mail']) &&389 isset($_POST['c_site']) && isset($_POST['c_content']) &&390 $_ctx->posts->commentsActive();391 392 # Posting a comment393 if ($post_comment)394 {395 # Spam trap396 if (!empty($_POST['f_mail'])) {397 http::head(412,'Precondition Failed');398 header('Content-Type: text/plain');399 echo "So Long, and Thanks For All the Fish";400 # Exits immediately the application to preserve the server.401 exit;402 }403 404 $name = $_POST['c_name'];405 $mail = $_POST['c_mail'];406 $site = $_POST['c_site'];407 $content = $_POST['c_content'];408 $preview = !empty($_POST['preview']);409 410 if ($content != '')411 {412 if ($core->blog->settings->system->wiki_comments) {413 $core->initWikiComment();414 } else {415 $core->initWikiSimpleComment();416 }417 $content = $core->wikiTransform($content);418 $content = $core->HTMLfilter($content);419 }420 421 $_ctx->comment_preview['content'] = $content;422 $_ctx->comment_preview['rawcontent'] = $_POST['c_content'];423 $_ctx->comment_preview['name'] = $name;424 $_ctx->comment_preview['mail'] = $mail;425 $_ctx->comment_preview['site'] = $site;426 427 if ($preview)428 {429 # --BEHAVIOR-- publicBeforeCommentPreview430 $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview);431 432 $_ctx->comment_preview['preview'] = true;433 }434 else435 {436 # Post the comment437 $cur = $core->con->openCursor($core->prefix.'comment');438 $cur->comment_author = $name;439 $cur->comment_site = html::clean($site);440 $cur->comment_email = html::clean($mail);441 $cur->comment_content = $content;442 $cur->post_id = $_ctx->posts->post_id;443 $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1;444 $cur->comment_ip = http::realIP();445 446 $redir = $_ctx->posts->getURL();447 $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?';448 449 try450 {451 if (!text::isEmail($cur->comment_email)) {452 throw new Exception(__('You must provide a valid email address.'));453 }454 455 # --BEHAVIOR-- publicBeforeCommentCreate456 $core->callBehavior('publicBeforeCommentCreate',$cur);457 if ($cur->post_id) {458 $comment_id = $core->blog->addComment($cur);459 460 # --BEHAVIOR-- publicAfterCommentCreate461 $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id);462 }463 464 if ($cur->comment_status == 1) {465 $redir_arg = 'pub=1';466 } else {467 $redir_arg = 'pub=0';468 }469 470 header('Location: '.$redir.$redir_arg);471 }472 catch (Exception $e)473 {474 $_ctx->form_error = $e->getMessage();475 $_ctx->form_error;476 }477 }478 }479 480 378 # The entry 481 379 self::serveDocument('post.html'); … … 513 411 { 514 412 $type = null; 515 $comments = false;516 413 $cat_url = false; 517 414 $post_id = null; … … 547 444 return; 548 445 } 549 elseif (preg_match('#^(atom|rss2)/comments/([0-9]+)$#',$args,$m))550 {551 # Post comments feed552 $type = $m[1];553 $comments = true;554 $post_id = (integer) $m[2];555 }556 446 elseif (preg_match('#^(?:category/(.+)/)?(atom|rss2)(/comments)?$#',$args,$m)) 557 447 { 558 448 # All posts or comments feed 559 449 $type = $m[2]; 560 $comments = !empty($m[3]);561 450 if (!empty($m[1])) { 562 451 $cat_url = $m[1]; … … 608 497 609 498 $tpl = $type; 610 if ($comments) { 611 $tpl .= '-comments'; 612 $_ctx->nb_comment_per_page = $core->blog->settings->system->nb_comment_per_feed; 613 } else { 614 $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed; 615 $_ctx->short_feed_items = $core->blog->settings->system->short_feed_items; 616 } 499 $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed; 500 $_ctx->short_feed_items = $core->blog->settings->system->short_feed_items; 617 501 $tpl .= '.xml'; 618 502 … … 627 511 if (!$comments && !$cat_url) { 628 512 $core->blog->publishScheduledEntries(); 629 }630 }631 632 public static function trackback($args)633 {634 if (!preg_match('/^[0-9]+$/',$args)) {635 # The specified trackback URL is not an number636 self::p404();637 } else {638 $tb = new dcTrackback($GLOBALS['core']);639 $tb->receive($args);640 513 } 641 514 } -
inc/public/rs.extension.php
r270 r848 13 13 14 14 $core->addBehavior('coreBlogGetPosts',array('rsExtendPublic','coreBlogGetPosts')); 15 $core->addBehavior('coreBlogGetComments',array('rsExtendPublic','coreBlogGetComments'));16 15 17 16 class rsExtendPublic … … 22 21 } 23 22 24 public static function coreBlogGetComments($rs)25 {26 $rs->extend('rsExtCommentPublic');27 }28 23 } 29 24 … … 74 69 } 75 70 76 class rsExtCommentPublic extends rsExtComment77 {78 public static function getContent($rs,$absolute_urls=false)79 {80 if ($rs->core->blog->settings->system->use_smilies)81 {82 $c = parent::getContent($rs,$absolute_urls);83 84 if (!isset($GLOBALS['__smilies'])) {85 $GLOBALS['__smilies'] = context::getSmilies($rs->core->blog);86 }87 return context::addSmilies($c);88 }89 90 return parent::getContent($rs,$absolute_urls);91 }92 }93 71 ?> -
locales/en/resources.php
r270 r848 25 25 'core_blog_pref' => dirname(__FILE__).'/help/blog_pref.html', 26 26 'core_categories' => dirname(__FILE__).'/help/categories.html', 27 'core_comments' => dirname(__FILE__).'/help/comments.html',28 27 'core_media' => dirname(__FILE__).'/help/media.html', 29 28 'core_post' => dirname(__FILE__).'/help/post.html',
Note: See TracChangeset
for help on using the changeset viewer.