function __construct() { Form::Form('NewsAdminEditForm'); $id = Url::get('id', 0); if ($id) { $this->news = DB::select("news", "id=" . $id, __LINE__ . __FILE__); } if (!$this->news) { Url::redirect_current(); } AZLib::getNewsCats(); }
function draw() { global $display; $cat_newss = array(); $news_cat_id = Url::get('news_catid', 'id', 0); AZLib::getNewsCats(); $display->add('news_cat_id', $news_cat_id); if (CGlobal::$allNewsCategories) { foreach (CGlobal::$allNewsCategories as $news_cat) { if ($news_cat['public']) { $news_cat['url'] = URL::build('news_list', array('news_catid' => $news_cat['id'], 'azname' => AZLib::safe_title($news_cat['name']))); $cat_newss[$news_cat['id']] = $news_cat; } } } $display->add('cat_newss', $cat_newss); $display->add('is_admin', User::have_permit(ADMIN_NEWS)); $display->output("NewsMenu"); }
function on_submit() { $name = Url::get('name'); $public = Url::get('public', 1); $position = Url::get('position', 'int', 0); $keywords = Url::get('keywords'); $description = Url::get('description'); if ($public != 1) { $public = 0; } $this->checkFormInput("Tên danh mục tin", 'name', $name, 'str', true, '', 2, 100); $this->checkFormInput("Vị trí", 'position', $position, 'int', true, '', 1, DB::count("news_categories") + 1); if (!$this->errNum) { $id = DB::insert('news_categories', array('name' => $name, 'keywords' => $keywords, 'description' => $description, 'position' => $position, 'public' => $public, 'user_modify' => User::user_name(), 'time_modify' => TIME_NOW, 'user_create' => User::user_name(), 'time_create' => TIME_NOW)); DB::query("UPDATE news_categories SET position=position+1 WHERE id!=" . $id . " AND position>=" . $position); AZLib::getNewsCats(1); Url::redirect_current(); } }
function draw() { global $display; $home_newss = array(); $display->add('is_admin', User::have_permit(ADMIN_NEWS)); $display->add('url_home', WEB_DIR); $display->add('time_now', News::displayTime()); $one_cart = ''; AZLib::getNewsCats(); if (CGlobal::$allNewsCategories) { foreach (CGlobal::$allNewsCategories as $news_catid => $news_cat) { if ($news_cat['public']) { $newss = array(); $re = DB::query("SELECT * FROM news WHERE status=1 AND news_catid={$news_catid} ORDER BY id DESC LIMIT 0,4"); if ($re) { $i = 1; while ($news = mysql_fetch_assoc($re)) { if ($i == 1) { if ($news['image']) { $news['image'] = AZLib::getImageThumb($news['image'], 150, 0, 0, $news['img_server']); } $i++; } $news['url'] = URL::build('news_detail', array('news_catid' => $news['news_catid'], 'news_id' => $news['id'], 'azname' => AZLib::safe_title($news['title']))); $news['news_h'] = date('H:i', $news['time_created']); $news['news_d'] = date('d-m-Y', $news['time_created']); $newss[$news['id']] = $news; } } if ($newss) { $home_newss[$news_catid] = array('name' => $news_cat['name'], 'url' => URL::build('news_list', array('news_catid' => $news_catid, 'azname' => AZLib::safe_title($news_cat['name']))), 'newss' => $newss); } } } } $display->add('home_newss', $home_newss); $display->output("NewsHome"); }
function __construct() { Form::Form('NewsListForm'); $news_cat_id = Url::get('news_catid', 'id', 0); AZLib::getNewsCats(); if ($news_cat_id && isset(CGlobal::$allNewsCategories[$news_cat_id]) && (CGlobal::$allNewsCategories[$news_cat_id]['public'] || User::have_permit(ADMIN_NEWS))) { $this->news_cat = CGlobal::$allNewsCategories[$news_cat_id]; } else { Url::redirect('news'); } $news_title = ''; $catid = $news_cat_id; $str_keywords = ''; $str_catSub = ''; $meta_keywords = ''; $meta_desc = ''; if (isset(CGlobal::$allNewsCategories[$catid])) { $news_title .= CGlobal::$allNewsCategories[$catid]['name']; $curMainCat = CGlobal::$allNewsCategories[$catid]; $str_catSub .= $curMainCat['name']; if ($curMainCat['keywords']) { $meta_keywords .= ($meta_keywords ? ', ' : '') . $curMainCat['keywords']; } if ($curMainCat['description']) { $meta_desc .= ($meta_desc ? ', ' : '') . $curMainCat['description']; } } if ($meta_desc != '') { CGlobal::$meta_desc = $meta_desc; } if ($meta_keywords != '') { CGlobal::$keywords = $meta_keywords; } elseif ($str_catSub != '') { CGlobal::$keywords = $str_catSub; } CGlobal::$website_title = stripslashes($news_title) . " - Tin tức"; }
function __construct() { Form::Form('DeleteNewsForm'); $id = Url::get('id', 0); if ($id) { $row = DB::select('news', "id={$id}"); if ($row) { DB::delete('news_categories', "id=" . $row['id']); DB::query("UPDATE news_categories SET position=position-1 WHERE id!=" . $row['id'] . " AND position>=" . $row['position']); AZLib::getNewsCats(1); } } Url::redirect_current(); }
function draw() { global $display; AZLib::get_config(); /*if (CGlobal::$curZone) { $zone_id = CGlobal::$curZone['id']; } else { $zone_id = 0; }*/ $zid = (int) Url::get("zone_id", 0); $display->add('cur_page', AZNet::$page['name']); $display->add('ADMIN_LOGO', User::have_permit(ADMIN_LOGO)); $in_detail_page = AZNet::$page['name'] == 'item_detail'; $topcats = array(); $pcats = array(); $stt = 0; $stt2 = 0; foreach (CGlobal::$subCategories as $top_id => $sub_cats) { if (isset(CGlobal::$allCategories[$top_id]) && CGlobal::$allCategories[$top_id]['parent_id'] == 0) { $topcat = CGlobal::$allCategories[$top_id]; if ($topcat['status'] == "HOME") { $topcat['name'] = $topcat['brief_name']; if (count($sub_cats) > 7) { $stt2++; } $topcat['left'] = "-" . (($stt2 - 1) * 30 + 10) . "px"; $topcat['url'] = WEB_DIR . "c{$topcat['id']}/{$topcat['ebname']}"; $topcat['selected'] = (int) (CGlobal::$curMainCat && CGlobal::$curMainCat['id'] == $topcat['id']); $topcat['selected2'] = 0; if ($topcat['selected']) { if ($sub_cats) { $topcat['class'] = "hm_item_list_sub"; } else { $topcat['class'] = "hm_item_seleted"; } } else { $topcat['class'] = "hm_item"; } if ($sub_cats) { $topcat['subs'] = array(); $num_sub = 0; foreach ($sub_cats as $sid => $subcat) { if ($subcat['status'] != "HIDE") { $subcat['url'] = WEB_DIR . "c{$subcat['id']}/{$topcat['ebname']}-{$subcat['ebname']}"; //$subcat['name'] = $subcat['brief_name']; if (CGlobal::$curLevel2Cat && CGlobal::$curLevel2Cat['id'] == $subcat['id']) { $topcat['selected2'] = 1; $topcat['class'] = "hm_item_seleted"; $subcat['class'] = "class='sub_seleted'"; } $topcat['subs'][$sid] = $subcat; $num_sub++; } } if ($topcat['selected'] && !$topcat['selected2']) { $max_per_col = ceil($num_sub / 5); if ($max_per_col <= 0) { $max_per_col = 1; } $display->add('max_per_col', $max_per_col); $display->add('subcat_items', $topcat['subs']); } } $topcats[$top_id] = $topcat; // if($stt++ >= 6) //break; } } } $display->add('topcats', $topcats); $display->add('web_dir', WEB_DIR); $display->add('DATA_PATH', DATA_PATH); //Load Logo //$test_time = mktime(0,0,0,11,26,2010); AZLib::getWebsiteLogo(); if (CGlobal::$websiteLogo !== FALSE && isset(CGlobal::$websiteLogo['current']['expired']) && CGlobal::$websiteLogo['current']['expired'] && CGlobal::$websiteLogo['current']['expired'] < TIME_NOW) { // Nếu Logo đang sử dụng đã hết hạn, lấy Logo còn hạn hoặc lấy Logo mặc định AZLib::getWebsiteLogo(1); } $display->add('logo', CGlobal::$websiteLogo['current']); $display->add('logos', CGlobal::$websiteLogo['logos']); //Top menu if (!isset($_SESSION['is_load_page_first'])) { $_SESSION['is_load_page_first'] = 0; } $display->add('url_root', WEB_ROOT); if (!User::is_login()) { $num_mess = 0; } else { $num_mess = User::$current->data['total_pm'] > 0 ? User::$current->data['total_pm'] : 0; } if (User::id()) { $display->add('user_id', User::id()); $user_name = User::$current->data['user_name']; $display->add('user_name', $user_name); } $referer_login_url = ''; $yahoo_open_id_href = ''; $google_open_id_href = ''; if (isset($_SESSION['openid_url']) && $_SESSION['user_id'] != 0) { $display->add('show_openid', FALSE); } elseif (!User::is_az_team()) { AZLib::check_uri(); $referer_login_url = base64_encode(CGlobal::$query_string); $yahoo_open_id_href = OID_URL . 'index.html?openid_identifier=http://me.yahoo.com/&long_redirect=' . base64_encode(CGlobal::$query_string); $google_open_id_href = OID_URL . 'index.html?openid_identifier=https://www.google.com/users/o8/id&long_redirect=' . base64_encode(CGlobal::$query_string); $display->add('show_openid', TRUE); } $display->add('OID_URL', $yahoo_open_id_href); $display->add('OID_URL_GOG', $google_open_id_href); $display->add('referer_login_url', $referer_login_url); $display->add('google_open_id_href', $google_open_id_href); $display->add('yahoo_open_id_href', $yahoo_open_id_href); $display->add('openid_on', OPENID_ON); $display->add('num_mess', $num_mess); $display->add('is_login', (int) User::is_login()); $display->add('is_admin', (int) User::is_az_team()); $display->add('is_admin_item', (int) User::have_permit(ADMIN_ITEM)); $display->add('is_root', User::is_root()); //End Top menu $display->add('category_id', CGlobal::$curCategory); $display->add('keywords', AZLib::cleanHtml(Url::get('keywords', ''))); $display->add('not_error_page', (int) (AZNet::$page['name'] != 'error')); $display->add('is_load_page_first', $_SESSION['is_load_page_first']); // Tỷ giá AZLib::get_config(); //$exchange = CGlobal::$configs['exchange']['conf_val']; //$display->add('exchange', number_format($exchange, 0, ',', '.')); // End Tỷ giá if ($_SESSION['is_load_page_first'] == 1) { $_SESSION['is_load_page_first'] = 0; } //End of top menu $curMainCat = CGlobal::$curMainCat; $curLevel2Cat = CGlobal::$curLevel2Cat; //Cat menu $sub_menu = FALSE; $sub_menu = $curMainCat && isset(CGlobal::$allCategories[$curMainCat['id']]) && isset(CGlobal::$subCategories[$curMainCat['id']]); $display->add('CURENT_TOP_CATID', (int) @$curMainCat['id']); $display->add('CURENT_LEVEL2_CATID', (int) @$curLevel2Cat['id']); $display->add('CURENT_CITY_ID', CGlobal::$curCity); $display->add('cur_page', Url::get('page')); $display->add('sub_menu', $sub_menu); $display->add('block_id', Module::$block_id); // System::debug($display->get_template_vars()); //End Cat menu if (User::is_root()) { $display->add("DEBUG", DEBUG); $display->add("show_bug_url", AZRewrite::formatUrl(Url::build_all(array(), "ebug=" . (int) (!DEBUG)))); } ################################################################################################################ #Event config $event_on = @CGlobal::$configs['event_on']['conf_val']; $submit = Url::get('submit', ''); if (User::is_admin()) { if ($submit == 'Cập nhật') { $display->add('msg', $this->showFormErrorMessages(1)); } $status_arr = array(0 => 'Tắt', 1 => 'Bật'); $display->add('status_option', AZLib::getOption($status_arr, $event_on)); } $display->add('event', $event_on); $display->add("data_path", DATA_PATH); #Event config ################################################################################################################ ################################################################################################################ #Search $search_catid = (int) Url::get('search_catid'); $search_cat_arr = array(-1 => '--Tất cả danh mục--'); foreach (CGlobal::$subCategories as $top_id => $sub_cats) { if (isset(CGlobal::$allCategories[$top_id]) && CGlobal::$allCategories[$top_id]['parent_id'] == 0) { $topcat = CGlobal::$allCategories[$top_id]; if ($topcat['status'] != "HIDE") { $search_cat_arr[$top_id] = $topcat['name']; if ($sub_cats) { foreach ($sub_cats as $sid => $subcat) { if ($subcat['status'] != "HIDE") { $search_cat_arr[$sid] = "-----" . $subcat['name']; } } } } } } $display->add('search_cat_option', AZLib::getOption($search_cat_arr, $search_catid)); #Search ################################################################################################################ /* System::debug($topcats);*/ $cat_newss = array(); $news_cat_id = Url::get('news_catid', 'id', 0); AZLib::getNewsCats(); $display->add('news_cat_id', $news_cat_id); if (CGlobal::$allNewsCategories) { foreach (CGlobal::$allNewsCategories as $news_cat) { if ($news_cat['public']) { $news_cat['url'] = URL::build('news_list', array('news_catid' => $news_cat['id'], 'azname' => AZLib::safe_title($news_cat['name']))); $cat_newss[$news_cat['id']] = $news_cat; } } } $display->add('cat_newss', $cat_newss); $display->output("Header"); // $display->output("header_old"); }
function __construct() { Form::Form('NewsAdminAddForm'); AZLib::getNewsCats(); }
function __construct() { Form::Form('MoveHomeNewsCatForm'); $catid = Url::get('id', 0); if ($catid) { $cmd = Url::get('cmd'); $category = DB::select('news_categories', $catid); if ($category) { if ($cmd == 'move_home') { DB::query("UPDATE news_categories SET position = 1 WHERE id={$category['id']}"); DB::query("UPDATE news_categories SET position = position+1 WHERE id!={$category['id']} AND position>=1 AND position<={$category['position']}"); } else { $posMax = DB::count("news_categories"); DB::query("UPDATE news_categories SET position = {$posMax} WHERE id={$category['id']}"); DB::query("UPDATE news_categories SET position = position-1 WHERE id!={$category['id']} AND position>={$category['position']} AND position<={$posMax}"); } AZLib::getNewsCats(1); } } Url::redirect_current(); }
function draw() { global $display; AZLib::getNewsCats(); $display->add('url_add', Url::build_current(array('cmd' => 'add'))); $display->add('msg', $this->showFormErrorMessages(1)); $news_catid = Url::get('news_catid', 0); $status = Url::get('status', 3); $date_begin = Url::get('date_begin'); $date_end = Url::get('date_end'); $keyword = Url::get('searchtext'); $hot = Url::get('hot', 1); for ($i = 1; $i <= 3; $i++) { $display->add('selected_' . $i, ''); } $display->add('selected_' . Url::get('status', 3), 'selected'); for ($i = 1; $i <= 2; $i++) { $display->add('tinnhanh_' . $i, ''); } $display->add('tinnhanh_' . Url::get('tinnhanh', 2), 'selected'); $condition = ' 1 '; if ($news_catid) { $condition .= " AND news_catid ={$news_catid} "; } if ($keyword != '') { $condition .= " AND ((title like '%{$keyword}%') OR (brief like '%{$keyword}%')) "; } $created_time_from = 0; $created_time_to = 0; if ($date_begin) { $date_arr = explode("-", $date_begin); if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) { $created_time_from = mktime(0, 0, 0, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]); } } if ($date_end) { $date_arr = explode("-", $date_end); if (isset($date_arr[0]) && isset($date_arr[1]) && isset($date_arr[2])) { $created_time_to = mktime(23, 59, 59, (int) $date_arr[1], (int) $date_arr[0], (int) $date_arr[2]); } } if ($created_time_from) { $condition .= ' AND time_created >=' . $created_time_from; } if ($date_end) { $condition .= " AND time_created <={$created_time_to}"; } if ($status != 3) { $condition .= ' and status=' . $status; } if ($hot == 2) { $condition .= ' and hot=' . $hot; } $cat_arr = array(0 => "--Danh mục tin--"); if (CGlobal::$allNewsCategories) { foreach (CGlobal::$allNewsCategories as $news_cat) { $cat_arr[$news_cat['id']] = "[{$news_cat['id']}] " . $news_cat['name'] . ($news_cat['public'] == 0 ? ' (Đã ẩn)' : ''); } } //$news_catid $display->add('news_cat_option', AZLib::getOption($cat_arr, $news_catid)); $display->add('hot_option', AZLib::getOption(array('1' => "Tất cả", 2 => "Tin Hot"), $hot)); $display->add('status_option', AZLib::getOption(array(3 => "Tất cả", 1 => "Hiện", 2 => "Ẩn"), $status)); $display->add('keyword', $keyword); $display->add('date_begin', $date_begin); $display->add('date_end', $date_end); $totalRows = DB::count("news", $condition); $limit = ''; $pagging = AZPagging::pagingSE($limit, $totalRows, 20, 10, 'page_no', "tin"); //$pagging = AZPagging::paging_list($limit,20,'page_no'); $items = array(); $re = DB::query('SELECT * FROM news WHERE ' . $condition . " ORDER BY id DESC " . $limit, __LINE__ . __FILE__, false, false, false, true); if ($re) { while ($item = mysql_fetch_assoc($re)) { $item['admin_link'] = News::admin_link($item); if ($item['image']) { $item['image'] = AZLib::getImageThumb($item['image'], 150, 0, 0, $item['img_server']); } $item['cat'] = "[{$item['news_catid']}] " . @CGlobal::$allNewsCategories[$item['news_catid']]['name']; $item['time_created'] = date('d/m/Y', $item['time_created']); $item['brief'] = stripslashes($item['brief']); $item['title'] = stripslashes($item['title']); $item['url'] = Url::build('news_detail', array('news_catid' => $item['news_catid'], 'news_id' => $item['id'])); $items[$item['id']] = $item; } } $display->add('items', $items); $display->add('pagging', $pagging); $this->beginForm(); $display->output("NewsAdmin"); $this->endForm(); }