Exemplo n.º 1
0
 public function storeInProps()
 {
     $pageId = Title::newFromText($this->pageName)->getArticleId();
     wfSetWikiaPageProp(self::WIKI_HERO_IMAGE_PROP_ID, $pageId, $this->imageName);
     wfSetWikiaPageProp(self::WIKI_HERO_DESCRIPTION_ID, $pageId, trim($this->description));
     wfSetWikiaPageProp(self::WIKI_HERO_IMAGE_CROP_POSITION_ID, $pageId, $this->cropPosition);
 }
 /**
  * approve content warning
  * @responseParam string result [ok/error]
  * @responseParam string msg - result message
  */
 public function approveContentWarning()
 {
     if (!$this->wg->User->isLoggedIn()) {
         $this->result = 'error';
         $this->msg = 'Logged in user only.';
         // for debuging
         return;
     }
     $userId = $this->wg->User->getId();
     wfSetWikiaPageProp(WPP_CONTENT_WARNING, $userId, 1);
     // clear cache
     $memKey = $this->getMemKeyContentWarning($userId);
     $this->wg->Memc->delete($memKey);
     $this->result = 'ok';
 }
Exemplo n.º 3
0
<?php

/**
 * @package MediaWiki
 * @addtopackage maintenance
 * @author tomek@wikia
 * @author tor@wikia
 * copy blog data from page_props to page_wikia_props  
 *  
 *
 */
ini_set("include_path", dirname(__FILE__) . "/..");
require_once "commandLine.inc";
if (!empty($wgBlogsInWikiaProps)) {
    echo "Already done";
    exit;
}
$list = BlogArticle::getPropsList();
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select(array("page_props"), array("*"), array("pp_propname" => array_keys($list), "pp_value" => 1, "pp_page in (select page_id from page where page_namespace = " . NS_BLOG_ARTICLE . ") "), __METHOD__);
$dbr = wfGetDB(DB_MASTER);
while ($row = $dbr->fetchObject($res)) {
    wfSetWikiaPageProp($list[$row->pp_propname], $row->pp_page, $row->pp_value);
}
$dbr->commit();
WikiFactory::setVarByName("wgBlogsInWikiaProps", $wgCityId, true);
Exemplo n.º 4
0
 /**
  *  create or edit board, if $board = null then we are creating new one
  */
 protected function createOrEditBoard($board, $titletext, $body, $bot = false)
 {
     wfProfileIn(__METHOD__);
     $id = null;
     if (!empty($board)) {
         $id = $board->getId();
     }
     if (self::LEN_OK !== $this->validateLength($titletext, 'title') || self::LEN_OK !== $this->validateLength($body, 'desc')) {
         wfProfileOut(__METHOD__);
         return false;
     }
     Forum::$allowToEditBoard = true;
     if ($id == null) {
         $title = Title::newFromText($titletext, NS_WIKIA_FORUM_BOARD);
     } else {
         $title = Title::newFromId($id, Title::GAID_FOR_UPDATE);
         $nt = Title::newFromText($titletext, NS_WIKIA_FORUM_BOARD);
         $title->moveTo($nt, true, '', false);
         $title = $nt;
     }
     $article = new Article($title);
     $editPage = new EditPage($article);
     $editPage->edittime = $article->getTimestamp();
     $editPage->textbox1 = $body;
     $result = array();
     $retval = $editPage->internalAttemptSave($result, $bot);
     if ($id == null) {
         $title = Title::newFromText($titletext, NS_WIKIA_FORUM_BOARD);
         if (!empty($title)) {
             wfSetWikiaPageProp(WPP_WALL_ORDER_INDEX, $title->getArticleId(), $title->getArticleId());
         }
     }
     Forum::$allowToEditBoard = false;
     wfProfileOut(__METHOD__);
     return $retval;
 }
 /**
  * Move prop in page_wikia_props table to new article
  * @param integer $type
  * @param integer $oldArticleId
  * @param integer $newArticleId
  */
 public function moveWikiaPageProp($type, $oldArticleId, $newArticleId)
 {
     $prop = wfGetWikiaPageProp($type, $oldArticleId);
     if (!empty($prop)) {
         wfDeleteWikiaPageProp($type, $oldArticleId);
         wfSetWikiaPageProp($type, $newArticleId, $prop);
     }
 }
