/** * Rewrite the template(s) from the source(s) to the target location(s). * * @param array $parameters The template(s) parameters. * * @return NULL */ public function write(array $parameters = array()) { if (!file_exists($this->_target)) { mkdir($this->_target, 0777, true); } foreach (new IteratorIterator(new DirectoryIterator($this->_source)) as $file) { if ($file->isFile()) { $this->writeSourceToTarget($file->getPathname(), $this->_target . '/' . $file->getBasename(), $parameters); } if ($file->isDir() && !$file->isDot()) { $directory = new Components_Helper_Templates_RecursiveDirectory($this->_source . '/' . $file->getBasename(), $this->_target . '/' . $file->getBasename()); $directory->write($parameters); } } }
} return $output; } if (in_array($component->getName(), $applications)) { $package_name = 'horde5-' . $component->getName(); } elseif (in_array($component->getName(), $bundles)) { throw new Components_Exception("Bundles are not supported in openSUSE"); } else { $package_name = 'php5-pear-' . $component->getName(); } $package_version = $component->getVersion(); $destination .= '/server:php:applications/' . $package_name; $archive = array_shift($component->placeArchive($destination, array("logger" => $this->_output, 'keep_version' => true))); if (!file_exists($destination)) { mkdir($destination, 0700, true); } $t_dirs = array($this->_config_application->getTemplateDirectory() . '/templates'); if (file_exists($t_dirs[0] . '-' . $package_name)) { $t_dirs[] = $t_dirs[0] . '-' . $package_name; } if (file_exists($t_dirs[0] . '-' . $package_name . '-' . $package_version)) { $t_dirs[] = $t_dirs[0] . '-' . $package_name . '-' . $package_version; } foreach ($t_dirs as $template_directory) { $build_template = new Components_Helper_Templates_RecursiveDirectory($template_directory, $destination); $build_template->write(array('name' => $package_name, 'version' => $package_version, 'component' => $component, 'applications' => $applications, 'bundles' => $bundles)); } // build a text containing only the last change. Use dash instead of * $changes = "updated to version {$package_version}\n- [xxx] something changed\n- [yyy] This changed too" . $component->getChangelog(new Components_Helper_ChangeLog($this->_output)); //$changes = $component->getInstallationFileList(); shell_exec("cd {$destination} && mv package.spec {$package_name}.spec && osc vc -m \"{$changes}\" &> file");
public function testMissingTargetRecursiveDirectory() { $tdir = $this->getTemporaryDirectory() . DIRECTORY_SEPARATOR . 'a' . '/b'; $templates = new Components_Helper_Templates_RecursiveDirectory(__DIR__ . '/../../../fixture/templates/rec-dir', $tdir); $templates->write(array('one' => 'One', 'two' => 'Two')); $this->assertEquals("One", file_get_contents($tdir . '/one/one')); $this->assertEquals("Two", file_get_contents($tdir . '/two/two')); }
public function run() { $options = $this->_config->getOptions(); $templates = new Components_Helper_Templates_RecursiveDirectory($this->_config_application->getTemplateDirectory(), $options['cisetup']); $templates->write(array('config' => $this->_config)); }