Esempio n. 1
0
 function PageAdmin($row)
 {
     Module::Module($row);
     if (User::is_root()) {
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case 'delete_all_cache':
                 AZNet::update_all_page();
                 require_once ROOT_PATH . 'includes/enbac/dir.php';
                 empty_all_dir(PAGE_CACHE_DIR, true);
                 Url::redirect_current();
                 break;
             case 'refresh':
                 $id = (int) Url::get('id', 0);
                 if ($id) {
                     AZNet::update_page($id);
                     if (Url::check('href')) {
                         Url::redirect_url($_REQUEST['href']);
                     } else {
                         Url::redirect_current();
                     }
                 }
                 Url::redirect_current();
                 break;
             case 'delete':
                 $id = (int) Url::get('id', 0);
                 if ($id) {
                     DB::delete('block', 'page_id=' . $id);
                     DB::delete_id('page', $id);
                     require_once ROOT_PATH . 'includes/enbac/dir.php';
                     empty_all_dir(DIR_CACHE . 'pages', true);
                     empty_all_dir(DIR_CACHE . 'modules', true);
                 }
                 Url::redirect_current();
                 break;
             case 'edit':
             case 'add':
             case 'copy':
                 require_once 'forms/edit.php';
                 $this->add_form(new EditPageAdminForm());
                 break;
             default:
                 require_once 'forms/list.php';
                 $this->add_form(new ListPageAdminForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Esempio n. 2
0
 function on_submit()
 {
     if (Url::get('cmd') == 'delete_items') {
         $selected_ids = Url::get('selected_ids');
         if ($selected_ids) {
             $ids = implode(',', $selected_ids);
             if ($ids) {
                 AZNet::update_page($ids);
                 DB::delete('block', 'page_id IN(' . $ids . ')');
                 DB::delete('page', 'id IN(' . $ids . ')');
                 require_once ROOT_PATH . 'includes/enbac/dir.php';
                 empty_all_dir(PAGE_CACHE_DIR, true);
             }
         }
         Url::redirect_current();
     }
 }
Esempio n. 3
0
 function on_submit()
 {
     $name = trim(Url::get('name'));
     $title = trim(Url::get('title'));
     $layout = trim(Url::get('layout'));
     $description = trim(Url::get('description'));
     $this->checkFormInput('Tên page', 'name', $name, 'uname', true, '', 1, 255);
     if (!$layout) {
         $this->setFormError('layout', 'Bạn chưa chọn Layout!');
     } elseif (!file_exists(ROOT_PATH . $layout)) {
         $this->setFormError('layout', 'Layout không tồn tại!');
     }
     $this->checkFormInput('Tiêu đề', 'title', $title, 'str', false, '', 0, 255);
     $this->checkFormInput('Mô tả', 'description', $description, 'str', false, '', 0, 255);
     if (!$this->errNum) {
         $new_row = array('name' => $name, 'title' => $title, 'layout' => $layout, 'description' => $description);
         if (Url::get('cmd') == 'copy') {
             if ($name == $this->page['name'] || DB::select('page', 'name="' . $name . '"')) {
                 $this->setFormError('name', 'Tên trang "' . $name . '" đã tồn tại, hãy chọn tên khác!');
                 return;
             }
             $id = DB::insert('page', $new_row);
             if ($id) {
                 $re = DB::query('SELECT id, module_id, page_id, region, position FROM block WHERE page_id=' . $this->page['id']);
                 if ($re) {
                     while ($row = mysql_fetch_assoc($re)) {
                         unset($row['id']);
                         $row['page_id'] = $id;
                         DB::insert('block', $row);
                     }
                 }
             }
         } elseif (Url::get('cmd') == 'edit') {
             DB::update('page', $new_row, 'id=' . $this->page['id']);
             AZNet::update_page($this->page['id']);
         } else {
             $id = DB::insert('page', $new_row);
         }
         Url::redirect_current();
     }
 }
Esempio n. 4
0
    function EditPage($row)
    {
        Module::Module($row);
        if (User::is_root()) {
            $cmd = Url::get('cmd');
            switch ($cmd) {
                case 'change_layout':
                    $id = (int) Url::get('id', 0);
                    $new_layout = Url::get('new_layout');
                    if ($id && $new_layout && file_exists(ROOT_PATH . $new_layout)) {
                        DB::update('page', array('layout' => $new_layout), 'id=' . $id);
                    }
                    AZNet::update_page(Url::get('id'));
                    if (Url::check('href') && Url::get('href')) {
                        Url::redirect_url(Url::get('href'));
                    } else {
                        Url::redirect_current(array('id' => Url::get('id')));
                    }
                    break;
                case 'delete_block':
                    $id = (int) Url::get('id', 0);
                    $block_id = (int) Url::get('block_id', 0);
                    if ($block_id) {
                        DB::delete('block', "id={$block_id}");
                        AZNet::update_page($id);
                    }
                    if (Url::check('href') && Url::get('href')) {
                        Url::redirect_url(Url::get('href'));
                    } else {
                        Url::redirect_current(array('id' => $id));
                    }
                    break;
                case 'move_bottom':
                case 'move_top':
                    $id = (int) Url::get('id', 0);
                    $block_id = (int) Url::get('block_id', 0);
                    if ($block_id && $id) {
                        $page = DB::select('page', 'id=' . $id);
                        $block = DB::select('block', 'id=' . $block_id);
                        if ($block && $page) {
                            $region = $block['region'];
                            if ($cmd == 'move_bottom') {
                                $position = DB::fetch('SELECT MAX(position) AS amax FROM block WHERE region="' . $region . '" AND page_id="' . $id . '"', 'amax', 0);
                                if ($position) {
                                    $position++;
                                } else {
                                    $position = 1;
                                }
                            } else {
                                $position = DB::fetch('SELECT MIN(position) AS amin FROM block WHERE region="' . $region . '" AND page_id="' . $id . '"', 'amax', 0);
                                if ($position) {
                                    $position--;
                                } else {
                                    $position = 1;
                                }
                            }
                            DB::update('block', array('region' => $region, 'position' => $position), 'id="' . $block_id . '"');
                            AZNet::update_page($id);
                        }
                    }
                    if (Url::check('href') && Url::get('href')) {
                        Url::redirect_url(Url::get('href'));
                    } else {
                        Url::redirect_current(array('id' => $id));
                    }
                    break;
                case 'move':
                    $id = (int) Url::get('id', 0);
                    $block_id = (int) Url::get('block_id', 0);
                    $dir = Url::get('move');
                    if ($id && $block_id && $dir) {
                        $block = DB::select('block', $block_id);
                        if ($block) {
                            if ($dir == 'up') {
                                $move[0] = '<';
                                $move[1] = 'DESC';
                            } else {
                                $move[0] = '>';
                                $move[1] = 'ASC';
                            }
                            if (DB::query('SELECT * FROM block WHERE region="' . DB::escape($block['region']) . '" AND page_id="' . $block['page_id'] . '"
									AND position' . $move[0] . $block['position'] . ' ORDER BY position ' . $move[1])) {
                                if ($row = DB::fetch()) {
                                    DB::update('block', array('position' => $block['position']), '`id`=' . $row['id']);
                                    DB::update('block', array('position' => $row['position']), '`id`=' . $block['id']);
                                }
                            }
                            AZNet::update_page($id);
                        }
                    }
                    if (Url::check('href') && Url::get('href')) {
                        Url::redirect_url(Url::get('href'));
                    } else {
                        Url::redirect_current(array('id' => $id));
                    }
                    break;
                default:
                    $id = (int) Url::get('id', 0);
                    $module_id = (int) Url::get('module_id', 0);
                    $region = Url::get('region');
                    if (!$id) {
                        Url::redirect('page');
                    }
                    if ($module_id && $region) {
                        $position = DB::fetch('SELECT MAX(position) AS amax FROM block WHERE region="' . $region . '" AND page_id="' . $id . '"', 'amax', 0);
                        if ($position) {
                            $position++;
                        }
                        if ($position <= 0) {
                            $position = 1;
                        }
                        DB::insert('block', array('region' => $region, 'position' => $position, 'page_id' => $id, 'module_id' => $module_id));
                        AZNet::update_page($id);
                        if (Url::check('href') && Url::get('href')) {
                            Url::redirect_url(Url::get('href'));
                        } else {
                            Url::redirect_current(array('id' => $id));
                        }
                    } else {
                        //Cấu hình page:
                        require_once 'forms/page_content.php';
                        $this->add_form(new PageContentForm());
                        break;
                    }
                    break;
            }
        } else {
            Url::access_denied();
        }
    }