コード例 #1
0
 public function testFolderCorrelations(lime_test $t)
 {
     $t->diag('Verify that each db folder exist in fs');
     $errors = 0;
     foreach ($this->folderTable->findAll() as $f) {
         if (!is_dir($f->fullPath)) {
             $t->diag(sprintf('folder %s does not exist in fs', $f));
             $errors++;
         }
     }
     $t->is($errors, 0, 'Each db folder exist in fs');
     if ($errors > 0) {
         die;
     }
     $t->diag('Verify that each fs folder exist in db');
     $errors = 0;
     foreach (sfFinder::type('dir')->discard(".*")->ignore_version_control()->maxdepth(20)->in($this->folderTable->getTree()->fetchRoot()->fullPath) as $f) {
         if (strpos($f, '/.')) {
             continue;
         }
         $f = dmOs::normalize($f);
         $f = str_replace(dmOs::normalize(sfConfig::get('sf_upload_dir')) . '/', '', $f);
         if (!$this->folderTable->createQuery('f')->where('f.rel_path = ?', $f)->exists()) {
             $t->diag(sprintf('folder %s does not exist in db', $f));
             $errors++;
         }
     }
     $t->is($errors, 0, 'Each fs folder exist in db');
 }
コード例 #2
0
ファイル: dmLorem.php プロジェクト: theolymp/diem
 protected static function getMarkdownLoremText()
 {
     if (null === self::$markdownLoremText) {
         self::$markdownLoremText = implode('', file(dmOs::join(sfConfig::get("dm_core_dir"), "data/lorem/markdown")));
     }
     return self::$markdownLoremText;
 }
コード例 #3
0
ファイル: DmMediaHelper.php プロジェクト: jaimesuez/diem
function media_file_image_tag(DmMedia $file, $options = array()) {
  $options = array_merge(array(
              'width' => $file->isImage() ? 128 : 64,
              'height' => $file->isImage() ? 98 : 64
          ), dmString::toArray($options, true));

  if ($file->isImage()) {
    $image = _media($file);
  } else {
    if (file_exists(
            dmOs::join(
                    sfConfig::get('sf_web_dir')
                    .
                    '/dmCorePlugin/images/media/'
                    .
                    dmOs::getFileExtension($file->getFile(), false)
                    . '.png'
            )
    )) {
      $image = _media('/dmCorePlugin/images/media/' . dmOs::getFileExtension($file->getFile(), false) . '.png');
    } else {
      $image = _media('/dmCorePlugin/images/media/unknown.png');
    }
  }

  return $image->size($options['width'], $options['height']);
}
コード例 #4
0
 protected function parse($configFiles)
 {
     // parse the yaml
     $rawConfig = self::getConfiguration($configFiles);
     $dmFrontConfig = self::parseYamls(array(dmOs::join(sfConfig::get('dm_front_dir'), 'config/routing.yml')));
     $firstConfig = array();
     $lastConfig = array();
     foreach ($rawConfig as $key => $value) {
         if (array_key_exists($key, $dmFrontConfig)) {
             $lastConfig[$key] = $value;
         } else {
             $firstConfig[$key] = $value;
         }
     }
     $config = array_merge($firstConfig, $lastConfig);
     // collect routes
     $routes = array();
     foreach ($config as $name => $params) {
         if (isset($params['type']) && 'collection' == $params['type'] || isset($params['class']) && false !== strpos($params['class'], 'Collection')) {
             $options = isset($params['options']) ? $params['options'] : array();
             $options['name'] = $name;
             $options['requirements'] = isset($params['requirements']) ? $params['requirements'] : array();
             $routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRouteCollection', array($options));
         } else {
             $routes[$name] = array(isset($params['class']) ? $params['class'] : 'sfRoute', array($params['url'] ? $params['url'] : '/', isset($params['params']) ? $params['params'] : (isset($params['param']) ? $params['param'] : array()), isset($params['requirements']) ? $params['requirements'] : array(), isset($params['options']) ? $params['options'] : array()));
         }
     }
     return $routes;
 }
