public function getEmbedCode()
 {
     $articleId = $this->getVal('articleId', '');
     $title = $this->getVal('fileTitle', '');
     $width = $this->getVal('width', '');
     $autoplay = $this->getVal('autoplay', false);
     $error = '';
     if (empty($title)) {
         $error = $this->wf->msgForContent('videohandler-error-missing-parameter', 'title');
     } else {
         if (empty($width)) {
             $error = $this->wf->msgForContent('videohandler-error-missing-parameter', 'width');
         } else {
             $title = Title::newFromText($title, NS_FILE);
             $file = $title instanceof Title ? wfFindFile($title) : false;
             if ($file === false) {
                 $error = $this->wf->msgForContent('videohandler-error-video-no-exist');
             } else {
                 $videoId = $file->getVideoId();
                 $assetUrl = $file->getPlayerAssetUrl();
                 $embedCode = $file->getEmbedCode($articleId, $width, $autoplay, true);
                 $this->setVal('videoId', $videoId);
                 $this->setVal('asset', $assetUrl);
                 $this->setVal('embedCode', $embedCode);
                 //@todo support json embed code
             }
         }
     }
     if (!empty($error)) {
         $this->setVal('error', $error);
     }
 }
Example #2
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;
 }
 /**
  * Get data for each gallery item
  * @param array $item Data about the media item
  * @param int $index Where the item shows up in the gallery
  * @return array|null
  */
 protected function getMediaData(array $item, $index)
 {
     $file = wfFindFile($item['title']);
     if (!$file instanceof File) {
         WikiaLogger::instance()->error('File with title: ' . $item['title'] . 'doesn\'t exist', ['class' => __CLASS__]);
         return null;
     }
     $dimension = MediaGalleryHelper::getImageWidth($this->itemCount, $index);
     $thumbUrl = WikiaFileHelper::getSquaredThumbnailUrl($file, $dimension);
     $dimensions = ['width' => $dimension, 'height' => $dimension];
     $thumb = $file->transform($dimensions);
     if (!$thumb instanceof ThumbnailImage) {
         WikiaLogger::instance()->error('ThumbnailImage from title: ' . $item['title'] . ' couldn\'t be created.', ['thumbClass' => get_class($thumb)]);
         return null;
     }
     $thumb->setUrl($thumbUrl);
     $thumbnail = $this->app->renderView('ThumbnailController', 'gallery', ['thumb' => $thumb]);
     $caption = '';
     if (!empty($item['caption'])) {
         // parse any wikitext in caption. Logic borrowed from WikiaMobileMediaService::renderMediaGroup.
         $parser = $this->getParser();
         $caption = $parser->internalParse($item['caption']);
         $parser->replaceLinkHolders($caption);
         $caption = $parser->killMarkers($caption);
     }
     $title = $file->getTitle();
     return ['thumbUrl' => $thumbUrl, 'thumbHtml' => $thumbnail, 'caption' => $caption, 'linkHref' => $file->getTitle()->getLinkURL(), 'title' => $title->getText(), 'dbKey' => $title->getDBKey()];
 }
