$path = RouteHandler::getPath();
self::getTPL()->assign(array(
- 'baseHref' => $host . $path,
- 'quickAccessPackages' => $this->getQuickAccessPackages(),
- // todo: 'timezone' => \wcf\util\DateUtil::getTimezone()
+ 'baseHref' => $host . $path
));
}
}
}
- /**
- * Returns a list of all installed applications packages.
- *
- * @return array
- */
- protected function getQuickAccessPackages() {
- $quickAccessPackages = array();
- foreach (PackageCacheBuilder::getInstance()->getData(array(), 'packages') as $packageID => $package) {
- if (!$package->isApplication) break;
- if ($package->package != 'com.woltlab.wcf') {
- $quickAccessPackages[] = $package;
- }
- }
-
- return $quickAccessPackages;
- }
-
/**
* Checks whether the active user has entered the valid master password.
*/
/**
* Returns the HTML tag to include current stylesheet.
*
- * @todo Add RTL support
- *
* @return string
*/
public function getStylesheet() {
if (RequestHandler::getInstance()->isACPRequest()) {
// ACP
- $filename = 'acp/style/style.css';
+ $filename = 'acp/style/style'.(WCF::getLanguage()->get('wcf.global.pageDirection') == 'rtl' ? '-rtl' : '').'.css';
if (!file_exists(WCF_DIR.$filename)) {
StyleCompiler::getInstance()->compileACP();
}
}
else {
// frontend
- $filename = 'style/style-'.$this->getStyle()->styleID.'.css';
+ $filename = 'style/style-'.$this->getStyle()->styleID.(WCF::getLanguage()->get('wcf.global.pageDirection') == 'rtl' ? '-rtl' : '').'.css';
if (!file_exists(WCF_DIR.$filename)) {
StyleCompiler::getInstance()->compile($this->getStyle()->getDecoratedObject());
}
return $newFileName;
}
- /**
- * Strips supernumerous BOMs from a given bytestream.
- *
- * If we are dealing with bytestreams being pushed from one program or script to another in a UTF-8
- * environment, we might encounter problems with BOMs (Byte Order Marks). E.g., if there's a script
- * that reads a .tar file via readfile(), and this script is encoded in UTF-8, and being called from another
- * script which wants to handle the bytestream that results from readfile(). But apparently because of the
- * UTF-8 encoding of the called script -- at least in some PHP versions -- readfile() adds a UTF-8 BOM
- * at the beginning of the bytestream. If we do write this bytestream to disk and then try to open the
- * resulting file, we will get an error because it is no more a valid .tar archive. The same thing happens
- * if we handle an .xml file and then try to parse it.
- * So, if bytestreams are being handled in a UTF-8 environment, be sure always to use this function
- * before writing the bytestream to disk or trying to parse it with an xml parser.
- * This works regardless of multibyte string support (mb_strpos and friends) being enabled or not.
- *
- * Btw, if you try to apply the following to a bytestream read from a .tar file,
- * you will end up with a file sized zero bytes:
- * while (($byte = fgetc($fileHandle)) !== false) {
- * fwrite($fileHandle, $byte);
- * }
- *
- * @param string $sourceContent
- * @param string $characterEncoding
- * @return string destinationContent
- */
- public static function stripBoms($sourceContent = '', $characterEncoding = 'UTF-8') {
- try {
- // TODO: implement recognition of other BOMs (UTF-7, UTF-16 big endian, UTF-16 little endian etc.)
- if ($characterEncoding == 'UTF-8') {
- // get the ASCII codes for the three bytes the UTF-8 BOM is consisting of.
- $firstByte = intval(0xEF);
- $secondByte = intval(0xBB);
- $thirdByte = intval(0xBF);
- }
- else {
- return $sourceContent;
- }
-
- // put the bytestream's first three bytes to an array.
- $workArray = unpack('C3', $sourceContent);
- if (!is_array($workArray)) {
- throw new SystemException("Unable to process bytestream.");
- }
-
- // detect the UTF-8 BOM.
- if (($workArray['1'] == $firstByte) && ($workArray['2'] == $secondByte) && ($workArray['3'] == $thirdByte)) {
- $tmpname = self::getTemporaryFilename('stripBoms_');
- $tmpStream = fopen($tmpname, 'w+');
- fwrite($tmpStream, $sourceContent);
- rewind($tmpStream);
-
- // cut off the BOM.
- fseek($tmpStream, 3); // compatibility for PHP < 5.1.0
- $destinationContent = stream_get_contents($tmpStream);
- fclose($tmpStream);
- @unlink($tmpname);
-
- return $destinationContent;
- }
- else {
- return $sourceContent;
- }
- }
- catch (SystemException $e) {
- // clean up
- if (isset($tmpname) && file_exists($tmpname)) @unlink($tmpname);
-
- throw $e;
- }
- }
-
/**
* Determines whether a file is text or binary by checking the first few bytes in the file.
* The exact number of bytes is system dependent, but it is typically several thousand.