コード例 #5
0
ファイル: dmThread.php プロジェクト: theolymp/diem
 protected function perf($kill = false)
 {
     if ($kill) {
         dmDebug::killForce(dmOs::getPerformanceInfos());
     }
     dmDebug::showForce(dmOs::getPerformanceInfos());
 }
コード例 #6
0
ファイル: dmFrontLayoutHelper.php プロジェクト: jdart/diem
 public function renderGoogleAnalytics()
 {
     if (($gaKey = dmConfig::get('ga_key')) && !$this->getService('user')->can('admin') && !dmOs::isLocalhost()) {
         return $this->getGoogleAnalyticsCode($gaKey);
     }
     return '';
 }
コード例 #7
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);
     }
 }
コード例 #8
0
 /**
  * Constructor.
  * This method is used to construct a child class instance,
  * and helps sfServiceContainer injects dependancies
  *
  * @param dmContext $context
  * @param sfServiceContainer $container
  */
 public function __construct(dmContext $context, sfServiceContainer $container, $user)
 {
     $this->context = $context;
     $this->container = $container;
     $this->user = $user;
     $this->initialize(array('cache_dir' => dmOs::join(sfConfig::get('sf_cache_dir'), $this->getApplication(), 'security')));
 }
コード例 #9
0
 protected function writeFixture(dmModule $module, $securityDesc)
 {
     $this->clear();
     if ($pluginName = $module->getPluginName()) {
         $root = dmContext::getInstance()->getConfiguration()->getPluginConfiguration($pluginName)->getRootDir();
     } else {
         $root = sfConfig::get('sf_root_dir');
     }
     $fixturesRootPath = dmOs::join($root, 'data', 'fixtures');
     foreach (array('admin', 'front') as $app) {
         foreach (array('actions', 'components') as $actionKind) {
             if (isset($securityDesc[$app]) && isset($securityDesc[$app][$actionKind]) && is_array($securityDesc[$app][$actionKind])) {
                 foreach ($securityDesc[$app][$actionKind] as $actionName => $actionDesc) {
                     if (isset($actionDesc['credentials'])) {
                         $credentials = (array) $module->getSecurityManager()->parseCredentials($actionDesc['credentials']);
                         foreach ($credentials as $credential) {
                             $this->addPermissionFor($credential, $module->getKey(), $actionName);
                         }
                     }
                 }
             }
         }
     }
     $this->doWriteFixture(dmOs::join($fixturesRootPath, 'DmPermissions', $module->getKey() . '.yml'));
 }
コード例 #10
0
 /**
  * Update changed documentation pages in database
  */
 protected function updateDatabase($branch)
 {
     $types = dmDb::query('Doc d')->select('d.type')->distinct()->fetchFlat();
     $cultures = sfConfig::get('dm_i18n_cultures');
     $originalCulture = sfDoctrineRecord::getDefaultCulture();
     foreach ($types as $type) {
         foreach ($cultures as $culture) {
             sfDoctrineRecord::setDefaultCulture($culture);
             $dir = dmOs::join($this->repo->getDir(), $type, $culture);
             $files = sfFinder::type('file')->name('/^\\d{2}\\s-\\s.+\\.markdown$/')->in($dir);
             foreach ($files as $file) {
                 $docName = preg_replace('/^\\d{2}\\s-\\s(.+)\\.markdown$/', '$1', basename($file));
                 $docRecord = dmDb::query('DocPage dp')->withI18n()->innerJoin('dp.Doc doc')->innerJoin('doc.Branch branch')->where('branch.number = ?', $branch)->andWhere('doc.type = ?', $type)->andWhere('dpTranslation.name = ?', $docName)->fetchOne();
                 if ($docRecord) {
                     $docText = file_get_contents($file);
                     if ($docRecord->text != $docText) {
                         $docRecord->text = $docText;
                         $docRecord->save();
                     }
                 }
             }
         }
     }
     sfDoctrineRecord::setDefaultCulture($originalCulture);
 }
