Example #1
0
 public function initialize($model, $menu_id = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $name = new Text("name");
     $name->addValidator(new PresenceOf(array('message' => 'name')));
     $this->add($name);
     $this->add(new Text("code"));
     $link = new Text("link");
     $link->addValidator(new PresenceOf(array('message' => 'link')));
     $this->add($link);
     // parents menu item
     $result = \Modules\Backend\Models\Menu_item::findByMenu_id($menu_id);
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $data = $system->getListTreeCategory($data, 'name');
     $parents = new Select('parents', $data);
     $this->add($parents);
     $tbl_menu = \Modules\Backend\Models\Menu::find();
     $menu = new Select('menu_id', $tbl_menu, array('using' => array('id', 'name')));
     $menu->setDefault($menu_id);
     $this->add($menu);
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $target = new Select('target', array('0' => 'Bình thường', '1' => 'Mở tab mới'));
     $this->add($target);
     $this->add(new Text("image"));
     $this->add(new Text("position"));
 }
Example #2
0
 public function initialize($model = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     // $this->add(new Select('status', array('0'=>'Không', '1'=>'Có')));
     $this->add(new Select('featured', array('0' => 'Không', '1' => 'Có')));
     $this->add(new Text("image"));
     $this->add(new TextArea("description"));
     $this->add(new TextArea("content"));
     // Config tab
     $this->add(new Text("link"));
     $this->add(new Select('url_target', array('normal' => 'Bình thường', '_blank' => 'Mở trang mới')));
     $this->add(new Text("published", array('data-format' => 'yyyy-MM-dd hh:mm:ss', 'value' => date('d-m-Y H:i:s'))));
     $this->add(new Text("position"));
     // SEO tab
     $this->add(new Text("seo_title"));
     $this->add(new TextArea("metadata"));
     $this->add(new TextArea("keyword"));
     $result = \Modules\Backend\Models\News_category::find();
     $system = new \Modules\Library\System();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, "title");
     $category_id = new Select('category_id', $record);
     $this->add($category_id);
 }
Example #3
0
 public function initialize($model = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $title = new Text("title");
     $title->addValidator(new PresenceOf());
     $this->add($title);
     $this->add(new Text("code"));
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $this->add(new Text("image"));
     $this->add(new TextArea("description"));
     $this->add(new Text("position"));
     $result = \Modules\Backend\Models\News_category::find();
     $system = new \Modules\Library\System();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, 'title');
     $parents = new Select('parents', $record);
     $this->add($parents);
 }
