Exemple #1
0
 /**
  * @param $name
  * @return mixed
  */
 public static function findBundle($name)
 {
     $class = false;
     $path = \TAO::localDir("/bundles/{$name}/lib/Bundle.php");
     if (is_file($path)) {
         $class = "\\App\\Bundle\\{$name}\\Bundle";
         $dir = \TAO::localDir("/bundles/{$name}");
     } else {
         $path = \TAO::taoDir("/bundles/{$name}/lib/Bundle.php");
         if (is_file($path)) {
             $class = "\\TAO\\Bundle\\{$name}\\Bundle";
             $dir = \TAO::taoDir("/bundles/{$name}");
         }
     }
     if ($class) {
         include_once $path;
         $bundle = new $class();
         $bundle->name = $name;
         $bundle->file = $path;
         $bundle->dir = $dir;
         if (\TAO::cache()->fileUpdated($path)) {
             $bundle->cachedInit();
         }
         $bundle->init();
         return $bundle;
     }
 }
Exemple #2
0
 /**
  * @param $type
  * @param $code
  * @param $class
  */
 public static function processSchema($type, $code, $class)
 {
     self::$code2type[$code] = $type;
     self::$classes[$code] = $class;
     $path = \TAO::getClassFile($class);
     if (\TAO::cache()->fileUpdated($path)) {
         $infoblock = new $class($code);
         //var_dump($infoblock);die;
         $infoblock->process();
     }
 }
Exemple #3
0
 /**
  * @param $dirs
  * @param $file
  * @param bool|false $extra
  * @return bool|string
  */
 public static function filePath($dirs, $file, $extra = false)
 {
     static $paths = array();
     $cache = \TAO::getOption('cache.template.paths');
     $key = md5(serialize(func_get_args()));
     if ($cache && !is_int($cache)) {
         $cache = 3600;
     }
     if ($cache) {
         $key = "tplpath/{$key}";
         $path = \TAO::cache()->get($key, $cache);
         if ($path) {
             return $path;
         }
     }
     if (isset($paths[$key])) {
         return $paths[$key];
     }
     if (preg_match('{^(.+)\\.(css|js|phtml|less|scss)$}', $file, $m)) {
         $base = $m[1];
         $ext = $m[2];
         $site = SITE_ID;
         $files = $extra ? array("{$base}-{$extra}-{$site}.{$ext}", "{$base}-{$extra}.{$ext}") : array();
         $files[] = "{$base}-{$site}.{$ext}";
         $files[] = "{$base}.{$ext}";
         foreach ($files as $fn) {
             foreach ($dirs as $dir) {
                 $path = "{$dir}/{$fn}";
                 if (is_file($path)) {
                     $paths[$key] = $path;
                     if ($cache) {
                         \TAO::cache()->set($key, $path, $cache);
                     }
                     return $path;
                 }
             }
         }
     }
     return false;
 }
Exemple #4
0
                }
                if ($row['Key'] == 'MUL') {
                    $type .= ' index';
                    $indexes[$name] = true;
                }
                $columns[$name] = $type;
            }
        }
        foreach ($fields as $field => $type) {
            if ($field == 'id') {
                continue;
            }
            list($column, $index) = self::parseField($table, $field, $type);
            if (isset($columns[$field]) && $column) {
                $query = "ALTER TABLE {$table} CHANGE `{$field}` {$column}";
                $DB->Query($query);
            } else {
                $query = "ALTER TABLE {$table} ADD {$column}";
                $DB->Query($query);
            }
            if ($index && !isset($indexes[$field])) {
                $index = preg_replace('{^KEY }', 'INDEX ', $index);
                $query = "ALTER TABLE {$table} ADD {$index}";
                $DB->Query($query);
            }
        }
    }
}
if (\TAO::cache()->fileUpdated(__FILE__)) {
    TablesSchema::process();
}