public function executeIndex() {
		OasisController::addBodyClass('wikinav2');

		$themeSettings = new ThemeSettings();
		$settings = $themeSettings->getSettings();

		$this->wordmarkText = $settings["wordmark-text"];
		$this->wordmarkType = $settings["wordmark-type"];
		$this->wordmarkSize = $settings["wordmark-font-size"];
		$this->wordmarkFont = $settings["wordmark-font"];

		if ($this->wordmarkType == "graphic") {
			wfProfileIn(__METHOD__ . 'graphicWordmarkV2');
			$this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());
			$imageTitle = Title::newFromText($themeSettings::WordmarkImageName,NS_IMAGE);
			if($imageTitle instanceof Title) {
				$attributes = array();
				$file = wfFindFile($imageTitle);
				if($file instanceof File) {
					$attributes []= 'width="' . $file->width . '"';
					$attributes []= 'height="' . $file->height. '"';
			
					if(!empty($attributes)) {
						$this->wordmarkStyle = ' ' . implode(' ',$attributes) . ' ';
					}
				}
			}
			wfProfileOut(__METHOD__. 'graphicWordmarkV2');
		}

		$this->mainPageURL = Title::newMainPage()->getLocalURL();
		
		$this->displaySearch = !empty($this->wg->EnableAdminDashboardExt) && AdminDashboardLogic::displayAdminDashboard($this, $this->wg->Title);
	}
	public function executeWordmark() {
		$themeSettings = new ThemeSettings();
		$settings = $themeSettings->getSettings();

		$this->wordmarkText = $settings['wordmark-text'];
		$this->wordmarkType = $settings['wordmark-type'];
		$this->wordmarkSize = $settings['wordmark-font-size'];
		$this->wordmarkFont = $settings['wordmark-font'];
		$this->wordmarkFontClass = !empty($settings["wordmark-font"]) ? "font-{$settings['wordmark-font']}" : '';
		$this->wordmarkUrl = '';
		if ($this->wordmarkType == "graphic") {
			wfProfileIn(__METHOD__ . 'graphicWordmark');
			$this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());			
			$imageTitle = Title::newFromText($themeSettings::WordmarkImageName,NS_IMAGE);
			if($imageTitle instanceof Title) {
				$attributes = array();
				$file = wfFindFile($imageTitle);
				if($file instanceof File) {
					$attributes []= 'width="' . $file->width . '"';
					$attributes []= 'height="' . $file->height. '"';
	
					if(!empty($attributes)) {
						$this->wordmarkStyle = ' ' . implode(' ',$attributes) . ' ';
					}
				}
			}
			wfProfileOut(__METHOD__. 'graphicWordmark');
		}

		$this->mainPageURL = Title::newMainPage()->getLocalURL();
	}