コード例 #11
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');
         }
     }
 }
コード例 #12
0
ファイル: dmTextDiff.php プロジェクト: theolymp/diem
 protected function loadVendorLib()
 {
     $dir = dmOs::join(sfConfig::get('dm_core_dir'), 'lib/vendor/Text_Diff');
     set_include_path(get_include_path() . PATH_SEPARATOR . $dir);
     require_once dmOs::join($dir, 'Text/Diff.php');
     require_once dmOs::join($dir, 'Text/Diff/Renderer/inline.php');
 }
コード例 #13
0
 protected function loadConfiguration()
 {
     sfConfig::add(array('sf_i18n' => true, 'sf_charset' => 'utf-8', 'sf_upload_dir_name' => str_replace(dmOs::normalize(sfConfig::get('sf_web_dir') . '/'), '', dmOs::normalize(sfConfig::get('sf_upload_dir'))), 'dm_data_dir' => dmOs::join(sfConfig::get('sf_data_dir'), 'dm'), 'dm_cache_dir' => dmOs::join(sfConfig::get('sf_cache_dir'), 'dm')));
     if (extension_loaded('mbstring')) {
         mb_internal_encoding('UTF-8');
     }
     dmConfig::initialize($this->dispatcher);
 }
コード例 #14
0
 /**
  * @see sfValidatorUrl
  */
 protected function doClean($value)
 {
     $value = parent::doClean($value);
     if ($value !== dmOs::sanitizeDirName($value)) {
         throw new sfValidatorError($this, 'invalid', array('value' => $value));
     }
     return $value;
 }
コード例 #15
0
ファイル: DmMediaHelper.php プロジェクト: jdart/diem
function media_file_infos(DmMedia $object)
{
    $infos = array(__('Size') => dmOs::humanizeSize($object->get('size')), __('Type') => $object->get('mime'), __('Created at') => format_date($object->get('created_at'), 'f'), __('Updated at') => format_date($object->get('updated_at'), 'f'), __('Url') => $object->getFullWebPath());
    if ($object->isImage()) {
        $infos = array_merge(array(__('Dimensions') => $object->getDimensions()), $infos);
    }
    return $infos;
}
コード例 #16
0
 protected function createMediaFromUploadedFile(array &$values)
 {
     $file = $values['file'];
     $folder = dmDb::table('DmMediaFolder')->findOneByRelPathOrCreate('widget');
     $media = dmDb::table('DmMedia')->findOneByFileAndDmMediaFolderId(dmOs::sanitizeFileName($file->getOriginalName()), $folder->id);
     if (!$media) {
         $media = dmDb::create('DmMedia', array('dm_media_folder_id' => $folder->id))->create($file)->saveGet();
     }
     $values['mediaId'] = $media->id;
 }
コード例 #17
0
 public function sync($relDir)
 {
     if ('/' === $relDir[0]) {
         throw new InvalidArgumentException($relDir . ' is not a relative web dir');
     }
     $dir = dmOs::join($this->webDir, $relDir);
     if (!is_dir($dir)) {
         throw new InvalidArgumentException($relDir . ' does not exist in ' . $this->webDir);
     }
     $this->syncDir($dir);
 }
コード例 #18
0
 protected function getAvailableModules()
 {
     $modules = array();
     foreach (glob(dmOs::join(sfConfig::get('dm_admin_dir'), 'modules/*'), GLOB_ONLYDIR) as $dir) {
         $modules[] = basename($dir);
     }
     foreach (glob(dmOs::join(sfConfig::get('sf_plugins_dir'), '*/modules/*'), GLOB_ONLYDIR) as $dir) {
         $modules[] = basename($dir);
     }
     return array_unique(array_merge($modules, self::$externalModules));
 }
コード例 #19
0
ファイル: dmMediaResource.php プロジェクト: theolymp/diem
 public function getFullPath()
 {
     switch ($this->getType()) {
         case self::MEDIA:
             return $this->source->getFullPath();
         case self::FILE:
             return dmOs::join(sfConfig::get('sf_web_dir'), $this->getPathFromWebDir());
         case self::REMOTE:
             return $this->remotePath;
     }
 }
