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


PHP WikiFactory::getCategory方法代码示例

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


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

示例1: getVerticalByWikiId

 /**
  * Get the vertical name for a wiki by its' ID
  *
  * @param integer $wikiId The wiki's ID
  *
  * @return string The name of the vertical (e.g. Gaming, Entertainment, etc.)
  */
 private function getVerticalByWikiId($wikiId)
 {
     //this has its' own cache layer
     $cat = WikiFactory::getCategory($wikiId);
     $ret = null;
     if (!empty($cat)) {
         $ret = $cat->cat_name;
     }
     return $ret;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:17,代码来源:WikisModel.class.php

示例2: loadData

 public static function loadData($forceRefresh = false, $forceLanguage = null)
 {
     global $wgMemc, $wgStatsDB, $wgContLang, $wgExternalSharedDB, $wgStatsDBEnabled;
     wfProfileIn(__METHOD__);
     self::$mLanguage = !empty($forceLanguage) ? $forceLanguage : $wgContLang->getCode();
     $cacheKey = self::CACHE_KEY_TOKEN . ':' . strtoupper(self::$mLanguage);
     self::$mData = $wgMemc->get($cacheKey);
     if (empty(self::$mData) || $forceRefresh) {
         self::$mData = array();
         $wikisIDs = array();
         // get all the active wikis selected by the sales team
         $wikiFactoryRecommended = WikiFactory::getVarByName(self::WF_VAR_NAME, null);
         self::$mData['recommended'] = array();
         if (!empty($wikiFactoryRecommended) && !empty($wikiFactoryRecommended->cv_variable_id)) {
             $dbr = WikiFactory::db(DB_SLAVE);
             $res = $dbr->select(array('city_list', 'city_variables'), 'city_id', array('city_id = cv_city_id', 'city_public' => 1, 'city_lang' => self::$mLanguage, 'cv_variable_id' => $wikiFactoryRecommended->cv_variable_id, 'cv_value' => serialize(true)));
             while ($row = $dbr->fetchObject($res)) {
                 self::$mData['recommended'][] = $row->city_id;
             }
             $dbr->freeResult($res);
         }
         $counter = 0;
         self::$mData['hubs'] = array();
         if (!empty($wgStatsDBEnabled)) {
             $wikis = DataMartService::getTopWikisByPageviews(DataMartService::PERIOD_ID_MONTHLY, 200, self::$mLanguage, null, 1);
             $minPageViews = isset(self::$pageviewsLimits[self::$mLanguage]) ? self::$pageviewsLimits[self::$mLanguage] : self::$pageviewsLimits['default'];
             foreach ($wikis as $wikiID => $pvCount) {
                 if ($pvCount >= $minPageViews) {
                     $hub = WikiFactory::getCategory($wikiID);
                     if (!$hub) {
                         continue;
                     }
                     if (!isset(self::$mData['hubs'][$hub->cat_id])) {
                         self::$mData['hubs'][$hub->cat_id] = array();
                     }
                     self::$mData['hubs'][$hub->cat_id][] = $wikiID;
                     $counter++;
                 }
             }
         }
         // removing entries from hubs that have a match in recommended
         if (!empty(self::$mData['recommended']) && !empty(self::$mData['hubs'])) {
             $counter = 0;
             foreach (self::$mData['hubs'] as $hubID => &$item) {
                 $item = array_diff($item, self::$mData['recommended']);
                 $counter += count($item);
             }
         }
         self::$mData['total'] = $counter;
         $wgMemc->set($cacheKey, self::$mData, 3600 * self::CACHE_EXPIRY);
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:53,代码来源:RandomWikiHelper.class.php

示例3: appendWikidesc

 protected function appendWikidesc($property)
 {
     global $wgLanguageCode, $wgDBcluster;
     $result = $this->getResult();
     $lang_id = WikiFactory::LangCodeToId($wgLanguageCode);
     $cats = WikiFactory::getCategory($this->cityId);
     $oWiki = WikiFactory::getWikiByID($this->cityId);
     $cat_id = !empty($cats) ? $cats->cat_id : 0;
     $data = array("langid" => $lang_id, "id" => $this->cityId, "catid" => $cat_id, "pagetitle" => wfMsg('pagetitle'), "flags" => $oWiki->city_flags, "db" => $oWiki->city_dbname, "position" => isset($wgDBcluster) ? $wgDBcluster : $oWiki->city_cluster);
     $result->setIndexedTagName($data, $property);
     $result->addValue('query', $property, $data);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:WikiaApiQuerySiteinfo.php

示例4: generateList

function generateList($format)
{
    global $wgMemc, $wgExternalSharedDB;
    $func = "begin_" . $format;
    $res = $func();
    $dbr = WikiFactory::db(DB_SLAVE, array(), $wgExternalSharedDB);
    $sth = $dbr->select(array("city_list"), array("city_title", "city_lang", "city_url", "city_id"), array("city_public = 1"), __METHOD__);
    while ($row = $dbr->fetchObject($sth)) {
        $row->category = WikiFactory::getCategory($row->city_id);
        $func = "body_" . $format;
        $res .= $func($row);
    }
    $func = "end_" . $format;
    $res .= $func();
    if (!empty($res)) {
        $gz_res = gzdeflate($res, 3);
        $wgMemc->set(wfSharedMemcKey("{$format}-city-list"), $gz_res, 3600 * 6);
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:newWikis.php

示例5: init

	public function init() {
		global $wgCityId;

		$this->app->wf->ProfileIn(__METHOD__);

		$category = WikiFactory::getCategory($wgCityId);

		$messageName = 'shared-Globalnavigation';
		if ($category) {
			$messageNameWithCategory = $messageName . '-' . $category->cat_id;
			if (!wfEmptyMsg($messageNameWithCategory, wfMsg($messageNameWithCategory))) {
				$messageName = $messageNameWithCategory;
			}
		}

		$navigation = new NavigationService(true /* useSharedMemcKey */);
		$menuNodes = $navigation->parseMessage($messageName, array(3, 4, 5), 10800 /* 3 hours */);

		wfRunHooks('AfterGlobalHeader', array(&$menuNodes, $category, $messageName));

		$this->menuNodes = $menuNodes;

		$this->app->wf->ProfileOut(__METHOD__);
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:24,代码来源:GlobalHeaderController.class.php

示例6: execute

 public function execute($wikiID)
 {
     global $wgOut, $wgRequest, $wgCityId, $wgUser;
     wfProfileIn(__METHOD__);
     $this->setHeaders();
     $firstVisit = true;
     $wikiID = !empty($wikiID) ? (int) $wikiID : $wgCityId;
     if (isset($_COOKIE[$this->mCookieName])) {
         $this->mCookie = json_decode($_COOKIE[$this->mCookieName]);
         $firstVisit = false;
     } else {
         $this->mCookie = new stdClass();
         $this->mCookie->origHub = null;
         $this->mCookie->langCode = null;
         $this->mCookie->history = array();
         if (!empty($wikiID)) {
             $hub = WikiFactory::getCategory($wikiID);
             if (is_object($hub)) {
                 $this->mCookie->origHub = $hub->cat_id;
                 $this->mCookie->langCode = WikiFactory::getWikiByID($wikiID)->city_lang;
                 $this->mCookie->history[] = $wikiID;
             }
         }
     }
     $this->loadData();
     $historyCount = count($this->mCookie->history);
     // reset the history if the user visited all the possible targets
     if ($historyCount >= $this->mData['total']) {
         $this->mCookie->history = array($wikiID);
     }
     // if language other than English and list of targets exhausted fall back to english
     if (($historyCount >= $this->mData['total'] || $this->mData['total'] == 0 && (count($this->mData['recommended']) == 0 || !$firstVisit)) && $this->mCookie->langCode != 'en') {
         $this->mCookie->langCode = 'en';
         $this->loadData();
     }
     $destinationID = null;
     $from = null;
     srand(time());
     // pick a recommended wiki the first time
     if ($firstVisit && !empty($this->mData['recommended'])) {
         $destinationID = $this->mData['recommended'][array_rand($this->mData['recommended'])];
         $from = 'recommended';
     } elseif (!empty($this->mCookie->origHub) && !empty($this->mData['hubs'][$this->mCookie->origHub])) {
         $currentHub = array_diff($this->mData['hubs'][$this->mCookie->origHub], $this->mCookie->history);
         if (count($currentHub) && count($this->mCookie->history) < RandomWikiHelper::TRACK_LIMIT) {
             $destinationID = $currentHub[array_rand($currentHub)];
             $from = 'origHub';
         }
     }
     // in case no wiki has been selected in the previous block pick a wiki from a random hub
     if (empty($destinationID)) {
         $hubsCount = count($this->mData['hubs']);
         $hub = array_rand($this->mData['hubs'], $hubsCount);
         if (!is_array($hub)) {
             $hub = array($hub);
         }
         foreach ($hub as $key) {
             $tmpHub = array_diff($this->mData['hubs'][$key], $this->mCookie->history);
             if (!count($tmpHub)) {
                 continue;
             }
             $itemKey = array_rand($tmpHub);
             $destinationID = $tmpHub[$itemKey];
             $from = "hub {$itemKey}";
         }
     }
     $this->mCookie->history[] = $destinationID;
     $cookieValue = json_encode($this->mCookie);
     $wgRequest->response()->setcookie(self::COOKIE_NAME_TOKEN, $cookieValue, time() + 3600 * self::COOKIE_EXPIRY);
     $url = WikiFactory::getVarValueByName('wgServer', $destinationID);
     //FB#1033: avoid being sent to Special:WikiActivity when logged-in, see MyHomw::getInitialMainPage
     if ($wgUser->isLoggedIn()) {
         $url .= '?redirect=no';
     }
     // Redirect the user to a randomly-chosen wiki (or not if profiling requested)
     $profiling = $wgRequest->getInt('forceprofile', 0);
     if ($profiling !== 1) {
         $wgOut->redirect($url);
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:81,代码来源:SpecialRandomWiki_body.php

示例7: empty

?>
</td>
				<td><?php 
echo $wiki->city_dbname;
?>
</td>
				<td><?php 
echo empty($cluster) ? "c1<acronym title='default'>*</acronym>" : $cluster;
?>
</td>
				<td><?php 
echo $wiki->city_lang;
?>
</td>
				<td><?php 
$wgHub = WikiFactory::getCategory($wiki->city_id);
if ($wgHub) {
    echo "<acronym title=\"id:{$wgHub->cat_id}\">{$wgHub->cat_name}</acronym>";
}
?>
</td>
				<td data-status="<?php 
echo $wiki->city_public;
?>
"><?php 
echo "<acronym title=\"{$wiki->city_public}\">{$statuses[$wiki->city_public]}</acronym>";
?>
</td>
			</tr>
		</table>
		</td>
开发者ID:schwarer2006,项目名称:wikia,代码行数:31,代码来源:form.tmpl.php

示例8: getCategoryIdForCity

 /**
  * Get category id for given cityId
  *
  * @param int $city_id city id
  *
  * @return stdClass ($row->cat_id $row->cat_name)
  */
 private static function getCategoryIdForCity($cityId)
 {
     $categoryId = null;
     if (self::isCorporatePage($cityId)) {
         $categoryId = WikiFactoryHub::CATEGORY_ID_CORPORATE;
     } else {
         $category = WikiFactory::getCategory($cityId);
         if ($category) {
             $categoryId = $category->cat_id;
         }
     }
     // Look for Comscore tag
     $wftags = new WikiFactoryTags($cityId);
     $tags = $wftags->getTags();
     if (is_array($tags)) {
         foreach ($tags as $name) {
             if (startsWith($name, self::$comscore_prefix, false)) {
                 $catName = substr($name, strlen(self::$comscore_prefix));
                 $category = WikiFactoryHub::getInstance()->getCategoryByName($catName);
                 if ($category) {
                     return $category['id'];
                 }
             }
         }
     }
     return $categoryId;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:34,代码来源:HubService.class.php

示例9: compareEventRecordWithRevision

function compareEventRecordWithRevision($dbname, $oRow, $debug)
{
    global $wgTitle, $wgLanguageCode;
    $langcode = WikiFactory::getVarValueByName('wgLanguageCode', $oRow->wiki_id);
    $lang_id = WikiFactory::LangCodeToId($langcode);
    $cats = WikiFactory::getCategory($oRow->wiki_id);
    $cat_id = !empty($cats) ? $cats->cat_id : 0;
    $result = false;
    if (is_object($oRow) && !empty($oRow->page_id) && !empty($oRow->rev_id)) {
        $data = loadFromDB($dbname, $oRow->page_id, $oRow->rev_id);
        if (is_object($data)) {
            $oRevision = new Revision($data);
            if ($oRow->rev_id > 0) {
                $wgTitle = Title::makeTitle($data->page_namespace, $data->page_title);
            } else {
                $wgTitle = $oRevision->getTitle();
            }
            $content = $oRevision->getText(Revision::FOR_THIS_USER);
            $is_bot = _user_is_bot($data->rev_user_text);
            $is_content = _revision_is_content();
            $is_redirect = _revision_is_redirect($content);
            $size = intval($oRevision->getSize());
            $words = str_word_count($content);
            $links = _make_links($oRow->page_id, $oRow->rev_id, $content);
            $timestamp = $data->ts;
            if ($data->rev_page == $oRow->page_id && $data->page_namespace == $oRow->page_ns && $data->rev_id == $oRow->rev_id && $timestamp == $oRow->rev_timestamp && $data->rev_user == $oRow->user_id && $is_bot == $oRow->user_is_bot && $is_content == $oRow->is_content && $is_redirect == $oRow->is_redirect && $size == $oRow->rev_size && $words == $oRow->total_words && $cat_id == $oRow->wiki_cat_id && $lang_id == $oRow->wiki_lang_id && $links['image'] == $oRow->image_links && $links['video'] == $oRow->video_links) {
                $result = true;
            } else {
                if ($debug) {
                    echo <<<TEXT
\tpage: {$data->rev_page} == {$oRow->page_id}
\tnamespage: {$data->page_namespace}\t== {$oRow->page_ns}
\trevision: {$data->rev_id}\t== {$oRow->rev_id}
\ttimestamp: {$timestamp} == {$oRow->rev_timestamp}
\tuser: {$data->rev_user} == {$oRow->user_id}
\tis_bot: {$is_bot} == {$oRow->user_is_bot}
\tis_content: {$is_content} == {$oRow->is_content}
\tis_redirect: {$is_redirect} == {$oRow->is_redirect}
\tsize: {$size} == {$oRow->rev_size}
\twords: {$words} == {$oRow->total_words}
\tcategory: {$cat_id} == {$oRow->wiki_cat_id}
\tlanguage: {$lang_id} == {$oRow->wiki_lang_id}
\timage links:{$links['image']} == {$oRow->image_links}
\tvideo links: {$links['video']} == {$oRow->video_links}

TEXT;
                }
            }
        } else {
            echo "Not local data found for: page: {$oRow->page_id} && revision: {$oRow->rev_id}  \n";
        }
    } else {
        echo "Not events data found for: page: {$oRow->page_id} && revision: {$oRow->rev_id}  \n";
    }
    return $result;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:testArchiveData.php

示例10: saveWiki

 protected function saveWiki($wiki)
 {
     $data = $wiki;
     $data['city_id'] = $data['id'];
     $data['city_public'] = $data['public'];
     $data['created'] = $this->ts($data['created']);
     $data['lastedited'] = $this->ts($data['lastedited']);
     $catData = WikiFactory::getCategory($data['id']);
     $data['city_cat_name'] = $catData ? $catData->cat_name : '';
     unset($data['public']);
     unset($data['id']);
     unset($data['url']);
     $this->getCache()->update($data);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:update.php

示例11: setCategory

 public function setCategory()
 {
     //This field is called categoryId but getCategory returns an object with cat_id and cat_name fields
     $this->mParams['categoryId'] = WikiFactory::getCategory($this->app->wg->CityId);
     // The code should probably be changed to this after double checking the scribe consumers
     //$category = WikiFactory::getCategory( $this->app->wg->CityId );
     //$this->mParams['categoryId'] = isset($category->cat_id) ? $category->cat_id : 0;
     //
     // And when categories are updated:
     //$this->mParams['categories'] = WikiFactory::getCategories( $this->app->wg->CityId );
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:ScribeEventProducer.class.php

示例12: __loadWikia

 /**
  * __loadWikia
  *
  * @access private
  *
  * @param Array range of columns in main table (A..Z)
  */
 private function __loadWikia()
 {
     global $wgLang, $wgContLang;
     $this->oWikia = WikiFactory::getWikiByID($this->mCityId);
     if (isset($this->oWikia) && !empty($this->oWikia)) {
         # created
         $this->oWikia->city_created_txt = "";
         if (isset($this->oWikia->city_created)) {
             $city_created = preg_replace("/(\\s|\\:|\\-)/", "", $this->oWikia->city_created);
             $this->oWikia->city_created_txt = $wgLang->timeanddate($city_created, true);
         }
         # category
         $this->oWikia->category = WikiFactory::getCategory($this->mCityId);
         # language name
         $this->oWikia->languageName = isset($this->oWikia->city_lang) ? $wgContLang->getLanguageName($this->oWikia->city_lang) : " - ";
         # Wikia title
         $this->oWikia->city_title = $this->mCityId > 0 ? ucfirst($this->oWikia->city_title) : wfMsg("wikistats_trend_all_wikia_text");
         # Wikia url
         $this->oWikia->city_url = $this->mCityId > 0 ? Xml::openElement('a', array('target' => 'new', 'href' => $this->oWikia->city_url)) . $this->oWikia->city_url . Xml::closeElement('a') : "";
         # Wikia domain
         $this->oWikia->city_domain = WikiFactory::getVarValueByName("wgServer", $this->mCityId);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SpecialWikiStats_helper.php

示例13: initVertical

 protected function initVertical()
 {
     global $wgCityId;
     $this->verticalId = HubService::getCanonicalCategoryId(WikiFactory::getCategory($wgCityId)->cat_id);
     $this->cityId = $wgCityId;
     $this->verticalName = $this->getContext()->getTitle()->getText();
     $this->canonicalVerticalName = str_replace(' ', '', $this->model->getCanonicalVerticalNameById($this->cityId));
     $this->wg->out->setPageTitle($this->verticalName);
     // For the main page, overwrite the <title> element with the contents of 'pagetitle-view-mainpage'.
     if ($this->getContext()->getTitle()->isMainPage()) {
         $msg = wfMessage('pagetitle-view-mainpage')->inContentLanguage();
         if (!$msg->isDisabled()) {
             $this->wg->out->setHTMLTitle($msg->title($this->getContext()->getTitle()));
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:WikiaHubsV3Controller.class.php

示例14: setCategory

 public function setCategory()
 {
     $this->mParams['categoryId'] = WikiFactory::getCategory($this->app->wg->CityId);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:4,代码来源:ScribeEventProducer.class.php


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