public function __construct($xml_file_name_stem, $db_section, $db_module = NULL)
 {
     $this->xml_file_name_stem = $xml_file_name_stem;
     $this->db_section = $db_section;
     $this->db_module = $db_module;
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $pd = $pdf->get_project_directory_for_this_project();
     $md = $pd->get_module_directory($db_section, $db_module);
     $this->xml_file = $md->get_db_admin_xml_file($xml_file_name_stem);
 }
 public static function get_cli_script_class_files()
 {
     /*
      * Get a list of all the non-abstract subclasses of
      * 'CLIScripts_CLIScript' for the whole project.
      */
     $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $project_directory = $project_directory_finder->get_project_directory_for_this_project();
     $cli_script_subclasses_files = $project_directory->get_php_subclass_files('CLIScripts_CLIScript', $include_parent_class = FALSE, $include_abstract_classes = FALSE);
     return array_map(array('CLIScripts_CLIScriptFilesHelper', 'convert_php_class_file_to_cli_script_php_class_file'), $cli_script_subclasses_files);
 }
 private function get_passwords_file_for_this_project()
 {
     $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();
     //
     //$passwords_file = $project_specific_directory->get_passwords_file();
     $passwords_file = $project_directory->get_passwords_file();
     return $passwords_file;
 }
 public static function get_instance()
 {
     if (self::$instance == NULL) {
         self::$instance = new HaddockProjectOrganisation_ProjectDirectoryFinder();
     }
     return self::$instance;
     #        if (!isset($_SESSION['project-directory-finder'])) {
     #            $_SESSION['project-directory-finder']
     #                = new HaddockProjectOrganisation_ProjectDirectoryFinder();
     #        }
     #
     #        return $_SESSION['project-directory-finder'];
 }
 public function get_payment_plug_ins()
 {
     if (!isset($this->payment_plug_ins)) {
         $this->payment_plug_ins = array();
         $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
         $pd = $pdf->get_project_directory_for_this_project();
         $payments_plug_in_module = $pd->get_plug_in_module_directory('payments');
         #print_r($payments_plug_in_module); exit;
         $this->payment_plug_ins = $payments_plug_in_module->get_payment_plug_ins();
     }
     #print_r($this->payment_plug_ins); exit;
     return $this->payment_plug_ins;
 }
 public static function find_section_and_module($args, $section_arg_name, $section_question, $module_arg_name, $module_question)
 {
     $section_and_module = array();
     if (isset($args[$section_arg_name])) {
         $section_and_module['section'] = $args[$section_arg_name];
     } else {
         echo $section_question;
         $section_and_module['section'] = CLIScripts_InputReader::get_choice_from_string('haddock plug-ins project-specific');
         if (!isset($section_and_module['section'])) {
             echo "Quitting!\n";
             exit;
         }
     }
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $project_directory = $pdf->get_project_directory_for_this_project();
     if ($section_and_module['section'] != 'project-specific') {
         if (isset($args[$module_arg_name])) {
             $section_and_module['module'] = $args[$module_arg_name];
         } else {
             if ($section_and_module['section'] == 'haddock') {
                 $module_directories = $project_directory->get_core_module_directories();
             } else {
                 if ($section_and_module['section'] == 'plug-ins') {
                     $module_directories = $project_directory->get_plug_in_module_directories();
                 }
             }
             $choice_str = '';
             $first = TRUE;
             foreach ($module_directories as $md) {
                 if ($first) {
                     $first = FALSE;
                 } else {
                     $choice_str .= ' ';
                 }
                 $choice_str .= $md->get_identifying_name();
             }
             echo $module_question;
             $section_and_module['module'] = CLIScripts_InputReader::get_choice_from_string($choice_str);
             if (!isset($section_and_module['module'])) {
                 echo "Quitting!\n";
                 exit;
             }
         }
     } else {
         if (isset($args[$module_arg_name])) {
             throw new Exception('No module should be set if the section is project-specific!');
         }
     }
     return $section_and_module;
 }
 public function get_config_manager($section, $module = NULL)
 {
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $pd = $pdf->get_project_directory_for_this_project();
     $md = $pd->get_module_directory($section, $module);
     $iscf = NULL;
     $pscf = NULL;
     $mcf = NULL;
     if ($md->has_instance_specific_config_file()) {
         $iscf = $md->get_instance_specific_config_file();
     }
     if ($md->has_project_specific_config_file()) {
         $pscf = $md->get_project_specific_config_file();
     }
     /*
      * Create the config manager reflection class.
      * 
      * If the module defines its own config manager and this is
      * set in the module's config file, then an instance of that
      * class should be returned.
      * 
      * Otherwise, an exception is thrown.
      */
     $cmcn = '';
     if ($md->has_config_file()) {
         $mcf = $md->get_config_file();
         if ($mcf->has_nested_value_str('haddock-project-organisation config-manager')) {
             $cmcn = $mcf->get_nested_value_str('haddock-project-organisation config-manager');
         }
     }
     if (strlen($cmcn) > 0) {
         $cmrc = new ReflectionClass($cmcn);
         return $cmrc->newInstance($section, $module, $iscf, $pscf, $mcf);
     } else {
         throw new ErrorHandling_SprintfException('No config manager class set in the \'%s\' module in the \'%s\'!', array($module, $section));
     }
 }