Example #4
0
 public function execute()
 {
     global $wgUser;
     # Change to current working directory
     $oldCwd = getcwd();
     chdir($oldCwd);
     # Options processing
     $user = $this->getOption('u', 'Delete page script');
     $reason = $this->getOption('r', '');
     $interval = $this->getOption('i', 0);
     if ($this->hasArg()) {
         $file = fopen($this->getArg(), 'r');
     } else {
         $file = $this->getStdin();
     }
     # Setup
     if (!$file) {
         $this->error("Unable to read file, exiting", true);
     }
     $wgUser = User::newFromName($user);
     $dbw = wfGetDB(DB_MASTER);
     # Handle each entry
     for ($linenum = 1; !feof($file); $linenum++) {
         $line = trim(fgets($file));
         if ($line == '') {
             continue;
         }
         $page = Title::newFromText($line);
         if (is_null($page)) {
             $this->output("Invalid title '{$line}' on line {$linenum}\n");
             continue;
         }
         if (!$page->exists()) {
             $this->output("Skipping nonexistent page '{$line}'\n");
             continue;
         }
         $this->output($page->getPrefixedText());
         $dbw->begin();
         if ($page->getNamespace() == NS_FILE) {
             $art = new ImagePage($page);
             $img = wfFindFile($art->mTitle);
             if (!$img || !$img->isLocal() || !$img->delete($reason)) {
                 $this->output(" FAILED to delete image file... ");
             }
         } else {
             $art = new Article($page);
         }
         $success = $art->doDeleteArticle($reason);
         $dbw->commit();
         if ($success) {
             $this->output(" Deleted!\n");
         } else {
             $this->output(" FAILED to delete article\n");
         }
         if ($interval) {
             sleep($interval);
         }
         wfWaitForSlaves();
     }
 }
 /**
  * Start doing stuff
  *
  * @param $par Mixed: parameter passed to the special page or null
  */
 public function execute($par)
 {
     global $wgOut;
     wfProfileIn(__METHOD__);
     $dbr = wfGetDB(DB_SLAVE);
     $where = array();
     if ($this->mQuery) {
         $where = array('article_tag' => $this->mQuery);
     }
     $foo = $dbr->select('imagetags', 'img_name', $where, __METHOD__);
     $imageNames = array();
     foreach ($foo as $omg) {
         $imageNames[] = $omg;
     }
     $imageNamesString = implode(',', $imageNames);
     // @todo CHECKME
     $res = $dbr->select('image', array('img_name', 'img_timestamp'), array("img_name IN {$imageNamesString}"), __METHOD__, array('ORDER BY' => 'img_timestamp DESC', 'LIMIT' => TAGGEDIMGS_PER_PAGE, 'OFFSET' => $this->mStartPage * TAGGEDIMGS_PER_PAGE));
     foreach ($res as $o) {
         $img = wfFindFile($o->img_name);
         $this->add($img, '');
     }
     $res = $dbr->select('imagetags', 'COUNT(img_name) AS img_count', $where, __METHOD__, array('GROUP BY' => 'article_tag'));
     $o = $dbr->fetchObject($res);
     if ($o) {
         $this->mCount = $o->img_count;
     }
     $wgOut->setPageTitle(wfMsg('imagetagging-taggedimages-title', $this->mQuery ? $this->mQuery : 'all'));
     $wgOut->setRobotPolicy('noindex,nofollow');
     $wgOut->addHTML($this->toHTML());
     wfProfileOut(__METHOD__);
 }
 /**
  * Add image to parser output for later usage
  *
  * @param string $title
  */
 public function addImage($title)
 {
     $file = wfFindFile($title);
     $tmstmp = $file ? $file->getTimestamp() : false;
     $sha1 = $file ? $file->getSha1() : false;
     $this->parser->getOutput()->addImage($title, $tmstmp, $sha1);
 }
 function displayCategoryTable()
 {
     global $wgOut;
     $catmap = Categoryhelper::getIconMap();
     ksort($catmap);
     $queryString = WikihowCategoryViewer::getViewModeParam();
     if (!empty($queryString)) {
         $queryString = "?" . $queryString;
     }
     $wgOut->addHTML("<div class='section_text'>");
     foreach ($catmap as $cat => $image) {
         $title = Title::newFromText($image);
         if ($title) {
             $file = wfFindFile($title, false);
             $sourceWidth = $file->getWidth();
             $sourceHeight = $file->getHeight();
             $heightPreference = false;
             if (self::CAT_HEIGHT > self::CAT_WIDTH && $sourceWidth > $sourceHeight) {
                 //desired image is portrait
                 $heightPreference = true;
             }
             $thumb = $file->getThumbnail(self::CAT_WIDTH, self::CAT_HEIGHT, true, true, $heightPreference);
             $category = urldecode(str_replace("-", " ", $cat));
             $catTitle = Title::newFromText("Category:" . $category);
             if ($catTitle) {
                 $wgOut->addHTML("<div class='thumbnail'><a href='{$catTitle->getLocalUrl()}{$queryString}'><img src='" . wfGetPad($thumb->getUrl()) . "' /><div class='text'><p><span>{$category}</span></p></div></a></div>");
             }
         }
     }
     $wgOut->addHTML("<div class='clearall'></div>");
     $wgOut->addHTML("</div><!-- end section_text -->");
 }
