public function addAction()
 {
     $flag = false;
     foreach ($this->privileges as $privilege) {
         if ($privilege['id'] == 74) {
             $flag = true;
         }
     }
     if (!$flag) {
         $this->_redirect('admin/index/error');
     }
     $this->view->headTitle($this->config['title']['addWidget']);
     $componentMapper = new Cloud_Model_Component_CloudComponentMapper();
     $components = $componentMapper->fetchAllByFront();
     $this->view->components = $components;
     if (isset($_POST['ok'])) {
         $newId = $this->widgetMapper->saveAll();
         $this->pagewidgetMapper->saveAll($newId);
         $this->view->message = 'Đã thêm widget: ' . $_POST['name'];
     }
 }
 public function editAction()
 {
     $flag = false;
     foreach ($this->privileges as $privilege) {
         if ($privilege['id'] == 70) {
             $flag = true;
         }
     }
     if (!$flag) {
         $this->_redirect('admin/index/error');
     }
     $this->view->headTitle($this->config['title']['editPage']);
     if ($this->request->getParam('id') != null) {
         $id = $this->request->getParam('id');
         $componentMapper = new Cloud_Model_Component_CloudComponentMapper();
         $components = $componentMapper->fetchAll();
         $currentPage = new Cloud_Model_Page_CloudPage();
         $this->pageMapper->find($id, $currentPage);
         $form = new Cloud_Form_Admin_Page_Edit(array('page' => $currentPage, 'components' => $components));
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->request->getPost())) {
                 $page = new Cloud_Model_Page_CloudPage($form->getValues());
                 $this->pageMapper->save($page);
                 $this->view->message = 'Đã sửa page: ' . $currentPage->getName();
             }
         }
         $this->view->form = $form;
     }
 }