public function postComments($id)
 {
     $owner = Post::find($id);
     $in = Input::all();
     PostComment::create(['id' => $id, 'StudentID' => Auth::user()->StudentID, 'commentboxes' => $in['message']]);
     PostNotification::create(['StudentID' => Auth::user()->StudentID, 'OwnerID' => $owner->StudentID, 'agroup' => 0, 'post_id' => $id, 'grouppageID' => 0, 'grouppagepostID' => 0, 'eventID' => 2, 'seen' => 0]);
 }
示例#2
0
 private function AddComment(sfWebRequest $request)
 {
     $text = $request->getParameter('comment_text');
     if ($request->isMethod("GET")) {
         $text = urldecode($text);
     }
     if ($this->getRequestParameter('comment_picture_url')) {
         $filename = jrFileUploader::UploadRemote($request->getParameter('comment_picture_url'));
         if ($text) {
             $text .= "<br/>";
         }
         $text .= "<img src='http://" . $request->getHost() . "/uploads/" . $filename . "' />";
     }
     if (!trim($text)) {
         return;
     }
     sfApplicationConfiguration::getActive()->loadHelpers(array('Parse', 'Text', 'Tag', 'I18N', 'Url'));
     $user = $this->getUser()->getGuardUser();
     $comment = new PostComment();
     $comment->setUser($user);
     $comment->setPost($this->post);
     if ($this->parent) {
         $comment->setParent($this->parent);
     }
     $comment->setComment(parsetext($text));
     $comment->setCommentOriginal($text);
     $comment->save();
     $this->curUser = $this->getUser()->getGuardUser();
     if ($this->curUser) {
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId(), $this->post->getAllComments('count'), time() + 24 * 60 * 60);
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
     }
 }
    private function displayNABConsole(&$dbw, &$dbr, $target)
    {
        global $wgOut, $wgRequest, $wgUser, $wgParser;
        $not_found = false;
        $title = Title::newFromURL($target);
        if (!$title || !$title->exists()) {
            $articleName = $title ? $title->getFullText() : $target;
            $wgOut->addHTML("<p>Error: Article &ldquo;{$articleName}&rdquo; not found. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>");
            $not_found = true;
        }
        if (!$not_found) {
            $rev = Revision::newFromTitle($title);
            if (!$rev) {
                $wgOut->addHTML("<p>Error: No revision for &ldquo;{$title->getFullText()}&rdquo;. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>");
                $not_found = true;
            }
        }
        if (!$not_found) {
            $in_nab = $dbr->selectField('newarticlepatrol', 'count(*)', array('nap_page' => $title->getArticleID()), __METHOD__) > 0;
            if (!$in_nab) {
                $wgOut->addHTML("<p>Error: This article is not in the NAB list.</p>");
                $not_found = true;
            }
        }
        if ($not_found) {
            $pageid = $wgRequest->getVal('page');
            if (strpos($target, ':') !== false && $pageid) {
                $wgOut->addHTML('<p>We can to try to <a href="/Special:NABClean/' . $pageid . '">delete this title</a> if you know this title exists in NAB yet is likely bad data.</p>');
            }
            return;
        }
        $locked = false;
        $min_timestamp = $dbr->selectField("revision", "min(rev_timestamp)", "rev_page=" . $title->getArticleId(), __METHOD__);
        $first_user = $dbr->selectField("revision", "rev_user_text", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__);
        $first_user_id = $dbr->selectField("revision", "rev_user", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__);
        $user = new User();
        if ($first_user_id) {
            $user->setId($first_user_id);
            $user->loadFromDatabase();
        } else {
            $user->setName($first_user);
        }
        $user_talk = $user->getTalkPage();
        $ut_id = $user_talk->getArticleID();
        $display_name = $user->getRealName() ? $user->getRealName() : $user->getName();
        $wgOut->setPageTitle(wfMsg('nap_title', $title->getFullText()));
        $count = $dbr->selectField('suggested_titles', array('count(*)'), array('st_title' => $title->getDBKey()), __METHOD__);
        $extra = $count > 0 ? ' - from Suggested Titles database' : '';
        $wgOut->addWikiText(wfMsg('nap_writtenby', $user->getName(), $display_name, $extra));
        $wgOut->addHTML(wfMsgExt('nap_quicklinks', 'parseinline', $this->me->getFullText() . "/" . $title->getFullText()));
        /// CHECK TO SEE IF ARTICLE IS LOCKED OR ALREADY PATROLLED
        $aid = $title->getArticleID();
        $half_hour_ago = wfTimestamp(TS_MW, time() - 30 * 60);
        $patrolled = $dbr->selectField('newarticlepatrol', 'nap_patrolled', array("nap_page={$aid}"), __METHOD__);
        if ($patrolled) {
            $locked = true;
            $wgOut->addHTML(wfMsgExt("nap_patrolled", 'parse'));
        } else {
            $user_co = $dbr->selectField('newarticlepatrol', 'nap_user_co', array("nap_page={$aid}", "nap_timestamp_co > '{$half_hour_ago}'"), __METHOD__);
            if ($user_co != '' && $user_co != 0 && $user_co != $wgUser->getId()) {
                $x = User::newFromId($user_co);
                $wgOut->addHTML(wfMsgExt("nap_usercheckedout", 'parse', $x->getName()));
                $locked = true;
            } else {
                // CHECK OUT THE ARTICLE TO THIS USER
                $ts = wfTimestampNow();
                $dbw->update('newarticlepatrol', array('nap_timestamp_co' => $ts, 'nap_user_co' => $wgUser->getId()), array("nap_page = {$aid}"), __METHOD__);
            }
        }
        $expandSpan = '<span class="nap_expand">&#9660;</span>';
        $externalLinkImg = '<img src="' . wfGetPad('/skins/common/images/external.png') . '"/>';
        /// SIMILAR RESULT
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_similarresults') . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $count = 0;
        $l = new LSearch();
        $hits = $l->googleSearchResultTitles($title->getFullText(), 0, 5);
        if (sizeof($hits) > 0) {
            $html = "";
            foreach ($hits as $hit) {
                $t1 = $hit;
                $id = rand(0, 500);
                if ($t1 == null || $t1->getFullURL() == $title->getFullURL() || $t1->getNamespace() != NS_MAIN || !$t1->exists()) {
                    continue;
                }
                $safe_title = htmlspecialchars(str_replace("'", "&#39;", $t1->getText()));
                $html .= "<tr><td>" . $this->skin->makeLinkObj($t1, wfMsg('howto', $t1->getText())) . "</td><td style='text-align:right; width: 200px;'>[<a href='#action' onclick='nap_Merge(\"{$safe_title}\");'>" . wfMsg('nap_merge') . "</a>] " . " [<a href='#action' onclick='javascript:nap_Dupe(\"{$safe_title}\");'>" . wfMsg('nap_duplicate') . "</a>] " . " <span id='mr_{$id}'>[<a onclick='javascript:nap_MarkRelated({$id}, {$t1->getArticleID()}, {$title->getArticleID()});'>" . wfMsg('nap_related') . "</a>]</span> " . "</td></tr>";
                $count++;
            }
        }
        if ($count == 0) {
            $wgOut->addHTML(wfMsg('nap_no-related-topics'));
        } else {
            $wgOut->addHTML(wfMsg('nap_already-related-topics') . "<table style='width:100%;'>{$html}</table>");
        }
        $wgOut->addHTML(wfMsg('nap_othersearches', urlencode($title->getFullText())));
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// COPYRIGHT CHECKER
        $cc_check = SpecialPage::getTitleFor('Copyrightchecker', $title->getText());
        $wgOut->addHTML("<script type='text/javascript'>window.onload = nap_cCheck; var nap_cc_url = \"{$cc_check->getFullURL()}\";</script>");
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_copyrightchecker') . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<div id='nap_copyrightresults'><center><img src='/extensions/wikihow/rotate.gif' alt='loading...'/></center></div>");
        $wgOut->addHTML("<center><input type='button' class='button primary' onclick='nap_cCheck();' value='Check'/></center>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// ARTICLE PREVIEW
        $editUrl = Title::makeTitle(NS_SPECIAL, "QuickEdit")->getFullURL() . "?type=editform&target=" . urlencode($title->getFullText()) . "&fromnab=1";
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='article' id='anchor-article'></a>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_articlepreview') . " - <a href=\"{$title->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getEditURL()}\" target=\"new\">" . wfMsg('edit') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getFullURL()}?action=history\" target=\"new\">" . wfMsg('history') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getTalkPage()->getFullURL()}\" target=\"new\">" . wfMsg('discuss') . "</a> {$externalLinkImg}" . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<div id='article_contents' ondblclick='nap_editClick(\"{$editUrl}\");'>");
        $popts = $wgOut->parserOptions();
        $popts->setTidy(true);
        // $parserOutput = $wgOut->parse($rev->getText(), $title, $popts);
        $output = $wgParser->parse($rev->getText(), $title, $popts);
        $parserOutput = $output->getText();
        $magic = WikihowArticleHTML::grabTheMagic($rev->getText());
        $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => $title->getNamespace(), 'magic-word' => $magic));
        $wgOut->addHTML($html);
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("<center><input id='editButton' type='button' class='button primary' name='wpEdit' value='" . wfMsg('edit') . "' onclick='nap_editClick(\"{$editUrl}\");'/></center>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML('<div style="clear: both;"></div>');
        /// DISCUSSION PREVIEW
        $talkPage = $title->getTalkPage();
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='talk' id='anchor-talk'></a>");
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_discussion') . " - <a href=\"{$talkPage->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<div id='disc_page'>");
        if ($talkPage->getArticleID() > 0) {
            $rp = Revision::newFromTitle($talkPage);
            $wgOut->addHTML($wgOut->parse($rp->getText()));
        } else {
            $wgOut->addHTML(wfMsg('nap_discussionnocontent'));
        }
        $wgOut->addHTML(PostComment::getForm(true, $talkPage, true));
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// USER INFORMATION
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='user' id='anchor-user'></a>");
        $used_templates = array();
        if ($ut_id > 0) {
            $res = $dbr->select('templatelinks', array('tl_title'), array('tl_from=' . $ut_id), __METHOD__);
            while ($row = $dbr->fetchObject($res)) {
                $used_templates[] = strtolower($row->tl_title);
            }
            $dbr->freeResult($res);
        }
        $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_userinfo') . " - <a href=\"{$user_talk->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $contribs = SpecialPage::getTitleFor('Contributions', $user->getName());
        $regDateTxt = "";
        if ($user->getRegistration() > 0) {
            preg_match('/^(\\d{4})(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/D', $user->getRegistration(), $da);
            $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]);
            $regdate = gmdate('F j, Y', $uts);
            $regDateTxt = wfMsg('nap_regdatetext', $regdate) . ' ';
        }
        $key = 'nap_userinfodetails_anon';
        if ($user->getID() != 0) {
            $key = 'nap_userinfodetails';
        }
        $wgOut->addWikiText(wfMsg($key, $user->getName(), number_format(WikihowUser::getAuthorStats($first_user), 0, "", ","), $title->getFullText(), $regDateTxt));
        if (WikihowUser::getAuthorStats($first_user) < 50) {
            if ($user_talk->getArticleId() == 0) {
                $wgOut->addHTML(wfMsg('nap_newwithouttalkpage'));
            } else {
                $rp = Revision::newFromTitle($user_talk);
                $xtra = "";
                if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE 8.0") === false) {
                    $xtra = "max-height: 300px; overflow: scroll;";
                }
                $output = $wgParser->parse($rp->getText(), $user_talk, $popts);
                $parserOutput = $output->getText();
                $wgOut->addHTML("<div style='border: 1px solid #eee; {$xtra}'>" . $parserOutput . "</div>");
            }
        }
        if ($user_talk->getArticleId() != 0 && sizeof($used_templates) > 0) {
            $wgOut->addHTML('<br />' . wfMsg('nap_usertalktemplates', implode($used_templates, ", ")));
        }
        $wgOut->addHTML(PostComment::getForm(true, $user_talk, true));
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        /// ACTION INFORMATION
        $maxrcid = $dbr->selectField('recentchanges', 'max(rc_id)', array('rc_cur_id=' . $aid), __METHOD__);
        $wgOut->addHTML("<div class='nap_section minor_section'>");
        $wgOut->addHTML("<a name='action' id='anchor-action'></a>");
        $wgOut->addHTML("<h2 class='nap_header'> " . wfMsg('nap_action') . "</h2>");
        $wgOut->addHTML("<div class='nap_body section_text'>");
        $wgOut->addHTML("<form action='{$this->me->getFullURL()}' name='nap_form' method='post' onsubmit='return checkNap();'>");
        $wgOut->addHTML("<input type='hidden' name='target' value='" . htmlspecialchars($title->getText()) . "'/>");
        $wgOut->addHTML("<input type='hidden' name='page' value='{$aid}'/>");
        $wgOut->addHTML("<input type='hidden' name='newbie' value='" . $wgRequest->getVal('newbie', 0) . "'/>");
        $wgOut->addHTML("<input type='hidden' name='prevuser' value='" . $user->getName() . "'/>");
        $wgOut->addHTML("<input type='hidden' name='maxrcid' value='{$maxrcid}'/>");
        $wgOut->addHTML("<table>");
        $suggested = $dbr->selectField('suggested_titles', 'count(*)', array('st_title' => $title->getDBKey()), __METHOD__);
        if ($suggested > 0) {
            $wgOut->addHTML("<tr><td valign='top'>" . wfMsg('nap_suggested_warning') . "</td></tr>");
        }
        $wgOut->addHTML("</table>");
        $wgOut->addHTML(wfMsg('nap_actiontemplates'));
        if ($wgUser->isAllowed('delete') || $wgUser->isAllowed('move')) {
            $wgOut->addHTML(wfMsg('nap_actionmovedeleteheader'));
            if ($wgUser->isAllowed('move')) {
                $wgOut->addHTML(wfMsg('nap_actionmove', htmlspecialchars($title->getText())));
            }
            if ($wgUser->isAllowed('delete')) {
                $wgOut->addHTML(wfMsg('nap_actiondelete'));
            }
        }
        // BUTTONS
        $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_skip') . "' id='nap_skip' name='nap_skip' class='button secondary' />");
        if (!$locked) {
            $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_markaspatrolled') . "' id='nap_submit' name='nap_submit' class='button primary' />");
        }
        $wgOut->addHTML("</form>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML("</div>");
        $wgOut->addHTML(<<<END
<script type='text/javascript'>

var tabindex = 1;
for(i = 0; i < document.forms.length; i++) {
\tfor (j = 0; j < document.forms[i].elements.length; j++) {
\t\tswitch (document.forms[i].elements[j].type) {
\t\t\tcase 'submit':
\t\t\tcase 'text':
\t\t\tcase 'textarea':
\t\t\tcase 'checkbox':
\t\t\tcase 'button':
\t\t\t\tdocument.forms[i].elements[j].tabIndex = tabindex++;
\t\t\t\tbreak;
\t\t\tdefault:
\t\t\t\tbreak;
\t\t}
\t}
}

// Handlers for expand/contract arrows
(function (\$) {
\$('.nap_expand').click(function() {
\tvar thisSpan = \$(this);
\tvar body = thisSpan.parent().next();
\tvar footer = body.next();
\tif (body.css('display') != 'none') {
\t\tfooter.hide();
\t\tbody.css('overflow', 'hidden');
\t\tvar oldHeight = body.height();
\t\tbody.animate(
\t\t\t{ height: 0 },
\t\t\t200,
\t\t\t'swing',
\t\t\tfunction () {
\t\t\t\tthisSpan.html('&#9658;');
\t\t\t\tbody
\t\t\t\t\t.hide()
\t\t\t\t\t.height(oldHeight);
\t\t\t});
\t} else {
\t\tvar oldHeight = body.height();
\t\tbody.height(0);
\t\tbody.animate(
\t\t\t{ height: oldHeight },
\t\t\t200,
\t\t\t'swing',
\t\t\tfunction () {
\t\t\t\tthisSpan.html('&#9660;');
\t\t\t\tfooter.show();
\t\t\t\tbody.css('overflow', 'visible');
\t\t\t});
\t}
\treturn false;
});
})(jQuery);

</script>

END
);
    }
 /**
  * This method is used to process non-article HTML
  */
 static function processHTML($body, $action = '', $opts = array())
 {
     global $wgUser, $wgTitle;
     $processHTML = true;
     // $wgTitle isn't used in the hook below
     wfRunHooks('PreWikihowProcessHTML', array($wgTitle, &$processHTML));
     if (!$processHTML) {
         return $body;
     }
     $doc = PHPQuery::newDocument($body);
     //run ShowGrayContainer hook for this
     if (@$opts['show-gray-container']) {
         pq("#bodycontents")->addClass("minor_section");
     }
     //let's mark each bodycontents section so we can target it with CSS
     if ($action) {
         pq("#bodycontents")->addClass("bc_" . $action);
     }
     //default each mw-htmlform-submit button to a primary button
     //gotta clear too because we're floating it now
     pq(".mw-htmlform-submit")->addClass("primary button buttonright");
     pq(".mw-htmlform-submit")->after("<div class='clearall'></div>");
     //USER PREFERENCES//////////////////////
     pq("#mw-prefsection-echo")->append(pq("#mw-prefsection-echo-emailsettingsind"));
     //DISCUSSION/USER TALK//////////////////////
     //move some pieces above the main part
     pq("#bodycontents")->before(pq(".template_top")->addClass("wh_block"));
     pq("#bodycontents")->before(pq(".archive_table")->addClass("wh_block"));
     //remove those useless paragraph line breaks
     $bc = preg_replace('/<p><br><\\/p>/', '', pq("#bodycontents")->html());
     pq("#bodycontents")->html($bc);
     //insert postcomment form
     $pc = new PostComment();
     $pcf = $pc->getForm(false, $wgTitle, true);
     if ($pcf && $wgTitle->getFullURL() != $wgUser->getUserPage()->getTalkPage()->getFullURL()) {
         $pc_form = $pcf;
         pq("#bodycontents")->append($pc_form);
     } else {
         $pc_form = '<a name="postcomment"></a><a name="post"></a>';
         pq(".de:last")->prepend($pc_form);
     }
     //HISTORY//////////////////////
     //move top nav down a smidge
     pq("#history_form")->before(pq(".navigation:first"));
     //EDIT PREVIEW//////////////////////
     if (substr($action, 0, 6) == 'submit') {
         $name = $action == 'submit2' ? "#editpage" : "#editform";
         $preview = pq("#wikiPreview");
         $changes = pq("#wikiDiff")->addClass("wh_block");
         pq("#wikiPreview")->remove();
         pq("#wikiDiff")->remove();
         //preview before or after based on user preference
         if ($wgUser->getOption('previewontop')) {
             pq($name)->before($preview);
             pq($name)->before($changes);
         } else {
             pq($name)->after($preview);
             pq($name)->after($changes);
         }
     }
     $markPatrolledLink = self::getMarkPatrolledLink();
     if ($markPatrolledLink) {
         pq('#bodycontents')->append($markPatrolledLink);
     }
     return $doc->htmlOuter();
 }
