/** * */ public function actionEdit() { $name = $this->request->getParam('name', 'platform.core.admin.general-setting'); $arr = explode('.', $name); $p0 = array_shift($arr); $p1 = array_shift($arr); foreach ($arr as $index => $ar) { $arr[$index] = _inflect($ar); } $class = '\\' . _inflect($p0) . '\\' . _inflect($p1) . '\\Form\\' . implode('\\', $arr); if (!class_exists($class)) { throw new \InvalidArgumentException("class {$class} does not exists."); } $form = app()->html()->factory($class); if (!$form instanceof BaseSettingForm) { throw new \InvalidArgumentException(); } if ($this->request->isMethod('post') && $form->isValid($_POST)) { $form->save(); } if ($this->request->isMethod('get')) { $form->load(); } $lp = new BlockParams(['base_path' => 'layout/partial/form-edit']); $this->view->setScript($lp)->assign(['form' => $form]); }
/** * */ public function actionEdit() { $name = $this->request->getParam('name', 'captcha.admin.recaptcha-setting'); $arr = explode('.', $name); $p0 = array_shift($arr); foreach ($arr as $index => $ar) { $arr[$index] = _inflect($ar); } $class = '\\' . _inflect($p0) . '\\Form\\' . implode('\\', $arr); // if (!class_exists($class)) // throw new \InvalidArgumentException(); $form = app()->html()->factory($class); if (!$form instanceof BaseSettingForm) { throw new \InvalidArgumentException(); } if ($this->request->isMethod('post') && $form->isValid($_POST)) { $form->save(); app()->routing()->redirect('admin', ['stuff' => 'captcha/manage/browse']); } if ($this->request->isMethod('get')) { $form->load(); } $lp = new BlockParams(['base_path' => 'layout/partial/form-edit']); $this->view->setScript($lp)->assign(['form' => $form]); }
/** * */ public function actionCmd() { list($id, $cmd, $context) = $this->request->getList('id', 'cmd', 'ctx'); if (empty($context)) { $context = 'profile'; } $obj = app()->find('invitation', $id); if (!$obj instanceof Invitation) { throw new \InvalidArgumentException("Could not find alert"); } $callbackName = _inflect(strtr($obj->getTypeId(), ['.' => '-', '_' => '-'])); switch ($cmd) { case 'accept': $callbackName = 'onAccept' . $callbackName; $this->response['html'] = app()->emitter()->callback($callbackName, $obj, $context); break; case 'deny': $callbackName = 'onIgnore' . $callbackName; $this->response['html'] = app()->emitter()->callback($callbackName, $obj, $context); break; } $this->response['callbackName'] = $callbackName; }