Example #4
0
 public function initialize($model = null, $menu_id = null)
 {
     $system = new \Modules\Library\System();
     // Main tab
     $name = new Text("name");
     $name->addValidator(new PresenceOf());
     $this->add($name);
     $menu = \Modules\Backend\Models\Menu::findFirst();
     $menu = new Text('menu', array('value' => $menu->name, 'readonly' => true));
     $this->add($menu);
     $menu_item = \Modules\Backend\Models\Menu_item::findByMenu_id($menu_id);
     $menu_item = $system->convert_object_to_array($menu_item);
     $data = null;
     $system->recursive($menu_item, 0, 1, $data);
     $record = $system->getListTreeCategory($data, 'name');
     $menu_item = new Select('menu_item', $record);
     $this->add($menu_item);
     $status = new Select('status', array('0' => 'Không', '1' => 'Có'));
     $status->setDefault('1');
     $this->add($status);
     $target = new Select('target', array('0' => 'Không', '1' => 'Có'));
     $target->setDefault('0');
     $this->add($target);
     $this->add(new Text("image"));
     // Config tab
     $result = \Modules\Backend\Models\News_category::find();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $record = $system->getListTreeCategory($data, 'title');
     $category = new Select('params[category][]', $record);
     $this->add($category);
     $params_show = new Select('params[show]', array('0' => 'Danh sách bài viết', '1' => 'Kênh thông tin - bài viết'));
     $params_show->setDefault($system->getParams($model, array('name' => 'show', 'default' => 0)));
     $this->add($params_show);
     $items = new Text("params[items]", array('class' => 'txt_medium', 'value' => "{$system->getParams($model, array('name' => 'items', 'default' => 10))}"));
     $this->add($items);
     $params_show_image = new Select('params[show_image]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_image->setDefault($system->getParams($model, array('name' => 'show_image', 'default' => 2)));
     $this->add($params_show_image);
     $params_link_image = new Select('params[link_image]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_link_image->setDefault($system->getParams($model, array('name' => 'link_image', 'default' => 2)));
     $this->add($params_link_image);
     $params_show_title = new Select('params[show_title]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_title->setDefault($system->getParams($model, array('name' => 'show_title', 'default' => 2)));
     $this->add($params_show_title);
     $params_link_title = new Select('params[link_title]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_link_title->setDefault($system->getParams($model, array('name' => 'link_title', 'default' => 2)));
     $this->add($params_link_title);
     $this->add(new Text('params[number_title]'));
     $params_show_description = new Select('params[show_description]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_description->setDefault($system->getParams($model, array('name' => 'show_description', 'default' => 2)));
     $this->add($params_show_description);
     $params_link_description = new Select('params[link_description]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_link_description->setDefault($system->getParams($model, array('name' => 'link_description', 'default' => 2)));
     $this->add($params_link_description);
     $this->add(new Text('params[number_description]'));
     $params_show_published = new Select('params[show_published]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_published->setDefault($system->getParams($model, array('name' => 'show_published', 'default' => 2)));
     $this->add($params_show_published);
     $params_show_hits = new Select('params[show_hits]', array('2' => 'Mặc định', '0' => 'Không', '1' => 'Có'));
     $params_show_hits->setDefault($system->getParams($model, array('name' => 'show_hits', 'default' => 2)));
     $this->add($params_show_hits);
 }
 /**
  *	Hàm lấy menu item của từng menu
  *	@param $menu_id
  */
 protected function getMenuItem($menu_id)
 {
     $model = $this->getModel();
     $result = $model::findByMenu_id($menu_id);
     $system = new \Modules\Library\System();
     $result = $system->convert_object_to_array($result);
     $data = null;
     $system->recursive($result, 0, 1, $data);
     $this->view->data = $data;
     // Xử lý submit tùy chọn
     if ($this->request->isPost()) {
         // xóa nhiều
         if ($this->request->getPost("delete")) {
             $id = $this->request->getPost("checkbox");
             if (count($id) > 0) {
                 $id = implode(',', $id);
                 $conditions = "id IN({$id})";
                 $model = $this->getModel();
                 $record = $model::find(array("conditions" => $conditions, "colums" => "id,title"));
                 if (count($record) > 0) {
                     $fail = "";
                     foreach ($record as $key => $value) {
                         $parent = $this->findFirst(array("conditions" => "parents = :parents:", "bind" => array("parents" => $value->id), "columns" => "id,title"));
                         if (!$parent) {
                             $aricle = \Modules\Backend\Models\News_article::findFirst(array("conditions" => "category_id = :id:", "bind" => array("id" => $value->id), "columns" => "id"));
                             if (!$aricle) {
                                 $value->delete();
                             } else {
                                 $fail .= $value->title . ",";
                             }
                         } else {
                             $fail .= $value->title . ",";
                         }
                     }
                     if (!empty($fail)) {
                         $this->flash->error("Xóa thất bại: " . $fail);
                     }
                     $this->view->disable();
                 }
             }
         }
         // kích hoạt nhiều
         if ($this->request->getPost("active")) {
             $this->status_multiple(1);
         }
         // đóng kích hoạt nhiều
         if ($this->request->getPost("no_active")) {
             $this->status_multiple(0);
         }
         // sắp xếp nhiều
         if ($this->request->getPost("order")) {
             $this->update_multiple(array("position"));
         }
         $this->view->disable();
         $this->redirect(array("action" => "index"));
     }
     //Plugin
     $plugin = new \Modules\Library\Plugin();
     $this->view->plugin = $plugin;
 }