Exemple #1
0
 /**
  *
  */
 public static final function run()
 {
     $c = 0;
     self::$actions = array();
     self::$options = array();
     $argv = $GLOBALS['argv'];
     foreach ($argv as $arg) {
         $arg = trim($arg);
         if (preg_match('{^--([^\\s=]+)=(.*)}', $arg, $m)) {
             self::$options[$m[1]] = $m[2];
         } else {
             if (preg_match('{^--([^\\s=]+)}', $arg, $m)) {
                 self::$options[$m[1]] = true;
             } else {
                 if ($c == 0) {
                     self::$script = $arg;
                 } else {
                     self::$actions[$c - 1] = $arg;
                 }
                 $c++;
             }
         }
     }
     foreach (self::$actions as $action) {
         $dir = \TAO::localDir('lib/CLI');
         if (is_dir($dir)) {
             $dir = dir($dir);
             while ($entry = $dir->read()) {
                 if (preg_match('{^(.+)\\.php$}', $entry, $m)) {
                     $class = '\\App\\CLI\\' . $m[1];
                     $object = new $class();
                     $object->runAction($action);
                 }
             }
         }
         foreach (\TAO::bundles() as $bundle) {
             $bundle->cli($action, self::$options);
         }
         if (isset(self::$handlers[$action])) {
             $cb = self::$handlers[$action];
             if (is_string($cb)) {
                 $cb = array($cb, $action);
             }
             if (is_callable($cb)) {
                 call_user_func($cb, self::$options);
             }
         }
     }
 }
Exemple #2
0
 /**
  * @param $name
  * @param string $domain
  * @param bool|false $lang
  * @return string
  */
 public static function t($name, $domain = 'messages', $lang = false)
 {
     if (!$lang) {
         $lang = \TAO::getCurrentLang();
     }
     $key = "{$domain}.{$lang}";
     if (!isset(self::$data[$key])) {
         self::$data[$key] = array();
         $file = "lang/{$key}.php";
         self::mergeLangData(self::$data[$key], \TAO::taoDir($file));
         foreach (\TAO::bundles() as $bundle) {
             self::mergeLangData(self::$data[$key], $bundle->filePath($file));
         }
         self::mergeLangData(self::$data[$key], \TAO::localDir($file));
     }
     return isset(self::$data[$key][$name]) ? self::$data[$key][$name] : "[lang:{$domain}/{$lang}/{$name}]";
 }
Exemple #3
0
 /**
  * @param $name
  * @return mixed
  */
 public function formObject($name, $check = true)
 {
     $path = \TAO::localDir("forms/{$name}.php");
     if (is_file($path)) {
         include_once $path;
         $class = "\\App\\Form\\{$name}";
         return new $class($name);
     }
     foreach (\TAO::bundles() as $bundle) {
         $class = $bundle->hasClass("Form\\{$name}");
         if ($class) {
             $object = new $class($name);
             $object->bundle = $bundle;
             return $object;
         }
     }
     if ($check) {
         print "Unknown form '{$name}'";
         die;
     }
 }