Пример #1
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     parent::execute($arguments, $options);
     $projectWebPath = sfConfig::get('sf_web_dir');
     $filesystem = new dmFilesystem($this->dispatcher, $this->formatter);
     foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) {
         $this->logSection('plugin', 'Configuring plugin - ' . $plugin);
         $this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin);
     }
     // remove useless doctrine assets
     if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) {
         if (!is_link($doctrineAssetPath)) {
             $filesystem->deleteDirContent($doctrineAssetPath);
         }
         $filesystem->remove($doctrineAssetPath);
     }
     // remove web cache dir
     $webCacheDir = sfConfig::get('sf_web_dir') . '/cache';
     if (is_link($webCacheDir)) {
         $filesystem->remove($webCacheDir);
     }
     // create web cache dir
     $filesystem->mkdir($webCacheDir);
     if (!file_exists(dmOs::join($projectWebPath, 'sf'))) {
         $filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true);
     }
 }
Пример #2
0
 protected function setDmPluginPaths()
 {
     $baseDir = dm::getDir();
     foreach (array('dmCorePlugin', 'dmAdminPlugin', 'dmFrontPlugin') as $rootPlugin) {
         $this->setPluginPath($rootPlugin, $baseDir . '/' . $rootPlugin);
     }
     foreach (array('dmUserPlugin', 'dmAlternativeHelperPlugin', 'sfWebBrowserPlugin', 'sfImageTransformPlugin', 'sfFeed2Plugin', 'sfFormExtraPlugin') as $embeddedPlugin) {
         $this->setPluginPath($embeddedPlugin, $baseDir . '/dmCorePlugin/plugins/' . $embeddedPlugin);
     }
 }
