Example #1
0
 function loadFile($file)
 {
     $store = NyaaConf::load($file);
     foreach ($store->get() as $k => $v) {
         $v['type'] = isset($v['type']) ? $v['type'] : 'text';
         $input = NyaaFormInput::factory(array_merge($v, array('name' => $k)));
         $this->addInput($input);
     }
 }
Example #2
0
 public static function factory($name, $confFile, $addOption = array())
 {
     $Conf = NyaaConf::load($confFile, $addOption);
     require_once dirname(__FILE__) . '/' . $name . '.class.php';
     $class = 'NyaaController' . ucfirst(strtolower($name));
     $ctrl = new $class();
     $ctrl->setConf($Conf);
     return $ctrl;
 }
Example #3
0
 function validaterFactory($conf)
 {
     require_once 'validater/validate.class.php';
     require_once 'validater/validater.class.php';
     $conf = NyaaConf::load($conf);
     $validater = new NyaaValidater();
     foreach ($conf->get() as $k => $v) {
         $validate = NyaaValidate::factory(array('type' => $v['type'], 'target' => $v['target'], 'message' => $v['message'], 'con' => $v['message_sep']));
         $validater->addValidate($validate);
     }
     return $validater;
 }
Example #4
0
 /**
  * factory
  *
  * @param string filepath
  * @param array option {typt,}
  */
 public static function factory($file, $option)
 {
     $CH = NyaaCache::current();
     if (self::RELEASE === false || false === ($Conf = $CH->get($file, $option))) {
         $Conf = NyaaConf::load($file, $option);
         $CH->set($file, $Conf);
     }
     $type = $Conf->getOr('fw.type', 'web');
     $file = dirname(__FILE__) . "/fw.{$type}.class.php";
     $class = 'NyaaFW' . ucfirst($type);
     require_once $file;
     $fw = new $class($Conf);
     return $fw;
 }
Example #5
0
 function doInstall($dir, $name)
 {
     $conf = $dir . '/package.conf';
     $Conf = NyaaConf::load($conf);
     $info =& $this->info;
     foreach ($Conf->getOr('app', array()) as $k => $v) {
         if ($k == "_root") {
             $key = $key2 = $name;
             $key2 = $name . ".class.php";
         } else {
             $key = "{$name}.{$k}";
             $key2 = "{$name}.{$v}";
         }
         $from = $dir . '/' . $v;
         $to = $this->appdir . "/{$key2}";
         if (file_exists($to)) {
             unlink($to);
         }
         symlink($from, $to);
         $info['app'][$key]['file'] = $this->appdir . "/{$key2}";
         $info['app'][$key]['class'] = preg_replace('/([^.]+)[.]{0,1}/e', 'ucfirst("\\1")', $key) . 'App';
         $info['app'][$key]['info'] = $Conf->getOr("info.app.{$k}", "");
     }
     foreach ($Conf->getOr('alias', array()) as $k => $v) {
         if ($v == "_root") {
             $key = "{$name}.{$k}";
             $to = $name;
         } else {
             $key = "{$name}.{$k}";
             $to = "{$name}.{$v}";
         }
         $info['app'][$key] = $info['app'][$to];
         $info['app'][$key]['info'] = "Redirect Of {$to}";
     }
     foreach ($Conf->getOr('template', array()) as $k => $v) {
         $key = "{$name}.{$k}";
         $from = $dir . '/' . $v;
         $to = $this->tpldir . "/{$name}.{$k}.html";
         if (file_exists($to)) {
             unlink($to);
         }
         symlink($from, $to);
         $info['template'][$key]['file'] = $to;
         $info['template'][$key]['info'] = $Conf->getOr("info.template.{$k}", "");
     }
     foreach ($Conf->getOr('package', array()) as $k => $v) {
         $this->doInstall($dir . '/' . $v, "{$name}.{$k}");
     }
 }