예제 #3
0
 public function addWikiaVars(&$obj, BaseTemplate &$tpl)
 {
     global $wgUser;
     wfProfileIn(__METHOD__);
     // ads
     $this->setupAds($tpl);
     // setup footer links
     $tpl->set('footerlinks', wfMsgExt('Shared-Monobook-footer-wikia-links', 'parse'));
     # rt33045
     $tpl->set('contact', '<a href="' . $wgUser->getSkin()->makeUrl('Special:Contact') . '" title="Contact Wikia">Contact Wikia</a>');
     # BAC-1036, CE-278
     /* Replace Wikia logo path
     		   This functionality is for finding proper path of Wiki.png instead of const one from wgLogo
     		   wikia logo should be stored under File:Wiki.png on current wikia. If wfFindFile doesn't find it
     		   on current wikia it tires to fallback to starter.wikia.com where the default one is stored
     		*/
     $logoPage = Title::newFromText('Wiki.png', NS_FILE);
     $logoFile = wfFindFile($logoPage);
     if ($logoFile) {
         $tpl->set('logopath', $logoFile->getUrl());
     } else {
         $tpl->set('logopath', wfReplaceImageServer($tpl->data['logopath']));
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 public static function getBadge($badgeTypeId)
 {
     wfProfileIn(__METHOD__);
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('ach_custom_badges', array('id', 'enabled', 'sponsored', 'badge_tracking_url', 'hover_tracking_url', 'click_tracking_url'), array('id' => $badgeTypeId), __METHOD__);
     if ($row = $dbr->fetchObject($res)) {
         $badge = array();
         $image = wfFindFile(AchConfig::getInstance()->getBadgePictureName($row->id));
         if ($image) {
             $hoverImage = wfFindFile(AchConfig::getInstance()->getHoverPictureName($row->id));
             $badge['type_id'] = $row->id;
             $badge['enabled'] = $row->enabled;
             $badge['thumb_url'] = $image->createThumb(90);
             $badge['awarded_users'] = AchPlatinumService::getAwardedUserNames($row->id);
             $badge['is_sponsored'] = $row->sponsored;
             $badge['badge_tracking_url'] = $row->badge_tracking_url;
             $badge['hover_tracking_url'] = $row->hover_tracking_url;
             $badge['click_tracking_url'] = $row->click_tracking_url;
             $badge['hover_content_url'] = is_object($hoverImage) ? wfReplaceImageServer($hoverImage->getFullUrl()) : null;
             wfProfileOut(__METHOD__);
             return $badge;
         }
     }
     wfProfileOut(__METHOD__);
     return false;
 }
예제 #5
0
function wfMakeSignatureCommon($href, $title, $iurl = null)
{
    global $wgBlankImgUrl;
    if (empty($iurl)) {
        $iurl = wfReplaceImageServer('/extensions/wikia/StaffSig/images/WikiaStaff.png');
    }
    return '<a href="' . $href . '" title="' . $title . '" class="staffSigLink"><img src="' . $wgBlankImgUrl . '" style="background-image: url(\'' . $iurl . '\')" alt="@Wikia" class="staffSig" width="41" height="12" /></a>';
}
function egOgmcParserOutputApplyValues($out, $parserOutput, $data)
{
    global $wgTitle;
    $articleId = $wgTitle->getArticleID();
    $titleImage = $titleDescription = null;
    wfRunHooks('OpenGraphMeta:beforeCustomFields', array($articleId, &$titleImage, &$titleDescription));
    // Only use ImageServing if no main image is already specified.  This lets people override the image with the parser function: [[File:{{#setmainimage:Whatever.png}}]].
    if (!isset($out->mMainImage)) {
        if (is_null($titleImage)) {
            // Get image from ImageServing
            // TODO: Make sure we automatically respect these restrictions from Facebook:
            // 		"An image URL which should represent your object within the graph.
            //		The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1.
            //		We support PNG, JPEG and GIF formats."
            $imageServing = F::build('ImageServing', array($articleId));
            foreach ($imageServing->getImages(1) as $key => $value) {
                $titleImage = Title::newFromText($value[0]['name'], NS_FILE);
            }
        }
        // If ImageServing was not able to deliver a good match, fall back to the wiki's wordmark.
        if (empty($titleImage) && !is_object($titleImage) && F::app()->checkSkin('oasis')) {
            $themeSettings = new ThemeSettings();
            $settings = $themeSettings->getSettings();
            if ($settings["wordmark-type"] == "graphic") {
                $titleImage = Title::newFromText($settings['wordmark-image-name'], NS_FILE);
            }
        }
        // If we have a Title object for an image, convert it to an Image object and store it in mMainImage.
        if (!empty($titleImage) && is_object($titleImage)) {
            $mainImage = wfFindFile($titleImage);
            if ($mainImage !== false) {
                $parserOutput->setProperty('mainImage', $mainImage);
                $out->mMainImage = $parserOutput->getProperty('mainImage');
            }
        } else {
            // Fall back to using a Wikia logo.  There aren't any as "File:" pages, so we use a new config var for one that
            // is being added to skins/common.
            global $wgBigWikiaLogo;
            $logoUrl = wfReplaceImageServer($wgBigWikiaLogo);
            $parserOutput->setProperty('mainImage', $logoUrl);
            $out->mMainImage = $parserOutput->getProperty('mainImage');
        }
    }
    // Get description from ArticleService
    if (is_null($titleDescription)) {
        $DESC_LENGTH = 100;
        $articleService = new ArticleService($articleId);
        $titleDescription = $articleService->getTextSnippet($DESC_LENGTH);
    }
    if (!empty($titleDescription)) {
        $parserOutput->setProperty('description', $titleDescription);
        $out->mDescription = $parserOutput->getProperty('description');
    }
    if ($page_id = Wikia::getFacebookDomainId()) {
        $out->addMeta('property:fb:page_id', $page_id);
    }
}
예제 #7
0
 /**
  * @dataProvider devboxDataProvider
  */
 public function testForDevbox($url, $timestamp, $expected)
 {
     $devImageServer = 'images.hakarl.wikia-dev.com';
     $this->mockGlobalVariable('wgDevBoxImageServerOverride', $devImageServer);
     // test logic for the old thumbnailer
     $this->mockGlobalVariable('wgEnableVignette', false);
     $testURL = wfReplaceImageServer($url, $timestamp);
     $this->assertEquals($expected, $testURL, 'URL returned by wfReplaceImageServer should match expected one');
     // test logic for the Vignette
     $this->mockGlobalVariable('wgEnableVignette', true);
     $testURL = wfReplaceImageServer($url, $timestamp);
     $this->assertEquals(0, preg_match('/images\\.hakarl\\.wikia-dev\\.com/', $testURL), 'URL returned by wfReplaceImageServer be the original with wgEnableVignette = true');
 }
 public function index()
 {
     /**
      * @var $themeSettings ThemeSettings
      */
     $themeSettings = F::build('ThemeSettings');
     $settings = $themeSettings->getSettings();
     $this->response->setVal('wordmarkText', $settings["wordmark-text"]);
     $this->response->setVal('wordmarkType', $settings["wordmark-type"]);
     $this->response->setVal('wordmarkFont', $settings["wordmark-font"]);
     if ($settings["wordmark-type"] == "graphic") {
         $this->response->setVal('wordmarkUrl', wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster()));
     } else {
         $this->response->setVal('wikiName', !empty($settings['wordmark-text']) ? $settings['wordmark-text'] : $this->wg->SiteName);
     }
     //$this->response->setVal( 'searchOpen', ($this->wg->Title->getText() == SpecialPage::getTitleFor( 'Search' )->getText() ) );
 }
예제 #9
0
 private function downloadWordmark()
 {
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $wordmark = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());
     $folder_path = $this->wikiName;
     if (!is_dir($folder_path)) {
         mkdir($folder_path, 0700);
     }
     $file_path = $folder_path . '/wordmark.png';
     if (file_exists($file_path)) {
         system("rm " . $file_path);
     }
     file_put_contents($file_path, Http::get($wordmark));
     if (file_get_contents($file_path) == '') {
         system("rm " . $file_path);
         system("cp default_wordmark.png " . $file_path);
     }
 }
예제 #10
0
 /**
  * See functions below for expected URL params
  */
 public function execute()
 {
     global $wgRequest, $wgCacheBuster;
     wfProfileIn(__METHOD__);
     extract($this->extractRequestParams());
     // Allow optionally using a prefixed-title instead of the page_id.
     if (empty($Id)) {
         $title = Title::newFromText($Title);
         if (is_object($title)) {
             $Id = $title->getArticleID();
         }
     }
     $article = Article::newFromID($Id);
     if (is_object($article)) {
         // Automatically follow redirects.
         if ($article->isRedirect()) {
             $title = $article->followRedirect();
             if (is_object($title)) {
                 // if this is not an object, then we're pretty unlikely to get any good image matches, but more likely to get them for the original ID.
                 $Id = $title->getArticleID();
             }
         }
         $imageUrl = null;
         $imageServing = new ImageServing(array($Id));
         foreach ($imageServing->getImages(1) as $key => $value) {
             $imgTitle = Title::newFromText($value[0]['name'], NS_FILE);
             $imgFile = wfFindFile($imgTitle);
             if (!empty($imgFile)) {
                 $imageUrl = wfReplaceImageServer($imgFile->getFullUrl(), $wgCacheBuster);
             }
         }
         $result = $this->getResult();
         if (empty($imageUrl)) {
             $result->addValue('image', "error", "No good, representiative image was found for this page.");
             // TODO: i18n
         } else {
             $result->addValue('image', $this->getModuleName(), $imageUrl);
         }
     }
     wfProfileOut(__METHOD__);
 }
 public function executePlayQuiz($params)
 {
     global $wgUser, $wgOut, $wgRequest, $wgSiteName;
     $this->data = $params['data'];
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $this->wordmarkType = $settings['wordmark-type'];
     $this->wordmarkText = $settings['wordmark-text'];
     if ($this->wordmarkType == 'graphic') {
         $this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());
     }
     // Facebook opengraph meta data
     $wgOut->addMeta('property:og:title', $this->data['titlescreentext']);
     $wgOut->addMeta('property:og:type', 'game');
     $wgOut->addMeta('property:og:url', $wgRequest->getFullRequestURL());
     $wgOut->addMeta('property:og:site_name', $wgSiteName);
     // mech: simply stripping the tags wont work, as some tags have to be replaced with a space
     $descrition = $this->data['fbrecommendationtext'];
     if (!$descrition) {
         /* mech: fbrecommendationtext field was intoduced while fixing bug 14843.
          * For older quizes the FB recommendation description defaults to titlescreentext
          */
         $descrition = str_replace('<', ' <', $this->data['titlescreentext']);
         // introduce an extra space at in front of tags
         $descrition = strip_tags($descrition);
         $descrition = preg_replace('/\\s\\s+/u', ' ', $descrition);
         // eliminate extraneous whitespaces
     }
     $wgOut->addMeta('property:og:description', $descrition);
     $wgOut->addMeta('property:og:image', $this->wordmarkUrl);
     $this->username = $wgUser->getName();
     $this->isAnonUser = $wgUser->isAnon();
     // render this array in PHP and encode it properly for JS
     $this->quizVars = array('cadence' => array(wfMsg('wikiaquiz-game-cadence-3'), wfMsg('wikiaquiz-game-cadence-2'), wfMsg('wikiaquiz-game-cadence-1')), 'correctLabel' => wfMsg('wikiaquiz-game-correct-label'), 'incorrectLabel' => wfMsg('wikiaquiz-game-incorrect-label'));
     // prefill with user's email
     $this->defaultEmail = $wgUser->isLoggedIn() ? $wgUser->getEmail() : '';
     // use token to prevent direct requests to the backend for storing emails
     $this->token = $wgUser->getEditToken('WikiaQuiz');
 }
