コード例 #1
0
ファイル: SignController.php プロジェクト: alexyandy/monc-php
 function in()
 {
     Monc::import('monc.form.LoginForm');
     $model = new LoginForm();
     if ($this->isPost()) {
         $model->setAttributes($_POST['LoginForm']);
         if ($model->save()) {
             $this->redirect(url('/admin'));
         }
     }
     $this->render('in', array('model' => $model));
 }
コード例 #2
0
ファイル: FormController.php プロジェクト: alexyandy/monc-php
 function step3()
 {
     Monc::import('monc.form.FormForm');
     $model = new FormForm();
     if ($this->isPost()) {
         $model->setAttributes($this->post('FormForm'));
         if ($model->save()) {
             $this->user->setState('form', $model->getAttributes());
             $this->redirect(curl('step4'));
         }
     } else {
         if ($data = $this->user->getState('form')) {
             $model->setAttributes($data);
         }
     }
     $this->render('form', array('model' => $model));
 }
コード例 #3
0
ファイル: MRouter.php プロジェクト: alexyandy/monc-php
 /**
  * @return MAction
  */
 public function createAction()
 {
     $uriWithOutParams = $this->request->uriWithOutParams;
     // ----------  /controller/action  ----------
     $mName = $cName = $aName = null;
     $cName = self::CONTROLLER_DEFAULT;
     $aName = self::ACTION_DEFAULT;
     if ($uriWithOutParams != '/') {
         $arr = explode('/', substr($uriWithOutParams, 1));
         $doneOffset = 0;
         if (count($arr) > 2) {
             list($mName, $cName, $aName) = $arr;
             $doneOffset = 3;
         } elseif (count($arr) > 1) {
             list($cName, $aName) = $arr;
             $doneOffset = 1;
             !$aName && ($aName = self::ACTION_DEFAULT);
         } elseif (count($arr) > 0) {
             $cName = $arr[0];
             $aName = self::ACTION_DEFAULT;
         }
         // only when the slices more than 3, we can get param from uri
         if (count($arr) > 3) {
             $brr = array_slice($arr, $doneOffset);
             for ($i = 0; $i < count($brr); $i += 2) {
                 $_GET[$brr[$i]] = isset($brr[$i + 1]) ? $brr[$i + 1] : null;
             }
         }
     }
     $module = $mName ? new MModule($mName) : null;
     $cNameController = ucfirst($cName) . "Controller";
     if ($module) {
         Monc::import('monc.controller.' . $mName . '.*');
     }
     $controller = new $cNameController(strtolower($cName));
     $controller->setModule($module);
     $action = new MAction($controller, $aName);
     $controller->setAction($action);
     return $action;
 }