Example #8
0
 public static function getImagePreview()
 {
     wfProfileIn(__METHOD__);
     global $wgTitle;
     // limit dimensions of returned image
     global $wgRequest;
     $maxWidth = $wgRequest->getInt('maxwidth', 500) - 20;
     $maxHeight = $wgRequest->getInt('maxheight', 300) - 75;
     $image = wfFindFile($wgTitle);
     if (empty($image)) {
         wfProfileOut(__METHOD__);
         return array();
     }
     // get original dimensions of an image
     $width = $image->getWidth();
     $height = $image->getHeight();
     // don't try to make image larger
     if ($width > $maxWidth or $height > $maxHeight) {
         $width = $maxWidth;
         $height = $maxHeight;
     }
     // generate thumbnail
     $thumb = $image->transform(array('width' => $width, 'height' => $height));
     wfProfileOut(__METHOD__);
     return array('width' => $thumb->getWidth(), 'height' => $thumb->getHeight(), 'html' => $thumb->toHtml());
 }
 public function execute()
 {
     global $wgRequest;
     wfProfileIn(__METHOD__);
     extract($this->extractRequestParams());
     $imageServing = new ImageServing(array($Id), $Size, array("w" => $Size, "h" => $Height));
     foreach ($imageServing->getImages(1) as $key => $value) {
         $tmpTitle = Title::newFromText($value[0]['name'], NS_FILE);
         $image = wfFindFile($tmpTitle);
         // BugId:31460 ForeignAPIFile does not support loading metadata from the file itself.
         // Note, that ForeignAPIFile::getPath() is a dommy method and always returns false, so
         // the 'File not found' dieUsage() call in the next if block is inevitable for ForeignAPIFile objects.
         if ($FailOnFileNotFound && false == $image instanceof ForeignAPIFile) {
             $image->loadFromFile();
             // side effect forces isMissing() check to fail if file really does not exist
         }
         if (!($image instanceof File && $image->exists()) || $image->isMissing() || $image->mime == 'unknown/unknown') {
             $this->dieUsage('File not found', 'filenotfound');
         }
         $width = $image->getWidth();
         $height = $image->getHeight();
         $imageUrl = $imageServing->getUrl($image->getName(), $width, $height);
     }
     $result = $this->getResult();
     $result->addValue('image', $this->getModuleName(), $imageUrl);
     $result->addValue('imagepage', $this->getModuleName(), $tmpTitle->getFullUrl());
     wfProfileOut(__METHOD__);
 }
