Пример #1
0
 }
 if ($f = mso_page_foreach('page-content')) {
     require $f;
 } else {
     if ($f = mso_page_foreach('page-content-' . getinfo('type'))) {
         require $f;
     } else {
         $p->div_start('mso-page-content mso-type-' . getinfo('type') . '-content');
         if ($f = mso_page_foreach('content')) {
             require $f;
         } else {
             // если show_thumb_type_ТИП вернул false, то картинку не ставим
             // show_thumb - если нужно отключить для всех типов
             if (mso_get_val('show_thumb', true) and mso_get_val('show_thumb_type_' . getinfo('type'), true)) {
                 // вывод миниатюры перед записью
                 if ($image_for_page = thumb_generate($p->meta_val('image_for_page'), mso_get_option('image_for_page_width', 'templates', 280), mso_get_option('image_for_page_height', 'templates', 210))) {
                     echo $p->img($image_for_page, mso_get_option('image_for_page_css_class', 'templates', 'image_for_page'), '', $p->val('page_title'));
                 }
             }
             $p->content('', '');
             $p->clearfix();
         }
         // для page возможен свой info-bottom
         if ($f = mso_page_foreach('mso-info-bottom-page')) {
             require $f;
         } elseif ($f = mso_page_foreach('info-bottom')) {
             require $f;
         }
         $p->html('<aside>');
         mso_page_content_end();
         $p->clearfix();
Пример #2
0
function _upload($up_dir, $fn, $r = array())
{
    $fn = _slug($fn);
    $ext = substr(strrchr($fn, '.'), 1);
    $name = substr($fn, 0, strlen($fn) - strlen($ext) - 1);
    // Если имя файла пустое, только расширение.
    if ($fn == '.' . $ext) {
        $fn = '1' . $fn;
    }
    // Если файл уже существует.
    if (file_exists($up_dir . $fn)) {
        for ($i = 1; $i < 100; $i++) {
            $fn = $name . '-' . $i . '.' . $ext;
            if (!file_exists($up_dir . $fn)) {
                break;
            }
        }
    }
    file_put_contents($up_dir . $fn, file_get_contents('php://input'));
    if (!in_array($ext, array('jpg', 'jpeg', 'png', 'gif'))) {
        // Не картинка, загрузили, больше ничего не надо.
        return;
    }
    // С какими дефолтными параметрами ресайзим и делаем миниатюрки.
    $def = array('resize_images' => mso_get_option('resize_images', 'general', '600'), 'size_image_mini' => mso_get_option('size_image_mini', 'general', '150'), 'image_mini_type' => mso_get_option('image_mini_type', 'general', '1'), 'use_watermark' => mso_get_option('use_watermark', 'general', '0'), 'watermark_type' => mso_get_option('watermark_type', 'general', '1'));
    //Можем передать свои параметры в эту функцию.
    $r = array_merge($def, $r);
    require getinfo('shared_dir') . 'stock/thumb/thumb.php';
    // У нас есть uploads_dir, а нужен url
    $url = str_replace(getinfo('uploads_dir'), getinfo('uploads_url'), $up_dir);
    // Если картинка больше, чем нужно, то делаем ресайз, иначе ничего не делаем.
    // $new_size пригодится, когда из новой картинки будем миниатюру делать.
    $size = $new_size = getimagesize($up_dir . $fn);
    if ($size[0] > $r['resize_images'] || $size[1] > $r['resize_images']) {
        if ($size[0] > $size[1]) {
            $new_size[0] = $r['resize_images'];
            $new_size[1] = round($size[1] / ($size[0] / $new_size[0]));
        } else {
            $new_size[1] = $r['resize_images'];
            $new_size[0] = round($size[0] / ($size[1] / $new_size[1]));
        }
        //pr($new_size);
        thumb_generate($url . $fn, $new_size[0], $new_size[1], false, 'resize', true, '', false);
    }
    // Создание ватермарки, если такая опция и есть нужный файл.
    if ($r['use_watermark'] and file_exists(getinfo('uploads_dir') . 'watermark.png')) {
        $water_type = $r['watermark_type'];
        // Расположение ватермарка на картинке
        $hor = 'right';
        //Инитим дефолтом.
        $vrt = 'bottom';
        //Инитим дефолтом.
        if ($water_type == 2 or $water_type == 4) {
            $hor = 'left';
        }
        if ($water_type == 2 or $water_type == 3) {
            $vrt = 'top';
        }
        if ($water_type == 1) {
            $hor = 'center';
            $vrt = 'middle';
        }
        $r_conf = array('image_library' => 'gd2', 'source_image' => $up_dir . $fn, 'new_image' => $up_dir . $fn, 'wm_type' => 'overlay', 'wm_vrt_alignment' => $vrt, 'wm_hor_alignment' => $hor, 'wm_overlay_path' => getinfo('uploads_dir') . 'watermark.png');
        $CI =& get_instance();
        $CI->load->library('image_lib');
        $CI->image_lib->clear();
        $CI->image_lib->initialize($r_conf);
        if (!$CI->image_lib->watermark()) {
            echo '<div class="error">' . t('Водяной знак:') . ' ' . $CI->image_lib->display_errors() . '</div>';
        }
    }
    // $r['image_mini_type'] = 6;
    switch ($r['image_mini_type']) {
        case 1:
            // Пропорциональное уменьшение
            if ($size[0] > $size[1]) {
                $new_size[0] = $r['size_image_mini'];
                $new_size[1] = round($size[1] / ($size[0] / $new_size[0]));
                thumb_generate($url . $fn, $new_size[0], $new_size[1], false, 'resize', true, 'mini', false);
            } else {
                $new_size[1] = $r['size_image_mini'];
                $new_size[0] = round($size[0] / ($size[1] / $new_size[1]));
                thumb_generate($url . $fn, $new_size[0], $new_size[1], false, 'resize', true, 'mini', false);
            }
            break;
        case 2:
            // Обрезки (crop) по центру
            thumb_generate($url . $fn, $r['size_image_mini'], $r['size_image_mini'], false, 'resize_full_crop_center', true, 'mini', false);
            break;
        case 3:
            // Обрезки (crop) с левого верхнего края
            thumb_generate($url . $fn, $r['size_image_mini'], $r['size_image_mini'], false, 'crop', true, 'mini', false);
            break;
        case 4:
            // Обрезки (crop) с левого нижнего края
            $thumb = new Thumb($url . $fn, $postfix = '', $replace_file = true, $subdir = 'mini');
            $thumb->crop($r['size_image_mini'], $r['size_image_mini'], 0, $new_size[1] - $r['size_image_mini']);
            //thumb_generate($url . $fn, $width, $height, false, $type_resize = 'resize_full_crop_center', true, 'mini', false);
            break;
        case 5:
            // Обрезки (crop) с правого верхнего края
            $thumb = new Thumb($url . $fn, $postfix = '', $replace_file = true, $subdir = 'mini');
            $thumb->crop($r['size_image_mini'], $r['size_image_mini'], $new_size[0] - $r['size_image_mini'], 0);
            //thumb_generate($url . $fn, $width, $height, false, $type_resize = 'resize_full_crop_center', true, 'mini', false);
            break;
        case 6:
            // Обрезки (crop) с правого нижнего края
            $thumb = new Thumb($url . $fn, $postfix = '', $replace_file = true, $subdir = 'mini');
            $thumb->crop($r['size_image_mini'], $r['size_image_mini'], $new_size[0] - $r['size_image_mini'], $new_size[1] - $r['size_image_mini']);
            //thumb_generate($url . $fn, $width, $height, false, $type_resize = 'resize_full_crop_center', true, 'mini', false);
            break;
        case 7:
            // Уменьшения и обрезки (crop) в квадрат
            if ($size[0] < $size[1]) {
                thumb_generate($url . $fn, $r['size_image_mini'], $r['size_image_mini'], false, 'resize_crop_center', true, 'mini', false);
            } else {
                thumb_generate($url . $fn, $r['size_image_mini'], $r['size_image_mini'], false, 'resize_h_crop_center', true, 'mini', false);
            }
            break;
    }
    thumb_generate($url . $fn, 100, 100, false, 'resize_full_crop_center', true, '_mso_i', false);
}
Пример #3
0
    $rules_result = eval('return ( ' . $rules . ' ) ? 1 : 0;');
    if ($rules_result === false) {
        $rules_result = 1;
    }
    if ($rules_result !== 1) {
        return;
    }
}
$logo = trim(mso_get_option('top1_header_logo', getinfo('template'), getinfo('template_url') . 'assets/images/logos/logo01.png'));
$logo_width = (int) mso_get_option('top1_header_logo_width', getinfo('template'), 0);
$logo_height = (int) mso_get_option('top1_header_logo_height', getinfo('template'), 0);
$logo_type_resize = mso_get_option('top1_header_logo_type_resize', getinfo('template'), 'resize_full_crop_center');
// задан размер по ширине и высоте, значит пробуем кропнуть указанное изображение и получить новое
if ($logo_width and $logo_height) {
    require_once getinfo('shared_dir') . 'stock/thumb/thumb.php';
    if ($new_image = thumb_generate($logo, $logo_width, $logo_height, false, $logo_type_resize, false, 'mini', '-' . $logo_width . '-' . $logo_height . '-' . $logo_type_resize)) {
        $logo = $new_image;
    }
}
if ($logo) {
    $logo = '<img src="' . $logo . '" alt="' . getinfo('name_site') . '" title="' . getinfo('name_site') . '">';
}
if (!is_type('home')) {
    $logo = '<a href="' . getinfo('siteurl') . '">' . $logo . '</a>';
}
$top1_block = mso_get_option('top1_block', getinfo('template'), '');
?>
<div class="menu-icons flex flex-vcenter bg-gray900 pad15-rl">
	<div>
		<ul class="menu menu2">
		<?php 
Пример #4
0
 public function output($r = array())
 {
     if (!$this->pages) {
         return;
     }
     // нет записей, выходим
     // дефолтный формат вывода
     $default = array('title_start' => '<h3 class="home-last-page">', 'title_end' => '</h3>', 'date' => 'D, j F Y г. в H:i', 'date_start' => '<span class="date"><time datetime="[page_date_publish_iso]">', 'date_end' => '</time></span>', 'cat_start' => ' | <span class="cat">', 'cat_end' => '</span>', 'cat_sep' => ', ', 'tag_start' => ' | <span class="tag">', 'tag_end' => '</span>', 'tag_sep' => ', ', 'author_start' => '', 'author_end' => '', 'read' => '»»»', 'read_start' => '', 'read_end' => '', 'comments_count_start' => '', 'comments_count_end' => '', 'thumb' => true, 'thumb_width' => 320, 'thumb_height' => 180, 'thumb_class' => 'thumb left', 'placehold' => false, 'placehold_path' => 'http://placehold.it/', 'placehold_pattern' => '[W]x[H].png', 'placehold_file' => false, 'placehold_data_bg' => '#CCCCCC', 'block_start' => '', 'block_end' => '', 'line1' => '[thumb]', 'line1_start' => '', 'line1_end' => '', 'line2' => '[title]', 'line2_start' => '', 'line2_end' => '', 'line3' => '[date] [cat]', 'line3_start' => '<p class="home-last-page-info">', 'line3_end' => '</p>', 'line4' => '', 'line4_start' => '', 'line4_end' => '', 'line5' => '', 'line5_start' => '', 'line5_end' => '', 'content' => true, 'content_chars' => 0, 'content_words' => 0, 'content_cut' => ' ...', 'content_start' => '<div class="mso-page-content">', 'content_end' => '</div>', 'columns' => 0, 'columns_class_row' => 'onerow', 'columns_class_cell' => 'col w1-2', 'clearfix' => false, 'page_start' => '', 'page_end' => '', 'pagination_start' => '', 'pagination_end' => '', 'box_grid' => 0, 'box_grid_class' => 'w50', 'box_grid_box_class' => 'table-box', 'exclude_page_add' => true);
     $r = array_merge($default, $r);
     // объединяем
     // $r = array_map('trim', $r);
     $p = new Page_out();
     // шаблонизатор
     // echo $r['block_start'];
     eval(mso_tmpl_prepare($r['block_start'], false));
     // формат записи
     $p->format('title', $r['title_start'], $r['title_end']);
     $p->format('date', $r['date'], $r['date_start'], $r['date_end']);
     $p->format('author', $r['author_start'], $r['author_end']);
     $p->format('cat', $r['cat_sep'], $r['cat_start'], $r['cat_end']);
     $p->format('tag', $r['tag_sep'], $r['tag_start'], $r['tag_end']);
     $p->format('read', $r['read'], $r['read_start'], $r['read_end']);
     $p->format('comments_count', $r['comments_count_start'], $r['comments_count_end']);
     if ($r['exclude_page_add']) {
         $exclude_page_id = mso_get_val('exclude_page_id');
     }
     if ($r['columns']) {
         $my_columns = new Columns($r['columns'], count($this->pages), $r['columns_class_row']);
     }
     if ($r['box_grid']) {
         $p->box_grid($r['box_grid']);
     }
     foreach ($this->pages as $page) {
         $p->load($page);
         // загружаем данные записи
         if ($r['box_grid']) {
             $p->box_grid_cell($r['box_grid_class'], $r['box_grid_box_class']);
         }
         if ($r['columns']) {
             $my_columns->out($r['columns_class_cell']);
         }
         // echo $r['page_start'];
         eval(mso_tmpl_prepare($r['page_start'], false));
         if ($r['thumb']) {
             // плейсхолд
             if ($r['placehold']) {
                 if ($r['placehold_file']) {
                     if ($r['placehold_file'] == 'data') {
                         // сами генерируем плейсхолд
                         // mso_holder($width = 100, $height = 100, $text = true, $background_color = '#CCCCCC', $text_color = '#777777', $font_size = 5)
                         $t_placehold = mso_holder($r['thumb_width'], $r['thumb_height'], false, $r['placehold_data_bg']);
                     } else {
                         $t_placehold = $r['placehold_path'] . $r['placehold_file'];
                     }
                 } else {
                     $t_placehold_pattern = str_replace('[W]', $r['thumb_width'], $r['placehold_pattern']);
                     $t_placehold_pattern = str_replace('[H]', $r['thumb_height'], $t_placehold_pattern);
                     $t_placehold_pattern = str_replace('[RND]', rand(1, 10), $t_placehold_pattern);
                     $t_placehold = $r['placehold_path'] . $t_placehold_pattern;
                 }
             } else {
                 $t_placehold = false;
             }
             if ($thumb = thumb_generate($p->meta_val('image_for_page'), $r['thumb_width'], $r['thumb_height'], $t_placehold)) {
                 $p->thumb = '<a href="' . mso_page_url($p->val('page_slug')) . '" title="' . htmlspecialchars($p->val('page_title')) . '"><img src="' . $thumb . '" class="' . $r['thumb_class'] . '" alt="' . htmlspecialchars($p->val('page_title')) . '"></a>';
             }
         }
         $p->line($r['line1'], $r['line1_start'], $r['line1_end']);
         $p->line($r['line2'], $r['line2_start'], $r['line2_end']);
         $p->line($r['line3'], $r['line3_start'], $r['line3_end']);
         if ($r['content']) {
             if ($r['content_chars']) {
                 $p->content_chars($r['content_chars'], $r['content_cut'], $r['content_start'], $r['content_end']);
                 // текст обрезанный
             } elseif ($r['content_words']) {
                 $p->content_words($r['content_words'], $r['content_cut'], $r['content_start'], $r['content_end']);
                 // текст обрезанный
             } else {
                 $p->content($r['content_start'], $r['content_end']);
             }
         }
         $p->line($r['line4'], $r['line4_start'], $r['line4_end']);
         $p->line($r['line5'], $r['line5_start'], $r['line5_end']);
         if ($r['clearfix']) {
             $p->clearfix();
         }
         // echo $r['page_end'];
         eval(mso_tmpl_prepare($r['page_end'], false));
         if ($r['columns']) {
             $my_columns->next();
         }
         if ($r['box_grid']) {
             $p->box_grid_next();
         }
         // сохраняем id записей, чтобы их исключить из вывода
         if ($r['exclude_page_add']) {
             $exclude_page_id[] = $p->val('page_id');
         }
     }
     if ($r['columns']) {
         $my_columns->close();
     }
     if ($r['box_grid']) {
         $p->box_grid_end();
     }
     if ($r['exclude_page_add']) {
         mso_set_val('exclude_page_id', $exclude_page_id);
     }
     if ($this->param['pagination']) {
         if (mso_hook_present('pagination')) {
             // echo $r['pagination_start'];
             eval(mso_tmpl_prepare($r['pagination_start'], false));
             mso_hook('pagination', $this->pagination);
             // echo $r['pagination_end'];
             eval(mso_tmpl_prepare($r['pagination_end'], false));
         }
     }
     // echo $r['block_end'];
     eval(mso_tmpl_prepare($r['block_end'], false));
 }