protected function configure($options = array(), $attributes = array()) { parent::configure($options = array(), $attributes = array()); // Option for both $this->addOption('ui_show_button_panel', true); $this->addOption('theme', sfConfig::get('dm_dmDateTimePickerPlugin_default_theme')); $this->addOption('ui_button_open', ''); $this->addOption('ui_button_clear', ''); // Date options $this->addOption('ui_date_format', dmContext::getInstance()->getServiceContainer()->getService('user')->getCulture()); $this->addOption('ui_number_of_months', 1); $this->addOption('ui_change_month', true); $this->addOption('ui_change_year', true); $this->addOption('ui_constrain_input', true); // Time options $this->addOption('ui_time_format', dmContext::getInstance()->getServiceContainer()->getService('user')->getCulture()); $this->addOption('ui_control_type', 'slider'); $this->addOption('ui_step_hour', 1); $this->addOption('ui_step_minute', 1); $this->addOption('ui_step_second', 1); $this->addOption('ui_hour_grid', 0); $this->addOption('ui_minute_grid', 0); $this->addOption('ui_second_grid', 0); if (!isset($options['theme'])) { $options['theme'] = $this->getOption('theme'); } $this->parseThemeDefaultOptions($options); }
public static function listenToMediaLibraryControlMenuEvent(sfEvent $event) { /** @var dmMediaLibraryControlMenu */ $media_library_menu = $event->getSubject(); $media_library_menu->addChild($media_library_menu->getI18n()->__('Add multiple files'), $media_library_menu->getHelper()->link('+/dmMediaUploadifyerAdmin/newMultipleFile?folder_id=' . $event['folder']->id)->set('.new_multiple_file.uploadify_dialog_me.s16.s16_file_add'))->end(); dmContext::getInstance()->getResponse()->addJavascript('dmMediaUploadifyerPlugin.adminCtrl'); }
public function getAssetAliases() { if (null === $this->assetAliases) { $this->assetAliases = (include dmContext::getInstance()->get('config_cache')->checkConfig('config/dm/assets.yml')); } return $this->assetAliases; }
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')); }
public static function getDmConfiguration() { $moduleManager = dmContext::getInstance()->getModuleManager(); // homepage first $config = array('homepage' => array('class' => 'sfRoute', 'url' => '/', 'params' => array('module' => 'dmAdmin', 'action' => 'index'))); // media library special route if ($dmMediaLibraryModule = $moduleManager->getModuleOrNull('dmMediaLibrary')) { $baseUrl = implode('/', array(dmString::slugify($dmMediaLibraryModule->getSpace()->getType()->getPublicName()), dmString::slugify($dmMediaLibraryModule->getSpace()->getPublicName()), dmString::slugify($dmMediaLibraryModule->getPlural()))); $config['dm_media_library_path'] = array('class' => 'sfRoute', 'url' => $baseUrl . '/path/:path', 'params' => array('module' => 'dmMediaLibrary', 'action' => 'path', 'path' => ''), 'requirements' => array('path' => '.*')); } // module routes foreach ($moduleManager->getModules() as $module) { if (!$module->hasAdmin()) { continue; } $baseUrl = implode('/', array(dmString::slugify($module->getSpace()->getType()->getPublicName()), dmString::slugify($module->getSpace()->getPublicName()), dmString::slugify($module->getPlural()))); $config[$module->getUnderscore()] = array('class' => 'sfRoute', 'url' => $baseUrl . '/:action/*', 'params' => array('module' => $module->getSfName(), 'action' => 'index')); } // static routes $config['default'] = array('class' => 'sfRoute', 'url' => '/+/:module/:action/*'); $config['signin'] = array('class' => 'sfRoute', 'url' => '/security/signin', 'params' => array('module' => 'dmUserAdmin', 'action' => 'signin')); $config['signout'] = array('class' => 'sfRoute', 'url' => '/security/signout', 'params' => array('module' => 'dmUserAdmin', 'action' => 'signout')); $config['dm_module_type'] = array('class' => 'sfRoute', 'url' => '/:moduleTypeName', 'params' => array('module' => 'dmAdmin', 'action' => 'moduleType')); $config['dm_module_space'] = array('class' => 'sfRoute', 'url' => '/:moduleTypeName/:moduleSpaceName', 'params' => array('module' => 'dmAdmin', 'action' => 'moduleSpace')); return $config; }
public function __construct($options = array(), $attributes = array()) { if (isset($options['choices'])) { $options['choices'] = array_merge($options['choices'], dmContext::getInstance()->getServiceContainer()->getService('i18n')->translateArray(dmWidgetFormChoiceEasing::$easing)); } else { $options['choices'] = dmContext::getInstance()->getServiceContainer()->getService('i18n')->translateArray(dmWidgetFormChoiceEasing::$easing); } parent::__construct($options, $attributes); }
/** * Initializes the current sfGenerator instance. * * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance */ public function initialize(sfGeneratorManager $generatorManager) { parent::initialize($generatorManager); if (!dmContext::hasInstance()) { dmContext::createInstance($generatorManager->getConfiguration()); } $this->moduleManager = dmContext::getInstance()->getModuleManager(); $this->setGeneratorClass('dmDoctrineForm'); }
/** * Used to insert a JS hack to replace the dmMedia/gallery add button by the uplodifier dialog * @param sfEvent $event */ public static function listenToActionChangeEvent(sfEvent $event) { if (dmContext::hasInstance() && $event['module'] == 'dmMedia' && $event['action'] == 'gallery') { $context = dmContext::getInstance(); $context->getResponse()->addStylesheet('lib.ui-dialog'); $context->getResponse()->addJavascript('lib.ui-dialog'); $context->getResponse()->addJavascript('dmMediaUploadifyerPlugin.galleryHack', 'last'); } }
/** * Configures the current validator. * * Available options: * * * date_format: A regular expression that dates must match * * with_time: true if the validator must return a time, false otherwise * * date_output: The format to use when returning a date (default to Y-m-d) * * datetime_output: The format to use when returning a date with time (default to Y-m-d H:i:s) * * date_format_error: The date format to use when displaying an error for a bad_format error (use date_format if not provided) * * max: The maximum date allowed (as a timestamp) * * min: The minimum date allowed (as a timestamp) * * date_format_range_error: The date format to use when displaying an error for min/max (default to d/m/Y H:i:s) * * Available error codes: * * * bad_format * * min * * max * * @param array $options An array of options * @param array $messages An array of error messages * * @see sfValidatorBase */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $i18n = dm::getI18n(); $this->addMessage('bad_format', '"%value%" ' . $i18n->__('does not match the date format') . ' (%date_format%).'); $this->addMessage('max', $i18n->__('The date must be before') . ' %max%.'); $this->addMessage('min', $i18n->__('The date must be after') . ' %min%.'); // $this->addOption('date_format', $this->getDateFormat(dm::getUser()->getCulture())); $this->addOption('context', dmContext::getInstance()); }
public function getContext() { if (null === $this->context) { if (!dmContext::hasInstance()) { $this->logSection('diem', sprintf('Loading %s...', get_class($this->configuration))); dm::createContext($this->configuration); } $this->context = dmContext::getInstance(); } return $this->context; }
/** * Get the current context * @return dmContext */ public function getContext() { if (null === $this->context) { if (!dmContext::hasInstance()) { $this->logSection('Diem Extended', sprintf('Loading %s...', get_class($this->configuration))); dm::createContext($this->configuration); } $this->context = dmContext::getInstance(); $this->context->get('filesystem')->setFormatter($this->formatter); } return $this->context; }
protected function loadRemoteCode($uri) { $browser = dmContext::getInstance()->getServiceContainer()->getService('web_browser'); try { if (!$browser->get($uri)->responseIsError()) { return $browser->getResponseText(); } else { throw new dmException(); } } catch (Exception $e) { throw new dmUnreachableRemoteLessException(sprintf('LESS code from source "%s" can not be reached.', $uri)); } }
public function __construct($options = array(), $attributes = array()) { $choices = array(); $modules = array(); foreach (dmContext::getInstance()->getModuleManager()->getModules() as $module) { $actions = $module->getActions(); foreach ($actions as $action) { $choiceName = $module->getName() . '|' . $action['name']; $choices[$module->getName() . '|' . $action['name']] = $module->getName() . ' | ' . $action['name']; } } $options['choices'] = $choices; parent::__construct($options, $attributes); }
public function setup() { parent::setup(); $this->useFields(array('dm_media_folder_id', 'file', 'legend', 'author', 'license')); $this->widgetSchema['file'] = new sfWidgetFormDmInputFile(); $this->validatorSchema['file'] = new sfValidatorFile(array('required' => $this->getObject()->isNew())); $this->changeToHidden('dm_media_folder_id'); $this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'clearName')))); $this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkFolder')))); if (false !== ($mimeTypes = $this->getOption('mime_types', false))) { $this->setMimeTypeWhiteList($mimeTypes); } elseif (false !== ($mimeTypes = sfConfig::get('dm_media_mime_type_whitelist', false))) { if (!dmContext::getInstance()->getUser()->can('media_ignore_whitelist')) { $this->setMimeTypeWhiteList($mimeTypes); } } }
protected function parseConfiguration() { $config = $this->getOption('config'); if ($this->getOption('width')) { $config['width'] = $this->getOption('width'); } if ($this->getOption('height')) { $config['height'] = $this->getOption('height'); } if (isset($config['content_css'])) { if (sfConfig::get('sf_environment') != 'prod') { $config['content_css'] = public_path($config['content_css']) . '?_tinyMceCache=' . strtotime('now'); } else { $config['content_css'] = public_path($config['content_css']); } } $config['tiny_mce_base_path'] = dirname(dmContext::getInstance()->getResponse()->calculateAssetPath('js', 'lib.tinymce')); return $config; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $i18n = dmContext::getInstance()->getServiceContainer()->getService('i18n'); $page = ''; if ($value) { try { $page = DmPageTable::getInstance()->findOneById($value); $page = $page->getTitle(); } catch (Exception $e) { $page = $i18n->__('ERROR: This page does not exist anymore.'); } } $data = array('page' => $page, 'title' => $i18n->__('Drag & Drop page from PAGE bar.'), 'clear_page_message' => $i18n->__('Clear page'), 'goto_page_message' => $i18n->__('Open page')); if (isset($attributes['class'])) { $attributes['class'] .= ' sfWidgetFormDmPageLink ' . str_replace('"', "'", json_encode($data)); } else { $attributes['class'] = 'sfWidgetFormDmPageLink ' . str_replace('"', "'", json_encode($data)); } return parent::render($name, $value, $attributes, $errors); }
public function __construct(dmContext $context, array $options = array()) { sfContext::getInstance()->getConfigCache()->registerConfigHandler('config/dm/behaviors.yml', 'dmBehaviorsConfigHandler', array()); include sfContext::getInstance()->getConfigCache()->checkConfig('config/dm/behaviors.yml'); $this->behaviors = sfConfig::get('dm_behaviors'); $this->helper = dmContext::getInstance()->getServiceContainer()->getService('helper'); $this->i18n = dmContext::getInstance()->getServiceContainer()->getService('i18n'); $this->loadedBehaviors = array(); $this->javascripts = array(); $this->stylesheets = array(); $this->context = $context; // The mode of instance $user = $this->context->getServiceContainer()->getService('user'); // HELP HERE PLEASE !!! // MAYBE USER CAN NOT ADMINISTRATE BEHAVIORS // BUT IF HE CAN CHANGE CONTENT // THIS SHOULD BE REGISTERED AS ADMIN MODE!!! // WHAT MORE PRIVILEGES TO CHECK ???? $this->adminMode = $user->can('behavior_add') || $user->can('behavior_edit') || $user->can('behavior_delete'); $this->configure($options); }
protected function executeInit($arguments = array(), $options = array()) { $moduleObject = dmContext::getInstance()->getModuleManager()->getModule($arguments['module']); $arguments['module'] = $moduleObject->getSfName(); if ($pluginName = $moduleObject->getPluginName()) { if ($moduleObject->isOverridden()) { return; } $moduleDir = dmOs::join($this->configuration->getPluginConfiguration($pluginName)->getRootDir(), 'modules', $moduleObject->getSfName()); } else { $moduleDir = dmOs::join(sfConfig::get('sf_apps_dir'), 'admin/modules', $moduleObject->getSfName()); } if (!$moduleDir) { throw new dmException('No generate dir'); } $this->logSection('diem', sprintf('Generating admin module "%s" for model "%s" in %s', $moduleObject->getKey(), $moduleObject->getModel(), $moduleDir)); // create basic application structure $finder = sfFinder::type('any')->discard('.sf'); $dirs = $this->configuration->getGeneratorSkeletonDirs('dmAdminDoctrineModule', $options['theme']); foreach ($dirs as $dir) { if (is_dir($dir)) { $this->getFilesystem()->mirror($dir, $moduleDir, $finder); break; } } // move configuration file if (file_exists($config = $moduleDir . '/lib/configuration.php')) { if (file_exists($target = $moduleDir . '/lib/' . $arguments['module'] . 'GeneratorConfiguration.class.php')) { $this->getFilesystem()->remove($config); } else { $this->getFilesystem()->rename($config, $target); } } // move helper file if (file_exists($config = $moduleDir . '/lib/helper.php')) { if (file_exists($target = $moduleDir . '/lib/' . $arguments['module'] . 'GeneratorHelper.class.php')) { $this->getFilesystem()->remove($config); } else { $this->getFilesystem()->rename($config, $target); } } // move form file if (file_exists($config = $moduleDir . '/lib/form.php')) { if (file_exists($target = $moduleDir . '/lib/' . $arguments['model'] . 'AdminForm.php')) { $this->getFilesystem()->remove($config); } else { $this->getFilesystem()->rename($config, $target); } } // move export file if (file_exists($config = $moduleDir . '/lib/export.php')) { if (file_exists($target = $moduleDir . '/lib/' . $arguments['model'] . 'AdminExport.class.php')) { $this->getFilesystem()->remove($config); } else { $this->getFilesystem()->rename($config, $target); } } // customize php and yml files $finder = sfFinder::type('file')->name('*.php', '*.yml'); $this->constants['MODULE_NAME'] = $arguments['module']; $this->constants['UC_MODULE_NAME'] = ucfirst($arguments['module']); $this->constants['CONFIG'] = sprintf(<<<EOF model_class: %s theme: %s non_verbose_templates: %s with_show: %s route_prefix: %s with_doctrine_route: %s EOF , $arguments['model'], $options['theme'], $options['non-verbose-templates'] ? 'true' : 'false', $options['with-show'] ? 'true' : 'false', $options['route-prefix'] ? $options['route-prefix'] : '~', 'false'); $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); $generatorFile = dmOs::join($moduleDir, 'config/generator.yml'); $generatorBuilder = new dmAdminGeneratorBuilder($moduleObject, $this->dispatcher); file_put_contents($generatorFile, $generatorBuilder->getTransformed(file_get_contents($generatorFile))); $moduleObject->getSecurityManager()->secure($moduleObject); }
public function getLessCompiler() { if ($this->lessCompiler) { return $this->lessCompiler; } else { $this->lessCompiler = dmContext::getInstance()->getServiceContainer()->getService('less_compiler'); return $this->lessCompiler; } }
public function getFilterFormOptions() { $method = 'getFilterFormOptionsFor' . dmContext::getInstance()->getActionName(); if (method_exists($this, $method)) { return $this->{$method}(); } return $this->getDefaultFilterFormOptions(); }
/** * @return $return if $source is equal or parent of the current page */ function dm_current_or_parent($source = null, $return = '.dm_current_or_parent') { return ($page = dmContext::getInstance()->getPage()) && ($page->isSource($source) || $page->isDescendantOfSource($source)) ? $return : null; }
protected function executeWidgetAction(array $widget) { $suffix_action = $widget['action'] . 'Widget'; if (dmContext::getInstance()->getController()->actionExists($module = $widget['module'], $suffix_action)) { $actionToRun = 'execute' . ucfirst($suffix_action); try { dmContext::getInstance()->getController()->getAction($module, $suffix_action)->preExecute(); dmContext::getInstance()->getController()->getAction($module, $suffix_action)->{$actionToRun}(!isset($widget['request']) ? dmContext::getInstance()->getRequest() : $widget['request']); dmContext::getInstance()->getController()->getAction($module, $suffix_action)->postExecute(); } catch (sfControllerException $e) { dmContext::getInstance()->getLogger()->warning(sprintf('The %s/%s direct action does not exist', $module, $suffix_action)); } } }
public function initialize($source) { $this->source = $source; $this->params = false; if (empty($source)) { $this->type = 'page'; $this->subject = dmDb::table('DmPage')->findOneBySource(null); } elseif (is_string($source)) { /* * If a blank space is found in the source, * remove characters after it * because they are just a comment * i.e. page:1?var=val Home */ if ($blankSpacePos = strpos($source, ' ')) { $source = substr($source, 0, $blankSpacePos); } /* * Extract url parameters from source string */ $this->params = dmString::getDataFromUrl($source); $source = dmString::getBaseFromUrl($source); if ('@homepage' === $source) { $source = 'main/root'; } if (strncmp($source, 'page:', 5) === 0) { if ($page = dmDb::table('DmPage')->findOneBySource($source)) { $this->type = 'page'; $this->subject = $page; } else { throw new dmException(sprintf('%s is not a valid link resource', $source)); } } elseif (strncmp($source, 'media:', 6) === 0) { if ($media = dmDb::table('DmMedia')->findOneByIdWithFolder(substr($source, 6))) { $this->type = 'media'; $this->subject = $media; } else { throw new dmException(sprintf('%s is not a valid link resource', $source)); } } elseif (strncmp($source, 'app:', 4) === 0) { $app = substr($source, 4); /* * A slug may be added to the app name, extract it */ if ($slashPos = strpos($app, '/')) { $slug = substr($app, $slashPos); $app = substr($app, 0, $slashPos); } else { $slug = ''; } $this->type = 'uri'; $this->subject = dmContext::hasInstance() ? dmContext::getInstance()->get('script_name_resolver')->get($app) . $slug : $slug; } elseif (strncmp($source, '@', 1) === 0) { $this->type = 'route'; $this->subject = $source; } elseif (strncmp($source, 'http://', 7) === 0 || strncmp($source, 'https://', 7) === 0 || strncmp($source, 'ftp://', 6) === 0 || strncmp($source, 'mailto:', 7) === 0 || strncmp($source, '#', 1) === 0) { $this->type = 'uri'; $this->subject = $source; } elseif (strncmp($source, '/', 1) === 0) { $this->type = 'uri'; $this->subject = $source; } elseif (strncmp($source, '+/', 2) === 0) { $this->type = 'action'; $this->subject = substr($source, 2); } elseif (substr_count($source, '/') === 1) { if ($page = dmDb::table('DmPage')->findOneBySource($source)) { $this->type = 'page'; $this->subject = $page; } else { throw new dmException(sprintf('%s is not a valid link resource', $source)); } } else { throw new dmException(sprintf('%s is not a valid link resource', $source)); } } elseif (is_object($source)) { if ($source instanceof DmPage) { $this->type = 'page'; $this->subject = $source; } elseif ($source instanceof DmMedia) { $this->type = 'media'; $this->subject = $source; } elseif ($source instanceof dmDoctrineRecord) { if ($module = $source->getDmModule()) { if ($module->hasPage()) { $this->type = 'record'; $this->subject = $source; } else { throw new dmException(sprintf('%s module has no page', $module)); } } else { throw new dmException(sprintf('%s object can not be associated to a page', get_class($source))); } } elseif ($source instanceof Exception) { $this->type = 'error'; $this->subject = $source; } } elseif (is_array($source)) { if (isset($source[1])) { if (is_object($source[1])) { $this->type = 'action'; $this->subject = array('sf_route' => $source[0], 'sf_subject' => $source[1]); } } else { $this->type = 'action'; $this->subject = $source; } } if (empty($this->type) || empty($this->subject)) { throw new dmException(sprintf('dmFrontLinkResource can not determine type of %s', $source)); } return $this; }
/** * Initializes the current sfGenerator instance. * * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance */ public function initialize(sfGeneratorManager $generatorManager) { parent::initialize($generatorManager); $this->moduleManager = dmContext::getInstance()->getModuleManager(); $this->setGeneratorClass('dmAdminDoctrineModule'); }
public static function load($useCache = true) { if (!self::$culture) { if (class_exists('dmContext', false) && dmContext::hasInstance() && ($user = dmContext::getInstance()->getUser())) { self::$culture = $user->getCulture(); } else { self::$culture = sfConfig::get('sf_default_culture'); } } try { if (self::$culture == sfConfig::get('sf_default_culture')) { $results = dmDb::pdo('SELECT s.name, t.value, t.lang FROM dm_setting s LEFT JOIN dm_setting_translation t ON t.id=s.id AND t.lang = ?', array(self::$culture))->fetchAll(PDO::FETCH_NUM); } else { $results = dmDb::pdo('SELECT s.name, t.value, t.lang FROM dm_setting s LEFT JOIN dm_setting_translation t ON t.id=s.id AND t.lang IN (?, ?)', array(self::$culture, sfConfig::get('sf_default_culture')))->fetchAll(PDO::FETCH_NUM); } } catch (PDOException $e) { $results = array(); } catch (Doctrine_Connection_Exception $e) { $results = array(); } self::$config = array(); foreach ($results as $result) { if (!isset(self::$config[$result[0]]) || isset(self::$config[$result[0]]) && $result[2] == self::$culture) { self::$config[$result[0]] = $result[1]; } } unset($results); self::$loaded = true; }
public function postSave($event) { parent::postSave($event); dmContext::getInstance()->getServiceContainer()->getService('mail_renderer')->clearCache(); }
public static function getPathFromWebDir($type, $asset) { $package = substr($asset, 0, strpos($asset, '.')); if (in_array($package, array('core', 'lib', 'front', 'admin'))) { $name = substr($asset, strpos($asset, '.') + 1); } else { $name = $asset; } switch ($type) { case 'js': switch ($package) { case 'core': $path = '/' . sfConfig::get('dm_core_asset') . '/js/' . $name . '.js'; break; case 'lib': $path = '/' . sfConfig::get('dm_core_asset') . '/lib/' . $name . '.js'; break; case 'front': $path = '/' . sfConfig::get('dm_front_asset') . '/js/' . $name . '.js'; break; case 'admin': $path = '/' . sfConfig::get('dm_admin_asset') . '/js/' . $name . '.js'; break; default: $path = '/' . dmString::str_replace_once('.', '/' . $type . '/', $asset) . '.js'; } break; case 'css': switch ($package) { case 'core': $path = '/' . sfConfig::get('dm_core_asset') . '/css/' . $name . '.css'; break; case 'lib': $path = '/' . sfConfig::get('dm_core_asset') . '/lib/' . $name . '.css'; break; case 'front': $path = '/' . sfConfig::get('dm_front_asset') . '/css/' . $name . '.css'; break; case 'admin': $path = '/' . sfConfig::get('dm_admin_asset') . '/css/' . $name . '.css'; break; default: $path = '/' . dmString::str_replace_once('.', '/' . $type . '/', $asset) . '.css'; } break; default: $path = '/' . dmString::str_replace_once('.', '/', $asset); } if (!isset($path)) { throw new dmException("Can not find path for asset {$type}.{$package}.{$asset}"); } // check for source version of the file in `dev` environment if (sfConfig::get('sf_environment') == 'dev') { $webPath = sfConfig::get('sf_web_dir'); $fsPath = $webPath . $path; $fsSourceFilePath = null; $fsDirName = dirname($fsPath); $fsFilename = basename($fsPath); if (strpos($fsFilename, '.min.')) { $possibleFsSourceFilePath = $fsDirName . DIRECTORY_SEPARATOR . str_replace('.min.', '.', $fsFilename); if (file_exists($possibleFsSourceFilePath)) { $fsSourceFilePath = $possibleFsSourceFilePath; } } if (is_null($fsSourceFilePath)) { $fsPathDirectories = explode(DIRECTORY_SEPARATOR, $fsDirName); $fsFilename = str_replace('.min.', '.', $fsFilename); foreach ($fsPathDirectories as $fsDirectory) { if (in_array($fsDirectory, array('min', 'minified', 'compressed', 'minimized'))) { foreach (array('source', 'unminified', 'uncompressed', 'unminimized') as $possibleSourceDirName) { $search = DIRECTORY_SEPARATOR . $fsDirectory . DIRECTORY_SEPARATOR; $replace = DIRECTORY_SEPARATOR . $possibleSourceDirName . DIRECTORY_SEPARATOR; $possibleFsSourceFilePath = str_replace($search, $replace, $fsDirName . DIRECTORY_SEPARATOR) . $fsFilename; if (file_exists($possibleFsSourceFilePath)) { $fsSourceFilePath = $possibleFsSourceFilePath; break; } } //break after a directory with minified files is found break; } } unset($fsDirectory); } if (!is_null($fsSourceFilePath)) { $fs = dmContext::getInstance()->getFilesystem(); $path = '/' . $fs->getRelativeDir($webPath . DIRECTORY_SEPARATOR, $fsSourceFilePath); } } return $path; }
public static function getHelper() { return dmContext::getInstance()->getHelper(); }
/** * @param string $content * @param bool $removeAttributes * @param bool $removeMissingElements * @see dmRichEditorContentParser */ function parse_rich_content($content, $removeAttributes = true, $removeMissingElements = true) { echo dmContext::getInstance()->getHelper()->parseRichContent($content, $removeAttributes, $removeMissingElements); }
/** * Returns the path of this module, in the filesystem * @return string the path in the filesystem */ public function getGenerationDir() { if (!$this->getOption('generate_dir', false)) { if ($pluginName = $this->getPluginName()) { if ($this->isOverridden()) { continue; } $this->setOption('generate_dir', dmOs::join(dmContext::getInstance()->getConfiguration()->getPluginConfiguration($pluginName)->getRootDir(), 'modules', $this->getSfName())); } else { $this->setOption('generate_dir', dmOs::join(sfConfig::get('sf_apps_dir'), DmContext::getInstance()->getConfiguration()->getApplication() . '/modules', $this->getSfName())); } } return $this->getOption('generate_dir'); }