/**
  * @see	\wcf\action\IAction::execute();
  */
 public function execute()
 {
     parent::execute();
     // header
     @header('Content-type: text/xml');
     // file name
     @header('Content-disposition: attachment; filename="options.xml"');
     // no cache headers
     @header('Pragma: no-cache');
     @header('Expires: 0');
     // content
     echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<options>\n";
     $options = Option::getOptions();
     foreach ($options as $option) {
         if ($option->hidden) {
             continue;
         }
         // ignore hidden options
         echo "\t<option>\n";
         echo "\t\t<name><![CDATA[" . StringUtil::escapeCDATA($option->optionName) . "]]></name>\n";
         echo "\t\t<value><![CDATA[" . StringUtil::escapeCDATA($option->optionValue) . "]]></value>\n";
         echo "\t</option>\n";
     }
     echo '</options>';
     $this->executed();
     exit;
 }
Esempio n. 2
0
 /**
  * Rebuilds the option file.
  */
 public static function rebuild()
 {
     $writer = new AtomicWriter(WCF_DIR . 'options.inc.php');
     // file header
     $writer->write("<?php\n/**\n* generated at " . gmdate('r') . "\n*/\n");
     // get all options
     $options = Option::getOptions();
     foreach ($options as $optionName => $option) {
         $writer->write("if (!defined('" . $optionName . "')) define('" . $optionName . "', " . ($option->optionType == 'boolean' || $option->optionType == 'integer' ? intval($option->optionValue) : "'" . addcslashes($option->optionValue, "'\\") . "'") . ");\n");
     }
     unset($options);
     // file footer
     $writer->write("\n");
     $writer->flush();
     $writer->close();
     FileUtil::makeWritable(WCF_DIR . 'options.inc.php');
     WCF::resetZendOpcache(WCF_DIR . 'options.inc.php');
 }
Esempio n. 3
0
	/**
	 * Rebuilds the option file.
	 */
	public static function rebuild() {
		$buffer = '';
		
		// file header
		$buffer .= "<?php\n/**\n* generated at ".gmdate('r')."\n*/\n";
		
		// get all options
		$options = Option::getOptions();
		foreach ($options as $optionName => $option) {
			$buffer .= "if (!defined('".$optionName."')) define('".$optionName."', ".(($option->optionType == 'boolean' || $option->optionType == 'integer') ? intval($option->optionValue) : "'".addcslashes($option->optionValue, "'\\")."'").");\n";
		}
		unset($options);
		
		// file footer
		$buffer .= "\n";
		
		// open file
		$file = new File(WCF_DIR.'options.inc.php');
		
		// write buffer
		$file->write($buffer);
		
		// close file
		$file->close();
		@$file->chmod(0777);
	}
Esempio n. 4
0
 /**
  * Compiles LESS stylesheets into one CSS-stylesheet and writes them
  * to filesystem. Please be aware not to append '.css' within $filename!
  * 
  * @param	string			$filename
  * @param	array<string>		$files
  * @param	array<string>		$variables
  * @param	string			$individualLess
  * @param	\wcf\system\Callback	$callback
  */
 protected function compileStylesheet($filename, array $files, array $variables, $individualLess, Callback $callback)
 {
     foreach ($variables as &$value) {
         if (StringUtil::startsWith($value, '../')) {
             $value = '~"' . $value . '"';
         }
     }
     unset($value);
     // add options as LESS variables
     if (PACKAGE_ID) {
         foreach (Option::getOptions() as $constantName => $option) {
             if (in_array($option->optionType, static::$supportedOptionType)) {
                 $variables['wcf_option_' . mb_strtolower($constantName)] = '~"' . $option->optionValue . '"';
             }
         }
     } else {
         // workaround during setup
         $variables['wcf_option_attachment_thumbnail_height'] = '~"210"';
         $variables['wcf_option_attachment_thumbnail_width'] = '~"280"';
         $variables['wcf_option_signature_max_image_height'] = '~"150"';
     }
     // build LESS bootstrap
     $less = $this->bootstrap($variables);
     foreach ($files as $file) {
         $less .= $this->prepareFile($file);
     }
     // append individual CSS/LESS
     if ($individualLess) {
         $less .= $individualLess;
     }
     try {
         $content = $this->compiler->compile($less);
     } catch (\Exception $e) {
         throw new SystemException("Could not compile LESS: " . $e->getMessage(), 0, '', $e);
     }
     $content = $callback($content);
     // compress stylesheet
     $lines = explode("\n", $content);
     $content = $lines[0] . "\n" . $lines[1] . "\n";
     for ($i = 2, $length = count($lines); $i < $length; $i++) {
         $line = trim($lines[$i]);
         $content .= $line;
         switch (substr($line, -1)) {
             case ',':
                 $content .= ' ';
                 break;
             case '}':
                 $content .= "\n";
                 break;
         }
         if (substr($line, 0, 6) == '@media') {
             $content .= "\n";
         }
     }
     // write stylesheet
     file_put_contents($filename . '.css', $content);
     FileUtil::makeWritable($filename . '.css');
     // convert stylesheet to RTL
     $content = StyleUtil::convertCSSToRTL($content);
     // write stylesheet for RTL
     file_put_contents($filename . '-rtl.css', $content);
     FileUtil::makeWritable($filename . '-rtl.css');
 }
