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


PHP Misc::getPagesFromLangIds方法代码示例

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


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

示例1: 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

示例2: 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

示例3: while

        while ($n < count($fromPages)) {
            $deleted .= textFromPage($fromPages[$n]) . " to " . textFromPage($toPages[$n]) . "\n";
            $n += 1;
        }
    }
    $sql = "select tl_from_lang, tl_from_aid, tl_to_lang, tl_to_aid FROM " . $langDB . ".daily_edits de" . " JOIN wikidb_112.translation_link tl on (tl.tl_from_aid=de.de_page_id AND tl_from_lang='{$lang}') or (tl.tl_to_lang='{$lang}' AND tl.tl_to_aid=de.de_page_id)" . " JOIN " . $langDB . ".page p on p.page_id=de.de_page_id" . " WHERE de_timestamp > '{$lowDate}' and p.page_is_redirect=1 and de_edit_type=" . DailyEdits::EDIT_TYPE;
    $res = $dbh->query($sql);
    $fromIds = array();
    $toIds = array();
    while ($row = $dbh->fetchObject($res)) {
        $fromIds[] = array('lang' => $row->tl_from_lang, 'id' => $row->tl_from_aid);
        $toIds[] = array('lang' => $row->tl_to_lang, 'id' => $row->tl_to_aid);
    }
    if (count($fromIds) > 0) {
        $fromPages = Misc::getPagesFromLangIds($fromIds);
        $toPages = Misc::getPagesFromLangIds($toIds);
        $n = 0;
        while ($n < count($fromPages)) {
            $redirected .= textFromPage($fromPages[$n]) . " to " . textFromPage($toPages[$n]) . "\n";
            $n += 1;
        }
    }
}
if ($moved != "" || $deleted != "" || $redirected != "") {
    $msg = substr($lowDate, 0, 4) . "-" . substr($lowDate, 4, 2) . "-" . substr($lowDate, 6, 2) . " to " . substr($today, 0, 4) . "-" . substr($today, 4, 2) . "-" . substr($today, 6, 2) . "\n";
    if ($redirected != "") {
        $msg .= "\nOne or both articles in each of the following translation links were redirected:\n" . $redirected;
    }
    if ($moved != "") {
        $msg .= "\nOne or both articles in each of the following translation links were moved:\n" . $moved;
    }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:sendLLChangedEmail.php

示例4: wfGetDB

    print "Running live in {$wgLanguageCode}\n";
}
global $wgUser;
$wgUser = User::newFromName("AlfredoBot");
$dbr = wfGetDB(DB_SLAVE);
$its = ImageTransfer::getUpdatesForLang($wgLanguageCode);
$errors = array();
$successes = array();
$creators = array();
$langIds = array();
foreach ($its as $it) {
    $langIds[] = array('lang' => $it->fromLang, 'id' => $it->fromAID);
    $langIds[] = array('lang' => $it->toLang, 'id' => $it->toAID);
}
//Look up URLs of ids
$pages = Misc::getPagesFromLangIds($langIds);
$lip = array();
foreach ($pages as $page) {
    $lip[$page['lang']][$page['page_id']] = $page;
}
foreach ($its as $it) {
    $fromPage = $lip[$it->fromLang][$it->fromAID];
    $toPage = $lip[$it->toLang][$it->toAID];
    print "Adding images to article:" . Misc::getLangBaseURL($toPage['lang']) . '/' . $toPage['page_title'] . ' (' . $it->toLang . ' ' . $it->toAID . ') based off ' . Misc::getLangBaseURL($fromPage['lang']) . '/' . $fromPage['page_title'] . ' (' . $it->fromLang . ' ' . $it->fromAID . ")\n";
    if (!$it->addImages($dryRun)) {
        print "Failed with error:" . $it->error . "\n";
        $errors[$it->creator][] = $it;
    } else {
        $successes[$it->creator][] = $it;
        print "Success\n";
    }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:alfredoCron.php

示例5: 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

示例6: batchPopulateURLs

 /**
  * Set the fromURL and toURL for a bunch of links
  */
 static function batchPopulateURLs(&$links)
 {
     $bl = array();
     foreach ($links as $link) {
         $bl[] = array('id' => $link->fromAID, 'lang' => $link->fromLang);
         $bl[] = array('id' => $link->toAID, 'lang' => $link->toLang);
     }
     $pages = Misc::getPagesFromLangIds($bl);
     $ll = array();
     foreach ($pages as $b) {
         if (isset($b['page_title'])) {
             $ll[$b['lang'] . $b['page_id']] = Misc::getLangBaseURL($b['lang']) . '/' . $b['page_title'];
         }
     }
     foreach ($links as &$link) {
         if (isset($ll[$link->fromLang . $link->fromAID])) {
             $link->fromURL = $ll[$link->fromLang . $link->fromAID];
         }
         if (isset($ll[$link->toLang . $link->toAID])) {
             $link->toURL = $ll[$link->toLang . $link->toAID];
         }
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:26,代码来源:TranslationLink.class.php


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