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; }
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; }
/** * 1. sessionid * 2. name */ function init() { $this->session = Monc::app()->session; }
{ // 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();
<?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']; });
protected function createPageUrl($page) { return $this->getPagination()->createPageUrl(Monc::app()->controller, $page); }
public function createWidget($className, $properties = array()) { $widget = Monc::app()->getWidgetFactory()->createWidget($this, $className, $properties); $widget->init(); return $widget; }
/** * @return App */ function app() { return Monc::app(); }