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();
 }
Ejemplo n.º 3
0
 public function execute()
 {
     global $wgCityId, $wgSitename, $wgServer;
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $this->output(implode(',', [$wgCityId, $wgSitename, $wgServer, $settings['page-opacity']]) . "\n");
 }
 /**
  * Updates wiki specific properties set from wiki creation wizard.
  * Context of this method is on the wiki that the values are changing on.
  * Main wiki creation happens on www, and it will redirect to the newly created wiki.
  * The values are read from the session and only accessible by the admin.
  */
 public function FinishCreate()
 {
     global $wgUser, $wgOut, $wgEnableNjordExt;
     if (!$wgUser->isAllowed('finishcreate')) {
         return false;
     }
     $this->skipRendering();
     $this->LoadState();
     $mainPage = wfMsgForContent('mainpage');
     // set theme
     if (!empty($this->params['color-body'])) {
         $themeSettings = new ThemeSettings();
         $themeSettings->saveSettings($this->params);
     }
     // set description on main page
     if (!empty($this->params['wikiDescription'])) {
         $mainTitle = Title::newFromText($mainPage);
         $mainId = $mainTitle->getArticleID();
         $mainArticle = Article::newFromID($mainId);
         if (!empty($mainArticle)) {
             if (!empty($wgEnableNjordExt)) {
                 $newMainPageText = $this->getMoMMainPage($mainArticle);
             } else {
                 $newMainPageText = $this->getClassicMainPage($mainArticle);
             }
             $mainArticle->doEdit($newMainPageText, '');
             $this->initHeroModule($mainPage);
         }
     }
     $wgOut->enableClientCache(false);
     $this->clearState();
     $wgOut->redirect($mainPage . '?wiki-welcome=1');
 }
 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);
 }
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);
    }
}
Ejemplo n.º 7
0
 /**
  * Gets theme settings from following places:
  *  - theme designer ($wgOasisThemeSettings)
  *  - theme chosen using usetheme URL param
  */
 public static function getOasisSettings()
 {
     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-body-middle'] = self::sanitizeColor($settings['color-body-middle']);
         $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"] = $themeSettings->getBackgroundUrl();
         // sending width and height of background image to SASS
         if (!empty($settings['background-image-width']) && !empty($settings['background-image-height'])) {
             // strip 'px' from previously cached settings since we removed 'px' (sanity check)
             $oasisSettings['background-image-width'] = str_replace('px', '', $settings['background-image-width']);
             $oasisSettings['background-image-height'] = str_replace('px', '', $settings['background-image-height']);
         } else {
             // if not cached in theme settings
             $bgImage = wfFindFile(ThemeSettings::BackgroundImageName);
             if (!empty($bgImage)) {
                 $settings['background-image-width'] = $oasisSettings['background-image-width'] = $bgImage->getWidth();
                 $settings['background-image-height'] = $oasisSettings['background-image-height'] = $bgImage->getHeight();
                 $themeSettings->saveSettings($settings);
             }
         }
         $oasisSettings['background-dynamic'] = $settings['background-dynamic'];
         $oasisSettings['page-opacity'] = $settings['page-opacity'];
         if (!empty($settings['wordmark-font']) && $settings['wordmark-font'] != 'default') {
             $oasisSettings['wordmark-font'] = $settings['wordmark-font'];
         }
         // RTL
         if (self::isRTL()) {
             $oasisSettings['rtl'] = 'true';
         }
         wfRunHooks('AfterOasisSettingsInitialized', [&$oasisSettings]);
         // RT:70673
         foreach ($oasisSettings as $key => $val) {
             if (!empty($val)) {
                 $oasisSettings[$key] = trim($val);
             }
         }
     }
     wfDebug(__METHOD__ . ': ' . json_encode($oasisSettings) . "\n");
     wfProfileOut(__METHOD__);
     return $oasisSettings;
 }
 public function index()
 {
     if (self::$skipRendering) {
         return false;
     }
     $this->setupLoginLink();
     $themeSettings = new 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', $themeSettings->getWordmarkUrl());
     } else {
         $this->response->setVal('wikiName', !empty($settings['wordmark-text']) ? $settings['wordmark-text'] : $this->wg->SiteName);
     }
 }
Ejemplo n.º 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);
     }
 }
 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');
 }
