コード例 #1
0
ファイル: Visiteur.class.php プロジェクト: pmoutet/navinum
 public function createDataFolder($dir = "")
 {
     $fileSystem = new sfFilesystem();
     $oldumask = umask(0);
     $fileSystem->mkdirs($this->getVisiteurDataPath(), 0755);
     $fileSystem->chmod($this->getVisiteurDataPath(), 0755);
     umask($oldumask);
     if ($dir != '') {
         $oldumask = umask(0);
         $fileSystem->mkdirs($this->getVisiteurDataPath() . '/' . $dir, 0755);
         $fileSystem->chmod($this->getVisiteurDataPath() . '/' . $dir, 0755);
         umask($oldumask);
     }
 }
コード例 #2
0
 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");
 }
コード例 #3
0
 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']);
     }
 }
コード例 #4
0
ファイル: Interactif.class.php プロジェクト: pmoutet/navinum
 public function createDataFolder()
 {
     $fileSystem = new sfFilesystem();
     $oldumask = umask(0);
     $fileSystem->mkdirs($this->getInteractifDataPath(), 0755);
     $fileSystem->chmod($this->getInteractifDataPath(), 0755);
     umask($oldumask);
 }
コード例 #5
0
ファイル: Exposition.class.php プロジェクト: pmoutet/navinum
 public function createDataFolder()
 {
     $fileSystem = new sfFilesystem();
     $oldumask = umask(0);
     $fileSystem->mkdirs($this->getExpositionDataPath(), 0777);
     $fileSystem->chmod($this->getExpositionDataPath(), 0777);
     umask($oldumask);
 }
コード例 #6
0
 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;
 }
コード例 #7
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;
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 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;
 }
