当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::getID方法代码示例

本文整理汇总了PHP中Article::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::getID方法的具体用法?PHP Article::getID怎么用?PHP Article::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Article的用法示例。


在下文中一共展示了Article::getID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Create a new poll
  * @param wgRequest question
  * @param wgRequest answer   (expects PHP array style in the form <input name=answer[]>)
  * Page Content should be of a different style so we have to translate
  *	  *question 1\n
  *	  *question 2\n
  */
 public static function create()
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     $title = $app->wg->Request->getVal('question');
     $answers = $app->wg->Request->getArray('answer');
     // array
     $title_object = Title::newFromText($title, NS_WIKIA_POLL);
     if (is_object($title_object) && $title_object->exists()) {
         $res = array('success' => false, 'error' => $app->renderView('Error', 'Index', array(wfMsg('wikiapoll-error-duplicate'))));
     } else {
         if ($title_object == null) {
             $res = array('success' => false, 'error' => $app->renderView('Error', 'Index', array(wfMsg('wikiapoll-error-invalid-title'))));
         } else {
             $content = "";
             foreach ($answers as $answer) {
                 $content .= "*{$answer}\n";
             }
             /* @var $article WikiPage */
             $article = new Article($title_object, NS_WIKIA_POLL);
             $article->doEdit($content, 'Poll Created', EDIT_NEW, false, $app->wg->User);
             $title_object = $article->getTitle();
             // fixme: check status object
             $res = array('success' => true, 'pollId' => $article->getID(), 'url' => $title_object->getLocalUrl(), 'question' => $title_object->getPrefixedText());
         }
     }
     wfProfileOut(__METHOD__);
     return $res;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:37,代码来源:WikiaPollAjax.class.php

