예제 #1
0
 public function testStatsEmptyArray()
 {
     $expected = array(0 => 'vendor/zetacomponents/unit-test/design/class_diagram.png');
     $stats = array();
     self::assertEquals($expected, ezcBaseFile::findRecursive("vendor/zetacomponents/unit-test", array('@/design/@'), array('@\\.svn@'), $stats));
     self::assertEquals(array('size' => 166066, 'count' => 1), $stats);
 }
예제 #2
0
 public static function getModuleList()
 {
     $ModulesDir = 'modules';
     $ModuleList = array();
     $dirSeparator = DIRECTORY_SEPARATOR;
     $Modules = ezcBaseFile::findRecursive($ModulesDir, array('@module.php@'));
     foreach ($Modules as $ModuleInclude) {
         include $ModuleInclude;
         $ModuleList[str_replace("modules{$dirSeparator}", '', dirname($ModuleInclude))] = array('name' => erTranslationClassLhTranslation::getInstance()->getTranslation('permission/editrole', $Module['name']));
     }
     // Add extensions modules
     $cfg = erConfigClassLhConfig::getInstance();
     $extensions = $cfg->getSetting('site', 'extensions');
     foreach ($extensions as $extension) {
         if (is_dir("extension/{$extension}/{$ModulesDir}")) {
             $Modules = ezcBaseFile::findRecursive("extension/{$extension}/{$ModulesDir}", array('@module.php@'));
             foreach ($Modules as $ModuleInclude) {
                 include $ModuleInclude;
                 if (isset($ModuleList[str_replace("extension/{$extension}/{$ModulesDir}{$dirSeparator}", '', dirname($ModuleInclude))]['name'])) {
                     $ModuleList[str_replace("extension/{$extension}/{$ModulesDir}{$dirSeparator}", '', dirname($ModuleInclude))]['name'] .= ', EX - ' . erTranslationClassLhTranslation::getInstance()->getTranslation('permission/editrole', $Module['name']);
                 } else {
                     $ModuleList[str_replace("extension/{$extension}/{$ModulesDir}{$dirSeparator}", '', dirname($ModuleInclude))] = array('name' => erTranslationClassLhTranslation::getInstance()->getTranslation('permission/editrole', $Module['name']));
                 }
             }
         }
     }
     return $ModuleList;
 }
예제 #3
0
function appendRecursive($archive, $sourceDir, $prefix)
{
    $context = new ArchiveContext();
    $context->archive = $archive;
    $context->prefix = $prefix;
    ezcBaseFile::walkRecursive($sourceDir, array(), array(), 'findRecursiveCallback', $context);
}
예제 #4
0
 public function expireCache()
 {
     if (isset($_SESSION['lhc_chat_config'])) {
         unset($_SESSION['lhc_chat_config']);
     }
     if ($this->expiredInRuntime == false) {
         $this->expiredInRuntime = true;
         foreach ($this->expireOptions as $option) {
             $this->setSetting('cachetimestamps', $option, 0);
         }
         foreach ($this->sessionExpireOptions as $option) {
             if (isset($_SESSION[$option])) {
                 unset($_SESSION[$option]);
             }
         }
         $compiledModules = ezcBaseFile::findRecursive('cache/cacheconfig', array('@\\.cache\\.php@'));
         foreach ($compiledModules as $compiledClass) {
             unlink($compiledClass);
         }
         $compiledTemplates = ezcBaseFile::findRecursive('cache/compiledtemplates', array('@(\\.php|\\.js|\\.css)@'));
         foreach ($compiledTemplates as $compiledTemplate) {
             unlink($compiledTemplate);
         }
         $instance = CSCacheAPC::getMem();
         $instance->increaseImageManipulationCache();
         $this->save();
     }
 }
 public function testStatsEmptyArray()
 {
     $expected = array(0 => 'File/design/class_diagram.png', 1 => 'File/design/design.txt', 2 => 'File/design/file.xml', 3 => 'File/design/file_operations.png', 4 => 'File/design/md5.png', 5 => 'File/design/requirements.txt');
     $stats = array();
     self::assertEquals($expected, ezcBaseFile::findRecursive("File", array('@/design/@'), array('@\\.svn@'), $stats));
     self::assertEquals(array('size' => 114282, 'count' => 6), $stats);
 }