Ejemplo n.º 11
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;
 }
 /**
  * Updates wiki specific properties set from wiki creation wizard.
  * Context of this method is on the wiki that the values are changing on.
  * Main wiki creation happens on www, and it will redirect to the newly created wiki.
  * The values are read from the session and only accessible by the admin.
  */
 public function FinishCreate()
 {
     global $wgUser, $wgSitename;
     if (!$wgUser->isAllowed('finishcreate')) {
         return false;
     }
     $this->skipRendering();
     global $wgOut;
     $this->LoadState();
     $mainPage = wfMsgForContent('mainpage');
     // set theme
     if (!empty($this->params['color-body'])) {
         $themeSettings = new ThemeSettings();
         $themeSettings->saveSettings($this->params);
     }
     // set description on main page
     if (!empty($this->params['wikiDescription'])) {
         $mainTitle = Title::newFromText($mainPage);
         $mainId = $mainTitle->getArticleID();
         $mainArticle = Article::newFromID($mainId);
         if (!empty($mainArticle)) {
             global $wgParser;
             $mainPageText = $mainArticle->getRawText();
             $matches = array();
             $description = $this->params['wikiDescription'];
             if (preg_match('/={2,3}[^=]+={2,3}/', $mainPageText, $matches)) {
                 $newSectionTitle = str_replace('Wiki', $wgSitename, $matches[0]);
                 $description = "{$newSectionTitle}\n{$description}";
             }
             $newMainPageText = $wgParser->replaceSection($mainPageText, 1, $description);
             $mainArticle->doEdit($newMainPageText, '');
         }
     }
     $wgOut->enableClientCache(false);
     $wgOut->redirect($mainPage . '?wiki-welcome=1');
 }
Ejemplo n.º 13
0
 public function executeIndex()
 {
     global $wgUser, $wgDevelEnvironment, $wgRequest, $wgCityId, $wgFavicon, $wgOut;
     wfProfileIn(__METHOD__);
     // String replacement logic taken from includes/Skin.php
     $this->wgFavicon = str_replace('images.wikia.com', 'images1.wikia.nocookie.net', $wgFavicon);
     $this->mainPageURL = Title::newMainPage()->getLocalURL();
     // add messages (fetch them using <script> tag)
     F::build('JSMessages')->enqueuePackage('Chat', JSMessages::EXTERNAL);
     // package defined in Chat_setup.php
     $this->jsMessagePackagesUrl = F::build('JSMessages')->getExternalPackagesUrl();
     // Variables for this user
     $this->username = $wgUser->getName();
     $this->avatarUrl = AvatarService::getAvatarUrl($this->username, ChatController::CHAT_AVATAR_DIMENSION);
     // Find the chat for this wiki (or create it, if it isn't there yet).
     $roomName = $roomTopic = "";
     $this->roomId = (int) NodeApiClient::getDefaultRoomId($roomName, $roomTopic);
     $this->roomName = $roomName;
     $this->roomTopic = $roomTopic;
     $this->chatkey = Chat::echoCookies();
     // Set the hostname of the node server that the page will connect to.
     $server = ChatHelper::getServer('Main');
     $this->nodePort = $server['port'];
     $this->nodeHostname = $server['host'];
     // Some building block for URLs that the UI needs.
     $this->pathToProfilePage = Title::makeTitle(!empty($this->wg->EnableWallExt) ? NS_USER_WALL : NS_USER_TALK, '$1')->getFullURL();
     $this->pathToContribsPage = SpecialPage::getTitleFor('Contributions', '$1')->getFullURL();
     $this->bodyClasses = "";
     if ($wgUser->isAllowed('chatmoderator')) {
         $this->isChatMod = 1;
         $this->bodyClasses .= ' chat-mod ';
     } else {
         $this->isChatMod = 0;
     }
     // Adding chatmoderator group for other users. CSS classes added to body tag to hide/show option in menu.
     $userChangeableGroups = $wgUser->changeableGroups();
     if (in_array('chatmoderator', $userChangeableGroups['add'])) {
         $this->bodyClasses .= ' can-give-chat-mod ';
     }
     $this->app->registerHook('MakeGlobalVariablesScript', 'ChatController', 'onMakeGlobalVariablesScript', array(), false, $this);
     $wgOut->getResourceLoader()->getModule('mediawiki');
     $ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
     $this->globalVariablesScript = $ret;
     //Theme Designer stuff
     $themeSettingObj = new ThemeSettings();
     $themeSettings = $themeSettingObj->getSettings();
     $this->themeSettings = $themeSettings;
     $this->wordmarkThumbnailUrl = '';
     if ($themeSettings['wordmark-type'] == 'graphic') {
         $title = Title::newFromText($themeSettings['wordmark-image-name'], NS_FILE);
         if ($title) {
             $image = wfFindFile($title);
             if ($image) {
                 $this->wordmarkThumbnailUrl = $image->createThumb(self::CHAT_WORDMARK_WIDTH, self::CHAT_WORDMARK_HEIGHT);
             }
         }
         if (empty($this->wordmarkThumbnailUrl)) {
             $this->wordmarkThumbnailUrl = WikiFactory::getLocalEnvURL($themeSettings['wordmark-image-url']);
         }
     }
     wfProfileOut(__METHOD__);
 }
