/** * 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'); }
/** * 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; }
/** * 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'); }
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__); }
/** * @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__); }
public function executeSaveSettings() { global $wgRequest; wfProfileIn(__METHOD__); $data = $wgRequest->getArray('settings'); $themeSettings = new ThemeSettings(); $themeSettings->saveSettings($data); wfProfileOut(__METHOD__); }