public function emailFollowNotifications($initiatingUser, $aWatchers, $iUserId, $iNamespace, $sMessage, $sAction)
 {
     $wg = F::app()->wg;
     $wg->DBname = WikiFactory::IDtoDB($this->getWikiId());
     $wg->Server = trim(WikiFactory::DBtoUrl(F::app()->wg->DBname), '/');
     if (!empty($wg->DevelEnvironment)) {
         $wg->Server = WikiFactory::getLocalEnvURL($wg->Server);
     }
     $wg->User = User::newFromId($initiatingUser);
     $targetUser = User::newFromId($iUserId);
     $this->logWatchers($aWatchers, $sAction);
     foreach ($aWatchers as $sKey => $sValue) {
         $oTitle = Title::makeTitle($iNamespace, $sKey);
         $oEmailNotification = new EmailNotification($targetUser, $oTitle, wfTimestampNow(), $sMessage, false, $currentRevId = 0, $previousRevId = 0, $sAction, ['notisnull' => 1, 'childTitle' => $this->title]);
         $oEmailNotification->notifyOnPageChange();
     }
 }
 public function getArticleDetails($wikiId, $articleId, $url)
 {
     $domain = WikiFactory::DBtoUrl(WikiFactory::IDtoDB($wikiId));
     //TODO: REFACTOR THE HACK
     if ($domain) {
         $callUrl = sprintf('%sapi/v1/Articles/Details?ids=%u', $domain, $articleId);
         $details = Http::get($callUrl);
         if (empty($details)) {
             $details = file_get_contents($callUrl);
         }
         $data = json_decode($details);
         if ($data) {
             return $data;
         }
         return false;
     }
     return false;
 }
 protected function getContentUrl($wikiId, $articleId)
 {
     return $this->getEpisodeService()->replaceHostUrl(WikiFactory::DBtoUrl(WikiFactory::IDtoDB($wikiId)) . EpisodeEntitySearchService::API_URL . $articleId);
 }
 /**
  * @desc Get url to community wiki
  *
  * @return url
  */
 public function getCommunityUrl()
 {
     return WikiFactory::DBtoUrl($this->getCommunityDbName());
 }
Beispiel #5
0
 protected function getWikiaArticles($episodes)
 {
     global $wgStagingEnvironment, $wgDevelEnvironment;
     $data = [];
     foreach ($episodes as $i => $episode) {
         try {
             $response = $this->sendRequest('TvApiController', 'getEpisode', ['seriesName' => $episode['title'], 'episodeName' => $episode['episode_title'], 'minArticleQuality' => self::MIN_ARTICLE_QUALITY]);
             $item = $response->getData();
             $item['wikia_id'] = $item['wikiId'];
             $item['page_id'] = $item['articleId'];
             $item['series_name'] = $episode['title'];
             $item['episode_name'] = $episode['episode_title'];
             $item['source'] = self::SOURCE_TVRAGE;
             unset($item['wikiId'], $item['articleId']);
             if ($wgStagingEnvironment || $wgDevelEnvironment) {
                 $url = WikiFactory::DBtoUrl(WikiFactory::IDtoDB($item['wikia_id']));
                 if (strpos($item['url'], $url) !== 0) {
                     $item['url'] = preg_replace('~http://[^\\.]+\\.~', 'http://', $item['url']);
                 }
             }
             $data[] = $item;
         } catch (Exception $e) {
             \Wikia\Logger\WikiaLogger::instance()->error(__METHOD__ . " : " . $e->getMessage());
         }
     }
     return $data;
 }
Beispiel #6
0
    public static function run(DatabaseMysql $db, $test = false, $verbose = false, $params)
    {
        $dbname = $params['dbname'];
        // Don't bother getting stats for the video wiki
        if ($dbname == 'video151') {
            return;
        }
        // Get total local videos
        $sql = 'SELECT COUNT(*) as local_count FROM video_info WHERE premium = 0';
        $result = $db->query($sql);
        $local_count = 0;
        while ($row = $db->fetchObject($result)) {
            $local_count = $row->local_count;
        }
        // Get number of matching videos and total number of matches
        $sql = 'SELECT page_id, props
				FROM page_wikia_props
				WHERE propname = ' . WPP_LVS_SUGGEST;
        $result = $db->query($sql);
        $num_matching = 0;
        $total_matches = 0;
        $countedPages = array();
        while ($row = $db->fetchObject($result)) {
            $info = unserialize($row->props);
            $num_matching++;
            $total_matches += count($info);
            $countedPages[$row->page_id] = 1;
        }
        $sql = 'SELECT page_id, props
				FROM page_wikia_props
				WHERE propname = ' . WPP_LVS_STATUS_INFO;
        $result = $db->query($sql);
        /*
         * Constants made available by LicensedVideoSwapHelper
        		const STATUS_KEEP = 1;            // set bit to 1 = kept video
        		const STATUS_SWAP = 2;            // set bit to 1 = swapped video
        		const STATUS_EXACT = 4;           // set bit to 0 = normal swap, 1 = swap with an exact match
        		const STATUS_SWAPPABLE = 8;       // set bit to 1 = video with suggestions
        		const STATUS_NEW = 16;            // set bit to 1 = video with new suggestions
        		const STATUS_FOREVER = 32;        // set bit to 1 = no more matches
        */
        $num_keeps = 0;
        $num_swaps = 0;
        while ($row = $db->fetchObject($result)) {
            $info = unserialize($row->props);
            if ($info['status'] & LicensedVideoSwapHelper::STATUS_KEEP) {
                $num_keeps++;
            } else {
                if ($info['status'] & LicensedVideoSwapHelper::STATUS_SWAP) {
                    $num_swaps++;
                }
            }
            // If this page wasn't counted above as having or more suggestions,
            // count it here.  This can happen if the suggestions get cleared out
            // after the video has been kept/swapped
            if (!array_key_exists($row->page_id, $countedPages)) {
                $num_matching++;
            }
        }
        $url = WikiFactory::DBtoUrl($dbname);
        echo "{$dbname},{$url},{$local_count},{$num_matching},{$total_matches},{$num_keeps},{$num_swaps}\n";
    }
 /**
  * Hook: get wiki link for SpecialGlobalUsage::formatItem()
  * @param array $item
  * @param string $page
  * @param string|false $link
  * @return bool true
  */
 public static function onGlobalUsageFormatItemWikiLink($item, $page, &$link)
 {
     $link = WikiFactory::DBtoUrl($item['wiki']);
     if ($link) {
         $link .= 'wiki/' . $page;
         $link = Xml::element('a', array('href' => $link), str_replace('_', ' ', $page));
     }
     return true;
 }