예제 #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $arr = \ezcBaseFile::findRecursive(SYSPATH . "/app/Api", array('@.*.php$@'));
     $apiHandler = new \Api\ApiHandler();
     $result = array();
     foreach ($arr as $file) {
         $method = basename($file, ".php");
         $class = $apiHandler->getClass($method);
         $rc = new \ReflectionClass($class);
         $txt = $rc->getDocComment();
         preg_match("|/\\*\\*\\s*( \\* [^-][^\n]+\n)+|i", $txt, $m);
         $txt = preg_replace(array("|/\\*\\*\n \\* |", "#\n ?\\* #"), array("", " "), $m[0]);
         $txt = trim($txt);
         $result[$method] = array($class, $txt);
     }
     $output->writeln("<comment>Список методов:</comment>");
     foreach ($result as $k => $v) {
         list($base) = explode(".", $k);
         if ($_base != $base) {
             $output->writeln("<comment>{$base}</comment>");
         }
         $_base = $base;
         $output->writeln(sprintf("  <info>%-24s</info> %s", $k, $v[1]));
     }
 }
예제 #7
0
 public function testNonExistingDirectory()
 {
     $expected = array();
     try {
         ezcBaseFile::findRecursive("NotHere", array('@xxx@'));
     } catch (ezcBaseFileNotFoundException $e) {
         self::assertEquals("The directory file 'NotHere' could not be found.", $e->getMessage());
     }
 }
예제 #8
0
파일: php.php 프로젝트: bmdevel/ezc
 /**
  * Processes the template with the variables added by the send() method.
  * The result of this action should be retrievable through the getResult() method.
  *
  * The $last parameter is set if the view handler is the last one in the
  * list of zones for a specific view.
  *
  * @param bool $last
  */
 public function process($last)
 {
     if (!file_exists($this->templateLocation)) {
         $fileName = ezcBaseFile::isAbsolutePath($this->templateLocation) ? $this->templateLocation : getcwd() . DIRECTORY_SEPARATOR . $this->templateLocation;
         throw new ezcBaseFileNotFoundException($fileName, 'php template');
     }
     ob_start();
     include $this->templateLocation;
     $this->result = ob_get_contents();
     ob_end_clean();
 }
 public function testRelative3()
 {
     $result = ezcBaseFile::calculateRelativePath('/foo/1/2/php.php', '/foo/bar');
     self::assertEquals('..' . DIRECTORY_SEPARATOR . '1' . DIRECTORY_SEPARATOR . '2' . DIRECTORY_SEPARATOR . 'php.php', $result);
     $result = ezcBaseFile::calculateRelativePath('/foo/bar/php.php', '/foo/bar');
     self::assertEquals('php.php', $result);
     $result = ezcBaseFile::calculateRelativePath('/php.php', '/foo/bar/1/2');
     self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'php.php', $result);
     $result = ezcBaseFile::calculateRelativePath('/bar/php.php', '/foo/bar/1/2');
     self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'php.php', $result);
 }
예제 #10
0
 public static function findRecursive($sourceDir, array $includeFilters = array(), array $excludeFilters = array())
 {
     // create the context, and then start walking over the array
     $context = new ezcBaseFileFindContext();
     ezcBaseFile::walkRecursive($sourceDir, $includeFilters, $excludeFilters, array('myProgressFinder', 'findRecursiveCallback'), $context);
     // collect the statistics (which we don't do anything with in this example)
     $statistics['size'] = $context->size;
     $statistics['count'] = $context->count;
     // return the found and pattern-matched files
     sort($context->elements);
     return $context->elements;
 }
예제 #11
0
 public function setUp()
 {
     try {
         if (file_exists('/tmp/lucene')) {
             ezcBaseFile::removeRecursive('/tmp/lucene');
         }
         mkdir('/tmp/lucene');
         $this->backend = new ezcSearchZendLuceneHandler("/tmp/lucene");
     } catch (ezcSearchCanNotConnectException $e) {
         self::markTestSkipped('Couldn\'t open Zend Lucene.');
     }
     $this->testFilesDir = dirname(__FILE__) . '/../testfiles/';
 }