예제 #12
0
 /**
  * Gets theme settings from following places:
  *  - theme designer ($wgOasisThemeSettings)
  *  - theme chosen using usetheme URL param
  */
 public static function getOasisSettings()
 {
     global $wgOasisThemes, $wgContLang;
     wfProfileIn(__METHOD__);
     // Load the 5 deafult colors by theme here (eg: in case the wiki has an override but the user doesn't have overrides).
     static $oasisSettings = array();
     if (empty($oasisSettings)) {
         $themeSettings = new ThemeSettings();
         $settings = $themeSettings->getSettings();
         $oasisSettings["color-body"] = self::sanitizeColor($settings["color-body"]);
         $oasisSettings["color-page"] = self::sanitizeColor($settings["color-page"]);
         $oasisSettings["color-buttons"] = self::sanitizeColor($settings["color-buttons"]);
         $oasisSettings["color-links"] = self::sanitizeColor($settings["color-links"]);
         $oasisSettings["color-header"] = self::sanitizeColor($settings["color-header"]);
         $oasisSettings["background-image"] = wfReplaceImageServer($settings['background-image'], self::getCacheBuster());
         $oasisSettings["background-align"] = $settings["background-align"];
         $oasisSettings["background-tiled"] = $settings["background-tiled"];
         $oasisSettings["background-fixed"] = $settings["background-fixed"];
         $oasisSettings["page-opacity"] = $settings["page-opacity"];
         if (isset($settings["wordmark-font"]) && $settings["wordmark-font"] != "default") {
             $oasisSettings["wordmark-font"] = $settings["wordmark-font"];
         }
         // RTL
         if ($wgContLang && $wgContLang->isRTL()) {
             $oasisSettings['rtl'] = 'true';
         }
     }
     // RT:70673
     foreach ($oasisSettings as $key => $val) {
         if (!empty($val)) {
             $oasisSettings[$key] = trim($val);
         }
     }
     wfDebug(__METHOD__ . ': ' . json_encode($oasisSettings) . "\n");
     wfProfileOut(__METHOD__);
     return $oasisSettings;
 }
예제 #13
0
 /**
  * Return a URL that displays $file shrunk to have the closest dimension meet $box.  Images smaller than the
  * bounding box will not be affected.  The part of the image that extends beyond the $box dimensions will be
  * cropped out.  The result is an image that completely fills the box with no empty space, but is cropped.
  *
  * @param File $file
  * @param array $box
  *
  * @return String
  */
 private function cropURL(File $file, array $box)
 {
     global $wgEnableVignette;
     if ($wgEnableVignette) {
         $cropUrl = $file->getUrlGenerator()->zoomCropDown()->width($box['w'])->height($box['h'])->url();
     } else {
         list($adjWidth, $adjHeight) = $this->fitClosest($file, $box);
         $height = $file->getHeight();
         $width = $file->getWidth();
         if ($adjHeight == $box['h']) {
             $width = $box['w'] * ($file->getHeight() / $box['h']);
         }
         if ($adjWidth == $box['w']) {
             $height = $box['h'] * ($file->getWidth() / $box['w']);
         }
         $cropStr = sprintf("%dpx-0,%d,0,%d", $adjWidth, $width, $height);
         $append = '';
         $mime = strtolower($file->getMimeType());
         if ($mime == 'image/svg+xml' || $mime == 'image/svg') {
             $append = '.png';
         }
         $cropUrl = wfReplaceImageServer($file->getThumbUrl($cropStr . '-' . $file->getName() . $append));
     }
     return $cropUrl;
 }
예제 #14
0
 public function getWikiWordmark($wikiId)
 {
     $url = '';
     $history = WikiFactory::getVarByName('wgOasisThemeSettingsHistory', $wikiId);
     $settings = unserialize($history->cv_value);
     if ($settings !== false) {
         $currentSettings = end($settings);
         if (isset($currentSettings['settings']['wordmark-type']) && $currentSettings['settings']['wordmark-type'] == 'text') {
             return '';
         }
         if (isset($currentSettings['settings']) && !empty($currentSettings['settings']['wordmark-image-url'])) {
             $url = wfReplaceImageServer($currentSettings['settings']['wordmark-image-url'], $currentSettings['timestamp']);
         }
     }
     return $url;
 }
예제 #15
0
파일: Timeline.php 프로젝트: yusufchang/app
/**
 * @param $timelinesrc string
 * @return string
 */
