protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $this->logSection('Create directory', "Visiteur");
     $q = Doctrine_Query::create()->from('Visiteur v');
     $visiteurs = $q->execute();
     foreach ($visiteurs as $visiteur) {
         $visiteur->createDataFolder();
     }
     $this->logSection('Create directory', "Interactif");
     $q = Doctrine_Query::create()->from('Interactif i');
     $interactifs = $q->execute();
     foreach ($interactifs as $interactif) {
         $interactif->createDataFolder();
     }
     $this->logSection('Create directory', "Exposition");
     $q = Doctrine_Query::create()->from('Exposition v');
     $expositions = $q->execute();
     foreach ($expositions as $exposition) {
         $exposition->createDataFolder();
     }
     $this->logSection('Create directory', "Medaille");
     $fileSystem = new sfFilesystem();
     $fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille");
     $this->logSection('Create directory', "MedailleType");
     $fileSystem = new sfFilesystem();
     $fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille_type");
 }
 public function execute($arguments = array(), $options = array())
 {
     $projectDir = UtilPsdf::fixPath($arguments['pjpath']);
     $packagesDir = $projectDir . DIRECTORY_SEPARATOR . $arguments['pkpath'] . DIRECTORY_SEPARATOR;
     if (is_dir($projectDir)) {
         throw new sfCommandException(sprintf('The project "%s" already exists.', $projectDir));
     }
     $filesystem = new sfFilesystem();
     // Create basic workspace structure
     $skeletonDir = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProject';
     $finder = sfFinder::type('any')->discard('.sf');
     $filesystem->mirror($skeletonDir, $projectDir, $finder);
     // Actualizo tokens
     $constants = array('PROJECT_NAME' => $arguments['pjname']);
     $finder = sfFinder::type('file')->name('.project');
     $filesystem->replaceTokens($finder->in($projectDir), '##', '##', $constants);
     // Create packages files (subdir por cada macro)
     $packages = $arguments['packages'];
     foreach ($packages as $pack) {
         if (!is_dir($packagesDir . $pack['macro'])) {
             $filesystem->mkdirs($packagesDir . $pack['macro']);
         }
         $file = $packagesDir . $pack['macro'] . DIRECTORY_SEPARATOR . $pack['name'] . '.xpdl';
         $filesystem->touch($file);
         file_put_contents($file, $pack['xpdl']);
     }
 }
示例#3
0
 public function createDataFolder()
 {
     $fileSystem = new sfFilesystem();
     $oldumask = umask(0);
     $fileSystem->mkdirs($this->getExpositionDataPath(), 0777);
     $fileSystem->chmod($this->getExpositionDataPath(), 0777);
     umask($oldumask);
 }
 /**
  * Installs web content for a plugin.
  *
  * @param string $plugin The plugin name
  * @param string $dir    The plugin directory
  */
 protected function installPluginAssets($plugin, $dir)
 {
     $webDir = $dir . DIRECTORY_SEPARATOR . 'web';
     if (is_dir($webDir)) {
         $filesystem = new sfFilesystem();
         $filesystem->relativeSymlink($webDir, sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin, true);
     }
 }
示例#5
0
文件: cleanup.php 项目: sympal/sympal
function refresh_assets()
{
    $uploadDir = dirname(__FILE__) . '/../fixtures/project/web/uploads';
    sfToolkit::clearDirectory($uploadDir);
    $finder = new sfFinder();
    $filesystem = new sfFilesystem();
    $filesystem->mirror(dirname(__FILE__) . '/../fixtures/assets', $uploadDir, $finder);
}
 /**
  * Clear dynamics folder cache.
  */
 static function listenToClearCache(sfEvent $event)
 {
     $dymanics_cache_path = sfConfig::get('sf_web_dir') . '/dynamics';
     if (file_exists($dymanics_cache_path)) {
         $filesystem = new sfFilesystem(new sfEventDispatcher(), new sfFormatter());
         $filesystem->remove(sfFinder::type('file')->discard('.sf')->in($dymanics_cache_path));
     }
 }
 protected function installPluginAssets($name, $path)
 {
     $webDir = $path . '/web';
     if (is_dir($webDir)) {
         $filesystem = new sfFilesystem();
         $filesystem->relativeSymlink($webDir, sfConfig::get('sf_web_dir') . '/' . $name, true);
     }
 }
