public static function format_header($aConfig, $sNewId)
 {
     $aReturn = array();
     BsConfig::set("MW::Flexiskin::Logo", $aConfig->logo);
     BsConfig::saveSettings();
     wfRunHooks("BSFlexiskinFormatterHeader", array(&$aConfig, &$aReturn));
     return implode(" \n", $aReturn);
 }
 /**
  * saves the settings to the database
  * @param array $aData an associative array of fieldnames and values
  */
 public function savePreferences($aData)
 {
     if (wfReadOnly()) {
         $url = SpecialPage::getTitleFor('WikiAdmin')->getFullURL(array('mode' => 'Preferences', 'success' => 0));
         $this->getOutput()->redirect($url);
         return false;
     }
     $vars = BsConfig::getRegisteredVars();
     foreach ($vars as $var) {
         $options = $var->getOptions();
         if (!($options & (BsConfig::LEVEL_PUBLIC | BsConfig::LEVEL_USER))) {
             continue;
         }
         if ($options & BsConfig::NO_DEFAULT) {
             continue;
         }
         $name = $this->generateFieldId($var);
         $value = isset($aData[$name]) ? $aData[$name] : NULL;
         if ($var->getOptions() & BsConfig::TYPE_BOOL && $value == NULL) {
             BsConfig::set($var->getKey(), 0, true);
         }
         $bReturn = true;
         wfRunHooks('BSWikiAdminPreferencesBeforeSetVariable', array($this, &$var, &$value, &$bReturn));
         if ($value !== null && $bReturn !== false) {
             BsConfig::set($var->getKey(), $value, true);
         }
     }
     BsConfig::saveSettings();
     $url = SpecialPage::getTitleFor('WikiAdmin')->getFullURL(array('mode' => 'Preferences', 'success' => 1));
     $this->getOutput()->redirect($url);
     return false;
 }
 /**
  * Activates the Flexiskin defined by id via request parameter
  * @return String encoded result JSON string
  */
 public function activateFlexiskin()
 {
     $sId = $this->getMain()->getVal('id', '');
     BsConfig::set("MW::Flexiskin::Active", $sId);
     BsConfig::saveSettings();
     return FormatJson::encode(array('success' => true));
 }
 /**
  * Hook handler for UserLoadOptions
  * @param User $user User whose options are being modified.
  * @param Array &$options Options array
  * @return true always true to keep hook alive
  */
 public static function onUserLoadOptions($user, &$options)
 {
     foreach ($options as $key => $value) {
         if (strpos($key, 'MW::') !== 0) {
             continue;
         }
         if (BsStringHelper::isSerialized($value)) {
             $options[$key] = unserialize($value);
         }
         BsConfig::set($key, $options[$key], true);
     }
     return true;
 }
 /**
  * Assembles the overall configuration for VisualEditor. This consists of
  * - TinyMCE consig standard:
  * - TinyMCE config overwrite:
  * - ResourceLoader dependencies:
  *
  * It is intentionally 'public' to allow other extensions to create and
  * modify their own configs and to create own TinyMCE instances
  * @param Parser $oParser
  * @param string $sLangCode
  * @return array
  */
 public function makeConfig($oParser, $sLangCode = null)
 {
     if ($sLangCode == null) {
         $sLangCode = $this->getLanguage()->getCode();
     }
     $aConfigs = array('standard' => $this->aConfigStandard + array('specialtaglist' => '', 'extended_valid_elements' => ''), 'overwrite' => $this->aConfigOverwrite, 'module_deps' => array('ext.bluespice'));
     $aExtensionTags = $oParser->getTags();
     //TODO: Use, or at least fall back to API "action=query&meta=siteinfo&siprop=extensiontags"
     $sAllowedTags = '';
     $sSpecialTags = '';
     foreach ($aExtensionTags as $sTagName) {
         if ($sTagName == 'pre') {
             continue;
         }
         $sAllowedTags .= $sTagName . '[*],';
         if ($sTagName == 'nowiki') {
             continue;
         }
         $sSpecialTags .= $sTagName . '|';
     }
     $sAllowedTags .= 'div[*],';
     //This is a bad place...
     BsConfig::set('MW::VisualEditor::SpecialTags', $sSpecialTags);
     BsConfig::set('MW::VisualEditor::AllowedTags', $sAllowedTags);
     $aDefaultTags = array("includeonly", "onlyinclude", "noinclude", "gallery", "code", "presentation", "backlink", "math", "video");
     $aConfigs['standard']["specialtaglist"] = $sSpecialTags . implode('|', $aDefaultTags);
     $aConfigs['standard']["extended_valid_elements"] = $sAllowedTags . implode('[*],', $aDefaultTags);
     //Find the right language file
     $sLangDir = __DIR__ . '/resources/tinymce/langs';
     if (!file_exists("{$sLangDir}/{$sLangCode}.js")) {
         //I don't know what language files use underscores, but I'll leave it here
         $aLanguage = explode('_', $sLangCode);
         if (count($aLanguage) < 2) {
             $aLanguage = explode('-', $sLangCode);
         }
         if (file_exists("{$sLangDir}/{$aLanguage[0]}.js")) {
             $sLangCode = $aLanguage[0];
         } else {
             $sLangCode = 'en';
         }
     }
     $aConfigs['standard']['language'] = $sLangCode;
     // TODO SW: use string flag as parameter to allow hookhandler to
     // determin context. This will be usefull if hook gets called in
     // another place
     wfRunHooks('VisualEditorConfig', array(&$aConfigs['standard'], &$aConfigs['overwrite'], &$aConfigs['module_deps']));
     foreach ($aConfigs['standard']['style_formats'] as &$aStyles) {
         foreach ($aStyles as $key => &$val) {
             if ($key === "title") {
                 $oMsg = wfMessage($val);
                 if ($oMsg->exists()) {
                     $val = $oMsg->plain();
                 }
             }
             if ($key === "items" && is_array($val)) {
                 foreach ($val as &$item) {
                     $oMsg = wfMessage($item['title']);
                     if ($oMsg->exists()) {
                         $item['title'] = $oMsg->plain();
                     }
                 }
             }
         }
     }
     $aConfigs['standard'] = $this->_prepareConfig($aConfigs['standard']);
     $aConfigs['overwrite'] = $this->_prepareConfig($aConfigs['overwrite']);
     return $aConfigs;
 }
 public static function disableFeedback()
 {
     $oResult = (object) array('success' => false, 'message' => '');
     if (BsCore::checkAccessAdmission('edit') === false) {
         //PW TODO: add error message
         return FormatJson::encode($oResult);
     }
     BsConfig::set('MW::BlueSpiceProjectFeedbackHelper::Active', false);
     BsConfig::saveSettings();
     $oResult->success = true;
     return FormatJson::encode($oResult);
 }