function wfRenderTimeline($timelinesrc)
{
    global $wgUploadDirectory, $wgUploadPath, $wgArticlePath, $wgTmpDirectory, $wgRenderHashAppend;
    global $wgTimelineSettings;
    // Get the backend to store plot data and pngs
    if ($wgTimelineSettings->fileBackend != '') {
        $backend = FileBackendGroup::singleton()->get($wgTimelineSettings->fileBackend);
    } else {
        $backend = new FSFileBackend(array('name' => 'timeline-backend', 'lockManager' => 'nullLockManager', 'containerPaths' => array('timeline-render' => "{$wgUploadDirectory}/timeline"), 'fileMode' => 777));
    }
    // Get a hash of the plot data
    $hash = md5($timelinesrc);
    if ($wgRenderHashAppend != '') {
        $hash = md5($hash . $wgRenderHashAppend);
    }
    // Storage destination path (excluding file extension)
    $fname = 'mwstore://' . $backend->getName() . "/timeline-render/{$hash}";
    // Wikia change - begin
    wfRunHooks('BeforeRenderTimeline', [&$backend, &$fname, $hash]);
    // Wikia change - end
    $previouslyFailed = $backend->fileExists(array('src' => "{$fname}.err"));
    $previouslyRendered = $backend->fileExists(array('src' => "{$fname}.png"));
    if ($previouslyRendered) {
        $timestamp = $backend->getFileTimestamp(array('src' => "{$fname}.png"));
        $expired = $timestamp < $wgTimelineSettings->epochTimestamp;
    } else {
        $expired = false;
    }
    // Create a new .map, .png (or .gif), and .err file as needed...
    if ($expired || !$previouslyRendered && !$previouslyFailed) {
        if (!is_dir($wgTmpDirectory)) {
            mkdir($wgTmpDirectory, 0777);
        }
        $tmpFile = TempFSFile::factory('timeline_');
        if ($tmpFile) {
            $tmpPath = $tmpFile->getPath();
            file_put_contents($tmpPath, $timelinesrc);
            // store plot data to file
            // Get command for ploticus to read the user input and output an error,
            // map, and rendering (png or gif) file under the same dir as the temp file.
            $cmdline = wfEscapeShellArg($wgTimelineSettings->perlCommand, $wgTimelineSettings->timelineFile) . " -i " . wfEscapeShellArg($tmpPath) . " -m -P " . wfEscapeShellArg($wgTimelineSettings->ploticusCommand) . " -T " . wfEscapeShellArg($wgTmpDirectory) . " -A " . wfEscapeShellArg($wgArticlePath) . " -f " . wfEscapeShellArg($wgTimelineSettings->fontFile);
            // Actually run the command...
            wfDebug("Timeline cmd: {$cmdline}\n");
            $retVal = null;
            $ret = wfShellExec($cmdline, $retVal);
            // Copy the output files into storage...
            // @TODO: store error files in another container or not at all?
            $opt = array('force' => 1, 'nonLocking' => 1, 'allowStale' => 1);
            // performance
            $backend->prepare(array('dir' => dirname($fname)));
            $backend->store(array('src' => "{$tmpPath}.map", 'dst' => "{$fname}.map"), $opt);
            $backend->store(array('src' => "{$tmpPath}.png", 'dst' => "{$fname}.png"), $opt);
            $backend->store(array('src' => "{$tmpPath}.err", 'dst' => "{$fname}.err"), $opt);
        } else {
            return "<div id=\"toc\" dir=\"ltr\"><tt>Timeline error. " . "Could not create temp file</tt></div>";
            // ugh
        }
        if ($ret == "" || $retVal > 0) {
            // Message not localized, only relevant during install
            return "<div id=\"toc\" dir=\"ltr\"><tt>Timeline error. " . "Command line was: " . htmlspecialchars($cmdline) . "</tt></div>";
        }
    }
    // Wikia change - begin
    if ($backend->fileExists(array('src' => "{$fname}.err", 'latest' => true))) {
        $err = $backend->getFileContents(array('src' => "{$fname}.err"));
    } else {
        $err = '';
    }
    // Wikia change - end
    if ($err != "") {
        // Convert the error from poorly-sanitized HTML to plain text
        $err = strtr($err, array('</p><p>' => "\n\n", '<p>' => '', '</p>' => '', '<b>' => '', '</b>' => '', '<br>' => "\n"));
        $err = Sanitizer::decodeCharReferences($err);
        // Now convert back to HTML again
        $encErr = nl2br(htmlspecialchars($err));
        $txt = "<div id=\"toc\" dir=\"ltr\"><tt>{$encErr}</tt></div>";
    } else {
        // Wikia change - begin
        if ($backend->fileExists(array('src' => "{$fname}.map", 'latest' => true))) {
            $map = $backend->getFileContents(array('src' => "{$fname}.map"));
        } else {
            $map = '';
        }
        // Wikia change - end
        $map = str_replace(' >', ' />', $map);
        $map = "<map name=\"timeline_" . htmlspecialchars($hash) . "\">{$map}</map>";
        $map = easyTimelineFixMap($map);
        $url = "{$wgUploadPath}/timeline/{$hash}.png";
        // Wikia change - begin
        $url = wfReplaceImageServer($url);
        // Wikia change - end
        $txt = $map . "<img usemap=\"#timeline_" . htmlspecialchars($hash) . "\" " . "src=\"" . htmlspecialchars($url) . "\">";
        if ($expired) {
            // Replacing an older file, we may need to purge the old one.
            global $wgUseSquid;
            if ($wgUseSquid) {
                $u = new SquidUpdate(array($url));
                $u->doUpdate();
            }
        }
    }
    return $txt;
}
예제 #16
0
 /**
  * Get a thumbnail object from a file and parameters.
  * If $path is set to null, the output file is treated as a source copy.
  * If $path is set to false, no output file will be created.
  *
  * @param File $file File object
  * @param string $url URL path to the thumb
  * @param int $width File's width
  * @param int $height File's height
  * @param string|bool|null $path Filesystem path to the thumb
  * @param int|bool $page Page number, for multi-page files
  */
 function __construct($file, $url, $width, $height, $path = false, $page = false)
 {
     $this->file = $file;
     $this->url = $url;
     # start wikia change
     $timestamp = !empty($file) ? $file->getTimestamp() : false;
     $this->url = wfReplaceImageServer($this->url, $timestamp);
     # end wikia change
     # These should be integers when they get here.
     # If not, there's a bug somewhere.  But let's at
     # least produce valid HTML code regardless.
     $this->width = round($width);
     $this->height = round($height);
     $this->path = $path;
     $this->page = $page;
 }
 /**
  * Returns image from page.
  * @param $mPageId int page id
  * @return string - image url
  */
 protected function getImageFromPageId($mPageId)
 {
     if (!is_array($mPageId)) {
         $mPageId = array($mPageId);
     }
     $imageServing = new ImageServing($mPageId, $this->thumbWidth, array("w" => $this->thumbWidth, "h" => $this->thumbHeight));
     $imageUrl = '';
     foreach ($imageServing->getImages(1) as $value) {
         if (!empty($value[0]['name'])) {
             $tmpTitle = Title::newFromText($value[0]['name'], NS_FILE);
             $image = wfFindFile($tmpTitle);
             if (empty($image)) {
                 return '';
             }
             $imageUrl = wfReplaceImageServer($image->getThumbUrl($imageServing->getCut($image->getWidth(), $image->getHeight()) . "-" . $image->getName()));
         }
     }
     return $imageUrl;
 }
