コード例 #1
0
 public function get_table_class_files()
 {
     $table_class_files = array();
     /*
      * The default table class file.
      */
     $default_table_class_file = new FileSystem_PHPClassFile(PROJECT_ROOT . '/plug-ins/database/classes/elements/' . 'Database_Table.inc.php');
     $mysql_user_factory = Database_MySQLUserFactory::get_instance();
     $mysql_user = $mysql_user_factory->get_for_this_project();
     $database = $mysql_user->get_database();
     $table_names = $database->get_table_names();
     $project_directory = $this->get_project_directory();
     $php_class_files = $project_directory->get_php_class_files();
     $table_reflection_class = $default_table_class_file->get_reflection_class();
     foreach ($table_names as $table_name) {
         $table_class_files[$table_name][] = $default_table_class_file;
         foreach ($php_class_files as $php_class_file) {
             $php_class_file->declare_class();
             $php_class_file_reflection_class = $php_class_file->get_reflection_class();
             if (!$php_class_file_reflection_class->isAbstract() && $php_class_file_reflection_class->isSubclassOf($table_reflection_class)) {
                 $table_class_files[$table_name][] = $php_class_file;
             }
         }
     }
     return $table_class_files;
 }
コード例 #2
0
 public function get_selection_manager($table_name)
 {
     #print_r($this->selection_managers);
     if (!isset($this->selection_managers[$table_name])) {
         #print_r($this->selection_managers_file);
         $mysql_user_factory = Database_MySQLUserFactory::get_instance();
         $mysql_user = $mysql_user_factory->get_for_this_project();
         $database = $mysql_user->get_database();
         $table = $database->get_table($table_name);
         if (isset($this->selection_managers_file) && $this->selection_managers_file->has_selection_manager($table_name)) {
             $selection_manager_filename = $this->selection_managers_file->get_selection_manager_filename($table_name);
             #echo "\$selection_manager_filename: $selection_manager_filename\n";
             $selection_manager_file = new FileSystem_PHPClassFile($selection_manager_filename);
             $selection_manager_file->declare_class();
             $selection_manager_reflection_class = new ReflectionClass($selection_manager_file->get_php_class_name());
             $this->selection_managers[$table_name] = $selection_manager_reflection_class->newInstance($table);
         } else {
             #echo "Using default selection manager for $table_name\n";
             $this->selection_managers[$table_name] = $this->default_selection_manager_reflection_class->newInstance($table);
         }
     }
     return $this->selection_managers[$table_name];
 }
コード例 #3
0
 public function get_field_renderer_class($table_name, $field_name)
 {
     if (isset($_SESSION['database-class-names'][$table_name]['fields'][$field_name]['renderer']['class_file'])) {
         require_once PROJECT_ROOT . $_SESSION['database-class-names'][$table_name]['fields'][$field_name]['renderer']['class_file'];
         return new ReflectionClass($_SESSION['database-class-names'][$table_name]['fields'][$field_name]['renderer']['class_name']);
     }
     if (DEBUG) {
         echo DEBUG_DELIM_OPEN;
         echo "Just entered: Database_DatabaseClassFactory::get_field_renderer_class(...)\n";
         echo "\$table_name: {$table_name}\n";
         echo "\$field_name: {$field_name}\n";
         $execution_timer = CLWDProjects_ExecutionTimer::get_instance();
         $execution_timer->mark();
         echo DEBUG_DELIM_CLOSE;
     }
     if (isset($this->field_renderer_classes[$table_name][$field_name])) {
         if (DEBUG) {
             echo DEBUG_DELIM_OPEN;
             echo "\$this->field_renderer_classes[{$table_name}][{$field_name}] is already set.\n";
             $execution_timer->mark();
             echo DEBUG_DELIM_CLOSE;
         }
     } else {
         $this->field_renderer_classes[$table_name][$field_name] = null;
         $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
         $project_directory = $project_directory_finder->get_project_directory_for_this_project();
         $project_specific_directory = $project_directory->get_project_specific_directory();
         $field_renderer_class_file = null;
         if ($project_specific_directory->has_database_class_name_file()) {
             $database_class_name_file = $project_specific_directory->get_database_class_name_file();
             if ($database_class_name_file->has_field_renderer_class_file($table_name, $field_name)) {
                 $field_renderer_class_file = $database_class_name_file->get_field_renderer_class_file($table_name, $field_name);
             }
         }
         # Fallback.
         if (!isset($field_renderer_class_file)) {
             $field_renderer_class_file = new FileSystem_PHPClassFile(PROJECT_ROOT . '/haddock/database/classes/renderers/Database_FieldRenderer.inc.php');
         }
         $field_renderer_class_file->declare_class();
         $this->field_renderer_classes[$table_name][$field_name] = new ReflectionClass($field_renderer_class_file->get_php_class_name());
     }
     if (DEBUG) {
         echo DEBUG_DELIM_OPEN;
         echo "About to return from: Database_DatabaseClassFactory::get_field_renderer_class(...)\n";
         $execution_timer->mark();
         echo "\$this->field_renderer_classes[{$table_name}][{$field_name}]:\n";
         print_r($this->field_renderer_classes[$table_name][$field_name]);
         echo DEBUG_DELIM_CLOSE;
     }
     return $this->field_renderer_classes[$table_name][$field_name];
 }
