Exemple #1
0
 /**
  * Return the comment list
  *
  * @param Integer $key , post id
  * @param Integer $limit , 
  * @param Integer $page
  * @return Array 
  */
 public function getCommentList($key, $limit = 10, $page = 1)
 {
     $comment = self::instance();
     $table = $this->table;
     $count = $comment->field("count(*) as count")->where("type = 1 AND post_id='{$key}'")->fetchList();
     $count = $count ? $count[0]['count'] : 0;
     $offset = 0;
     $pages = $count / $limit;
     $pages = $pages < 1 ? 1 : $pages;
     $pages = is_float($pages) ? intval($pages) + 1 : $pages;
     $page = $page < 1 ? 1 : $page;
     $page = $page > $pages ? $pages : $page;
     $offset = $limit * ($page - 1);
     $list['count'] = $count;
     $list['page'] = $page;
     $list['pages'] = $pages;
     $list["list"] = $comment->field("{$table}.id,post_id as bid,{$table}.uid,u.username,u.email,{$table}.content,{$table}.published,{$table}.parent,i.path as avatar")->joinQuery('members as u', "{$table}.uid = u.id")->joinQuery('images as i', "i.uid = {$table}.uid")->where("{$table}.post_id = '{$key}' AND {$table}.type = 1 AND i.class = 2")->order("{$table}.published DESC")->limit("{$offset},{$limit}")->fetchList();
     if ($list['list']) {
         foreach ($list["list"] as $key => $value) {
             $list['list'][$key]['avatar'] = ImageControl::getRelativeImage($value['avatar']);
         }
         return $list;
     } else {
         return array();
     }
 }
Exemple #2
0
 /**
  * Instance construct
  */
 function __construct()
 {
     parent::__construct();
     $this->images_book = ImagesBook::instance();
     $this->images_book_article = ImagesBookArticle::instance();
     $this->images_course_article = ImagesCourseArticle::instance();
     $this->images_member = ImagesMember::instance();
     $this->images_course = ImagesCourse::instance();
 }
 /**
  * [getUserForId description]
  * @param  [type] $uid [description]
  * @return [type]      [description]
  */
 public function getUserForId($uid)
 {
     $table = $this->members->table;
     $list = $this->members->field("{$table}.id,{$table}.email,{$table}.username,{$table}.published,{$table}.role_id,mi.avatar_id as cover,mi.sex,mi.birthday,mi.phone,mi.conntry,mi.province,mi.city,mi.address,mi.ip,mi.last_ip,mi.last_dateline,mi.summary,ur.name as role_name")->joinQuery('member_info as mi', "mi.id={$table}.id")->joinQuery('user_role as ur', "ur.id={$table}.role_id")->where("{$table}.id='{$uid}'")->order("{$table}.published")->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover'] = ImageControl::getRelativeImage($value['cover']);
             }
         }
         return $list[0];
     }
     return false;
 }
Exemple #4
0
 /**
  * [getCategory description]
  * @return [type] [description]
  */
 public function getCategory()
 {
     $category = self::instance();
     $table = $this->table;
     $list = $category->field("{$table}.cid,{$table}.name, {$table}.sort, {$table}.dateline, i.path as cover")->joinQuery("images as i", "{$table}.pid=i.pid")->limit(20)->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover'] = \lib\dao\ImageControl::getRelativeImage($value['cover']);
             }
         }
         $books->joinTables = array();
         return $list;
     }
     return "";
 }
 /**
  * [getDownloadForUserid description]
  *
  * $type:
  *      1 = api
  *      2 = m
  * $uid == 1 , free book;
  * 
  * @param  [type]  $uid  [description]
  * @param  integer $type [description]
  * @return [type]        [description]
  */
 public function getDownloadForUserid($uid, $limit = 10, $page = 1, $type = 1)
 {
     $table = $this->downloads->table;
     $sql = "({$table}.uid = '{$uid}' || {$table}.uid = '1') AND {$table}.type = '{$type}' AND bi.type = 1 AND i.class=1";
     $offset = $page == 1 ? 0 : ($page - 1) * $limit;
     $list = $this->downloads->field("DISTINCT b.bid,{$table}.did,{$table}.published,{$table}.uid,{$table}.old_id,b.title,b.author,i.path as cover")->joinQuery("books as b", "{$table}.old_id=b.bid")->joinQuery('book_image as bi', "b.bid=bi.bid")->joinQuery('images as i', 'i.pid=bi.pid')->where($sql)->order("{$table}.published")->limit($offset, $limit)->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover'] = ImageControl::getRelativeImage($value['cover']);
             }
         }
         $this->downloads->joinTables = array();
         return $list;
     }
     return false;
 }