Ejemplo n.º 8
0
<?php

/**
 * The main .INC for the create-new-haddock-class script.
 * @copyright Clear Line Web Design, 2007-07-31
 */
/*
 * Create the singleton objects.
 */
$cmf = HaddockProjectOrganisation_ConfigManagerFactory::get_instance();
$pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
$project_directory = $pdf->get_project_directory_for_this_project();
$cm = $cmf->get_config_manager('haddock', 'haddock-project-organisation');
if ($class_section == 'project-specific') {
    $module_directory = $project_directory->get_project_specific_directory();
} else {
    if ($class_section == 'haddock') {
        $module_directory = $project_directory->get_core_module_directory($class_module);
    } elseif ($class_section == 'plug-ins') {
        $module_directory = $project_directory->get_plug_in_module_directory($class_module);
    }
}
$full_class_name = $module_directory->get_camel_case_root() . '_' . $class_name;
if (!$silent) {
    echo "The full class name: {$full_class_name}\n";
}
$classes_directory = $module_directory->get_classes_directory();
$class_filename = $classes_directory->get_name() . "/{$full_class_name}.inc.php";
if (!$silent) {
    echo "The class filename: {$class_filename}\n";
}
 /**
  * @return HaddockProjectOrganisation_ModuleDirectory
  *  The module directory where this page request lives.
  */
 public function get_module_directory()
 {
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $pd = $pdf->get_project_directory_for_this_project();
     if ($this->get_section() == 'project-specific') {
         return $pd->get_project_specific_directory();
     } else {
         if ($this->get_section() == 'plug-ins') {
             return $pd->get_plug_in_module_directory($this->get_module());
         }
         if ($this->get_section() == 'haddock') {
             return $pd->get_core_module_directory($this->get_module());
         }
     }
     throw new Exception('No module directory found!');
 }
 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];
 }
 public function get_project_directory()
 {
     $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $project_directory = $project_directory_finder->get_project_directory_for_this_project();
     return $project_directory;
 }
 private function get_shop_module_directory()
 {
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $pd = $pdf->get_project_directory_for_this_project();
     $smd = $pd->get_plug_in_module_directory('shop');
     return $smd;
 }
 public static function get_all_unit_tests_php_class_files()
 {
     $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $project_directory = $project_directory_finder->get_project_directory_for_this_project();
     return $project_directory->get_all_unit_tests_php_class_files();
 }
 public static function refresh_autoload_file()
 {
     $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $project_directory = $project_directory_finder->get_project_directory_for_this_project();
     $project_directory->refresh_autoload_file();
 }
 /**
  * @return HaddockProjectOrganisation_ModuleDirectory
  *  The module directory where this page request lives.
  */
 public function get_module_directory()
 {
     if (DEBUG) {
         echo DEBUG_DELIM_OPEN;
         echo 'Method: ' . __METHOD__ . PHP_EOL;
         echo 'Line: ' . __LINE__ . PHP_EOL;
         echo DEBUG_DELIM_CLOSE;
     }
     $module_directory = null;
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $pd = $pdf->get_project_directory_for_this_project();
     if (DEBUG) {
         echo DEBUG_DELIM_OPEN;
         echo 'Method: ' . __METHOD__ . PHP_EOL;
         echo 'Line: ' . __LINE__ . PHP_EOL;
         echo 'print_r($pd):' . PHP_EOL;
         print_r($pd);
         echo DEBUG_DELIM_CLOSE;
     }
     $section = $this->get_section();
     if (DEBUG) {
         echo DEBUG_DELIM_OPEN;
         echo 'Method: ' . __METHOD__ . PHP_EOL;
         echo 'Line: ' . __LINE__ . PHP_EOL;
         echo '$section: ' . $section . PHP_EOL;
         echo DEBUG_DELIM_CLOSE;
     }
     if ($section == 'project-specific') {
         $module_directory = $pd->get_project_specific_directory();
     } else {
         if ($this->get_section() == 'plug-ins') {
             $module_directory = $pd->get_plug_in_module_directory($this->get_module());
         }
         if ($this->get_section() == 'haddock') {
             $module_directory = $pd->get_core_module_directory($this->get_module());
         }
     }
     if (DEBUG) {
         echo DEBUG_DELIM_OPEN;
         echo 'Method: ' . __METHOD__ . PHP_EOL;
         echo 'Line: ' . __LINE__ . PHP_EOL;
         echo 'print_r($module_directory):' . PHP_EOL;
         print_r($module_directory);
         echo DEBUG_DELIM_CLOSE;
     }
     if (isset($module_directory)) {
         return $module_directory;
     } else {
         throw new Exception('No module directory found!');
     }
 }
 private function get_admin_config_file()
 {
     $pdf = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $pd = $pdf->get_project_directory_for_this_project();
     $psd = $pd->get_project_specific_directory();
     return $psd->get_config_file('haddock', 'admin');
 }