Esempio n. 5
0
 /**
  * Rebuilds cached options
  *
  * @param 	string 		filename
  * @param	integer		$packageID
  */
 public static function rebuildFile($filename, $packageID = PACKAGE_ID)
 {
     $buffer = '';
     // file header
     $buffer .= "<?php\n/**\n* generated at " . gmdate('r') . "\n*/\n";
     // get all options
     $options = Option::getOptions($packageID);
     foreach ($options as $optionName => $option) {
         $buffer .= "if (!defined('" . $optionName . "')) define('" . $optionName . "', " . ($option['optionType'] == 'boolean' || $option['optionType'] == 'integer' ? intval($option['optionValue']) : "'" . addcslashes($option['optionValue'], "'\\") . "'") . ");\n";
     }
     unset($options);
     // file footer
     $buffer .= "?>";
     // open file
     $file = new File($filename);
     // write buffer
     $file->write($buffer);
     unset($buffer);
     // close file
     $file->close();
     @$file->chmod(0777);
 }
Esempio n. 6
0
 /**
  * Compiles LESS stylesheets.
  * 
  * @param	\cms\data\stylesheet\Stylesheet		$stylesheet
  * @param	integer					$styleID
  */
 public function compile(Stylesheet $stylesheet, $styleID = null)
 {
     $styles = StyleHandler::getInstance()->getStyles();
     // compile stylesheet for all installed styles
     if ($styleID === null) {
         foreach ($styles as $style) {
             $this->compile($stylesheet, $style->styleID);
         }
         return;
     }
     $style = $styles[$styleID];
     // get style variables
     $variables = $style->getVariables();
     if (isset($variables['individualLess'])) {
         unset($variables['individualLess']);
     }
     // add style image path
     $imagePath = '../images/';
     if ($style->imagePath) {
         $imagePath = FileUtil::getRelativePath(WCF_DIR . 'style/', WCF_DIR . $style->imagePath);
         $imagePath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($imagePath));
     }
     $variables['style_image_path'] = "'{$imagePath}'";
     // apply overrides
     if (isset($variables['overrideLess'])) {
         $lines = explode("\n", StringUtil::unifyNewlines($variables['overrideLess']));
         foreach ($lines as $line) {
             if (preg_match('~^@([a-zA-Z]+): ?([@a-zA-Z0-9 ,\\.\\(\\)\\%\\#-]+);$~', $line, $matches)) {
                 $variables[$matches[1]] = $matches[2];
             }
         }
         unset($variables['overrideLess']);
     }
     // add options as LESS variables
     foreach (Option::getOptions() as $constantName => $option) {
         if (in_array($option->optionType, array('boolean', 'integer'))) {
             $variables['wcf_option_' . mb_strtolower($constantName)] = '~"' . $option->optionValue . '"';
         }
     }
     // compile
     $this->compiler->setVariables($variables);
     $content = "/* stylesheet for '" . $stylesheet->getTitle() . "', generated on " . gmdate('r') . " -- DO NOT EDIT */\n\n";
     $content .= $this->compiler->compile($stylesheet->less);
     // compress stylesheet
     $lines = explode("\n", $content);
     $content = $lines[0] . "\n" . $lines[1] . "\n";
     for ($i = 2, $length = count($lines); $i < $length; $i++) {
         $line = trim($lines[$i]);
         $content .= $line;
         switch (substr($line, -1)) {
             case ',':
                 $content .= ' ';
                 break;
             case '}':
                 $content .= "\n";
                 break;
         }
         if (substr($line, 0, 6) == '@media') {
             $content .= "\n";
         }
     }
     // write stylesheet
     $filename = $stylesheet->getLocation($styleID);
     file_put_contents($filename, $content);
     FileUtil::makeWritable($filename);
     // write rtl stylesheet
     $content = StyleUtil::convertCSSToRTL($content);
     $filename = $stylesheet->getLocation($styleID, true);
     file_put_contents($filename, $content);
     FileUtil::makeWritable($filename);
 }
Esempio n. 7
0
 public function getApiKey()
 {
     $options = Option::getOptions();
     return $options['WBB_TAPATALK_API_KEY']->optionValue;
 }