Exemple #6
0
 public function getMembersList($option = array(), $limit = 10, $page = 1)
 {
     $sql = '';
     if (is_array($option) or $option) {
         $i = 1;
         $count = count($option);
         foreach ($option as $key => $value) {
             if ($i == $count) {
                 $sql .= "{$key}='" . $value . "'";
             } else {
                 $sql .= "{$key}='" . $value . "' AND ";
             }
             $i++;
         }
     }
     $offset = $page == 1 ? 0 : ($page - 1) * $limit;
     $table = $this->members->table;
     $list = $this->members->field("{$table}.id,{$table}.email,{$table}.username,{$table}.published,{$table}.role_id,r.name as role_name,mi.ip,mi.last_ip,im.path as cover,mi.last_dateline as dateline,mi.summary")->joinQuery("user_role as r", "{$table}.role_id=r.id")->joinQuery('member_info as mi', "{$table}.id=mi.id")->joinQuery('images_member as im', "im.imid=mi.avatar_id")->where($sql)->order("{$table}.id")->limit("{$offset},{$limit}")->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover_small'] = ImageControl::getRealCoverSize($list[$key]['cover']);
                 $list[$key]['cover_medium'] = ImageControl::getRealCoverSize($list[$key]['cover'], "medium");
                 $list[$key]['cover'] = ImageControl::getRelativeImage($value['cover']);
             }
         }
         return $list;
     }
     return false;
 }
Exemple #7
0
 /**
  * [getBookInfo description]
  * @param  [String] $bid [description]
  * @return [Array]      [return list of the bookInfo]
  */
 public function getBookInfo($bid)
 {
     $books = self::instance();
     $table = $books->table;
     $userStatus = Members::getCurrentUser();
     $userID = isset($userStatus->id) ? $userStatus->id : 0;
     $list = $books->field("{$table}.bid,{$table}.cid,{$table}.title,{$table}.author,i.path as cover,{$table}.pubtime,{$table}.isbn,{$table}.press,f.apple_price as price,{$table}.summary,f.tags")->joinQuery("book_info as f", "{$table}.bid=f.bid")->joinQuery('book_image as p', "{$table}.bid=p.bid")->joinQuery('images as i', 'i.pid=p.pid')->joinQuery('book_fields as bf', "{$table}.bid=bf.bid AND bf.uid={$userID}")->where("{$table}.bid='{$bid}'")->order("{$table}.published")->limit(1)->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover'] = ImageControl::getRelativeImage($value['cover']);
             }
         }
         return $list[0];
     }
     return "";
 }
 public function getPurchasedForBooks($option = array(), $limit = 10, $page = 1)
 {
     if (!is_array($option) or !$option) {
         return false;
     }
     $sql = '';
     $i = 1;
     $table = $this->productPurchased->table;
     $option = array_merge_recursive($option, array('bi.type' => '1'));
     $count = count($option);
     foreach ($option as $key => $value) {
         if ($i == $count) {
             $sql .= "{$key}='" . $value . "'";
         } else {
             $sql .= "{$key}='" . $value . "' AND ";
         }
         $i++;
     }
     $offset = $page == 1 ? 0 : ($page - 1) * $limit;
     $list = $this->productPurchased->field("{$table}.pid,{$table}.status,{$table}.published,{$table}.uid,b.bid,b.title,b.author,i.path as cover,p.total_fee as price")->joinQuery("products as p", "{$table}.pid=p.pid")->joinQuery("books as b", "p.oldid=b.bid")->joinQuery('book_image as bi', "b.bid=bi.bid")->joinQuery('images as i', 'i.pid=bi.pid')->where($sql)->order("{$table}.published")->limit($offset, $limit)->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover'] = ImageControl::getRelativeImage($value['cover']);
             }
         }
         $this->productPurchased->joinTables = array();
         return $list;
     }
     return false;
 }
 /**
  * Get BookRecommand List 
  * 
  * @param Array, $option
  * @param Int, $limit
  * @param Int, $page
  * @param Int, $type
  * @return Array
  * */
 public function getBookRecommendList($option = array(), $cid = false, $limit = 10, $page = 1)
 {
     if (!is_array($option) or !$option) {
         return false;
     }
     $option['br.cid'] = $cid;
     $sql = '';
     $i = 1;
     $count = count($option);
     foreach ($option as $key => $value) {
         if ($i == $count) {
             $sql .= "{$key}='" . $value . "'";
         } else {
             $sql .= "{$key}='" . $value . "' AND ";
         }
         $i++;
     }
     $offset = $page == 1 ? 0 : ($page - 1) * $limit;
     $table = $this->book->table;
     $list = $this->book->field("{$table}.bid,{$table}.cid,{$table}.title,{$table}.author,i.path as cover,{$table}.pubtime,{$table}.isbn,{$table}.press,f.apple_price as price,{$table}.summary,f.tags")->joinQuery("book_info as f", "{$table}.bid=f.bid")->joinQuery('book_image as p', "{$table}.bid=p.bid")->joinQuery('images as i', 'i.pid=p.pid')->joinQuery('book_fields as bf', "{$table}.bid=bf.bid")->joinQuery('book_recommend as br', "{$table}.bid=br.bid")->where($sql)->order("br.sort")->limit($offset, $limit)->fetchList();
     if (is_array($list)) {
         foreach ($list as $key => $value) {
             if (isset($value['cover']) and $value['cover']) {
                 $list[$key]['cover'] = ImageControl::getRelativeImage($value['cover']);
             }
         }
         return $list;
     }
     return false;
 }