diff --git a/common.php b/common.php index 82847dfc6..a1c2fa1a1 100644 --- a/common.php +++ b/common.php @@ -489,4 +489,6 @@ header('Last-Modified: ' . $gmnow); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Pragma: no-cache'); // HTTP/1.0 + +$html_process = new html_process(); ?> \ No newline at end of file diff --git a/lib/common.lib.php b/lib/common.lib.php index 1891e2495..29c7e7b01 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -2170,30 +2170,41 @@ if (!function_exists('file_put_contents')) { // HTML 마지막 처리 function html_end() { - $end = new html_process(); - return $end->run(); + global $html_process; + + return $html_process->run(); +} + +function add_stylesheet($stylesheet, $order=0) +{ + global $html_process; + + if(trim($stylesheet)) + $html_process->merge_stylesheet($stylesheet, $order); } class html_process { - protected $links = array(); + protected $css = array(); - function css_callback1($m) { - $s = $m[0]; - if(preg_match('/]+>/i', $s)) { - preg_match_all("/(]+>)|(]+>)/is", $s, $m); - $this->links = array_merge($this->links, $m[0]); + function merge_stylesheet($stylesheet, $order) + { + $links = $this->css; + $is_merge = true; + + foreach($links as $link) { + if($link[1] == $stylesheet) { + $is_merge = false; + break; + } } - return ''; - } - function css_callback2($m) { - $this->links = array_merge($this->links, array($m[0])); - return ''; + if($is_merge) + $this->css[] = array($order, $stylesheet); } function run() { - global $config, $g5, $member, $css; + global $config, $g5, $member; // 현재접속자 처리 $tmp_sql = " select count(*) as cnt from {$g5['login_table']} where lo_ip = '{$_SERVER['REMOTE_ADDR']}' "; @@ -2214,28 +2225,29 @@ class html_process { //if ($row['Data_free'] > 0) sql_query(" OPTIMIZE TABLE $g5['login_table'] "); } - // 버퍼의 내용에서 body 태그 중간의 외부 css 파일을 CAPTURE 하여 head 태그로 이동시켜준다. $buffer = ob_get_contents(); ob_end_clean(); - preg_match('#
(.*)#is', $buffer, $bodys); - - $bodys = preg_replace_callback("//is", 'html_process::css_callback1', $bodys); - $bodys = preg_replace_callback("//is", 'html_process::css_callback2', $bodys); - $bodys = preg_replace_callback("/]+>/is", 'html_process::css_callback2', $bodys); - - $links = array_unique($this->links); $stylesheet = ''; + $links = $this->css; - foreach($links as $link) { - if(!trim($link)) - continue; + if(!empty($links)) { + foreach ($links as $key => $row) { + $order[$key] = $row[0]; + $index[$key] = $key; + $style[$key] = $row[1]; + } - if(preg_match('/]+>/i', $link)) - $buffer = preg_replace('#'.$link.'#', '', $buffer); + array_multisort($order, SORT_ASC, $index, SORT_ASC, $links); - $stylesheet .= PHP_EOL.$link; + foreach($links as $link) { + if(!trim($link[1])) + continue; + + $stylesheet .= PHP_EOL.$link[1]; + } } + /* diff --git a/mobile/skin/board/basic/list.skin.php b/mobile/skin/board/basic/list.skin.php index 7d2d690aa..5b72909c1 100644 --- a/mobile/skin/board/basic/list.skin.php +++ b/mobile/skin/board/basic/list.skin.php @@ -7,9 +7,10 @@ $colspan = 5; if ($is_checkbox) $colspan++; if ($is_good) $colspan++; if ($is_nogood) $colspan++; -?> - +// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 +add_stylesheet('', 0); +?>