Exemplo n.º 1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $storage1 = new Horde_SessionHandler_Storage_File(array('path' => self::$dir));
     $storage2 = new Horde_SessionHandler_Storage_File(array('path' => Horde_Util::createTempDir()));
     self::$handler = new Horde_SessionHandler_Storage_Stack(array('stack' => array($storage1, $storage2)));
 }
Exemplo n.º 2
0
 /**
  * Constructor.
  *
  * @param array $params  Configuration parameters:
  * <pre>
  * email_charset - (string) The default email charset.
  *                 DEFAULT: NONE
  * temp - (string) [REQUIRED] Location of temporary directory.
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct(array $params = array())
 {
     if (empty($params['temp'])) {
         throw new InvalidArgumentException('A temporary directory must be provided.');
     }
     $this->_tempdir = Horde_Util::createTempDir(true, $params['temp']);
     $this->_params = array_merge(array('email_charset' => null), $params);
 }
Exemplo n.º 3
0
 public function setUp()
 {
     if (!self::$conf) {
         $this->markTestSkipped('No test configuration');
     }
     $conf = self::$conf;
     $conf['paths']['cvsps_home'] = Horde_Util::createTempDir(true, $conf['paths']['cvsps_home']);
     $conf['sourceroot'] = __DIR__ . '/repos/cvs';
     $this->vcs = Horde_Vcs::factory('Cvs', $conf);
 }
Exemplo n.º 4
0
 public function testXmlCreation()
 {
     $tmp_dir = Horde_Util::createTempDir();
     file_put_contents($tmp_dir . '/.gitignore', '');
     mkdir($tmp_dir . '/horde');
     mkdir($tmp_dir . '/framework');
     mkdir($tmp_dir . '/framework/test');
     file_put_contents($tmp_dir . '/framework/test/test.php', '<?php');
     $_SERVER['argv'] = array('horde-components', '--updatexml', $tmp_dir . '/framework/test');
     $this->_callStrictComponents();
     $this->assertTrue(file_exists($tmp_dir . '/framework/test/package.xml'));
 }
Exemplo n.º 5
0
 public function testError()
 {
     $this->setPearGlobals();
     $cwd = getcwd();
     $tmp_dir = Horde_Util::createTempDir();
     $_SERVER['argv'] = array('horde-components', '--verbose', '--snapshot', '--destination=' . $tmp_dir, __DIR__ . '/../../../fixture/simple');
     try {
         $this->_callUnstrictComponents();
     } catch (Components_Exception_Pear $e) {
         ob_end_clean();
         $this->assertContains('PEAR_Packagefile_v2::toTgz: invalid package.xml', (string) $e);
         $this->assertContains('Old.php" in package.xml does not exist', $e);
     }
     chdir($cwd);
 }
Exemplo n.º 6
0
 /**
  * Return the full rendered version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  * @throws Horde_Exception
  */
 protected function _render()
 {
     $has_xsl = Horde_Util::extensionExists('xsl');
     if ($has_xsl) {
         $tmpdir = Horde_Util::createTempDir(true) . '/';
     }
     $fnames = array('content.xml', 'styles.xml', 'meta.xml');
     $tags = array('text:p' => 'p', 'table:table' => 'table border="0" cellspacing="1" cellpadding="0" ', 'table:table-row' => 'tr bgcolor="#cccccc"', 'table:table-cell' => 'td', 'table:number-columns-spanned=' => 'colspan=');
     if (!$this->getConfigParam('zip')) {
         $this->setConfigParam('zip', Horde_Compress::factory('Zip'));
     }
     $list = $this->getConfigParam('zip')->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_LIST));
     foreach ($list as $key => $file) {
         if (in_array($file['name'], $fnames)) {
             $content = $this->getConfigParam('zip')->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_DATA, 'info' => $list, 'key' => $key));
             if ($has_xsl) {
                 file_put_contents($tmpdir . $file['name'], $content);
             } elseif ($file['name'] == 'content.xml') {
                 return array($this->_mimepart->getMimeId() => array('data' => str_replace(array_keys($tags), array_values($tags), $content), 'status' => array(), 'type' => 'text/html; charset=UTF-8'));
             }
         }
     }
     if (!$has_xsl) {
         return array();
     }
     $xslt = new XSLTProcessor();
     $xsl = new DOMDocument();
     $xsl->load(realpath(__DIR__ . '/Ooo/export/xhtml/opendoc2xhtml.xsl'));
     $xslt->importStylesheet($xsl);
     $xslt->setParameter('http://www.w3.org/1999/XSL/Transform', array('metaFileURL' => 'file://' . $tmpdir . 'meta.xml', 'stylesFileURL' => 'file://' . $tmpdir . 'styles.xml', 'java' => false));
     $xml = new DOMDocument();
     $xml->load(realpath($tmpdir . 'content.xml'));
     $result = $xslt->transformToXml($xml);
     if (!$result) {
         $result = libxml_get_last_error()->message;
     }
     return array($this->_mimepart->getMimeId() => array('data' => $result, 'status' => array(), 'type' => 'text/html; charset=UTF-8'));
 }
