/**
  * @param $fields
  */
 public static function OnAfterIBlockUpdate($fields)
 {
     $code = $fields['CODE'];
     $file = \TAO::localDir("cache/infoblock/{$code}.php");
     if (is_file($file)) {
         unlink($file);
     }
 }
Exemple #2
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 #3
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 #4
0
 /**
  * @param array $cfg
  */
 public static function init($cfg = array())
 {
     foreach ($cfg as $k => $v) {
         self::$config[$k] = $v;
     }
     if (isset($GLOBALS['TAO_INITED'])) {
         return;
     }
     $GLOBALS['TAO_INITED'] = true;
     $cfgFile = \TAO::localDir('.config.php');
     if (is_file($cfgFile)) {
         $extraConfig = (include $cfgFile);
         self::$config = \TAO::mergeArgs(self::$config, $extraConfig);
     }
     self::initAdmin();
     if (self::$config['fs_pages']) {
         self::addBundle('FSPages');
     }
     if (self::$config['elements']) {
         self::addBundle('Elements');
     }
     \TAO\Auth::init();
     AddEventHandler("main", "OnBeforeProlog", function () {
     });
 }
Exemple #5
0
 /**
  * @param $file
  * @return bool|string
  */
 public function staticPagePath($file)
 {
     $path = \TAO::localDir("pages/{$file}");
     return is_file($path) ? $path : false;
 }
Exemple #6
0
 /**
  * @param $args
  * @param bool|false $name
  * @return bool|string
  */
 public function templateForArgs($args, $name = false)
 {
     $tpl = isset($args['template']) ? $args['template'] : false;
     if (!$tpl || !is_file($tpl)) {
         $tpl = isset($args['mode']) ? $args['mode'] : false;
     }
     if (isset($args['view_name'])) {
         $name = $args['view_name'];
     }
     if (!$tpl || !is_file($tpl)) {
         if ($name) {
             $tpl = \TAO::localDir("views/{$name}.phtml");
         }
     }
     if (!is_file($tpl)) {
         if ($name) {
             $tpl = \TAO::taoDir("views/{$name}.phtml");
         }
     }
     return $tpl;
 }
Exemple #7
0
 /**
  * @param $file
  * @return string
  */
 public function localPath($file)
 {
     $file = trim($file, '/');
     return \TAO::localDir("bundles/{$this->name}/{$file}");
 }
Exemple #8
0
 /**
  * @param $file
  * @return bool|string
  */
 public function viewPath($file)
 {
     return \TAO::filePath(array(\TAO::localDir("views/navigation"), \TAO::taoDir("views/navigation")), $file);
 }
Exemple #9
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;
     }
 }
Exemple #10
0
 /**
  * @param $dir
  * @return array
  */
 private function fileDirs($dir)
 {
     $dirs = array();
     $sub = $this->subdir();
     if ($this->bundle) {
         if ($sub) {
             $dirs[] = $this->bundle->localPath("{$dir}/shop/{$sub}");
         }
         $dirs[] = $this->bundle->localPath("{$dir}/shop");
     }
     if ($sub) {
         $dirs[] = \TAO::localDir("{$dir}/shop/{$sub}");
     }
     $dirs[] = \TAO::localDir("{$dir}/shop");
     $dirs[] = \TAO::taoDir("{$dir}/shop");
     return $dirs;
 }
Exemple #11
0
 /**
  * @param $sub
  * @return array
  */
 public function dirs($sub)
 {
     $dirs = array();
     if ($this->dir) {
         $dirs[] = "{$this->dir}/{$sub}";
     }
     $dirs[] = \TAO::localDir($sub);
     $dirs[] = \TAO::taoDir($sub);
     return $dirs;
 }
Exemple #12
0
 /**
  * @return string
  */
 public function sectionClassName()
 {
     $code = $this->getMnemocode();
     if (isset(self::$sectionClasses[$code])) {
         return self::$sectionClasses[$code];
     }
     if (!$this->sectionClassName) {
         $path = \TAO::localDir("section/{$code}.php");
         if (is_file($path)) {
             include_once $path;
             $this->sectionClassName = '\\App\\Section\\' . $code;
         } else {
             if ($bundle = $this->bundle()) {
                 if ($className = $bundle->getSectionClassName($code)) {
                     $this->sectionClassName = $className;
                 }
             }
         }
         if (!$this->sectionClassName) {
             $this->sectionClassName = '\\TAO\\Section';
         }
     }
     return $this->sectionClassName;
 }