public function formatter($widget, $inputs) { $plugins = $this->getOption('plugins'); $prefix = $widget->generateId(sprintf($this->widgetSchema->getNameFormat(), $this->pluginFieldKey)) . '_'; $rows = array(); foreach ($inputs as $id => $input) { $name = substr($id, strlen($prefix)); $plugin = $plugins[$name]; $rows[] = $widget->renderContentTag('tr', $widget->renderContentTag('td', $input['input']) . $widget->renderContentTag('td', $input['label']) . $widget->renderContentTag('td', sfWidget::escapeOnce($plugin->getVersion())) . $widget->renderContentTag('td', sfWidget::escapeOnce($plugin->getSummary())) . $widget->renderContentTag('td', $plugin->hasBackend() ? link_to(__('Setting'), $plugin->getName() . '/index') : '')); } return !$rows ? '' : implode($widget->getOption('separator'), $rows); }
</body> </html> END; $waited = <<<END <html> <head> <script type="text/javascript" src="/dynamics/foo.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="/dynamics/foo.css" /> <link rel="stylesheet" type="text/css" media="screen" href="/bar.css" /> <script type="text/javascript" src="/bar.js"></script> </head> <body> <p>Lorem ipsum</p> </body> </html> END; $t->is($manager->filterContent(new sfEvent('lorem', 'event.name'), $content), $waited, '->addSfDynamicsTags() inserts tags at the beginning of <head> if position "prepend" and placeholder not found'); } $t->comment('->getTag()'); $manager = sfDynamics::getManager(); sfWidget::setXhtml(false); $t->is($manager->getTag('foo.js', 'javascript'), '<script type="text/javascript" src="foo.js"></script>', '->getTag() returns a "<script>" tag for the js type'); $t->is($manager->getTag('foo.css', 'stylesheet'), '<link rel="stylesheet" type="text/css" media="all" href="foo.css" >', '->getTag() returns a "<style media="screen">" tag for the css type'); sfWidget::setXhtml(true); $t->is($manager->getTag('foo.css', 'stylesheet'), '<link rel="stylesheet" type="text/css" media="all" href="foo.css" />', '->getTag() uses the sfWidget::getXhtml() config'); try { $manager->getTag('foo.swf', 'swf'); $t->fail('->getTag() throws an exception if type isn’t stylesheet or javascript'); } catch (Exception $e) { $t->pass('->getTag() throws an exception if type isn’t stylesheet or javascript'); }
/** * Renders a HTML content tag. * * The id attribute is added automatically to the array of attributes if none is specified. * If uses for "id_format" option to generate the id. * * @param string $tag The tag name * @param string $content The content of the tag * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * * @return string An HTML tag string */ public function renderContentTag($tag, $content = null, $attributes = array()) { return parent::renderContentTag($tag, $content, $this->fixFormId($attributes)); }
/** * Sets the XHTML generation flag. * * @param bool $boolean true if widgets must be generated as XHTML, false otherwise */ public static function setXhtml($boolean) { self::$xhtml = (bool) $boolean; }
public static function appendMobileInputModeAttributesForFormWidget(sfWidget $widget, $mode = 'alphabet') { $modes = array('hiragana' => 1, 'hankakukana' => 2, 'alphabet' => 3, 'numeric' => 4); if (empty($modes[$mode])) { return false; } $widget->setAttribute('istyle', $modes[$mode]); $widget->setAttribute('mode', $mode); }
public function getTag($url, $type) { switch ($type) { case 'javascript': return sprintf('<script type="text/javascript" src="%s"></script>', $url); case 'stylesheet': return sprintf('<link rel="stylesheet" type="text/css" media="all" href="%s" %s>', $url, sfWidget::isXhtml() ? '/' : ''); default: throw new BadMethodCallException('Invalid asset type.'); } }
$t->diag('::escapeOnce()'); $t->is(sfWidget::escapeOnce('This a > text to "escape"'), 'This a > text to "escape"', '::escapeOnce() escapes an HTML strings'); $t->is(sfWidget::escapeOnce(sfWidget::escapeOnce('This a > text to "escape"')), 'This a > text to "escape"', '::escapeOnce() does not escape an already escaped string'); $t->is(sfWidget::escapeOnce('This a > text to "escape"'), 'This a > text to "escape"', '::escapeOnce() does not escape an already escaped string'); class MyClass { public function __toString() { return 'mycontent'; } } $t->is(sfWidget::escapeOnce(new MyClass()), 'mycontent', '::escapeOnce() converts objects to string'); // ::fixDoubleEscape() $t->diag('::fixDoubleEscape()'); $t->is(sfWidget::fixDoubleEscape(htmlspecialchars(htmlspecialchars('This a > text to "escape"'), ENT_QUOTES, sfWidget::getCharset()), ENT_QUOTES, sfWidget::getCharset()), 'This a > text to "escape"', '::fixDoubleEscape() fixes double escaped strings'); // ::getCharset() ::setCharset() $t->diag('::getCharset() ::setCharset()'); $t->is(sfWidget::getCharset(), 'UTF-8', '::getCharset() returns the charset to use for widgets'); sfWidget::setCharset('ISO-8859-1'); $t->is(sfWidget::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for widgets'); // ::setXhtml() ::isXhtml() $t->diag('::setXhtml() ::isXhtml()'); $w = new MyWidget(); $t->is(sfWidget::isXhtml(), true, '::isXhtml() return true if the widget must returns XHTML tags'); sfWidget::setXhtml(false); $t->is($w->renderTag('input', array('value' => 'Test')), '<input value="Test">', '::setXhtml() changes the value of the XHTML tag'); // ->getJavaScripts() ->getStylesheets() $t->diag('->getJavaScripts() ->getStylesheets()'); $w = new MyWidget(); $t->is($w->getJavaScripts(), array(), '->getJavaScripts() returns an array of stylesheets'); $t->is($w->getStylesheets(), array(), '->getStylesheets() returns an array of JavaScripts');
/** * @see sfProjectConfiguration */ public function initConfiguration() { $configCache = $this->getConfigCache(); // in debug mode, start global timer if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted()) { sfWebDebugPanelTimer::startTime(); } // required core classes for the framework if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && !self::$coreLoaded) { $configCache->import('config/core_compile.yml', false); } $this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); sfAutoload::getInstance()->register(); // load base settings include $configCache->checkConfig('config/settings.yml'); if ($file = $configCache->checkConfig('config/app.yml', true)) { include $file; } if (false !== sfConfig::get('sf_csrf_secret')) { sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret')); } sfWidget::setCharset(sfConfig::get('sf_charset')); sfValidatorBase::setCharset(sfConfig::get('sf_charset')); // force setting default timezone if not set if ($default_timezone = sfConfig::get('sf_default_timezone')) { date_default_timezone_set($default_timezone); } else { if (sfConfig::get('sf_force_default_timezone', true)) { date_default_timezone_set(@date_default_timezone_get()); } } // error settings ini_set('display_errors', $this->isDebug() ? 'on' : 'off'); error_reporting(sfConfig::get('sf_error_reporting')); // initialize plugin configuration objects $this->initializePlugins(); // Disabled by default in symfony 1.1 because it causes problems with Doctrine. // If you want to enable it in your application, just copy the spl_autoload_register() line // in your configuration class. if (0 && $this->isDebug()) { spl_autoload_register(array(sfAutoload::getInstance(), 'autoloadAgain')); } // compress output if (!self::$coreLoaded) { ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); } self::$coreLoaded = true; }
/** * Various initializations. */ public function initConfiguration() { $configCache = $this->getConfigCache(); // in debug mode, start global timer if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted()) { sfWebDebugPanelTimer::startTime(); } // required core classes for the framework if (!$this->isDebug() && !sfConfig::get('sf_test') && !self::$coreLoaded) { $configCache->import('config/core_compile.yml', false); } // autoloader(s) $this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); sfAutoload::getInstance()->register(); if ($this->isDebug()) { sfAutoloadAgain::getInstance()->register(); } // load base settings $this->beforeSettingsConfiguration(); include($configCache->checkConfig('config/settings.yml')); if ($file = $configCache->checkConfig('config/app.yml', true)) { include($file); } if (false !== sfConfig::get('sf_csrf_secret')) { sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret')); } sfWidget::setCharset(sfConfig::get('sf_charset')); sfValidatorBase::setCharset(sfConfig::get('sf_charset')); // force setting default timezone if not set if ($default_timezone = sfConfig::get('sf_default_timezone')) { date_default_timezone_set($default_timezone); } else if (sfConfig::get('sf_force_default_timezone', true)) { date_default_timezone_set(@date_default_timezone_get()); } // error settings ini_set('display_errors', $this->isDebug() ? 'on' : 'off'); error_reporting(sfConfig::get('sf_error_reporting')); // initialize plugin configuration objects $this->initializePlugins(); // compress output if (!self::$coreLoaded) { ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null); } self::$coreLoaded = true; }
<div id="Top"><div class="parts googleCalendarDescBox" style="position: relative;"> <div class="body"> <ul> <li><?php echo __('Schedules fetched from Google are saved and updated in this SNS.'); ?> </li> <li><?php echo __('If the public flag was set to [All Members], those schedules are public to SNS members.'); ?> </li> <li><?php echo __('If the public flag was set to [Participants only scheduled public], those schedules can see the members that have the mail address related to Google Calendar and invited to schedules on Google Calendar. Thus, the all SNS member cannot those schedules.'); ?> </li> <li><?php echo __('Then, the schedules you create are the only target of convert.'); ?> </li> </ul> </div> </div><!-- parts --></div> <?php $options = array('button' => __('Update'), 'title' => __('Fetch from Google Calendar %email%', array('%email%' => sfWidget::escapeOnce($form->getOption('id')))), 'url' => url_for('calendar_api_import')); op_include_form('googleCalendarImportForm', $form, $options);