Exemple #1
0
 public function getArticles()
 {
     $pache = $GLOBALS['pache'];
     $page = $this->page - 1;
     $start = $page * $pache->pagelimit;
     $model = FrontData::getInstance();
     if ($this->listingType === 'categories') {
         $this->articles = $model->getArticlesByCategories($this->categories, $start, $pache->pagelimit);
     } else {
         if ($this->listingType === 'tag') {
             $this->articles = $model->getArticlesByTag($this->tag, $start, $pache->pagelimit);
         } else {
             $this->articles = $model->getArticles($start, $pache->pagelimit);
         }
     }
 }
Exemple #2
0
 public function pageCode()
 {
     $html = '';
     $model = FrontData::getInstance();
     $home = HomeController::getInstance();
     $pache = $GLOBALS['pache'];
     $page = $home->page;
     if (isset($home->tag)) {
         $listingType = 'tag';
         $listingTypeValue = $home->tag;
     } else {
         if (isset($home->categories)) {
             $listingType = 'categories';
             $listingTypeValue = $home->categories;
         } else {
             $listingType = '';
             $listingTypeValue = NULL;
         }
     }
     $countPage = ceil($model->articleCount($listingType, $listingTypeValue) / $pache->pagelimit);
     $i = $page;
     if ($i - 4 < 1) {
         $i = 5;
     }
     for ($i = $i - 4; $i < $page + 5; ++$i) {
         if ($i > $countPage) {
             break;
         }
         $url = '?';
         if (isset($_GET[$listingType])) {
             $url .= $listingType . '=' . urlencode($_GET[$listingType]) . '&';
         }
         if ($page == $i) {
             $html .= '<a class="pagecode current"><div class="code">' . $i . '</div><div class="bg"></div></a>';
         } else {
             $html .= '<a class="pagecode" href="' . $url . 'page=' . $i . '">' . $i . '</a> ';
         }
     }
     $form = '<form method="get" style="display:none;"><input name="page" size="4" /></form>';
     $html = '<div id="page">' . $html . $form . '</div>';
     return $html;
 }
Exemple #3
0
 /**
  * 获得单例对象
  * @param @params array 数据库连接信息
  * @return object 单例的对象
  */
 public static function getInstance($params = array())
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self($params);
     }
     return self::$instance;
 }
 public function out()
 {
     $model = FrontData::getInstance();
     $this->categories = $model->getCategories();
     return $this->backHTML();
 }
Exemple #5
0
 public function __construct()
 {
     $this->model = FrontData::getInstance();
 }
 public function outTagList()
 {
     $model = FrontData::getInstance();
     $this->tags = $model->getTaglistById($this->article['id']);
     return is_null($this->article['id']) ? '' : $this->outTagHTML();
 }