function getlistAction()
 {
     $order_dir = front::$_req["dir"];
     if (!in_array($order_dir, array("ASC", "DESC"))) {
         $order_dir = "ASC";
     }
     $order_col = front::$_req["sort"];
     if (!in_array($order_col, array("id", "title", "date_create"))) {
         $order_col = "id";
     }
     $limit = front::$_req["limit"];
     if (!$limit) {
         $limit = 20;
     }
     $offset = front::$_req["start"];
     if (!$offset) {
         $offset = 0;
     }
     $totalCount = front::og("db")->select("SELECT COUNT(*) FROM corporative_blog WHERE id_blog = 0")->fetchOne();
     $blogs = front::og("db")->select("SELECT c.*, u.uname, u.usurname, u.login FROM corporative_blog c JOIN users u on u.uid = c.id_user  WHERE id_blog = 0 ORDER BY ?v ?v LIMIT ? OFFSET ?", $order_col, $order_dir, $limit, $offset)->fetchAll();
     $bids = front::get_hash($blogs, "id", "id");
     $uids = front::get_hash($blogs, "id_user", "id_user");
     $comm = front::get_hash(front::og("db")->select("SELECT COUNT(id_blog) as count, id_blog FROM corporative_blog WHERE id_blog IN(?a) GROUP BY id_blog", $bids)->fetchAll(), "id_blog", "count");
     $user = front::og("db")->select("SELECT uname, usurname, login, uid FROM users WHERE uid IN(?a)", $uids)->fetchAll();
     //, "uid", "usname");
     foreach ($user as $k => $v) {
         $usr[$v['uid']] = $v;
     }
     $blogs = front::toUtf($blogs);
     echo json_encode(array("data" => $blogs, "totalCount" => $totalCount));
 }
Пример #2
0
 public function getlistAction()
 {
     $order_dir = front::$_req['dir'];
     if (!in_array($order_dir, array('ASC', 'DESC'))) {
         $order_dir = 'ASC';
     }
     $order_col = front::$_req['sort'];
     if (!in_array($order_col, array('id', 'title', 'date_create'))) {
         $order_col = 'id';
     }
     $limit = front::$_req['limit'];
     if (!$limit) {
         $limit = 20;
     }
     $offset = front::$_req['start'];
     if (!$offset) {
         $offset = 0;
     }
     $totalCount = front::og('db')->select('SELECT COUNT(*) FROM corporative_blog WHERE id_blog = 0')->fetchOne();
     $blogs = front::og('db')->select('SELECT c.*, u.uname, u.usurname, u.login FROM corporative_blog c JOIN users u on u.uid = c.id_user  WHERE id_blog = 0 ORDER BY ?v ?v LIMIT ? OFFSET ?', $order_col, $order_dir, $limit, $offset)->fetchAll();
     $bids = front::get_hash($blogs, 'id', 'id');
     $uids = front::get_hash($blogs, 'id_user', 'id_user');
     $comm = front::get_hash(front::og('db')->select('SELECT COUNT(id_blog) as count, id_blog FROM corporative_blog WHERE id_blog IN(?a) GROUP BY id_blog', $bids)->fetchAll(), 'id_blog', 'count');
     $user = front::og('db')->select('SELECT uname, usurname, login, uid FROM users WHERE uid IN(?a)', $uids)->fetchAll();
     //, "uid", "usname");
     foreach ($user as $k => $v) {
         $usr[$v['uid']] = $v;
     }
     $blogs = front::toUtf($blogs);
     echo json_encode(array('data' => $blogs, 'totalCount' => $totalCount));
 }
