示例#1
0
 private function _test_file_lists()
 {
     $file_options = global_file_options();
     $delimiter = $file_options->path_delimiter;
     $input_path = $this->env->source_path();
     $input_path->append('../../../templates/wizards/new_application');
     $files = file_list_for($input_path->as_text(), '', true);
     $this->_check_equal(140, sizeof($files));
     $this->_check_equal('code' . $delimiter . 'cmd' . $delimiter . '[[_entry_name_lc_]]_commands.php', $files[0]);
     $files = file_list_for($input_path->as_text(), '', false);
     $this->_check_equal(1, sizeof($files));
     $this->_check_equal('config.ini', $files[0]);
     $files = file_list_for($input_path->as_text(), 'my/new/files', true);
     $this->_check_equal(140, sizeof($files));
     $this->_check_equal('my' . $delimiter . 'new' . $delimiter . 'files' . $delimiter . 'code' . $delimiter . 'cmd' . $delimiter . '[[_entry_name_lc_]]_commands.php', $files[0]);
     $files = file_list_for($input_path->as_text(), 'my/new/files', false);
     $this->_check_equal(1, sizeof($files));
     $this->_check_equal('my' . $delimiter . 'new' . $delimiter . 'files' . $delimiter . 'config.ini', $files[0]);
 }
示例#2
0
/**
 * Return the list of files for the given path.
 * @param string $base_path Must be a full path.
 * @param string $path_to_prepend Prepended to each file.
 * @param bool $recurse If true, include all sub-folders.
 * @param FILE_OPTIONS $opts
 * @return string[]
 */
function file_list_for($base_path, $path_to_prepend = '', $recurse = false, $opts = NULL)
{
    if (!isset($opts)) {
        $opts = global_file_options();
    }
    $base_path = ensure_ends_with_delimiter($base_path, $opts);
    $Result = array();
    if ($handle = @opendir($base_path)) {
        while (($name = readdir($handle)) != false) {
            if ($name[0] != '.') {
                if (is_dir(join_paths($base_path, $name))) {
                    if ($recurse) {
                        $Result = array_merge($Result, file_list_for(join_paths($base_path, $name, $opts), join_paths($path_to_prepend, $name, $opts), $recurse, $opts));
                    }
                } else {
                    $Result[] = join_paths($path_to_prepend, $name);
                }
            }
        }
        closedir($handle);
    }
    return $Result;
}
 /**
  * @access private
  */
 protected function _execute()
 {
     $input_path = $this->env->source_path();
     $input_path->append('wizards/new_application');
     $config = parse_ini_file($input_path->appended_as_text('config.ini'), true);
     $paths = read_array_index($config, 'recurse_paths');
     $exts = read_array_index($config, 'extensions');
     $files = array();
     foreach ($paths as $path) {
         $files = array_merge($files, file_list_for($input_path->appended_as_text($path), $path, true));
     }
     $output_path = $this->env->source_path();
     $output_path->append('wizards/output/' . $this->app_folder);
     foreach ($files as $file_name) {
         $in = $input_path;
         $in->append($file_name);
         $ext = $in->extension();
         $out = $output_path;
         $out->append($this->_apply_templates($file_name));
         if (in_array($ext, $exts)) {
             $this->_log('Read [' . $in->as_text() . ']');
             $text = file_get_contents($in->as_text());
             $text = $this->_apply_templates($text);
             $out->write_text_file($text);
             $this->_log('Wrote [' . $out->as_text() . ']', Msg_type_info);
         } else {
             $out->ensure_path_exists();
             copy($in->as_text(), $out->as_text());
             $this->_log('Copied to [' . $out->as_text() . ']', Msg_type_info);
         }
     }
 }
示例#4
0
****************************************************************************/
if ($App->login->is_allowed(Privilege_set_global, Privilege_configure)) {
    $class_name = $App->final_class_name('APPLICATION_CONFIGURATION_INFO', 'webcore/obj/framework_info.php');
    $info = new $class_name($App);
    if (read_var('framework')) {
        $base_url = $Env->source_path();
        $info_to_uprade = $info->lib_info;
    } else {
        $base_url = $App->source_path();
        $info_to_uprade = $info->app_info;
    }
    if (!$info_to_uprade->exists() || $info_to_uprade->needs_upgrade()) {
        $version_tag = 'public $version_from = \'' . $info_to_uprade->database_version . '\';';
        $base_url->append('tasks/db');
        $path = $base_url->as_text();
        $files = file_list_for($path);
        foreach ($files as $f) {
            $text = file_get_contents($path . $f);
            if (strpos($text, $version_tag) !== false) {
                $class_names = null;
                $Result = preg_match('/class ([a-zA-Z_0-9]+) extends/', $text, $class_names);
                if (sizeof($class_names) != 2) {
                    log_message("Could not find class name in [{$f}].", Msg_type_warning);
                } else {
                    $task_class_name = $class_names[1];
                    $task_file_name = $path . $f;
                    break;
                }
            }
        }
        if (empty($task_class_name)) {