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);
     }
 }
Beispiel #2
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;
 }
Beispiel #3
0
    }
    // make a PEAR compatible version
    $version = $version_prefix . '.' . $version;
} else {
    $version = $argv[1];
}
print sprintf("Releasing symfony version \"%s\".\n", $version);
// tests
$result = $filesystem->sh('php data/bin/symfony symfony:test');
if (0 != $result) {
    throw new Exception('Some tests failed. Release process aborted!');
}
if (is_file('package.xml')) {
    $filesystem->remove(getcwd() . DIRECTORY_SEPARATOR . 'package.xml');
}
$filesystem->copy(getcwd() . '/package.xml.tmpl', getcwd() . '/package.xml');
// add class files
$finder = sfFinder::type('file')->relative();
$xml_classes = '';
$dirs = array('lib' => 'php', 'data' => 'data');
foreach ($dirs as $dir => $role) {
    $class_files = $finder->in($dir);
    foreach ($class_files as $file) {
        $xml_classes .= '<file role="' . $role . '" baseinstalldir="symfony" install-as="' . $file . '" name="' . $dir . '/' . $file . '" />' . "\n";
    }
}
// replace tokens
$filesystem->replaceTokens(getcwd() . DIRECTORY_SEPARATOR . 'package.xml', '##', '##', array('SYMFONY_VERSION' => $version, 'CURRENT_DATE' => date('Y-m-d'), 'CLASS_FILES' => $xml_classes, 'STABILITY' => $stability));
$results = $filesystem->sh('pear package');
echo $results;
$filesystem->remove(getcwd() . DIRECTORY_SEPARATOR . 'package.xml');
 /**
  * Performs a demo of this plugin functionnalities.
  *
  * @author  Jérôme Pierre <*****@*****.**>
  * @version V1 - August 4th 2010
  *
  * @param sfWebRequest $request The current web request.
  *
  * @return sfView The appropriate view.
  *
  * @todo Find a better way to list the available methods.
  */
 public function executeIndex(sfWebRequest $request)
 {
     // Defines the available methods.
     $this->_methods = array('getFileName', 'getFileDateTime', 'getFileSize', 'getFileType', 'getMimeType', 'getSectionsFound', 'getCOMPUTED', 'getImageDescription', 'getOrientation', 'getYCbCrPositioning', 'getXResolution', 'getYResolution', 'getResolutionUnit', 'getDateTime', 'getDateTimeOriginal', 'getDateTimeDigitized', 'getMake', 'getModel', 'getSoftware', 'getExif_IFD_Pointer', 'getExifVersion', 'getFlashPixVersion', 'getColorSpace', 'getFNumber', 'getExposureTime', 'getExposureProgram', 'getISOSpeedRatings', 'getComponentsConfiguration', 'getShutterSpeedValue', 'getApertureValue', 'getExposureBiasValue', 'getMeteringMode', 'getFlash', 'getFlashPixVersion', 'getFocalLength', 'getUserComment', 'getExifImageWidth', 'getExifImageLength', 'getFocalPlaneXResolution', 'getFocalPlaneYResolution', 'getFocalPlaneResolutionUnit', 'getCustomRendered', 'getExposureMode', 'getWhiteBalance', 'getSceneCaptureType');
     //
     // Defines the upload directory and the default file path.
     $upload_directory = sfConfig::get('sf_upload_dir') . '/s6yExifDataManagerPlugin';
     $default_file_path = "{$upload_directory}/jpierre.jpg";
     //
     // Manage the default demo image.
     if (!is_file($default_file_path)) {
         $file_system = new sfFilesystem();
         $file_system->copy(sfConfig::get('sf_plugins_dir') . '/s6yExifDataManagerPlugin/web/images/jpierre.jpg', $default_file_path, array('override' => true));
     }
     //
     // Manage the upload of other demo images.
     $this->_form = new s6yExifDataManagerForm();
     if ($request->isMethod('POST')) {
         $this->_form->bind($request->getPostParameter($this->_form->getName()), $request->getFiles($this->_form->getName()));
         if ($this->_form->isValid()) {
             $validated_file = $this->_form->getValue('_file_path');
             $validated_file->save("{$upload_directory}/{$validated_file->getOriginalName()}");
             $this->getUser()->setAttribute('_file_path', $validated_file->getSavedName());
         }
     }
     //
     // Defines the current file path.
     $this->_file_path = $this->getUser()->getAttribute('_file_path', $default_file_path);
     //
     // Defines the current exif data.
     $exif_data_manager = s6yExifDataManager::getInstance()->supplyImage($this->_file_path);
     $this->_exif_data = array();
     $methods = array_unique($this->_methods + array_keys($exif_data_manager->getExifData()));
     foreach ($methods as $method) {
         try {
             $this->_exif_data[$method] = $exif_data_manager->{$method}();
         } catch (sfException $e) {
             $this->_exif_data[$method] = $e;
         }
     }
     //
     // Define the size of the demo image.
     $max = 300;
     try {
         $width = $exif_data_manager->getExifImageWidth();
         $height = $exif_data_manager->getExifImageLength();
     } catch (sfException $e) {
         try {
             $computed = $exif_data_manager->getCOMPUTED();
             $width = $computed['Width'];
             $height = $computed['Height'];
         } catch (sfException $e) {
             $width = $max;
             $height = $max;
         }
     }
     if ($width > $max || $height > $max) {
         if ($width > $height) {
             $height = $height * $max / $width;
             $width = $max;
         } else {
             $width = $width * $max / $height;
             $height = $max;
         }
     }
     $this->_image_width = $width;
     $this->_image_height = $height;
     //
 }