Example #10
0
 function execute($par)
 {
     global $wgRequest, $wgOut;
     $this->setHeaders();
     $this->outputHeader();
     $file = !is_null($par) ? $par : $wgRequest->getText('file');
     $title = Title::makeTitleSafe(NS_FILE, $file);
     if (!$title instanceof Title || $title->getNamespace() != NS_FILE) {
         $this->showForm($title);
     } else {
         $file = wfFindFile($title);
         if ($file && $file->exists()) {
             $url = $file->getURL();
             $width = $wgRequest->getInt('width', -1);
             $height = $wgRequest->getInt('height', -1);
             if ($width != -1) {
                 $mto = $file->transform(array('width' => $width, 'height' => $height));
                 if ($mto && !$mto->isError()) {
                     $url = $mto->getURL();
                 }
             }
             $wgOut->redirect($url);
         } else {
             $wgOut->setStatusCode(404);
             $this->showForm($title);
         }
     }
 }
 public static function getBadge($badgeTypeId)
 {
     wfProfileIn(__METHOD__);
     global $wgExternalSharedDB;
     global $wgEnableAchievementsStoreLocalData;
     $badges = array();
     if (empty($wgEnableAchievementsStoreLocalData)) {
         $dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
     } else {
         $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;
 }
 public function getVideoData($titleText, $thumbnailWidth, $videoWidth = self::DEFAULT_OASIS_VIDEO_WIDTH, $autoplay = true, $useMaster = false, $cityShort = 'life', $videoHeight = '', $useJWPlayer = true, $inAjaxResponse = false)
 {
     wfProfileIn(__METHOD__);
     $data = array();
     $title = Title::newFromText($titleText, NS_FILE);
     $file = wfFindFile($title);
     if (!WikiaFileHelper::isVideoFile($file)) {
         $data['error'] = wfMsg('related-videos-error-no-video-title');
     } else {
         $meta = unserialize($file->getMetadata());
         $trans = $file->transform(array('width' => $thumbnailWidth, 'height' => -1));
         $thumb = array('width' => $trans->width, 'height' => $trans->height, 'thumb' => $trans->url);
         $data['external'] = 0;
         // false means it is not set. Meaningful values: 0 and 1.
         $data['id'] = $titleText;
         $data['fullUrl'] = $title->getFullURL();
         $data['prefixedUrl'] = $title->getPrefixedURL();
         $data['description'] = $file->getDescription();
         $data['duration'] = $meta['duration'];
         $data['embedCode'] = null;
         $data['embedJSON'] = null;
         $data['provider'] = $file->minor_mime;
         $data['thumbnailData'] = $thumb;
         $data['title'] = $file->getTitle()->getText();
         $data['timestamp'] = $file->getTimestamp();
         $data['uniqueId'] = $file->getVideoUniqueId();
     }
     $data['owner'] = '';
     $data['ownerUrl'] = '';
     wfProfileOut(__METHOD__);
     return $data;
 }
Example #13
0
function formatImageLink($imageName, $linkTarget, $altText)
{
    if (preg_match('/^(http|ftp)/', $imageName)) {
        $imageUrl = $imageName;
        $sizeAttrs = "";
    } else {
        $imageTitle = Title::makeTitleSafe(NS_IMAGE, $imageName);
        if (is_null($imageTitle)) {
            return "(invalid image name)";
        }
        $image = wfFindFile($imageTitle);
        if (is_null($image)) {
            return "(invalid image)";
        }
        $imageUrl = $image->getViewURL();
        $sizeAttrs = 'width="' . IntVal($image->getWidth()) . '" height="' . IntVal($image->getHeight()) . '"';
    }
    if (preg_match('/^(http|ftp)/', $linkTarget)) {
        $linkUrl = $linkTarget;
    } else {
        $linkTitle = Title::newFromText($linkTarget);
        if (is_null($linkTitle)) {
            return "(invalid link target)";
        }
        $linkUrl = $linkTitle->getLocalUrl();
    }
    return '<a href="' . htmlspecialchars($linkUrl) . '"><img src="' . htmlspecialchars($imageUrl) . '" ' . $sizeAttrs . ' alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '" /></a>';
}
 /**
  * set appropriate status code for deleted pages
  *
  * @author ADi
  * @author Władysław Bodzek <*****@*****.**>
  * @param Title $title
  * @param Article $article
  * @return bool
  */
 public static function onAfterInitialize(&$title, &$article, &$output)
 {
     if (!$title->exists() && $title->isDeleted()) {
         $setDeletedStatusCode = true;
         // handle special cases
         switch ($title->getNamespace()) {
             case NS_CATEGORY:
                 // skip non-empty categories
                 if (Category::newFromTitle($title)->getPageCount() > 0) {
                     $setDeletedStatusCode = false;
                 }
                 break;
             case NS_FILE:
                 // skip existing file with deleted description
                 $file = wfFindFile($title);
                 if ($file && $file->exists()) {
                     $setDeletedStatusCode = false;
                 }
                 break;
         }
         if ($setDeletedStatusCode) {
             $output->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
         }
     }
     return true;
 }
Example #15
0
 /**
  * Check to see if an image was already uploaded for wikiphoto
  */
 public static function checkDupImage($filename)
 {
     $dbr = self::getDB('read');
     $contents = @file_get_contents($filename);
     if ($contents) {
         $sha1 = sha1($contents);
         $db_title = $dbr->selectField('images_sha1', 'is_page_title', array('is_sha1' => $sha1), __METHOD__);
         if ($db_title) {
             $title = Title::newFromDBkey('Image:' . $db_title);
             if ($title && $title->exists()) {
                 $file = wfFindFile($title);
                 if ($file) {
                     $path = $file->getPath();
                     if ($path && @file_exists($path)) {
                         $contents = @file_get_contents($path);
                         if ($contents) {
                             $sha1_orig = sha1($contents);
                             if ($sha1_orig == $sha1) {
                                 return $title->getText();
                             }
                         }
                     }
                 }
             }
         }
     }
     return '';
 }
Example #16
0
 function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $request = $this->getRequest();
     $file = !is_null($par) ? $par : $request->getText('file');
     $title = Title::newFromText($file, NS_FILE);
     if (!$title instanceof Title || $title->getNamespace() != NS_FILE) {
         $this->showForm($title);
     } else {
         $file = wfFindFile($title);
         if ($file && $file->exists()) {
             // Default behaviour: Use the direct link to the file.
             $url = $file->getURL();
             $width = $request->getInt('width', -1);
             $height = $request->getInt('height', -1);
             // If a width is requested...
             if ($width != -1) {
                 $mto = $file->transform(array('width' => $width, 'height' => $height));
                 // ... and we can
                 if ($mto && !$mto->isError()) {
                     // ... change the URL to point to a thumbnail.
                     $url = $mto->getURL();
                 }
             }
             $this->getOutput()->redirect($url);
         } else {
             $this->getOutput()->setStatusCode(404);
             $this->showForm($title);
         }
     }
 }
