Example #1
0
 function __construct(IContextSource $context, $userName = null, $search = '', $including = false)
 {
     global $wgMiserMode;
     $this->mIncluding = $including;
     if ($userName) {
         $nt = Title::newFromText($userName, NS_USER);
         if (!is_null($nt)) {
             $this->mUserName = $nt->getText();
             $this->mQueryConds['img_user_text'] = $this->mUserName;
         }
     }
     if ($search != '' && !$wgMiserMode) {
         $this->mSearch = $search;
         $nt = Title::newFromURL($this->mSearch);
         if ($nt) {
             $dbr = wfGetDB(DB_SLAVE);
             $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike($dbr->anyString(), strtolower($nt->getDBkey()), $dbr->anyString());
         }
     }
     if (!$including) {
         if ($context->getRequest()->getText('sort', 'img_date') == 'img_date') {
             $this->mDefaultDirection = true;
         } else {
             $this->mDefaultDirection = false;
         }
     } else {
         $this->mDefaultDirection = true;
     }
     parent::__construct($context);
 }
 function execute()
 {
     // Get the parameters
     $params = $this->extractRequestParams();
     $result = $this->getResult();
     $module = $this->getModuleName();
     $error = '';
     $id = $params['id'];
     $name = $params['name'];
     $title = null;
     if ($id) {
         $title = Title::newFromID($id);
     } elseif ($name) {
         $title = Title::newFromURL($name);
     }
     if (!$title || !$title->exists()) {
         $error = 'Title not found';
     } else {
         $revid = $params['revid'];
         $downloader = new MobileArticleDownloader();
         $articleResult = $downloader->getArticleData($title, $revid);
         $result->addValue(null, $module, $articleResult);
     }
     if ($error) {
         $result->addValue(null, $module, array('error' => $error));
     }
     return true;
 }
 function execute()
 {
     global $wgOut;
     $this->limit = min($this->request->getInt('limit', 50), 5000);
     if ($this->limit <= 0) {
         $this->limit = 50;
     }
     $this->from = $this->request->getInt('from');
     $this->back = $this->request->getInt('back');
     $targetString = isset($this->par) ? $this->par : $this->request->getVal('target');
     if (is_null($targetString)) {
         $wgOut->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->target = Title::newFromURL($targetString);
     if (!$this->target) {
         $wgOut->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->selfTitle = Title::makeTitleSafe(NS_SPECIAL, 'Whatlinkshere/' . $this->target->getPrefixedDBkey());
     $wgOut->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
     $wgOut->setSubtitle(wfMsg('linklistsub'));
     $wgOut->addHTML(wfMsgExt('whatlinkshere-barrow', array('escapenoentities')) . ' ' . $this->skin->makeLinkObj($this->target, '', 'redirect=no') . "<br />\n");
     $this->showIndirectLinks(0, $this->target, $this->limit, $this->from, $this->back);
 }
 function execute($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('target', '');
     $opts->add('namespace', '', FormOptions::INTNULL);
     $opts->add('limit', 50);
     $opts->add('from', 0);
     $opts->add('back', 0);
     $opts->add('hideredirs', false);
     $opts->add('hidetrans', false);
     $opts->add('hidelinks', false);
     $opts->add('hideimages', false);
     $opts->fetchValuesFromRequest($this->getRequest());
     $opts->validateIntBounds('limit', 0, 5000);
     // Give precedence to subpage syntax
     if (isset($par)) {
         $opts->setValue('target', $par);
     }
     // Bind to member variable
     $this->opts = $opts;
     $this->target = Title::newFromURL($opts->getValue('target'));
     if (!$this->target) {
         $out->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->getSkin()->setRelevantTitle($this->target);
     $this->selfTitle = $this->getTitle($this->target->getPrefixedDBkey());
     $out->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
     $out->setSubtitle(wfMsg('whatlinkshere-backlink', Linker::link($this->target, $this->target->getPrefixedText(), array(), array('redirect' => 'no'))));
     $this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
 }
Example #5
0
 public static function parserFunction($parser, $vid = null, $img = null)
 {
     global $wgTitle, $wgContLang;
     wfLoadExtensionMessages('WHVid');
     if ($vid === null || $img === null) {
         return '<div class="errorbox">' . wfMsg('missing-params') . '</div>';
     }
     $vid = htmlspecialchars($vid);
     $divId = "whvid-" . md5($vid . mt_rand(1, 1000));
     $vidUrl = self::getVidUrl($vid);
     $imgTitle = Title::newFromURL($img, NS_IMAGE);
     $imgUrl = null;
     if ($imgTitle) {
         $imgFile = RepoGroup::singleton()->findFile($imgTitle);
         $smallImgUrl = '';
         $largeImgUrl = '';
         if ($imgFile) {
             $width = 550;
             $height = 309;
             $thumb = $imgFile->getThumbnail($width, $height);
             $largeImgUrl = wfGetPad($thumb->getUrl());
             $width = 240;
             //$height = 135;
             $thumb = $imgFile->getThumbnail($width);
             $smallImgUrl = wfGetPad($thumb->getUrl());
         }
     }
     return $parser->insertStripItem(wfMsgForContent('embed-html', $divId, $vidUrl, $largeImgUrl, $smallImgUrl));
 }
 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc, $wgDBname;
     global $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode;
     global $wgFeedClasses, $wgUseRCPatrol;
     global $wgScriptPath, $wgServer;
     global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
     $fname = 'wfSpecialGeneratefeed';
     $pretty = isset($_GET['pretty']) && $_GET['pretty'] != null;
     global $messageMemc, $wgDBname, $wgFeedCacheTimeout;
     global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
     header('Content-type: application/x-javascript');
     if ($pretty) {
         echo 'document.writeln("<div style=\\"border: 1px solid #ccc; padding: 15px; width:275px; font-size: small; font-family: Arial;\\"><center><a href=\\"http://www.wikihow.com\\"><img src=\\"http://www.wikihow.com/skins/WikiHow/wikiHow.gif\\" border=0></a></center><br/>");';
         echo 'document.writeln("<b>How-to of the Day:</b><br />");';
     } else {
         echo 'document.writeln("<b>wikiHow: How-to of the Day:</b><br />");';
     }
     $feeds = FeaturedArticles::getFeaturedArticles(6);
     $now = time();
     foreach ($feeds as $f) {
         $url = $f[0];
         $d = $f[1];
         if ($d > $now) {
             continue;
         }
         $url = str_replace("http://www.wikihow.com/", "", $url);
         $title = Title::newFromURL(urldecode($url));
         echo 'document.writeln("<a href=\\"' . $title->getFullURL() . '\\">How to ' . $title->getText() . '</a><br/>");';
     }
     if ($pretty) {
         echo 'document.writeln("</div>");';
     }
     exit;
 }
 function MergehistoryForm($request, $par = "")
 {
     global $wgUser;
     $this->mAction = $request->getVal('action');
     $this->mTarget = $request->getVal('target');
     $this->mDest = $request->getVal('dest');
     $this->mSubmitted = $request->getBool('submitted');
     $this->mTargetID = intval($request->getVal('targetID'));
     $this->mDestID = intval($request->getVal('destID'));
     $this->mTimestamp = $request->getVal('mergepoint');
     if (!preg_match("/[0-9]{14}/", $this->mTimestamp)) {
         $this->mTimestamp = '';
     }
     $this->mComment = $request->getText('wpComment');
     $this->mMerge = $request->wasPosted() && $wgUser->matchEditToken($request->getVal('wpEditToken'));
     // target page
     if ($this->mSubmitted) {
         $this->mTargetObj = Title::newFromURL($this->mTarget);
         $this->mDestObj = Title::newFromURL($this->mDest);
     } else {
         $this->mTargetObj = null;
         $this->mDestObj = null;
     }
     $this->preCacheMessages();
 }
function scrapeGoogle($q)
{
    $q = urlencode($q);
    $url = "http://www.google.com/uds/GwebSearch?callback=google.search.WebSearch.RawCompletion&context=0&lstkp=0&rsz=large&hl=en&source=gsc&gss=.com&sig=c1cdabe026cbcfa0e7dc257594d6a01c&q={$q}%20site%3Awikihow.com&gl=www.google.com&qid=124c49541548cd45a&key=ABQIAAAAYdkMNf23adqRw4vVq1itihTad9mjNgCjlcUxzpdXoz7fpK-S6xTT265HnEaWJA-rzhdFvhMJanUKMA&v=1.0";
    $contents = file_get_contents($url);
    #echo $q . "\n";
    $result = preg_match_all('@unescapedUrl":"([^"]*)"@u', $contents, $matches);
    $ids = array();
    $params = split("{", $contents);
    #print_r($params); exit;
    #echo $contents; echo "$q\n"; print_r($matches); exit;
    #print_r($matches);
    foreach ($matches[1] as $m) {
        $m = str_replace('http://www.wikihow.com/', '', $m);
        $r = Title::newFromURL($m);
        if ($r == '') {
            continue;
        }
        if (!$r) {
            echo "Couldn't make title out of {$r}\n";
            continue;
        } else {
            if ($r->getNamespace() != NS_MAIN) {
                continue;
            } else {
                if ($r->getArticleID() > 0) {
                    $ids[] = $r->getArticleID();
                    #echo "adding link from {$r->getText()} to " . urldecode($q) . "\n";
                }
            }
        }
    }
    return $ids;
}
Example #9
0
 /**
  * Checks some initial queries
  * Note that $title here is *not* a Title object, but a string!
  */
 function checkInitialQueries($title, $action, &$output, $request, $lang)
 {
     if ($request->getVal('printable') == 'yes') {
         $output->setPrintable();
     }
     $ret = NULL;
     if ('' == $title && 'delete' != $action) {
         $ret = Title::newMainPage();
     } elseif ($curid = $request->getInt('curid')) {
         # URLs like this are generated by RC, because rc_title isn't always accurate
         $ret = Title::newFromID($curid);
     } else {
         $ret = Title::newFromURL($title);
         /* check variant links so that interwiki links don't have to worry about
         			   the possible different language variants
         			*/
         if (count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0) {
             $lang->findVariantLink($title, $ret);
         }
     }
     if (($oldid = $request->getInt('oldid')) && (is_null($ret) || $ret->getNamespace() != NS_SPECIAL)) {
         // Allow oldid to override a changed or missing title.
         $rev = Revision::newFromId($oldid);
         if ($rev) {
             $ret = $rev->getTitle();
         }
     }
     return $ret;
 }
 /**
  * @return void
  */
 private function loadRequestParams()
 {
     $request = $this->getRequest();
     $this->mAction = $request->getVal('action');
     $this->mTarget = $request->getVal('target');
     $this->mDest = $request->getVal('dest');
     $this->mSubmitted = $request->getBool('submitted');
     $this->mTargetID = intval($request->getVal('targetID'));
     $this->mDestID = intval($request->getVal('destID'));
     $this->mTimestamp = $request->getVal('mergepoint');
     if (!preg_match('/[0-9]{14}/', $this->mTimestamp)) {
         $this->mTimestamp = '';
     }
     $this->mComment = $request->getText('wpComment');
     $this->mMerge = $request->wasPosted() && $this->getUser()->matchEditToken($request->getVal('wpEditToken'));
     // target page
     if ($this->mSubmitted) {
         $this->mTargetObj = Title::newFromURL($this->mTarget);
         $this->mDestObj = Title::newFromURL($this->mDest);
     } else {
         $this->mTargetObj = null;
         $this->mDestObj = null;
     }
     $this->preCacheMessages();
 }
function wfMarkFeaturedSaved(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor)
{
    $t = $article->getTitle();
    if ($t == null || $t->getNamespace() != NS_PROJECT || $t->getDBKey() != "RSS-feed") {
        return true;
    }
    $dbw = wfGetDB(DB_MASTER);
    // reuben - i removed this for now to fix an urgent issue for krystle where
    // old FAs don't show up in categories.  the more involved fix is to remove
    // this function wfMarkFeaturedSaved() and just check if an article has
    // the {{fa}}, set the page_is_featured flag for that one article.  With
    // this 'fix', if an article ever shows up in the RSS feed, it will be
    // considered an FA in the DB forever.
    // clear everything from before
    //$success = $dbw->update( 'page',  array( /* SET */ 'page_is_featured' => 0) , array('1' => '1'));
    $lines = split("\n", $text);
    foreach ($lines as $line) {
        if (strpos($line, "http://") === 0) {
            $tokens = split(" ", $line);
            $t = $tokens[0];
            $t = str_replace("http://www.wikihow.com/", "", $t);
            $url = str_replace($wgServer . $wgScriptPath . "/", "", $t);
            $x = Title::newFromURL(urldecode($url));
            if (!$x) {
                continue;
            }
            $ret = $dbw->update('page', array('page_is_featured' => 1), array('page_namespace' => $x->getNamespace(), 'page_title' => $x->getDBKey()));
        }
    }
    return true;
}
 function execute()
 {
     global $wgOut;
     $this->limit = min($this->request->getInt('limit', 50), 5000);
     if ($this->limit <= 0) {
         $this->limit = 50;
     }
     $this->from = $this->request->getInt('from');
     $this->dir = $this->request->getText('dir', 'next');
     if ($this->dir != 'prev') {
         $this->dir = 'next';
     }
     $targetString = isset($this->par) ? $this->par : $this->request->getVal('target');
     if (is_null($targetString)) {
         $wgOut->showErrorPage('notargettitle', 'notargettext');
         return;
     }
     $this->target = Title::newFromURL($targetString);
     if (!$this->target) {
         $wgOut->showErrorPage('notargettitle', 'notargettext');
         return;
     }
     $this->selfTitle = Title::makeTitleSafe(NS_SPECIAL, 'Whatlinkshere/' . $this->target->getPrefixedDBkey());
     $wgOut->setPagetitle($this->target->getPrefixedText());
     $wgOut->setSubtitle(wfMsg('linklistsub'));
     $wgOut->addHTML(wfMsg('whatlinkshere-barrow') . ' ' . $this->skin->makeLinkObj($this->target, '', 'redirect=no') . "<br />\n");
     $this->showIndirectLinks(0, $this->target, $this->limit, $this->from, $this->dir);
 }
Example #13
0
 function execute()
 {
     require_once 'includes/PageHistory.php';
     global $wgOut, $wgTitle;
     if ($_GET["pid"] != "") {
         $dbr =& wfGetDB(DB_SLAVE);
         $sql = "SELECT page_namespace,page_title FROM {$dbr->tableName('page')} WHERE page_id = " . $_GET["pid"];
         $res = $dbr->query($sql);
         while ($row = $dbr->fetchObject($res)) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $title2 = $title->getText();
         }
     }
     if ($title2 != "") {
         $wgTitle = Title::newFromURL($title2);
         $wgArticle = new Article($wgTitle);
         $wgOut->setSquidMaxage($wgSquidMaxage);
         $h = new PageHistory($wgArticle);
         $h->History();
     }
     // This line removes the navigation and everything else from the
     // page, if you don't set it, you get what looks like a regular wiki
     // page, with the body you defined above.
     $wgOut->setArticleBodyOnly(true);
 }
 /**
  * Called when the user goes to an edit page
  * Override the functionality of the edit to require a URL to translate
  */
 static function onCustomEdit()
 {
     global $wgRequest, $wgOut;
     $draft = $wgRequest->getVal('draft', null);
     $target = $wgRequest->getVal('title', null);
     $action = $wgRequest->getVal('action', null);
     $section = $wgRequest->getVal('section', $wgRequest->getVal('wpSection', null));
     $save = $wgRequest->getVal('wpSave', null);
     $title = Title::newFromURL($target);
     // We have the dialog to enter the URL when we are adding a new article, and have no existing draft.
     if (self::isTranslatorUser()) {
         if ($draft == null && !$title->exists() && $action == 'edit') {
             EasyTemplate::set_path(dirname(__FILE__) . '/');
             // Templates to remove from tranlsation
             $remove_templates = array("{{FA}}", "\\[\\[Category:[^\\]]+\\]\\]");
             // Words or things to automatically translate
             $translations = array(array('from' => self::getSectionRegex('Steps'), 'to' => self::getSectionWikitext(wfMsg('Steps'))), array('from' => self::getSectionRegex('Tips'), 'to' => self::getSectionWikitext(wfMsg('Tips'))), array('from' => self::getSectionRegex('Warnings'), 'to' => self::getSectionWikitext(wfMsg('Warnings'))), array('from' => self::getSectionRegex('Ingredients'), 'to' => self::getSectionWikitext(wfMsg('Ingredients'))), array('from' => self::getSectionRegex("Things You'll need"), 'to' => self::getSectionWikitext(wfMsg('Thingsyoullneed'))), array('from' => self::getSectionRegex("Related wikiHows"), 'to' => self::getSectionWikitext(wfMsg('Related'))), array('from' => self::getSectionRegex("Sources and Citations"), 'to' => self::getSectionWikitext(wfMsg('Sources'))));
             $vars = array('title' => $target, 'checkForLL' => true, 'translateURL' => true, 'translations' => json_encode($translations), 'remove_templates' => array_map(preg_quote, $remove_templates));
             $html = EasyTemplate::html('TranslateEditor.tmpl.php', $vars);
             $wgOut->addHTML($html);
             QuickEdit::showEditForm($title);
             return false;
         } elseif ($section == null && $save == null) {
             EasyTemplate::set_path(dirname(__FILE__) . '/');
             $vars = array('title' => $target, 'checkForLL' => true, 'translateURL' => false);
             $html = EasyTemplate::html('TranslateEditor.tmpl.php', $vars);
             $wgOut->addHTML($html);
             QuickEdit::showEditForm($title);
             return false;
         }
     }
     return true;
 }
function checkGoogle($query)
{
    $url = "http://www.google.com/search?q=" . urlencode($query . " site:wikihow.com") . "&num=100";
    $contents = file_get_contents($url);
    $matches = array();
    $preg = "/href=\"http:\\/\\/[^\"]*\"*/";
    $preg = "/href=\"http:\\/\\/[^\"]*\" class=l */ ";
    preg_match_all($preg, $contents, $matches);
    #echo "checking $query\n";
    $results = array();
    foreach ($matches[0] as $url) {
        $url = substr($url, 6, strlen($url) - 7);
        $url = str_replace('" class=', '', $url);
        // check for cache article
        if (strpos($url, "/search?q=cache") !== false || strpos($url, "google.com/") !== false) {
            continue;
        }
        #echo $url . "\n";
        $url = str_replace('http://www.wikihow.com/', '', $url);
        $t = Title::newFromURL($url);
        if ($t) {
            $results[] = $t;
        }
    }
    return $results;
}
Example #16
0
/**
 * @todo document
 */
function wfSpecialEmailuser($par)
{
    global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgEnableUserEmail;
    if (!($wgEnableEmail && $wgEnableUserEmail)) {
        $wgOut->showErrorPage("nosuchspecialpage", "nospecialpagetext");
        return;
    }
    if (!$wgUser->canSendEmail()) {
        wfDebug("User can't send.\n");
        $wgOut->showErrorPage("mailnologin", "mailnologintext");
        return;
    }
    $action = $wgRequest->getVal('action');
    $target = isset($par) ? $par : $wgRequest->getVal('target');
    if ("" == $target) {
        wfDebug("Target is empty.\n");
        $wgOut->showErrorPage("notargettitle", "notargettext");
        return;
    }
    $nt = Title::newFromURL($target);
    if (is_null($nt)) {
        wfDebug("Target is invalid title.\n");
        $wgOut->showErrorPage("notargettitle", "notargettext");
        return;
    }
    $nu = User::newFromName($nt->getText());
    if (is_null($nu) || !$nu->canReceiveEmail()) {
        wfDebug("Target is invalid user or can't receive.\n");
        $wgOut->showErrorPage("noemailtitle", "noemailtext");
        return;
    }
    if ($wgUser->isBlockedFromEmailUser()) {
        // User has been blocked from sending e-mail. Show the std blocked form.
        wfDebug("User is blocked from sending e-mail.\n");
        $wgOut->blockedPage();
        return;
    }
    if (!$wgUser->getEditCount()) {
        //no edits? no emailing...
        $wgOut->errorpage('Emailerror', 'Emailerrortext');
        return;
    }
    $f = new EmailUserForm($nu);
    if ("success" == $action) {
        $f->showSuccess($nu);
    } else {
        if ("submit" == $action && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            # Check against the rate limiter
            if ($wgUser->pingLimiter('emailuser')) {
                $wgOut->rateLimited();
                return;
            }
            $f->doSubmit();
        } else {
            $f->showForm();
        }
    }
}
	public function execute( $par ) {
		global $wgRequest, $wgUser, $wgOut;
		$this->setHeaders();
		if( $wgUser->isAllowed( 'feedback' ) ) {
			if( $wgUser->isBlocked() ) {
				$wgOut->blockedPage();
				return;
			}
		} else {
			$wgOut->permissionRequired( 'feedback' );
			return;
		}
		if( wfReadOnly() ) {
			$wgOut->readOnlyPage();
			return;
		}
		$this->skin = $wgUser->getSkin();
		$this->doPurge = ('purge' === $wgRequest->getVal( 'action' ) && $wgUser->isAllowed('purge'));
		# Our target page
		$this->target = $wgRequest->getText( 'target' );
		$this->page = Title::newFromURL( $this->target );
		# We need a page...
		if( is_null($this->page) ) {
			$wgOut->showErrorPage( 'notargettitle', 'notargettext' );
			return;
		} elseif( !ReaderFeedback::isPageRateable( $this->page ) ) {
			$wgOut->addHTML( wfMsgExt('readerfeedback-main',array('parse')) );
			return;
		}
		# Thank people who voted...
		if( ReaderFeedbackPage::userAlreadyVoted( $this->page ) ) {
			$wgOut->setSubtitle( wfMsgExt('ratinghistory-thanks','parseinline') );
		}
		$period = $wgRequest->getInt( 'period' );
		$validPeriods = array(31,93,365,1095);
		if( !in_array($period,$validPeriods) ) {
			$period = 31; // default
		}
		$this->period = $period;
		$this->dScale = 20;

		$this->now = time(); // one time for whole request

		$this->showForm();
		$this->showTable();
		/*
		 * Allow client caching.
		 */
		if( !$this->doPurge && $wgOut->checkLastModified( self::getTouched($this->page) ) ) {
			return; // Client cache fresh and headers sent, nothing more to do
		} else {
			$wgOut->enableClientCache( false ); // don't show stale graphs
			if( $this->doPurge ) $this->purgePage();
		}
		$this->showGraphs();
	}
 /**
  * handler for beforeMove hook
  *
  * @static
  *
  * @param MovePageForm $move -- Special::Move class instance
  *
  * @return bool true -- pass hook further
  */
 public static function beforeMove(&$move)
 {
     wfProfileIn(__METHOD__);
     /* title object */
     $title = Title::newFromURL($move->newTitle);
     /* check title */
     $ret = PhalanxTitleBlock::checkTitle($title);
     wfProfileOut(__METHOD__);
     return $ret;
 }
Example #19
0
 /**
  * Parse the request to get the Title object
  *
  * @throws MalformedTitleException If a title has been provided by the user, but is invalid.
  * @return Title Title object to be $wgTitle
  */
 private function parseTitle()
 {
     global $wgContLang;
     $request = $this->context->getRequest();
     $curid = $request->getInt('curid');
     $title = $request->getVal('title');
     $action = $request->getVal('action');
     if ($request->getCheck('search')) {
         // Compatibility with old search URLs which didn't use Special:Search
         // Just check for presence here, so blank requests still
         // show the search page when using ugly URLs (bug 8054).
         $ret = SpecialPage::getTitleFor('Search');
     } elseif ($curid) {
         // URLs like this are generated by RC, because rc_title isn't always accurate
         $ret = Title::newFromID($curid);
     } else {
         $ret = Title::newFromURL($title);
         // Alias NS_MEDIA page URLs to NS_FILE...we only use NS_MEDIA
         // in wikitext links to tell Parser to make a direct file link
         if (!is_null($ret) && $ret->getNamespace() == NS_MEDIA) {
             $ret = Title::makeTitle(NS_FILE, $ret->getDBkey());
         }
         // Check variant links so that interwiki links don't have to worry
         // about the possible different language variants
         if (count($wgContLang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0) {
             $wgContLang->findVariantLink($title, $ret);
         }
     }
     // If title is not provided, always allow oldid and diff to set the title.
     // If title is provided, allow oldid and diff to override the title, unless
     // we are talking about a special page which might use these parameters for
     // other purposes.
     if ($ret === null || !$ret->isSpecialPage()) {
         // We can have urls with just ?diff=,?oldid= or even just ?diff=
         $oldid = $request->getInt('oldid');
         $oldid = $oldid ? $oldid : $request->getInt('diff');
         // Allow oldid to override a changed or missing title
         if ($oldid) {
             $rev = Revision::newFromId($oldid);
             $ret = $rev ? $rev->getTitle() : $ret;
         }
     }
     // Use the main page as default title if nothing else has been provided
     if ($ret === null && strval($title) === '' && !$request->getCheck('curid') && $action !== 'delete') {
         $ret = Title::newMainPage();
     }
     if ($ret === null || $ret->getDBkey() == '' && !$ret->isExternal()) {
         // If we get here, we definitely don't have a valid title; throw an exception.
         // Try to get detailed invalid title exception first, fall back to MalformedTitleException.
         Title::newFromTextThrow($title);
         throw new MalformedTitleException('badtitletext', $title);
     }
     return $ret;
 }
 /**
  * set message to article relation
  * 
  * @param int $messageId
  * @param array $pages - array( 'order_index' => 'page_id' )  
  */
 function setWithURLs($messageId, $url = array())
 {
     wfProfileIn(__METHOD__);
     $out = array();
     foreach ($url as $key => $value) {
         $title = Title::newFromURL($value);
         if (!empty($title)) {
             $out[$key] = $title->getArticleId();
         }
     }
     $this->set($messageId, $out);
     wfProfileOut(__METHOD__);
 }
Example #21
0
 public static function beforeMove(&$move, &$block)
 {
     wfProfileIn(__METHOD__);
     $retVal = true;
     $title = Title::newFromURL($move->newTitle);
     if (!$title instanceof Title) {
         wfProfileOut(__METHOD__);
         return $retVal;
     }
     $retVal = self::checkTitle($title, $block);
     wfProfileOut(__METHOD__);
     return $retVal;
 }
 /**
  * @param integer $namespace (Default NS_MAIN)
  * @param string $from list all pages from this name (default FALSE)
  */
 function showChunk($namespace = NS_MAIN, $from, $including = false)
 {
     global $wgOut, $wgUser, $wgContLang;
     $fname = 'indexShowChunk';
     $sk = $wgUser->getSkin();
     $fromTitle = Title::newFromURL($from);
     if ($namespace == NS_MAIN and $fromTitle) {
         $namespace = $fromTitle->getNamespace();
     }
     $fromKey = is_null($fromTitle) ? '' : $fromTitle->getDBkey();
     $dbr =& wfGetDB(DB_SLAVE);
     $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_is_redirect'), array('page_namespace' => $namespace, 'page_title LIKE \'' . $dbr->escapeLike($fromKey) . '%\''), $fname, array('ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title'));
     ### FIXME: side link to previous
     $n = 0;
     $out = '<table style="background: inherit;" border="0" width="100%">';
     $namespaces = $wgContLang->getFormattedNamespaces();
     while ($n < $this->maxPerPage && ($s = $dbr->fetchObject($res))) {
         $t = Title::makeTitle($s->page_namespace, $s->page_title);
         if ($t) {
             $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '') . $sk->makeKnownLinkObj($t, htmlspecialchars($t->getText()), false, false) . ($s->page_is_redirect ? '</div>' : '');
         } else {
             $link = '[[' . htmlspecialchars($s->page_title) . ']]';
         }
         if ($n % 3 == 0) {
             $out .= '<tr>';
         }
         $out .= "<td>{$link}</td>";
         $n++;
         if ($n % 3 == 0) {
             $out .= '</tr>';
         }
     }
     if ($n % 3 != 0) {
         $out .= '</tr>';
     }
     $out .= '</table>';
     if ($including) {
         $out2 = '';
     } else {
         $nsForm = $this->namespaceForm($namespace, $from);
         $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
         $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
         $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' . $sk->makeKnownLink($wgContLang->specialPage($this->name), wfMsg('allpages'));
         if ($n == $this->maxPerPage && ($s = $dbr->fetchObject($res))) {
             $namespaceparam = $namespace ? "&namespace={$namespace}" : "";
             $out2 .= " | " . $sk->makeKnownLink($wgContLang->specialPage($this->name), wfMsg('nextpage', $s->page_title), "from=" . wfUrlEncode($s->page_title) . $namespaceparam);
         }
         $out2 .= "</td></tr></table><hr />";
     }
     $wgOut->addHtml($out2 . $out);
 }