예제 #12
0
 /**
  * Check and return file
  *
  * Check for the files location, and return the absolute path to the file,
  * or thorw an exception, if the file could not be found.
  * 
  * @param string $file 
  * @return string
  */
 protected function getFile($file)
 {
     if (!ezcBaseFile::isAbsolutePath($file)) {
         // If path to file is not an absolute path, use the given relative
         // path relative to the currently processed document location.
         $file = $this->path . $file;
     }
     // @TODO: docutils performs automatic checks, that no system files
     // (like /etc/passwd) are included - do we want to do similar stuff
     // here?
     // Throw an exception, if we cannot find the referenced file
     if (!is_file($file) || !is_readable($file)) {
         throw new ezcBaseFileNotFoundException($file);
     }
     return $file;
 }
 protected function setUp()
 {
     // truncates the ezsi_file table
     $db = eZDB::instance();
     $sql = 'TRUNCATE TABLE ' . self::SI_BLOCK_TABLE_NAME;
     if (!$db->query($sql)) {
         return false;
     }
     // removes files in the si-block directory
     if (is_dir(realpath(self::SI_BLOCK_STORAGE_DIR))) {
         try {
             ezcBaseFile::removeRecursive(self::SI_BLOCK_STORAGE_DIR);
         } catch (Exception $e) {
             echo 'Got Exception message : ' . $e->getMessage() . "\n";
             return false;
         }
     }
 }
 /**
  * Clears all static cache for a site
  * Removers all static cache, but not the static cache directory itself.
  *
  * Currently, this function only supports 'combined_host_url'
  *
  */
 static function clearStaticCache()
 {
     $ini = eZINI::instance('staticcache.ini');
     $storageDir = $ini->variable('CacheSettings', 'StaticStorageDir');
     // Check that we have combined_host_url hostmatching
     $siteIni = eZINI::instance();
     $matchType = $siteIni->variable('SiteAccessSettings', 'MatchOrder');
     if ($matchType !== 'combined_host_url') {
         throw new Exception('combined_host_url required for this workflow');
     }
     global $eZCurrentAccess;
     $siteAccess = $eZCurrentAccess['name'];
     //Get hostname part from siteaccess name (exclude for instance _eng or _admin)
     if (strpos($siteAccess, '_') === false) {
         $hostName = $siteAccess;
     } else {
         $hostName = substr($siteAccess, 0, strpos($siteAccess, '_'));
     }
     $staticCacheDir = eZDir::path(array($storageDir, $hostName));
     // Sanity checking, make sure we don't remove everyones static cache.
     if ($staticCacheDir == $storageDir) {
         throw new Exception("Failed to find correct static cache directory : {$staticCacheDir} \n");
     }
     $dirs = scandir($staticCacheDir);
     foreach ($dirs as $dir) {
         if ($dir !== '.' && $dir !== '..') {
             $fullPath = eZDir::path(array($staticCacheDir, $dir));
             if (is_dir($fullPath)) {
                 ezcBaseFile::removeRecursive($fullPath);
             } else {
                 if (!unlink($fullPath)) {
                     throw new ezsfFileCouldNotRemoveException($fullPath);
                 }
             }
         }
     }
 }
예제 #15
0
 public static function testAbsoluteStreamWrapper()
 {
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('phar://test.phar/foo'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('http://example.com/file'));
 }
