本文整理匯總了PHP中Answer::getSpecialCategoryTag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Answer::getSpecialCategoryTag方法的具體用法?PHP Answer::getSpecialCategoryTag怎麽用?PHP Answer::getSpecialCategoryTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Answer
的用法示例。
在下文中一共展示了Answer::getSpecialCategoryTag方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
function create()
{
global $wgUser, $wgContLang;
if (wfReadOnly()) {
return false;
}
if (empty($this->title) || !$this->title->userCan('edit') || !$this->title->userCan('create')) {
return false;
}
if ($this->badWordsTest()) {
return false;
}
if (!wfRunHooks('CreateDefaultQuestionPageFilter', array($this->title))) {
wfDebug(__METHOD__ . ": question '{$this->title}' filtered out by hook\n");
return false;
}
if ($this->searchTest()) {
return false;
}
$default_text = Answer::getSpecialCategoryTag("unanswered");
//add default category tags passed in
if ($this->categories) {
$categories_array = explode("|", $this->categories);
foreach ($categories_array as $category) {
$default_text .= "\n[[" . $wgContLang->getNsText(NS_CATEGORY) . ":" . ucfirst($category) . "]]";
}
}
$flags = EDIT_NEW;
$article = new Article($this->title);
$article->doEdit($default_text, wfMsgForContent("new_question_comment"), $flags);
if ($wgUser->isLoggedIn()) {
// check user preferences before adding to watchlist (RT #45647)
$watchCreations = $wgUser->getGlobalPreference('watchcreations');
if (!empty($watchCreations)) {
$wgUser->addWatch($this->title);
}
}
//store question in session so we can give attribution if they create an account afterwards
$_SESSION['wsQuestionAsk'] = "";
if ($wgUser->isAnon()) {
$_SESSION['wsQuestionAsk'] = $this->question;
}
return true;
}
示例2: create
function create($text)
{
global $wgOut, $wgUser, $wgContLang;
if (wfReadOnly()) {
return false;
}
if ($this->badWordsTest()) {
return false;
}
if (!wfRunHooks('CreateDefaultQuestionPageFilter', array($this->title))) {
return false;
}
if (!$this->title->userCan('edit') || !$this->title->userCan('create')) {
return false;
}
if ($this->searchTest()) {
return false;
}
$default_text = $text . Answer::getSpecialCategoryTag("unanswered");
//add default category tags passed in
if ($this->categories) {
$categories_array = explode("|", $this->categories);
foreach ($categories_array as $category) {
$default_text .= "\n[[" . $wgContLang->getNsText(NS_CATEGORY) . ":" . ucfirst($category) . "]]";
}
}
$flags = EDIT_NEW;
$article = new Article($this->title);
$article->doEdit($default_text, wfMsgForContent("new_question_comment"), $flags);
if ($wgUser->isLoggedIn()) {
$wgUser->addWatch($this->title);
}
//store question in session so we can give attribution if they create an account afterwards
$_SESSION['wsQuestionAsk'] = "";
if ($wgUser->isAnon()) {
$_SESSION['wsQuestionAsk'] = $this->question;
}
return true;
}
示例3: fnMarkAsAnswered
function fnMarkAsAnswered($editpage)
{
global $wgRequest;
$answered = Answer::getSpecialCategoryTag("answered");
$unanswered = Answer::getSpecialCategoryTag("unanswered");
if (!Answer::newFromTitle($editpage->mTitle)->isQuestion(false, false)) {
return true;
}
if (Title::newFromRedirect($editpage->textbox1) != NULL) {
return true;
}
if (Answer::isMarkedForDeletion($editpage->textbox1)) {
$editpage->textbox1 = trim(str_ireplace(array($answered, $unanswered), '', $editpage->textbox1));
return true;
}
if (Answer::isContentAnswered($editpage->textbox1)) {
$editpage->textbox1 = trim(str_ireplace($unanswered, '', $editpage->textbox1));
if (strpos($editpage->textbox1, $answered) === false) {
$editpage->textbox1 = $editpage->textbox1 . "\n" . $answered;
}
} else {
$editpage->textbox1 = trim(str_ireplace($answered, '', $editpage->textbox1));
if (strpos($editpage->textbox1, $unanswered) === false) {
$editpage->textbox1 = $unanswered . "\n" . $editpage->textbox1;
}
}
$editpage->textbox1 = trim($editpage->textbox1);
return true;
}