Пример #1
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));
 }