Copyright 2011-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Gunnar Wrobel (wrobel@pardus.de)
Esempio n. 1
0
 /**
  * Returns the release name.
  *
  * @return string The release name.
  */
 public function getName()
 {
     if (isset($this->_notes['name'])) {
         return $this->_notes['name'];
     }
     return $this->_component->getName();
 }
Esempio n. 2
0
File: Root.php Progetto: horde/horde
 /**
  * Try to determine the root path based on a component.
  *
  * @return string|boolean The root path or false if it could not be
  *                        determined.
  */
 private function _determineRootFromComponent()
 {
     if (!empty($this->_component)) {
         try {
             return $this->_component->repositoryRoot($this);
         } catch (Components_Exception $e) {
             $this->_errors[] = sprintf('Component %s has no repository root!', $this->_component->getName());
             return false;
         }
     }
     return false;
 }
Esempio n. 3
0
 /**
  * List a Horde component as dependency.
  *
  * @param Components_Component $component The component for which the
  *                                        dependency tree should be shown     * @param int                  $level     The current list level.
  * @param string               $parent    Name of the parent element.
  * @param array                $options   Options for generating the list.
  *
  * @return boolean True in case listing should continue.
  */
 private function _listComponent(Components_Component $component, $level, $parent, $options)
 {
     $key = $component->getName() . '/' . $component->getChannel();
     if (in_array($key, array_keys($this->_displayed_dependencies))) {
         if (empty($this->_displayed_dependencies[$key])) {
             $add = '(RECURSION) ***STOP***';
         } else {
             $add = '(ALREADY LISTED WITH ' . $this->_displayed_dependencies[$key] . ') ***STOP***';
         }
     } else {
         $add = '';
     }
     $this->_element($component->getChannel() == 'pear.horde.org' ? 'green' : 'yellow', $level, $key, $component->getName() . '-' . $component->getVersion(), $component->getChannel(), $add, $options);
     if (in_array($key, array_keys($this->_displayed_dependencies))) {
         return false;
     } else {
         $this->_displayed_dependencies[$key] = $parent;
         return true;
     }
 }
Esempio n. 4
0
 /**
  * Ensure that the component is available within the installation
  * environment.
  *
  * @param Components_Pear_Environment $environment The environment we
  *                                                 install into.
  * @param Components_Component        $component   The component that
  *                                                 should be installed.
  * @param array                       $options     Install options.
  * @param string                      $reason      Optional reason for
  *                                                 adding the package.
  *
  * @return NULL
  */
 private function _installComponent(Components_Pear_Environment $environment, Components_Component $component, $options = array(), $reason = '')
 {
     if (empty($options['pretend'])) {
         $component->install($environment, $this->_getPerComponentOptions($component, $options), $reason);
     } else {
         $this->_output->ok(sprintf('Would install component %s%s.', $component->getName(), $reason));
     }
 }