示例2: run

 /**
  * Run a refreshLinks job
  * @return boolean success
  */
 function run()
 {
     global $wgTitle, $wgUser, $wgLang, $wrGedcomExportDirectory;
     $wgTitle = $this->title;
     // FakeTitle (the default) generates errors when accessed, and sometimes I log wgTitle, so set it to something else
     $wgUser = User::newFromName('WeRelate agent');
     // set the user
     $treeId = $this->params['tree_id'];
     $treeName = $this->params['name'];
     $treeUser = $this->params['user'];
     $filename = "{$wrGedcomExportDirectory}/{$treeId}.ged";
     $ge = new GedcomExporter();
     $error = $ge->exportGedcom($treeId, $filename);
     if ($error) {
         $this->error = $error;
         return false;
     }
     // leave a message for the tree requester
     $userTalkTitle = Title::newFromText($treeUser, NS_USER_TALK);
     $article = new Article($userTalkTitle, 0);
     if ($article->getID() != 0) {
         $text = $article->getContent();
     } else {
         $text = '';
     }
     $title = Title::makeTitle(NS_SPECIAL, 'Trees');
     $msg = wfMsg('GedcomExportReady', $wgLang->date(wfTimestampNow(), true, false), $treeName, $title->getFullURL(wfArrayToCGI(array('action' => 'downloadExport', 'user' => $treeUser, 'name' => $treeName))));
     $text .= "\n\n" . $msg;
     $success = $article->doEdit($text, 'GEDCOM export ready');
     if (!$success) {
         $this->error = 'Unable to edit user talk page: ' . $treeUser;
         return false;
     }
     return true;
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:39,代码来源:GedcomExportJob.php

示例3: getRawPage

 /**
 		Gets the 'raw' content from an article page.
 */
 public function getRawPage(&$obj)
 {
     if (!isset($obj) || empty($obj)) {
         return null;
     }
     if (!is_a($obj, 'Title')) {
         $title = self::getTitle($obj);
     } else {
         $title = $obj;
     }
     $article = new Article($title);
     if ($article->getID() == 0) {
         return null;
     }
     return $article->getContent();
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:19,代码来源:MiscParserFunctions.body.php

示例4: wfUndeleteNFD

function wfUndeleteNFD(&$title, $create)
{
    if ($title->getNamespace() != NS_MAIN) {
        return true;
    }
    $article = new Article($title);
    $revision = Revision::newFromTitle($title);
    // if an article becomes a redirect, vanquish all previous nfd entries
    if (preg_match("@^#REDIRECT@", $revision->getText())) {
        NFDProcessor::markPreviousAsInactive($article->getID());
        return true;
    }
    // do the templates
    wfDebug("NFD: Looking for NFD templates\n");
    $l = new NFDProcessor($revision, $article);
    $l->process();
    return true;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:18,代码来源:NFDGuardian.php

示例5: getTextSnippet

 /**
  * Gets a plain text snippet from an article.  An optional second argument allows a break limit.
  * When given, if the text is greater than $breakLimit, truncate it to $length, if its less than
  * $breakLimit, return the whole snippet.  This allows better snippets for text that is very close
  * in character count to $length.
  *
  * For example if $length=100 and $breakLimit=200 and the source text is 205 characters, the content
  * will be truncated at the word closest to 100 characters.  If the source text is 150 characters,
  * then this method will return all 150 characters.
  *
  * If however we only give one parameter, $length=200 and the source text is 205 characters, we
  * will return text truncated at the word nearest 200 characters, likely only leaving out a single
  * word from the snippet.  This can lead to a strange user experience in some cases (e.g. a user
  * clicks a link in a notification email to see the full edit and finds that there's only one word
  * they weren't able to read from the email)
  *
  * @param integer $length [OPTIONAL] The maximum snippet length, defaults to 100
  * @param integer $breakLimit A breakpoint for showing the full snippet.
  *
  * @return string The plain text snippet, it includes SUFFIX at the end of the string
  * if the length of the article's content is longer than $length, the text will be cut
  * respecting the integrity of the words
  *
  * @throws WikiaException If $length is bigger than MAX_LENGTH
  *
  * @example
  * $service = new ArticleService( $article );
  * $snippet = $service->getTextSnippet( 250, 400 );
  *
  * $service->setArticleById( $title->getArticleID() );
  * $snippet = $service->getTextSnippet( 50 );
  *
  * $service->setArticle( $anotherArticle );
  * $snippet = $service->getTextSnippet();
  */
 public function getTextSnippet($length = 100, $breakLimit = null)
 {
     // don't allow more than the maximum to avoid flooding Memcached
     if ($length > self::MAX_LENGTH) {
         throw new WikiaException('Maximum allowed length is ' . self::MAX_LENGTH);
     }
     // It may be that the article is just not there
     if (!$this->article instanceof Article) {
         return '';
     }
     $id = $this->article->getID();
     if ($id <= 0) {
         return '';
     }
     $text = $this->getTextSnippetSource($id);
     $length = $this->adjustTextSnippetLength($text, $length, $breakLimit);
     $snippet = wfShortenText($text, $length, $useContentLanguage = true);
     return $snippet;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:54,代码来源:ArticleService.class.php

示例6: approveLink

 public function approveLink($id)
 {
     $link = $this->getLink($id);
     // Create the wiki page for the newly-approved link
     $linkTitle = Title::makeTitleSafe(NS_LINK, $link['title']);
     $article = new Article($linkTitle);
     $article->doEdit($link['url'], wfMsgForContent('linkfilter-edit-summary'));
     $newPageId = $article->getID();
     // Tie link record to wiki page
     $dbw = wfGetDB(DB_MASTER);
     wfSuppressWarnings();
     $date = date('Y-m-d H:i:s');
     wfRestoreWarnings();
     $dbw->update('link', array('link_page_id' => intval($newPageId), 'link_approved_date' => $date), array('link_id' => intval($id)), __METHOD__);
     $dbw->commit();
     if (class_exists('UserStatsTrack')) {
         $stats = new UserStatsTrack($link['user_id'], $link['user_name']);
         $stats->incStatField('links_approved');
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:20,代码来源:LinkClass.php

示例7: setup

 protected function setup($par)
 {
     global $wgRequest, $wgUser;
     // Options
     $opts = new FormOptions();
     $this->opts = $opts;
     // bind
     $opts->add('page1', '');
     $opts->add('page2', '');
     $opts->add('rev1', '');
     $opts->add('rev2', '');
     $opts->add('action', '');
     // Set values
     $opts->fetchValuesFromRequest($wgRequest);
     $title1 = Title::newFromText($opts->getValue('page1'));
     $title2 = Title::newFromText($opts->getValue('page2'));
     if ($title1 && $title1->exists() && $opts->getValue('rev1') == '') {
         $pda = new Article($title1);
         $pdi = $pda->getID();
         $pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
         $opts->setValue('rev1', $pdLastRevision->getId());
     } elseif ($opts->getValue('rev1') != '') {
         $pdrev = Revision::newFromId($opts->getValue('rev1'));
         if ($pdrev) {
             $opts->setValue('page1', $pdrev->getTitle()->getPrefixedText());
         }
     }
     if ($title2 && $title2->exists() && $opts->getValue('rev2') == '') {
         $pda = new Article($title2);
         $pdi = $pda->getID();
         $pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
         $opts->setValue('rev2', $pdLastRevision->getId());
     } elseif ($opts->getValue('rev2') != '') {
         $pdrev = Revision::newFromId($opts->getValue('rev2'));
         if ($pdrev) {
             $opts->setValue('page2', $pdrev->getTitle()->getPrefixedText());
         }
     }
     // Store some objects
     $this->skin = $wgUser->getSkin();
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:41,代码来源:SpecialComparePages.php

示例8: bwVirtualPageSwitchInit

function bwVirtualPageSwitchInit(&$title, &$article)
{
    // let mediawiki handle those.
    $ns = $title->getNamespace();
    if (NS_MEDIA == $ns || NS_CATEGORY == $ns || NS_IMAGE == $ns) {
        return true;
    }
    // let mediawiki handle those also.
    global $bwVirtualPageExcludeNamespaces;
    if (in_array($ns, $bwVirtualPageExcludeNamespaces)) {
        return true;
    }
    $article = new Article($title);
    // let mediawiki handle the articles that already exist
    if ($article->getID() != 0) {
        return true;
    }
    // now, we are interested in non-existing articles!
    wfRunHooks('VirtualPage', array(&$title, &$article));
    return true;
}
开发者ID:clrh,项目名称:mediawiki,代码行数:21,代码来源:VirtualPage.php

示例9: UW_Authors_List

function UW_Authors_List ( &$out, &$text ) {
	global $wgTitle, $wgRequest, $wgShowAuthorsNamespaces, $wgShowAuthors;

	/* do nothing if the option is disabled
	 * (but why would the extension be enabled?) */
	if ( !$wgShowAuthors )
		return true;

	// only build authors on namespaces in $wgShowAuthorsNamespaces
	if ( !in_array ( $wgTitle->getNamespace(), $wgShowAuthorsNamespaces ) )
		return true;

	/* get the contribs from the database (don't use the default
	 * MediaWiki one since it ignores the current user) */
	$article = new Article ( $wgTitle );
	$contribs = array();
	$db = wfGetDB ( DB_MASTER );
	$rev_table  = $db->tableName ( "revision" );
	$user_table = $db->tableName ( "user" );

	$sql = "SELECT rev_user, rev_user_text, user_real_name, MAX(rev_timestamp) as timestamp
		FROM $rev_table LEFT JOIN $user_table ON rev_user = user_id
		WHERE rev_page = {$article->getID()}
		GROUP BY rev_user, rev_user_text, user_real_name
		ORDER BY timestamp DESC";

	$results = $db->query ( $sql, __METHOD__ );
	while ( $line = $db->fetchObject ( $results ) ) {
		$contribs[] = array(
			$line->rev_user,
			$line->rev_user_text,
			$line->user_real_name
		);
	}

	$db->freeResult ( $results );


	// return if there are no authors
	if ( sizeof ( $results ) <= 0 )
		return true;

	// now build a sensible authors display in HTML
	require_once ( "includes/Credits.php" );

	

	$authors = "\n<div class='authors'>" .
		"<h4>" . wfMsg( 'authors_authors' ) . "</h4>" .
		"<ul>";
	$anons = 0;
	foreach ( $contribs as $author ) {
		$id       = $author[0];
		$username = $author[1];
		$realname = $author[2];

		if ( $id != "0" ) { // user with an id
			// FIME: broken. Incompatible with 1.14. Method creditLink() was renamed and changed.
			$author_link = $realname
				? creditLink( $username, $realname )
				: creditLink( $username );
			$authors .= "<li>$author_link</li>";
		} else { // anonymous
			$anons++;
		}
	}
	// add the anonymous entries
	if ( $anons > 0 )
		$authors .= "<li>" . wfMsg( 'authors_anonymous' ) . "</li>";
	$authors .= "</ul></div>";

	$text .= $authors;
	return true;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:74,代码来源:Authors.php

示例10: execute

 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgContLang, $wgHooks, $wgSupressPageTitle, $wgPollScripts;
     $wgSupressPageTitle = true;
     // Blocked users cannot create polls
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage(false);
         return false;
     }
     // Check that the DB isn't locked
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     /**
      * Redirect anonymous users to login page
      * It will automatically return them to the CreatePoll page
      */
     if ($wgUser->getID() == 0) {
         $wgOut->setPageTitle(wfMsgHtml('poll-woops'));
         $login = SpecialPage::getTitleFor('Userlogin');
         $wgOut->redirect($login->getLocalURL('returnto=Special:CreatePoll'));
         return false;
     }
     /**
      * Create Poll Thresholds based on User Stats
      */
     global $wgCreatePollThresholds;
     if (is_array($wgCreatePollThresholds) && count($wgCreatePollThresholds) > 0) {
         $canCreate = true;
         $stats = new UserStats($wgUser->getID(), $wgUser->getName());
         $stats_data = $stats->getUserStats();
         $threshold_reason = '';
         foreach ($wgCreatePollThresholds as $field => $threshold) {
             if ($stats_data[$field] < $threshold) {
                 $canCreate = false;
                 $threshold_reason .= ($threshold_reason ? ', ' : '') . "{$threshold} {$field}";
             }
         }
         if ($canCreate == false) {
             $wgSupressPageTitle = false;
             $wgOut->setPageTitle(wfMsg('poll-create-threshold-title'));
             $wgOut->addHTML(wfMsg('poll-create-threshold-reason', $threshold_reason));
             return '';
         }
     }
     // i18n for JS
     $wgHooks['MakeGlobalVariablesScript'][] = 'CreatePoll::addJSGlobals';
     // Add CSS & JS
     $wgOut->addScriptFile($wgPollScripts . '/Poll.js');
     $wgOut->addExtensionStyle($wgPollScripts . '/Poll.css');
     // If the request was POSTed, try creating the poll
     if ($wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false) {
         $_SESSION['alreadysubmitted'] = true;
         // Add poll
         $poll_title = Title::makeTitleSafe(NS_POLL, $wgRequest->getVal('poll_question'));
         if (is_null($poll_title) && !$poll_title instanceof Title) {
             $wgSupressPageTitle = false;
             $wgOut->setPageTitle(wfMsg('poll-create-threshold-title'));
             $wgOut->addHTML(wfMsg('poll-create-threshold-reason', $threshold_reason));
             return '';
         }
         // Put choices in wikitext (so we can track changes)
         $choices = '';
         for ($x = 1; $x <= 10; $x++) {
             if ($wgRequest->getVal("answer_{$x}")) {
                 $choices .= $wgRequest->getVal("answer_{$x}") . "\n";
             }
         }
         // Create poll wiki page
         $localizedCategoryNS = $wgContLang->getNsText(NS_CATEGORY);
         $article = new Article($poll_title);
         $article->doEdit("<userpoll>\n{$choices}</userpoll>\n\n[[" . $localizedCategoryNS . ':' . wfMsgForContent('poll-category') . "]]\n" . '[[' . $localizedCategoryNS . ':' . wfMsgForContent('poll-category-user', $wgUser->getName()) . "]]\n" . '[[' . $localizedCategoryNS . ":{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}, {{subst:CURRENTYEAR}}]]\n\n__NOEDITSECTION__", wfMsgForContent('poll-edit-desc'));
         $newPageId = $article->getID();
         $p = new Poll();
         $poll_id = $p->addPollQuestion($wgRequest->getVal('poll_question'), $wgRequest->getVal('poll_image_name'), $newPageId);
         // Add choices
         for ($x = 1; $x <= 10; $x++) {
             if ($wgRequest->getVal("answer_{$x}")) {
                 $p->addPollChoice($poll_id, $wgRequest->getVal("answer_{$x}"), $x);
             }
         }
         // Clear poll cache
         $key = wfMemcKey('user', 'profile', 'polls', $wgUser->getID());
         $wgMemc->delete($key);
         // Redirect to new poll page
         $wgOut->redirect($poll_title->getFullURL());
     } else {
         $_SESSION['alreadysubmitted'] = false;
         include 'create-poll.tmpl.php';
         $template = new CreatePollTemplate();
         $wgOut->addTemplate($template);
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:99,代码来源:SpecialCreatePoll.php

示例11: updateUndelete

 static function updateUndelete($title, $isnewid)
 {
     $article = new Article($title);
     $id = $article->getID();
     self::setKey($id, $title);
     return true;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:7,代码来源:TitleKey_body.php

示例12: createQuizArticle

 /**
  * Create a new quiz eleemnt
  * @see WikiaQuizElement.class.php
  */
 public static function createQuizArticle()
 {
     wfProfileIn(__METHOD__);
     $wgRequest = F::app()->getGlobal('wgRequest');
     $wgUser = F::app()->getGlobal('wgUser');
     $title = $wgRequest->getVal('question');
     $title_object = Title::newFromText($title, NS_WIKIA_QUIZARTICLE);
     if (is_object($title_object) && $title_object->exists()) {
         $res = array('success' => false, 'error' => F::app()->renderView('Error', 'Index', array(wfMsg('wikiaquiz-error-duplicate-question'))));
     } else {
         if ($title_object == null) {
             $res = array('success' => false, 'error' => F::app()->renderView('Error', 'Index', array(wfMsg('wikiaquiz-error-invalid-question'))));
         } else {
             $error = null;
             $content = self::parseCreateEditQuizArticleRequest($wgRequest, null, $error);
             if ($error) {
                 $res = array('success' => false, 'error' => F::app()->renderView('Error', 'Index', array($error)));
             } else {
                 $article = new Article($title_object);
                 $status = $article->doEdit($content, 'Quiz Article Created', EDIT_NEW, false, $wgUser);
                 $title_object = $article->getTitle();
                 // fixme: check status object
                 $res = array('success' => true, 'quizElementId' => $article->getID(), 'url' => $title_object->getLocalUrl(), 'question' => $title_object->getPrefixedText());
             }
         }
     }
     wfProfileOut(__METHOD__);
     return $res;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:WikiaQuizAjax.class.php

示例13: getContent

 /**
  * Fetch initial editing page content.
  *
  * @param $def_text string
  * @returns mixed string on success, $def_text for invalid sections
  * @private
  */
 function getContent($def_text = '')
 {
     global $wgOut, $wgRequest, $wgParser;
     wfProfileIn(__METHOD__);
     # Get variables from query string :P
     $section = $wgRequest->getVal('section');
     $preload = $wgRequest->getVal('preload', $section === 'new' ? 'MediaWiki:addsection-preload' : '');
     $undoafter = $wgRequest->getVal('undoafter');
     $undo = $wgRequest->getVal('undo');
     // For message page not locally set, use the i18n message.
     // For other non-existent articles, use preload text if any.
     if (!$this->mTitle->exists()) {
         if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
             # If this is a system message, get the default text.
             $text = $this->mTitle->getDefaultMessageText();
             if ($text === false) {
                 $text = $this->getPreloadedText($preload);
             }
         } else {
             # If requested, preload some text.
             $text = $this->getPreloadedText($preload);
         }
         // For existing pages, get text based on "undo" or section parameters.
     } else {
         $text = $this->mArticle->getContent();
         if ($undo > 0 && $undoafter > 0 && $undo < $undoafter) {
             # If they got undoafter and undo round the wrong way, switch them
             list($undo, $undoafter) = array($undoafter, $undo);
         }
         if ($undo > 0 && $undo > $undoafter) {
             # Undoing a specific edit overrides section editing; section-editing
             # doesn't work with undoing.
             if ($undoafter) {
                 $undorev = Revision::newFromId($undo);
                 $oldrev = Revision::newFromId($undoafter);
             } else {
                 $undorev = Revision::newFromId($undo);
                 $oldrev = $undorev ? $undorev->getPrevious() : null;
             }
             # Sanity check, make sure it's the right page,
             # the revisions exist and they were not deleted.
             # Otherwise, $text will be left as-is.
             if (!is_null($undorev) && !is_null($oldrev) && $undorev->getPage() == $oldrev->getPage() && $undorev->getPage() == $this->mArticle->getID() && !$undorev->isDeleted(Revision::DELETED_TEXT) && !$oldrev->isDeleted(Revision::DELETED_TEXT)) {
                 $undotext = $this->mArticle->getUndoText($undorev, $oldrev);
                 if ($undotext === false) {
                     # Warn the user that something went wrong
                     $this->editFormPageTop .= $wgOut->parse('<div class="error mw-undo-failure">' . wfMsgNoTrans('undo-failure') . '</div>');
                 } else {
                     $text = $undotext;
                     # Inform the user of our success and set an automatic edit summary
                     $this->editFormPageTop .= $wgOut->parse('<div class="mw-undo-success">' . wfMsgNoTrans('undo-success') . '</div>');
                     $firstrev = $oldrev->getNext();
                     # If we just undid one rev, use an autosummary
                     if ($firstrev->mId == $undo) {
                         $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
                         $this->undidRev = $undo;
                     }
                     $this->formtype = 'diff';
                 }
             } else {
                 // Failed basic sanity checks.
                 // Older revisions may have been removed since the link
                 // was created, or we may simply have got bogus input.
                 $this->editFormPageTop .= $wgOut->parse('<div class="error mw-undo-norev">' . wfMsgNoTrans('undo-norev') . '</div>');
             }
         } elseif ($section != '') {
             if ($section == 'new') {
                 $text = $this->getPreloadedText($preload);
             } else {
                 // Get section edit text (returns $def_text for invalid sections)
                 $text = $wgParser->getSection($text, $section, $def_text);
             }
         }
     }
     wfProfileOut(__METHOD__);
     return $text;
 }
开发者ID:natalieschauser,项目名称:csp_media_wiki,代码行数:84,代码来源:EditPage.php

示例14: execute

    function execute($par)
    {
        global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
        global $wgRequest, $wgSitename, $wgLanguageCode, $IP;
        global $wgScript, $wgFilterCallback, $wgScriptPath;
        $this->setHeaders();
        require_once "{$IP}/extensions/wikihow/EditPageWrapper.php";
        require_once "{$IP}/includes/EditPage.php";
        $target = isset($par) ? $par : $wgRequest->getVal('target');
        if (!$target) {
            $wgOut->addHTML("No target specified. In order to thank a group of authors, a page must be provided.");
            return;
        }
        $title = Title::newFromDBKey($target);
        $me = Title::makeTitle(NS_SPECIAL, "ThankAuthors");
        if (!$wgRequest->getVal('token')) {
            $sk = $wgUser->getSkin();
            $talk_page = $title->getTalkPage();
            $token = $this->getToken1();
            $thanks_msg = wfMsg('thank-you-kudos', $title->getFullURL(), wfMsg('howto', $title->getText()));
            // add the form HTML
            $wgOut->addHTML(<<<EOHTML
\t\t\t\t<script type='text/javascript'>
\t\t\t\t\tfunction submitThanks () {
\t\t\t\t\t\tvar message = \$('#details').val();
\t\t\t\t\t\tif(message == "") {
\t\t\t\t\t\t\talert("Please enter a message.");
\t\t\t\t\t\t\treturn false;
\t\t\t\t\t\t}
\t\t\t\t\t\tvar url = '{$me->getFullURL()}?token=' + \$('#token')[0].value + '&target=' + \$('#target')[0].value + '&details=' + \$('#details')[0].value;
\t\t\t\t\t\tvar form = \$('#thanks_form');
\t\t\t\t\t\tform.html(\$('#thanks_response').html());
\t\t\t\t\t\t\$.get(url);
\t\t\t\t\t\treturn true;
\t\t\t\t\t}
\t\t\t\t</script>

\t\t\t\t<div id="thanks_response" style="display:none;">{$thanks_msg}</div>
\t\t\t\t<div id="thanks_form"><div class="section_text">
EOHTML
);
            $wgOut->addWikiText(wfMsg('enjoyed-reading-article', $title->getFullText(), $talk_page->getFullText()));
            $wgOut->addHTML("<input id=\"target\" type=\"hidden\" name=\"target\" value=\"{$target}\"/>\n\t\t\t\t<input id=\"token\" type=\"hidden\" name=\"{$token}\" value=\"{$token}\"/>\n\t\t\t\t");
            $wgOut->addHTML("<br />\n\t\t\t\t<textarea style='width:98%;' id=\"details\" rows=\"5\" cols=\"100\" name=\"details\"></textarea><br/>\n\t\t\t\t<br /><button onclick='submitThanks();' class='button primary'>" . wfMsg('submit') . "</button>\n\t\t\t\t</div></div>");
        } else {
            // this is a post, accept the POST data and create the
            // Request article
            wfLoadExtensionMessages('PostComment');
            $wgOut->setArticleBodyOnly(true);
            $user = $wgUser->getName();
            $real_name = User::whoIsReal($wgUser->getID());
            if ($real_name == "") {
                $real_name = $user;
            }
            $dateStr = $wgLang->timeanddate(wfTimestampNow());
            $comment = $wgRequest->getVal("details");
            $text = $title->getFullText();
            wfDebug("STA: got text...");
            // filter out links
            $preg = "/[^\\s]*\\.[a-z][a-z][a-z]?[a-z]?/i";
            $matches = array();
            if (preg_match($preg, $comment, $matches) > 0) {
                $wgOut->addHTML(wfMsg('no_urls_in_kudos', $matches[0]));
                return;
            }
            $comment = strip_tags($comment);
            $formattedComment = wfMsg('postcomment_formatted_thanks', $dateStr, $user, $real_name, $comment, $text);
            wfDebug("STA: comment {$formattedComment}\n");
            wfDebug("STA: Checking blocks...");
            $tmp = "";
            if ($wgUser->isBlocked()) {
                $this->blockedIPpage();
                return;
            }
            if (!$wgUser->getID() && $wgWhitelistEdit) {
                $this->userNotLoggedInPage();
                return;
            }
            if ($target == "Spam-Blacklist") {
                $wgOut->readOnlyPage();
                return;
            }
            wfDebug("STA: checking read only\n");
            if (wfReadOnly()) {
                $wgOut->readOnlyPage();
                return;
            }
            wfDebug("STA: checking rate limiter\n");
            if ($wgUser->pingLimiter('userkudos')) {
                $wgOut->rateLimited();
                return;
            }
            wfDebug("STA: checking blacklist\n");
            if ($wgFilterCallback && $wgFilterCallback($title, $comment, "")) {
                // Error messages or other handling should be
                // performed by the filter function
                return;
            }
            wfDebug("STA: checking tokens\n");
            $usertoken = $wgRequest->getVal('token');
//.........这里部分代码省略.........
开发者ID:biribogos,项目名称:wikihow-src,代码行数:101,代码来源:ThankAuthors.body.php

示例15: printPage

    function printPage($form_name, $embedded = false)
    {
        global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop;
        global $wgUser, $wgTitle;
        // Get contents of form-definition page.
        $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
        if (!$form_title || !$form_title->exists()) {
            if ($form_name === '') {
                $text = Html::element('p', array('class' => 'error'), wfMessage('sf_runquery_badurl')->text()) . "\n";
            } else {
                $text = Html::rawElement('p', array('class' => 'error'), wfMessage('sf_formstart_badform', SFUtils::linkText(SF_NS_FORM, $form_name))->parse()) . "\n";
            }
            $wgOut->addHTML($text);
            return;
        }
        // Initialize variables.
        $form_article = new Article($form_title, 0);
        $form_definition = $form_article->getContent();
        if ($embedded) {
            $run_query = false;
            $content = null;
            $raw = false;
        } else {
            $run_query = $wgRequest->getCheck('wpRunQuery');
            $content = $wgRequest->getVal('wpTextbox1');
            $raw = $wgRequest->getBool('raw', false);
        }
        $form_submitted = $run_query;
        if ($raw) {
            $wgOut->setArticleBodyOnly(true);
        }
        // If user already made some action, ignore the edited
        // page and just get data from the query string.
        if (!$embedded && $wgRequest->getVal('query') == 'true') {
            $edit_content = null;
            $is_text_source = false;
        } elseif ($content != null) {
            $edit_content = $content;
            $is_text_source = true;
        } else {
            $edit_content = null;
            $is_text_source = true;
        }
        list($form_text, $javascript_text, $data_text, $form_page_title) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $form_article->getID(), $edit_content, null, null, true, $embedded);
        $text = "";
        // Get the text of the results.
        $resultsText = '';
        if ($form_submitted) {
            // @TODO - fix RunQuery's parsing so that this check
            // isn't needed.
            if ($wgParser->getOutput() == null) {
                $headItems = array();
            } else {
                $headItems = $wgParser->getOutput()->getHeadItems();
            }
            foreach ($headItems as $key => $item) {
                $wgOut->addHeadItem($key, "\t\t" . $item . "\n");
            }
            $wgParser->mOptions = ParserOptions::newFromUser($wgUser);
            $resultsText = $wgParser->parse($data_text, $wgTitle, $wgParser->mOptions)->getText();
        }
        // Get the full text of the form.
        $fullFormText = '';
        $additionalQueryHeader = '';
        $dividerText = '';
        if (!$raw) {
            // Create the "additional query" header, and the
            // divider text - one of these (depending on whether
            // the query form is at the top or bottom) is displayed
            // if the form has already been submitted.
            if ($form_submitted) {
                $additionalQueryHeader = "\n" . Html::element('h2', null, wfMessage('sf_runquery_additionalquery')->text()) . "\n";
                $dividerText = "\n<hr style=\"margin: 15px 0;\" />\n";
            }
            $action = htmlspecialchars($this->getTitle($form_name)->getLocalURL());
            $fullFormText .= <<<END
\t<form id="sfForm" name="createbox" action="{$action}" method="post" class="createbox">

END;
            $fullFormText .= Html::hidden('query', 'true');
            $fullFormText .= $form_text;
        }
        // Either don't display a query form at all, or display the
        // query form at the top, and the results at the bottom, or the
        // other way around, depending on the settings.
        if ($wgRequest->getVal('additionalquery') == 'false') {
            $text .= $resultsText;
        } elseif ($sfgRunQueryFormAtTop) {
            $text .= $fullFormText;
            $text .= $dividerText;
            $text .= $resultsText;
        } else {
            $text .= $resultsText;
            $text .= $additionalQueryHeader;
            $text .= $fullFormText;
        }
        if ($embedded) {
            $text = "<div class='runQueryEmbedded'>{$text}</div>";
        }
        // Armor against doBlockLevels()
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:SF_RunQuery.php


注:本文中的Article::getID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。