Exemplo n.º 7
0
 protected function getTemporaryDirectory()
 {
     return Horde_Util::createTempDir();
 }
Exemplo n.º 8
0
 /**
  * Return the package.xml file from the archive.
  *
  * Function copied from Pirum.
  *
  * (c) 2009 - 2011 Fabien Potencier
  *
  * @return string The path to the package.xml file.
  */
 private function _loadPackageFromArchive()
 {
     if (!function_exists('gzopen')) {
         $tmpDir = Horde_Util::createTempDir();
         copy($this->_archive, $tmpDir . '/archive.tgz');
         system('cd ' . $tmpDir . ' && tar zxpf archive.tgz');
         if (!is_file($tmpDir . '/package.xml')) {
             throw new Horde_Component_Exception(sprintf('Found no package.xml in "%s"!', $this->_archive));
         }
         return $tmpDir . '/package.xml';
     }
     $gz = gzopen($this->_archive, 'r');
     if ($gz === false) {
         throw new Horde_Component_Exception(sprintf('Failed extracting archive "%s"!', $this->_archive));
     }
     $tar = '';
     while (!gzeof($gz)) {
         $tar .= gzread($gz, 10000);
     }
     gzclose($gz);
     while (strlen($tar)) {
         $filename = rtrim(substr($tar, 0, 100), chr(0));
         $filesize = octdec(rtrim(substr($tar, 124, 12), chr(0)));
         if ($filename != 'package.xml') {
             $offset = $filesize % 512 == 0 ? $filesize : $filesize + (512 - $filesize % 512);
             $tar = substr($tar, 512 + $offset);
             continue;
         }
         $checksum = octdec(rtrim(substr($tar, 148, 8), chr(0)));
         $cchecksum = 0;
         $tar = substr_replace($tar, '        ', 148, 8);
         for ($i = 0; $i < 512; $i++) {
             $cchecksum += ord($tar[$i]);
         }
         if ($checksum != $cchecksum) {
             throw new Horde_Component_Exception(sprintf('Invalid archive "%s"!', $this->_archive));
         }
         $package = substr($tar, 512, $filesize);
         $tmpFile = Horde_Util::getTempFile();
         file_put_contents($tmpFile, $package);
         return $tmpFile;
     }
     throw new Horde_Component_Exception(sprintf('Found no package.xml in "%s"!', $this->_archive));
 }
Exemplo n.º 9
0
 public static function setUpBeforeClass()
 {
     self::$dir = Horde_Util::createTempDir();
 }
Exemplo n.º 10
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));
        }
    }
Exemplo n.º 11
0
 /**
  * Constructor.
  *
  * @param string $gnupg  The path to the GnuPG binary.
  * @param string $temp   Location of temporary directory.
  */
 public function __construct($gnupg, $temp = null)
 {
     $this->_tempdir = Horde_Util::createTempDir($temp);
     /* Store the location of GnuPG and set common options. */
     $this->_gnupg = array($gnupg, '--emit-version', '--no-tty', '--no-secmem-warning', '--no-options', '--no-default-keyring', '--yes', '--homedir ' . $this->_tempdir);
 }
Exemplo n.º 12
0
 public function testConstruction()
 {
     $b = new Horde_Prefs_Storage_File('nobody', array('directory' => Horde_Util::createTempDir()));
 }