예제 #1
0
<?php

/**
 * The args for the create-new-www-page script.
 *
 * @copyright Clear Line Web Design, 2007-08-27
 */
$section_and_module = HaddockProjectOrganisation_CLIModuleDirectoryFinder::find_section_and_module($args, 'page-section', "In which section do you want to save the new page?\n", 'page-module', "In which module do you want to save the new page?\n");
$page_section = $section_and_module['section'];
$page_module = NULL;
if (isset($section_and_module['module'])) {
    $page_module = $section_and_module['module'];
}
if (isset($args['page-name'])) {
    $page_name = $args['page-name'];
} else {
    echo "Please enter a name for the page:\n";
    $page_name = trim(fgets(STDIN));
}
if (isset($args['page-type'])) {
    $page_type = $args['page-type'];
} else {
    echo "Please enter a type for the page:\n";
    $page_type = trim(fgets(STDIN));
}
if (isset($args['copyright-holder'])) {
    $copyright_holder = $args['copyright-holder'];
} else {
    $config_file = $project_directory->get_config_file();
    $copyright_holder = $config_file->get_copyright_holder();
}
예제 #2
0
//        }
//
//        echo "The module that will be searched must be set: \n";
//
//        $search_module = CLIScripts_InputReader::get_choice_from_string($choice_str);
//
//        if (!isset($search_module)) {
//            echo "Quitting!\n";
//            exit;
//        }
//    }
//} else {
//    if (isset($args['script-module'])) {
//        throw new Exception('No module should be set if the section is project-specific!');
//    }
//}
$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");
$search_section = $section_and_module['section'];
$search_module = $section_and_module['module'];
if (isset($args['search-type'])) {
    $search_type = $args['search-type'];
} else {
    echo "Please enter the type of file that you are interested in.\n";
    echo "Leave blank to just list pages of all types.\n";
    $search_type = trim(fgets(STDIN));
}
if (!$silent) {
    echo "The search section: {$search_section}\n";
    echo "The class module: {$search_module}\n";
    echo "The type: {$search_type}\n";
}
예제 #3
0
<?php

/**
 * The args for the list-cli-scripts script.
 *
 * @copyright Clear Line Web Design, 2007-08-03
 */
echo "Do you want to list all the CLI scripts in the project?\n";
$all_project = CLIScripts_InputReader::ask_yes_no_question();
if (!$all_project) {
    $section_and_module = HaddockProjectOrganisation_CLIModuleDirectoryFinder::find_section_and_module($args, 'search-section', "Search for scripts in which section?\n", 'search-module', "Search for scripts in which module?\n");
} else {
    $section_and_module = NULL;
}
echo "Do you want to refresh the wrapper scripts?\n";
$refresh_wrapper_scripts = CLIScripts_InputReader::ask_yes_no_question();
if (!$silent) {
    if ($all_project) {
        echo "Searching the entire project.\n";
    } else {
        echo "Searching individual modules.\n";
    }
    if (isset($section_and_module)) {
        print_r($section_and_module);
    }
    echo ($refresh_wrapper_scripts ? 'R' : 'Not r') . "efreshing the wrapper scripts.\n";
}
 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));
     #}
 }