コード例 #4
0
 public function get_table_class_files()
 {
     $table_class_files = array();
     /*
      * The default table class file.
      */
     $default_table_class_file = new FileSystem_PHPClassFile(PROJECT_ROOT . '/haddock/database/classes/elements/' . 'Database_Table.inc.php');
     $mysql_user_factory = Database_MySQLUserFactory::get_instance();
     $mysql_user = $mysql_user_factory->get_for_this_project();
     $database = $mysql_user->get_database();
     $table_names = $database->get_table_names();
     $project_directory = $this->get_project_directory();
     $php_class_files = $project_directory->get_php_class_files();
     #print_r($php_class_files);
     #$table_reflection_class = new ReflectionClass('Database_Table');
     $table_reflection_class = $default_table_class_file->get_reflection_class();
     #print_r($table_reflection_class);
     foreach ($table_names as $table_name) {
         $table_class_files[$table_name][] = $default_table_class_file;
         foreach ($php_class_files as $php_class_file) {
             $php_class_file->declare_class();
             $php_class_file_reflection_class = $php_class_file->get_reflection_class();
             #echo $php_class_file_reflection_class->getName() . "<br />\n";
             #print_r($php_class_file_reflection_class);
             #
             #echo '$php_class_file_reflection_class->isAbstract(): ' . "\n";
             #echo $php_class_file_reflection_class->isAbstract() . "\n";
             #
             #echo '$php_class_file_reflection_class->isSubclassOf($table_reflection_class): ' . "\n";
             #echo $php_class_file_reflection_class->isSubclassOf($table_reflection_class) . "\n";
             if (!$php_class_file_reflection_class->isAbstract() && $php_class_file_reflection_class->isSubclassOf($table_reflection_class)) {
                 #echo 'Appending '
                 #    . $php_class_file->get_php_class_name()
                 #    . " to the array.\n";
                 $table_class_files[$table_name][] = $php_class_file;
             }
         }
     }
     #print_r($table_class_files);
     return $table_class_files;
 }
コード例 #5
0
 public static function convert_php_class_file_to_cli_script_php_class_file(FileSystem_PHPClassFile $php_class_file)
 {
     return new CLIScripts_CLIScriptPHPClassFile($php_class_file->get_name());
 }
コード例 #6
0
 /**
  * Should this be deprecated and moved to a helper class?
  */
 public static function cmp_php_class_names(FileSystem_PHPClassFile $a, FileSystem_PHPClassFile $b)
 {
     return strcasecmp($a->get_php_class_name(), $b->get_php_class_name());
 }