コード例 #11
0
 /**
  * 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();
 }
 public function cacheOutput($event, $content)
 {
     $cacheBaseDir = $this->rootDir . DIRECTORY_SEPARATOR . 'cache';
     $cacheRoutes = array('plugin_rest_release_deps', 'plugin_rest_package_info', 'plugin_rest_release_version');
     $lastEntry = sfContext::getInstance()->getActionStack()->getLastEntry();
     if (!$lastEntry) {
         return $content;
     }
     $lastRouting = $lastEntry->getActionInstance()->getContext()->getRouting();
     $lastRequest = $lastEntry->getActionInstance()->getRequest();
     $currentRouteName = $lastRouting->getCurrentRouteName();
     $filePath = $cacheBaseDir . $lastRequest->getPathInfo();
     // TODO: Add consider to Windows directory separator
     if (in_array($currentRouteName, $cacheRoutes)) {
         $filesystem = new sfFilesystem();
         $filesystem->mkdirs(dirname($filePath));
         file_put_contents($filePath, $content);
     }
     return $content;
 }
コード例 #13
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../../lib/test/otokouTestFunctional.class.php';
// creating temporary folder
$pdf_dir = sfConfig::get('sf_web_dir') . '/functional/pdf';
$fs = new sfFilesystem();
$fs->mkdirs($pdf_dir);
$browser = new otokouTestFunctional(new sfBrowser());
$browser->loadData();
$browser->setTester('doctrine', 'sfTesterDoctrine');
$browser->info('1 - Security')->info('1.1 - No access without login')->get('/ruf/reports')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(401)->end()->info('1.2 - Username is required in route')->login('user_gs', 'user')->get('/reports')->with('response')->begin()->isStatusCode(404)->end()->info('1.3 - A user can only access his resources')->get('/ruf/reports')->with('response')->begin()->isStatusCode(403)->end()->info('Correct request')->get('/user_gs/reports')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'index')->end()->logout()->info('2 - Index')->info('2.1 - A user only sees his reports')->login('ruf', 'admin@1')->get('/ruf/reports')->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 1)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('ul#reports_menu li a:contains("Create a new report")', true)->checkElement('h3.report_category_title', 1)->checkElement('div#category_vw-touran-1-4-tsi div.vehicle_reports_none', 1)->end()->logout()->login('user_gs', 'user')->get('/user_gs/reports')->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('h1:contains("Reports")', true)->checkElement('h3.report_category_title', 2)->checkElement('h3.report_category_title:contains("car_gs_1")', 1)->checkElement('div#category_car-gs-1 table.reports_list tbody tr', 2)->checkElement('div#category_car-gs-3 div.vehicle_reports_none', 1)->checkElement('table.reports_list', 1)->checkElement('table.reports_list tbody tr', 2)->checkElement('tfoot.more_reports', false)->end()->logout()->login('user_reports', 'user')->get('/user_reports/reports')->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 20)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('ul#reports_menu li a:contains("(Un)archive vehicles")', true)->checkElement('h1:contains("Reports")', true)->checkElement('h3.report_category_title', 4)->checkElement('h3.report_category_title:contains("car_reports_01")', true, array('position' => 1))->checkElement('h3.report_category_title:contains("car_reports_02")', true, array('position' => 2))->checkElement('h3.report_category_title:contains("car_reports_03")', true, array('position' => 3))->checkElement('h3.report_category_title:contains("car_reports_04")', true, array('position' => 4))->checkElement('table.reports_list', 1)->checkElement('div.vehicle_reports_none', 3)->checkElement('div#category_car-reports-02 div.vehicle_reports_none', true)->checkElement('div#category_car-reports-03 div.vehicle_reports_none', true)->checkElement('div#category_car-reports-04 div.vehicle_reports_none', true)->checkElement('div#category_car-reports-01 table.reports_list tbody tr', 3)->checkElement('table.reports_list', 1)->checkElement('table.reports_list tbody tr', 3)->checkElement('table.reports_list tbody tr.report_new', 2)->checkElement('table.reports_list tbody tr.report_old', 1)->checkElement('table.reports_list tbody tr.report_new', true, array('position' => 1))->checkElement('table.reports_list tbody tr.report_new', true, array('position' => 2))->checkElement('table.reports_list tbody tr.report_old', true, array('position' => 3))->checkElement('tfoot.more_reports', 1)->checkElement('div.pagination', true)->end()->logout()->info('3 - List of reports')->login('user_gs', 'user')->get('/user_gs/reports')->info('3.1 - Vehicles')->with('response')->click('car_gs_3')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'listVehicle')->end()->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('body:contains("No reports available")', true)->checkElement('table.reports_list', false)->end()->get('/user_gs/reports/vehicle/car-gs-1')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'listVehicle')->end()->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('body:contains("No reports available")', false)->checkElement('table.reports_list', true)->checkElement('table.reports_list tbody tr', 2)->checkElement('table.reports_list tbody tr.report_new', 1)->checkElement('table.reports_list tbody tr.report_old', 1)->end()->logout()->login('user_reports', 'user')->get('/user_reports/reports/vehicle/car-reports-01')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'listVehicle')->isParameter('username', 'user_reports')->isParameter('slug', 'car-reports-01')->end()->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 20)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('body:contains("No reports available")', false)->checkElement('table.reports_list', true)->checkElement('table.reports_list tbody tr', 20)->checkElement('table.reports_list tbody tr.report_new', 2)->checkElement('table.reports_list tbody tr.report_old', 18)->checkElement('table.reports_list tbody tr.report_new', true, array('position' => 1))->checkElement('table.reports_list tbody tr.report_new', true, array('position' => 2))->checkElement('table.reports_list tbody tr.report_old', true, array('position' => 3))->checkElement('div.sf_admin_pagination', true)->end()->info('3.2 - Custom reports')->logout()->login('user_gs', 'user')->get('/user_gs/reports/custom')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'listCustom')->end()->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('body:contains("No reports available")', false)->checkElement('table.reports_list', true)->checkElement('table.reports_list tbody tr', 20)->checkElement('table.reports_list tbody tr.report_new', 1)->checkElement('table.reports_list tbody tr.report_new td:contains("0-1000 km - Car gs 1 and Car gs 2")', true)->checkElement('table.reports_list tbody tr.report_new td:contains("report archived")', false)->checkElement('table.reports_list tbody tr.report_old', 19)->checkElement('div.sf_admin_pagination', true)->end()->info('4 - Creation of a new custom report')->info('4.1 - "New" form')->get('/user_gs/report/new')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'new')->end()->with('response')->begin()->isStatusCode(200)->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('h1:contains("Create a new report")', true)->checkElement('div.sf_admin_content form', true)->checkElement('div.sf_admin_content form div.sf_admin_form_row', 4)->end()->info('4.2 - Form errors - required fields')->click('Create', array())->with('form')->begin()->hasErrors(2)->isError('name', '/required/')->isError('vehicles_list', '/required/')->end()->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'create')->end()->info('4.3 - Form errors - ranges and vehicles list')->click('Create', array('report' => array('name' => 'Custom report', 'date_range' => array('from' => date('Y-m-d', time())), 'kilometers_range' => array('from' => 0), 'vehicles_list' => array($browser->getVehicleId('car2')))))->with('form')->begin()->hasErrors(2)->hasGlobalError('/Only one/')->isError('vehicles_list', '/invalid/')->end()->info('4.4 - No charges related to the defined range')->click('Create', array('report' => array('name' => 'Custom report', 'date_range' => array('from' => null, 'to' => null), 'kilometers_range' => array('from' => 4, 'to' => 5), 'vehicles_list' => array($browser->getVehicleId('car-gs-1')))))->with('form')->begin()->hasErrors(1)->hasGlobalError('/No charges/')->end()->info('4.5 - Form errors - user_id')->click('Create', array('report' => array('name' => 'Custom report', 'user_id' => $browser->getUserId('ruf'), 'date_range' => array('from' => null, 'to' => date('Y-m-d')), 'kilometers_range' => array('from' => 0, 'to' => null), 'vehicles_list' => array($browser->getVehicleId('car-gs-1')))))->with('form')->begin()->hasErrors(1)->hasGlobalError('/User/')->end()->info('4.6 - Form ok')->click('Create', array('report' => array('name' => 'Custom report', 'user_id' => $browser->getUserId('user_gs'), 'date_range' => array('from' => '', 'to' => date('Y-m-d')), 'kilometers_range' => array('from' => 220, 'to' => ''), 'vehicles_list' => array($browser->getVehicleId('car-gs-1')))))->with('form')->begin()->hasErrors(false)->end()->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'create')->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.name LIKE ?', 'Custom report')->andWhere('r.date_to = ?', date('Y-m-d'))->andWhere('kilometers_from = ?', 220)->leftJoin('r.Vehicles v')->andWhereIn('v.id', array($browser->getVehicleId('car-gs-1'))), 1)->end()->with('response')->begin()->isRedirected(true)->followRedirect()->end()->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->end()->info('4.7 - Default values for form')->get('/user_gs/report/new')->click('Create', array('report' => array('name' => 'Custom report', 'vehicles_list' => array($browser->getVehicleId('car-gs-1')))))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected(true)->followRedirect()->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.name LIKE ?', 'Custom report')->andWhere('r.date_to = ?', date('Y-m-d'))->andWhere('kilometers_from = ?', 0)->leftJoin('r.Vehicles v')->andWhereIn('v.id', array($browser->getVehicleId('car-gs-1'))), 1)->end()->info('5 - Delete')->info('5.1 - Vehicle report')->get('/user_gs/report/new')->click('Create', array('report' => array('name' => 'Custom report delete vehicle 1', 'date_range' => array('from' => '', 'to' => date('Y-m-d')), 'kilometers_range' => array('from' => 30, 'to' => ''), 'vehicles_list' => array($browser->getVehicleId('car-gs-1')))))->get('/user_gs/reports/vehicle/car-gs-1')->with('response')->begin()->checkElement('table.reports_list tbody tr', 5)->checkElement('table.reports_list tbody tr td:contains("Custom report delete vehicle 1")', true)->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.name LIKE ?', 'Custom report delete vehicle 1')->andWhere('r.date_to = ?', date('Y-m-d'))->andWhere('kilometers_from = ?', 30)->leftJoin('r.Vehicles v')->andWhereIn('v.id', array($browser->getVehicleId('car-gs-1'))), 1)->end()->call('/user_gs/report/delete/custom-report-delete-vehicle-1', 'delete', array('_with_csrf' => true))->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'delete')->end()->with('response')->begin()->isRedirected(true)->followRedirect()->end()->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'listVehicle')->end()->with('response')->begin()->checkElement('table.reports_list tbody tr', 4)->checkElement('table.reports_list tbody tr td:contains("Custom report delete vehicle 1")', false)->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.name LIKE ?', 'Custom report delete vehicle 1')->andWhere('r.date_from = ?', date('Y-m-d'))->andWhere('kilometers_to = ?', 10000)->leftJoin('r.Vehicles v')->andWhereIn('v.id', array($browser->getVehicleId('car-gs-1'))), false)->end()->info('5.2 - Custom report')->get('/user_gs/report/new')->click('Create', array('report' => array('name' => 'Custom report delete vehicle 2', 'date_range' => array('from' => '', 'to' => date('Y-m-d')), 'kilometers_range' => array('from' => 300, 'to' => ''), 'vehicles_list' => array($browser->getVehicleId('car-gs-1'), $browser->getVehicleId('car-gs-2')))))->get('/user_gs/reports/custom')->with('response')->begin()->checkElement('table.reports_list tbody tr', 20)->checkElement('table.reports_list tbody tr td:contains("Custom report delete vehicle 2")', true)->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.name LIKE ?', 'Custom report delete vehicle 2')->andWhere('r.date_to = ?', date('Y-m-d'))->andWhere('kilometers_from = ?', 300)->leftJoin('r.Vehicles v')->andWhereIn('v.id', array($browser->getVehicleId('car-gs-1'), $browser->getVehicleId('car-gs-2'))), 1)->end()->call('/user_gs/report/delete/custom-report-delete-vehicle-2', 'delete', array('_with_csrf' => true))->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'delete')->end()->with('response')->begin()->isRedirected(true)->followRedirect()->end()->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'listCustom')->end()->with('response')->begin()->checkElement('table.reports_list tbody tr', 20)->checkElement('table.reports_list tbody tr td:contains("Custom report delete vehicle 2")', false)->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.name LIKE ?', 'Custom report delete vehicle 2')->andWhere('r.date_from = ?', date('Y-m-d'))->andWhere('kilometers_to = ?', 10000)->leftJoin('r.Vehicles v')->andWhereIn('v.id', array($browser->getVehicleId('car-gs-1'), $browser->getVehicleId('car-gs-2'))), false)->end()->info('6 - Show action')->info('6.1 - isNew() flag')->get('/user_gs/reports')->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.user_id = ?', $browser->getUserId('user_gs')), 32)->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.user_id = ?', $browser->getUserId('user_gs'))->andWhere('r.is_new = ?', true), 3)->end()->with('response')->begin()->checkElement('table.reports_list', 1)->checkElement('table.reports_list tbody tr', 3)->checkElement('table.reports_list tbody tr.report_new', 1)->checkElement('tfoot.more_reports', 1)->end()->click('0-100 km - Car gs 1')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'show')->end()->get('/user_gs/reports')->with('response')->begin()->checkElement('table.reports_list', true)->checkElement('table.reports_list tbody tr', 3)->checkElement('table.reports_list tbody tr.report_new', 0)->end()->with('doctrine')->begin()->check('Report', Doctrine_Core::getTable('Report')->createQuery('r')->andWhere('r.user_id = ?', $browser->getUserId('user_gs'))->andWhere('r.is_new = ?', true), 2)->end()->info('6.2 - Single vehicle')->get('/user_gs/report/show/0-100-km-car-gs-1')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h2:contains("Download")', true)->checkElement('div.report_download a:contains("pdf")')->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('ul li a:contains("Create a new report")', true)->checkElement('h1:contains("Overall performances")', 1)->checkElement('h2:contains("car_gs")', 1)->checkElement('h1:contains("Costs")', 1)->checkElement('h2:contains("Cost per kilometer")', 1)->checkElement('h2:contains("Annual cost")', 1)->checkElement('h2:contains("Costs allocation")', 1)->checkElement('h1:contains("Travel")', 1)->checkElement('h2:contains("Annual travel")', 1)->checkElement('h2:contains("Monthly travel")', 1)->checkElement('h1:contains("Fuel consumption")', 1)->checkElement('body div#main img', 6)->end()->info('6.3 - Multiple vehicles')->get('/user_gs/report/show/0-1000-km-car-gs-1-and-car-gs-2')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h2:contains("Download")', true)->checkElement('div.report_download a:contains("pdf")')->checkElement('ul li a:contains("By Vehicle")', true)->checkElement('ul#reports_menu ul li.vehicle_archived', 0)->checkElement('ul#reports_menu ul li.vehicle_active', 2)->checkElement('ul#reports_menu li a:contains("Custom reports")', true)->checkElement('ul li a:contains("Create a new report")', true)->checkElement('h1:contains("Overall performances")', 1)->checkElement('h2:contains("car_gs")', 2)->checkElement('h1:contains("Costs")', 1)->checkElement('h2:contains("Cost per kilometer")', 1)->checkElement('h2:contains("Annual cost")', 1)->checkElement('h2:contains("Costs allocation")', 1)->checkElement('h1:contains("Travel")', 1)->checkElement('h2:contains("Annual travel")', 1)->checkElement('h2:contains("Monthly travel")', 1)->checkElement('h1:contains("Fuel consumption")', 1)->checkElement('body div#main img', 6)->checkElement('body:contains("Not enough data")', false)->end()->info('7 - Pdf')->get('/user_gs/report/pdf/0-1000-km-car-gs-1-and-car-gs-2')->with('request')->begin()->isParameter('module', 'report')->isParameter('action', 'pdf')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'application/pdf');
sfToolkit::clearDirectory($pdf_dir);
rmdir($pdf_dir);
コード例 #14
0
 public function setCacheDir($cacheDir)
 {
     $newCacheDir = $cacheDir . DIRECTORY_SEPARATOR;
     if (is_callable('posix_getuid')) {
         $userinfo = posix_getpwuid(posix_getuid());
         $newCacheDir .= $userinfo['name'];
     } else {
         $newCacheDir .= php_sapi_name();
     }
     sfConfig::set('sf_cache_dir', $newCacheDir);
     if (is_dir($newCacheDir)) {
         $filesystem = new sfFilesystem();
         $filesystem->mkdirs($newCacheDir);
         $filesystem->chmod($newCacheDir, 0777);
     }
     parent::setCacheDir($newCacheDir);
 }
コード例 #15
0
<?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');
コード例 #16
0
 public function setCacheDir($cacheDir)
 {
     $newCacheDir = $cacheDir . DIRECTORY_SEPARATOR . php_sapi_name();
     sfConfig::set('sf_cache_dir', $newCacheDir);
     $filesystem = new sfFilesystem();
     $filesystem->mkdirs(sfConfig::get('sf_cache_dir'));
     parent::setCacheDir($newCacheDir);
 }
コード例 #17
0
 */
