Example #1
0
 public function show($id)
 {
     $blog = new Blog();
     $this->viewOptions = $blog->show($id);
     // アクション名を設定する
     $this->action = 'show';
     // ビューを呼び出す
     include 'views/layout/application.php';
 }
Example #2
0
 public function show($id)
 {
     //モデルを呼び出す
     $blog = new Blog();
     $this->showOptions = $blog->show($id);
     //アクション名を設定
     $this->action = 'show';
     //ビューを呼び出す
     require 'views/layout/application.php';
 }
Example #3
0
 public function show($id)
 {
     $blog = new Blog();
     // 8, 7の結果を戻り値として返す → var_dumpで表示
     $this->viewOptions = $blog->show($id);
     var_dump($this->viewOptions);
     // アクション名を設定する
     $this->action = 'show';
     //ビューを呼び出す
     include 'views/layout/application.php';
 }
Example #4
0
 /**
  * 发布首页内容
  * 
  * @param array       $articles 文章列表
  * @param \Comm\Pager $pager    分页器
  * @param array       $blog     博客配置
  * @param string      $publish  是否真正发布
  * 
  * @return mixed
  */
 public static function home(array $articles, \Comm\Pager $pager, array $blog = null, $publish = true)
 {
     $blog || ($blog = Blog::show());
     $smarty = \Comm\Smarty::init();
     //设置分页回调
     $pager->link_callback = function ($page) use($publish) {
         if ($page <= 1) {
             $result = '/';
         } else {
             $result = "/index/{$page}.html";
         }
         if (!$publish) {
             $result = '#' . $result;
         }
         return $result;
     };
     $tpl_vars = array('blog' => $blog, 'articles' => isset($articles['result']) ? $articles['result'] : array(), 'pager' => $pager, 'publish' => $publish);
     if ($publish) {
         if ($pager->page == 1) {
             $path = 'index.html';
         } else {
             $path = "index/{$pager->page}.html";
         }
         $message = sprintf('update home (%u) [%s]', $pager->page, date('Y-m-d H:i:s'));
         $content = $smarty->render('tpl:home', $tpl_vars);
         $result = \Model\Publish::publishUserRespos($path, $content, $message);
     } else {
         $result = $smarty->display('tpl:home', $tpl_vars);
     }
     return $result;
 }