function efNetworkAuth_Setup()
{
    global $wgRequest;
    # $wgTitle isn't initalized yet - but we need to know where we are
    $pageTitle = Title::newFromURL($wgRequest->getVal('title'));
    if (is_object($pageTitle)) {
        # Doesn't apply to Userlogin and Userlogout pages - that breaks stuff
        if ($pageTitle->isSpecial('Userlogin') || $pageTitle->isSpecial('Userlogout')) {
            # bail!
            return true;
        }
    }
    efNetworkAuth_Authenticate();
    return true;
}
 function checkParameters($par)
 {
     // Handle parameter
     $this->mTarget = $par;
     if ($par === null || $par === "") {
         $this->output->addHTML(wfMsg('lqt_threadrequired'));
         return false;
     }
     $thread = Threads::withRoot(new Article(Title::newFromURL($par)));
     if (!$thread) {
         $this->output->addHTML(wfMsg('lqt_nosuchthread'));
         return false;
     }
     $this->mThread = $thread;
     return true;
 }
Example #25
0
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang;
     //$userGroups = $wgUser->getGroups();
     if ($wgUser->isBlocked()) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if ($wgRequest->wasPosted()) {
         $dbr = wfGetDB(DB_SLAVE);
         $pageList = $wgRequest->getVal('pages-list', '');
         $wgOut->setArticleBodyOnly(true);
         $pageList = preg_split('@[\\r\\n]+@', $pageList);
         foreach ($pageList as $url) {
             $url = trim($url);
             $pagename = self::getTitleFromURL($url);
             if (!empty($pagename)) {
                 $t = Title::newFromURL($pagename);
                 if (!empty($t)) {
                     $is_nabbed = Newarticleboost::isNABbed($dbr, $t->getArticleId());
                     if ($is_nabbed) {
                         $nabbed = 'yes';
                     } else {
                         $nabbed = 'no';
                         $nabbed .= '<br />[<a href="./Special:Newarticleboost/' . $pagename . '" target="_blank">boost it</a>]';
                     }
                 }
                 $urls[] = array('url' => $url, 'id' => $t->getArticleId(), 'boosted' => $nabbed);
             }
         }
         $html = '<style>.tres tr:nth-child(even) {background: #ccc;}</style>';
         $html .= '<table class="tres"><tr><th width="450px">URL</th><th>ID</th><th>Boosted?</th></tr>';
         foreach ($urls as $row) {
             $html .= "<tr><td class='nab_url'><a href='{$row['url']}'>{$row['url']}</a></td><td class='nab_id'>{$row['id']}</td><td class='boost'>{$row['boosted']}</td></tr>";
         }
         $html .= '</table>';
         $result = array('result' => $html);
         print json_encode($result);
         return;
     }
     $wgOut->setHTMLTitle('Admin - Lookup NAB - wikiHow');
     $wgOut->addStyle('../extensions/wikihow/adminlookup.css?rev=' . WH_SITEREV);
     $tmpl = AdminLookupPages::getGuts('AdminLookupNab');
     $wgOut->addHTML($tmpl);
     $wgOut->addHTML($wgServer);
 }