예제 #16
0
 public function testRecursiveCopyFailureNotWriteable()
 {
     try {
         ezcBaseFile::copyRecursive($this->tempDir . '/dir2', $this->tempDir . '/dir4');
     } catch (ezcBaseFilePermissionException $e) {
         return;
     }
     $this->fail('Expected ezcBaseFilePermissionException.');
 }
 /**
  * Extracts class information from PHP sourcecode.
  * @return array (className=>filename)
  */
 protected function getClassFileList($fileList, $mode)
 {
     $retArray = array();
     $this->log("Searching for classes (tokenizing).");
     $statArray = array('nFiles' => count($fileList), 'classCount' => 0, 'classAdded' => 0);
     $this->setStatArray(self::OUTPUT_PROGRESS_PHASE2, $statArray);
     if (count($fileList)) {
         $this->startProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
         // Compatibility with PHP 5.2 where T_NAMESPACE constant is not available
         // Assigning the constant value to $tNamespace
         // 377 is the value for T_NAMESPACE in PHP 5.3.x
         $tNamespace = defined('T_NAMESPACE') ? T_NAMESPACE : self::UNDEFINED_TOKEN;
         // Traits support, see http://issues.ez.no/19028
         $tTrait = defined('T_TRAIT') ? T_TRAIT : self::UNDEFINED_TOKEN;
         foreach ($fileList as $file) {
             $this->updateProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
             if ($mode === self::MODE_SINGLE_EXTENSION) {
                 $file = getcwd() . DIRECTORY_SEPARATOR . $this->options->basePath . DIRECTORY_SEPARATOR . $file;
             }
             $tokens = @token_get_all(file_get_contents($file));
             $namespace = null;
             foreach ($tokens as $key => $token) {
                 if (is_array($token)) {
                     switch ($token[0]) {
                         case self::UNDEFINED_TOKEN:
                             // Unsupported token, do nothing
                             break;
                             // Store namespace name, if applicable, to concatenate with class name
                         // Store namespace name, if applicable, to concatenate with class name
                         case $tNamespace:
                             // NAMESPACE_TOKEN - WHITESPACE_TOKEN - TEXT_TOKENS (containing namespace name)
                             $offset = $key + 2;
                             $namespace = "";
                             while ($tokens[$offset] !== ";" && $tokens[$offset] !== "{") {
                                 if (is_array($tokens[$offset])) {
                                     $namespace .= $tokens[$offset][1];
                                 }
                                 $offset++;
                             }
                             $namespace = trim(addcslashes($namespace, '\\'));
                             break;
                         case T_CLASS:
                         case T_INTERFACE:
                         case $tTrait:
                             // Increment stat for found class.
                             $this->incrementProgressStat(self::OUTPUT_PROGRESS_PHASE2, 'classCount');
                             // CLASS_TOKEN - WHITESPACE_TOKEN - TEXT_TOKEN (containing class name)
                             $className = $tokens[$key + 2][1];
                             if ($namespace !== null) {
                                 $className = "{$namespace}\\\\{$className}";
                             }
                             $filePath = $file;
                             if ($mode === self::MODE_SINGLE_EXTENSION) {
                                 $filePath = ezcBaseFile::calculateRelativePath($filePath, getcwd() . DIRECTORY_SEPARATOR . $this->options->basePath);
                             }
                             // make sure we store cross-platform file system paths,
                             // using a forward slash as directory separator
                             if (DIRECTORY_SEPARATOR != '/') {
                                 $filePath = str_replace(DIRECTORY_SEPARATOR, '/', $filePath);
                             }
                             // Here there are two code paths.
                             // MODE_KERNEL_OVERRIDE will only add a class if
                             // it exists in the MODE_KERNEL autoload array.
                             // All other modes will only add a class if the
                             // class name is unique.
                             $addClass = $this->classCanBeAdded($className, $filePath, $mode, $retArray);
                             if ($addClass) {
                                 // increment stat for actually added number of classes.
                                 $this->incrementProgressStat(self::OUTPUT_PROGRESS_PHASE2, 'classAdded');
                                 $retArray[$className] = $filePath;
                             }
                             break;
                     }
                 }
             }
         }
         $this->stopProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
         ksort($retArray);
     }
     if ($this->output !== null) {
         extract($this->getStatArray(self::OUTPUT_PROGRESS_PHASE2));
         $this->log("Found {$classCount} classes, added {$classAdded} of them to the autoload array.");
     }
     return $retArray;
 }