Esempio n. 5
0
    /**
     * Updates the component information in the horde-web repository.
     *
     * @param Components_Component $component The data of this component will
     *                                        be updated.
     * @param array                $options   The set of options for the
     *                                        operation.
     *
     * @return NULL
     */
    public function update(Components_Component $component, $options)
    {
        if (empty($options['destination'])) {
            throw new Components_Exception('"destination" MUST be set for this action!');
        } else {
            $destination = $options['destination'];
        }
        if (empty($options['html_generator'])) {
            throw new Components_Exception('"--html-generator" MUST be set for this action!');
        }
        $tmp_dir = Horde_Util::createTempDir();
        $archive = $component->placeArchive($tmp_dir, array('logger' => $this->_output));
        if (!$archive[0]) {
            throw new Components_Exception('Failed retrieving the component archive!');
        }
        system('cd ' . $tmp_dir . ' && tar zxpf ' . $archive[0]);
        $source = preg_replace('/\\.tgz$/', '', $archive[0]);
        $doc_files = $this->_identifyDocFiles($source . '/doc');
        $doc_files = array_merge($doc_files, $this->_identifyDocFiles($source . '/docs'));
        if (file_exists($source . '/README')) {
            $doc_files[$source . '/README'] = 'README';
        }
        if (preg_match('/^Horde_/', $component->getName())) {
            $view_root = $destination . '/app/views/Library/libraries/' . $component->getName() . '/docs';
        } else {
            $view_root = $destination . '/app/views/App/apps/' . $component->getName() . '/docs';
        }
        if (!file_exists($view_root)) {
            mkdir($view_root, 0777, true);
        }
        $docs = '<h3>Documentation</h3>

<p>These are the documentation files as distributed with the latest component\'s release tarball.</p>

<ul>
';
        foreach ($doc_files as $path => $filename) {
            if (preg_match('/^Horde_/', $component->getName())) {
                $docs .= '<li><a href="<?php echo $this->urlWriter->urlFor(array(\'controller\' => \'library\', \'action\' => \'docs\', \'library\' => \'' . $component->getName() . '\', \'file\' => \'' . $filename . '\')); ?>">' . $filename . '</a></li>' . "\n";
            } else {
                $docs .= '<li><a href="<?php echo $this->urlWriter->urlFor(array(\'controller\' => \'apps\', \'action\' => \'docs\', \'app\' => \'' . $component->getName() . '\', \'file\' => \'' . $filename . '\')); ?>">' . $filename . '</a></li>' . "\n";
            }
            if ($filename == 'CHANGES') {
                $out = '<h3>Changes by Release</h3><pre>';
                $orig = file_get_contents($path);
                $orig = preg_replace('/</', '&lt;', $orig);
                $orig = preg_replace(';pear\\s*(bug|request)\\s*#([[:digit:]]*);', '<a href="http://pear.php.net/bugs/bug.php?id=\\2">\\0</a>;', $orig);
                $orig = preg_replace(';(,\\s*|\\()((bug|request)\\s*#(\\d*));i', '\\1<a href="http://bugs.horde.org/ticket/\\4">\\2</a>', $orig);
                $out .= $orig . '</pre>';
            } elseif ($filename == 'RELEASE_NOTES') {
                $out = "<h3>Release notes for the latest release</h3><pre>\n";
                $notes = (include $path);
                $out .= $notes['changes'];
                $out .= "</pre>\n";
            } else {
                $descriptorspec = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
                $process = proc_open($options['html_generator'] . ' --output-encoding=UTF-8 --rfc-references ' . $path, $descriptorspec, $pipes);
                if (is_resource($process)) {
                    fclose($pipes[0]);
                    $out = stream_get_contents($pipes[1]);
                    fclose($pipes[1]);
                    $errors = stream_get_contents($pipes[2]);
                    fclose($pipes[2]);
                    $return_value = proc_close($process);
                    $out = preg_replace('#.*<body>[\\n]?(.*)</body>.*#ms', '\\1', $out);
                    if ($filename == 'DOCS_ORIGIN') {
                        $out = preg_replace('#\\?actionID=export&amp;format=rst#', '', $out);
                        $out = preg_replace('#<td class="field-body">(.*)</td>#', '<td class="field-body"><a href="<?php echo $this->urlWriter->urlFor(array(\'controller\' => \'library\', \'action\' => \'docs\', \'library\' => \'' . $component->getName() . '\', \'file\' => \'\\1\')); ?>">\\1</a></td>', $out);
                    }
                    if (!empty($errors)) {
                        $this->_output->warn(print_r($errors, true));
                    }
                } else {
                    //@todo
                }
            }
            //@todo Pretend
            if (!empty($out)) {
                file_put_contents($view_root . '/' . $filename . '.html', $out);
                $this->_output->ok(sprintf('Wrote documentation file "%s"!', $view_root . '/' . $filename . '.html'));
            }
        }
        $docs .= '</ul>';
        file_put_contents($view_root . '/docs.html', $docs);
        $data_file = $destination . '/config/components.d/' . strtolower($component->getName()) . '.json';
        if (empty($options['pretend'])) {
            $data = $component->getData();
            $data->hasDocuments = !empty($doc_files);
            file_put_contents($data_file, json_encode($data));
            $this->_output->ok(sprintf('Wrote data for component %s to %s', $component->getName(), $data_file));
        } else {
            $this->_output->info(sprintf('Would write data for component %s to %s', $component->getName(), $data_file));
        }
    }