Example #1
0
 function getList()
 {
     $files = File::readDir($this->dir);
     $array = array();
     foreach ($files as $dir) {
         $array[] = (include $this->dir . $dir . DS . 'config.php');
     }
     return $array;
 }
Example #2
0
 /**
  * The function returns Proud Layouts.
  * 
  * @static
  * @access public
  * @param bool $assoc If TRUE returns associated array with name in value, otherwise value is object.
  * @return array The layouts.
  */
 public static function getLayouts($assoc = false)
 {
     $result = array();
     foreach (File::readDir(dirname(__FILE__) . '/layout') as $file) {
         $name = 'Proud_Layout_' . basename($file, '.php');
         $class = new $name();
         if ($assoc) {
             $result[get_class($class)] = $class->getName();
         } else {
             $result[get_class($class)] = $class;
         }
     }
     return $result;
 }
 function execute()
 {
     $theme = Settings::getValue('theme', 'connection');
     $dir = APP_DIR . DS . 'connection' . DS . APP_TEMPLATES_DIR . DS . 'themes' . DS . $theme . DS;
     $files = File::readDir($dir);
     $files_map = array_map(function ($item) use($dir) {
         return array('type' => is_dir($dir . $item) ? 'dir' : 'file', 'name' => $item);
     }, $files);
     usort($files_map, function ($a, $b) {
         if ($a['type'] == $b['type']) {
             return $a['name'] < $b['name'] ? -1 : 1;
         }
         return $a['type'] < $b['type'] ? -1 : 1;
     });
     $this->smarty->assign('files', $files_map);
 }
 function execute()
 {
     $path = Request::post('path');
     $theme = Settings::getValue('theme', 'connection');
     $dir = APP_DIR . DS . 'connection' . DS . APP_TEMPLATES_DIR . DS . 'themes' . DS . $theme . DS . $path;
     $files = File::readDir($dir);
     $files_map = array_map(function ($item) use($dir) {
         return array('type' => is_dir($dir . $item) ? 'dir' : 'file', 'name' => $item);
     }, $files);
     usort($files_map, function ($a, $b) {
         if ($a['type'] == $b['type']) {
             return $a['name'] < $b['name'] ? -1 : 1;
         }
         return $a['type'] < $b['type'] ? -1 : 1;
     });
     return array('files' => $files_map, 'path' => $path);
 }