Ejemplo n.º 17
0
 *  - the host
 *  - the username
 *  - the database
 *  - the password
 *
 * that are used by this project are saved to file.
 *
 * @copyright Clear Line Web Design, 2007-01-26
 */
/*
 * -----------------------------------------------------------------------------
 */
require_once PROJECT_ROOT . '/haddock/haddock-project-organisation/classes/' . 'HaddockProjectOrganisation_ProjectDirectoryFinder.inc.php';
/*
 * -----------------------------------------------------------------------------
 */
/*
 * Define the necessary classes.
 */
$return_to = '/admin/database/passwords-file-management.html';
if (isset($_POST['host']) && isset($_POST['username']) && isset($_POST['database']) && isset($_POST['password'])) {
    $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();
    $password_file = $project_specific_directory->get_passwords_file();
    $password_file->set_host($_POST['host']);
    $password_file->set_username($_POST['username']);
    $password_file->set_database($_POST['database']);
    $password_file->set_password($_POST['password']);
    $password_file->commit();
}
 public function do_actions()
 {
     $batch_mode = isset($args['batch-mode']);
     $whole_project = isset($args['whole-project']);
     if (!$whole_project) {
         $section_and_module = HaddockProjectOrganisation_CLIModuleDirectoryFinder::find_section_and_module($args, 'search-section', "The section to search must be set:\n", 'search-module', "The module to search must be set:\n");
     }
     if (isset($args['parent-class'])) {
         $parent_class = $args['parent-class'];
     }
     $output_in_csv = isset($args['csv']);
     //$output_in_csv = FALSE;
     //if ($batch_mode) {
     //    $output_in_csv = isset($args['csv']);
     //} else {
     //    if (isset($args['csv'])) {
     //        $output_in_csv = TRUE;
     //    } else {
     //        echo "Output in CSVs?\n";
     //        $output_in_csv = CLIScripts_InputReader::get_choice_from_string('yes no');
     //    }
     //}
     $methods = FALSE;
     if ($batch_mode) {
         $methods = isset($args['methods']);
     } else {
         if (isset($args['methods'])) {
             $methods = TRUE;
         } else {
             echo "Search for methods?\n";
             $methods = CLIScripts_InputReader::get_choice_from_string('yes no') == 'yes';
         }
     }
     $files = FALSE;
     if ($batch_mode) {
         $files = isset($args['files']);
     } else {
         if (isset($args['files'])) {
             $files = TRUE;
         } else {
             echo "List the files?\n";
             $files = CLIScripts_InputReader::get_choice_from_string('yes no') == 'yes';
         }
     }
     if ($methods) {
         $sort_methods = FALSE;
         if (isset($args['sort-methods'])) {
             $sort_methods = TRUE;
         } else {
             echo "Sort the methods?\n";
             $sort_methods = CLIScripts_InputReader::get_choice_from_string('yes no') == 'yes';
         }
     } else {
         if (isset($args['sort-methods'])) {
             throw new Exception('--sort-methods must not be set if --methods is not set!');
         }
     }
     if (!$silent) {
         echo $batch_mode ? "Running in batch mode.\n" : "Not running in batch mode.\n";
         if ($whole_project) {
             echo "Searching the whole project.\n";
         } else {
             echo 'Searching the ' . $section_and_module['section'] . " section.\n";
             if ($section_and_module['section'] != 'project-specific') {
                 echo 'Searching the ' . $section_and_module['module'] . " module.\n";
             }
         }
         echo 'Output ' . ($output_in_csv ? '' : 'not ') . "in CSVs.\n";
         echo ($methods ? 'L' : 'Not l') . "isting the methods.\n";
         echo ($files ? 'L' : 'Not l') . "isting the files.\n";
     }
     /*
      * Find the classes.
      */
     $project_directory_finder = HaddockProjectOrganisation_ProjectDirectoryFinder::get_instance();
     $project_directory = $project_directory_finder->get_project_directory_for_this_project();
     $php_class_files = array();
     if ($whole_project) {
         if (isset($parent_class)) {
             $php_class_files = $project_directory->get_php_subclass_files($parent_class);
         } else {
             $php_class_files = $project_directory->get_php_class_files();
         }
     } else {
         if ($section_and_module['section'] == 'project-specific') {
             $module_directory = $project_directory->get_project_specific_directory();
         } else {
             if ($section_and_module['section'] == 'haddock') {
                 $module_directory = $project_directory->get_core_module_directory($section_and_module['module']);
             } elseif ($section_and_module['section'] == 'plug-ins') {
                 $module_directory = $project_directory->get_plug_in_module_directory($section_and_module['module']);
             }
         }
         if ($parent_class) {
             $php_class_files = $module_directory->get_php_subclass_files($parent_class);
         } else {
             $php_class_files = $module_directory->get_php_class_files();
         }
     }
     usort($php_class_files, array('FileSystem_PHPClassFile', 'cmp_php_class_names'));
     /*
      * Print off the data.
      */
     if (count($php_class_files) > 0) {
         if ($methods) {
             /*
              * Does it makes sense to do this in batch mode or CSV mode?
              */
             if (!$batch_mode and !$output_in_csv) {
                 echo "Which class do you want to search for methods?\n";
                 $choice_str = '';
                 $first = TRUE;
                 foreach ($php_class_files as $p_c_f) {
                     if ($first) {
                         $first = FALSE;
                     } else {
                         $choice_str .= ' ';
                     }
                     $choice_str .= $p_c_f->get_php_class_name();
                 }
                 $class_name = CLIScripts_InputReader::get_choice_from_string($choice_str);
                 $php_class_file = NULL;
                 foreach ($php_class_files as $p_c_f) {
                     if ($p_c_f->get_php_class_name() == $class_name) {
                         $php_class_file = $p_c_f;
                         break;
                     }
                 }
                 if (isset($php_class_file)) {
                     echo 'The methods of ' . $php_class_file->get_php_class_name();
                     if ($files) {
                         echo ' saved in "PROJECT_ROOT . ' . $php_class_file->get_name_relative_to_dir(PROJECT_ROOT) . '"';
                     }
                     echo ":\n\n";
                     $class_reflection_object = $php_class_file->get_reflection_class();
                     $method_names = array();
                     foreach ($class_reflection_object->getMethods() as $method) {
                         if ($method->getDeclaringClass() == $class_reflection_object) {
                             $method_names[] = $method->getName();
                         }
                     }
                     if ($sort_methods) {
                         sort($method_names);
                     }
                     foreach ($method_names as $mn) {
                         echo "\t{$mn}\n";
                     }
                     echo "\n";
                 }
             }
         } else {
             if (!$output_in_csv) {
                 echo "\nThe classes: \n\n";
             }
             foreach ($php_class_files as $p_c_f) {
                 if ($output_in_csv) {
                     echo '"' . $p_c_f->get_php_class_name() . '"';
                     if ($files) {
                         echo ',';
                         echo '"' . $p_c_f->get_name_relative_to_dir(PROJECT_ROOT) . '"';
                     }
                     echo "\n";
                 } else {
                     echo "\t" . $p_c_f->get_php_class_name();
                     if ($files) {
                         echo "\n";
                         echo "\t" . $p_c_f->get_name_relative_to_dir(PROJECT_ROOT) . "\n";
                     }
                     echo "\n";
                 }
             }
             if (!$output_in_csv) {
                 echo "\n";
             }
         }
     } else {
         if (!$output_in_csv) {
             echo "No classes found!\n";
         }
     }
     #/*
     # * Require a user response before exiting.
     # */
     #if (!$batch_mode) {
     #    echo "Press \"ENTER\" to exit.\n";
     #    $reply = trim(fgets(STDIN));
     #}
 }