일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- html
- API
- CI3
- config
- mysql
- function
- 영카트
- FCM
- CodeIgniter
- php
- 웹 프로그래밍
- ajax
- phpDocumentor
- APK
- 헬퍼
- codeigniter3
- 옵션표
- rairen
- 코드이그나이터
- 라이렌
- MSsql
- 설정
- 그누보드
- jquery
- 안드로이드
- javascript
- Database
- jw player
- 후크
- 함수
Archives
- Today
- Total
프로그램 개발서
responsive css ... 본문
if (! function_exists('directory_map')) {
/**
* 디렉토리 맵 생성
*
* 지정된 디렉터리를 읽고 해당 디렉터리의 배열 표현을 만듭니다.
* 디렉터리에 포함된 하위 폴더도 매핑됩니다.
*
* @param string $source_dir 소스 경로
* @param int $directory_depth 탐색할 디렉터리의 깊이
* (0 = 완전 재귀,, 1 = 현재 디렉토리, 기타)
* @param bool $hidden 숨겨진 파일 표시 여부
* @return array
*/
function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
{
if ($fp = @opendir($source_dir)) {
$filedata = array();
$new_depth = $directory_depth - 1;
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
while (FALSE !== ($file = readdir($fp))) {
// Remove '.', '..', and hidden files [optional]
if ($file === '.' or $file === '..' or ($hidden === FALSE && $file[0] === '.')) {
continue;
}
is_dir($source_dir . $file) && $file .= DIRECTORY_SEPARATOR;
if (($directory_depth < 1 or $new_depth > 0) && is_dir($source_dir . $file)) {
$filedata[$file] = directory_map($source_dir . $file, $new_depth, $hidden);
} else {
$filedata[] = $file;
}
}
closedir($fp);
return $filedata;
}
return FALSE;
}
}
// 2024년 12월 13일 반응형을 위한 스타일 추가
$isResponsiveStylesheetIntegration = true; // 파일을 나눌지 말지 구분
$isMin = true; // min 방식
$isMax = true; // max
const EYOOM_THEME_CSS_RESPONSIVE_PATH = EYOOM_THEME_PATH . "/css/responsive";
const EYOOM_THEME_CSS_RESPONSIVE_URL = EYOOM_THEME_URL . "/css/responsive";
$map = directory_map(EYOOM_THEME_CSS_RESPONSIVE_PATH, 1);
$min = [];
$max = [];
// 테마 css 폴더 내 반응형 폴더 맵
foreach($map as $name){
// 프린트 파일은 그냥 출력
if(strpos($name, 'print.css') !== false){
// <link rel="stylesheet" href="print.css" media="print">
add_stylesheet('<link rel="stylesheet" href="'.EYOOM_THEME_CSS_RESPONSIVE_URL.'/print.css?ver='.G5_CSS_VER.'" media="print">', 10);
continue;
}
// 디렉토리인 경우
if(is_dir(EYOOM_THEME_CSS_RESPONSIVE_PATH . '/' . $name) and !$isResponsiveStylesheetIntegration){
$name = str_replace("\\", "", $name);
$subFiles = directory_map(EYOOM_THEME_CSS_RESPONSIVE_PATH . '/' . $name, 1);
foreach ($subFiles as $file) {
if (preg_match('/(?<=min\.)\d+(?=\.css)/', $file, $matches)) {
$min[$matches[0]] = '<link rel="stylesheet" href="'.EYOOM_THEME_CSS_RESPONSIVE_URL.'/'.$name.'/media.screen.min.'.$matches[0].'.css?ver='.G5_CSS_VER.'" media="screen and (min-width: '.$matches[0].'px)">';
}
if (preg_match('/(?<=max\.)\d+(?=\.css)/', $file, $matches)) {
$max[$matches[0]] = '<link rel="stylesheet" href="'.EYOOM_THEME_CSS_RESPONSIVE_URL.'/'.$name.'/media.screen.max.'.$matches[0].'.css?ver='.G5_CSS_VER.'" media="screen and (max-width: '.$matches[0].'px)">';
}
}
}
// 파일인 경우
elseif (is_file(EYOOM_THEME_CSS_RESPONSIVE_PATH . '/' . $name) and $isResponsiveStylesheetIntegration) {
if (strpos($name, 'min') !== false) {
$min[] = '<link rel="stylesheet" href="'.EYOOM_THEME_CSS_RESPONSIVE_URL.'/'.$name.'?ver='.G5_CSS_VER.'">';
} elseif (strpos($name, 'max') !== false) {
$max[] = '<link rel="stylesheet" href="'.EYOOM_THEME_CSS_RESPONSIVE_URL.'/'.$name.'?ver='.G5_CSS_VER.'">';
}
}
}
// 스타일 추가 함수 (값 기반 정렬)
$addStylesheets = function ($styles, $priority, $keySort = false, $reverse = false) {
// 키 기준
if ($keySort) {
// 역방향
if($reverse){
krsort($styles, SORT_NUMERIC); // 키 기반 정렬
}
// 정방향
else{
ksort($styles, SORT_NUMERIC); // 키 기반 정렬
}
}
// 값 기분
else {
// 역방향
if($reverse){
rsort($styles, SORT_STRING); // 값 기반 정렬
}
// 정방향
else{
sort($styles, SORT_STRING); // 값 기반 정렬
}
}
foreach ($styles as $style) {
add_stylesheet($style, $priority);
}
};
if ($isResponsiveStylesheetIntegration) {
if ($isMin) $addStylesheets($min, 8); // 값 기반 정렬
if ($isMax) $addStylesheets($max, 9); // 값 기반 정렬
} else {
if ($isMin) $addStylesheets($min, 8, true); // 키 기반 정렬
if ($isMax) $addStylesheets($max, 9, true, true); // 키 기반 정렬
}
반응형
'Web' 카테고리의 다른 글
[MySQL] Event_Scheduler 활성화 (0) | 2021.11.22 |
---|---|
Note v.1 (0) | 2021.07.20 |
[MySQL] 함수 BIT_COUNT, COALESCE (0) | 2021.07.16 |
[DB][MySQL] 시/도, 시/군/구, 읍/면/동 .sql (0) | 2021.07.05 |
Favicon HTML link Tag (0) | 2020.06.08 |