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(); }
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() ) ); }
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); } }
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'); }
/** * 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; }
/** * @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, $wgDevelEnvironment, $wgStagingEnvironment; $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}"; // Wikia change - begin if (!empty($wgDevelEnvironment) || !empty($wgStagingEnvironment)) { $p = "noindex,nofollow"; } // Wikia change - end 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) { // Wikia change begin - @author: macbre $appleTouchIcon = wfReplaceImageServer($wgAppleTouchIcon, SassUtil::getCacheBuster()); // Wikia change end $tags[] = Html::element('link', array('rel' => 'apple-touch-icon', 'href' => $appleTouchIcon)); } $tags[] = Html::element('link', array('rel' => 'shortcut icon', 'href' => Wikia::getFaviconFullUrl())); # 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); }