예제 #1
0
 /**
  * Construct function
  *
  * options key 
  * boolean fileConfig   if enable file config 
  * string  basePath     default app/forms 
  * boolean i18n         if enable translator
  * @return void
  */
 public function __construct($options = array())
 {
     if (isset($options['i18n']) && $options['i18n']) {
         $this->enableI18n(true);
     }
     if (isset($options['valid']) && $options['valid']) {
         $this->enableValid($options['valid']);
     }
     if (isset($options['clientValidate']) && $options['clientValidate']) {
         $this->setClientValidate($options['clientValidate']);
     }
     if (isset($options['fileConfig']) && $options['fileConfig']) {
         //Manaul set form config file.
         if (isset($options['configFile'])) {
             $config_file = $options['configFile'];
         } else {
             $form_path = isset($options['basePath']) ? $options['basePath'] : realpath(dirname(__FILE__) . '/../../app/forms');
             $params = Aimo_Controller::getInstance()->_params;
             $config_file = $form_path . DIRECTORY_SEPARATOR . $params['_m'] . DIRECTORY_SEPARATOR . $params['_c'] . '_' . $params['_a'] . '.php';
         }
         $form_options = array();
         if (is_file($config_file)) {
             $form_options = (include $config_file);
         } else {
             $e = new Exception($config_file . " Does not exists !");
             Aimo_Debug::dump($e->getTrace());
             throw $e;
         }
         foreach ($form_options as $type => $option) {
             //$type = isset($option['type'])?$option['type']:$type;
             $this->addElement($option['type'], $option);
         }
     }
 }
예제 #2
0
 /**
  * Singleton instance
  *
  * @return Aimo_Controller
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #3
0
 /**
  * get current module
  *
  * @return string
  */
 public function getCurModule()
 {
     if (null === $this->_curModule || empty($this->_curModule)) {
         $params = Aimo_Controller::getInstance()->_params;
         $this->_curModule = $params['_m'];
     }
     return $this->_curModule;
 }