示例#1
0
    echo $item['article_id'];
    ?>
.html"><?php 
    echo Str::strip_html($item['title']);
    ?>
</a>
                            &nbsp; &nbsp;&nbsp;<span class="time"><?php 
    echo date('Y-m-d', $item['post_date']);
    ?>
</span>
                            &nbsp;&nbsp;&nbsp; <span>阅读:<?php 
    echo $item['views'];
    ?>
</span>
                        <p><?php 
    echo Str::slice(Str::strip_html($item['content']), 100, '..');
    ?>
<p>
                    </li>
                    <?php 
}
?>
                </ul>
             <div class="page_list"> <?php 
echo $pagination->render('pagination/digg');
?>
</div>
        </div>


    </div>
 /**
  * 图书添加
  */
 public function action_add()
 {
     $this->checkLogin();
     $this->_add_css('styles/album/edit_articles.css');
     $this->template->pageTitle = '添加图书';
     $this->template->categories = $categories = $this->cate->getCates($this->auth['uid']);
     $article = ORM::factory('article');
     if ($this->isPost()) {
         //数据验证
         $post = Validate::factory($this->getPost())->filter(TRUE, 'trim')->rule('title', 'not_empty')->rule('cate_id', 'not_empty')->rule('content', 'not_empty');
         if ($post->check()) {
             preg_match_all("/(src)=[\"|'| ]{0,}((https?\\:\\/\\/.*?)([^>]*[^\\.htm]\\.(gif|jpg|bmp|png)))/i", $this->getPost('content'), $match);
             $img = preg_replace("/^http:\\/\\/[\\w\\.\\-\\_]*wal8\\.com\\//i", '', $match[2][0]);
             $article->thumb = $img;
             $article->excerpt = Str::slice(Str::strip_html($this->getPost('content')), 30, '...');
             $article->uid = $this->auth['uid'];
             $article->userip = Request::$client_ip;
             $aid = $article->values($post)->save();
             $tags = trim($this->getPost('tags'));
             $tags = explode(' ', $tags);
             $this->tag->add($aid, 'article', $tags, $this->auth['uid']);
             $select = DB::select(DB::expr("count(0)"))->from('articles')->where('cate_id', '=', $post['cate_id']);
             DB::update('article_categories')->set(array('art_num' => $select))->where('cate_id', '=', $post['cate_id'])->execute();
             $links[] = array('text' => '图书管理', 'href' => '/book/article/list');
             $this->show_message('添加图书成功', 1, $links, true);
         } else {
             $this->show_message($post->errors('book/article'));
         }
     }
 }