/**
     * Allows access to a directory on the server.
     *
     * Access to the directory is restricted using a .htaccess file.
     *
     * If there is already a .htaccess file in the directory, it is backed up first.
     *
     * @param string $directory The name of the directory, relative to PROJECT_ROOT.
     */
    public static function allow_access_to_directory($directory)
    {
        $validator = new FileSystem_ExistingDirectoryRelativeToProjectRootValidator();
        if ($validator->validate($directory)) {
            $abs_directory = PROJECT_ROOT . DIRECTORY_SEPARATOR . $directory;
            $htaccess_file_name = $abs_directory . DIRECTORY_SEPARATOR . '.htaccess';
            /*
             * Back up the old file.
             */
            if (file_exists($htaccess_file_name)) {
                $back_up_htaccess_file_name = $htaccess_file_name . '_' . date('U');
                rename($htaccess_file_name, $back_up_htaccess_file_name);
            }
            $copyright_holder = HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_holder();
            $date = date('Y-m-d');
            if ($fh = fopen($htaccess_file_name, 'w')) {
                $htaccess_file_content = <<<HTA
# Allowing access to {$directory}
# (c) {$date}, {$copyright_holder}

Order Allow,Deny
Allow from all

HTA;
                fwrite($fh, $htaccess_file_content);
                fclose($fh);
            }
        }
    }
 public function do_actions()
 {
     if ($this->has_arg('datum-name')) {
         $datum_name = $this->get_arg('datum-name');
     } else {
         echo 'Which datum do you want to set?' . PHP_EOL;
         $datum_name = CLIScripts_UserInterrogationHelper::get_choice_from_string_array(array('Name', 'Title', 'Copyright Holder', 'Version Code', 'Camel Case Root'));
         echo "Setting the '{$datum_name}'" . PHP_EOL;
     }
     if ($this->has_arg('new-value')) {
         $new_value = $this->get_arg('new-value');
     } else {
         echo 'Please enter the new value:' . PHP_EOL;
         $new_value = trim(fgets(STDIN));
         echo 'New value: ' . $new_value . PHP_EOL;
     }
     switch ($datum_name) {
         case 'Name':
             HaddockProjectOrganisation_ProjectInformationHelper::set_name($new_value);
             break;
         case 'Title':
             HaddockProjectOrganisation_ProjectInformationHelper::set_title($new_value);
             break;
         case 'Copyright Holder':
             HaddockProjectOrganisation_ProjectInformationHelper::set_copyright_holder($new_value);
             break;
         case 'Version Code':
             HaddockProjectOrganisation_ProjectInformationHelper::set_version_code($new_value);
             break;
         case 'Camel Case Root':
             HaddockProjectOrganisation_ProjectInformationHelper::set_camel_case_root($new_value);
             break;
     }
 }
 public static function test_project_title_can_be_worked_out_from_the_project_name()
 {
     self::set_up();
     $title = HaddockProjectOrganisation_ProjectInformationHelper::get_title();
     $test_result = isset($title) && strlen($title) > 0;
     if (file_exists($title_back_up_file_name)) {
         rename($title_back_up_file_name, $title_file_name);
     }
     self::tear_down();
     return $test_result;
 }
 public static function get_start_page_widget_content()
 {
     $ul = new HTMLTags_UL();
     $info = array('Title' => HaddockProjectOrganisation_ProjectInformationHelper::get_title(), 'Version' => HaddockProjectOrganisation_ProjectInformationHelper::get_version_code(), 'Copyright Holder' => HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_holder());
     $dl = new HTMLTags_DL();
     foreach ($info as $key => $value) {
         $dt = new HTMLTags_DT($key . ':&nbsp;');
         $dd = new HTMLTags_DD($value);
         $dl->append($dt);
         $dl->append($dd);
     }
     return $dl;
 }
 public function do_actions()
 {
     #$config_manager = Configuration_ConfigManagerHelper::get_config_manager('haddock', 'haddock-project-organisation');
     /*
      * List the info.
      */
     echo 'Information about your installation:' . PHP_EOL;
     #printf(
     #	'Release major version: \'%s\'' . PHP_EOL,
     #	$config_manager->get_major_release_version()
     #);
     printf('Name: \'%s\'' . PHP_EOL, HaddockProjectOrganisation_ProjectInformationHelper::get_name());
     printf('Title: \'%s\'' . PHP_EOL, HaddockProjectOrganisation_ProjectInformationHelper::get_title());
     printf('Copyright Holder: \'%s\'' . PHP_EOL, HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_holder());
     printf('Version Code: \'%s\'' . PHP_EOL, HaddockProjectOrganisation_ProjectInformationHelper::get_version_code());
     printf('Camel Case Root: \'%s\'' . PHP_EOL, HaddockProjectOrganisation_ProjectInformationHelper::get_camel_case_root());
 }