Ejemplo n.º 14
0
 /**
  * Update theme settings
  *
  * @param array $settings array of settings
  * @param string $theme theme folder name
  * @param string $column 'value', 'default' or 'both'
  */
 public function updateThemeSettings($settings = array(), $theme = '', $column = 'value')
 {
     require_once LIBS . 'ThemeSettings.php';
     $themeSettings = new ThemeSettings();
     return $themeSettings->updateThemeSettings($this, $settings, $theme, $column);
 }
Ejemplo n.º 15
0
 /**
  * Update theme settings
  *
  * @param array $settings array of settings
  * @param string $theme theme folder name
  * @param string $column 'value', 'default' or 'both'
  */
 public function updateThemeSettings($settings = array(), $theme = '', $column = 'value')
 {
     $themeSettings = ThemeSettings::instance();
     return $themeSettings->updateThemeSettings($this, $settings, $theme, $column);
 }
Ejemplo n.º 16
0
 public static function set_theme_setting($setting_name, $value)
 {
     $return = false;
     if (ThemeSettings::has_setting($setting_name) != false) {
         $mods = self::_get_theme_mods_option();
         $old_value = isset($mods[$setting_name]) ? $mods[$setting_name] : false;
         /**
          * Filter the theme mod value on save.
          *
          * The dynamic portion of the hook name, `$name`, refers to the key name of
          * the modification array. For example, 'header_textcolor', 'header_image',
          * and so on depending on the theme options.
          *
          * @since 3.9.0
          *
          * @param string $value     The new value of the theme mod.
          * @param string $old_value The current value of the theme mod.
          */
         $mods[$setting_name] = apply_filters("pre_set_theme_mod_{$setting_name}", $value, $old_value);
         $theme = get_option('stylesheet');
         $result = update_option("theme_mods_{$theme}", $mods);
         if (!empty($result) && $old_value != $value) {
             $return = true;
         }
     }
     return $return;
 }
Ejemplo n.º 17
0
 public function executeIndex()
 {
     ChatHelper::info(__METHOD__ . ': Method called');
     global $wgUser, $wgFavicon, $wgOut, $wgHooks, $wgSitename;
     wfProfileIn(__METHOD__);
     // String replacement logic taken from includes/Skin.php
     $this->wgFavicon = str_replace('images.wikia.com', 'images1.wikia.nocookie.net', $wgFavicon);
     $this->mainPageURL = Title::newMainPage()->getLocalURL();
     // add messages (fetch them using <script> tag)
     JSMessages::enqueuePackage('Chat', JSMessages::EXTERNAL);
     // package defined in Chat_setup.php
     $this->jsMessagePackagesUrl = JSMessages::getExternalPackagesUrl();
     // Variables for this user
     $this->username = $wgUser->getName();
     $this->avatarUrl = AvatarService::getAvatarUrl($this->username, ChatController::CHAT_AVATAR_DIMENSION);
     // Find the chat for this wiki (or create it, if it isn't there yet).
     $this->roomId = (int) NodeApiClient::getDefaultRoomId();
     // we overwrite here data from redis since it causes a bug DAR-1532
     $this->roomName = $wgSitename;
     $this->roomTopic = wfMsg('chat-default-topic', $wgSitename);
     $this->chatkey = Chat::echoCookies();
     // Set the hostname of the node server that the page will connect to.
     $chathost = ChatHelper::getChatConfig('ChatHost');
     $server = explode(":", $chathost);
     $this->nodeHostname = $server[0];
     $this->nodePort = $server[1];
     $chatmain = ChatHelper::getServer('Main');
     $this->nodeInstance = $chatmain['serverId'];
     // Some building block for URLs that the UI needs.
     $this->pathToProfilePage = Title::makeTitle(!empty($this->wg->EnableWallExt) ? NS_USER_WALL : NS_USER_TALK, '$1')->getFullURL();
     $this->pathToContribsPage = SpecialPage::getTitleFor('Contributions', '$1')->getFullURL();
     $this->bodyClasses = "";
     if ($wgUser->isAllowed('chatmoderator')) {
         $this->isChatMod = 1;
         $this->bodyClasses .= ' chat-mod ';
     } else {
         $this->isChatMod = 0;
     }
     // Adding chatmoderator group for other users. CSS classes added to body tag to hide/show option in menu.
     $userChangeableGroups = $wgUser->changeableGroups();
     if (in_array('chatmoderator', $userChangeableGroups['add'])) {
         $this->bodyClasses .= ' can-give-chat-mod ';
     }
     // set up global js variables just for the chat page
     $wgHooks['MakeGlobalVariablesScript'][] = array($this, 'onMakeGlobalVariablesScript');
     $wgOut->getResourceLoader()->getModule('mediawiki');
     $ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
     $this->globalVariablesScript = $ret;
     //Theme Designer stuff
     $themeSettingObj = new ThemeSettings();
     $themeSettings = $themeSettingObj->getSettings();
     $this->themeSettings = $themeSettings;
     $this->wordmarkThumbnailUrl = '';
     if ($themeSettings['wordmark-type'] == 'graphic') {
         $title = Title::newFromText($themeSettings['wordmark-image-name'], NS_FILE);
         if ($title) {
             $image = wfFindFile($title);
             if ($image) {
                 $this->wordmarkThumbnailUrl = $image->createThumb(self::CHAT_WORDMARK_WIDTH, self::CHAT_WORDMARK_HEIGHT);
             }
         }
         if (empty($this->wordmarkThumbnailUrl)) {
             $this->wordmarkThumbnailUrl = WikiFactory::getLocalEnvURL($themeSettings['wordmark-image-url']);
         }
     }
     // CONN-436: Invalidate Varnish cache for ChatRail:GetUsers
     ChatRailController::purgeMethod('GetUsers', ['format' => 'json']);
     wfProfileOut(__METHOD__);
 }