Пример #3
0
    protected function renderHead()
    {
        return sprintf('<html>
<head>
<title>Diem %s System Check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<style type="text/css">%s</style>
</head>', DIEM_VERSION, file_get_contents(dmOs::join(dm::getDir(), 'dmCorePlugin/web/lib/blueprint/screen.css')) . file_get_contents(dmOs::join(dm::getDir(), 'dmCorePlugin/web/css/serverCheck.css')));
    }
Пример #4
0
 protected function getDiagramImage($appName)
 {
     $dependencyDiagramImage = sprintf('dependency_diagram_%s_%s.png', $appName, time());
     $dependencyDiagramImageFullPath = dmOs::join(sfConfig::get('sf_web_dir'), 'cache', $dependencyDiagramImage);
     $dotFile = tempnam(sys_get_temp_dir(), 'dm_dependency_');
     if (!$this->context->getFilesystem()->mkdir(dirname($dependencyDiagramImageFullPath))) {
         throw new dmException(sprintf('Can not mkdir %s', $dependencyDiagramImageFullPath));
     }
     $configFiles = array(dmOs::join(sfConfig::get('dm_core_dir'), 'config/dm/services.yml'), dmOs::join(dm::getDir(), sprintf('dm%sPlugin/config/dm/services.yml', dmString::camelize($appName))));
     $projectFile = dmOs::join(sfConfig::get('sf_config_dir'), 'dm/services.yml');
     if (file_exists($projectFile)) {
         $configFiles[] = $projectFile;
     }
     $appFile = dmOs::join(sfConfig::get('sf_apps_dir'), $appName, 'config/dm/services.yml');
     if (file_exists($appFile)) {
         $configFiles[] = $appFile;
     }
     $sc = new sfServiceContainerBuilder();
     $loader = new sfServiceContainerLoaderFileYaml($sc);
     $loader->load($configFiles);
     $sc->setService('dispatcher', $this->context->getEventDispatcher());
     $sc->setService('user', $this->context->getUser());
     $sc->setService('response', $this->context->getResponse());
     $sc->setService('i18n', $this->getI18n());
     $sc->setService('routing', $this->context->getRouting());
     $sc->setService('config_cache', $this->context->getConfigCache());
     $sc->setService('controller', $this->context->getController());
     $sc->setService('logger', $this->context->getLogger());
     $sc->setService('module_manager', $this->context->getModuleManager());
     $sc->setService('context', $this->context);
     $sc->setService('doctrine_manager', Doctrine_Manager::getInstance());
     $dumper = new dmServiceContainerDumperGraphviz($sc);
     $dumper->enableDispatcherLinks($this->withDispatcherLinks);
     file_put_contents($dotFile, $dumper->dump(array('graph' => array('overlap' => 'false', 'splines' => 'true', 'epsilon' => '0.5', 'maxiter' => '30000', 'concentrate' => 'false', 'bgcolor' => 'transparent', 'ratio' => 'fill', 'size' => '25,12'), 'node' => array('fontsize' => 20, 'fontname' => 'Arial', 'shape' => 'Mrecord'), 'edge' => array('fontsize' => 9, 'fontname' => 'Arial', 'color' => 'grey', 'arrowhead' => 'open', 'arrowsize' => 1), 'node.instance' => array('fillcolor' => '#ffffff', 'style' => 'filled', 'shape' => 'component'), 'node.definition' => array('fillcolor' => 'transparent'), 'node.missing' => array('fillcolor' => '#ffaaaa', 'style' => 'filled', 'shape' => 'record'))));
     $filesystem = $this->context->getFileSystem();
     //$return = $filesystem->exec(sprintf('dot -Tpng %s > %s', $dotFile, $dependencyDiagramImageFullPath));
     //$return = $filesystem->exec(sprintf('twopi -Granksep=5 -Tpng %s > %s', $dotFile, $dependencyDiagramImageFullPath));
     $return = $filesystem->exec(sprintf('neato -Tpng %s > %s', $dotFile, $dependencyDiagramImageFullPath));
     unlink($dotFile);
     if (!$return) {
         $this->getUser()->logError(sprintf('Diem can not generate the %s dependency diagram. Probably graphviz is not installed on the server.', $appName), false);
         $this->getUser()->logAlert($filesystem->getLastExec('command') . "\n" . $filesystem->getLastExec('output'), false);
     }
     return '/cache/' . $dependencyDiagramImage;
 }
Пример #5
0
 protected function getConfigPathPriority($configPath)
 {
     // application configuration
     if (0 === strpos($configPath, sfConfig::get('sf_apps_dir'))) {
         return 6;
     } elseif (0 === strpos($configPath, sfConfig::get('sf_root_dir') . '/config')) {
         return 5;
     } elseif (0 === strpos($configPath, sfConfig::get('sf_plugins_dir'))) {
         return 4;
     } elseif (0 === strpos($configPath, sfConfig::get('dm_core_dir') . '/plugins')) {
         return 3;
     } elseif (0 === strpos($configPath, sfConfig::get('dm_core_dir'))) {
         return 1;
     } elseif (0 === strpos($configPath, sfConfig::get('sf_symfony_lib_dir'))) {
         return 0;
     } elseif (0 === strpos($configPath, dm::getDir())) {
         return 2;
     }
     //others ( ? )
     return 4;
 }
Пример #6
0
<?php

require_once realpath(dirname(__FILE__) . '/../../../config/ProjectConfiguration.class.php');
require_once dm::getDir() . '/dmCorePlugin/lib/test/dmAdminFunctionalCoverageTest.php';
$config = array('login' => true, 'username' => 'admin', 'validate' => false, 'debug' => true, 'env' => 'prod');
$test = new dmAdminFunctionalCoverageTest($config);
$test->run();
Пример #7
0
<?php

$config = getcwd() . '/config/ProjectConfiguration.class.php';
require_once $config;
require_once dm::getDir() . '/dmCorePlugin/test/unit/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
$t = new lime_test(50);
dm::loadHelpers(array('Dm', 'I18N'));
$menu = $helper->get('menu')->name('Test Menu');
$root1 = $menu->getChild('Root 1');
$root1->addChild('Child 1');
$last = $root1->addChild('Child 2');
$root2 = $menu->getChild('Root 2');
$child1 = $root2->addChild('Child 1');
$child2 = $child1->addChild('Child 2');
$t->is($root1->getLevel(), 0, 'Test root level is 0');
$t->is($root2->getLevel(), 0, 'Test root level is 0');
$t->is($child1->getLevel(), 1, 'Test level is 1');
$t->is($child2->getLevel(), 2, 'Test level is 2');
$t->is($child2->getPathAsString(), 'Test Menu > Root 2 > Child 1 > Child 2', 'Test getPathAsString()');
$t->is(get_class($root1), get_class($menu), 'Test children are created as same class as parent');
// array access
$t->is($menu['Root 1']['Child 1']->getName(), 'Child 1', 'Test name()');
// countable
$t->is(count($menu), $menu->count(), 'Test sfSympalMenu Countable interface');
$t->is(count($root1), 2, 'Test sfSympalMenu Countable interface');
$count = 0;
foreach ($root1 as $key => $value) {
    $count++;
    $t->is($key, 'Child ' . $count, 'Test iteratable');
<?php

require_once dm::getDir() . '/dmCorePlugin/lib/config/dmApplicationConfiguration.php';
/**
 * sfConfiguration represents a configuration for a symfony application.
 *
 * @package    symfony
 * @subpackage config
 * @author     Fabien Potencier <*****@*****.**>
 * @version    SVN: $Id: sfApplicationConfiguration.class.php 13947 2008-12-11 14:15:32Z fabien $
 */
abstract class dmAdminApplicationConfiguration extends dmApplicationConfiguration
{
    public function setup()
    {
        parent::setup();
        $this->enablePlugins('dmAdminPlugin');
    }
}
 protected static function isProjectConfigFile($configFile)
 {
     // Diem embedded in project
     if (0 === strpos(dm::getDir(), sfConfig::get('sf_root_dir'))) {
         return 0 === strpos($configFile, sfConfig::get('sf_root_dir')) && 0 !== strpos($configFile, sfConfig::get('sf_plugins_dir')) && 0 !== strpos($configFile, dm::getDir());
     } else {
         return 0 === strpos($configFile, sfConfig::get('sf_root_dir')) && 0 !== strpos($configFile, sfConfig::get('sf_plugins_dir'));
     }
 }
Пример #10
0
    $deepMedia = $mediaTable->findOneByFileAndDmMediaFolderId('dmBaseLinkTag.php', $linkFolder->id);
    $t->isa_ok($deepMedia, 'DmMedia', 'deep media found in db');
} catch (Exception $e) {
    $t->fail($e->getMessage());
}
$folderFullPath = $folder->fullPath;
$folder->getNode()->delete();
$t->ok(!$folder->exists(), 'folder ' . $folder . ' has been deleted in database');
$t->ok(!is_dir($folderFullPath), 'folder ' . $folderFullPath . ' has been deleted in filesystem');
$t->ok(!$folderTable->findOneByRelPath($folder->relPath), 'folder ' . $folder . ' can not be found anymore in db');
$t->diag('Sync root');
$root->sync();
$helper->checkTreeIntegrity($t);
$helper->testFolderCorrelations($t);
$t->diag('Copy heavy folders structure into folder');
$sourcePath = dmOs::join(dm::getDir(), 'dmCorePlugin/lib/model/doctrine');
$destRelPath = 'test_lib_model_' . dmString::random(8);
$destFullPath = dmOs::join($root->fullPath, $destRelPath);
try {
    $helper->get('filesystem')->mirror($sourcePath, $destFullPath, sfFinder::type('all'));
    $t->pass('Copy completed');
} catch (Exception $e) {
    $t->fail('Copy failed : ' . $e->getMessage());
}
$t->ok(file_exists(dmOs::join($destFullPath, 'PluginDmMediaTable.class.php')), dmProject::unRootify(dmOs::join($destFullPath, 'PluginDmMediaTable.class.php')) . ' exists');
$t->diag('Sync root');
$root->sync();
$helper->checkTreeIntegrity($t);
$helper->testFolderCorrelations($t);
$folder = $folderTable->findOneByRelPath($destRelPath);
$folderFullPath = $folder->fullPath;
Пример #11
0
<?php

require_once dm::getDir() . '/dmFrontPlugin/lib/config/dmFrontApplicationConfiguration.php';
class frontConfiguration extends dmFrontApplicationConfiguration
{
    public function configure()
    {
    }
}
Пример #12
0
 public function getPanelContent()
 {
     $html = parent::getPanelContent();
     $html .= $this->formatArrayAsHtml('Diem', array('version' => DIEM_VERSION, 'path' => dm::getDir()));
     return $html;
 }