Exemplo n.º 1
0
 protected function generateLayoutTemplates()
 {
     $this->logSection('diem', 'generate layout templates');
     $filesystem = $this->get('filesystem');
     foreach (dmDb::query('DmLayout l')->fetchRecords() as $layout) {
         $template = $layout->get('template');
         $templateFile = dmProject::rootify('apps/front/modules/dmFront/templates/' . $template . 'Success.php');
         if (!file_exists($templateFile)) {
             if ($filesystem->mkdir(dirname($templateFile))) {
                 $filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/pageSuccess.php'), $templateFile);
                 $filesystem->chmod($templateFile, 0777);
             } else {
                 $this->logBlock('Can NOT create layout template ' . $template, 'ERROR');
             }
         }
     }
     $layoutFile = dmProject::rootify('apps/front/modules/dmFront/templates/layout.php');
     if (!file_exists($layoutFile)) {
         if ($filesystem->mkdir(dirname($layoutFile))) {
             $filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/layout.php'), $layoutFile);
             $filesystem->chmod($layoutFile, 0777);
         } else {
             $this->logBlock('Can NOT create layout ' . $layoutFile, 'ERROR');
         }
     }
 }
Exemplo n.º 2
0
 public function initialize(array $options)
 {
     parent::initialize($options);
     if ('/' !== $this->options['file'][0]) {
         $this->options['file'] = dmProject::rootify($this->options['file']);
     }
     $this->nbFields = count($this->fields);
 }
Exemplo n.º 3
0
 public function executeSave(dmWebRequest $request)
 {
     $file = dmProject::rootify($request->getParameter('file'));
     $this->forward404Unless(file_exists($file), $file . ' does not exists');
     try {
         @$this->getService('file_backup')->save($file);
     } catch (dmException $e) {
         return $this->renderJson(array('type' => 'error', 'message' => 'backup failed : ' . $e->getMessage()));
     }
     @file_put_contents($file, $request->getParameter('code'));
     if (dmOs::getFileExtension($file, false) == 'css') {
         $return = array('type' => 'css', 'path' => $this->getHelper()->getStylesheetWebPath(dmOs::getFileWithoutExtension($file)));
     } else {
         $this->getService('cache_cleaner')->clearTemplate();
         $return = array('type' => 'php', 'widgets' => $this->getWidgetInnersForFile($file));
     }
     $return['message'] = $this->getI18n()->__('Your modifications have been saved');
     return $this->renderJson($return);
 }
Exemplo n.º 4
0
$t->isa_ok($currentIndex->getLuceneIndex(), 'Zend_Search_Lucene_Proxy', 'The current index is instanceof Zend_Search_Lucene_Proxy');
$t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
dmConfig::set('search_stop_words', 'un le  les de,du , da, di ,do   ou ');
$t->is($currentIndex->getStopWords(), array('un', 'le', 'les', 'de', 'du', 'da', 'di', 'do', 'ou'), 'stop words retrieved from site instance : ' . implode(', ', $currentIndex->getStopWords()));
$t->diag('Cleaning text');
$html = '<ol><li><a class="link dm_parent" href="symfony">Accueil</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines">Domaines</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines/77-cursus-proin1i471j0u">cursus. Proin1i471j0u</a></li><li>></li><li><a class="link dm_parent" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1">trices interdum risus. Duisgpcinqn1</a></li><li>></li><li><span class="link dm_current">Info : t, auctor ornare, risus. Donec lo</span></li></ol><span class="link dm_current">Info : t, auctor ornare, risus. Donec lo</span><div class="info_tag list_by_info"><ul class="elements"><li class="element clearfix"><a class="link" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1/t-auctor-ornare-risus-donec-lo-79/t-donec">t. Donec</a></li><li class="element clearfix"><a class="link" href="symfony/domaines/77-cursus-proin1i471j0u/104-trices-interdum-risus-duisgpcinqn1/t-auctor-ornare-risus-donec-lo-79/em-ipsu">em ipsu</a></li></ul></div>';
$expected = 'accueil domaines cursus proin1i471j0u trices interdum risus duisgpcinqn1 info t auctor ornare risus donec lo info t auctor ornare risus donec lo t donec em ipsu';
$t->is($currentIndex->cleanText($html), $expected, 'cleaned text : ' . $expected);
$html = '<div>some content<a href="url">a link text  é àî</a>... end</div>';
$expected = 'some content a link text e ai end';
$t->is($currentIndex->cleanText($html), $expected, 'cleaned text : ' . $expected);
// for now this doesn't work on windows
if ('/' !== DIRECTORY_SEPARATOR) {
    return;
}
$t->diag('Populate all indices');
$t->ok($engine->populate(), 'Indices populated');
$t->is($user->getCulture(), sfConfig::get('sf_default_culture'), 'User\'s culture has not been changed');
$t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
$t->diag('Optimize all indices');
$t->ok($engine->optimize(), 'Indices optimized');
$t->is($user->getCulture(), sfConfig::get('sf_default_culture'), 'User\'s culture has not been changed');
$t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
$t->ok(file_exists(dmProject::rootify('cache/testIndex/' . $currentIndex->getName(), 'segments.gen')), 'There is segments.gen in cache index dir ' . dmProject::rootify('cache/testIndex/' . $currentIndex->getName(), 'segments.gen'));
$indexDescription = $engine->getCurrentIndex()->describe();
// not pages indexed with sqlite (?)
if (!$isSqlite) {
    $t->is($indexDescription['Documents'], $engine->getCurrentIndex()->getPagesQuery()->count(), 'All pages have been indexed : ' . $indexDescription['Documents']);
    $t->diag('Perform a search');
    $engine->search('Diem');
}
Exemplo n.º 5
0
 protected function decodePath($path)
 {
     return dmProject::rootify(strtr($path, array_flip($this->getOption('path_replacements'))));
 }