$fs = new sfFilesystem();
$this->logSection('install', 'default to propel');

$this->logSection('install', 'default to sqlite');
$this->runTask('configure:database', sprintf("'sqlite:%spropel.db'", sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR));

$this->logSection('install', 'fix sqlite database permissions');
touch(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR .'propel.db');
chmod(sfConfig::get('sf_data_dir'), 0777);
chmod(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'propel.db', 0777);


$this->logSection('install', 'install propel 1.6');
sfSymfonyPluginManager::disablePlugin('sfPropelPlugin', sfConfig::get('sf_config_dir'));
$fs->mkdirs(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'sfPropelORMPlugin');

$root_dir = realpath(sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
$plugin_dir = realpath(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '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));
sfSymfonyPluginManager::enablePlugin('sfPropelORMPlugin', sfConfig::get('sf_config_dir'));

$this->logSection('install', 'setup propel behavior');
$ini_file = sfConfig::get('sf_config_dir'). DIRECTORY_SEPARATOR . 'propel.ini';
$content = file_get_contents($ini_file);
preg_replace('#^propel.behavior#', ';\1', $content);
$content .= <<<EOF
コード例 #18
0
ファイル: reportTest.php プロジェクト: rbolliger/otokou
<?php

include dirname(__FILE__) . '/../bootstrap/Doctrine.php';
include dirname(__FILE__) . '/../../lib/test/otokouTestFunctional.class.php';
$ut = new otokouTestFunctional(new sfBrowser('otokou.localhost'));
$pdf_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_report_dir_name');
$chart_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . sfConfig::get('app_charts_base_path');
$fs = new sfFilesystem();
$fs->mkdirs($pdf_dir);
$fs->mkdirs($chart_dir);
$t = new lime_test(20, new lime_output_color());
$t->diag('getNumVehicles() - One entry');
$vehicles_query = Doctrine_Core::getTable('Vehicle')->createQuery('v')->leftJoin('v.User u')->andWhere('u.username = ?', 'user_gs')->limit(1);
$report = new Report();
$report->setName('report_test_1');
$report->setUserId($ut->getUserId('user_gs'));
$report->setVehicles($vehicles_query->execute());
$report->save();
$t->cmp_ok($report->getNumVehicles(), '===', 1);
$t->diag('getNumVehicles() - Many entries');
$vehicles_query = Doctrine_Core::getTable('Vehicle')->createQuery('v')->leftJoin('v.User u')->andWhere('u.username = ?', 'user_gs');
$report = new Report();
$report->setName('report_test_2');
$report->setUserId($ut->getUserId('user_gs'));
$report->setVehicles($vehicles_query->execute());
$report->save();
$t->cmp_ok($report->getNumVehicles(), '===', 4);
$t->diag('getPdfFileName()');
$pdfname = $report->getHash() . '.pdf';
$t->cmp_ok($report->getPdfFileName(), '===', $pdfname, 'Pdf filename is built from hash');
$t->diag('getPdfWebPath()');
 protected function importFromGit($gitUrl, $gitCommit)
 {
     $filesystem = new sfFilesystem();
     require_once 'VersionControl/Git.php';
     $dir = sfConfig::get('sf_cache_dir') . '/git-' . md5($gitUrl . $gitCommit);
     $filesystem->mkdirs($dir);
     $git = new VersionControl_Git(sfConfig::get('sf_cache_dir'));
     $git->createClone($gitUrl, false, $dir);
     $filesystem->chmod($dir, 0777);
     $git->checkout($gitCommit);
     return $dir;
 }
コード例 #20
0
 public function checkPath($path, $create = true)
 {
     if (false === strpos($path, sfConfig::get('sf_root_dir'))) {
         throw new sfException(sprintf('checkPath() only accepts system paths. Got "%s" instead.', $path));
     }
     $exists = file_exists($path);
     if (!$exists && $create) {
         $fs = new sfFilesystem();
         $fs->mkdirs($path);
         $exists = true;
     }
     return $exists;
 }