示例#1
0
 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
 function createWidget($owner, $className, $properties = array())
 {
     $className = Monc::importlib($className, true);
     $widget = new $className($owner);
     if (isset($this->widgets[$className])) {
         $properties = $properties === array() ? $this->widgets[$className] : MMap::mergeArray($this->widgets[$className], $properties);
     }
     foreach ($properties as $name => $value) {
         $widget->{$name} = $value;
     }
     return $widget;
 }
示例#3
0
 public function save()
 {
     if (!$this->name == 'admin') {
         $this->addError('name', 'name error');
         return false;
     }
     if (!$this->password == 'admin') {
         $this->addError('password', 'pwd error');
         return false;
     }
     Monc::app()->user->login();
     return true;
 }
示例#4
0
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     if (!($info = Monc::app()->user->getState('info'))) {
         throw new RuntimeException('第二步的个人信息还没填写');
     }
     $model = new Request();
     $model->setAttributes($info);
     $model->setAttributes($this->getAttributes());
     if (!$model->save()) {
         $this->addErrors($model->getErrors());
         return false;
     }
     return true;
 }
示例#5
0
 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));
 }
示例#6
0
 /**
  * @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;
 }
示例#7
0
 /**
  * 1. sessionid
  * 2. name
  */
 function init()
 {
     $this->session = Monc::app()->session;
 }
示例#8
0
    {
        // existed
        if (in_array($path, $this->import_path_param)) {
            return substr($path, strrpos($path, '.') + 1);
        }
        $this->import_path_param[] = $path;
        $path = MONC . '../' . str_replace('.', DIRECTORY_SEPARATOR, $path);
        if (substr($path, -1) == '*') {
            $path = substr($path, 0, strlen($path) - 1);
        } else {
            $path .= '.php';
        }
        if (!file_exists($path)) {
            //debug_print_backtrace();
            return;
            //throw new RuntimeException('no such path: ' . $path);
        }
        if (is_dir($path)) {
            $d = opendir($path);
            while ($file = readdir($d)) {
                is_file($path . $file) && !is_link($path . $file) && preg_match('/\\.php$/', $file) && ($this->import[$file] = $path . $file);
            }
        } else {
            $file = substr($path, strrpos($path, '/') + 1);
            $this->import[$file] = $path;
        }
        return substr($path, strrpos($path, '/') + 1, -4);
    }
}
return Monc::app();
示例#9
0
<?php

spl_autoload_register(function ($class) {
    if (!isset(Monc::app()->import[$class . '.php'])) {
        throw new Exception('not found class [' . $class . ']');
    }
    include Monc::app()->import[$class . '.php'];
});
示例#10
0
 protected function createPageUrl($page)
 {
     return $this->getPagination()->createPageUrl(Monc::app()->controller, $page);
 }
示例#11
0
 public function createWidget($className, $properties = array())
 {
     $widget = Monc::app()->getWidgetFactory()->createWidget($this, $className, $properties);
     $widget->init();
     return $widget;
 }
示例#12
0
/**
 * @return App
 */
function app()
{
    return Monc::app();
}