예제 #18
0
 /**
  * Processes the specified template source and returns the output string.
  *
  * Note: The first time a template is accessed it needs to be compiled so the
  * execution time will be higher than subsequent calls.
  *
  * @param string $location The path to the template file to process, can be a PHP stream.
  * @param ezcTemplateConfiguration $config Optional configuration object which overrides
  *                                         the default one defined in this object ($configuration).
  * @return string
  *
  * @apichange Remove the test for ezcTemplateLocationInterface as it's deprecated.
  *
  * @throws ezcTemplateParserException
  *         If the template could not be compiled.
  * @throws ezcTemplateFileNotWriteableException
  *         If the directory could not be created.
  */
 public function process($location, ezcTemplateConfiguration $config = null)
 {
     if ($config === null) {
         $config = $this->configuration;
     }
     $this->properties["usedConfiguration"] = $config;
     $this->properties["tstTree"] = false;
     $this->properties["astTree"] = false;
     $this->properties["stream"] = $location;
     if ($location instanceof ezcTemplateLocation || $location instanceof ezcTemplateLocationInterface) {
         $this->properties["file"] = $location;
         $this->properties["stream"] = $location->getPath();
     } elseif ($config->locator) {
         $this->properties["stream"] = $config->locator->translatePath($this->properties["stream"]);
     }
     if (strlen($this->properties["stream"]) > 0 && !ezcBaseFile::isAbsolutepath($this->properties["stream"])) {
         $this->properties["stream"] = $config->templatePath . DIRECTORY_SEPARATOR . $this->properties["stream"];
     }
     $this->properties["streamStack"][] = $this->properties["stream"];
     // lookup compiled code here
     $compiled = ezcTemplateCompiledCode::findCompiled($this->properties["stream"], $config->context, $this);
     $this->properties["compiledTemplatePath"] = $compiled->path;
     $counter = 0;
     while (true) {
         ++$counter;
         if ($counter > 3) {
             // @todo fix exception
             throw new ezcTemplateCompilationFailedException("Failed to create and execute compiled code after " . ($counter - 1) . " tries.");
         }
         if (file_exists($compiled->path) && (!$config->checkModifiedTemplates || filemtime($this->properties["stream"]) <= filemtime($compiled->path))) {
             if (!$config->executeTemplate) {
                 $this->properties["output"] = "";
                 return "";
             }
             try {
                 // execute compiled code here
                 $this->properties["output"] = $compiled->execute();
                 return $this->properties["output"];
             } catch (ezcTemplateOutdatedCompilationException $e) {
                 // The compiled file cannot be used so we need to recompile it
             }
         }
         $this->createDirectory(dirname($compiled->path));
         // get the compiled path.
         // use parser here
         $source = new ezcTemplateSourceCode($this->properties["stream"], $this->properties["stream"]);
         $source->load();
         $parser = new ezcTemplateParser($source, $this);
         $this->properties["tstTree"] = $parser->parseIntoNodeTree();
         if ($parser->hasCacheBlocks && !$config->disableCache) {
             $fetchCacheInfo = new ezcTemplateFetchCacheInformation();
             $this->properties["tstTree"]->accept($fetchCacheInfo);
             $tstToAst = new ezcTemplateTstToAstCachedTransformer($parser, $fetchCacheInfo->cacheTst);
         } else {
             $tstToAst = new ezcTemplateTstToAstTransformer($parser);
         }
         $this->properties["tstTree"]->accept($tstToAst);
         $this->properties["astTree"] = $tstToAst->programNode;
         $astToAst = new ezcTemplateAstToAstContextAppender($config->context);
         $tstToAst->programNode->accept($astToAst);
         // Extra optimization.
         $astToAst = new ezcTemplateAstToAstAssignmentOptimizer();
         $tstToAst->programNode->accept($astToAst);
         $g = new ezcTemplateAstToPhpGenerator($compiled->path, $config);
         // Write to the file.
         $tstToAst->programNode->accept($g);
         // Add to the cache system.
         if ($config->cacheManager) {
             $config->cacheManager->includeTemplate($this, $this->properties["stream"]);
         }
     }
     // execute compiled code here
     throw new ezcTemplateInternalException("Compilation or execution failed");
 }
예제 #19
0
<?php

require 'tutorial_autoload.php';
$data = ezcBaseFile::findRecursive(dirname(__DIR__), array('@repos/.*_autoload.php$@'), array('@/my_.*@'));
var_dump($data);
 public function testRecursiveCopyDirCalled0()
 {
     ezcBaseFile::copyRecursive($this->tempDir . '/dir7', $this->tempDir . '/dest');
     $this->assertEquals(count(ezcBaseFile::findRecursive($this->tempDir . '/dir7')), count(ezcBaseFile::findRecursive($this->tempDir . '/dest')));
     $this->assertTrue(is_dir($this->tempDir . '/dest/0'));
 }
