本文整理汇总了PHP中Wikia::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Wikia::getVar方法的具体用法?PHP Wikia::getVar怎么用?PHP Wikia::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikia
的用法示例。
在下文中一共展示了Wikia::getVar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onArticleSaveComplete
public static function onArticleSaveComplete($article, $user, $revision, $status)
{
wfProfileIn(__METHOD__);
$insertedImages = Wikia::getVar('imageInserts');
$imageDeletes = Wikia::getVar('imageDeletes');
$changedImages = $imageDeletes;
foreach ($insertedImages as $img) {
$changedImages[$img['il_to']] = true;
}
$sendTrackEvent = false;
foreach ($changedImages as $imageDBName => $dummy) {
$title = Title::newFromDBkey($imageDBName);
if (!empty($title)) {
$mq = new self($title);
$mq->unsetCache();
$sendTrackEvent = true;
}
}
// send track event if embed change
if ($sendTrackEvent) {
Track::event('embed_change');
}
wfProfileOut(__METHOD__);
return true;
}
示例2: execute
function execute()
{
$this->app->setSkinTemplateObj($this);
$response = $this->app->sendRequest(Wikia::getVar('OasisEntryControllerName', 'Oasis'), 'index', null, false);
$response->sendHeaders();
$response->render();
}
示例3: doEdit
function doEdit($edit)
{
// create "fake" EditPage
$editor = (object) array('textbox1' => isset($edit['text']) ? $edit['text'] : '');
// try to get section name
MyHome::getSectionName($editor, '', !empty($edit['section']) ? $edit['section'] : false, $errno);
// create "fake" RecentChange object
$row = (object) array('rev_timestamp' => time(), 'rev_user' => 1, 'rev_user_text' => 'test', 'page_namespace' => NS_MAIN, 'page_title' => 'Test', 'rev_comment' => isset($edit['comment']) ? $edit['comment'] : '', 'rev_minor_edit' => true, 'page_is_new' => !empty($edit['is_new']), 'page_id' => 1, 'rev_id' => 1, 'rc_id' => 1, 'rc_patrolled' => 1, 'rc_old_len' => 1, 'rc_new_len' => 1, 'rc_deleted' => 1, 'rc_timestamp' => time());
$rc = RecentChange::newFromCurRow($row);
// call MyHome to add its data to rc object and Wikia vars
MyHome::storeInRecentChanges($rc);
$data = Wikia::getVar('rc_data');
unset($data['articleComment']);
return $data;
}
示例4: onArticleSaveComplete
/**
* Hook: add premium video and clear cache (editor - source mode)
* @param Article $article
* @param User $user
* @param $text
* @param $summary
* @param $minoredit
* @param $watchthis
* @param $sectionanchor
* @param $flags
* @param $revision
* @param $status
* @param $baseRevId
* @return true
*/
public static function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
{
if (!F::build('VideoInfoHelper', array(), 'videoInfoExists')) {
return true;
}
$insertedImages = Wikia::getVar('imageInserts');
$affected = false;
$userId = $user->getId();
foreach ($insertedImages as $img) {
$videoInfoHelper = F::build('VideoInfoHelper');
$videoData = $videoInfoHelper->getVideoDataByTitle($img['il_to'], true);
if (!empty($videoData)) {
$videoInfo = F::build('VideoInfo', array($videoData));
$affected = $videoInfo->addPremiumVideo($userId);
}
}
// clear cache if premium video is added
if ($affected) {
$mediaService = F::build('MediaQueryService');
$mediaService->clearCacheTotalVideos();
$mediaService->clearCacheTotalPremiumVideos();
}
return true;
}
示例5: watchBlogListing
/**
* saveListingRelation -- hook for ,
*
* @static
* @access public
*
*
* @return bool
*/
public static function watchBlogListing(&$article, &$user, $text, $summary, $minor, $undef1, $undef2, &$flags, $revision, &$status, $baseRevId)
{
if (!$status->value['new']) {
return true;
}
wfProfileIn(__METHOD__);
$dbw = wfGetDB(DB_SLAVE);
if (defined('NS_BLOG_ARTICLE') && $article->getTitle()->getNamespace() == NS_BLOG_ARTICLE) {
$cat = array_keys(Wikia::getVar('categoryInserts'));
$catIn = array();
foreach ($cat as $value) {
$title = Title::makeTitle(NS_CATEGORY, $value);
$catIn[] = $dbw->addQuotes($title->getDBKey());
}
$username = $user->getName();
$con = '';
if (count($catIn) > 0) {
$con .= '(blr_relation in(' . implode(",", $catIn) . ') AND blr_type = "cat" ) OR ';
}
$con .= '(blr_relation = "' . $dbw->addQuotes($username) . '" AND blr_type = "user" ) ';
$res = $dbw->select(array('blog_listing_relation'), array('blr_title'), $con, __METHOD__);
$related = array();
while ($row = $dbw->fetchObject($res)) {
//Bug fix //
$exploded = explode(":", $row->blr_title);
if (count($exploded) > 1) {
$title = $exploded[1];
} else {
$title = $row->blr_title;
}
$title = Title::makeTitle(NS_BLOG_LISTING, $title);
$related[] = ucfirst($title->getDBKey());
}
self::emailNotification($article->getTitle(), $related, NS_BLOG_LISTING, $user, "blogpost", wfMsg('follow-bloglisting-summary'));
}
wfProfileOut(__METHOD__);
return true;
}
示例6: processAllInTrack
private function processAllInTrack()
{
wfProfileIn(__METHOD__);
global $wgContLang;
if ($this->mTitle->isContentPage()) {
// BADGE_EDIT
if (empty($this->mCounters[BADGE_EDIT])) {
$this->mCounters[BADGE_EDIT] = 0;
}
$this->mCounters[BADGE_EDIT]++;
// EDIT+CATEGORY
// get categories article already belongs to
$articleCategories = array_change_key_case($this->mTitle->getParentCategories(), CASE_LOWER);
// get categories to which article is added within this edit
$insertedCategories = array_change_key_case(Wikia::getVar('categoryInserts'), CASE_LOWER);
// get configuration of edit+categories
$editPlusCategory = AchConfig::getInstance()->getInTrackEditPlusCategory();
$cat1 = strtolower($wgContLang->getNSText(NS_CATEGORY));
foreach ($editPlusCategory as $badge_type_id => $badge_config) {
if ($badge_config['enabled']) {
$cat2 = str_replace(' ', '_', strtolower($badge_config['category']));
if (isset($insertedCategories[$cat2]) || isset($articleCategories[$cat1 . ':' . $cat2])) {
if (empty($this->mCounters[$badge_type_id])) {
$this->mCounters[$badge_type_id] = 0;
}
$this->mCounters[$badge_type_id]++;
}
}
}
// BADGE_PICTURE
$insertedImages = Wikia::getVar('imageInserts');
if (!empty($insertedImages) && is_array($insertedImages)) {
if (empty($this->mCounters[BADGE_PICTURE])) {
$this->mCounters[BADGE_PICTURE] = 0;
}
foreach ($insertedImages as $inserted_image) {
if ($inserted_image['il_to'][0] != ':') {
if (wfFindFile($inserted_image['il_to'])) {
//check if the image has been used less than 10 times
//(to avoid awarding after template based bulk insertion)
//calls api.php?action=query&list=imageusage&iulimit=10&iutitle=File:File_mame.ext
$imageUsageCount = 0;
$imageUsageLimit = 10;
$params = array('action' => 'query', 'list' => 'imageusage', 'iutitle' => "File:{$inserted_image['il_to']}", 'iulimit' => $imageUsageLimit);
try {
wfProfileIn(__METHOD__ . '::apiCall');
$api = new ApiMain(new FauxRequest($params));
$api->execute();
$res = $api->getResultData();
wfProfileOut(__METHOD__ . '::apiCall');
if (is_array($res['query']['imageusage'])) {
$imageUsageCount = count($res['query']['imageusage']);
}
} catch (Exception $e) {
}
if ($imageUsageCount < $imageUsageLimit) {
$this->mCounters[BADGE_PICTURE]++;
}
}
}
}
}
// BADGE_CATEGORY
$insertedCategories = Wikia::getVar('categoryInserts');
if (!empty($insertedCategories) && is_array($insertedCategories)) {
if (empty($this->mCounters[BADGE_CATEGORY])) {
$this->mCounters[BADGE_CATEGORY] = 0;
}
$this->mCounters[BADGE_CATEGORY] += count($insertedCategories);
}
}
// BADGE_BLOGPOST
// is defined check if required because blogs are not enabled everywhere
if (defined('NS_BLOG_ARTICLE') && $this->mTitle->getNamespace() == NS_BLOG_ARTICLE) {
if ($this->mTitle->getBaseText() == $this->mUser->getName()) {
if ($this->mStatus->value['new'] == true) {
if (empty($this->mCounters[BADGE_BLOGPOST])) {
$this->mCounters[BADGE_BLOGPOST] = 0;
}
$this->mCounters[BADGE_BLOGPOST]++;
}
}
}
// BADGE_BLOGCOMMENT
// is defined check if required because blogs are not enabled everywhere
if (defined('NS_BLOG_ARTICLE_TALK') && $this->mTitle->getNamespace() == NS_BLOG_ARTICLE_TALK) {
// handle only article/comment creating (not editing)
if ($this->mStatus->value['new'] == true) {
$blogPostTitle = Title::newFromText($this->mTitle->getBaseText(), NS_BLOG_ARTICLE);
if ($blogPostTitle) {
$blogPostArticle = new Article($blogPostTitle);
if (empty($this->mCounters[BADGE_BLOGCOMMENT]) || !in_array($blogPostArticle->getID(), $this->mCounters[BADGE_BLOGCOMMENT])) {
if (empty($this->mCounters[BADGE_BLOGCOMMENT])) {
$this->mCounters[BADGE_BLOGCOMMENT] = array();
}
$this->mCounters[BADGE_BLOGCOMMENT][] = $blogPostArticle->getID();
}
}
}
}
//.........这里部分代码省略.........
示例7: storeAdditionalRcData
/**
* Given an associative array of data to store, adds this to additional data and updates
* the row in recentchanges corresponding to the provided RecentChange (or, if rc is not
* provided, then the RecentChange that is stored in Wikia::getVar('rc') will be used);
*/
public static function storeAdditionalRcData($additionalData, &$rc = null)
{
wfProfileIn(__METHOD__);
$rc_data = Wikia::getVar('rc_data');
$rc_data = $rc_data ? $rc_data : array();
// rc_data might not have been set
$rc_data = array_merge($rc_data, $additionalData);
// additionalData overwrites existing keys in rc_data if there are collisions.
if (!is_object($rc)) {
$rc = Wikia::getVar('rc');
}
if ($rc instanceof RecentChange) {
/* @var $rc RecentChange */
$rc_id = $rc->getAttribute('rc_id');
$rc_log_type = $rc->getAttribute('rc_log_type');
if (!in_array($rc_log_type, self::$additionalRcDataBlacklist)) {
$dbw = wfGetDB(DB_MASTER);
$dbw->update('recentchanges', array('rc_params' => MyHome::packData($rc_data)), array('rc_id' => $rc_id), __METHOD__);
}
}
Wikia::setVar('rc_data', $rc_data);
wfProfileOut(__METHOD__);
}
示例8: onArticleSaveComplete
/**
* @desc Counts actions involve adding or editing articles
*
* @param Article $article
*/
function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
{
// Quick exit if we are already done with Founder Progress Bar (memcache key set for 30 days)
if (self::allTasksComplete()) {
return true;
}
wfProfileIn(__METHOD__);
$app = F::app();
$title = $article->getTitle();
if ($flags & EDIT_NEW) {
// Tasks related to adding new pages X (do not count auto generated user pages or categories or files or ...)
if ($title->getNamespace() == NS_MAIN) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_PAGE_ADD_10));
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_PAGE_ADD_20));
if (self::bonusTaskEnabled(FT_BONUS_PAGE_ADD_5)) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_BONUS_PAGE_ADD_5));
}
}
// if blogpost
if ($app->wg->EnableBlogArticles && $title->getNamespace() == NS_BLOG_ARTICLE) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_BLOGPOST_ADD));
}
// if topten list
if ($app->wg->EnableTopListsExt && $title->getNamespace() == NS_TOPLIST) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_TOPTENLIST_ADD));
}
// edit profile page X
if ($title->getNamespace() == NS_USER && $title->getText() == $app->wg->User->getName()) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_PROFILE_EDIT));
}
}
// Tasks related to updating existing pages
if ($flags & EDIT_UPDATE) {
// Tasks related to editing any article content X
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_TOTAL_EDIT_75));
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_TOTAL_EDIT_300));
if (self::bonusTaskEnabled(FT_BONUS_EDIT_50)) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_BONUS_EDIT_50));
}
// if main page
if ($title->getArticleId() == Title::newMainPage()->getArticleId()) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_MAINPAGE_EDIT));
// Is there a better way to detect if there's a slider on the main page?
if (stripos($text, "slider") > 0) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_MAINPAGE_ADDSLIDER));
}
}
// Add a page to a category: this var is set by the Parser
$categoryInserts = Wikia::getVar('categoryInserts');
if (!empty($categoryInserts)) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_CATEGORY_ADD_3));
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_CATEGORY_ADD_5));
}
// edit category page X
if ($title->getNamespace() == NS_CATEGORY) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_CATEGORY_EDIT));
}
// edit TOP_NAV Wiki-navigation X
if ($title->getNamespace() == NS_MEDIAWIKI && $title->getText() == "Wiki-navigation") {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_TOPNAV_EDIT));
}
// if commcorner X
if ($title->getNamespace() == NS_MEDIAWIKI && $title->getText() == "Community-corner") {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_COMMCORNER_EDIT));
}
// edit profile page X
if ($title->getNamespace() == NS_USER && $title->getText() == $app->wg->User->getName()) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_PROFILE_EDIT));
}
// if page contains gallery tag
if (stripos($text, "<gallery") !== false) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_GALLERY_ADD));
}
// if page contains video tag
if (stripos($text, "<video") !== false || stripos($text, "[[Video:") !== false) {
$app->sendRequest('FounderProgressBar', 'doTask', array('task_id' => FT_VIDEO_ADD));
}
}
wfProfileOut(__METHOD__);
return true;
}