示例#5
0
 /**
  * 提交评论
  *
  * @return [type] [description]
  */
 public function actionPostComment()
 {
     $nickname = trim($this->_gets->getParam('nickname'));
     $email = trim($this->_gets->getParam('email'));
     $postId = trim($this->_gets->getParam('postId'));
     $comment = trim($this->_gets->getParam('comment'));
     try {
         if (empty($postId)) {
             throw new Exception('编号丢失');
         } elseif (empty($nickname) || empty($email) || empty($comment)) {
             throw new Exception('昵称、邮箱、内容必须填写');
         }
         $bagecmsPostCommentModel = new PostComment();
         $bagecmsPostCommentModel->attributes = array('post_id' => $postId, 'nickname' => $nickname, 'email' => $email, 'content' => $comment);
         if ($bagecmsPostCommentModel->save()) {
             $var['state'] = 'success';
             $var['message'] = '提交成功';
         } else {
             throw new Exception(CHtml::errorSummary($bagecmsPostCommentModel, null, null, array('firstError' => '')));
         }
     } catch (Exception $e) {
         $var['state'] = 'error';
         $var['message'] = '出现错误:' . $e->getMessage();
     }
     exit(CJSON::encode($var));
 }
示例#6
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if (XUtils::method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif (XUtils::method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
         is_array($ids) && ($ids = implode(',', $ids));
     } else {
         XUtils::message('errorBack', '只支持POST,GET数据');
     }
     empty($ids) && XUtils::message('error', '未选择记录');
     switch ($command) {
         case 'delete':
             parent::_acl('post_delete');
             Post2tags::xdelete($ids);
             $commentModel = new PostComment();
             $commentModel->deleteAll('post_id IN(' . $ids . ')');
             AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids));
             parent::_delete(new Post(), $ids, array('index'), array('attach_file', 'attach_thumb'));
             break;
         case 'commentDelete':
             parent::_acl('post_comment_delete');
             AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容评论,ID:' . $ids));
             parent::_delete(new PostComment(), $ids, array('comment'));
             break;
         case 'commentVerify':
             parent::_acl('post_comment_verify');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '审核评论,ID:' . $ids));
             parent::_verify(new PostComment(), 'verify', $ids, array('comment'));
             break;
         case 'commentUnVerify':
             parent::_acl('post_comment_verify');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '取消评论审核,ID:' . $ids));
             parent::_verify(new PostComment(), 'unVerify', $ids, array('comment'));
             break;
         case 'verify':
             parent::_acl('post_verify');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量审核内容,ID:' . $ids));
             parent::_verify(new Post(), 'verify', $ids, array('index'));
             break;
         case 'unVerify':
             parent::_acl('post_verify');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量取消内容审核,ID:' . $ids));
             parent::_verify(new Post(), 'unVerify', $ids, array('index'));
             break;
         case 'commend':
             parent::_acl('post_commend');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量推荐内容,ID:' . $ids));
             parent::_commend(new Post(), 'commend', $ids, array('index'));
             break;
         case 'unCommend':
             parent::_acl('post_commend');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '批量取消内容推荐,ID:' . $ids));
             parent::_commend(new Post(), 'unCommend', $ids, array('index'));
             break;
         case 'specialDelete':
             parent::_acl('post_special_delete');
             AdminLogger::_create(array('catalog' => 'delete', 'intro' => '删除内容,ID:' . $ids));
             parent::_delete(new Special(), $ids, array('special'), array('attach_file', 'attach_thumb'));
             break;
         default:
             throw new CHttpException(404, '错误的操作类型:' . $command);
             break;
     }
 }
 function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgTitle;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (!($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()))) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     wfLoadExtensionMessages("NFDGuardian");
     if ($wgRequest->getVal('fetchInnards')) {
         //get next article to vote on
         $wgOut->disable();
         $result = self::getNextInnards($wgRequest->getVal('nfd_type'));
         print_r(json_encode($result));
         return;
     } else {
         if ($wgRequest->getVal('getVoteBlock')) {
             //get all the votes for the right rail module
             $wgOut->setArticleBodyOnly(true);
             $wgOut->addHTML(self::getVoteBlock($wgRequest->getVal('nfd_id')));
             return;
         } else {
             if ($wgRequest->getVal('edit')) {
                 //get the html that goes into the page when a user clicks the edit tab
                 $wgOut->setArticleBodyOnly(true);
                 $t = Title::newFromID($wgRequest->getVal('articleId'));
                 if ($t) {
                     $a = new Article($t);
                     $editor = new EditPage($a);
                     $editor->edit();
                     //Old code for when we wanted to remove
                     //the nfd template from the edit window
                     /*$content = $wgOut->getHTML();
                     				$wgOut->clearHTML();
                     
                     				//grab the edit form
                     				$data = array();
                     				$data['form'] = $content;
                     
                     				//then take out the template
                     				$c = new NFDProcessor();
                     				$template = $c->getFullTemplate($wgRequest->getVal('nfd_id'));
                     				$articleContent = $a->getContent();
                     				$articleContent = str_replace($template, "", $articleContent);
                     				$data['newContent'] = $articleContent;
                     				print_r(json_encode($data));*/
                 }
                 return;
             } else {
                 if ($wgRequest->getVal('discussion')) {
                     //get the html that goes into the page when a user clicks the discussion tab
                     $wgOut->setArticleBodyOnly(true);
                     $t = Title::newFromID($wgRequest->getVal('articleId'));
                     if ($t) {
                         $tDiscussion = $t->getTalkPage();
                         if ($tDiscussion) {
                             $a = new Article($tDiscussion);
                             $content = $a->getContent();
                             $wgOldTitle = $wgTitle;
                             $wgTitle = $tDiscussion;
                             $wgOut->addHTML($wgOut->parse($content));
                             $wgOut->addHTML(PostComment::getForm(true, $tDiscussion, true));
                             $wgTitle = $wgOldTitle;
                         }
                     }
                     return;
                 } else {
                     if ($wgRequest->getVal('confirmation')) {
                         //get confirmation dialog after user has edited the article
                         $wgOut->setArticleBodyOnly(true);
                         echo $this->confirmationModal($wgRequest->getVal('articleId'));
                         return;
                     } else {
                         if ($wgRequest->getVal('history')) {
                             //get the html that goes into the page when a user clicks the history tab
                             $wgOut->setArticleBodyOnly(true);
                             $t = Title::newFromID($wgRequest->getVal('articleId'));
                             if ($t) {
                                 $historyContext = clone $this->getContext();
                                 $historyContext->setTitle($t);
                                 $historyContext->setWikiPage(WikiPage::factory($t));
                                 $pageHistory = Action::factory("history", WikiPage::factory($t), $historyContext);
                                 $pageHistory->onView();
                                 return;
                             }
                         } else {
                             if ($wgRequest->getVal('diff')) {
                                 //get the html that goes into the page when a user asks for a diffs
                                 $wgOut->setArticleBodyOnly(true);
                                 $t = Title::newFromID($wgRequest->getVal('articleId'));
                                 if ($t) {
                                     $a = new Article($t);
                                     $wgOut->addHtml('<div class="article_inner">');
                                     $a->view();
                                     $wgOut->addHtml('</div>');
                                 }
                                 return;
                             } else {
                                 if ($wgRequest->getVal('article')) {
                                     //get the html that goes into the page when a user clicks the article tab
                                     $wgOut->setArticleBodyOnly(true);
                                     $t = Title::newFromId($wgRequest->getVal('articleId'));
                                     if ($t) {
                                         $r = Revision::newFromTitle($t);
                                         if ($r) {
                                             $popts = $wgOut->parserOptions();
                                             $popts->setTidy(true);
                                             echo WikihowArticleHTML::processArticleHTML($wgOut->parse($r->getText(), $t, $popts), array('no-ads' => true, 'ns' => $t->getNamespace()));
                                         }
                                     }
                                     return;
                                 } else {
                                     if ($wgRequest->wasPosted()) {
                                         $wgOut->setArticleBodyOnly(true);
                                         if ($wgRequest->getVal('submitEditForm')) {
                                             //user has edited the article from within the NFD Guardian tool
                                             $wgOut->disable();
                                             $this->submitEdit();
                                             $result = self::getNextInnards($wgRequest->getVal('nfd_type'));
                                             print_r(json_encode($result));
                                             return;
                                         } else {
                                             //user has voted
                                             if ($wgRequest->getVal('nfd_skip', 0) == 1) {
                                                 NFDProcessor::skip($wgRequest->getVal('nfd_id'));
                                             } else {
                                                 NFDProcessor::vote($wgRequest->getVal('nfd_id'), $wgRequest->getVal('nfd_vote'));
                                             }
                                             $wgOut->disable();
                                             $result = self::getNextInnards($wgRequest->getVal('nfd_type'));
                                             print_r(json_encode($result));
                                             return;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /**
      * This is the shell of the page, has the buttons, etc.
      */
     $wgOut->addJScode('nfdgj');
     $wgOut->addJScode('csjs');
     $wgOut->addCSScode('nfdgc');
     $wgOut->addCSScode('diffc');
     //add delete confirmation to bottom of page
     $wgOut->addHtml("<div class='waiting'><img src='" . wfGetPad('/extensions/wikihow/rotate.gif') . "' alt='' /></div>");
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $wgOut->addHTML($tmpl->execute('NFDdelete.tmpl.php'));
     $wgOut->setHTMLTitle(wfMsg('nfd'));
     $wgOut->setPageTitle(wfMsg('nfd'));
     // add standings widget
     $group = new NFDStandingsGroup();
     $indi = new NFDStandingsIndividual();
     $indi->addStatsWidget();
     $group->addStandingsWidget();
 }
示例#8
0
 /**
  * 为帖子回复投票
  * Enter description here ...
  * @param unknown_type $commentId
  * @param unknown_type $value
  */
 public function actionPostComment($commentId = 0, $value = 0)
 {
     if ($commentId) {
         //$vote = new PostVote;
         $vote = PostCommentVote::model()->findByAttributes(array('userId' => Yii::app()->user->id, 'commentId' => $commentId));
         if ($vote && $vote->value == $value) {
             $result = $vote->delete();
         } else {
             $vote or $vote = new PostCommentVote();
             $vote->commentId = $commentId;
             $vote->value = $value;
             $vote->userId = Yii::app()->user->id;
             $vote->addTime = time();
             $result = $vote->save();
         }
         if ($result) {
             $postComment = PostComment::model()->findByPk($vote->commentId);
             $score = $postComment->voteupCount - $postComment->votedownCount;
             $this->renderPartial('result', array('score' => $score, 'voteupers' => $postComment->voteupers));
         }
     }
 }
示例#9
0
文件: _comment.php 项目: bigbol/ziiwo
<?php

$bagecmsCommentModel = new PostComment();
$bagecmsCommentCriteria = new CDbCriteria();
$bagecmsCommentCriteria->condition = 'post_id=' . $bagecmsShow['id'];
$bagecmsCommentCriteria->order = 't.id DESC';
$bagecmsCommentCount = $bagecmsCommentModel->count($bagecmsCommentCriteria);
$bagecmsCommentPages = new CPagination($bagecmsCommentCount);
$bagecmsCommentPages->pageSize = 15;
$bagecmsCommentPageParams = XUtils::buildCondition($_GET, array('id'));
$bagecmsCommentPageParams['#'] = 'commentList';
$bagecmsCommentPages->params = is_array($bagecmsCommentPageParams) ? $bagecmsCommentPageParams : array();
$bagecmsCommentCriteria->limit = $bagecmsCommentPages->pageSize;
$bagecmsCommentCriteria->offset = $bagecmsCommentPages->currentPage * $bagecmsCommentPages->pageSize;
$bagecmsCommentList = $bagecmsCommentModel->findAll($bagecmsCommentCriteria);
?>
<div id="comment">
      <div class="boxTit ">
        <h3>最新评论</h3>
      </div>
      <div class="bmc">
      <?php 
foreach ($bagecmsCommentList as $key => $row) {
    ?>
        <dl class="item clear">
          <dt class="user"> <a class="title" ><?php 
    echo CHtml::encode($row->nickname);
    ?>
</a> <span class=" xw0"><?php 
    echo date('Y-m-d H:i:s', $row['create_time']);
    ?>