예제 #18
0
 /**
  * parser hook for <Cube file=f size=i input={mouse,keyboard}> tag
  * @return string tag body
  */
 static function parseInput($input)
 {
     $pics_urls = array(7);
     $i = 0;
     if (strpos($input, "\n") == 0) {
         $input = substr($input, strpos($input, "\n") + 1);
     }
     while (strpos($input, "\n") > -1) {
         //echo trim(substr($input,0,strpos($input,"\n")));
         $title = Title::newFromText(trim(substr($input, 0, strpos($input, "\n"))), NS_FILE);
         $imageFile = wfFindFile($title);
         $pics_urls[$i + 1] = wfReplaceImageServer($imageFile->getFullUrl());
         $input = substr($input, strpos($input, "\n") + 1);
         $i++;
     }
     //echo"i=$i";
     //print_r($pics_urls);
     $pics = "var pics_names=[";
     switch ($i) {
         case 0:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'" . $wgExtensionsPath . "/wikia/WebGL/images/{$i}.png'";
             }
             break;
         case 1:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'http://aurbanski.wikia-dev.com/wikia.php?controller=Cube&method=getData&format=html&url=" . $pics_urls[1] . "'";
             }
             break;
         case 2:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'http://aurbanski.wikia-dev.com/wikia.php?controller=Cube&method=getData&format=html&url=";
                 switch ($i) {
                     case 1:
                         $pics .= $pics_urls[1];
                         break;
                     case 2:
                         $pics .= $pics_urls[1];
                         break;
                     case 3:
                         $pics .= $pics_urls[2];
                         break;
                     case 4:
                         $pics .= $pics_urls[2];
                         break;
                     case 5:
                         $pics .= $pics_urls[2];
                         break;
                     case 6:
                         $pics .= $pics_urls[2];
                         break;
                 }
                 $pics .= "'";
             }
             break;
         case 3:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'http://aurbanski.wikia-dev.com/wikia.php?controller=Cube&method=getData&format=html&url=";
                 switch ($i) {
                     case 1:
                         $pics .= $pics_urls[1];
                         break;
                     case 2:
                         $pics .= $pics_urls[2];
                         break;
                     case 3:
                         $pics .= $pics_urls[3];
                         break;
                     case 4:
                         $pics .= $pics_urls[3];
                         break;
                     case 5:
                         $pics .= $pics_urls[3];
                         break;
                     case 6:
                         $pics .= $pics_urls[3];
                         break;
                 }
                 $pics .= "'";
             }
             break;
         case 4:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'http://aurbanski.wikia-dev.com/wikia.php?controller=Cube&method=getData&format=html&url=";
                 switch ($i) {
                     case 1:
                         $pics .= $pics_urls[1];
                         break;
                     case 2:
                         $pics .= $pics_urls[2];
                         break;
                     case 3:
                         $pics .= $pics_urls[4];
                         break;
                     case 4:
                         $pics .= $pics_urls[4];
                         break;
                     case 5:
                         $pics .= $pics_urls[4];
                         break;
                     case 6:
                         $pics .= $pics_urls[3];
                         break;
                 }
                 $pics .= "'";
             }
             break;
         case 5:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'http://aurbanski.wikia-dev.com/wikia.php?controller=Cube&method=getData&format=html&url=";
                 switch ($i) {
                     case 1:
                         $pics .= $pics_urls[1];
                         break;
                     case 2:
                         $pics .= $pics_urls[1];
                         break;
                     case 3:
                         $pics .= $pics_urls[3];
                         break;
                     case 4:
                         $pics .= $pics_urls[4];
                         break;
                     case 5:
                         $pics .= $pics_urls[2];
                         break;
                     case 6:
                         $pics .= $pics_urls[5];
                         break;
                 }
                 $pics .= "'";
             }
             break;
         case 6:
             for ($i = 1; $i < 7; $i++) {
                 if ($i > 1) {
                     $pics .= ",";
                 }
                 $pics .= "'http://aurbanski.wikia-dev.com/wikia.php?controller=Cube&method=getData&format=html&url=";
                 $pics .= $pics_urls[$i];
                 $pics .= "'";
             }
             break;
     }
     $pics .= "];";
     //echo$pics;
     return $pics;
 }
예제 #19
0
 /**
  * Create a direct link to a given uploaded file.
  * This will make a broken link if $file is false.
  *
  * @param $title Title object.
  * @param $file File|false mixed File object or false
  * @param $html String: pre-sanitized HTML
  * @return String: HTML
  *
  * @todo Handle invalid or missing images better.
  */
 public static function makeMediaLinkFile(Title $title, $file, $html = '')
 {
     $nofollow = '';
     #wikia addition;
     if ($file && $file->exists()) {
         $url = wfReplaceImageServer($file->getURL(), $file->getTimestamp());
         $class = 'internal';
     } else {
         $url = self::getUploadUrl($title);
         $class = 'new';
         global $wgWikiaUseNoFollow;
         if (!empty($wgWikiaUseNoFollow)) {
             $nofollow = ' rel="nofollow"';
         }
     }
     $alt = htmlspecialchars($title->getText(), ENT_QUOTES);
     if ($html == '') {
         $html = $alt;
     }
     $u = htmlspecialchars($url);
     return "<a href=\"{$u}\" class=\"{$class}\" title=\"{$alt}\"{$nofollow}>{$html}</a>";
 }
예제 #20
0
 public static function getUrlIMG($imgName)
 {
     $imgFile = wfFindFile($imgName);
     //find file
     if ($imgFile) {
         $urlIMG = wfReplaceImageServer($imgFile->getUrl());
     } else {
         // if not set default img
         $imgFile = wfFindFile('iOtherIcon.png');
         $urlIMG = wfReplaceImageServer($imgFile->getUrl());
     }
     return $urlIMG;
 }
