Exemplo n.º 1
0
 private function getModels()
 {
     $models = array();
     // User Models
     $dir = Kennel::getPath() . '/application/models/';
     if (is_dir($dir)) {
         foreach (scandir($dir) as $filename) {
             $path_info = pathinfo($filename);
             if ($path_info['extension'] && $path_info['extension'] == 'xml') {
                 $models[] = array('dir' => $dir, 'info' => $path_info, 'source' => 'application');
             }
         }
     }
     // Module Models
     foreach (Kennel::$MODULES as $module) {
         $dir = Kennel::getPath() . "/modules/{$module['id']}/models/";
         if (is_dir($dir)) {
             foreach (scandir($dir) as $filename) {
                 $path_info = pathinfo($filename);
                 if (isset($path_info['extension']) && $path_info['extension'] == 'xml') {
                     $models[] = array('dir' => $dir, 'info' => $path_info, 'source' => $module['id']);
                 }
             }
         }
     }
     // System Models
     $dir = Kennel::getPath() . "/system/models/";
     if (is_dir($dir)) {
         foreach (scandir($dir) as $filename) {
             $path_info = pathinfo($filename);
             if ($path_info['extension'] && $path_info['extension'] == 'xml') {
                 $models[] = array('dir' => $dir, 'info' => $path_info, 'source' => 'system');
             }
         }
     }
     self::$DB = new MySQL();
     $rs = self::$DB->query("SHOW TABLES");
     $tables = array();
     while ($row = self::$DB->fetch_array($rs)) {
         $tables[] = $row[0];
     }
     foreach ($models as $id => $model) {
         //self::checkModel($model['info']['filename']);
         // FILENAME was only introduced in PHP 5.2 and Terra Empresas is gay
         $filename = substr($model['info']['basename'], 0, strpos($model['info']['basename'], '.xml'));
         $schema = ORM::getSchema($filename);
         $result = array_search($schema->table, $tables);
         if ($result !== FALSE) {
             $models[$id]['status'] = 'ok';
         } else {
             $models[$id]['status'] = '';
         }
     }
     return $models;
 }
Exemplo n.º 2
0
 static function fetchModules()
 {
     // Initialize the variable
     self::$MODULES = array();
     // Skip if the modules folder do not exist
     if (!file_exists(self::getPath('modules'))) {
         return null;
     }
     // Get through the file list in the modules directory
     $files = scandir(self::getPath('modules'));
     foreach ($files as $file) {
         // Get only valid directories
         if (is_dir(Kennel::getPath('modules') . '/' . $file) && $file != '.' && $file != '..' && $file != '.svn') {
             if (is_file(Kennel::getPath('modules') . "/{$file}/info.php")) {
                 if (isset($info)) {
                     unset($info);
                 }
                 include Kennel::getPath('modules') . "/{$file}/info.php";
                 self::$MODULES[$file] = $info;
             }
         }
     }
 }