Get::plug('article', function ($reference, $excludes = array()) { $config = Config::get(); $speak = Config::speak(); $FP = 'article:'; if (!($results = Get::post($reference, $excludes, ARTICLE, '/' . $config->index->slug . '/', $FP))) { return $results; } // Include comment(s) data $c = array(); $cc = 0; $ccc = '0 ' . $speak->comments; if ($comments = Get::comments('ASC', 'post:' . $results->id, Guardian::happy() ? 'txt,hold' : 'txt')) { $cc = $comments !== false ? count($comments) : 0; $ccc = $cc . ' ' . ($cc === 1 ? $speak->comment : $speak->comments); foreach ($comments as $comment) { $c[] = Get::comment($comment); } $results->comments = Filter::colon($FP . 'comments', $c, $results); } $results->total_comments = Filter::colon($FP . 'total_comments', $cc, $results); $results->total_comments_text = Filter::colon($FP . 'total_comments_text', $ccc, $results); unset($comments, $c, $cc, $ccc); return $results; }); /** * ========================================================================== * GET COMMENT PATH * ========================================================================== * * -- CODE: ----------------------------------------------------------------- *
Weapon::fire('on_comment_update', array($G, $P)); Weapon::fire('on_comment_repair', array($G, $P)); Guardian::kick($config->manager->slug . '/comment/repair/id:' . $id); } } Shield::lot(array('segment' => 'comment', 'default' => $comment))->attach('manager', false); }); /** * Comment Killer * -------------- */ Route::accept($config->manager->slug . '/comment/kill/id:(:num)', function ($id = "") use($config, $speak) { if (Guardian::get('status') !== 'pilot') { Shield::abort(); } if (!($comment = Get::comment($id))) { Shield::abort(); // File not found! } Config::set(array('page_title' => $speak->deleting . ': ' . $speak->comment . $config->title_separator . $config->manager->title, 'response' => $comment, 'cargo' => DECK . DS . 'workers' . DS . 'kill.comment.php')); if ($request = Request::post()) { $P = array('data' => Mecha::A($comment)); Guardian::checkToken($request['token']); File::open($comment->path)->delete(); $task_connect = $comment; include DECK . DS . 'workers' . DS . 'task.field.3.php'; File::write($config->total_comments_backend - 1)->saveTo(SYSTEM . DS . 'log' . DS . 'comments.total.log', 0600); Notify::success(Config::speak('notify_success_deleted', $speak->comment)); Weapon::fire('on_comment_update', array($P, $P)); Weapon::fire('on_comment_destruct', array($P, $P)); Guardian::kick($config->manager->slug . '/comment');
/** * Widget Recent Comment * --------------------- * * [1]. Widget::recentComment(); * [2]. Widget::recentComment(5); * */ public static function recentComment($total = 7, $avatar_size = 50, $summary = 100, $d = 'monsterid') { $T1 = TAB; $T2 = str_repeat(TAB, 2); $T3 = str_repeat(TAB, 3); $T4 = str_repeat(TAB, 4); $T5 = str_repeat(TAB, 5); $config = Config::get(); $speak = Config::speak(); $comments = Get::comments(); $html = O_BEGIN . '<div class="widget widget-recent widget-recent-comment"' . ($comments ? ' id="widget-recent-comment-' . self::$id['recent_comment'] . '"' : "") . '>' . NL; self::$id['recent_comment']++; if ($comments) { $comments_id = array(); foreach ($comments as $comment) { $parts = explode('_', File::B($comment)); $comments_id[] = $parts[1]; } rsort($comments_id); $html .= $T1 . '<ul class="recent-comment-list">' . NL; for ($i = 0, $count = count($comments_id); $i < $total; ++$i) { if ($i === $count) { break; } $comment = Get::comment($comments_id[$i]); $article = Get::articleAnchor($comment->post); $html .= $T2 . '<li class="recent-comment">' . NL; if ($avatar_size !== false && $avatar_size > 0) { $html .= $T3 . '<div class="recent-comment-avatar">' . NL; $html .= $T4 . '<img alt="" src="' . $config->protocol . 'www.gravatar.com/avatar/' . md5($comment->email) . '?s=' . $avatar_size . '&d=' . urlencode($d) . '" width="' . $avatar_size . '" height="' . $avatar_size . '"' . ES . NL; $html .= $T3 . '</div>' . NL; } $html .= $T3 . '<div class="recent-comment-header">' . NL; if (trim($comment->url) === "" || $comment->url === '#') { $html .= $T4 . '<span class="recent-comment-name">' . $comment->name . '</span>' . NL; } else { $html .= $T4 . '<a class="recent-comment-name" href="' . $comment->url . '" rel="nofollow">' . $comment->name . '</a>' . NL; } $html .= $T3 . '</div>' . NL; $html .= $T3 . '<div class="recent-comment-body"><p>' . Converter::curt($comment->message, $summary, '…') . '</p></div>' . NL; $html .= $T3 . '<div class="recent-comment-footer">' . NL; $html .= $T4 . '<span class="recent-comment-time">' . NL; $html .= $T5 . '<time datetime="' . $comment->date->W3C . '">' . $comment->date->FORMAT_3 . '</time> <a title="' . ($article ? strip_tags($article->title) : $speak->notify_error_not_found) . '" href="' . $comment->permalink . '" rel="nofollow">#</a>' . NL; $html .= $T4 . '</span>' . NL; $html .= $T3 . '</div>' . NL; $html .= $T2 . '</li>' . NL; } $html .= $T1 . '</ul>' . NL; } else { $html .= Config::speak('notify_empty', strtolower($speak->comments)); } $html .= '</div>' . O_END; $html = Filter::apply('widget', $html); return Filter::apply('widget:recent.comment', Filter::apply('widget:recent', $html)); }