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


PHP WikiFactory类代码示例

本文整理汇总了PHP中WikiFactory的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory类的具体用法?PHP WikiFactory怎么用?PHP WikiFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: process

 /**
  * Called from maintenance script only.  Send Digest emails for any founders with that preference enabled
  *
  * @param array $events Events is empty for this type
  */
 public function process(array $events)
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $founderEmailObj = FounderEmails::getInstance();
     $wgTitle = Title::newMainPage();
     // Get list of founders with digest mode turned on
     $cityList = $founderEmailObj->getFoundersWithPreference('founderemails-views-digest');
     $wikiService = new WikiService();
     // Gather daily page view stats for each wiki requesting views digest
     foreach ($cityList as $cityID) {
         $user_ids = $wikiService->getWikiAdminIds($cityID);
         $foundingWiki = WikiFactory::getWikiById($cityID);
         $page_url = GlobalTitle::newFromText('Createpage', NS_SPECIAL, $cityID)->getFullUrl(array('modal' => 'AddPage'));
         $emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID));
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($user, $cityID)) {
                 continue;
             }
             self::addParamsUser($cityID, $user->getName(), $emailParams);
             $langCode = $user->getGlobalPreference('language');
             $links = array('$WIKINAME' => $emailParams['$WIKIURL']);
             $mailSubject = strtr(wfMsgExt('founderemails-email-views-digest-subject', array('content')), $emailParams);
             $mailBody = strtr(wfMsgExt('founderemails-email-views-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS']), $emailParams);
             $mailBodyHTML = F::app()->renderView('FounderEmails', 'GeneralUpdate', array_merge($emailParams, array('language' => 'en', 'type' => 'views-digest')));
             $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
             $mailCategory = FounderEmailsEvent::CATEGORY_VIEWS_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
             $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
         }
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:FounderEmailsViewsDigestEvent.class.php