コード例 #20
0
 public function clearName($validator, $values)
 {
     if (!empty($values['file'])) {
         $filename = dmOs::sanitizeFileName($values['file']->getOriginalName());
         if (empty($filename)) {
             $error = new sfValidatorError($validator, 'This is a bad name');
             // throw an error bound to the password field
             throw new sfValidatorErrorSchema($validator, array('file' => $error));
         }
     }
     return $values;
 }
コード例 #21
0
 protected function getFile(array $infos)
 {
     $file_format_values = array('%db_name%' => $infos['name'], '%year%' => date('Y'), '%month%' => date('m'), '%day%' => date('d'), '%time%' => date('H-i-s'));
     if (!empty($infos['tag'])) {
         $file_format = $this->getOption('file_format');
         $file_format_values = array_merge($file_format_values, array('%tag%' => $infos['tag']));
     } else {
         $file_format = str_replace('-%tag%', '', $this->getOption('file_format'));
     }
     $fileName = strtr($file_format, $file_format_values);
     return dmOs::join($this->getOption('dir'), $fileName);
 }
コード例 #22
0
 /**
  * Generates classes and templates in cache.
  *
  * @param array $params The parameters
  *
  * @return string The data to put in configuration cache
  */
 public function generate($params = array())
 {
     // create the project base class for all forms
     $file = sfConfig::get('sf_lib_dir') . '/filter/doctrine/BaseFormFilterDoctrine.class.php';
     if (!file_exists($file)) {
         if (!is_dir($directory = dirname($file))) {
             mkdir($directory, 0777, true);
         }
         copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data/skeleton/lib/filter/doctrine/BaseFormFilterDoctrine.class.php'), $file);
     }
     parent::generate($params);
 }
コード例 #23
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $filesystem = $this->get('filesystem');
     $uploadDir = dmOs::join(sfConfig::get('sf_web_dir'), 'uploads');
     if (!$filesystem->mkdir($uploadDir)) {
         throw new dmException(dmProject::unRootify($uploadDir) . ' is not writable');
     }
     $cacheDir = dmOs::join(sfConfig::get('sf_cache_dir'), 'open_package', dmProject::getKey());
     if (!$filesystem->mkdir($cacheDir)) {
         throw new dmException(dmProject::unRootify($cacheDir) . ' is not writable');
     }
     $filesystem->deleteDirContent($cacheDir);
     if (file_exists(dmOs::join($uploadDir, dmProject::getKey() . '.tgz'))) {
         $filesystem->unlink(dmOs::join($uploadDir, dmProject::getKey() . '.tgz'));
     }
     $this->log('Building the package, please wait...');
     $finder = sfFinder::type('all')->prune(array('.thumbs'))->discard(array('.thumbs'));
     foreach (array('apps', 'config', 'lib', 'plugins', 'public_html', 'test') as $dir) {
         $filesystem->mirror(dmOs::join(sfConfig::get('sf_root_dir'), $dir), dmOs::join($cacheDir, $dir), $finder);
     }
     $filesystem->copy(dmOs::join(sfConfig::get('sf_root_dir'), 'symfony'), dmOs::join($cacheDir, 'symfony'));
     foreach (array('cache', 'data') as $dir) {
         $filesystem->mkdir(dmOs::join($cacheDir, $dir));
     }
     if (file_exists(dmOs::join(sfConfig::get('sf_data_dir'), 'mysql'))) {
         $filesystem->mirror(dmOs::join(sfConfig::get('sf_data_dir'), 'mysql'), dmOs::join($cacheDir, 'data/mysql'), sfFinder::type('all'));
     }
     $databasesFile = dmOs::join($cacheDir, 'config/databases.yml');
     $databasesConfig = sfYaml::load($databasesFile);
     foreach ($databasesConfig as $namespace => $nsConfig) {
         foreach ($nsConfig as $dbName => $config) {
             $dsn = $databasesConfig[$namespace][$dbName]['param']['dsn'];
             $databasesConfig[$namespace][$dbName]['param']['dsn'] = preg_replace('#//(.+)\\:(.*)@#', '//#DB_USER#:#DB_PASSWORD#@', $dsn);
             foreach (array('username', 'password') as $key) {
                 if (isset($databasesConfig[$namespace][$dbName]['param'][$key])) {
                     unset($databasesConfig[$namespace][$dbName]['param'][$key]);
                 }
             }
         }
         file_put_contents($databasesFile, sfYaml::dump($databasesConfig, 5));
     }
     $filesystem->unlink(dmOs::join($cacheDir, 'test/functional'));
     $command = 'cd ' . dirname($cacheDir) . '; tar -czf ' . dmProject::getKey() . '.tgz ' . dmProject::getKey();
     $this->logSection('Compression', $command);
     if (!$filesystem->exec($command)) {
         throw new dmException($filesystem->getLastExec('output'));
     }
     rename(dmOs::join(dirname($cacheDir), dmProject::getKey() . '.tgz'), dmOs::join($uploadDir, dmProject::getKey() . '.tgz'));
     $filesystem->unlink($cacheDir);
     $this->logBlock('Done !', 'INFO');
 }