예제 #21
0
 function getSiteIniFiles()
 {
     $siteIniList = ezcBaseFile::findRecursive($this->getNewDistroPathName() . "settings", array('@site\\.ini@'));
     $result = array();
     foreach ($siteIniList as $siteIniFilePath) {
         $parts = explode($this->getNewDistroPathName(), $siteIniFilePath);
         // ignore the default site.ini and any temp INI files
         if ($parts[1] != 'settings/site.ini' and $parts[1] != '/settings/site.ini' and !strstr($siteIniFilePath, '~') and !strstr($siteIniFilePath, '.LCK')) {
             $result[] = $parts[1];
         }
     }
     return $result;
 }
예제 #22
0
 /**
  * Resets the whole storage.
  *
  * Deletes all data in the storage including {@link ezcCacheStackMetaData}
  * that was stored using {@link storeMetaData()}.
  */
 public function reset()
 {
     $files = glob("{$this->properties['location']}*");
     foreach ($files as $file) {
         if (is_dir($file)) {
             ezcBaseFile::removeRecursive($file);
         } else {
             if (@unlink($file) === false) {
                 throw new ezcBaseFilePermissionException($file, ezcBaseFileException::REMOVE, 'Could not unlink cache file.');
             }
         }
     }
 }
 public static function testAbsoluteLinux3()
 {
     if (ezcBaseFeatures::os() === 'Windows') {
         self::markTestSkipped('Test is for unix-like systems only');
     }
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt//winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:/winnt/winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:/winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:/table.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:winnt'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c//winnt.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//winnt.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('/winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('winnt.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//server/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////server/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//tequila/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////tequila/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//tequila/thare/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////tequila/thare/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//server//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////server//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//tequila//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////tequila//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('/etc/init.d/apache'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//etc//init.d//apache'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('etc/init.d/apache'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('etc//init.d//apache'));
 }
예제 #24
0
    ezcBaseFile::removeRecursive('var/tmpfiles/backupfiles');
    if (!file_exists('var/tmpfiles/backupfiles')) {
        mkdir('var/tmpfiles/backupfiles');
        mkdir('var/tmpfiles/backupfiles/design');
    }
    $zip->extractTo('var/tmpfiles/update');
    $zip->close();
    $foldersSwitch = array('doc', 'ezcomponents', 'lib', 'modules', 'pos', 'translations', 'design/backendtheme', 'design/defaulttheme');
    echo "Switching folders\n";
    foreach ($foldersSwitch as $folder) {
        rename($folder, 'var/tmpfiles/backupfiles/' . $folder . '_' . $date);
        rename('var/tmpfiles/update/livehelperchat-master/lhc_web/' . $folder, $folder);
    }
    unlink('var/tmpfiles/master.zip');
    echo "Your old folders can be found - var/tmpfiles/backupfiles\n";
    ezcBaseFile::removeRecursive('var/tmpfiles/update');
    $jsonObject = json_decode(erLhcoreClassModelChatOnlineUser::executeRequest('https://raw.githubusercontent.com/LiveHelperChat/livehelperchat/master/lhc_web/doc/update_db/structure.json'), true);
    echo "----------------\nUpdating database\n----------------\n";
    if (is_array($jsonObject)) {
        $errorMessages = erLhcoreClassUpdate::doTablesUpdate($jsonObject);
        if (empty($errorMessages)) {
            $CacheManager = erConfigClassLhCacheConfig::getInstance();
            $CacheManager->expireCache();
            echo "UPDATE DONE\n";
        } else {
            echo "ERROR:\n" . implode("\n", $errorMessages);
        }
    }
} else {
    echo "Could not download archive!!!";
}
예제 #25
0
파일: main.php 프로젝트: bmdevel/ezc
 /**
  * Tries to locate a file
  *
  * Tries to locate a file, referenced in a docbook document. If available
  * the document path is used a base for relative paths.
  *
  * @param string $file
  * @return string
  */
 public function locateFile($file)
 {
     if (!ezcBaseFile::isAbsolutePath($file)) {
         $file = $this->document->getPath() . $file;
     }
     if (!is_file($file)) {
         throw new ezcBaseFileNotFoundException($file);
     }
     return $file;
 }
<?php