示例2: getPathPrefix

 function getPathPrefix()
 {
     $wikiDbName = $this->repo->getDBName();
     $wikiId = WikiFactory::DBtoID($wikiDbName);
     $wikiUploadPath = WikiFactory::getVarValueByName('wgUploadPath', $wikiId);
     return VignetteRequest::parsePathPrefix($wikiUploadPath);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:WikiaForeignDBFile.class.php

示例3: getCityId

 public function getCityId()
 {
     if (empty($this->cityId) and !empty($this->dbName)) {
         $this->cityId = WikiFactory::DBtoID($this->dbName);
     }
     return $this->cityId;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:PromoImage.class.php

示例4: execute

 /**
  * execute -- main entry point to api method
  *
  * use secret hash for checking if api is called by proper engine
  *
  * @access public
  *
  * @return api result
  */
 public function execute()
 {
     global $wgTheSchwartzSecretToken, $wgCityId, $wgServer, $wgExtensionMessagesFiles;
     $params = $this->extractRequestParams();
     $status = 0;
     if (isset($params["token"]) && $params["token"] === $wgTheSchwartzSecretToken) {
         /**
          * get creator from param
          */
         $founder = User::newFromId($params["user_id"]);
         $founder->load();
         /**
          * get city_founding_user from city_list
          */
         if (!$founder) {
             $wiki = WikiFactory::getWikiByID($wgCityId);
             $founder = User::newFromId($wiki->city_founding_user);
         }
         Wikia::log(__METHOD__, "user", $founder->getName());
         if ($founder && $founder->isEmailConfirmed()) {
             if ($founder->sendMail(wfMsg("autocreatewiki-reminder-subject"), wfMsg("autocreatewiki-reminder-body", array($founder->getName(), $wgServer)), null, null, "AutoCreateWikiReminder", wfMsg("autocreatewiki-reminder-body-HTML", array($founder->getName(), $wgServer)))) {
                 $status = 1;
             }
         }
     } else {
         $this->dieUsageMsg(array("sessionfailure"));
     }
     $result = array("status" => $status);
     $this->getResult()->setIndexedTagName($result, 'status');
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:40,代码来源:WikiaApiCreatorReminderEmail.php

示例5: WidgetFounderBadge

function WidgetFounderBadge($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetFounderBadge", "user");
    $user = $wgMemc->get($key);
    if (is_null($user)) {
        global $wgCityId;
        $user = WikiFactory::getWikiById($wgCityId)->city_founding_user;
        $wgMemc->set($key, $user, 3600);
    }
    if (0 == $user) {
        return wfMsgForContent("widget-founderbadge-notavailable");
    }
    $key = wfMemcKey("WidgetFounderBadge", "edits");
    $edits = $wgMemc->get($key);
    if (empty($edits)) {
        $edits = AttributionCache::getInstance()->getUserEditPoints($user);
        $wgMemc->set($key, $edits, 300);
    }
    $author = array("user_id" => $user, "user_name" => User::newFromId($user)->getName(), "edits" => $edits);
    $output = Answer::getUserBadge($author);
    wfProfileOut(__METHOD__);
    return $output;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:26,代码来源:WidgetFounderBadge.php

示例6: execute

 public function execute($subpage)
 {
     global $wgOut, $wgRequest, $wgUser, $wgCacheEpoch, $wgCityId;
     wfProfileIn(__METHOD__);
     $this->setHeaders();
     $this->mTitle = SpecialPage::getTitleFor('cacheepoch');
     if ($this->isRestricted() && !$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         wfProfileOut(__METHOD__);
         return;
     }
     //no WikiFactory (internal wikis)
     if (empty($wgCityId)) {
         $wgOut->addHTML(wfMsg('cacheepoch-no-wf'));
         wfProfileOut(__METHOD__);
         return;
     }
     if ($wgRequest->wasPosted()) {
         $wgCacheEpoch = wfTimestampNow();
         $status = WikiFactory::setVarByName('wgCacheEpoch', $wgCityId, $wgCacheEpoch, wfMsg('cacheepoch-wf-reason'));
         if ($status) {
             $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-updated', $wgCacheEpoch) . '</h2>');
         } else {
             $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-not-updated') . '</h2>');
         }
     } else {
         $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-header') . '</h2>');
     }
     $wgOut->addHTML(Xml::openElement('form', array('action' => $this->mTitle->getFullURL(), 'method' => 'post')));
     $wgOut->addHTML(wfMsg('cacheepoch-value', $wgCacheEpoch) . '<br>');
     $wgOut->addHTML(Xml::submitButton(wfMsg('cacheepoch-submit')));
     $wgOut->addHTML(Xml::closeElement('form'));
     wfProfileOut(__METHOD__);
 }
开发者ID:yusufchang,项目名称:app,代码行数:34,代码来源:SpecialCacheEpoch.php

示例7: __construct

 public function __construct($id = null)
 {
     parent::__construct();
     if (is_null($id)) {
         $id = $this->wg->CityId;
     }
     $this->id = $id;
     if ($this->wg->CityId == $id) {
         $this->db = wfGetDB(DB_SLAVE);
         $this->dbname = $this->wg->DBname;
     } else {
         // find db name
         $dbname = WikiFactory::IDtoDB($this->id);
         if (empty($dbname)) {
             throw new Exception("Could not find wiki with ID {$this->id}");
         }
         // open db connection (and check if db really exists)
         $db = wfGetDB(DB_SLAVE, array(), $dbname);
         if (!is_object($db)) {
             throw new Exception("Could not connect to wiki database {$dbname}");
         }
         $this->db = $db;
         $this->dbname = $dbname;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:WikiDataSource.php

示例8: newFromWiki

 /**
  * Get storage instance to access uploaded files for a given wiki
  *
  * @param $cityId number|string city ID or wiki name
  * @param $dataCenter string|null name of data center (res, iowa ... )
  * @return SwiftStorage storage instance
  */
 public static function newFromWiki($cityId, $dataCenter = null)
 {
     $wgUploadPath = \WikiFactory::getVarValueByName('wgUploadPath', $cityId);
     $path = trim(parse_url($wgUploadPath, PHP_URL_PATH), '/');
     list($containerName, $prefix) = explode('/', $path, 2);
     return new self($containerName, '/' . $prefix, $dataCenter);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:SwiftStorage.class.php

示例9: execute

 function execute($par)
 {
     global $wgOut, $wgCityId, $wgSuppressWikiHeader, $wgSuppressPageHeader, $wgShowMyToolsOnly, $wgExtensionsPath, $wgBlankImgUrl, $wgJsMimeType, $wgTitle, $wgUser, $wgRequest;
     wfProfileIn(__METHOD__);
     // redirect to www.wikia.com
     if ($wgCityId == 177) {
         $destServer = WikiFactory::getVarValueByName('wgServer', $this->destCityId);
         $destArticlePath = WikiFactory::getVarValueByName('wgArticlePath', $this->destCityId);
         $wgOut->redirect($destServer . str_replace('$1', 'Special:LandingPage', $destArticlePath));
         return;
     }
     $this->setHeaders();
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/LandingPage/css/LandingPage.scss'));
     // hide wiki and page header
     $wgSuppressWikiHeader = true;
     $wgSuppressPageHeader = true;
     // only shown "My Tools" on floating toolbar
     $wgShowMyToolsOnly = true;
     // parse language links (RT #71622)
     $languageLinks = array();
     $parsedMsg = wfStringToArray(wfMsg('landingpage-language-links'), '*', 10);
     foreach ($parsedMsg as $item) {
         if ($item != '') {
             list($text, $lang) = explode('|', $item);
             $languageLinks[] = array('text' => $text, 'href' => $wgTitle->getLocalUrl("uselang={$lang}"));
         }
     }
     // fetching the landingpage sites
     $landingPageLinks = CorporatePageHelper::parseMsgImg('landingpage-sites', false, false);
     // render HTML
     $template = new EasyTemplate(dirname(__FILE__) . '/templates');
     $template->set_vars(array('imagesPath' => $wgExtensionsPath . '/wikia/LandingPage/images/', 'languageLinks' => $languageLinks, 'wgBlankImgUrl' => $wgBlankImgUrl, 'wgTitle' => $wgTitle, 'landingPageLinks' => $landingPageLinks, 'landingPageSearch' => F::app()->getView("SearchController", "Index", array("placeholder" => "Search Wikia", "fulltext" => "0", "wgBlankImgUrl" => $wgBlankImgUrl, "wgTitle" => $wgTitle))));
     $wgOut->addHTML($template->render('main'));
     wfProfileOut(__METHOD__);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:35,代码来源:SpecialLandingPage.class.php

示例10: getUploadDir

 private function getUploadDir()
 {
     if (!isset($this->uploadDir)) {
         $this->uploadDir = WikiFactory::getVarValueByName('wgUploadPath', $this->mTitle->mCityId);
     }
     return $this->uploadDir;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:GlobalFile.class.php

示例11: countNotExternal

function countNotExternal()
{
    $dbr = wfGetDB(DB_SLAVE, "dpl");
    /**
     * get active databases from city_list
     */
    $databases = array();
    $res = $dbr->select(WikiFactory::table("city_list"), array("city_dbname", "city_id"), array("city_public" => 1), __FUNCTION__);
    while ($row = $dbr->fetchObject($res)) {
        $databases[$row->city_id] = $row->city_dbname;
    }
    $dbr->freeResult($res);
    foreach ($databases as $city_id => $database) {
        $sql = "\n\t\t\tSELECT count(*) as count\n\t\t\tFROM revision r1 FORCE INDEX (PRIMARY), text t2\n\t\t\tWHERE old_id = rev_text_id\n\t\t\tAND old_flags NOT LIKE '%external%'\n\t\t";
        $dbr->selectDB($database);
        $dbr->begin();
        $res = $dbr->query($sql, __FUNCTION__);
        $row = $dbr->fetchObject($res);
        if (!empty($row->count)) {
            printf("Not External rows in %5d %30s = %8d\n", $city_id, $database, $row->count);
        }
        $dbr->freeResult($res);
        $dbr->commit();
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:countNotExternal.php

示例12: initializeBlacklist

 /**
  * Look for videos that are blacklisted in the wgVideosModuleBlackList variable on community central
  */
 protected function initializeBlacklist()
 {
     $communityBlacklist = \WikiFactory::getVarByName("wgVideosModuleBlackList", \WikiFactory::COMMUNITY_CENTRAL);
     if (is_object($communityBlacklist) && !empty($communityBlacklist->cv_value)) {
         $this->blacklist = unserialize($communityBlacklist->cv_value);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:VideosModuleBase.class.php

示例13: performQueryTest

 /**
  * @param $wikiId
  * @param $query
  * @return float
  */
 public function performQueryTest($wikiId, $query)
 {
     $wgLinkSuggestLimit = 6;
     $dbName = WikiFactory::IDtoDB($wikiId);
     $db = wfGetDB(DB_SLAVE, [], $dbName);
     $namespaces = WikiFactory::getVarValueByName("wgContentNamespaces", $wikiId);
     $namespaces = $namespaces ? $namespaces : [0];
     $query = addslashes($query);
     $queryLower = strtolower($query);
     if (count($namespaces) > 0) {
         $commaJoinedNamespaces = count($namespaces) > 1 ? array_shift($namespaces) . ', ' . implode(', ', $namespaces) : $namespaces[0];
     }
     $pageNamespaceClause = isset($commaJoinedNamespaces) ? 'page_namespace IN (' . $commaJoinedNamespaces . ') AND ' : '';
     $pageTitlePrefilter = "";
     if (strlen($queryLower) >= 2) {
         $pageTitlePrefilter = "(\n\t\t\t\t\t\t\t( page_title " . $db->buildLike(strtoupper($queryLower[0]) . strtolower($queryLower[1]), $db->anyString()) . " ) OR\n\t\t\t\t\t\t\t( page_title " . $db->buildLike(strtoupper($queryLower[0]) . strtoupper($queryLower[1]), $db->anyString()) . " ) ) AND ";
     } else {
         if (strlen($queryLower) >= 1) {
             $pageTitlePrefilter = "( page_title " . $db->buildLike(strtoupper($queryLower[0]), $db->anyString()) . " ) AND ";
         }
     }
     $sql = "SELECT page_len, page_id, page_title, rd_title, page_namespace, page_is_redirect\n\t\t\t\t\t\tFROM page\n\t\t\t\t\t\tLEFT JOIN redirect ON page_is_redirect = 1 AND page_id = rd_from\n\t\t\t\t\t\tLEFT JOIN querycache ON qc_title = page_title AND qc_type = 'BrokenRedirects'\n\t\t\t\t\t\tWHERE  {$pageTitlePrefilter} {$pageNamespaceClause} (LOWER(page_title) LIKE '{$queryLower}%')\n\t\t\t\t\t\t\tAND qc_type IS NULL\n\t\t\t\t\t\tORDER BY page_id\n\t\t\t\t\t\tLIMIT " . $wgLinkSuggestLimit * 3;
     // we fetch 3 times more results to leave out redirects to the same page
     $start = microtime(true);
     $res = $db->query($sql, __METHOD__);
     while ($res->fetchRow()) {
     }
     return microtime(true) - $start;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:Query_B.class.php

示例14: markWikiAsClosed

 /**
  * Mark given wiki as queued for removal
  *
  * @param $wikiId integer city ID
  * @return bool
  */
 private function markWikiAsClosed($wikiId)
 {
     WikiFactory::setFlags($wikiId, WikiFactory::FLAG_FREE_WIKI_URL | WikiFactory::FLAG_DELETE_DB_IMAGES);
     $res = WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $wikiId, self::REASON);
     WikiFactory::clearCache($wikiId);
     return $res !== false;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:removeQAWikis.php

示例15: getVariablesValues

 /**
  * Get variables values
  *
  * @return object key / value list variables
  */
 private function getVariablesValues()
 {
     global $wgInstantGlobalsOverride;
     if (!empty($wgInstantGlobalsOverride) && is_array($wgInstantGlobalsOverride)) {
         $override = $wgInstantGlobalsOverride;
     } else {
         $override = [];
     }
     $ret = [];
     $variables = [];
     wfRunHooks('InstantGlobalsGetVariables', [&$variables]);
     foreach ($variables as $name) {
         // Use the value on community but override with the $wgInstantGlobalsOverride
         if (array_key_exists($name, $override)) {
             $value = $override[$name];
         } else {
             $value = WikiFactory::getVarValueByName($name, Wikia::COMMUNITY_WIKI_ID);
         }
         // don't emit "falsy" values
         if (!empty($value)) {
             $ret[$name] = $value;
         }
     }
     return (object) $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:InstantGlobalsModule.class.php


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