Exemplo n.º 6
0
 public function getFullPath()
 {
     return dmProject::rootify($this->getOption('dir'));
 }
Exemplo n.º 7
0
<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(10);
sfConfig::set('dm_backup_enabled', true);
$backup = $helper->get('file_backup');
$rootDir = sfConfig::get('sf_root_dir');
$backupDir = $backup->getDir();
$t->is($backupDir, dmOs::join(sfConfig::get('sf_data_dir'), 'dm/backup/filesystem'), $backupDir);
$t->ok(is_dir($backupDir), $backupDir . ' exists');
$t->ok(is_writable($backupDir), $backupDir . ' is writable');
$t->diag('Change backup dir to cache/backupTest');
$backup->setDir('cache/backupTest');
$t->ok(is_dir($backupDir), $backupDir . ' exists');
$t->ok(is_writable($backupDir), $backupDir . ' is writable');
$t->diag('clear backup');
$backup->clear();
$t->is($backup->getFiles(), array(), 'backup is empty');
$file = dmProject::rootify('config/ProjectConfiguration.class.php');
$t->diag('backup ' . $file);
$backup->save($file);
$backupFile = dmOs::join($backup->getDir(), 'config/ProjectConfiguration.class.php.' . date('Y-m-d_H-i-s'));
$t->is(count($backup->getFiles()), 1, 'backup has one file');
$t->is($backup->getFiles(), array($backupFile), 'backup has ' . $backupFile);
$t->is(file_get_contents($file), file_get_contents($backupFile), 'backup file is same as file');
$t->diag('clear backup');
$backup->clear();
$t->is($backup->getFiles(), array(), 'backup is empty');
 protected function projectHasModels()
 {
     return 0 !== count(sfYaml::load(file_get_contents(dmProject::rootify('config/doctrine/schema.yml'))));
 }
Exemplo n.º 9
0
 protected function upgradeToAuthDmUserAdminModule()
 {
     // Admin : Replace login and secure module: dmAuthAdmin -> dmUserAdmin
     $settingsFile = dmProject::rootify('apps/admin/config/settings.yml');
     $settingsText = file_get_contents($settingsFile);
     $settings = sfYaml::load($settingsText);
     foreach (array('.settings', '.actions') as $space) {
         $loginModule = dmArray::get(dmArray::get($settings['all'], $space, array()), 'login_module');
         $secureModule = dmArray::get(dmArray::get($settings['all'], $space, array()), 'secure_module');
         if ('dmAuth' == $loginModule || 'dmAuthAdmin' == $loginModule) {
             $settingsText = preg_replace('/login_module\\:(\\s*)\\w+/i', 'login_module:$1dmUserAdmin', $settingsText);
             file_put_contents($settingsFile, $settingsText);
         }
         if ('dmAuth' == $secureModule || 'dmAuthAdmin' == $loginModule) {
             $settingsText = preg_replace('/secure_module\\:(\\s*)\\w+/i', 'secure_module:$1dmUserAdmin', $settingsText);
             file_put_contents($settingsFile, $settingsText);
         }
     }
 }
