public function getWidgetTypes() { if (null === $this->widgetTypes) { $cache = $this->serviceContainer->getService('cache_manager')->getCache('dm/widget/' . sfConfig::get('sf_app') . sfConfig::get('sf_environment')); $this->widgetTypes = $cache->get('types'); if (empty($this->widgetTypes)) { $internalConfigFile = $this->serviceContainer->getService('config_cache')->checkConfig($this->getOption('config_file')); $internalConfig = (include $internalConfigFile); $this->widgetTypes = array(); $controller = $this->serviceContainer->getService('controller'); foreach ($internalConfig as $moduleKey => $actions) { $this->widgetTypes[$moduleKey] = array(); foreach ($actions as $actionKey => $action) { $fullKey = $moduleKey . dmString::camelize($actionKey); $name = dmArray::get($action, 'name', dmString::humanize($actionKey)); $widgetTypeConfig = array('full_key' => $moduleKey . ucfirst($actionKey), 'name' => $name, 'public_name' => dmArray::get($action, 'public_name', dmString::humanize($name)), 'form_class' => dmArray::get($action, 'form_class', $fullKey . 'Form'), 'view_class' => dmArray::get($action, 'view_class', $fullKey . 'View'), 'use_component' => $this->componentExists($moduleKey, $fullKey), 'cache' => dmArray::get($action, 'cache', false)); $this->widgetTypes[$moduleKey][$actionKey] = new dmWidgetType($moduleKey, $actionKey, $widgetTypeConfig); } } foreach ($this->serviceContainer->getService('module_manager')->getProjectModules() as $moduleKey => $module) { $this->widgetTypes[$moduleKey] = array(); foreach ($module->getComponents() as $componentKey => $component) { $baseClass = 'dmWidget' . dmString::camelize($component->getType()); $widgetTypeConfig = array('full_key' => $moduleKey . ucfirst($componentKey), 'name' => $component->getName(), 'public_name' => $module->getName() . ' ' . dmString::humanize($component->getName()), 'form_class' => $baseClass . 'Form', 'view_class' => $baseClass . 'View', 'use_component' => $this->componentExists($moduleKey, $componentKey), 'cache' => $component->isCachable()); $this->widgetTypes[$moduleKey][$componentKey] = new dmWidgetType($moduleKey, $componentKey, $widgetTypeConfig); } } $cache->set('types', $this->widgetTypes); } } return $this->widgetTypes; }
/** * Join media for this columnName or alias * return @dmDoctrineQuery $this */ public function withDmMedia($alias, $rootAlias = null) { $rootAlias = $rootAlias ? $rootAlias : $this->getRootAlias(); $mediaJoinAlias = $rootAlias . dmString::camelize($alias); $folderJoinAlias = $mediaJoinAlias . 'Folder'; return $this->leftJoin(sprintf('%s.%s %s, %s.%s %s', $rootAlias, $alias, $mediaJoinAlias, $mediaJoinAlias, 'Folder', $folderJoinAlias)); }
/** * Sets a parameter (implements the ArrayAccess interface). * * @param string $name The parameter name * @param mixed $value The parameter value */ public function offsetSet($name, $value) { $name = dmString::camelize($name); if (!$value instanceof dmForm) { throw new InvalidArgumentException(sprintf('The object "%s" is not an instance of dmForm', get_class($value))); } $this->prepareFormForPage($value); $this->forms[$name] = $value; }
public function checks(array $checks = array()) { $checks = array_merge($this->getDefaultChecks(), $checks); foreach ($checks as $check => $expected) { $method = 'is' . dmString::camelize($check); $this->{$method}($expected); } $this->test()->unlike($this->getResponse()->getContent(), '/\\[EXCEPTION\\]/', 'Response contains no [Exception]'); return $this; }
public function get($key) { if (method_exists($this, $method = 'get' . dmString::camelize($key))) { return $this->{$method}(); } if (isset($this->data[$key])) { return $this->data[$key]; } return null; }
protected function findCustomGetters() { $getters = array(); foreach (array_keys($this->getFields()) as $field) { $getter = 'get' . dmString::camelize($field); if (method_exists($this, $getter)) { $getters[$field] = $getter; } } return $getters; }
public function execute() { if (!$this->configuration) { throw new dmException('Please set an application configuration with ->setConfiguration()'); } $this->log('load basic data'); $this->dispatcher->notify(new sfEvent($this, 'dm.data.before')); foreach ($this->datas as $data) { $this->{'load' . dmString::camelize($data)}(); } $this->dispatcher->notify(new sfEvent($this, 'dm.data.after')); }
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; }
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; }
public function execute($configFiles) { $config = array(); $behaviors = array(); foreach ($configFiles as $file) { $tmp = $this->parseYaml($file); if (!isset($tmp['dmBehaviors'])) { continue; } foreach ($tmp['dmBehaviors'] as $key => $value) { $sectionKey = dmString::slugify($value['section']); if (!isset($config[$sectionKey])) { $config[$sectionKey] = array('section_name' => $value['section'], 'behaviors' => array()); } $config[$sectionKey]['behaviors'][$key] = array('name' => isset($value['name']) ? $value['name'] : dmString::humanize($key), 'icon' => isset($value['icon']) ? $value['icon'] : '/dmCorePlugin/images/16/gear.png', 'form' => isset($value['form']) ? $value['form'] : 'dm' . dmString::camelize($key) . 'BehaviorForm', 'view' => isset($value['view']) ? $value['view'] : 'dm' . dmString::camelize($key) . 'BehaviorView', 'cache' => isset($value['cache']) ? (bool) $value['cache'] : true); $behaviors[$key] = $config[$sectionKey]['behaviors'][$key]; } } $retval = sprintf("<?php\n" . "// auto-generated by %s\n" . "// date: %s\nsfConfig::set('dm_behaviors_menu_items', \n%s\n);\n sfConfig::set('dm_behaviors', \n%s\n); \n ?>", __CLASS__, date('Y/m/d H:i:s'), var_export($config, true), var_export($behaviors, true)); return $retval; }
public function __construct($key, array $options) { $this->key = $key; $this->options = $options; $this->baseClass = 'dmWidget' . dmString::camelize($this->getType()); }
/** * Loads the diem services */ protected function loadServiceContainer() { require_once sfConfig::get('dm_core_dir') . '/lib/vendor/sfService/sfServiceContainerInterface.php'; require_once sfConfig::get('dm_core_dir') . '/lib/vendor/sfService/sfServiceContainer.php'; $name = 'dm' . dmString::camelize(sfConfig::get('sf_app')) . 'ServiceContainer'; $file = dmOs::join(sfConfig::get('dm_cache_dir'), $name . '.php'); if (!file_exists($file)) { $this->dumpServiceContainer($name, $file); } require_once $file; $this->serviceContainer = new $name(); $this->dispatcher->connect('dm.config.updated', array($this, 'listenToConfigUpdatedEvent')); }
public function getReplacementsForPatterns(dmProjectModule $module, array $patterns, dmDoctrineRecord $record) { $moduleKey = $module->getKey(); $replacements = array(); foreach ($this->getPatternsPlaceholders($patterns) as $placeholder) { if ('culture' === $placeholder || 'user.culture' === $placeholder) { $replacements[$this->wrap($placeholder)] = $this->culture; continue; } /* * Extract model and field from 'model.field' or 'model' */ if (strpos($placeholder, '.')) { list($usedModuleKey, $field) = explode('.', $placeholder); } else { $usedModuleKey = $placeholder; $field = '__toString'; } $usedModuleKey = dmString::modulize($usedModuleKey); $usedRecord = null; /* * Retrieve used record */ if ($usedModuleKey === $moduleKey) { $usedRecord = $record; } elseif ($module->hasAncestor($usedModuleKey)) { $usedRecord = $record->getAncestorRecord($module->getAncestor($usedModuleKey)->getModel()); } else { $usedRecord = $record->getRelatedRecord($this->moduleManager->getModule($usedModuleKey)->getModel()); } if ($usedRecord instanceof dmDoctrineRecord) { /* * get record value for field */ if ($field === '__toString') { $usedValue = $usedRecord->__toString(); $processMarkdown = true; } else { try { $usedValue = $usedRecord->get($field); } catch (Doctrine_Record_UnknownPropertyException $e) { $usedValue = $usedRecord->{'get' . dmString::camelize($field)}(); } $processMarkdown = $this->shouldProcessMarkdown($usedRecord->getTable(), $field); } unset($usedRecord); } else { $usedValue = $moduleKey . '-' . $usedModuleKey . ' not found'; $processMarkdown = false; } $usedValue = trim($usedValue); if ($processMarkdown) { $usedValue = dmMarkdown::brutalToText($usedValue); } $replacements[$this->wrap($placeholder)] = $usedValue; } return $replacements; }
/** * Shortcut for Doctrine_Core::getTable * @return myDoctrineTable the table for this model class name */ public static function table($class) { return Doctrine_Core::getTable(dmString::camelize($class)); }
public function getFormOptions() { $method = 'getFormOptionsFor' . dmString::camelize(dmContext::getInstance()->getActionName()); if (method_exists($this, $method)) { return $this->{$method}(); } return $this->getDefaultFormOptions(); }
/** * Gets a service. * * If a service is both defined through a setService() method and * with a set*Service() method, the former has always precedence. * * @param string $id The service identifier * @param string $class Alternative class to use * * @return object The associated service * * @throw InvalidArgumentException if the service is not defined */ public function getService($id, $class = null) { if (isset($this->services[$id])) { return $this->services[$id]; } if (!empty($id) && method_exists($this, $method = 'get' . dmString::camelize($id) . 'Service')) { if (null !== $class) { $defaultClass = $this->getParameter($id . '.class'); $this->setParameter($id . '.class', $class); } $service = $this->{$method}(); if (null !== $class) { $this->setParameter($id . '.class', $defaultClass); } return $service; } throw new InvalidArgumentException(sprintf('The service "%s" does not exist.', $id)); }
protected function fixModuleConfig($moduleKey, $moduleConfig, $isInContent) { /* * Extract plural from name * name | plural */ if (!empty($moduleConfig['name'])) { if (strpos($moduleConfig['name'], '|')) { list($moduleConfig['name'], $moduleConfig['plural']) = explode('|', $moduleConfig['name']); } } else { $moduleConfig['name'] = dmString::humanize($moduleKey); } if (empty($moduleConfig['model'])) { $candidateModel = dmString::camelize($moduleKey); $model = class_exists('Base' . $candidateModel, true) ? Doctrine_Core::isValidModelClass($candidateModel) ? $candidateModel : false : false; } else { $model = $moduleConfig['model']; } // BC "actions" deprecated keyword becomes "components" if (isset($moduleConfig['actions'])) { $moduleConfig['components'] = $moduleConfig['actions']; unset($moduleConfig['actions']); } //security features $securityConfig = $this->fixSecurityConfig($moduleKey, $moduleConfig); $moduleOptions = array('name' => (string) trim($moduleConfig['name']), 'plural' => (string) trim(empty($moduleConfig['plural']) ? $model ? dmString::pluralize($moduleConfig['name']) : $moduleConfig['name'] : $moduleConfig['plural']), 'model' => $model, 'credentials' => isset($moduleConfig['credentials']) ? is_string($moduleConfig['credentials']) ? trim($moduleConfig['credentials']) : (is_array($moduleConfig['credentials']) ? $moduleConfig['credentials'] : '') : ((bool) $isInContent ? 'content' : null), 'underscore' => (string) dmString::underscore($moduleKey), 'is_project' => (bool) $isInContent || dmArray::get($moduleConfig, 'page', false) || count(dmArray::get($moduleConfig, 'components', array())), 'plugin' => $moduleConfig['plugin'], 'overridden' => dmArray::get($moduleConfig, 'overridden', false), 'has_admin' => (bool) dmArray::get($moduleConfig, 'admin', $model || !$isInContent), 'has_front' => (bool) dmArray::get($moduleConfig, 'front', true), 'components' => dmArray::get($moduleConfig, 'components', array()), 'has_security' => is_array($securityConfig), 'security' => $securityConfig, 'i18n_catalogue' => isset($moduleConfig['i18n_catalogue']) ? $moduleConfig['i18n_catalogue'] : sfConfig::get('dm_i18n_catalogue')); if ($moduleOptions['is_project']) { $moduleOptions = array_merge($moduleOptions, array('parent_key' => dmArray::get($moduleConfig, 'parent') ? dmString::modulize(trim(dmArray::get($moduleConfig, 'parent'))) : null, 'has_page' => (bool) dmArray::get($moduleConfig, 'page', false))); } // fix non array action filters foreach ($moduleOptions['components'] as $componentKey => $componentConfig) { if (is_array($componentConfig) && array_key_exists('filters', $componentConfig) && !is_array($componentConfig['filters'])) { $moduleOptions['components'][$componentKey]['filters'] = array($componentConfig['filters']); } } return $moduleOptions; }
/** * returns a value of a property or a related component * * @param mixed $fieldName name of the property or related component * @param boolean $load whether or not to invoke the loading procedure * @throws Doctrine_Record_Exception if trying to get a value of unknown property / related component * @return mixed */ public function get($fieldName, $load = true) { $hasAccessor = $this->hasAccessor($fieldName); if ($hasAccessor || $this->_table->getAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE)) { $componentName = $this->_table->getComponentName(); $accessor = $this->hasAccessor($fieldName) ? $this->getAccessor($fieldName) : 'get' . dmString::camelize($fieldName); if ($hasAccessor || method_exists($this, $accessor)) { /* * Special case. * For versionable tables, we don't want to use * the getVersion accessor when requesting 'version'. * This is because "Version" is a relation, and "version" is a fieldname. * The case is lost when using getVersion. */ if ('version' === $fieldName && $this->getTable()->isVersionable()) { return $this->_get($fieldName, $load); } $this->hasAccessor($fieldName, $accessor); return $this->{$accessor}($load); } } return $this->_get($fieldName, $load); }
public function getSettingValidator(DmSetting $setting) { $method = 'get' . dmString::camelize($setting->type) . 'SettingValidator'; return $this->{$method}($setting); }
protected function paginationCreateRelationQuery($field, $pk, $search) { $queryBuilder = 'paginateBuildQueryFor' . dmString::camelize($field); if (!method_exists($this, $queryBuilder)) { //from here, we guess the relation is bound to the object of the DmModule //check if it is a local key relation $relation = dmString::camelize(substr($field, 0, strlen($field) - 5)); //remove _list @todo make it given by $request, using .metadata() and writting it within template $table = $this->getDmModule()->getTable(); //guessing relation from field name if ($table->hasRelation($relation)) { $relation = $table->getRelation($relation); } elseif ($table->hasRelation($field)) { $relation = $table->getRelation($field); } elseif ($table->hasRelation($relation = dmString::camelize($field))) { $relation = $table->getRelation($relation); } elseif ($relation = $table->getRelationByColumn($field)) { } $table = dmDb::table($relation['class']); $query = $table->createQuery('r'); if (strlen($search) > 0) { $this->processSearchQuery($query, $search, $table); } $this->search = $search; } else { $query = $this->{$queryBuilder}($pk, $search); } return $query; }
/** * Returns HTML code for a field. * * @param sfModelGeneratorConfigurationField $field The field * * @return string HTML code */ public function renderField($field) { $fieldName = $field->getName(); $html = $this->getColumnGetter($fieldName, true); if ($renderer = $field->getRenderer()) { $html = sprintf('%s ? call_user_func_array(%s, array_merge(array(%s), %s)) : " "', $html, $this->asPhp($renderer), $html, $this->asPhp($field->getRendererArguments())); } else { if ($field->isComponent()) { return sprintf("get_component('%s', '%s', array('type' => 'list', '%s' => \$%s))", $this->getModuleName(), $fieldName, $this->getSingularName(), $this->getSingularName()); } else { if ($field->isPartial()) { return sprintf("get_partial('%s/%s', array('type' => 'list', '%s' => \$%s))", $this->getModuleName(), $fieldName, $this->getSingularName(), $this->getSingularName()); } else { if ('Date' == $field->getType()) { $html = sprintf("false !== strtotime({$html}) ? format_date(%s, \"%s\") : ' '", $html, $field->getConfig('date_format', 'f')); } else { if ('Boolean' == $field->getType()) { $html = "sprintf('<a class=\"s16block s16_%s {field: \\'%s\\'}\" title=\"%s\"></a>', " . $html . " ? 'tick' : 'cross', '" . $fieldName . "', __('Click to edit'))"; } elseif ($relation = $this->table->getRelationHolder()->getLocalByColumnName($fieldName)) { if ('DmMedia' === $relation->getClass()) { $html = '$' . $this->getSingularName() . "->get('" . $relation->getLocalColumnName() . "') ? get_partial('dmMedia/viewLittle', array('object' => \$" . $this->getSingularName() . "->get('" . $relation->getAlias() . "'))) : '-'"; } else { $localModule = $this->moduleManager->getModuleByModel($relation->getClass()); if ($localModule && $localModule->hasAdmin()) { $html = "(\$sf_user->canAccessToModule('{$localModule->getKey()}')\n? _link(\${$this->getSingularName()}->get('{$relation->getAlias()}'))\n->text(\${$this->getSingularName()}->get('{$relation->getAlias()}')->__toString())\n->set('.associated_record.s16right.s16_arrow_up_right_medium')\n: \$" . $this->getSingularName() . "->get('" . $relation->getAlias() . "'))"; } else { $html = "\$" . $this->getSingularName() . "->get('" . $relation->getAlias() . "')"; } $html = '$' . $this->getSingularName() . "->get('" . $relation->getLocalColumnName() . "') ? " . $html . " : '-'"; } } elseif (substr($fieldName, -5) === '_list') { if (!($relation = $this->table->getRelationHolder()->get($alias = dmString::camelize(substr($fieldName, 0, strlen($fieldName) - 5))))) { $relation = $this->table->getRelationHolder()->get($alias = substr($fieldName, 0, strlen($fieldName) - 5)); } if ($relation) { $html = "\$sf_context->getServiceContainer()->mergeParameter('related_records_view.options', array(\n 'record' => \$" . $this->getSingularName() . ",\n 'alias' => '" . $alias . "'\n))->getService('related_records_view')->render()"; } } elseif ('dm_gallery' === $fieldName) { $html = "get_partial('dmMedia/galleryLittle', array('record' => \$" . $this->getSingularName() . "));"; } else { $html = 'htmlentities(dmString::truncate(' . $html . ', ' . $field->getConfig('truncate', sfConfig::get('dm_admin_list_truncate', 120)) . '), ENT_COMPAT, \'UTF-8\')'; if ($this->module->getTable()->isMarkdownColumn($fieldName)) { $html = "str_replace(array('*', '#'), '', " . $html . ")"; } } } } } } if ($field->isLink()) { $html = sprintf("_link('@%s?action=edit&pk='.\$%s->getPrimaryKey())->text(%s)->addClass('link_edit')", $this->module->getUnderscore(), $this->getSingularName(), $html); } return $html; }
protected function createPaginateRelationQuery($field, $relation, $search) { $queryBuilder = 'buildQueryFor' . dmString::camelize($field); if (!method_exists($this, $queryBuilder)) { $table = dmDb::table($relation['class']); $query = $table->createQuery('r'); if (strlen($search) > 0) { $this->processSearchQuery($query, $search, $table); } $this->search = $search; } else { $query = $this->{$queryBuilder}($search); } return $query; }
/** * Builds the Swift message inserting vars in templates * * @return dmMail $this */ public function render() { if (!$this->getTemplate()) { throw new dmMailException('You must call setTemplate() to set a mail template'); } $this->updateTemplate(); $template = $this->getTemplate(); $replacements = $this->getReplacements(); $this->getMessage()->setSubject(strtr($template->subject, $replacements))->setBody(strtr($template->body, $replacements))->setFrom($this->emailListToArray(strtr($template->from_email, $replacements)))->setTo($this->emailListToArray(strtr($template->to_email, $replacements))); foreach (array('cc', 'bcc', 'reply_to', 'sender') as $field) { if ($value = $template->get($field . '_email')) { $processedValue = $this->emailListToArray(strtr($value, $replacements)); $this->getMessage()->{'set' . dmString::camelize($field)}($processedValue); } } $headers = $this->getMessage()->getHeaders(); if ($headers->has('List-Unsubscribe')) { $headers->remove('List-Unsubscribe'); } if ($template->list_unsuscribe) { $headers->addTextHeader('List-Unsubscribe', strtr($template->list_unsuscribe, $replacements)); } $this->isRendered = true; return $this; }
public function renderLinksArray(array $links) { $html = array(); $nbLinks = count($links); $it = 0; foreach ($links as $type => $options) { if (is_string($type)) { $method = 'render' . dmString::camelize($type) . 'Link'; if (++$it === $nbLinks) { $options['last'] = true; } $html[$type] = $this->{$method}($options); } else { $html[$type] = $options; } } return $html; }
// override this method in your form to keep them parent::unsetAutoFields(); } <?php foreach ($this->getMediaRelations() as $mediaRelation) { ?> /** * Creates a DmMediaForm instance for <?php echo $mediaRelation['local'] . "\n"; ?> * * @return DmMediaForm a form instance for the related media */ protected function createMediaFormFor<?php echo dmString::camelize($mediaRelation['local']); ?> () { return DmMediaForRecordForm::factory($this->object, '<?php echo $mediaRelation['local']; ?> ', '<?php echo $mediaRelation['alias']; ?> ', $this->validatorSchema['<?php echo $mediaRelation['local']; ?> ']->getOption('required')); } <?php
<style type="text/css"> div.full_width_image { width: 100%; height: 450px; } div.full_width_image img.panview { cursor: move; } </style> <?php if (!empty($mldProjectImage)) { echo _tag('div.dm_box.big.diagram', _tag('div.title', _tag('h2', 'Project Database' . _link($mldProjectImage)->text(__('Download'))->target('blank'))) . _tag('div.dm_box_inner', _tag('div.full_width_image', _media($mldProjectImage)->set('.panview#mld_project')))); } if (!empty($mldUserImage)) { echo _tag('div.dm_box.big.diagram', _tag('div.title', _tag('h2', 'Diem User Database' . _link($mldUserImage)->text(__('Download'))->target('blank'))) . _tag('div.dm_box_inner', _tag('div.full_width_image', _media($mldUserImage)->set('.panview#mld_user')))); } if (!empty($mldCoreImage)) { echo _tag('div.dm_box.big.diagram', _tag('div.title', _tag('h2', 'Diem Core Database' . _link($mldCoreImage)->text(__('Download'))->target('blank'))) . _tag('div.dm_box_inner', _tag('div.full_width_image', _media($mldCoreImage)->set('.panview#mld_core')))); } foreach ($dicImages as $appName => $image) { if (!$image) { continue; } echo _tag('div.dm_box.big.diagram', _tag('div.title', _tag('h2', dmString::camelize($appName) . ' : Dependency Injection Container' . _link($image)->text(__('Download'))->target('blank'))) . _tag('div.dm_box_inner', ($withDispatcherLinks ? _tag('p.s16.s16_info', _link('+/dmDiagram/index?with_dispatcher_links=0')->text('Hide dispatcher dependencies')) : _tag('p.s16.s16_info', 'As nearly all modules have a reference to dispatcher, these dependencies are hidden. ' . _link('+/dmDiagram/index?with_dispatcher_links=1')->text('Click here to see them'))) . _tag('div.full_width_image', _media($image)->set('.panview#panview' . $appName)))); }
public function getFormOptions() { $method = 'getFormOptionsFor' . dmString::camelize($actionName = $this->action->getActionName()); if (method_exists($this, $method)) { return $this->{$method}(); } else { foreach (array(array('new', 'create'), array('edit', 'update')) as $fallback) { if ($actionName === $fallback[1] && method_exists($this, 'getFormOptionsFor' . $fallback[0])) { return $this->{'getFormOptionsFor' . $fallback[0]}(); } } } return $this->getDefaultFormOptions($actionName); }