예제 #21
0
 /**
  * @param $unused Unused
  * @param $addContentType bool
  *
  * @return string HTML tag links to be put in the header.
  */
 public function getHeadLinks($unused = null, $addContentType = false)
 {
     global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgRightsPage, $wgRightsUrl;
     $tags = array();
     if ($addContentType) {
         if ($wgHtml5) {
             # More succinct than <meta http-equiv=Content-Type>, has the
             # same effect
             $tags[] = Html::element('meta', array('charset' => 'UTF-8'));
         } else {
             $tags[] = Html::element('meta', array('http-equiv' => 'Content-Type', 'content' => "{$wgMimeType}; charset=UTF-8"));
             $tags[] = Html::element('meta', array('http-equiv' => 'Content-Style-Type', 'content' => 'text/css'));
         }
     }
     $tags[] = Html::element('meta', array('name' => 'generator', 'content' => "MediaWiki {$wgVersion}"));
     $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
     if ($p !== 'index,follow') {
         // http://www.robotstxt.org/wc/meta-user.html
         // Only show if it's different from the default robots policy
         $tags[] = Html::element('meta', array('name' => 'robots', 'content' => $p));
     }
     if (count($this->mKeywords) > 0) {
         $strip = array("/<.*?" . ">/" => '', "/_/" => ' ');
         $tags[] = Html::element('meta', array('name' => 'keywords', 'content' => preg_replace(array_keys($strip), array_values($strip), implode(',', $this->mKeywords))));
     }
     foreach ($this->mMetatags as $tag) {
         if (0 == strcasecmp('http:', substr($tag[0], 0, 5))) {
             $a = 'http-equiv';
             $tag[0] = substr($tag[0], 5);
         } elseif (0 == strcasecmp('property:', substr($tag[0], 0, 9))) {
             $a = 'property';
             $tag[0] = substr($tag[0], 9);
         } else {
             $a = 'name';
         }
         $tags[] = Html::element('meta', array($a => $tag[0], 'content' => $tag[1]));
     }
     foreach ($this->mLinktags as $tag) {
         $tags[] = Html::element('link', $tag);
     }
     # Universal edit button
     if ($wgUniversalEditButton && $this->isArticleRelated()) {
         $user = $this->getUser();
         if ($this->getTitle()->quickUserCan('edit', $user) && ($this->getTitle()->exists() || $this->getTitle()->quickUserCan('create', $user))) {
             // Original UniversalEditButton
             $msg = $this->msg('edit')->text();
             $tags[] = Html::element('link', array('rel' => 'alternate', 'type' => 'application/x-wiki', 'title' => $msg, 'href' => $this->getTitle()->getLocalURL('action=edit')));
             // Alternate edit link
             $tags[] = Html::element('link', array('rel' => 'edit', 'title' => $msg, 'href' => $this->getTitle()->getLocalURL('action=edit')));
         }
     }
     # Generally the order of the favicon and apple-touch-icon links
     # should not matter, but Konqueror (3.5.9 at least) incorrectly
     # uses whichever one appears later in the HTML source. Make sure
     # apple-touch-icon is specified first to avoid this.
     if ($wgAppleTouchIcon !== false) {
         $tags[] = Html::element('link', array('rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon));
     }
     if ($wgFavicon !== false) {
         // Wikia change begin - @author: hyun
         $wgFavicon = wfReplaceImageServer($wgFavicon);
         // Wikia change end
         $tags[] = Html::element('link', array('rel' => 'shortcut icon', 'href' => $wgFavicon));
     }
     # OpenSearch description link
     $tags[] = Html::element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => wfScript('opensearch_desc'), 'title' => $this->msg('opensearch-desc')->inContentLanguage()->text()));
     if ($wgEnableAPI) {
         # Real Simple Discovery link, provides auto-discovery information
         # for the MediaWiki API (and potentially additional custom API
         # support such as WordPress or Twitter-compatible APIs for a
         # blogging extension, etc)
         $tags[] = Html::element('link', array('rel' => 'EditURI', 'type' => 'application/rsd+xml', 'href' => wfExpandUrl(wfAppendQuery(wfScript('api'), array('action' => 'rsd')), PROTO_RELATIVE)));
     }
     # Language variants
     if (!$wgDisableLangConversion && $wgCanonicalLanguageLinks) {
         $lang = $this->getTitle()->getPageLanguage();
         if ($lang->hasVariants()) {
             $urlvar = $lang->getURLVariant();
             if (!$urlvar) {
                 $variants = $lang->getVariants();
                 foreach ($variants as $_v) {
                     $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $_v, 'href' => $this->getTitle()->getLocalURL(array('variant' => $_v))));
                 }
             } else {
                 $tags[] = Html::element('link', array('rel' => 'canonical', 'href' => $this->getTitle()->getCanonicalUrl()));
             }
         }
     }
     # Copyright
     $copyright = '';
     if ($wgRightsPage) {
         $copy = Title::newFromText($wgRightsPage);
         if ($copy) {
             $copyright = $copy->getLocalURL();
         }
     }
     if (!$copyright && $wgRightsUrl) {
         $copyright = $wgRightsUrl;
     }
     if ($copyright) {
         $tags[] = Html::element('link', array('rel' => 'copyright', 'href' => $copyright));
     }
     # Feeds
     if ($wgFeed) {
         foreach ($this->getSyndicationLinks() as $format => $link) {
             # Use the page name for the title.  In principle, this could
             # lead to issues with having the same name for different feeds
             # corresponding to the same page, but we can't avoid that at
             # this low a level.
             $tags[] = $this->feedLink($format, $link, $this->msg("page-{$format}-feed", $this->getTitle()->getPrefixedText())->text());
         }
         # Recent changes feed should appear on every page (except recentchanges,
         # that would be redundant). Put it after the per-page feed to avoid
         # changing existing behavior. It's still available, probably via a
         # menu in your browser. Some sites might have a different feed they'd
         # like to promote instead of the RC feed (maybe like a "Recent New Articles"
         # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
         # If so, use it instead.
         if ($wgOverrideSiteFeed) {
             foreach ($wgOverrideSiteFeed as $type => $feedUrl) {
                 // Note, this->feedLink escapes the url.
                 $tags[] = $this->feedLink($type, $feedUrl, $this->msg("site-{$type}-feed", $wgSitename)->text());
             }
         } elseif (!$this->getTitle()->isSpecial('Recentchanges')) {
             $rctitle = SpecialPage::getTitleFor('Recentchanges');
             foreach ($wgAdvertisedFeedTypes as $format) {
                 $tags[] = $this->feedLink($format, $rctitle->getLocalURL("feed={$format}"), $this->msg("site-{$format}-feed", $wgSitename)->text());
             }
         }
     }
     return implode("\n", $tags);
 }
