function default_profiles() { $all = mso_get_path_files(getinfo('template_dir') . 'assets/css/profiles/', getinfo('template_url') . 'assets/css/profiles/', false, array('css')); if ($all) { $all = ' ||Нет #' . implode($all, '#'); } else { $all = ' ||Нет'; } return $all; }
/** * autoload файлов в подкаталоге /autoload/ ($auto_dir) заданного $dir * $in_base = true — поиск относительно BASE_DIR * $in_page = true, в текущей page * результат объединяется * * @param $dir * @param $in_base * @param $in_page * @param $auto_dir * * @return string */ function mso_autoload($dir = '', $in_base = true, $in_page = true, $auto_dir = '/autoload/') { global $VAR; if (!$dir) { return; } // если каталог не указан, выходим $a1 = $a2 = array(); if ($in_base) { $a1 = mso_get_path_files(BASE_DIR . $dir . $auto_dir, BASE_URL . $dir . $auto_dir, true, array('js', 'css')); } if ($in_page) { $a2 = mso_get_path_files(CURRENT_PAGE_DIR . $dir . $auto_dir, CURRENT_PAGE_URL . $dir . $auto_dir, true, array('js', 'css')); } $autoload = array_merge($a1, $a2); $ret = ''; if ($autoload) { foreach ($autoload as $fn) { if ($VAR['remove_protocol']) { $fn = mso_remove_protocol($fn); } $ext = substr(strrchr($fn, '.'), 1); // расширение файла if ($ext == 'js') { // .async и .defer — если в имени файла есть это вхождение // то прописываем эти атрибуты к <script> if (strpos($fn, '.async') !== false) { $attr = ' async'; } elseif (strpos($fn, '.defer') !== false) { $attr = ' defer'; } else { $attr = ''; } $ret .= NR . '<script src="' . $fn . '"' . $attr . '></script>'; } elseif ($ext == 'css') { $ret .= mso_load_css($fn); } } } return $ret; }
function my_default_head_section() { global $page; echo '<!DOCTYPE HTML> <html' . mso_get_val('head_section_html_add') . '><head>' . mso_hook('head_start') . ' <meta charset="UTF-8"> <title>' . mso_head_meta('title') . '</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="MaxSite CMS"> <meta name="description" content="' . mso_head_meta('description') . '"> <meta name="keywords" content="' . mso_head_meta('keywords') . '"> <meta property="og:title" content="' . mso_head_meta('title') . '"> <meta property="og:description" content="' . mso_head_meta('description') . '"> <meta property="og:url" content="' . mso_link_rel('canonical', '', true) . '"> <link rel="shortcut icon" href="' . getinfo('template_url') . 'assets/images/favicons/' . mso_get_option('default_favicon', 'templates', 'favicon1.png') . '" type="image/x-icon"> '; if (is_type('page') and isset($page['page_meta']['image_for_page'][0])) { echo '<meta property="og:image" content="' . $page['page_meta']['image_for_page'][0] . '">'; } if (mso_get_option('default_canonical', 'templates', 0)) { echo mso_link_rel('canonical'); } echo mso_rss(); if ($fn = mso_fe('custom/head-start.php')) { require $fn; } // autoload файлов if ($autoload_css = mso_get_path_files(getinfo('template_dir') . 'assets/css/', getinfo('template_url') . 'assets/css/', true, array('css'))) { foreach ($autoload_css as $fn_css) { echo '<link rel="stylesheet" href="' . $fn_css . '">' . NR; } } my_out_component_css(); mso_hook('head_css'); my_default_out_profiles(); // своя версия jQuery, если нужно if ($j = mso_get_val('jquery_url', false)) { echo '<script src="' . $j . '"></script>' . NR; } else { if (mso_fe('assets/js/jquery.min.js')) { echo mso_add_file('assets/js/jquery.min.js'); } else { echo mso_load_jquery(); } } mso_hook('head'); // autoload js-файлов if ($autoload_js = mso_get_path_files(getinfo('template_dir') . 'assets/js/autoload/', getinfo('template_url') . 'assets/js/autoload/', true, array('js'))) { foreach ($autoload_js as $fn_js) { echo '<script src="' . $fn_js . '"></script>' . NR; } } if ($fn = mso_fe('custom/head.php')) { require $fn; } if ($fn = mso_page_foreach('head')) { require $fn; } if (function_exists('ushka')) { echo ushka('head'); } if (mso_fe('assets/js/my.js')) { echo mso_add_file('assets/js/my.js'); } if ($my_style = mso_get_option('my_style', 'templates', '')) { echo NR . '<!-- custom css-my_style -->' . NR . '<style>' . NR . $my_style . '</style>'; } mso_hook('head_end'); if (function_exists('ushka')) { echo ushka('google_analytics_top'); } echo NR . '</head>'; }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } if ($fn = mso_fe('custom/body-end.php')) { require $fn; } if (function_exists('ushka')) { echo ushka('google_analytics'); echo ushka('body_end'); } mso_hook('body_end'); // lazy-загрузка js-файлов if ($lazy_js = mso_get_path_files(getinfo('template_dir') . 'assets/js/lazy/', getinfo('template_url') . 'assets/js/lazy/', true, array('js'))) { foreach ($lazy_js as $fn_js) { echo '<script src="' . $fn_js . '"></script>' . NR; } } # end of file
function admin_options_favicon() { $all = mso_get_path_files(getinfo('uploads_dir') . 'favicons/', getinfo('template_url') . 'uploads/favicons/', false); return implode($all, '#'); }
function default_header_logo() { $all = mso_get_path_files(getinfo('template_dir') . 'assets/images/logos/', getinfo('template_url') . 'assets/images/logos/', false); return implode($all, '#'); }
// проверка на обновление POST if (mso_check_post_ini()) { echo '<div class="update">' . t('Обновлено!') . '</div>'; } $options = array(); // если переменная = true, то подгружаем дефолтные опции из shared/options/default/ if (mso_get_val('get_options_default', true)) { // получим список всех файлов из options $files = mso_get_path_files(getinfo('shared_dir') . 'options/default/', getinfo('shared_dir') . 'options/default/', true, array('ini')); foreach ($files as $file) { $add = mso_get_ini_file($file); $options = array_merge($options, $add); } } // получим список всех файлов из options шаблона $files = mso_get_path_files(getinfo('template_dir') . 'options/', getinfo('template_dir') . 'options/', true, array('ini')); foreach ($files as $file) { $add = mso_get_ini_file($file); $options = array_merge($options, $add); } if (file_exists(getinfo('template_dir') . 'custom/my_options.php')) { require getinfo('template_dir') . 'custom/my_options.php'; } if (file_exists(getinfo('template_dir') . 'custom/my_options.ini')) { $add = mso_get_ini_file(getinfo('template_dir') . 'custom/my_options.ini'); // и свой $options = array_merge($options, $add); } // подключим все опции компонентов из components // в них ini-файлы, а также php-файлы, обслуживающие ini (для PHP_START PHP_END) // поэтому подключаем все php-файлы, после все ini-файлы
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /* вывод случайного изображения из заданного каталога */ // где выводить $component_output = mso_get_option('component_image_rand_output', 'templates', array()); if (!in_array('all', $component_output)) { if (!in_array(getinfo('type'), $component_output)) { return; } } $subdir = mso_get_option('default_header_image', 'templates', '-template-'); if ($subdir == '-template-') { // каталог шаблона $imgs = mso_get_path_files(getinfo('template_dir') . 'images/headers/', getinfo('template_url') . 'images/headers/'); } else { $imgs = mso_get_path_files(getinfo('uploads_dir') . $subdir . '/', getinfo('uploads_url') . $subdir . '/'); } // каталог в uploads if ($imgs) { $img = $imgs[array_rand($imgs, 1)]; // случайный выбор echo '<div class="image-rand"><div class="wrap">' . '<img src="' . $img . '" alt="" title="">' . '</div></div>'; } # end file
$all = array_merge($all, $all_add); } if (file_exists(getinfo('template_dir') . 'custom/my_options.php')) { require getinfo('template_dir') . 'custom/my_options.php'; } if (file_exists(getinfo('template_dir') . 'custom/my_options.ini')) { $all_add = mso_get_ini_file(getinfo('template_dir') . 'custom/my_options.ini'); // и свой $all = array_merge($all, $all_add); } // подключим все опции компонентов в components/options // в них ini-файлы, а также php-файлы, обслуживающие ini (для PHP_START PHP_END) // поэтому подключаем все php-файлы, после все ini-файлы // подключаем только те опции и ini компонентов, которые реально существуют // все компоненты $all_component = mso_get_path_files(getinfo('template_dir') . 'components/', getinfo('template_dir') . 'components/', true, array('php')); // проверяем опции foreach ($all_component as $file) { $file = str_replace('/components/', '/components/options/', $file); if (file_exists($file)) { require $file; } // php-файлы } // проверяем ini в options foreach ($all_component as $file) { $file = str_replace('/components/', '/components/options/', $file); $file = str_replace('.php', '.ini', $file); if (file_exists($file)) { $all_add = mso_get_ini_file($file); // css-файлы
function _mso_less_import_all_callback($matches) { $dir = trim($matches[2]); $files = mso_get_path_files(getinfo('template_dir') . 'css-less/' . $dir . '/', $dir . '/', true, array('less')); $m = ''; foreach ($files as $file) { // $m .= '@import url(\'' . $file . '\'); '; // старый вариант $m .= '/* ================== ' . $file . ' ================== */' . NR . NR; $m .= file_get_contents(getinfo('template_dir') . 'css-less/' . $file) . NR; } return $m; }