public function initialize() { if ($this->configuration instanceof sfApplicationConfiguration) { if (sfNestedCommentConfig::isRoutesRegister()) { if (in_array('sfNestedComment', sfConfig::get('sf_enabled_modules', array()))) { $this->dispatcher->connect('routing.load_configuration', array('sfNestedCommentRouting', 'listenToRoutingLoadConfigurationEvent')); } if (in_array('sfNestedCommentAdmin', sfConfig::get('sf_enabled_modules', array()))) { $this->dispatcher->connect('routing.load_configuration', array('sfNestedCommentRouting', 'addRouteForNestedCommentAdmin')); } } sfOutputEscaper::markClassAsSafe('sfNestedCommentsRenderer'); if (sfNestedCommentConfig::isUsePluginPurifier()) { self::registerHTMLPurifier(); } } }
$t->diag('::unescape() unescapes strings'); $t->is(sfOutputEscaper::unescape('<strong>escaped!</strong>'), '<strong>escaped!</strong>', '::unescape() returns an unescaped string if the value to unescape is a string'); $t->is(sfOutputEscaper::unescape('<strong>échappé</strong>'), '<strong>échappé</strong>', '::unescape() returns an unescaped string if the value to unescape is a string'); $t->diag('::unescape() unescapes arrays'); $input = sfOutputEscaper::escape('esc_entities', array('foo' => '<strong>escaped!</strong>', 'bar' => array('foo' => '<strong>escaped!</strong>'))); $output = sfOutputEscaper::unescape($input); $t->ok(is_array($output), '::unescape() returns an array if the input is a sfOutputEscaperArrayDecorator object'); $t->is($output['foo'], '<strong>escaped!</strong>', '::unescape() unescapes all elements of the original array'); $t->is($output['bar']['foo'], '<strong>escaped!</strong>', '::unescape() is recursive'); $t->diag('::unescape() unescapes objects'); $object = new OutputEscaperTestClass(); $input = sfOutputEscaper::escape('esc_entities', $object); $output = sfOutputEscaper::unescape($input); $t->isa_ok($output, 'OutputEscaperTestClass', '::unescape() returns the original object when a sfOutputEscaperObjectDecorator object is passed'); $t->is($output->getTitle(), '<strong>escaped!</strong>', '::unescape() unescapes all methods of the original object'); $t->is($output->title, '<strong>escaped!</strong>', '::unescape() unescapes all properties of the original object'); $t->is($output->getTitleTitle(), '<strong>escaped!</strong>', '::unescape() is recursive'); $t->isa_ok(sfOutputEscaperIteratorDecorator::unescape(sfOutputEscaper::escape('esc_entities', new DirectoryIterator('.'))), 'DirectoryIterator', '::unescape() unescapes sfOutputEscaperIteratorDecorator objects'); $t->diag('::unescape() does not unescape object marked as being safe'); $t->isa_ok(sfOutputEscaper::unescape(sfOutputEscaper::escape('esc_entities', new sfOutputEscaperSafe(new OutputEscaperTestClass()))), 'OutputEscaperTestClass', '::unescape() returns the original value if it is marked as being safe'); sfOutputEscaper::markClassAsSafe('OutputEscaperTestClass'); $t->isa_ok(sfOutputEscaper::unescape(sfOutputEscaper::escape('esc_entities', new OutputEscaperTestClass())), 'OutputEscaperTestClass', '::unescape() returns the original value if the object class is marked as being safe'); $t->isa_ok(sfOutputEscaper::unescape(sfOutputEscaper::escape('esc_entities', new OutputEscaperTestClassChild())), 'OutputEscaperTestClassChild', '::unescape() returns the original value if one of the object parent class is marked as being safe'); $t->diag('::unescape() do nothing to resources'); $fh = fopen(__FILE__, 'r'); $t->is(sfOutputEscaper::unescape($fh), $fh, '::unescape() do nothing to resources'); $t->diag('::unescape() unescapes mixed arrays'); $object = new OutputEscaperTestClass(); $input = array('foo' => 'bar', 'bar' => sfOutputEscaper::escape('esc_entities', '<strong>bar</strong>'), 'foobar' => sfOutputEscaper::escape('esc_entities', $object)); $output = array('foo' => 'bar', 'bar' => '<strong>bar</strong>', 'foobar' => $object); $t->is(sfOutputEscaper::unescape($input), $output, '::unescape() unescapes values with some escaped and unescaped values');
/** * Listens to the template.filter_parameters event. * * @param sfEvent $event An sfEvent instance * @param array $parameters An array of template parameters to filter * * @return array The filtered parameters array */ public function filterTemplateParameters(sfEvent $event, $parameters) { $parameters['op_config'] = new opConfig(); sfOutputEscaper::markClassAsSafe('opConfig'); $parameters['op_color'] = new opColorConfig(); $table = Doctrine::getTable('SnsTerm'); $application = sfConfig::get('sf_app'); if ($application == 'pc_backend') { $application = 'pc_frontend'; } $table->configure(sfContext::getInstance()->getUser()->getCulture(), $application); if (!$table['member']) { $table->configure('en', $application); } $parameters['op_term'] = $table; sfOutputEscaper::markClassAsSafe('SnsTermTable'); return $parameters; }
/** * Listens to the template.filter_parameters event. * * @param sfEvent $event An sfEvent instance * @param array $parameters An array of template parameters to filter * * @return array The filtered parameters array */ public function filterTemplateParameters(sfEvent $event, $parameters) { $parameters['op_config'] = new opConfig(); sfOutputEscaper::markClassAsSafe('opConfig'); $parameters['op_color'] = new opColorConfig(); $table = Doctrine::getTable('SnsTerm'); $table->configure(sfContext::getInstance()->getUser()->getCulture(), sfConfig::get('sf_app')); $parameters['op_term'] = $table; sfOutputEscaper::markClassAsSafe('SnsTermTable'); return $parameters; }
public function initialize($context, $moduleName, $actionName, $viewName) { $this->moduleName = $moduleName; $this->actionName = $actionName; $this->viewName = $viewName; $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); if (sfConfig::get('sf_logging_enabled')) { $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Initialize view for "%s/%s"', $moduleName, $actionName)))); } sfOutputEscaper::markClassAsSafe('sfForm'); $this->attributeHolder = $this->initializeAttributeHolder(); $this->parameterHolder = new sfParameterHolder(); $this->parameterHolder->add(sfConfig::get('mod_' . strtolower($moduleName) . '_view_param', array())); $request = $context->getRequest(); if (!is_null($format = $request->getRequestFormat())) { if ('html' != $format) { $this->setExtension('.' . $format . $this->getExtension()); } if ($mimeType = $request->getMimeType($format)) { $this->context->getResponse()->setContentType($mimeType); $this->setDecorator(false); } $this->dispatcher->notify(new sfEvent($this, 'view.configure_format', array('format' => $format, 'response' => $context->getResponse(), 'request' => $context->getRequest()))); } $this->configure(); return true; }
public function initialize() { // make the ioMenuItem not be escaped in the template sfOutputEscaper::markClassAsSafe('ioMenuItem'); }