예제 #22
0
 public function saveSettings($settings, $cityId = null)
 {
     global $wgCityId, $wgUser;
     $cityId = empty($cityId) ? $wgCityId : $cityId;
     if (isset($settings['favicon-image-name']) && strpos($settings['favicon-image-name'], 'Temp_file_') === 0) {
         $temp_file = new LocalFile(Title::newFromText($settings['favicon-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
         $file = new LocalFile(Title::newFromText(self::FaviconImageName, 6), RepoGroup::singleton()->getLocalRepo());
         $file->upload($temp_file->getPath(), '', '');
         $temp_file->delete('');
         $settings['favicon-image-url'] = $file->getURL();
         $settings['favicon-image-name'] = $file->getName();
         $file->repo->forceMaster();
         $history = $file->getHistory(1);
         if (count($history) == 1) {
             $oldFaviconFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
         }
     }
     if (isset($settings['wordmark-image-name']) && strpos($settings['wordmark-image-name'], 'Temp_file_') === 0) {
         $temp_file = new LocalFile(Title::newFromText($settings['wordmark-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
         $file = new LocalFile(Title::newFromText(self::WordmarkImageName, 6), RepoGroup::singleton()->getLocalRepo());
         $file->upload($temp_file->getPath(), '', '');
         $temp_file->delete('');
         $settings['wordmark-image-url'] = $file->getURL();
         $settings['wordmark-image-name'] = $file->getName();
         $file->repo->forceMaster();
         $history = $file->getHistory(1);
         if (count($history) == 1) {
             $oldFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
         }
     }
     if (isset($settings['background-image-name']) && strpos($settings['background-image-name'], 'Temp_file_') === 0) {
         $temp_file = new LocalFile(Title::newFromText($settings['background-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
         $file = new LocalFile(Title::newFromText(self::BackgroundImageName, 6), RepoGroup::singleton()->getLocalRepo());
         $file->upload($temp_file->getPath(), '', '');
         $temp_file->delete('');
         $settings['background-image'] = $file->getURL();
         $settings['background-image-name'] = $file->getName();
         $imageServing = new ImageServing(null, 120, array("w" => "120", "h" => "100"));
         $settings['user-background-image'] = $file->getURL();
         $settings['user-background-image-thumb'] = wfReplaceImageServer($file->getThumbUrl($imageServing->getCut($file->getWidth(), $file->getHeight(), "origin") . "-" . $file->getName()));
         $file->repo->forceMaster();
         $history = $file->getHistory(1);
         if (count($history) == 1) {
             $oldBackgroundFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
         }
     }
     $reason = wfMsg('themedesigner-reason', $wgUser->getName());
     // update history
     if (!empty($GLOBALS[self::WikiFactoryHistory])) {
         $history = $GLOBALS[self::WikiFactoryHistory];
         $lastItem = end($history);
         $revisionId = intval($lastItem['revision']) + 1;
     } else {
         $history = array();
         $revisionId = 1;
     }
     // #140758 - Jakub
     // validation
     // default color values
     foreach (ThemeDesignerHelper::getColorVars() as $sColorVar => $sDefaultValue) {
         if (!isset($settings[$sColorVar]) || !ThemeDesignerHelper::isValidColor($settings[$sColorVar])) {
             $settings[$sColorVar] = $sDefaultValue;
         }
     }
     // update WF variable with current theme settings
     WikiFactory::setVarByName(self::WikiFactorySettings, $cityId, $settings, $reason);
     // add entry
     $history[] = array('settings' => $settings, 'author' => $wgUser->getName(), 'timestamp' => wfTimestampNow(), 'revision' => $revisionId);
     // limit history size to last 10 changes
     $history = array_slice($history, -self::HistoryItemsLimit);
     if (count($history) > 1) {
         for ($i = 0; $i < count($history) - 1; $i++) {
             if (isset($oldFaviconFile) && isset($history[$i]['settings']['favicon-image-name'])) {
                 if ($history[$i]['settings']['favicon-image-name'] == self::FaviconImageName) {
                     $history[$i]['settings']['favicon-image-name'] = $oldFaviconFile['name'];
                     $history[$i]['settings']['favicon-image-url'] = $oldFaviconFile['url'];
                 }
             }
             if (isset($oldFile) && isset($history[$i]['settings']['wordmark-image-name'])) {
                 if ($history[$i]['settings']['wordmark-image-name'] == self::WordmarkImageName) {
                     $history[$i]['settings']['wordmark-image-name'] = $oldFile['name'];
                     $history[$i]['settings']['wordmark-image-url'] = $oldFile['url'];
                 }
             }
             if (isset($oldBackgroundFile) && isset($history[$i]['settings']['background-image-name'])) {
                 if ($history[$i]['settings']['background-image-name'] == self::BackgroundImageName) {
                     $history[$i]['settings']['background-image-name'] = $oldBackgroundFile['name'];
                 }
             }
         }
     }
     WikiFactory::setVarByName(self::WikiFactoryHistory, $cityId, $history, $reason);
 }
예제 #23
0
 public static function onThumbnailVideoHTML($options, $linkAttribs, $imageAttribs, File $file, &$html)
 {
     global $wgRTEParserEnabled;
     if (!empty($wgRTEParserEnabled)) {
         return true;
     }
     if (is_null(self::$isWikiaMobile)) {
         self::init();
     }
     if (self::$isWikiaMobile) {
         wfProfileIn(__METHOD__);
         /**
          * WikiaMobile: lazy loading images in a SEO-friendly manner
          * @author Federico "Lox" Lucignano <federico@wikia-inc.com
          * @author Artur Klajnerok <*****@*****.**>
          */
         $origImg = Xml::element('img', $imageAttribs, '', true);
         if (empty($imageAttribs['alt'])) {
             unset($imageAttribs['alt']);
         }
         //Not all 'files' have getProviderName defined
         if (is_callable([$file, 'getProviderName'])) {
             $provider = $file->getProviderName();
         } else {
             $provider = '';
         }
         $imageParams = array('type' => 'video', 'provider' => $provider, 'full' => $imageAttribs['src']);
         if (!empty($imageAttribs['data-video-key'])) {
             $imageParams['name'] = htmlspecialchars($imageAttribs['data-video-key']);
         }
         if (!empty($options['caption'])) {
             $imageParams['capt'] = 1;
         }
         // TODO: this resizes every video thumbnail with a width over 64px regardless of where it appears.
         // We may want to add the ability to allow custom image widths (like on the file page history table for example)
         $size = WikiaMobileMediaService::calculateMediaSize($file->getWidth(), $file->getHeight());
         $thumb = $file->transform($size);
         $imageAttribs['src'] = wfReplaceImageServer($thumb->getUrl(), $file->getTimestamp());
         $imageAttribs['width'] = $size['width'];
         $imageAttribs['height'] = $size['height'];
         $data = ['attributes' => $imageAttribs, 'parameters' => [$imageParams], 'anchorAttributes' => $linkAttribs, 'noscript' => $origImg, 'isSmall' => WikiaMobileMediaService::isSmallImage($imageAttribs['width'], $imageAttribs['height'])];
         $title = $file->getTitle()->getDBKey();
         $titleText = $file->getTitle()->getText();
         $views = MediaQueryService::getTotalVideoViewsByTitle($title);
         $data['content'] = Xml::element('span', ['class' => 'videoInfo'], "{$titleText} (" . $file->getHandler()->getFormattedDuration() . ", " . wfMessage('wikiamobile-video-views-counter', $views)->inContentLanguage()->text() . ')');
         $html = F::app()->sendRequest('WikiaMobileMediaService', 'renderImageTag', $data, true)->toString();
         wfProfileOut(__METHOD__);
     }
     return true;
 }
예제 #24
0
 /**
  * Gets path to original file
  *
  * @return string URL
  */
 public function getUrl()
 {
     if (!isset($this->url)) {
         $this->url = $this->getUploadDir() . '/' . $this->getUrlRel();
         $this->url = wfReplaceImageServer($this->url, $this->getTimestamp());
     }
     return $this->url;
 }
?>
><?php 
echo $comment['avatar'];
?>
</a>
	</div>
	<blockquote class=msg>
		<div class=by>
			<?php 
echo $comment['sig'];
?>
			<?php 
if (!empty($comment['isStaff'])) {
    ?>
			<img class=staff src=<?php 
    echo wfReplaceImageServer('/extensions/wikia/StaffSig/images/WikiaStaff.png');
    ?>
 alt=@wikia/></span>
			<?php 
}
?>
		</div>
		<div class=txt><?php 
echo $comment['text'];
?>
</div>
		<div class=date><?php 
echo $comment['timestamp'];
?>
</div>
	</blockquote>
예제 #26
0
 private function getImageSrc($filename)
 {
     $imageSrc = '';
     $fileTitle = Title::newFromText($filename, NS_FILE);
     $image = wfFindFile($fileTitle);
     if (!is_object($image) || $image->height == 0 || $image->width == 0) {
         return $imageSrc;
     } else {
         $thumbDim = $image->height > $image->width ? $image->width : $image->height;
         $imageServing = new ImageServing(array($fileTitle->getArticleID()), $thumbDim, array("w" => $thumbDim, "h" => $thumbDim));
         $imageSrc = wfReplaceImageServer($image->getThumbUrl($imageServing->getCut($thumbDim, $thumbDim) . "-" . $image->getName()));
     }
     return $imageSrc;
 }
예제 #27
0
 /**
  * Get URL for avatar
  */
 static function getAvatarUrl($user, $avatarSize = 20, $avoidUpscaling = false)
 {
     wfProfileIn(__METHOD__);
     static $avatarsCache;
     if ($user instanceof User) {
         $key = "{$user->getName()}::{$avatarSize}";
     } else {
         //assumes $user is a string with user name
         $key = "{$user}::{$avatarSize}";
     }
     if (isset($avatarsCache[$key])) {
         $avatarUrl = $avatarsCache[$key];
     } else {
         if (!$user instanceof User) {
             $user = self::getUser($user);
         }
         // handle anon users - return default avatar
         if (empty($user) || !class_exists('Masthead')) {
             $avatarUrl = self::getDefaultAvatar($avatarSize);
             wfProfileOut(__METHOD__);
             return $avatarUrl;
         }
         $masthead = Masthead::newFromUser($user);
         $avatarUrl = $masthead->getThumbnail($avatarSize, true, $avoidUpscaling);
         // use per-user cachebuster when custom avatar is used
         $cb = !$masthead->isDefault() ? intval($user->getOption('avatar_rev')) : 0;
         // Make URLs consistent and using no-cookie domain.  We need to pass a
         // stringified zero rather than an actual zero because this function
         // treats them differently o_O  Setting this to string zero matches
         // the anonymous user behavior (BugId:22190)
         $avatarUrl = wfReplaceImageServer($avatarUrl, $cb > 0 ? $cb : "0");
         $avatarsCache[$key] = $avatarUrl;
     }
     wfProfileOut(__METHOD__);
     return $avatarUrl;
 }
 public function getTile()
 {
     $position_X = $this->getVal('x');
     $position_Y = $this->getVal('y');
     $zoom = $this->getVal('z');
     $name = $this->getVal('imgName');
     $ver_img = $this->getVal('version');
     $width = 256;
     $imgFile = $this->wf->findFile($name);
     $heightIMG = $imgFile->height;
     $widthIMG = $imgFile->width;
     $titlesize = null;
     if ($heightIMG > $widthIMG) {
         $titlesize = $heightIMG;
     } else {
         $titlesize = $widthIMG;
     }
     $titlesize = $titlesize / pow(2, $zoom);
     $left = floor($position_X * $titlesize);
     $right = floor($left + $titlesize);
     $top = floor($position_Y * $titlesize);
     $bottom = floor($top + $titlesize);
     $urlIMG = wfReplaceImageServer($imgFile->getThumbUrl("{$width}px-{$left},{$right},{$top},{$bottom}-" . $imgFile->getName()));
     $this->setVal('url', $urlIMG);
 }
예제 #29
0
 /**
  * Get wiki background full, up-to-date URL
  *
  * This method returns URL based on "background-image" and performs URL rewrite
  * for migrated wikis with short Swift bucket name
  *
  * @see  $wgUploadPath - "http://images.wikia.com/24_/es/images"
  *
  * @author macbre
  * @return string background URL or empty string if not found
  */
 public function getBackgroundUrl()
 {
     global $wgUploadPath;
     $backgroundUrl = $this->getSettings()['background-image'];
     if (!VignetteRequest::isVignetteUrl($backgroundUrl)) {
         if (empty($backgroundUrl)) {
             return $backgroundUrl;
         }
         $backgroundPath = explode('/images/', $backgroundUrl)[0];
         if (!empty($wordmarkPath)) {
             $backgroundUrl = str_replace($backgroundPath . '/images', $wgUploadPath, $backgroundUrl);
         }
         $backgroundUrl = wfReplaceImageServer($backgroundUrl, SassUtil::getCacheBuster());
     }
     return $backgroundUrl;
 }
 /**
  * Returns image or snippet for the category on id basis.
  * Uses in modified getArticle
  *
  * @param $iCategoryId int category pageId
  * @return array
  */
 protected function getCategoryImageOrSnippet($iCategoryId)
 {
     $title = Title::newFromID($iCategoryId);
     $sCategoryDBKey = $title->getDBKey();
     // tries to get image from images in category
     $result = CategoryDataService::getAlphabetical($sCategoryDBKey, NS_FILE, 1);
     if (!empty($result)) {
         $counter = 0;
         foreach ($result as $item) {
             if ($counter > F::App()->wg->maxCategoryExhibitionSubcatChecks) {
                 break;
             }
             $imageServing = new ImageServing(array($item['page_id']), $this->thumbWidth, array("w" => $this->thumbWidth, "h" => $this->thumbHeight));
             $itemTitle = Title::newFromID($item['page_id']);
             $image = wfFindFile($itemTitle);
             if (!empty($image)) {
                 $imageSrc = wfReplaceImageServer($image->getThumbUrl($imageServing->getCut($image->width, $image->height) . "-" . $image->getName()));
                 return array('imageUrl' => (string) $imageSrc, 'snippetText' => '');
             }
             $counter++;
         }
     }
     // if no images found, tries to get image or snippet from artice
     unset($result);
     $result = CategoryDataService::getAlphabetical($sCategoryDBKey, NS_MAIN, 10);
     if (!empty($result)) {
         $counter = 0;
         $snippetText = '';
         $imageUrl = '';
         foreach ($result as $item) {
             if ($counter > F::App()->wg->maxCategoryExhibitionSubcatChecks) {
                 break;
             }
             $imageUrl = $this->getImageFromPageId($item['page_id']);
             if (!empty($imageUrl)) {
                 break;
             }
             if (empty($snippetText)) {
                 $snippetService = new ArticleService($item['page_id']);
                 $snippetText = $snippetService->getTextSnippet();
             }
             $counter++;
         }
         return array('imageUrl' => $imageUrl, 'snippetText' => $snippetText);
     } else {
         return array('imageUrl' => '', 'snippetText' => '');
     }
 }