示例#8
0
 public function delete(Doctrine_Connection $conn = null)
 {
     parent::delete($conn);
     $path = $this->getChartPath('system');
     if (file_exists($path)) {
         $fs = new sfFilesystem(new sfEventDispatcher());
         $fs->remove($path);
     }
 }
 public function save()
 {
     Doctrine::getTable('SnsConfig')->set('customizing_css', $this->getValue('css'));
     $filesystem = new sfFilesystem();
     $cssPath = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'customizing.css';
     if (is_file($cssPath)) {
         @$filesystem->remove($cssPath);
     }
 }
 public static function execute($arguments = array(), $options = array())
 {
     $app = $arguments['application'];
     $module = $arguments['module'];
     $action = $arguments['action'];
     $process = $arguments['process'];
     $activity = $arguments['activity'];
     $scripts = $arguments['scripts'];
     // Fuerzo el cero (0) si no contiene valor
     if (!$activity['is_autocomplete']) {
         $activity['is_autocomplete'] = '0';
     }
     $actionDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module . '/actions';
     $templateDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module . '/templates';
     $actionFile = $action . 'Action.class.php';
     $templateFile = $action . 'Success.php';
     $errorFile = $action . 'Error.php';
     $filesystem = new sfFilesystem();
     if (!is_dir($actionDir)) {
         throw new sfCommandException(sprintf("No se pudo identificar el modulo symfony '%s' implementacion del paquete '%s'", $actionDir, $module));
     }
     if (is_file($actionDir . '/' . $actionFile)) {
         // Borro el archivo porque lo voy a recrear
         $filesystem->remove($actionDir . '/' . $actionFile);
         //throw new sfCommandException(sprintf('The action "%s" already exists.', $actionFile));
     }
     if (is_file($templateDir . '/' . $templateFile)) {
         // Borro el archivo porque lo voy a recrear
         $filesystem->remove($templateDir . '/' . $templateFile);
         //throw new sfCommandException(sprintf('The template "%s" already exists.', $templateFile));
     }
     // Activity Type determine skeleton
     if ($activity['type'] == 'StartEvent') {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/startAction.class.php';
     } elseif ($activity['type'] == 'EndEvent') {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/endAction.class.php';
     } elseif ($activity['type'] == 'TaskUser' or $activity['type'] == 'TaskManual') {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserAction.class.php';
         $skeletonTemplate = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserSuccess.php';
         $skeletonError = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserError.php';
     } else {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityAction.class.php';
     }
     // create basic action
     $filesystem->copy($skeletonAction, $actionDir . '/' . $actionFile);
     // customize action
     $constants = array('ACTIVITY' => $action, 'ACTIVITY_NAME' => $activity['name'], 'MODULE' => $module, 'PROCESS_ID' => $process['id'], 'PROCESS_NAME' => $process['name'], 'SET_DATAFIELDS' => $scripts['set_datafields'], 'PTN_NAME' => $scripts['ptn_name'], 'PTN_SET_PARAMS' => $scripts['ptn_set_params'], 'PTN_URL_TEMPLATE' => file_exists($scripts['ptn_url_template']) ? file_get_contents($scripts['ptn_url_template']) : '', 'RULES_NEXT' => $scripts['rules_next'], 'ACTIVITY_AUTOCOMPLETE' => $activity['is_autocomplete']);
     $finder = sfFinder::type('file')->name($actionFile);
     $filesystem->replaceTokens($finder->in($actionDir), '##', '##', $constants);
     // Personalize template Success y Error
     if ($activity['type'] == 'TaskUser' or $activity['type'] == 'TaskManual') {
         $filesystem->copy($skeletonTemplate, $templateDir . '/' . $templateFile);
         $finder = sfFinder::type('file')->name($templateFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
         $filesystem->copy($skeletonError, $templateDir . '/' . $errorFile);
         $finder = sfFinder::type('file')->name($errorFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
     }
 }
 /**
  *
  */
 protected function replaceTokens($file)
 {
     $properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
     $constants = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'PACKAGE_NAME' => !is_null($this->package) ? $this->package : 'package name');
     if (!is_readable($file)) {
         throw new sfCommandException("Failed to replace tokens as file is not accessible.");
     }
     // customize service file
     $sfFilesystem = new sfFilesystem();
     $sfFilesystem->replaceTokens($file, '##', '##', $constants);
 }
示例#12
0
 public function delete(Doctrine_Connection $conn = null)
 {
     $guid = $this->getGuid();
     parent::delete($conn);
     $delete_log = new DeleteLog();
     $delete_log->setGuid($guid);
     $delete_log->setModelName(get_class($this));
     $delete_log->save();
     $fileSystem = new sfFilesystem();
     @$fileSystem->remove($this->getInteractifDataPath());
 }
 private function copyWebAssets($plugin, $dir)
 {
     $webDir = $dir . DIRECTORY_SEPARATOR . 'web';
     $filesystem = new sfFilesystem();
     if (is_dir($webDir)) {
         $finder = sfFinder::type('any');
         $this->dirctoryRecusiveDelete(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin);
         $filesystem->mirror($webDir, sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin, $finder);
     }
     return;
 }
 public function execute($request)
 {
     $css = Doctrine::getTable('SnsConfig')->get('customizing_css');
     $this->getResponse()->setContent($css);
     $this->getResponse()->setContentType('text/css');
     // cache
     $filesystem = new sfFilesystem();
     $dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css';
     @$filesystem->mkdirs($dir);
     file_put_contents($dir . DIRECTORY_SEPARATOR . 'customizing.css', $css);
     return sfView::NONE;
 }
示例#15
0
 public function uninstallModelFiles($plugin)
 {
     $filesystem = new sfFilesystem();
     $baseDir = sfConfig::get('sf_lib_dir');
     $subpackages = array('model', 'form', 'filter');
     foreach ($subpackages as $subpackage) {
         $targetDir = $baseDir . DIRECTORY_SEPARATOR . $subpackage . DIRECTORY_SEPARATOR . 'doctrine' . DIRECTORY_SEPARATOR . $plugin;
         if (is_dir($targetDir)) {
             $filesystem->remove(sfFinder::type('any')->in($targetDir));
             $filesystem->remove($targetDir);
         }
     }
 }
 /**
  * Unnstalls web content for a plugin.
  *
  * @param string $plugin The plugin name
  */
 public function uninstallWebContent($plugin)
 {
     $targetDir = $this->environment->getOption('web_dir') . DIRECTORY_SEPARATOR . $plugin;
     if (is_dir($targetDir)) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Uninstalling web data for plugin')));
         $filesystem = new sfFilesystem();
         if (is_link($targetDir)) {
             $filesystem->remove($targetDir);
         } else {
             $filesystem->remove(sfFinder::type('any')->in($targetDir));
             $filesystem->remove($targetDir);
         }
     }
 }
 public static function cacheCss($event, $content)
 {
     $lastEntry = sfContext::getInstance()->getActionStack()->getLastEntry();
     if (!$lastEntry) {
         return $content;
     }
     if ('opSkinClassicPlugin' === $lastEntry->getModuleName() && 'css' === $lastEntry->getActionName()) {
         $filesystem = new sfFilesystem();
         $dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css';
         @$filesystem->mkdirs($dir);
         file_put_contents($dir . DIRECTORY_SEPARATOR . opSkinClassicConfig::getCurrentTheme() . '.css', $content);
     }
     return $content;
 }
 public function createDataFolder($dir = "")
 {
     $fileSystem = new sfFilesystem();
     $oldumask = umask(0);
     $fileSystem->mkdirs($this->getGroupeVisiteurDataPath(), 0755);
     $fileSystem->chmod($this->getGroupeVisiteurDataPath(), 0755);
     umask($oldumask);
     if ($dir != '') {
         $oldumask = umask(0);
         $fileSystem->mkdirs($this->getGroupeVisiteurDataPath() . '/' . $dir, 0755);
         $fileSystem->chmod($this->getGroupeVisiteurDataPath() . '/' . $dir, 0755);
         umask($oldumask);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     if (!extension_loaded('openssl')) {
         throw Exception('this task requires the openssl php extension, see http://www.php.net/openssl');
     }
     $days = null;
     while (!is_numeric($days)) {
         $days = $this->ask('The Days of Validity (default:365)');
         if (!$days) {
             $days = 365;
         }
     }
     while (!($phrase = $this->ask('Private Key Phrase'))) {
     }
     $country = null;
     while (!($country = strtoupper($this->ask('Country Name (2 letter code)'))) || strlen($country) != 2) {
         $this->logBlock('invalid format.', 'ERROR');
     }
     while (!($state = $this->ask('State or Province Name (full name)'))) {
     }
     while (!($locality = $this->ask('Locality Name (eg,city)'))) {
     }
     while (!($org = $this->ask('Organization Name(eg,company)'))) {
     }
     while (!($orgUnit = $this->ask('Organization Unit Name(eg,section)'))) {
     }
     while (!($common = $this->ask('Common Name(eg,Your name)'))) {
     }
     while (!($email = $this->ask('Email Address'))) {
     }
     $dn = array('countryName' => $country, 'stateOrProvinceName' => $state, 'localityName' => $locality, 'organizationName' => $org, 'organizationalUnitName' => $orgUnit, 'commonName' => $common, 'emailAddress' => $email);
     $dirname = sfConfig::get('sf_plugins_dir') . '/opOpenSocialPlugin/certs';
     $filesystem = new sfFilesystem($this->dispatcher, $this->formatter);
     $filesystem->mkdirs($dirname);
     $privatekey = openssl_pkey_new();
     $csr = openssl_csr_new($dn, $privatekey);
     $sscert = openssl_csr_sign($csr, null, $privatekey, $days);
     openssl_x509_export($sscert, $certout);
     openssl_pkey_export($privatekey, $pkeyout, $phrase);
     $cert_filename = $dirname . '/public.crt';
     file_put_contents($cert_filename, $certout);
     $this->logSection('file+', $cert_filename);
     $pkey_filename = $dirname . '/private.key';
     file_put_contents($pkey_filename, $pkeyout);
     $this->logSection('file+', $pkey_filename);
     $databaseManager = new sfDatabaseManager($this->configuration);
     Doctrine::getTable('SnsConfig')->set('shindig_private_key_phrase', $phrase);
 }
 public function execute($request)
 {
     $css = Doctrine::getTable('SnsConfig')->get('customizing_css', '');
     $this->getResponse()->setContent($css);
     $this->getResponse()->setContentType('text/css');
     // cache
     $filesystem = new sfFilesystem();
     $dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'css';
     @$filesystem->mkdirs($dir);
     $filesystem->chmod($dir, 0777);
     $cssPath = $dir . DIRECTORY_SEPARATOR . 'customizing.css';
     file_put_contents($cssPath, $css);
     $filesystem->chmod($cssPath, 0666);
     $this->getResponse()->setHttpHeader('Last-Modified', sfWebResponse::getDate(time()));
     return sfView::NONE;
 }
示例#21
0
 protected function advpng($from, $to)
 {
     // advpng does not have any output parameters, copy the file and then compress the copy
     $command = sprintf('advpng --recompress --quiet "%s"', $to);
     $this->fs->copy($from, $to, true);
     return $command;
 }
 public static function execute($arguments = array(), $options = array())
 {
     $app = $arguments['application'];
     $module = $arguments['module'];
     $process_id = $arguments['process_id'];
     $process_name = $arguments['process_name'];
     $process_display_name = $arguments['process_display_name'];
     $moduleDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module;
     $file_pack_xpdl = $moduleDir . '/data/package.xpdl';
     $file_proc_xpdl = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProcess/process.part.xpdl';
     $file_pool_xpdl = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProcess/pool.part.xpdl';
     if (!is_file($file_pack_xpdl) || !is_file($file_proc_xpdl) || !is_file($file_pool_xpdl)) {
         throw new sfCommandException(sprintf('No se pudo identificar un paquete, parte de proceso o pool'));
     }
     $contentPack = file_get_contents($file_pack_xpdl);
     $contentProc = file_get_contents($file_proc_xpdl);
     $contentPool = file_get_contents($file_pool_xpdl);
     $pos = strpos($contentPack, '<xpdl2:WorkflowProcess Id="' . $process_id . '"');
     if ($pos > 0) {
         throw new sfCommandException(sprintf('El proceso ' . $process_name . ' ya existe en el xpdl'));
     }
     // Pool
     // Defino etiqueta Pools si es el primero
     $pos = strpos($contentPack, '<xpdl2:Pools>');
     if ($pos <= 0) {
         $contentPool = '<xpdl2:Pools>' . $contentPool . '</xpdl2:Pools>';
     }
     // Inserto despues de la etiqueta de header redefinibles del paquete
     $key = '</xpdl2:RedefinableHeader>';
     $contentPack = str_replace($key, $key . $contentPool, $contentPack);
     file_put_contents($file_pack_xpdl, $contentPack);
     // Proceso
     // Defino etiqueta WorkflowProcesses si es el primero
     $pos = strpos($contentPack, '<xpdl2:WorkflowProcesses>');
     if ($pos <= 0) {
         $contentProc = '<xpdl2:WorkflowProcesses>' . $contentProc . '</xpdl2:WorkflowProcesses>';
     }
     // Inserto antes de la etiqueta de atributos extendidos del paquete
     $key = '<xpdl2:ExtendedAttributes>';
     $contentPack = str_replace($key, $contentProc . $key, $contentPack);
     file_put_contents($file_pack_xpdl, $contentPack);
     // customize xpdl
     $constants = array('PROCESS_ID' => $process_id, 'PROCESS_DISPLAY_NAME' => $process_name, 'PROCESS_NAME' => str_replace(' ', '', $process_name), 'POOL_ID' => UtilXpdl::genRandId(), 'POOL_DISPLAY_NAME' => 'Pool', 'POOL_NAME' => 'Pool', 'LANE_ID' => UtilXpdl::genRandId(), 'LANE_DISPLAY_NAME' => 'Lane', 'LANE_NAME' => 'Lane');
     $filesystem = new sfFilesystem();
     $finder = sfFinder::type('file')->name('*.xpdl');
     $filesystem->replaceTokens($finder->in($moduleDir), '##', '##', $constants);
 }
 /**
  * Intializes a new migration.
  *
  * @throws RuntimeException
  *
  * @param string $name The human readable name for this migration.
  *
  * @return string The filename for the new migration.
  */
 public function initializeMigration($name)
 {
     $version = microtime(true) * 10000;
     $migration = new sfPropelMigration($version, $name);
     $skeleton = sfPropelMigrationSkeleton::getSkeleton($version);
     if (!is_dir($migration->getDirname())) {
         $fs = new sfFilesystem();
         $fs->mkdirs($migration->getDirname());
     }
     if (is_writable($migration->getDirname())) {
         if (file_put_contents($migration->getFullFilename(), $skeleton) === false) {
             throw new RuntimeException(self::EXCEPTION_MIGRATION_NOT_WRITTEN);
         }
     } else {
         throw new RuntimeException(self::EXCEPTION_MIGRATION_DIR_NOT_WRITABLE);
     }
     return $migration->getFilename();
 }
 protected function _cleanupAdminGenModules()
 {
     $fs = new sfFilesystem($this->getContext()->getEventDispatcher(), new sfFormatter());
     foreach ($this->_modules as $module) {
         $this->info('Removing admin gen module "' . $module . '"');
         $fs->sh('rm -rf ' . sfConfig::get('sf_app_module_dir') . '/' . $module);
     }
     $fs->sh('rm -rf ' . sfConfig::get('sf_test_dir') . '/functional/backend');
     $fs->sh('rm -rf ' . sfConfig::get('sf_data_dir') . '/*.sqlite');
 }
示例#25
0
 public function _doUpgrade()
 {
     $this->logSection('sympal', 'Moving model/form/filter files from lib/*/doctrine/sfSympalPlugin to lib/*/doctrine/sfSympalCMFPlugin');
     $finder = sfFinder::type('file');
     $filesystem = new sfFilesystem($this->_dispatcher, $this->_formatter);
     foreach ($this->_dirs as $origin => $destination) {
         $this->logSection('sympal', sprintf('Mirroring %s to %s', $origin, $destination));
         $filesystem->mirror(sfConfig::get('sf_root_dir') . '/' . $origin, sfConfig::get('sf_root_dir') . '/' . $destination, $finder);
         $this->logSection('sympal', sprintf('Deleting %s', $origin));
         // remove the files first
         foreach ($finder->in(sfConfig::get('sf_root_dir') . '/' . $origin) as $file) {
             $filesystem->remove(sfConfig::get('sf_root_dir') . '/' . $origin . '/' . $file);
         }
         // remove the dirs
         $dirs = array(sfConfig::get('sf_root_dir') . '/' . $origin . '/base', sfConfig::get('sf_root_dir') . '/' . $origin);
         foreach ($dirs as $dir) {
             if (file_exists($dir)) {
                 $filesystem->remove($dir);
             }
         }
     }
 }
示例#26
0
 public function symlinkDocument($interactif_id, $visiteur_id, $filename, $target)
 {
     $interactifs_dir = sfConfig::get('sf_root_dir') . '/web/interactif';
     $fileSystem = new sfFilesystem();
     if (!file_exists($interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id . '/' . $filename)) {
         if (!is_dir($interactifs_dir . '/' . $interactif_id)) {
             $oldumask = umask(0);
             $fileSystem->mkdirs($interactifs_dir . '/' . $interactif_id, 0755);
             $fileSystem->chmod($interactifs_dir . '/' . $interactif_id, 0755);
             umask($oldumask);
         }
         if (!is_dir($interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id)) {
             $oldumask = umask(0);
             $fileSystem->mkdirs($interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id, 0755);
             $fileSystem->chmod($interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id, 0755);
             umask($oldumask);
         }
         symlink($target, $interactifs_dir . '/' . $interactif_id . '/' . $visiteur_id . '/' . $filename);
         return true;
         //exit;
     }
     return false;
 }
 /**
  * Validates the response.
  *
  * @param mixed $checkDTD Either true to validate against the response DTD or
  *                        provide the path to a *.xsd, *.rng or *.rnc schema
  *
  * @return sfTestFunctionalBase|sfTester
  *
  * @throws LogicException If the response is neither XML nor (X)HTML
  */
 public function isValid($checkDTD = false)
 {
     if (preg_match('/(x|ht)ml/i', $this->response->getContentType())) {
         $revert = libxml_use_internal_errors(true);
         $dom = new DOMDocument('1.0', $this->response->getCharset());
         $content = $this->response->getContent();
         if (true === $checkDTD) {
             $cache = sfConfig::get('sf_cache_dir') . '/sf_tester_response/w3';
             if ($cache[1] == ':') {
                 // On Windows systems the path will be like c:\symfony\cache\xml.dtd
                 // I did not manage to get DOMDocument loading a file protocol url including the drive letter
                 // file://c:\symfony\cache\xml.dtd or file://c:/symfony/cache/xml.dtd
                 // The first one simply doesnt work, the second one is treated as remote call.
                 // However the following works. Unfortunatly this means we can only access the current disk
                 // file:///symfony/cache/xml.dtd
                 // Note that all work for file_get_contents so the bug is most likely in DOMDocument.
                 $local = 'file://' . substr(str_replace(DIRECTORY_SEPARATOR, '/', $cache), 2);
             } else {
                 $local = 'file://' . $cache;
             }
             if (!file_exists($cache . '/TR/xhtml11/DTD/xhtml11.dtd')) {
                 $filesystem = new sfFilesystem();
                 $finder = sfFinder::type('any')->discard('.sf');
                 $filesystem->mirror(dirname(__FILE__) . '/w3', $cache, $finder);
                 $finder = sfFinder::type('file');
                 $filesystem->replaceTokens($finder->in($cache), '##', '##', array('LOCAL_W3' => $local));
             }
             $content = preg_replace('#(<!DOCTYPE[^>]+")http://www.w3.org(.*")#i', '\\1' . $local . '\\2', $content);
             $dom->validateOnParse = $checkDTD;
         }
         $dom->loadXML($content);
         switch (pathinfo($checkDTD, PATHINFO_EXTENSION)) {
             case 'xsd':
                 $dom->schemaValidate($checkDTD);
                 $message = sprintf('response validates per XSD schema "%s"', basename($checkDTD));
                 break;
             case 'rng':
             case 'rnc':
                 $dom->relaxNGValidate($checkDTD);
                 $message = sprintf('response validates per relaxNG schema "%s"', basename($checkDTD));
                 break;
             default:
                 $message = $dom->validateOnParse ? sprintf('response validates as "%s"', $dom->doctype->name) : 'response is well-formed "xml"';
         }
         if (count($errors = libxml_get_errors())) {
             foreach ($errors as $error) {
                 $message .= sprintf("\n * (line:%d) %s", $error->line, $error->message);
             }
             $this->tester->fail($message);
         } else {
             $this->tester->pass($message);
         }
         libxml_use_internal_errors($revert);
     } else {
         throw new LogicException(sprintf('Unable to validate responses of content type "%s"', $this->response->getContentType()));
     }
     return $this->getObjectToReturn();
 }
 public static function clearFileCache($filename)
 {
     $sizes = array_merge(self::getAllowedSize(), array('raw'));
     $formats = self::getAllowedFormat();
     $filesystem = new sfFilesystem();
     foreach ($sizes as $size) {
         if ('raw' !== $size) {
             $s = explode('x', $size);
             $width = $s[0];
             $height = $s[1];
         } else {
             $width = $height = '';
         }
         foreach ($formats as $format) {
             $path = self::getPathToFileCache($format, $width, $height, $filename);
             if (is_file($path)) {
                 @$filesystem->remove($path);
             }
         }
     }
 }
示例#29
0
 public function calculateRelativeDir($from, $to)
 {
     return parent::calculateRelativeDir($from, $to);
 }
示例#30
0
 * @package    symfony
 * @author     Fabien Potencier <*****@*****.**>
 * @version    SVN: $Id$
 */
require_once dirname(__FILE__) . '/../../lib/exception/sfException.class.php';
require_once dirname(__FILE__) . '/../../lib/task/sfFilesystem.class.php';
require_once dirname(__FILE__) . '/../../lib/util/sfFinder.class.php';
require_once dirname(__FILE__) . '/../../lib/vendor/lime/lime.php';
if (!isset($argv[1])) {
    throw new Exception('You must provide version prefix.');
}
if (!isset($argv[2])) {
    throw new Exception('You must provide stability status (alpha/beta/stable).');
}
$stability = $argv[2];
$filesystem = new sfFilesystem();
if (($stability == 'beta' || $stability == 'alpha') && count(explode('.', $argv[1])) < 2) {
    $version_prefix = $argv[1];
    $result = $filesystem->sh('svn status -u ' . getcwd());
    if (preg_match('/Status against revision\\:\\s+(\\d+)\\s*$/im', $result, $match)) {
        $version = $match[1];
    }
    if (!isset($version)) {
        throw new Exception('Unable to find last SVN revision.');
    }
    // make a PEAR compatible version
    $version = $version_prefix . '.' . $version;
} else {
    $version = $argv[1];
}
print sprintf("Releasing symfony version \"%s\".\n", $version);