[slide] header = заголовок2 text = текст с html без переносов link = http://max-3000.com/ img = TEMPLATE_URL/images/placehold/1140x300.png [/slide] '; $slides0 = mso_get_option('slidesjs', 'templates', $slides_def); if (!$slides0) { return; } // слайды не определены - выходим $slides0 = str_replace('TEMPLATE_URL/', getinfo('template_url'), $slides0); // ищем вхождение [slide] ... [slide] // указываем дефолтные атрибуты полей слайдера $slides = mso_section_to_array($slides0, '!\\[slide\\](.*?)\\[\\/slide\\]!is', array('header' => '', 'text' => '', 'link' => '', 'img' => '')); if (!$slides) { return; } // нет секций - выходим $slidesjs_output = mso_get_option('slidesjs_pagination', 'templates', 1) ? 'true' : 'false'; $slidesjs_play = (int) mso_get_option('slidesjs_play', 'templates', 4000); // http://slidesjs.com/ echo mso_load_jquery('slides.min.jquery.js'); echo ' <script> $(document).ready(function(){ $("div.slidesjs").slides({ currentClass: "slides_current", play: ' . $slidesjs_play . ', effect: "fade",
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /* (c) http://max-3000.com/ вывод соцсететй иконками стили задаются в _social.less Файл использовать в других компонентах if ($fn = mso_fe('components/_social/_social.php')) require($fn); */ $social = '[social]' . NR . mso_get_option('social', 'templates', '') . '[/social]'; $social = mso_section_to_array($social, 'social', array(), true); if ($social and isset($social[0])) { echo '<div class="social">'; $socials = $social[0]; // подсказки в title $title = array('behance' => 'Behance', 'blogger' => 'Blogger', 'dropbox' => 'Dropbox', 'evernote' => 'Evernote', 'facebook' => 'Facebook', 'gplus' => 'Google+', 'github' => 'Github', 'last_fm' => 'Last FM', 'linked_in' => 'Linked In', 'mail' => 'Mail.ru', 'email' => 'Контакты', 'odnoklassniki' => 'Одноклассники', 'rss' => 'RSS', 'skype' => 'Skype', 'twitter' => 'Twitter', 'vimeo' => 'Vimeo', 'vkontakte' => 'В Контакте', 'yahoo' => 'Yahoo', 'youtube' => 'Youtube'); foreach ($socials as $s => $url) { if ($s == 'rss') { echo '<a class="rss" title="RSS" href="' . getinfo('rss_url') . '"></a>'; } else { if (isset($title[$s])) { $t = tf($title[$s]); } else { $t = $s; } echo '<a class="' . $s . '" rel="nofollow" title="' . $t . '" href="' . trim($url) . '"></a>'; } }
} if ($fn = mso_find_ts_file('type/home/my_home.php')) { require $fn; } else { // свой вариант вывода главной на основе опций с [unit] $home_units = false; // если есть units.php, то получаем из него текст с [unit] if ($fn = mso_find_ts_file('type/home/units.php')) { $home_units = file_get_contents($fn); } else { $home_units = mso_get_option('home_units', 'templates', ''); // или из опции } if ($home_units) { // ищем вхождение [unit] ... [/unit] $units = mso_section_to_array($home_units, '!\\[unit\\](.*?)\\[\\/unit\\]!is', array('file' => '')); // pr($units); // подключаем каждый указанный unit // _rules — php-условие, при котором юнит выводится // параметр file где указывается файл юнита в каталоге type/home/units/ // если file нет, то проверяются другие параметры если есть: // html — выводится как есть текстом // require — подключается файл в шаблоне (пусть относительно каталога шаблона) // ushka — ушка // component — компонент шаблона // option_key и option_type и option_default — опция if ($units) { $UNIT_NUM = 0; // порядковый номер юнита (можно использовать для кэширования) foreach ($units as $UNIT) { $UNIT_NUM++;
function forms_content_callback($matches) { $text = $matches[1]; $text = str_replace("\r", "", $text); $text = str_replace(' ', ' ', $text); $text = str_replace("\t", ' ', $text); $text = str_replace('<br />', "<br>", $text); $text = str_replace('<br>', "\n", $text); $text = str_replace("\n\n", "\n", $text); $text = str_replace(' ', ' ', $text); $text = str_replace(' ', ' ', $text); $text = str_replace(' ', ' ', $text); $text = str_replace(' ', ' ', $text); $text = str_replace("\n ", "\n", $text); $text = str_replace("\n\n", "\n", $text); $text = trim($text); // число антиспама привязано и к сессии $ses = getinfo('session'); $ses = preg_replace("/\\D/", '', $ses['session_id']); $ses = substr($ses, 0, 4); $antispam_num = date('jw') + date('t') * date('G') + $ses; // служебная секция [options] $def = array('email' => mso_get_option('admin_email', 'general', '*****@*****.**'), 'subject' => '', 'from' => '', 'redirect' => '', 'redirect_pause' => '2', 'ushka' => '', 'reset' => 1, 'require_title' => '*', 'antispam' => tf('Наберите число'), 'antispam_ok' => $antispam_num); $options = mso_section_to_array($text, 'options', $def, true); // если секции [options] нет, то ставим дефолт if (!$options) { $options[0] = $def; } if ($options) { $options = $options[0]; } // служебная секция [files] $def = array('file_count' => 0, 'file_type' => 'jpg|jpeg|png|svg', 'file_max_size' => 200, 'file_description' => 'Скриншоты', 'file_tip' => tf('Выберите для загрузки файлы (jpg, jpeg, png, svg) размером до 200 Кб')); $files = mso_section_to_array($text, 'files', $def, true); if ($files) { $files = $files[0]; // только одна секция // если полей меньше 1, то обнуляем массив if ((int) $files['file_count'] < 1) { $files = array(); } } // поля формы [field] $def = array('require' => 0, 'type' => 'text', 'description' => '', 'placeholder' => '', 'tip' => '', 'value' => '', 'attr' => '', 'clean' => 'base', 'values' => '', 'default' => '', 'subject' => 0, 'from' => 0); $fields = mso_section_to_array($text, 'field', $def, true); $options = array_map('trim', $options); // pr($options); // pr($files); // pr($fields); // pr($text); // html-формат вывода $format['container_class'] = 'mso-forms'; // css-класс для div-контейнера формы $format['textarea'] = '<p><label><span>[description][require_title]</span><textarea [field_param]>[value]</textarea></label>[tip]</p>'; $format['checkbox'] = '<p><label><span></span><input [field_param] value="1" type="checkbox"> [description]</label>[tip]</p>'; $format['select'] = '<p><label><span>[description][require_title]</span><select [field_param]>[option]</select></label>[tip]</p>'; $format['input'] = '<p><label><span>[description][require_title]</span><input [field_param]></label>[tip]</p>'; $format['tip'] = '<span class="mso-forms-tip">[tip]</span>'; $format['file_description'] = '<p><label><span>[file_description]</span></label></p>'; $format['file_field'] = '<p>[file_field]</p>'; $format['file_tip'] = '<p><span class="mso-forms-tip">[file_tip]</span></p>'; $format['message_ok'] = '<p class="mso-forms-ok">' . tf('Ваше сообщение отправлено') . '</p>'; $format['message_error'] = '<p class="mso-forms-error">[error]</p>'; $format['antispam'] = '<p><label><span>[antispam] [antispam_ok][require_title]</span>[input]</label></p>'; $format['buttons'] = '<p class="mso-forms-buttons">[submit] [reset]</p>'; $format['mail_field'] = '[description]: [post_value] [NR]'; // подключаем файл формата из текущего шаблона if ($fn = mso_fe('custom/plugins/forms/format.php')) { require $fn; } $out = ''; // затираем исходный текст формы if ($_POST) { // если это отправка $result_post = forms_content_post($options, $files, $fields, $format); // в $result_post результат отправки if ($result_post['show_ok']) { $out .= $format['message_ok']; if ($options['redirect']) { // редирект через N секунд header('Refresh: ' . $options['redirect_pause'] . '; url=' . $options['redirect']); } } elseif ($result_post['show_error']) { // вывод сообщений об ошибках foreach ($result_post['show_error'] as $error) { $out .= str_replace('[message_error]', tf($error), $format['message_error']); } if ($result_post['show_form']) { $out .= forms_show_form($options, $files, $result_post['fields'], $format); } } } else { // выводим форму $out .= forms_show_form($options, $files, $fields, $format); } return $out; }
function last_pages_unit_widget_custom($arg = array(), $num = 1) { if (!isset($arg['header'])) { $arg['header'] = mso_get_val('widget_header_start', '<div class="mso-widget-header"><span>') . t('Последние записи') . mso_get_val('widget_header_end', '</span></div>'); } if (!isset($arg['cache_time'])) { $arg['cache_time'] = 0; } if (!isset($arg['prefs'])) { $arg['prefs'] = ''; } $out = ''; $cache_key = 'last_pages_unit_widget-' . serialize($arg) . '-' . $num; if ($arg['cache_time'] > 0 and $out = mso_get_cache($cache_key)) { return $out; # да есть в кэше } $units = mso_section_to_array('[unit]' . $arg['prefs'] . '[/unit]', '!\\[unit\\](.*?)\\[\\/unit\\]!is'); ob_start(); if ($units and isset($units[0]) and $units[0]) { $UNIT = $units[0]; require dirname(realpath(__FILE__)) . '/last-pages.php'; } $out = $arg['header'] . ob_get_clean(); if ($arg['cache_time'] > 0) { mso_add_cache($cache_key, $out, $arg['cache_time'] * 60); } return $out; }
$slides = mso_section_to_array($slides0, '!\\[slide\\](.*?)\\[\\/slide\\]!is', array(), false, true); if (!$slides) { return; } // нет секций - выходим // замена в тексте $slides0 = str_replace('TEMPLATE_URL/', getinfo('template_url'), $slides0); $slides0 = str_replace('SITE_URL/', getinfo('siteurl'), $slides0); // опции слайдера свои $options = mso_section_to_array($slides0, '!\\[options\\](.*?)\\[\\/options\\]!is', array()); if (isset($options[0])) { $options = $options[0]; } $options_def = array('block_start' => '<div class="layout-center-wrap"><div class="layout-wrap mar30-tb pad20-rl">', 'block_end' => '</div></div>', 'element' => '.component-lightslider', 'ul_class' => 'component-lightslider'); $options = mso_merge_array($options, $options_def); // в секции [js] все параметры слайдера в родном js-формате $js = mso_section_to_array($slides0, '!\\[js\\](.*?)\\[\\/js\\]!is', array(), false, true); // данные в первом элементе $js = isset($js[0]) ? $js[0] : ''; echo $options['block_start'] . '<ul class="' . $options['ul_class'] . '">'; foreach ($slides as $slide) { if (!$slide) { continue; } // не указан текст echo '<li>' . trim($slide) . '</li>'; } echo '</ul>' . $options['block_end']; echo mso_load_script(getinfo('template_url') . 'components/lightslider/lightslider.min.js'); echo '<script>$(document).ready(function() { $("' . $options["element"] . '").lightSlider({' . $js . '}); });</script>'; # end of file