// php cron.php -s site_admin -c cron/util/generate_translation_file_ext -p extension/icclicktocall
$arrayTranslationsProcess = array();
$filesToCheck = ezcBaseFile::findRecursive('./' . $cronjobPathOption->value, array('@\\.php$@'), array('@/albums|ezcomponents|doc|translations|var|cache|bin|Zend|setttings|pos/@'));
$locale = 'en_EN';
foreach ($filesToCheck as $filePath) {
    $contentFile = file_get_contents($filePath);
    $Matches = array();
    preg_match_all('/<\\?php echo erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)(.*?)\\?\\>/i', $contentFile, $Matches);
    foreach ($Matches[1] as $key => $section) {
        if (!isset($arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section] = array();
        }
        if (!in_array($Matches[2][$key], $arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section][] = $Matches[2][$key];
        }
        $contentFile = str_replace($Matches[0][$key], '', $contentFile);
    }
    $Matches = array();
    preg_match_all('/erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)/i', $contentFile, $Matches);
    foreach ($Matches[1] as $key => $section) {
        if (!isset($arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section] = array();
        }
        if (!in_array($Matches[2][$key], $arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section][] = $Matches[2][$key];
        }
    }
}
$reader = new ezcTranslationTsBackend($cronjobPathOption->value . '/doc');
<?php

