Iran
|
use this functions:
writetocsscache, file cache_styles.php- function writetocsscache($data) {
- global $_G;
- $cssdir = ($_G[langdir] == "ltr") ? "" : "_rtl" ;
- $dir = DISCUZ_ROOT.'./template/default/common/';
- $dh = opendir($dir);
- $data['staticurl'] = STATICURL;
- while(($entry = readdir($dh)) !== false) {
- if(fileext($entry) == 'css') {
- $cssfile = DISCUZ_ROOT.'./'.$data['tpldir'].'/common/'.$entry;
- !file_exists($cssfile) && $cssfile = $dir.$entry;
- $cssdata = @implode('', file($cssfile));
- if(file_exists($cssfile = DISCUZ_ROOT.'./'.$data['tpldir'].'/common/extend_'.$entry)) {
- $cssdata .= @implode('', file($cssfile));
- }
- if(is_array($_G['setting']['plugins']['available']) && $_G['setting']['plugins']['available']) {
- foreach($_G['setting']['plugins']['available'] as $plugin) {
- if(file_exists($cssfile = DISCUZ_ROOT.'./source/plugin/'.$plugin.'/template/extend_'.$entry)) {
- $cssdata .= @implode('', file($cssfile));
- }
- }
- }
- $cssdata = preg_replace("/\{([A-Z0-9]+)\}/e", '\$data[strtolower(\'\1\')]', $cssdata);
- $cssdata = preg_replace("/<\?.+?\?>\s*/", '', $cssdata);
- $cssdata = !preg_match('/^http:\/\//i', $data['styleimgdir']) ? preg_replace("/url\((["'])?".preg_quote($data['styleimgdir'], '/')."/i", "url(\\1../../$data[styleimgdir]", $cssdata) : $cssdata;
- $cssdata = !preg_match('/^http:\/\//i', $data['imgdir']) ? preg_replace("/url\((["'])?".preg_quote($data['imgdir'], '/')."/i", "url(\\1../../$data[imgdir]", $cssdata) : $cssdata;
- $cssdata = !preg_match('/^http:\/\//i', $data['staticurl']) ? preg_replace("/url\((["'])?".preg_quote($data['staticurl'], '/')."/i", "url(\\1../../$data[staticurl]", $cssdata) : $cssdata;
- if($entry == 'module.css' || $entry == 'module_rtl.css') {
- $cssdata = preg_replace('/\/\*\*\s*(.+?)\s*\*\*\//', '[\\1]', $cssdata);
- }
- $cssdata = preg_replace(array('/\s*([,;:\{\}])\s*/', '/[\t\n\r]/', '/\/\*.+?\*\//'), array('\\1', '',''), $cssdata);
- if(@$fp = fopen(DISCUZ_ROOT.'./data/cache/style_'.$data['styleid'].'_'.$entry, 'w')) {
- fwrite($fp, $cssdata);
- fclose($fp);
- } else {
- exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
- }
- }
- }
- }
Copy the Code loadcsstemplate, file class_template.php- function loadcsstemplate() {
- global $_G;
- $cssdir = ($_G[langdir] == "ltr") ? "" : "_rtl" ;
- $scriptcss = '<link rel="stylesheet" type="text/css" href="data/cache/style_{STYLEID}_common'.$cssdir.'.css?{VERHASH}" />';
- $content = $this->csscurmodules = '';
- $content = @implode('', file(DISCUZ_ROOT.'./data/cache/style_'.STYLEID.'_module'.$cssdir.'.css'));
- $content = preg_replace("/\[(.+?)\](.*?)\[end\]/ies", "\$this->cssvtags('\\1','\\2')", $content);
- if($this->csscurmodules) {
- $this->csscurmodules = preg_replace(array('/\s*([,;:\{\}])\s*/', '/[\t\n\r]/', '/\/\*.+?\*\//'), array('\\1', '',''), $this->csscurmodules);
- if(@$fp = fopen(DISCUZ_ROOT.'./data/cache/style_'.STYLEID.'_'.$_G['basescript'].'_'.CURMODULE.$cssdir.'.css', 'w')) {
- fwrite($fp, $this->csscurmodules);
- fclose($fp);
- } else {
- exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
- }
- $scriptcss .= '<link rel="stylesheet" type="text/css" href="data/cache/style_{STYLEID}_'.$_G['basescript'].'_'.CURMODULE.$cssdir.'.css?{VERHASH}" />';
- }
- $scriptcss .= '{if $_G[uid] && isset($_G[cookie][extstyle]) && strpos($_G[cookie][extstyle], TPLDIR) !== false}<link rel="stylesheet" id="css_extstyle" type="text/css" href="$_G[cookie][extstyle]/style.css" />{elseif $_G[style][defaultextstyle]}<link rel="stylesheet" id="css_extstyle" type="text/css" href="$_G[style][defaultextstyle]/style.css" />{/if}';
- return $scriptcss;
- }
Copy the Code this functions work as your rules:
LTR CSS:
common.css
...
RTL CSS:
common_rtl.css
|
|