Exemplo n.º 10
0
<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(5);
$cliFile = 'cache/thread_launcher_test.php';
$helper->get('service_container')->mergeParameter('thread_launcher.options', array('cli_file' => $cliFile));
$threadLauncher = $helper->get('thread_launcher');
$t->is($threadLauncher->getCliFileFullPath(), dmProject::rootify($cliFile), 'cli file is ' . dmProject::rootify($cliFile));
$t->ok(file_exists(dmProject::rootify($cliFile)), 'cli file has been created in ' . $cliFile);
$threadClass = 'dmThreadTest';
$proofFileName = dmString::random();
try {
    $threadLauncher->execute(dmString::random());
    $t->fail('thread launcher throws an exception when thread class does not exists');
} catch (dmException $e) {
    $t->pass('thread launcher throws an exception when thread class does not exists');
}
$t->diag($threadLauncher->getCommand($threadClass, array('proof_file_name' => $proofFileName)));
try {
    $threadLauncher->execute($threadClass, array('proof_file_name' => $proofFileName));
    $t->pass('thread launcher executed correctly the thread ' . $threadClass);
} catch (dmException $e) {
    $t->fail('thread launcher executed correctly the thread ' . $threadClass);
    $t->diag('got : ' . $threadLauncher->getLastExec('output'));
}
$t->ok(file_exists(dmOs::join(sfConfig::get('sf_cache_dir'), $proofFileName)), 'The thread did its job successfully');
Exemplo n.º 11
0
} while (!$isDatabaseOk);
/*
 * APPLY
 */
$this->logBlock('Your configuration is valid', 'INFO_LARGE');
usleep(1000000);
$sendReports = $this->askConfirmation(array('Send anonymous reports about plugins used to improve http://diem-project.org/plugins (Y/n)'), 'QUESTION_LARGE', true);
if (!$this->askConfirmation(array('The installation will remove all data in the ' . $settings['database']['name'] . ' database.', '', 'Are you sure you want to proceed? (Y/n)'), 'QUESTION_LARGE', true)) {
    $this->logSection('diem', 'installation aborted');
    exit;
}
$this->filesystem->mirror(dmOs::join(sfConfig::get('dm_core_dir'), 'data/skeleton'), sfConfig::get('sf_root_dir'), sfFinder::type('any')->discard('.sf'), array('override' => true));
$this->replaceTokens(sfConfig::get('sf_config_dir'), array('SYMFONY_CORE_AUTOLOAD' => $symfonyCoreAutoload, 'DIEM_CORE_STARTER' => var_export(dmOs::join(sfConfig::get('dm_core_dir'), 'lib/core/dm.php'), true), 'DIEM_WEB_DIR' => "sfConfig::get('sf_root_dir').'/" . $settings['web_dir_name'] . "'", 'DIEM_CULTURE' => var_export($settings['culture'], true), 'SEND_REPORTS' => var_export($sendReports, true)));
$this->filesystem->remove(array(dmProject::rootify('web/css'), dmProject::rootify('web/css/main.css'), dmProject::rootify('web/images'), dmProject::rootify('data/fixtures'), dmProject::rootify('data/fixtures/fixtures.yml')));
if ('web' != $settings['web_dir_name']) {
    $this->filesystem->rename(dmProject::rootify('web'), dmProject::rootify($settings['web_dir_name']));
}
$db = $settings['database'];
$this->runTask('configure:database', array('dsn' => $db['dsn'], 'username' => $db['user'], 'password' => $db['password']));
try {
    if ('/' !== DIRECTORY_SEPARATOR) {
        throw new Exception('Automatic install disabled for windows servers');
    }
    $this->logBlock('Installing ' . $projectKey . '. This may take some time.', 'INFO_LARGE');
    $out = $err = null;
    $this->getFilesystem()->execute(sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'dm:setup --no-confirmation'), $out, $err);
    $this->logBlock('Your project is now ready to be accessed by the web. Try it out on admin_dev.php.', 'INFO_LARGE');
    $this->logBlock('Your username is "admin" and your password is ' . (empty($settings['database']['password']) ? '"admin"' : 'the database password'), 'INFO_LARGE');
} catch (Exception $e) {
    $this->logBlock('There is one last thing you need to do.  Please run "php symfony dm:setup"', 'INFO_LARGE');
}
Exemplo n.º 12
0
 public function getCliFileFullPath()
 {
     return dmProject::rootify($this->getOption('cli_file'));
 }
Exemplo n.º 13
0
 public function setDir($dir)
 {
     $this->setOption('dir', dmProject::rootify($dir));
     $this->checkDirIsWritable();
 }