示例#1
0
 public function __construct(dmContext $context, array $options = array())
 {
     $this->context = $context;
     $this->serviceContainer = $context->getServiceContainer();
     $this->htmlWriter = new phpHtmlWriter();
     $this->initialize($options);
 }
 public function manage(DmRecordPermission $permission)
 {
     if (!$this->user->getUser()) {
         return;
     }
     $userId = $this->user->getUser()->get($this->user->getUser()->getTable()->getIdentifier());
     $query = dmDb::table('DmRecordPermissionAssociation')->createQuery('p')->select('p.id, p.dm_secure_module, p.dm_secure_action, p.dm_secure_model, g.id, u.id')->leftJoin('p.Groups g')->leftJoin('p.Users u')->addWhere('p.dm_secure_module = ?', $permission->get('secure_module'))->addWhere('p.dm_secure_action = ?', $permission->get('secure_action'))->addWhere('p.dm_secure_model = ?', $permission->get('secure_model'));
     $query = $this->context->getEventDispatcher()->filter(new sfEvent($permission, 'dm_record_permission_association_manager.filter_query'), $query)->getReturnValue();
     $associations = $query->execute();
     $this->associate($permission, $associations);
 }
示例#3
0
 public function __construct(Exception $e, dmContext $context)
 {
     $this->exception = $e;
     $this->class = get_class($e);
     $this->name = $e->getMessage() ? $e->getMessage() : 'n/a';
     $this->module = $context->getModuleName();
     $this->action = $context->getActionName();
     $this->uri = $context->getRequest()->getUri();
     $env = 'n/a';
     if ($conf = $context->getConfiguration()) {
         $env = $conf->getEnvironment();
     }
     $this->env = $env;
     $this->date = date('H:i:s j F Y');
 }
 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');
 }
 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;
 }
示例#7
0
 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 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 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');
     }
 }
示例#12
0
 /**
  * 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());
 }
示例#13
0
 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;
 }
 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);
 }
示例#16
0
 public function boot($app = 'admin', $env = 'test', $debug = true)
 {
     $rootDir = getcwd();
     // configuration
     require_once $rootDir . '/config/ProjectConfiguration.class.php';
     $this->configuration = ProjectConfiguration::getApplicationConfiguration($app, $env, $debug, $rootDir);
     $this->context = dmContext::createInstance($this->configuration, null, $this->contextClass);
     sfConfig::set('sf_logging_enabled', false);
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $this->cleanup();
     $this->initialize();
     register_shutdown_function(array($this, 'cleanup'));
     return $this;
 }
 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);
 }
示例#21
0
 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 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 function postSave($event)
 {
     parent::postSave($event);
     dmContext::getInstance()->getServiceContainer()->getService('mail_renderer')->clearCache();
 }
    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);
    }
示例#25
0
 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 getFilterFormOptions()
 {
     $method = 'getFilterFormOptionsFor' . dmContext::getInstance()->getActionName();
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
     return $this->getDefaultFilterFormOptions();
 }
示例#27
0
/**
 * @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);
}
示例#28
0
 public function __construct(dmContext $context, array $options = array())
 {
     $this->context = $context;
     $this->helper = $context->getHelper();
     $this->initialize($options);
 }
示例#29
0
文件: dmBase.php 项目: rafaelgou/diem
 public static function getHelper()
 {
     return dmContext::getInstance()->getHelper();
 }
示例#30
0
 /**
  * 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');
 }