Example #1
0
function addListObjectID($data, $type = "news")
{
    global $sys_config;
    $key = "{$type}-listcontent";
    if (!isset($sys_config[$key])) {
        $sys_config[$key] = array();
    }
    if (is_array($data)) {
        // du lieu la mang
        if (isset($data["id"])) {
            //1 chieu
            addObjectID($data["id"], $type);
        } else {
            foreach ($data as $item) {
                if (is_object($item)) {
                    //mang cac doi tuong
                    if (isset($item->id)) {
                        addObjectID($item->id, $type);
                    }
                } else {
                    if (is_array($item)) {
                        //mang 2 chieu
                        if (isset($item["id"])) {
                            addObjectID($item["id"], $type);
                        }
                    }
                }
            }
        }
    } else {
        if (is_object($data)) {
            // du lieu la doi tuong
            if (isset($data->id)) {
                addObjectID($data->id, $type);
            }
        } else {
            addObjectID($data, $type);
        }
    }
    return count($sys_config[$key]);
}
Example #2
0
 function getItems($catID = null, $feature = 0, $limit = 10, $start = 0)
 {
     //        filter_order, filter_order_Dir, limit, limitstart
     $filter_order = Request::getVar('filter_order', 'viewed');
     $filter_order_Dir = Request::getVar('filter_order_Dir', 'DESC');
     $command = Yii::app()->db->createCommand();
     $command->limit($limit, $start);
     $command->order("{$filter_order} {$filter_order_Dir}");
     $where = array();
     $where[] = "B.id = {$catID}";
     if ($feature == 1) {
         $where[] = "A.feature = 1";
     }
     $command->where(implode(" AND ", $where));
     $items = $command->select('A.*,B.title as cat_name,B.alias as cat_alias')->from("{$this->table}  A")->join("{$this->table_categories} B", 'A.catID=B.id')->queryAll();
     if (count($items)) {
         foreach ($items as &$item) {
             $params = array("view" => "detail", "id" => $item['id'], "alias" => $item['alias'], "catID" => $item['catID'], "cat_alias" => $item['cat_alias']);
             $item['link'] = Router::buildLink('videos', $params);
             addObjectID($item['id'], "videos");
         }
     }
     return $items;
 }
Example #3
0
 function getVideoCategoy($catID, $start = 0, $limit = 10)
 {
     global $mainframe, $db;
     $list_ids = getListObjectID("videos");
     $where = array();
     $where[] = "A.status = 1";
     $where[] = "B.status = 1";
     $where[] = "A.catID = {$catID} ";
     if ($list_ids != false and $list_ids != "") {
         $where[] = "A.id not in({$list_ids})";
     }
     $where = implode(" AND ", $where);
     $query = "SELECT A.*, B.alias cat_alias, B.title cat_title " . "FROM " . TBL_VIDEOS . " A LEFT JOIN " . TBL_CATEGORIES . " B ON A.catID = B.id " . " WHERE  {$where} " . " ORDER BY A.cdate DESC LIMIT {$start}, {$limit}";
     $query_command = $db->createCommand($query);
     $items = $query_command->queryAll();
     if (count($items)) {
         foreach ($items as &$item) {
             $params = array("view" => "detail", "id" => $item['id'], "alias" => $item['alias'], "catID" => $item['catID'], "cat_alias" => $item['cat_alias']);
             $item['link'] = Router::buildLink('videos', $params);
             addObjectID($item['id'], "video");
         }
     }
     return $items;
 }
Example #4
0
 function getItem($cid, $alias = null)
 {
     global $mainframe, $db;
     $where = array();
     $where[] = "A.status = 1";
     $where[] = "B.status = 1";
     if (intval($cid) != 0) {
         $where[] = " A.id = {$cid}";
     } else {
         $where[] = " A.alias = '{$alias}'";
     }
     $where = implode(" AND ", $where);
     $query_command = Yii::app()->db->createCommand();
     $query_command->select("A.*, B.alias cat_alias, B.title cat_title")->from($this->tablename . " A")->leftJoin($this->tbl_category . " B", "A.catID = B.id")->where($where);
     $item = $query_command->queryRow();
     if ($item == FALSE) {
         return false;
     }
     $params = array("view" => "category", "id" => $item['catID'], "alias" => $item['cat_alias']);
     $item['cat_link'] = Router::buildLink('articles', $params);
     $params = array("view" => "detail", "id" => $item['id'], "alias" => $item['alias'], "catID" => $item['catID'], "cat_alias" => $item['cat_alias']);
     $item['link'] = Router::buildLink('articles', $params);
     addObjectID($item['id'], "articles");
     return $item;
 }