Example #17
0
 protected function openShowVideo()
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     JSMessages::enqueuePackage('VideoPage', JSMessages::EXTERNAL);
     $file = $this->getDisplayedFile();
     //If a timestamp is specified, show the archived version of the video (if it exists)
     $timestamp = $app->wg->Request->getInt('t', 0);
     if ($timestamp > 0) {
         $archiveFile = wfFindFile($this->mTitle, $timestamp);
         if ($archiveFile instanceof LocalFile && $archiveFile->exists()) {
             $file = $archiveFile;
         }
     }
     $autoplay = $app->wg->VideoPageAutoPlay;
     // JS for VideoBootstrap
     $embedCode = $file->getEmbedCode(self::VIDEO_WIDTH, ['autoplay' => $autoplay]);
     // Tell JS that HTML will already be loaded on the page.
     $embedCode['htmlPreloaded'] = 1;
     // HTML is no longer needed in VideoBootstrap
     $html = $embedCode['html'];
     unset($embedCode['html']);
     $videoDisplay = '<script type="text/javascript">window.playerParams = ' . json_encode($embedCode) . ';</script>';
     $videoDisplay .= '<div class="fullImageLink" id="file">' . $html . '</div>';
     $videoDisplay .= $this->getVideoInfoLine($file);
     $app->wg->Out->addHTML($videoDisplay);
     wfProfileOut(__METHOD__);
 }
 public function Wordmark()
 {
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $wordmarkURL = '';
     if ($settings['wordmark-type'] == 'graphic') {
         wfProfileIn(__METHOD__ . 'graphicWordmark');
         $imageTitle = Title::newFromText($themeSettings::WordmarkImageName, NS_IMAGE);
         $file = wfFindFile($imageTitle);
         $attributes = [];
         $wordmarkStyle = '';
         if ($file instanceof File) {
             $wordmarkURL = $file->getUrl();
             $attributes[] = 'width="' . $file->width . '"';
             $attributes[] = 'height="' . $file->height . '"';
             if (!empty($attributes)) {
                 $this->wordmarkStyle = ' ' . implode(' ', $attributes) . ' ';
             }
         }
         wfProfileOut(__METHOD__ . 'graphicWordmark');
     }
     $mainPageURL = Title::newMainPage()->getLocalURL();
     $this->setVal('mainPageURL', $mainPageURL);
     $this->setVal('wordmarkText', $settings['wordmark-text']);
     $this->setVal('wordmarkFontSize', $settings['wordmark-font-size']);
     $this->setVal('wordmarkUrl', $wordmarkURL);
     $this->setVal('wordmarkStyle', $wordmarkStyle);
 }
 /**
  * Get the current file version (null if this not a File page)
  * @return File|null|false
  */
 public function getFile()
 {
     if ($this->file === null && $this->mTitle->getNamespace() == NS_FILE) {
         $this->file = wfFindFile($this->mTitle);
     }
     return $this->file;
 }
 function newAttachmentData($id)
 {
     $obj = $this->cacheManager->retrieveAtachmentData($id);
     if ($obj instanceof \PageAttachment\Attachment\AttachmentData) {
         $pageAttachmentData = $obj;
     } else {
         $title = \Title::newFromID($id);
         $article = new \Article($title, NS_FILE);
         $file = \wfFindFile($title);
         $size = $file->getSize();
         $description = $this->replaceHtmlTags($file->getDescriptionText());
         $dateUploaded = $article->getTimestamp();
         $uploadedBy = null;
         if ($this->runtimeConfig->isShowUserRealName()) {
             $uploadedBy = \User::whoIsReal($article->getUser());
         }
         if ($uploadedBy == null) {
             $uploadedBy = \User::whoIs($article->getUser());
         }
         $attachedToPages = null;
         if ($this->securityManager->isRemoveAttachmentPermanentlyEnabled()) {
             $attachedToPages = $this->getAttachedToPages($id);
         }
         $pageAttachmentData = new AttachmentData($id, $title, $size, $description, $dateUploaded, $uploadedBy, $attachedToPages);
         $this->cacheManager->storeAttachmentData($pageAttachmentData);
     }
     return $pageAttachmentData;
 }
	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 = $themeSettings->getWordmarkUrl();
         $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();
 }
 private function executeWikiaVideo($wikiaFilename)
 {
     $wikiaFile = wfFindFile($wikiaFilename);
     if (!$wikiaFile) {
         $this->dieUsage('Valid Wikia video URL, but video is missing', 'wikia-video-missing');
     }
     return array('title' => $wikiaFile->getTitle()->getText(), 'url' => $wikiaFile->getUrl(), 'provider' => 'wikia');
 }