Beispiel #5
0
 public static function writeCacheFile($pathToCacheFile, $content)
 {
     $filesystem = new sfFilesystem();
     $currentUmask = umask();
     umask(00);
     $tmpFile = tempnam(dirname($pathToCacheFile), basename($pathToCacheFile));
     if (!($fp = @fopen($tmpFile, 'wb'))) {
         throw new sfCacheException('Failed to write cache file.');
     }
     @fwrite($fp, $content);
     @fclose($fp);
     if (!@rename($tmpFile, $pathToCacheFile)) {
         if ($filesystem->copy($tmpFile, $pathToCacheFile, array('override' => true))) {
             $filesystem->remove($tmpFile);
         }
     }
     $filesystem->chmod($pathToCacheFile, 0666);
     umask($currentUmask);
 }
 /**
  * Copies a file.
  * By default, if the target already exists, it is not overriden.
  * To override existing files, pass the "override" option.
  * To create uniq file name, pass the "dynamic_name" option.
  * To process images files, you may pass "image" and "thumbs" options like arrays.
  * Image option format:
  * <ul>
  *   <li>int "width" - width</li>
  *   <li>int "height" - height</li>
  *   <li>string "type" - resize mode (width, height, auto, zoom, crop)</li>
  *   <li>string "crop" - crop type (left-top, left-bottom, right-top, right-bottom, center, specific array('x' => int, 'y' => int))</li>
  * </ul>
  * If you passed the "crop" image option then after resizing image will be croped using some of specific methods, otherwise it will be only resized
  *
  * @param string $originFile  The original filename
  * @param string $targetFile  The target filename
  * @param array  $options     An array of options
  * @return bool               if file copied
  */
 public function copy($originFile, $targetFile, $options = array())
 {
     $targetFile = $this->prepareFilename($targetFile);
     $dynamic_name = isset($options['dynamic_name']) && $options['dynamic_name'];
     $options['override'] = isset($options['override']) && $options['override'];
     if ($dynamic_name) {
         $targetFile = $this->dynamicFileName($targetFile);
     }
     $image = false;
     if (isset($options['thumbs']) || isset($options['images'])) {
         $image = $this->createImage($originFile, $options['override']);
     }
     if ($image) {
         $files = $this->saveImage($image, $targetFile, $options);
     } else {
         parent::copy($originFile, $targetFile, $options);
         $files = array($targetFile);
     }
     return file_exists($targetFile) ? $files : false;
 }
 public function execute($arguments = array(), $options = array())
 {
     $this->logSection('psdf:generate-activity', sprintf("Generando actividad '%s'...", $arguments['activity']));
     $this->logSection('psdf:generate-activity', sprintf("Nombre: '%s' Id: '%s' Type: '%s'", $arguments['activity'], $this->psdf_activity_data['id'], $this->psdf_activity_data['type']));
     //$this->log( 'Datos de la actividad:' );
     //$this->log( sfYaml::dump($this->psdf_activity_data) );
     // --------------------------------
     // Creo la accion y template correspondiente
     // --------------------------------
     // Nombres de actividad parseado a implementar
     $action = str_replace(' ', '_', $arguments['activity']);
     $actionDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'] . '/modules/' . $arguments['package'] . '/actions';
     $templateDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'] . '/modules/' . $arguments['package'] . '/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 existe el directorio '%s' del modulo '%s' sobre el cual implementar la accion '%s'", $actionDir, $arguments['package'], $action));
     }
     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
     $skeletonAction = dirname(__FILE__) . sprintf('/skeleton/activity/action/%sAction.class.php', $this->psdf_activity_data['type']);
     $skeletonTemplate = dirname(__FILE__) . sprintf('/skeleton/activity/template/%sSuccess.php', $this->psdf_activity_data['type']);
     $skeletonError = dirname(__FILE__) . sprintf('/skeleton/activity/template/%sError.php', $this->psdf_activity_data['type']);
     if (!is_file($skeletonAction)) {
         throw new sfCommandException(sprintf("No hay definido un esqueleto para crear la actividad del tipo '%s'", $this->psdf_activity_data['type']));
     }
     // --------------------------------
     // Personalizacion comun a todas las actividades
     // --------------------------------
     $scripts['set_datafields'] = $this->genScriptSetDatafield();
     $scripts['rules_next'] = $this->genScriptNextActivity();
     $scripts['pattern'] = $this->genScriptsPattern();
     // customize action
     $constants = array('ACTION' => $action, 'MODULE' => $arguments['package'], 'PROCESS_ID' => $arguments['process_id'], 'RULES_NEXT' => $scripts['rules_next'], 'SET_DATAFIELDS' => $scripts['set_datafields'], 'PTN_NAME' => $scripts['pattern']['name'], 'PTN_SET_PARAMS' => $scripts['pattern']['set_parameter'], 'PTN_SET_TEMPLATE' => $scripts['pattern']['set_template'], 'PTN_SET_DATAFIELDS' => $scripts['pattern']['set_datafield'], 'PROCESS_NAME' => $arguments['process'], 'ACTIVITY_NAME' => $arguments['activity']);
     // create basic action
     $filesystem->copy($skeletonAction, $actionDir . '/' . $actionFile);
     $finder = sfFinder::type('file')->name($actionFile);
     $filesystem->replaceTokens($finder->in($actionDir), '##', '##', $constants);
     if (is_file($skeletonTemplate)) {
         $filesystem->copy($skeletonTemplate, $templateDir . '/' . $templateFile);
         $finder = sfFinder::type('file')->name($templateFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
     }
     if (is_file($skeletonError)) {
         $filesystem->copy($skeletonError, $templateDir . '/' . $errorFile);
         $finder = sfFinder::type('file')->name($errorFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
     }
     $this->logSection('psdf:generate-activity', sprintf("Fin generacion actividad", $arguments['activity']));
 }
<?php

/**
 * @author Julien Muetton
 * @see http://www.symfony-project.org/blog/2009/06/10/new-in-symfony-1-3-project-creation-customization
 */
$fs = new sfFilesystem();
$fs->mkdirs(sfConfig::get('sf_plugins_dir') . '/sfPropelORMPlugin');
$root_dir = realpath(sfConfig::get('sf_root_dir') . '/../');
$plugin_dir = realpath(sfConfig::get('sf_plugins_dir') . '/sfPropelORMPlugin');
$finder = sfFinder::type('any')->ignore_version_control(false)->discard('mockproject')->prune('mockproject');
$fs->mirror($root_dir, $plugin_dir, $finder);
$fs->execute(sprintf('cd %s && git submodule update --init --recursive', $plugin_dir));
include dirname(__FILE__) . '/../../config/installer.php';
$fs->mkdirs($task_dir = sfConfig::get('sf_lib_dir') . '/task');
$fs->copy(dirname(__FILE__) . '/PropelInstallTask.class.php', $task_dir . '/PropelInstallTask.class.php');
$this->runTask('cache:clear');