コード例 #24
0
 public function executeDownload(dmWebRequest $request)
 {
     $this->forward404Unless($versionNumber = $request->getParameter('v'));
     $this->forward404Unless($version = dmDb::table('Version')->findOneByNumber($versionNumber));
     $this->forward404Unless($package = $version->Package);
     $this->forward404Unless($package->exists());
     $fileName = sprintf('diem-%s%s', $version->number, dmOs::getFileExtension($package->fullPath));
     $this->getService('event_log')->setOption('enabled', false);
     $version->mapValue('disable_versioning', true);
     $version->downloads = $version->downloads + 1;
     $version->save();
     $this->context->getEventDispatcher()->notify(new sfEvent($this, 'download.package', array('version' => $version->number)));
     return $this->download($package->fullPath, array('file_name' => $fileName));
 }
コード例 #25
0
 protected function getAvailableModules()
 {
     $modules = array();
     foreach (glob(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/*'), GLOB_ONLYDIR) as $dir) {
         $modules[] = basename($dir);
     }
     if ($dirs = glob(dmOs::join(sfConfig::get('sf_plugins_dir'), '*/modules/*'), GLOB_ONLYDIR)) {
         foreach ($dirs as $dir) {
             if ('Admin' !== substr($dir, -5)) {
                 $modules[] = basename($dir);
             }
         }
     }
     return array_unique(array_merge($modules, self::$externalModules));
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('Diem Extended', 'Generate fixtures for DmPermissions within admin modules');
     $modules = $this->get('module_manager')->getModules();
     unset($modules['dmUser'], $modules['dmPermission'], $modules['dmGroup'], $modules['dmRecordPermission'], $modules['dmRecordPermissionAssociation']);
     foreach ($modules as $moduleKey => $module) {
         $securityDescriptor = $module->getSecurityManager()->getSecurityConfiguration();
         if (!empty($securityDescriptor)) {
             $this->logSection('Diem Extended', 'generating DmPermission fixtures for ' . $module->getKey());
             $this->addFixtures($module, $securityDescriptor);
         }
     }
     $root = sfConfig::get('sf_root_dir');
     $fixturesRootPath = dmOs::join($root, 'data', 'fixtures');
     $this->writeFixtures(dmOs::join($fixturesRootPath, 'DmPermissions', 'DmPermissions.yml'));
 }
コード例 #27
0
ファイル: actions.class.php プロジェクト: theolymp/diem
 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;
 }
コード例 #28
0
 public function execute()
 {
     require_once dmOs::join(sfConfig::get('dm_core_dir'), 'lib/vendor/Zend/Reflection/File.php');
     require_once dmOs::join(sfConfig::get('dm_core_dir'), 'lib/vendor/Zend/CodeGenerator/Php/File.php');
     require_once dmOs::join(sfConfig::get('dm_core_dir'), 'lib/vendor/dmZend/CodeGenerator/Php/Class.php');
     $file = dmOs::join($this->moduleDir, 'actions/actions.class.php');
     if (!$this->filesystem->mkdir(dirname($file))) {
         $this->logError('can not create directory ' . dmProject::unrootify(dirname($file)));
     }
     $className = $this->module->getKey() . 'Actions';
     if (file_exists($file)) {
         if ($this->shouldSkip($file)) {
             $this->log('skip ' . dmProject::unrootify($file));
             return true;
         }
         include_once $file;
         $this->class = dmZendCodeGeneratorPhpClass::fromReflection(new Zend_Reflection_Class($className));
         foreach ($this->class->getMethods() as $method) {
             $method->setIndentation($this->indentation);
         }
     } else {
         $this->class = $this->buildClass($className);
     }
     $this->class->setIndentation($this->indentation);
     if ($this->module->hasModel()) {
         foreach ($this->module->getComponents() as $component) {
             if ($component->getType() == 'form') {
                 $methodName = 'execute' . dmString::camelize($component->getKey()) . 'Widget';
                 if (!$this->class->getMethod($methodName)) {
                     $this->class->setMethod($this->buildFormMethod($methodName, $component));
                 }
             }
         }
     }
     if ($code = $this->class->generate()) {
         $return = file_put_contents($file, "<?php\n" . $code);
         $this->filesystem->chmod($file, 0777);
     } else {
         $return = true;
     }
     if (!$return) {
         $this->logError('can not write to ' . dmProject::unrootify($file));
     }
     return $return;
 }
コード例 #29
0
 /**
  * @return array models that act as DmTaggable
  */
 public function getTaggableModels()
 {
     $cacheManager = $this->getService('cache_manager');
     if ($cacheManager && $cacheManager->getCache('dm_tag')->has('taggable_models')) {
         return $cacheManager->getCache('dm_tag')->get('taggable_models');
     }
     $modelBaseFiles = array_merge(glob(dmOs::join(sfConfig::get('sf_lib_dir'), 'model/doctrine/base/Base*.class.php')), glob(dmOs::join(sfConfig::get('sf_lib_dir'), 'model/doctrine/*Plugin/base/Base*.class.php')));
     $taggableModels = array();
     foreach ($modelBaseFiles as $modelBaseFile) {
         if (strpos(file_get_contents($modelBaseFile), 'new Doctrine_Template_DmTaggable(')) {
             $taggableModels[] = preg_replace('|^Base(\\w+).class.php$|', '$1', basename($modelBaseFile));
         }
     }
     if ($cacheManager) {
         $cacheManager->getCache('dm_tag')->set('taggable_models', $taggableModels);
     }
     return $taggableModels;
 }
コード例 #30
0
ファイル: dmDoctrineGraphviz.php プロジェクト: theolymp/diem
 public function getMldImage(array $options = array())
 {
     $options = array_merge(array('type' => null, 'size' => '30,10'), $options);
     $digraph = $this->genMLD($options);
     $diagramImage = sprintf('mld_diagram_%s_%s.png', $options['type'], time());
     $imageFullPath = dmOs::join(sfConfig::get('sf_web_dir'), 'cache', $diagramImage);
     $dotFile = tempnam(sys_get_temp_dir(), 'dm_mld_');
     if (!$this->filesystem->mkdir(dirname($imageFullPath))) {
         throw new dmException(sprintf('Can not mkdir %s', $imageFullPath));
     }
     file_put_contents($dotFile, $digraph);
     $return = $this->filesystem->exec(sprintf('dot -Tpng %s > %s', $dotFile, $imageFullPath));
     unlink($dotFile);
     if (!$return) {
         throw new dmException(sprintf('Diem can not generate the mld diagram : %s', $this->filesystem->getLastExec('output')));
     }
     return '/cache/' . $diagramImage;
 }