Пример #3
0
 /**
  * Выборка блогов из таблицы
  *
  * @param int $page Страница
  * @param int $count Количество на странице
  */
 function getCorporateBlog($page = 1, $count = 10, $tags = false)
 {
     if (!$tags) {
         $total = front::og("db")->select("SELECT COUNT(*) FROM corporative_blog WHERE id_blog = 0  AND (id_deleted IS NULL OR id_deleted = 0)")->fetchOne();
         front::og("tpl")->page_corp = $page;
         front::og("tpl")->pages_corp = ceil($total / $count);
         front::og("tpl")->total_corp = $total;
         $nPages = ceil($total / $count);
         if (($total == 0 || $total - 1 < ($page - 1) * $count) && $this->uri[0] == 'page' || $nPages == 1 && $this->uri[0] == 'page') {
             include ABS_PATH . '/404.php';
             exit;
         }
     }
     $page--;
     $sql_page = $page * $count;
     $blogs = front::og("db")->select("SELECT * FROM corporative_blog WHERE " . ($tags ? ' id IN(?a) AND ' : ' 0 = ? AND ') . " id_blog = 0 AND (id_deleted IS NULL OR id_deleted = 0) ORDER BY id DESC LIMIT ? OFFSET ?", $tags ? $tags : 0, $count, $sql_page)->fetchAll();
     if (!$blogs && $tags) {
         Header("Location: /404.php");
     }
     $bids = front::get_hash($blogs, "id", "id");
     $uids = front::get_hash($blogs, "id_user", "id_user");
     //return false;
     if ($bids) {
         //$comm  = front::get_hash(front::og("db")->select("SELECT COUNT(id_blog) as count, id_blog FROM corporative_blog WHERE id_blog IN(?a) GROUP BY id_blog", $bids)->fetchAll(), "id_blog", "count");
         $user = front::og("db")->select("SELECT uname, usurname, login, uid, role, is_pro, is_pro_test, boss_rate FROM users WHERE uid IN(?a)", $uids)->fetchAll();
         //, "uid", "usname");
         foreach ($blogs as $k => $v) {
             $cid[$v['id']] = $v['id'];
         }
         if ($cid) {
             $attach = front::og("db")->select("SELECT * FROM corporative_blog_attach WHERE msg_id IN(?a)", $cid)->fetchAll();
         }
         if ($attach) {
             foreach ($attach as $key => $val) {
                 $res_attach[$val['msg_id']][] = $val;
             }
             front::og("tpl")->attach = $res_attach;
         }
         foreach ($user as $k => $v) {
             $usr[$v['uid']] = $v;
         }
         list($lastDate, $upDate) = self::getViewPostsDate($bids);
     }
     //var_dump($lastDate);
     //var_dump($upDate);
     front::og("tpl")->usbank = $usr;
     //front::og("tpl")->comment = $comm;
     front::og("tpl")->blogs = $blogs;
     front::og("tpl")->lastDate = $lastDate;
     front::og("tpl")->upDate = $upDate;
     front::og("tpl")->tags = self::getCorpTags();
     //self::GetTags($count, 10);
     //front::og("tpl")->attach  = $attach;
     //self::getCorpTags();
     return array($blogs, $usr);
 }
Пример #4
0
 /**
  * Выборка блогов из таблицы
  *
  * @param int $page страница
  * @param int $count количество на странице
  */
 function getCorporateBlog($page = 1, $count = 10)
 {
     $total = front::og("db")->select("SELECT COUNT(*) FROM corporative_blog WHERE id_blog = 0  AND (id_deleted IS NULL OR id_deleted = 0)")->fetchOne();
     front::og("tpl")->page_corp = $page;
     front::og("tpl")->pages_corp = ceil($total / $count);
     front::og("tpl")->total_corp = $total;
     $page--;
     $sql_page = $page * $count;
     $blogs = front::og("db")->select("SELECT * FROM corporative_blog WHERE id_blog = 0 AND (id_deleted IS NULL OR id_deleted = 0) ORDER BY id DESC LIMIT ? OFFSET ?", $count, $sql_page)->fetchAll();
     $bids = front::get_hash($blogs, "id", "id");
     $uids = front::get_hash($blogs, "id_user", "id_user");
     $comm = front::get_hash(front::og("db")->select("SELECT COUNT(id_blog) as count, id_blog FROM corporative_blog WHERE id_blog IN(?a) GROUP BY id_blog", $bids)->fetchAll(), "id_blog", "count");
     $user = front::og("db")->select("SELECT uname, usurname, login, uid, role, is_pro, is_pro_test, boss_rate FROM users WHERE uid IN(?a)", $uids)->fetchAll();
     //, "uid", "usname");
     foreach ($blogs as $k => $v) {
         $cid[$v['id']] = $v['id'];
     }
     if ($cid) {
         $attach = front::og("db")->select("SELECT * FROM corporative_blog_attach WHERE msg_id IN(?a)", $cid)->fetchAll();
     }
     if ($attach) {
         foreach ($attach as $key => $val) {
             $res_attach[$val['msg_id']][] = $val;
         }
         front::og("tpl")->attach = $res_attach;
     }
     foreach ($user as $k => $v) {
         $usr[$v['uid']] = $v;
     }
     front::og("tpl")->usbank = $usr;
     front::og("tpl")->comment = $comm;
     front::og("tpl")->blogs = $blogs;
     //front::og("tpl")->attach  = $attach;
 }