Beispiel #1
0
 private function getArticle($article_id)
 {
     $params = array();
     $params = array('eq' => array('article_id' => $article_id));
     if (!$this->is_root) {
         $params['lt'] = array('category_id' => 5);
     }
     $article = Repository::findOneFromArticle($params);
     if ($article == false) {
         header("Location: /index/notfound");
         return;
     }
     $params['tags'] = SqlRepository::getTags($article_id);
     $params['title'] = $article->get_title();
     $params['indexs'] = json_decode($article->get_indexs());
     $params['contents'] = \TechlogTools::pre_treat_article($article->get_draft());
     $params['title_desc'] = $article->get_title_desc();
     $params['article_category_id'] = $article->get_category_id();
     if (StringOpt::spider_string($params['contents'], '"page-header"', '</div>') === null) {
         $params['contents'] = '<div class="page-header"><h1>' . $article->get_title() . '</h1></div>' . $params['contents'];
     }
     $article->set_access_count($article->get_access_count() + 1);
     Repository::persist($article);
     $params['inserttime'] = $article->get_inserttime() . '&nbsp;&nbsp;&nbsp;最后更新: ' . $article->get_updatetime() . '&nbsp;&nbsp;&nbsp;访问数量:' . ($article->get_access_count() + 1);
     return $params;
 }
Beispiel #2
0
 function listAction()
 {
     $date_num = array(31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30);
     $infos = SqlRepository::getTagIdCount();
     $tag_infos = array();
     foreach ($infos as $info) {
         $info['tag_name'] = Repository::findTagNameFromTags(array('eq' => array('tag_id' => $info['tag_id'])));
         $tag_infos[] = $info;
     }
     //$first_date = '2013-12-15';
     $dates = array();
     $timestamp = time() - 3600;
     $month_num = (date('Y', $timestamp) - 2013) * 12 + (date('m', $timestamp) - 12) + 1;
     for ($i = 0; $i <= $month_num; $i++) {
         $info = array();
         $y = date('Y', $timestamp);
         $m = date('m', $timestamp);
         $timestamp -= 3600 * 24 * $date_num[$m - 1];
         if ($m == 3 && ($y % 100 == 0 && $y % 400 == 0 || $y % 100 != 0 && $y % 4 == 0)) {
             $timestamp -= 3600;
         }
         $date = $y . '-' . $m;
         $info['id'] = $y . '0' . $m;
         $info['month'] = $date;
         $info['article'] = Repository::findCountFromArticle(array('ge' => array('inserttime' => $date . '-01 00:00:00"'), 'le' => array('inserttime' => $date . '-31 00:00:00"')));
         $info['mood'] = Repository::findCountFromMood(array('ge' => array('inserttime' => $date . '-01 00:00:00"'), 'le' => array('inserttime' => $date . '-31 00:00:00"')));
         $dates[] = $info;
     }
     $params = array('dates' => $dates, 'tags' => $tag_infos, 'tag_count' => count($tag_infos), 'title' => '检索一下', 'category_id' => 1);
     $this->display(__METHOD__, $params);
 }
Beispiel #3
0
 public function listAction()
 {
     $notes = SqlRepository::getBooknotes();
     $booknotes = array();
     foreach ($notes as $note) {
         $infos = array();
         $infos['idx_href'] = '/article/list/' . $note->get_index_article_id();
         $infos['image_path'] = Repository::findPathFromImages(array('eq' => array('image_id' => $note->get_image_id())));
         $title = Repository::findTitleFromArticle(array('eq' => array('article_id' => $note->get_index_article_id())));
         $infos['title'] = mb_substr($title, 0, 35);
         $infos['descs'] = mb_substr($note->get_descs(), 0, 35);
         $booknotes[] = $infos;
     }
     $params = array('infos' => $booknotes, 'title' => '读书笔记', 'category_id' => 2);
     $this->display(__METHOD__, $params);
 }
