/**
  * Fetches the directory object for the module with
  * the matching name.
  *
  * Each module and plug-in should store its project-specific data
  * in its own directory.
  * This function returns that directory.
  *
  * @param string $module_name The identifying name of the module.
  */
 public static function get_directory($module_name)
 {
     if (HaddockProjectOrganisation_ModuleDirectoriesHelper::insist_module_directory_exists($module_name)) {
         $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
         $directory_name = $project_specific_directory->get_name() . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . $module_name;
         FileSystem_DirectoryHelper::mkdir_parents($directory_name);
         return new FileSystem_Directory($directory_name);
     }
 }
コード例 #2
0
 private static function get_default_location_directory_name($create_directory_if_not_exists = FALSE)
 {
     $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
     $default_location_directory_name = $project_specific_directory->get_name() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'public-html';
     if ($create_directory_if_not_exists) {
         if (!is_dir($default_location_directory_name)) {
             FileSystem_DirectoryHelper::mkdir_parents($default_location_directory_name);
         }
     }
     return $default_location_directory_name;
 }
 /**
  * Gets the name of the project information directory.
  *
  * If the directory does not exist, then it can optionally be created.
  * 
  * @param bool $create_directory_if_not_exists Whether the function should create the directory if it does not exist.
  * @return string The name of the directory containing the project information.
  */
 public static function get_project_information_directory_name($create_directory_if_not_exists = FALSE)
 {
     $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
     $project_information_directory_name = $project_specific_directory->get_name() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'haddock-project-organisation';
     if ($create_directory_if_not_exists) {
         if (!is_dir($project_information_directory_name)) {
             FileSystem_DirectoryHelper::mkdir_parents($project_information_directory_name);
         }
     }
     return $project_information_directory_name;
 }
    public static function create_project_specific_html_page_class()
    {
        $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
        $project_specific_directory->make_sure_classes_directory_exists();
        $classes_directory = $project_specific_directory->get_classes_directory();
        $html_pages_directory_name = $classes_directory->get_name() . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'html';
        #echo '$html_pages_directory_name: ' . $html_pages_directory_name . PHP_EOL;
        FileSystem_DirectoryHelper::mkdir_parents($html_pages_directory_name);
        $project_specific_html_page_class_name = $project_specific_directory->get_camel_case_root() . '_' . 'HTMLPage';
        #echo '$project_specific_html_page_class_name: ' . $project_specific_html_page_class_name . PHP_EOL;
        $project_specific_html_page_class_file_name = $html_pages_directory_name . DIRECTORY_SEPARATOR . $project_specific_html_page_class_name . '.inc.php';
        #echo '$project_specific_html_page_class_file_name: ' . $project_specific_html_page_class_file_name . PHP_EOL;
        if (is_file($project_specific_html_page_class_file_name)) {
            throw new ErrorHandling_SprintfException('\'%s\' already exists!', array($project_specific_html_page_class_file_name));
        } else {
            $date = date('Y-m-d');
            $copyright_holder = $project_specific_directory->get_copyright_holder();
            $file_contents = <<<CNT
<?php
/**
 * {$project_specific_html_page_class_name}
 *
 * @copyright {$date}, {$copyright_holder}
 */

abstract class
\t{$project_specific_html_page_class_name}
extends
\tPublicHTML_HTMLPage
{
}
?>
CNT;
            if ($fh = fopen($project_specific_html_page_class_file_name, 'w')) {
                fwrite($fh, $file_contents);
                fclose($fh);
                HaddockProjectOrganisation_AutoloadFilesHelper::refresh_autoload_file();
            }
        }
    }
 private static function get_project_information_directory_name()
 {
     $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
     return $project_specific_directory->get_name() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'haddock-project-organisation';
 }
 public static function test_project_specific_directory_exists()
 {
     $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
     return $project_specific_directory->exists();
 }
コード例 #7
0
    public static function create_html_pages()
    {
        /* 
         * Find the project specific directory for the classes.
         */
        $project_specific_directory = HaddockProjectOrganisation_ProjectSpecificDirectoryHelper::get_project_specific_directory();
        $project_specific_directory->make_sure_classes_directory_exists();
        $classes_directory = $project_specific_directory->get_classes_directory();
        $html_pages_directory_name = $classes_directory->get_name() . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'html';
        FileSystem_DirectoryHelper::mkdir_parents($html_pages_directory_name);
        $project_specific_html_page_class_name = $project_specific_directory->get_camel_case_root() . '_' . 'HTMLPage';
        /* 
         * Create the abstract class for the user login pages.
         */
        $project_specific_user_login_html_page_class_name = $project_specific_directory->get_camel_case_root() . '_' . 'UserLoginHtmlPage';
        $project_specific_user_login_html_page_class_file_name = $html_pages_directory_name . DIRECTORY_SEPARATOR . $project_specific_user_login_html_page_class_name . '.inc.php';
        if (is_file($project_specific_user_login_html_page_class_file_name)) {
            echo "'{$project_specific_user_login_html_page_class_file_name}' already exists!" . PHP_EOL;
        } else {
            $date = date('Y-m-d');
            $copyright_holder = $project_specific_directory->get_copyright_holder();
            $file_contents = <<<CNT
<?php
/**
 * {$project_specific_user_login_html_page_class_name}
 *
 * @copyright {$date}, {$copyright_holder}
 */

abstract class
\t{$project_specific_user_login_html_page_class_name}
extends
\t{$project_specific_html_page_class_name}
{
    public function
        get_error_message_div()
    {
        return UserLogin_DisplayHelper::get_error_message_div();
    }

    public function
        get_login_status_div()
    {
        return UserLogin_DisplayHelper::get_login_status_div();
    }
}
?>
CNT;
            if ($fh = fopen($project_specific_user_login_html_page_class_file_name, 'w')) {
                fwrite($fh, $file_contents);
                fclose($fh);
                HaddockProjectOrganisation_AutoloadFilesHelper::refresh_autoload_file();
            }
        }
        /* 
         * Create the registration page.
         */
        $project_specific_registration_html_page_class_name = $project_specific_directory->get_camel_case_root() . '_' . 'UserLoginRegistrationHtmlPage';
        $project_specific_registration_html_page_class_file_name = $html_pages_directory_name . DIRECTORY_SEPARATOR . $project_specific_registration_html_page_class_name . '.inc.php';
        if (is_file($project_specific_registration_html_page_class_file_name)) {
            echo "'{$project_specific_registration_html_page_class_file_name}' already exists!" . PHP_EOL;
        } else {
            $date = date('Y-m-d');
            $copyright_holder = $project_specific_directory->get_copyright_holder();
            $file_contents = <<<CNT
<?php
/**
 * {$project_specific_registration_html_page_class_name}
 *
 * @copyright {$date}, {$copyright_holder}
 */

class
\t{$project_specific_registration_html_page_class_name}
extends
\t{$project_specific_user_login_html_page_class_name}
{
    public function
        content()
    {
        \$div = new HTMLTags_Div();
        \$div->append(\$this->get_error_message_div());
        \$div->append(\$this->get_registration_div());
        echo \$div->get_as_string();
    }

    public function
        get_registration_div()
    {
        return UserLogin_DisplayHelper::get_registration_div();
    }
}
?>
CNT;
            if ($fh = fopen($project_specific_registration_html_page_class_file_name, 'w')) {
                fwrite($fh, $file_contents);
                fclose($fh);
                HaddockProjectOrganisation_AutoloadFilesHelper::refresh_autoload_file();
            }
        }
    }