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


PHP Misc::getLangBaseURL方法代码示例

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


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

示例1: getIntlRedirect

 function getIntlRedirect($lang, $pageid)
 {
     static $dbr = null;
     if (!$dbr) {
         $dbr = wfGetDB(DB_SLAVE);
     }
     $sql = 'SELECT rd_title FROM ' . Misc::getLangDB($lang) . '.redirect WHERE rd_from=' . intval($pageid) . ' AND rd_namespace=' . NS_MAIN;
     $res = $dbr->query($sql, __METHOD__);
     $row = $res ? $res->fetchObject() : null;
     return $row ? Misc::getLangBaseURL($lang) . '/' . $row->rd_title : '';
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:11,代码来源:AdminRedirects.body.php

示例2: execute

 public function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang, $wgLanguageCode;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     $userGroups = $wgUser->getGroups();
     if ($wgUser->getID() == 0 || !(in_array('sysop', $userGroups) || in_array('staff', $userGroups))) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if (!$wgRequest->wasPosted()) {
         EasyTemplate::set_path(dirname(__FILE__));
         $tmpl = EasyTemplate::html("RevertTool.tmpl.php", array('msg' => wfMsg("mass-revert-message"), 'msgName' => "mass-revert-message"));
         $wgOut->addHTML($tmpl);
         return true;
     } else {
         set_time_limit(0);
         $list = $wgRequest->getVal('page-list');
         $revertUser = $wgRequest->getVal('revert-user');
         $list = explode("\n", $list);
         $urls = array();
         if ($wgLanguageCode != "en") {
             $pages = Misc::getPagesFromURLs($list);
             foreach ($pages as $page) {
                 if ($page['lang'] == $wgLanguageCode) {
                     $urls[] = Misc::getLangBaseURL($page['lang']) . '/' . $page['page_title'];
                 } else {
                     $links = TranslationLink::getLinksTo($page['lang'], $page['page_id']);
                     foreach ($links as $link) {
                         if ($link->toLang == $wgLanguageCode) {
                             $urls[] = $link->toURL;
                         }
                     }
                 }
             }
         } else {
             $urls = $list;
         }
         $results = $this->revertList($urls, $revertUser);
         $wgOut->setArticleBodyOnly(true);
         $wgOut->addHTML(json_encode($results));
         return true;
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:47,代码来源:RevertTool.body.php

示例3: getAllExclusions

 function getAllExclusions()
 {
     global $wgOut, $wgActiveLanguages;
     $wgOut->setArticleBodyOnly(true);
     $dbr = wfGetDB(DB_SLAVE);
     $ids = array();
     $this->getPageIdsForLanguage($dbr, $ids, "en");
     foreach ($wgActiveLanguages as $languageCode) {
         $this->getPageIdsForLanguage($dbr, $ids, $languageCode);
     }
     $pages = Misc::getPagesFromLangIds($ids);
     $date = date('Y-m-d');
     header('Content-type: application/force-download');
     header('Content-disposition: attachment; filename="adexclusions_' . $date . '.xls"');
     foreach ($pages as $page) {
         echo Misc::getLangBaseURL($page["lang"]) . "/" . $page["page_title"] . "\n";
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:18,代码来源:AdminAdExclusions.body.php

示例4: addImages

 /**
  * Add a bunch of URLs to the database for adding their images to various languages
  * @param urls New-line seperated list of URLs or Article ids from POST
  * @param langs Comma-seperated list of languages to add the images on
  */
 private function addImages($urls, $langs)
 {
     $urls = preg_split("@[\r\n]+@", Misc::getUrlDecodedData($urls));
     $langs = preg_split("@,@", urldecode($langs));
     $realUrls = array();
     $langIds = array();
     foreach ($urls as $url) {
         if (is_numeric($url)) {
             $langIds[] = array("lang" => "en", "id" => $url);
         } else {
             $realUrls[] = $url;
         }
     }
     $pagesA = Misc::getPagesFromURLs($realUrls, array('page_id', 'page_title'));
     $badURLs = array();
     $results = array();
     foreach ($realUrls as $url) {
         if (!isset($pagesA[$url])) {
             foreach ($langs as $lang) {
                 ImageTransfer::addBadURL($url, $lang, "URL not found");
             }
             $results[] = array('fromURL' => $url, 'toURL' => '', 'status' => 'Bad URL');
         }
     }
     $pagesB = Misc::getPagesFromLangIds($langIds, array('page_id', 'page_title'));
     $pages = array_merge($pagesA, $pagesB);
     $fromIDs = array();
     $urlLookup = array();
     foreach ($pages as $page) {
         $fromIDs[] = $page['page_id'];
         $urlLookup[$page['page_id']] = Misc::getLangBaseURL('en') . '/' . $page['page_title'];
     }
     if (sizeof($fromIDs) == 0) {
         return array();
     }
     // Fetch to cache the pages for later use in addImage
     $this->batchFetchPages("en", $fromIDs);
     $langTLs = array();
     foreach ($langs as $lang) {
         $langTLs[$lang] = TranslationLink::getLinks("en", $lang, array("tl_from_aid in (" . implode(',', $fromIDs) . ")"));
         $newFromIds = array_map(function ($m) {
             return $m->fromAID;
         }, $langTLs[$lang]);
         foreach ($fromIDs as $id) {
             //Add error links
             if (!in_array($id, $newFromIds)) {
                 $this->addImage($id, $lang, 0);
                 if (isset($urlLookup[$id])) {
                     $results[] = array('fromURL' => $urlLookup[$id], 'toURL' => '', 'status' => 'Could not find any translation link to ' . $lang);
                 }
             }
         }
         TranslationLink::batchPopulateURLs($langTLs[$lang]);
         // Cache the other language pages too in a batch
         $langIds = array();
         foreach ($langTLs[$lang] as $tl) {
             $langIds[] = $tls->toAID;
         }
         $this->batchFetchPages($lang, $langIds);
     }
     foreach ($langs as $lang) {
         foreach ($langTLs[$lang] as $tl) {
             if (!$this->addImage($tl->fromAID, $tl->toLang, $tl->toAID)) {
                 $results[] = array('fromURL' => $tl->fromURL, 'toURL' => $tl->toURL, 'status' => 'Queued');
             } else {
                 $results[] = array('fromURL' => $tl->fromURL, 'toURL' => $tl->toURL, 'status' => 'Failed to queue');
             }
         }
     }
     return $results;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:76,代码来源:Alfredo.body.php

示例5: getLangEndpoints

 public static function getLangEndpoints()
 {
     global $wgActiveLanguages;
     $langs = array();
     foreach (array_merge($wgActiveLanguages, array('en')) as $langCode) {
         $langs[$langCode] = array('code' => $langCode, 'endpoint' => Misc::getLangBaseURL($langCode) . '/api.php');
     }
     return $langs;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:9,代码来源:ApiApp.body.php

示例6: foreach

    if ($email == NULL || $email == "") {
        next;
    }
    $msg = "<table><thead><tr><td>Inputted URL</td><td>Translated URL</td><td>Error</td></tr></thead>\n";
    if (isset($errorURLs[$creator])) {
        foreach ($errorURLs[$creator] as $url) {
            $msg .= "<tr><td>" . $url . "</td><td></td><td>URL Not Found</td></tr>\n";
        }
    }
    if (isset($errors[$creator])) {
        foreach ($errors[$creator] as $it) {
            $fromPage = $lip[$it->fromLang][$it->fromAID];
            $toPage = $lip[$it->toLang][$it->toAID];
            $msg .= "<tr><td>" . Misc::getLangBaseURL($fromPage['lang']) . "/" . $fromPage['page_title'] . "</td><td>" . (isset($toPage['page_title']) ? Misc::getLangBaseURL($toPage['lang']) . "/" . $toPage['page_title'] : "") . "</td><td>" . $it->error . "</td></tr>\n";
        }
    }
    if (isset($successes[$creator])) {
        foreach ($successes[$creator] as $it) {
            $fromPage = $lip[$it->fromLang][$it->fromAID];
            $toPage = $lip[$it->toLang][$it->toAID];
            $msg .= "<tr><td>" . Misc::getLangBaseURL($fromPage['lang']) . "/" . $fromPage['page_title'] . "</td><td>" . Misc::getLangBaseURL($toPage['lang']) . "/" . $toPage['page_title'] . "</td><td>" . ($it->error != '' ? $it->error : "Success") . "</td></tr>\n";
        }
    }
    $msg .= "</table>";
    $from = new MailAddress("alerts@wikihow.com");
    $to = new MailAddress($email);
    $subject = "Image Transfers Complete";
    $content_type = "text/html; charset={$wgOutputEncoding}";
    print "Sending email:\n from:alerts@wikihow.com\nto:{$email}\nSubject:{$subject}\n{$msg}";
    UserMailer::send($to, $from, $subject, $msg, false, $content_type);
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:alfredoCron.php

示例7: wfGetDB

<?php

// Get all alfredo articles, that have an extra intro space
require_once "commandLine.inc";
$dbr = wfGetDB(DB_SLAVE);
$sql = "select distinct itj_to_aid from wikidb_112.image_transfer_job where itj_to_lang=" . $dbr->addQuotes($wgLanguageCode);
$res = $dbr->query($sql, __METHOD__);
$ids = array();
foreach ($res as $row) {
    $ids[] = $row->itj_to_aid;
}
$lookupIds = array();
foreach ($ids as $id) {
    if ($id != 0) {
        $t = Title::newFromId($id);
        if ($t) {
            $r = Revision::newFromTitle($t);
            if ($r && preg_match("@^ +[^\\s\\[]@", $r->getText(), $matches)) {
                print $r->getText();
                $lookupIds[] = array('lang' => $wgLanguageCode, 'id' => $id);
            }
        }
    }
}
$pages = Misc::getPagesFromLangIds($lookupIds);
foreach ($pages as $page) {
    print Misc::getLangBaseURL($wgLanguageCode) . '/' . $page['page_title'] . "\n";
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:28,代码来源:checkForLeadingSpaces.php

示例8: addLink

 /**
  * Add interwiki links between page A, and page B
  * @param forward Do a forward link? Otherwise, we do a link from toAID to fromAID
  * @param dryRun Run through adding the links without actually adding the links. Instead, just output as if we added the links. 
  * @return array('status'=>,'dup'=>) Status is 0 unable to add, 1 already added, 2 Overrode other links in same language  3 add successfully. dup is an array of other links to the same language, which are overriden if dryRun is set to to false
  */
 function addLink($forward, $dryRun = true)
 {
     global $wgServer, $wgUser, $wgLanguageCode;
     $ret = array('status' => 0, 'dup' => array());
     // Make sure we are adding a link between working URLs
     if (intVal($this->fromAID) <= 0 || intVal($this->toAID) <= 0) {
         return $ret;
     }
     if ($this->fromURL == NULL || $this->toURL == NULL) {
         return $ret;
     }
     if ($forward) {
         $fromURL = urldecode($this->fromURL);
         $toURL = urldecode($this->toURL);
         $fromAID = $this->fromAID;
         $toAID = $this->toAID;
         $fromLang = $this->fromLang;
         $toLang = $this->toLang;
     } else {
         $fromURL = urldecode($this->toURL);
         $toURL = urldecode($this->fromURL);
         $toAID = $this->fromAID;
         $fromAID = $this->toAID;
         $fromLang = $this->toLang;
         $toLang = $this->fromLang;
     }
     // We can only add links for our language code
     if (!preg_match('@' . preg_quote(Misc::getLangBaseURL($wgLanguageCode), "@") . '/(.+)@', $fromURL, $matches)) {
         return $ret;
     }
     $fromPage = Misc::fullUrlToPartial($fromURL);
     $toPage = Misc::fullUrlToPartial($toURL);
     $fromTitle = Title::newFromId($fromAID);
     if (!$fromTitle || $fromTitle->getNamespace() != NS_MAIN) {
         return $ret;
     }
     $r = Revision::newFromTitle($fromTitle);
     if (!$r) {
         return $ret;
     }
     $text = $r->getText();
     $linkText = "\n[[" . $toLang . ":" . str_replace("-", " ", $toPage) . "]]";
     $linkTextRE = "\\[\\[" . $toLang . ":(?:" . preg_quote($toPage, "/") . "|" . preg_quote(urlencode($toPage), "/") . ")\\]\\]";
     $linkTextRE = str_replace("\\-", "[ -]", $linkTextRE);
     //Duplicate
     if (preg_match("/" . $linkTextRE . "/", $text, $matches)) {
         $ret['status'] = 1;
         return $ret;
     } elseif (preg_match_all("/\\[\\[" . $toLang . ":[^\\]]+\\]\\]/i", $text, $matches)) {
         $ret['status'] = 2;
         $ret['dup'] = $matches[0];
         foreach ($matches[0] as $match) {
             $text = preg_replace("@[\r\n]*" . preg_quote($match) . "@", "", $text);
             $text = str_replace($match, "", $text);
         }
     } else {
         $ret['status'] = 3;
     }
     $text .= $linkText;
     $article = new Article($fromTitle);
     if (!$dryRun) {
         $article->doEdit($text, wfMsg('addll-editsummary'));
         self::writeLog(self::ACTION_SAVE, $fromLang, $r->getId(), $fromAID, $fromPage, $toLang, $toPage, $toAID, "interwiki");
     }
     return $ret;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:72,代码来源:TranslationLink.class.php


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