Beispiel #4
0
 public function listAction()
 {
     $labels = array();
     $uv = array();
     $pv = array();
     $timestamp = time();
     for ($i = 0; $i < 14; ++$i) {
         $date = date('Y-m-d', $timestamp - 3600 * 24 * (14 - 1) + $i * 3600 * 24);
         list($total, $date) = SqlRepository::getUVInfos($date);
         $uv[] = $total;
         $labels[] = $date;
     }
     $pv_count = SqlRepository::getPVInfos($timestamp);
     foreach ($pv_count as $pv_info) {
         $pv[] = $pv_info['total'];
     }
     $all_pv = Repository::findCountFromStats();
     $all_uv = RedisRepository::getAllUV();
     $category_infos = SqlRepository::getCategoryInfos();
     $colors = array(array('color' => 'rgba(0, 255, 255, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'), array('color' => 'rgba(255, 255, 128, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'), array('color' => 'rgba(128, 128, 255, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'), array('color' => 'rgba(17, 177, 255, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'), array('color' => 'rgba(255, 128, 192, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'), array('color' => 'rgba(128, 255, 128, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'), array('color' => 'rgba(104, 180, 255, 0.8)', 'light' => 'rgba(220, 220, 220, 0.3)'));
     $category_data = array();
     $temp_infos = array();
     for ($i = 0; $i < count($category_infos); ++$i) {
         $infos = $category_infos[$i];
         $temp_infos['label'] = $infos['category'];
         $temp_infos['value'] = intval($infos['total']);
         $temp_infos['color'] = $colors[$i]['color'];
         $temp_infos['highlight'] = $colors[$i]['light'];
         $category_data[] = $temp_infos;
     }
     $category_data[] = array('label' => '心情小说', 'value' => intval(Repository::findCountFromMood()), 'color' => $colors[count($colors) - 1]['color'], 'highlight' => $colors[count($colors) - 1]['light']);
     $category_infos = SqlRepository::getCategoryNewArticle();
     $category_ids = array('龙潭书斋' => 1, '读书笔记' => 2, '龙渊阁记' => 3, '技术分享' => 4);
     if ($this->is_root) {
         $category_ids['龙泉日记'] = 5;
         $category_ids['龙泉财报'] = 6;
         $category_ids['心情小说'] = 'mood';
     }
     $params = array('all_pv' => $all_pv, 'all_uv' => $all_uv, 'today_pv' => $pv[13], 'today_uv' => $uv[13], 'category_infos' => $category_infos, 'category_ids' => json_encode($category_ids), 'pv' => json_encode($pv), 'uv' => json_encode($uv), 'labels' => json_encode($labels), 'category_data' => json_encode($category_data), 'title' => '数据统计');
     $this->display(__METHOD__, $params);
 }
Beispiel #5
0
 private function getArticleInfos($articles, $is_moode = false)
 {
     if (empty($articles)) {
         return array();
     }
     $ret = array();
     foreach ($articles as $article) {
         $ret_infos = array();
         preg_match('/^(?<month>\\d{4}-\\d{2})-(?<date>\\d{2})/is', $article->get_inserttime(), $arr);
         $ret_infos['month'] = str_replace('-', '/', $arr['month']);
         $ret_infos['date'] = $arr['date'];
         $tags = SqlRepository::getTags($article->get_article_id());
         if (is_array($tags)) {
             $ret_infos['tags'] = array_slice($tags, 0, 4);
         }
         $contents = TechlogTools::pre_treat_article($article->get_draft());
         $imgpath = StringOpt::spider_string($contents, 'img<![&&]>src="', '"');
         if ($imgpath == null) {
             $ret_infos['contents'] = strip_tags($contents);
             $ret_infos['contents'] = mb_substr($ret_infos['contents'], 0, 500, 'utf-8');
         } else {
             $ret_infos['contents'] = '<p><a href="/article/list/' . $article->get_article_id() . '" target="_blank">' . '<img class="img-thumbnail" alt="200x200" style="height: 200px;"' . ' src="' . $imgpath . '"></a></p><br /><p>' . mb_substr(strip_tags($contents), 0, 100, 'utf-8') . '</p>';
         }
         $ret_infos['title'] = $article->get_title();
         $ret_infos['article_id'] = $article->get_article_id();
         $ret[] = $ret_infos;
     }
     return $ret;
 }