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


PHP Title::newFromURL方法代码示例

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


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

示例1: __construct

 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);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SpecialListfiles.php

示例2: execute

 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;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:28,代码来源:ApiMobileArticleDownloader.body.php

示例3: execute

 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);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:25,代码来源:SpecialWhatlinkshere.php

示例4: execute

 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'));
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:34,代码来源:SpecialWhatlinkshere.php

示例5: parserFunction

 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));
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:29,代码来源:WHVid.body.php

示例6: execute

 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;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:35,代码来源:GenerateJSFeed.body.php

示例7: MergehistoryForm

 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();
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:25,代码来源:SpecialMergeHistory.php

示例8: scrapeGoogle

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;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:34,代码来源:suggestionsMakeLinks.php

示例9: checkInitialQueries

 /**
  * 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;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:33,代码来源:Wiki.php

示例10: loadRequestParams

 /**
  * @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();
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:28,代码来源:SpecialMergeHistory.php

示例11: wfMarkFeaturedSaved

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;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:FeaturedArticles.php

示例12: execute

 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);
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:28,代码来源:SpecialWhatlinkshere.php

示例13: execute

 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);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:25,代码来源:pageHistory.php

示例14: onCustomEdit

 /**
  * 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;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:37,代码来源:TranslateEditor.body.php

示例15: checkGoogle

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;
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:26,代码来源:doGoogleMiniTest.php


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