Exemplo n.º 6
0
 public function execute()
 {
     $this->test = $this->hasOption('test');
     $this->verbose = $this->hasOption('verbose');
     $workingVideos = 0;
     $deletedVideos = 0;
     $privateVideos = 0;
     $otherErrorVideos = 0;
     $log = WikiaLogger::instance();
     // Only write to memcache, no reads. We want to make sure to always talk to each of the provider's API directly.
     // Since each time a request is made to these APIs the response is cached for 1 day, disallow memcache reads
     // so we can be sure to not be pulling stale data.
     F::app()->wg->AllowMemcacheReads = false;
     F::app()->wg->AllowMemcacheWrites = true;
     $this->debug("(debugging output enabled)\n ");
     $allVideos = $this->getVideos();
     foreach ($allVideos as $provider => $videos) {
         $class = ucfirst($provider) . "ApiWrapper";
         foreach ($videos as $video) {
             try {
                 // No need to assign this object to anything, we're just trying to catch exceptions during its creation
                 new $class($video['video_id']);
                 // If an exception isn't thrown by this point, we know the video is still good
                 $this->debug("Found working video: " . $video['video_title']);
                 $workingVideos++;
             } catch (Exception $e) {
                 $removeVideo = true;
                 $loggingParams = ["video_title" => $video["video_title"], "video_id" => $video["video_id"], "error" => $e->getMessage(), "exception" => get_class($e), "status_code" => $e->getStatusCode()];
                 $log->info("Video with error encountered", $loggingParams);
                 if ($e instanceof VideoNotFoundException) {
                     $this->debug("Found deleted video: " . $video['video_title']);
                     $deletedVideos++;
                     $status = self::STATUS_DELETED;
                 } elseif ($e instanceof VideoIsPrivateException) {
                     $this->debug("Found private video: " . $video['video_title']);
                     $privateVideos++;
                     $status = self::STATUS_PRIVATE;
                 } else {
                     $this->debug("Found other video: " . $video['video_title']);
                     $this->debug($e->getMessage());
                     $otherErrorVideos++;
                     $status = self::STATUS_OTHER_ERROR;
                     $removeVideo = false;
                 }
                 if (!$this->test) {
                     wfSetWikiaPageProp(WPP_VIDEO_STATUS, $video['page_id'], $status);
                     if ($removeVideo) {
                         $this->setRemovedValue($video, $removeVideo);
                     }
                 }
             }
         }
     }
     if (!$this->test) {
         $mediaService = new MediaQueryService();
         $mediaService->clearCacheTotalVideos();
         $memcKeyRecent = wfMemcKey('videomodule', 'local_videos', VideosModule::CACHE_VERSION, "recent");
         F::app()->wg->Memc->delete($memcKeyRecent);
     }
     echo "\n========SUMMARY========\n";
     echo "Found {$workingVideos} working videos\n";
     echo "Found {$deletedVideos} deleted videos\n";
     echo "Found {$privateVideos} private videos\n";
     echo "Found {$otherErrorVideos} other videos\n";
 }
Exemplo n.º 7
0
 protected function setInProps($prop, $val = 1)
 {
     wfSetWikiaPageProp($prop, $this->getId(), $val);
     $key = $this->getPropCacheKey();
     $cache = $this->getCache();
     $this->propsCache = $cache->get($key);
     $this->propsCache[$prop] = $val;
     $cache->set($key, $this->propsCache);
     return true;
 }
Exemplo n.º 8
0
 protected function setWikiaProp($propName, $articleId, $value)
 {
     wfSetWikiaPageProp($propName, $articleId, $value);
 }
Exemplo n.º 9
0
 /**
  * save article extra properties to page_props table
  *
  * @access public
  * @static
  *
  * @param array $props array of properties to save (prop name => prop value)
  */
 public static function setProps($page_id, array $props)
 {
     wfProfileIn(__METHOD__);
     $dbw = wfGetDB(DB_MASTER);
     $replace = self::getPropsList();
     foreach ($props as $sPropName => $sPropValue) {
         wfSetWikiaPageProp($replace[$sPropName], $page_id, $sPropValue);
     }
     $dbw->commit();
     #--- for ajax
     wfProfileOut(__METHOD__);
 }