Ejemplo n.º 18
0
 /**
  * @param $title Title
  * @param bool $isArticleDeleted
  */
 private static function resetThemeBackgroundSettings($title, $isArticleDeleted = false)
 {
     wfProfileIn(__METHOD__);
     if ($title instanceof Title && $title->getText() == ThemeSettings::BackgroundImageName) {
         $themeSettings = new ThemeSettings();
         $settings = $themeSettings->getSettings();
         if (strpos($settings['background-image'], ThemeSettings::BackgroundImageName) !== false) {
             $settings['background-image-width'] = null;
             $settings['background-image-height'] = null;
             if ($isArticleDeleted) {
                 $settings['background-image'] = '';
                 $settings['user-background-image'] = '';
                 $settings['user-background-image-thumb'] = '';
             }
         }
         $themeSettings->saveSettings($settings);
     }
     wfProfileOut(__METHOD__);
 }
Ejemplo n.º 19
0
 /**
  * Defines the theme option metabox and field configuration
  * @since  0.1.0
  * @return array
  */
 public static function option_fields()
 {
     // Only need to initiate the array once per page-load
     if (!empty(self::$theme_options)) {
         return self::$theme_options;
     }
     self::$theme_options = array('id' => 'theme_options', 'show_on' => array('key' => 'options-page', 'value' => array(self::$key)), 'show_names' => true, 'fields' => array(array('name' => __('Place Name', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => 'place_name', 'type' => 'text_medium'), array('name' => __('City', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => 'city_name', 'type' => 'text_medium'), array('name' => __('Phone number', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => 'phone', 'type' => 'text_medium'), array('name' => __('place address', 'bookingwp'), 'desc' => __('es via roma 10, 00100 Roma', 'bookingwp'), 'id' => 'place_address', 'type' => 'text_medium'), array('name' => __('email', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => 'email', 'type' => 'text_email'), array('name' => __('Facebook page URL', 'cmb'), 'id' => $prefix . 'facebook_url', 'type' => 'text_url'), array('name' => __('Twitter URL', 'cmb'), 'id' => $prefix . 'twitter_url', 'type' => 'text_url'), array('name' => __('Test Color Picker', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => 'test_colorpicker', 'type' => 'colorpicker', 'default' => '#ffffff'), array('name' => __('Footer Text', 'bookingwp'), 'desc' => __('field description (optional)', 'bookingwp'), 'id' => 'footer_text', 'type' => 'text'), array('name' => __('Amenities IT', 'bookingwp'), 'desc' => __('servizi (separati da virgola)', 'bookingwp'), 'id' => 'custom_services_list_it', 'type' => 'text'), array('name' => __('Amenities EN', 'bookingwp'), 'desc' => __('servizi (separati da virgola)', 'bookingwp'), 'id' => 'custom_services_list_en', 'type' => 'text')));
     return self::$theme_options;
 }
 public function executeSaveSettings()
 {
     global $wgRequest;
     wfProfileIn(__METHOD__);
     $data = $wgRequest->getArray('settings');
     $themeSettings = new ThemeSettings();
     $themeSettings->saveSettings($data);
     wfProfileOut(__METHOD__);
 }
 public function executeSaveSettings()
 {
     wfProfileIn(__METHOD__);
     global $wgRequest;
     // check rights
     if (!ThemeDesignerHelper::checkAccess()) {
         $this->displayRestrictionError(__METHOD__);
     }
     $data = $wgRequest->getArray('settings');
     if ($wgRequest->wasPosted()) {
         $themeSettings = new ThemeSettings();
         $themeSettings->saveSettings($data);
     }
     wfProfileOut(__METHOD__);
 }