Example #5
0
            foreach (explode(',', $arr[1]) as $col) {
                $cols[] = '`' . $col . '`';
            }
            $result['*' . trim($cols[0], '`')] = 'alter table `' . $new['name'] . '` add ' . str_replace('primary', 'primary key', $arr[0]) . ' (' . implode(',', $cols) . ')';
        }
    }
    return $result;
}
include_once dirname(dirname(__FILE__)) . '/includes/application.php';
Application::run('config');
$codes = array('00000', '42S01', '23000', '42S21');
$DB = Database::getInstance();
$len = strlen(Runtime::get('INCLUDE_DIR') . '/models') + 1;
$error = array();
Console::writeln('Database objects update');
foreach (File::readDir(Runtime::get('INCLUDE_DIR') . '/models', true, null, '*.php') as $file) {
    $content = file_get_contents($file);
    if (preg_match('/{INSTALL:SQL{(.*)}}/is', $content, $res)) {
        $file = substr($file, $len);
        //Console::writeln( $file, 30 );
        $lines = preg_split("/;(\n|\r\n){2}/", $res[1]);
        foreach ($lines as $query) {
            $new = parseCreateTable(trim($query));
            if ($new) {
                if (preg_match('/class ([\\w\\_]+) extends/i', $content, $res)) {
                    $obj = new $res[1]();
                    $missed = $extra = $cols = array();
                    foreach (get_object_vars($obj) as $field => $value) {
                        $found = false;
                        foreach ($new['columns'] as $col) {
                            $arr = explode(' ', $col, 2);
Example #6
0
 /**
  * TLhe function returns array of layouts.
  * 
  * @static
  * @access public
  * @return array The array of layouts.
  */
 public static function getLayouts()
 {
     $result = array();
     foreach (File::readDir(Runtime::get('TEMPLATE_DIR') . '/frontend/layout/') as $file) {
         $result[basename($file)] = basename($file, '.html');
     }
     asort($result);
     return $result;
 }
Example #7
0
 function getList()
 {
     if (self::$configs) {
         return self::$configs;
     }
     $localesDir = APP_DIR . DS . App::getAppName() . DS . APP_LOCALE . DS;
     $list = File::readDir($localesDir);
     $configs = array();
     foreach ($list as $value) {
         $config = $localesDir . $value . DS . 'config.php';
         if (file_exists($config)) {
             $configs[] = (include $config);
         }
     }
     self::$configs = $configs;
     return $configs;
 }
 /**
  * 清空所有的文件缓存
  *
  * @access public
  * @return boolean
  */
 public function clear()
 {
     $fileList = File::readDir($this->_cachePath);
     //删除所有的缓存文件
     foreach ($fileList as $fileName) {
         if (strpos($fileName, '.filecache.php') !== false) {
             unlink($this->_cachePath . DS . $fileName);
         }
     }
     return true;
 }
Example #9
0
 /**
  * The function reads directory with classes.
  * 
  * @static
  * @access public
  * @param string $path The classes directory.
  * @param string $prefix The class name prefix.
  * @return array The classes.
  */
 public static function readClasses($path, $prefix = '')
 {
     $classes = array();
     foreach (File::readDir($path, true, null, '*.php') as $file) {
         if (is_dir($file)) {
             continue;
         }
         $size = filesize($file);
         $text = file_get_contents($file);
         $arr = explode("\n", $text);
         $lines = count($arr);
         $file = str_replace($path . '/', '', $file);
         $name = $prefix . str_replace('.php', '', String::toFirstCase($file, '_', '/'));
         //Console::writeln( $name );
         if (preg_match('/public function __construct\\((.+)\\)/i', str_replace("\n", '', $text), $res)) {
             $break = false;
             foreach (explode(',', $res[1]) as $arg) {
                 if (strlen($arg) > 1 && !strpos($arg, '=')) {
                     $classes[] = array($name, $size, $lines, 'constructor arguments');
                     $break = true;
                     break;
                 }
             }
             if ($break) {
                 continue;
             }
         }
         if (strpos($text, 'private function __construct')) {
             //Console::writeln( '::singleton '.$name );
             $classes[] = array($name, $size, $lines, 'signleton');
         } else {
             if (strpos($text, 'abstract class')) {
                 //Console::writeln( '::abstract '.$name );
                 $classes[] = array($name, $size, $lines, 'abstract');
             } else {
                 $class = new $name();
                 $classes[] = array($class, $size, $lines);
                 //Console::writeln( get_class( $class ) );
             }
         }
     }
     return $classes;
 }
Example #10
0
<?php

include_once dirname(dirname(__FILE__)) . '/includes/application.php';
Application::run('config');
for ($i = 0; $i < 10; $i++) {
    if (!isset($argv[$i])) {
        $argv[$i] = null;
    }
}
$m = File::readClasses(INCLUDE_MODELS_DIR);
$c = File::readClasses(INCLUDE_CONTROLLERS_DIR, 'Controller_');
$v = File::readClasses(INCLUDE_VIEWS_DIR, 'View_');
$t = array();
$dir = Runtime::get('TEMPLATE_DIR');
foreach (File::readDir($dir, true, null, '.html') as $file) {
    if (is_dir($file)) {
        continue;
    }
    $text = file_get_contents($file);
    $arr = explode("\n", $text);
    $t[] = array(str_replace($dir . '/', '', $file), filesize($file), count($arr));
}
$stats = array('size' => array('m' => 0, 'c' => 0, 'v' => 0, 't' => 0, 'a' => 0), 'lines' => array('m' => 0, 'c' => 0, 'v' => 0, 't' => 0, 'a' => 0));
foreach ($stats['size'] as $i => $value) {
    if ($i == 'a') {
        break;
    }
    foreach (${$i} as $item) {
        $stats['size'][$i] += $item[1];
        $stats['lines'][$i] += $item[2];
        $stats['size']['a'] += $item[1];