// php cron.php -s site_admin -c cron/util/generate_translation_file
$arrayTranslationsProcess = array();
$items = erLhcoreClassModelChatConfig::getItems(array('limit' => 500, 'filter' => array('hidden' => 0)));
foreach ($items as $item) {
    $arrayTranslationsProcess['listchatconfig'][] = $item->explain;
}
$filesToCheck = ezcBaseFile::findRecursive('.', array('@\\.php$@'), array('@/./albums|./ezcomponents|./doc|./translations|./var|./extension|./cache|./bin|./Zend|./setttings|./pos/@'));
$locale = 'en_EN';
foreach ($filesToCheck as $filePath) {
    $contentFile = file_get_contents($filePath);
    $Matches = array();
    preg_match_all('/<\\?php echo erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)(.*?)\\?\\>/i', $contentFile, $Matches);
    foreach ($Matches[1] as $key => $section) {
        if (!isset($arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section] = array();
        }
        if (!in_array($Matches[2][$key], $arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section][] = $Matches[2][$key];
        }
        $contentFile = str_replace($Matches[0][$key], '', $contentFile);
    }
    $Matches = array();
    preg_match_all('/erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)/i', $contentFile, $Matches);
    foreach ($Matches[1] as $key => $section) {
        if (!isset($arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section] = array();
        }
        if (!in_array($Matches[2][$key], $arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section][] = $Matches[2][$key];
예제 #28
0
파일: extractor.php 프로젝트: bmdevel/ezc
 /**
  * Run the generator.
  * Process the given options and generates translation files.
  */
 public function run()
 {
     try {
         $this->input->process();
     } catch (ezcConsoleException $e) {
         $this->raiseError("Error while processing your options: {$e->getMessage()}", true);
     }
     if ($this->input->getOption('h')->value === true) {
         $this->output->outputText($this->input->getHelpText(self::PROGRAM_DESCRIPTION, 80, true), "help");
         exit(0);
     }
     $translationDir = $this->input->argumentDefinition["translation dir"]->value;
     $templatePath = realpath($this->input->getOption("templates")->value);
     // setup the backend to write to and/or read from
     $options = array('format' => $this->input->getOption("format")->value, 'keepObsolete' => true);
     $this->backend = new ezcTranslationTsBackend($translationDir);
     $this->backend->setOptions($options);
     $locale = $this->input->getOption("locale")->value;
     // remove the translation file if option overwrite is set
     $translationFile = $this->backend->buildTranslationFileName($locale);
     if ($this->input->getOption("overwrite")->value === true && file_exists($translationFile)) {
         unlink($translationFile);
     }
     // init the writer
     $this->backend->initWriter($locale);
     // keep track of which contexts are in use
     $usedContexts = array();
     // find the .ezt files and loop over them.
     $it = ezcBaseFile::findRecursive($templatePath, array('@\\.ezt$@'));
     foreach ($it as $item) {
         $pathname = $this->unifyFilepath(realpath($item), $templatePath);
         $this->output->outputLine('Processing file ' . $pathname . ' ...');
         // get translation contexts from template
         $contexts = $this->getTranslationsFromTemplate($item);
         foreach ($contexts as $contextName => $translationMapNew) {
             // record that this context is in use
             $usedContexts[] = $contextName;
             // get existing translation strings from file
             if ($this->input->getOption("overwrite")->value === false) {
                 $translationMapOriginal = $this->getTranslationsFromTsFile($contextName);
             } else {
                 $translationMapOriginal = array();
             }
             // create empty context
             $context = array();
             // insert new translations
             foreach ($translationMapNew as $original => $translationElement) {
                 // insert new strings
                 if (!isset($translationMapOriginal[$original])) {
                     // edit filename to unify accross platforms and strip template path
                     $translationElement->filename = $this->unifyFilepath($translationElement->filename, $templatePath);
                     $context[] = $translationElement;
                 }
             }
             // update translations
             if ($this->input->getOption("overwrite")->value === false) {
                 foreach ($translationMapOriginal as $original => $translationElement) {
                     // update data
                     if (isset($translationMapNew[$original])) {
                         $new = $translationMapNew[$original];
                         $translationElement->comment = $new->comment;
                         $translationElement->filename = $this->unifyFilepath($new->filename, $templatePath);
                         $translationElement->line = $new->line;
                         $translationElement->column = $new->column;
                         // change status of previously obsolete strings
                         if ($translationElement->status == ezcTranslationData::OBSOLETE) {
                             if (!empty($translationElement->translation)) {
                                 $translationElement->status = ezcTranslationData::TRANSLATED;
                             } else {
                                 $translationElement->status = ezcTranslationData::UNFINISHED;
                             }
                         }
                         $context[] = $translationElement;
                     } elseif ($translationElement->filename == $pathname) {
                         $translationElement->status = ezcTranslationData::OBSOLETE;
                         $context[] = $translationElement;
                     }
                 }
             }
             $this->backend->storeContext($contextName, $context);
         }
     }
     // write translation data to file
     $this->backend->deinitWriter();
     $contextNames = $this->backend->getContextNames($locale);
     // init the writer
     $this->backend->initWriter($locale);
     // check which contexts are now totally gone
     foreach ($contextNames as $contextName) {
         if (!in_array($contextName, $usedContexts)) {
             echo "{$contextName} is all obsolete\n";
             $context = $this->backend->getContext($locale, $contextName);
             foreach ($context as &$translationElement) {
                 $translationElement->status = ezcTranslationData::OBSOLETE;
             }
             $this->backend->storeContext($contextName, $context);
         }
     }
     // write translation data to file
     $this->backend->deinitWriter();
     $this->output->outputLine();
     $this->output->outputLine("Translation file for locale '{$locale}' successfully written to '{$translationDir}'.", 'info');
 }
예제 #29
0
 /**
  * Deletes everything below a path.
  *
  * Deletes the resource identified by $path recursively. Returns an
  * instance of {@link ezcWebdavErrorResponse} if the deletion failed, and
  * null on success.
  * 
  * @param string $path 
  * @return ezcWebdavErrorResponse
  */
 protected function performDelete($path)
 {
     $errors = $this->checkDeleteRecursive($this->root . $path);
     // If an error will occur return the proper status. We return
     // multistatus in any case.
     if (count($errors)) {
         return new ezcWebdavMultistatusResponse($errors);
     }
     // Just delete otherwise
     if (is_file($this->root . $path)) {
         unlink($this->root . $path);
     } else {
         ezcBaseFile::removeRecursive($this->root . $path);
     }
     // Finally empty property storage for removed node
     $storagePath = $this->getPropertyStoragePath($path);
     if (is_file($storagePath)) {
         unlink($storagePath);
     }
     return null;
 }
 public function testRecursiveNotWritableParent()
 {
     self::assertEquals(15, count(ezcBaseFile::findRecursive($this->tempDir)));
     try {
         ezcBaseFile::removeRecursive($this->tempDir . '/dir7/dir1');
     } catch (ezcBaseFilePermissionException $e) {
         self::assertEquals("The file '{$this->tempDir}/dir7' can not be opened for writing.", $e->getMessage());
     }
     self::assertEquals(15, count(ezcBaseFile::findRecursive($this->tempDir)));
 }