本文整理汇总了PHP中wfReplaceImageServer函数的典型用法代码示例。如果您正苦于以下问题:PHP wfReplaceImageServer函数的具体用法?PHP wfReplaceImageServer怎么用?PHP wfReplaceImageServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfReplaceImageServer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeIndex
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);
}
示例2: executeWordmark
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: addWikiaVars
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;
}
示例4: getBadge
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: wfMakeSignatureCommon
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>';
}
示例6: egOgmcParserOutputApplyValues
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: testForDevbox
/**
* @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');
}
示例8: index
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: downloadWordmark
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: execute
/**
* 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__);
}
示例11: executePlayQuiz
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: getOasisSettings
/**
* 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: cropURL
/**
* 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: getWikiWordmark
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: wfRenderTimeline
/**
* @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) {
//.........这里部分代码省略.........