Example #24
0
 protected function getVideoDuplicate($provider, $videoId)
 {
     $duplicates = WikiaFileHelper::getDuplicateVideos($provider, $videoId);
     if (count($duplicates) > 0) {
         return wfFindFile($duplicates[0]['video_title']);
     }
     return null;
 }
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);
    }
}
Example #26
0
/**
 * Called in some places (currently just extensions)
 * to get the URL for a given file.
 */
function wfAjaxGetFileUrl($file)
{
    $file = wfFindFile($file);
    if (!$file || !$file->exists()) {
        return null;
    }
    $url = $file->getUrl();
    return $url;
}
Example #27
0
 /**
  * @param string $title Video title
  * @return array
  */
 private function executeWikiaVideo($title)
 {
     $file = wfFindFile($title);
     if (!$file instanceof LocalFile) {
         $this->dieUsage('Wikia video doesn\'t exist', 'wikia-video-missing');
     }
     $options = ['autoplay' => true, 'isAjax' => true];
     return array('embedCode' => json_encode($file->getEmbedCode(self::EMBED_WIDTH, $options)));
 }
 public function execute()
 {
     $params = $this->extractRequestParams();
     $history = $params['history'];
     $prop = array_flip($params['prop']);
     $fld_timestamp = isset($prop['timestamp']);
     $fld_user = isset($prop['user']);
     $fld_comment = isset($prop['comment']);
     $fld_url = isset($prop['url']);
     $fld_size = isset($prop['size']);
     $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
     if (!empty($pageIds[NS_IMAGE])) {
         foreach ($pageIds[NS_IMAGE] as $dbKey => $pageId) {
             $title = Title::makeTitle(NS_IMAGE, $dbKey);
             $img = wfFindFile($title);
             $data = array();
             if (!$img) {
                 $data['missing'] = '';
             } else {
                 $data['repository'] = $img->getRepoName();
                 $isCur = true;
                 while ($line = $img->nextHistoryLine()) {
                     // assignment
                     $vals = array();
                     if ($fld_timestamp) {
                         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $line->img_timestamp);
                     }
                     if ($fld_user) {
                         $vals['user'] = $line->img_user_text;
                         if (!$line->img_user) {
                             $vals['anon'] = '';
                         }
                     }
                     if ($fld_size) {
                         $vals['size'] = $line->img_size;
                         $vals['width'] = $line->img_width;
                         $vals['height'] = $line->img_height;
                     }
                     if ($fld_url) {
                         $vals['url'] = $isCur ? $img->getURL() : $img->getArchiveUrl($line->oi_archive_name);
                     }
                     if ($fld_comment) {
                         $vals['comment'] = $line->img_description;
                     }
                     $data[] = $vals;
                     if (!$history) {
                         // Stop after the first line.
                         break;
                     }
                     $isCur = false;
                 }
                 $img->resetHistory();
             }
             $this->addPageSubItems($pageId, $data);
         }
     }
 }
Example #29
0
function imageURL(&$parser, $name = '')
{
    $imageObj = wfFindFile($name);
    if (!$imageObj || !$imageObj->exists()) {
        return wfMsg('respawn:noexist', $name);
    } else {
        return $imageObj->getViewURL();
    }
}
 public function getImageData($element)
 {
     $returnVal = [];
     if (isset($element['title'])) {
         $title = $this->getTitleFromText($element['title']);
         $returnVal = ['url' => $title->getLocalUrl(), 'file' => wfFindFile($title)];
     }
     return $returnVal;
 }