/* Code copied from new style Admin_HTMLPage
 * to give old-style admin pages the same look
 */
$image_div = new HTMLTags_Div();
$image_div->set_attribute_str('id', 'logo_image');
$logo_img = new HTMLTags_IMG();
$logo_src_url = new HTMLTags_URL();
$cmf = HaddockProjectOrganisation_ConfigManagerFactory::get_instance();
$config_manager = $cmf->get_config_manager('haddock', 'admin');
$logo_config_filename = $config_manager->get_logo_image_filename();
$logo_src_url->set_file($logo_config_filename);
$logo_img->set_src($logo_src_url);
$image_div->append($logo_img);
echo $image_div->get_as_string();
$h1_title = new HTMLTags_Heading(1);
$home_link = new HTMLTags_A(HaddockProjectOrganisation_ProjectInformationHelper::get_title());
$home_link->set_href(new HTMLTags_URl('/'));
$h1_title->append_tag_to_content($home_link);
echo $h1_title->get_as_string();
$gvm = Caching_GlobalVarManager::get_instance();
echo "<h2>\n";
//
//echo "Admin\n";
//
//echo "&nbsp;&gt;&nbsp;\n";
#echo $current_module_directory->get_admin_section_title();
#echo "\n";
#print_r($current_admin_page_directory);
//if (isset($current_admin_page_directory)) {
//    echo "&nbsp;&gt;&nbsp;\n";
//
    public function render_body_div_footer()
    {
        ?>
<div
    id="footer"
>
<?php 
        echo '&copy; ';
        echo HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_date_string();
        echo ', ';
        echo HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_holder();
        echo PHP_EOL;
        ?>
</div>
<?php 
    }
 /**
  * Should this value be set for each module?
  */
 public function get_copyright_holder()
 {
     return HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_holder();
 }
 protected function get_widget_title()
 {
     $title = HaddockProjectOrganisation_ProjectInformationHelper::get_title();
     return $title . '&nbsp;Information';
 }
 protected function get_widget_content()
 {
     return HaddockProjectOrganisation_ProjectInformationHelper::get_start_page_widget_content();
 }
 private static function get_initial_date_file_name()
 {
     $project_information_directory_name = HaddockProjectOrganisation_ProjectInformationHelper::get_project_information_directory_name($create_directory_if_not_exists = TRUE);
     return $project_information_directory_name . DIRECTORY_SEPARATOR . 'initial-date.txt';
 }
 private static function get_copyright_string()
 {
     $copyright_string = '';
     /*
      * Create a date string.
      */
     $date = date('Y-m-d');
     /*
      * Get the name of the copyright holder of the project.
      */
     $copyright_holder = HaddockProjectOrganisation_ProjectInformationHelper::get_copyright_holder();
     $copyright_string .= "{$date}, {$copyright_holder}";
     return $copyright_string;
 }
 protected function get_project_title()
 {
     #/*
     # * Find the module config manager.
     # */
     #$cmf = HaddockProjectOrganisation_ConfigManagerFactory::get_instance();
     #$config_manager = $cmf->get_config_manager('haddock', 'haddock-project-organisation');
     #
     #return $config_manager->get_project_name();
     return HaddockProjectOrganisation_ProjectInformationHelper::get_title();
 }
 public function get_title()
 {
     return HaddockProjectOrganisation_ProjectInformationHelper::get_title();
 }
 public static function get_instance_specific_config_directory_for_project_name()
 {
     return self::get_instance_specific_config_directory_name() . DIRECTORY_SEPARATOR . HaddockProjectOrganisation_ProjectInformationHelper::get_name();
 }
 public static function test_project_camel_case_root_is_settable_with_numbers()
 {
     #self::set_up();
     $test_camel_case_root = 'F0oB4r';
     HaddockProjectOrganisation_ProjectInformationHelper::set_camel_case_root($test_camel_case_root);
     $test_result = HaddockProjectOrganisation_ProjectInformationHelper::get_camel_case_root() == $test_camel_case_root;
     #self::tear_down();
     return $test_result;
 }