public function __construct($objModule, $strColumn = 'main') { parent::__construct($objModule, $strColumn); $this->objBlock = BlockModel::findByPk($this->block); if ($this->objBlock !== null) { foreach ($this->objBlock->row() as $key => $value) { // overwrite module parameter with block parameter, except the following if (in_array($key, array('id', 'pid', 'tstamp', 'module', 'title'))) { continue; } $this->{$key} = deserialize($value); } } }
public function blockBasicPageEditAction() { if (Session::hasUser('admin')) { $adminModel = new AdminModel(); $data_admin = $adminModel->getAdminPage(Router::getId()); $indexModel = new IndexModel(); $data_pages = $indexModel->getBasicPageBlock(); // $data_pages = array(); // foreach($d_p as $v){ // $data_pages[$v['id_page']] = $v; // } //Debugger::PrintR($data_pages); $request = new Request(); $blockModel = new BlockModel($request); // $id_array = $blockModel->getIdArray(); // $del_array = $blockModel->getDeleteArray(); // $test = $blockModel->isExist(); // Debugger::PrintR($id_array); // Debugger::PrintR($del_array); //Debugger::PrintR($test); if ($request->isPost()) { if ($blockModel->isNumeric()) { if (!$blockModel->isExist()) { $blockModel->update(); $redirect = $request->post('redirect'); } else { $id = $blockModel->isExist(); Session::setFlash("Basic_page с id номером " . $id . " не существует!"); } } else { Session::setFlash('Введите целые числа!'); } } $args = array('data_admin' => $data_admin[0], 'data_pages' => $data_pages, 'redirect' => isset($redirect) ? $redirect : null); return $this->render_admin($args); } else { throw new Exception('Access is forbidden', 403); } }
/** * 完成删除 */ function delin() { $block_name = $_POST['blockname']; $blocks = new BlockModel(); $where = array('blockname' => array('eq', $block_name)); if ($blocks->where($where)->delete() !== false) { $this->assign('jumpUrl', __URL__ . '/index'); $this->success('删除成功'); } else { $this->assign('jumpUrl', __URL__ . '/index'); $this->error('删除失败'); } }