function wfSpamBlackTitleBeforeMove(&$move)
{
    global $useSpamRegexNoHttp;
    $useSpamRegexNoHttp = 1;
    wfProfileIn(__METHOD__);
    $retVal = true;
    $title = Title::newFromURL($move->newTitle);
    if (!$title instanceof Title) {
        wfProfileOut(__METHOD__);
        return $retVal;
    }
    /* */
    $retVal = wfBlackListTitleParse($title);
    /* */
    wfProfileOut(__METHOD__);
    return $retVal;
}
 public function execute($par)
 {
     $request = $this->getRequest();
     $this->setHeaders();
     # Our target page
     $this->target = $request->getText('page');
     $this->page = Title::newFromURL($this->target);
     # Revision ID
     $this->oldid = $request->getVal('oldid');
     $this->oldid = $this->oldid == 'best' ? 'best' : intval($this->oldid);
     # We need a page...
     if (is_null($this->page)) {
         $this->getOutput()->showErrorPage('notargettitle', 'notargettext');
         return;
     }
     $this->showStableList();
 }
Example #28
0
 /**
  * Parse the request to get the Title object
  *
  * @return Title object to be $wgTitle
  */
 private function parseTitle()
 {
     global $wgContLang;
     $request = $this->context->getRequest();
     $curid = $request->getInt('curid');
     $title = $request->getVal('title');
     if ($request->getCheck('search')) {
         // Compatibility with old search URLs which didn't use Special:Search
         // Just check for presence here, so blank requests still
         // show the search page when using ugly URLs (bug 8054).
         $ret = SpecialPage::getTitleFor('Search');
     } elseif ($curid) {
         // URLs like this are generated by RC, because rc_title isn't always accurate
         $ret = Title::newFromID($curid);
     } elseif ($title == '' && $this->getAction() != 'delete') {
         $ret = Title::newMainPage();
     } else {
         $ret = Title::newFromURL($title);
         // Alias NS_MEDIA page URLs to NS_FILE...we only use NS_MEDIA
         // in wikitext links to tell Parser to make a direct file link
         if (!is_null($ret) && $ret->getNamespace() == NS_MEDIA) {
             $ret = Title::makeTitle(NS_FILE, $ret->getDBkey());
         }
         // Check variant links so that interwiki links don't have to worry
         // about the possible different language variants
         if (count($wgContLang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0) {
             $wgContLang->findVariantLink($title, $ret);
         }
     }
     // For non-special titles, check for implicit titles
     if (is_null($ret) || $ret->getNamespace() != NS_SPECIAL) {
         // We can have urls with just ?diff=,?oldid= or even just ?diff=
         $oldid = $request->getInt('oldid');
         $oldid = $oldid ? $oldid : $request->getInt('diff');
         // Allow oldid to override a changed or missing title
         if ($oldid) {
             $rev = Revision::newFromId($oldid);
             $ret = $rev ? $rev->getTitle() : $ret;
         }
     }
     if ($ret === null || $ret->getDBkey() == '' && $ret->getInterwiki() == '') {
         $ret = SpecialPage::getTitleFor('Badtitle');
     }
     return $ret;
 }
Example #29
0
 function __construct()
 {
     global $wgRequest, $wgMiserMode;
     if ($wgRequest->getText('sort', 'img_date') == 'img_date') {
         $this->mDefaultDirection = true;
     } else {
         $this->mDefaultDirection = false;
     }
     $search = $wgRequest->getText('ilsearch');
     if ($search != '' && !$wgMiserMode) {
         $nt = Title::newFromURL($search);
         if ($nt) {
             $dbr = wfGetDB(DB_SLAVE);
             $this->mQueryConds = array('LOWER(img_name)' . $dbr->buildLike($dbr->anyString(), strtolower($nt->getDBkey()), $dbr->anyString()));
         }
     }
     parent::__construct();
 }
Example #30
0
 public function execute()
 {
     global $wgUser, $wgRequest, $wgOut;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     $type = $wgRequest->getVal('type', null);
     $target = $wgRequest->getVal('target', null);
     if ($type == 'editform') {
         $wgOut->setArticleBodyOnly(true);
         $title = Title::newFromURL($target);
         if (!$title) {
             $wgOut->addHTML('error: bad target');
         } else {
             self::showEditForm($title);
         }
     }
 }