本文整理汇总了PHP中HTMLPurifier_Config::set方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLPurifier_Config::set方法的具体用法?PHP HTMLPurifier_Config::set怎么用?PHP HTMLPurifier_Config::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLPurifier_Config
的用法示例。
在下文中一共展示了HTMLPurifier_Config::set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setConfigAttribute
private function setConfigAttribute(HTMLPurifier_Config $config, $key, $subkey, $value)
{
if (version_compare($config->version, '4.0.0') >= 0) {
$config->set("{$key}.{$subkey}", $value);
} else {
$config->set($key, $subkey, $value);
}
}
示例2: html5Config
private static function html5Config(\HTMLPurifier_Config $config)
{
$config->set('HTML.DefinitionID', 'jivoo.html5');
$config->set('HTML.DefinitionRev', 1);
$def = $config->maybeGetRawHTMLDefinition();
if ($def) {
$def->addElement('figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common');
$def->addElement('figcaption', 'Inline', 'Flow', 'Common');
}
}
示例3: get_config
/**
* @return \HTMLPurifier_Config
*/
protected function get_config()
{
if (is_null($this->config)) {
$this->config = \HTMLPurifier_Config::createDefault();
$this->config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$this->config->set('HTML.AllowedAttributes', array('a.href', 'a.target', 'img.src', '*.class'));
$this->config->set('Attr.AllowedFrameTargets', array('_blank'));
$this->config->set('HTML.Allowed', 'a,abbr,acronym,b,blockquote,cite,code,dd,div,dl,dt,em,i,li,ol,p,pre,s,span,strike,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,tt,u,ul');
}
return $this->config;
}
示例4: create
/**
* @param string|array|HTMLPurifier_Config $config
* @param HTMLPurifier_ConfigSchema $schema
* @return HTMLPurifier_Config
*/
public static function create($config = null, HTMLPurifier_ConfigSchema $schema = null)
{
if (!$schema instanceof HTMLPurifier_ConfigSchema) {
$schema = HTMLPurifier_ConfigSchema::makeFromSerial();
}
if ($config instanceof HTMLPurifier_Config) {
$configObj = $config;
} else {
$configObj = new HTMLPurifier_Config($schema);
$configObj->set('Core.Encoding', 'UTF-8');
$configObj->set('HTML.Doctype', 'HTML 4.01 Transitional');
if (is_string($config)) {
$configObj->loadIni($config);
} elseif (is_array($config)) {
$configObj->loadArray($config);
}
}
$def = $configObj->getHTMLDefinition(true);
// this finalizes config
HTMLPurifier_HTML5Definition::setup($def);
return $configObj;
}
示例5: register
public function register(Application $app)
{
parent::register($app);
$app['form.secret'] = $app->share(function () use($app) {
return md5('form_secret' . $app['salt']);
});
$app['html_purifier.allowed_elements'] = ['p', 'ul', 'ol', 'li', 'b', 'i', 'strong', 'em', 'img', 'sub', 'sup', 'blockquote', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'address', 'br', 'dl', 'dt', 'dd'];
$app['html_purifier.allowed_attributes'] = ['*.class', 'img.src', 'img.alt', 'a.href', 'a.title', 'td.abbr', 'td.colspan', 'td.rowspan', 'th.abbr', 'th.colspan', 'th.rowspan', 'table.summary'];
$app['html_purifier.config'] = $app->share(function () use($app) {
$config = new \HTMLPurifier_Config(\HTMLPurifier_ConfigSchema::instance());
$config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$config->set('HTML.AllowedElements', implode(',', $app['html_purifier.allowed_elements']));
$config->set('HTML.AllowedAttributes', implode(',', $app['html_purifier.allowed_attributes']));
$config->set('AutoFormat.RemoveEmpty', true);
$config->set('AutoFormat.AutoParagraph', true);
$config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$cachePath = $app['paths.cache'] . '/htmlpurifier';
if (!is_dir($cachePath)) {
mkdir($cachePath, 0777, true);
}
$config->set('Cache.SerializerPath', $cachePath);
return $config;
});
$app['html_purifier'] = $app->share(function () use($app) {
return new \HTMLPurifier($app['html_purifier.config']);
});
$app['form.html_purifier'] = $app->share(function () use($app) {
return new HtmlPurifier($app['html_purifier']);
});
$app['form.html_extension'] = $app->share(function () use($app) {
return new HtmlExtension(new HtmlType($app['form.html_purifier']), new HtmlTypeGuesser($app['annotations.reader']));
});
$app['form.extensions'] = $app->share($app->extend('form.extensions', function (array $extensions) use($app) {
$extensions[] = new DoctrineOrmExtension($app['orm.manager_registry']);
$extensions[] = $app['form.html_extension'];
return $extensions;
}));
$app['form.type.extensions'] = $app->share($app->extend('form.type.extensions', function (array $extensions) use($app) {
$extensions[] = new FormTypeExtension();
$extensions[] = new DateTypeExtension();
$extensions[] = new TimeTypeExtension();
return $extensions;
}));
}
示例6: testInherit
public function testInherit()
{
$this->schema->add('Phantom.Masked', 25, 'int', false);
$this->schema->add('Phantom.Unmasked', 89, 'int', false);
$this->schema->add('Phantom.Latemasked', 11, 'int', false);
$config = new HTMLPurifier_Config($this->schema);
$config->set('Phantom.Masked', 800);
$subconfig = HTMLPurifier_Config::inherit($config);
$config->set('Phantom.Latemasked', 100, 'int', false);
$this->assertIdentical($subconfig->get('Phantom.Masked'), 800);
$this->assertIdentical($subconfig->get('Phantom.Unmasked'), 89);
$this->assertIdentical($subconfig->get('Phantom.Latemasked'), 100);
}
示例7:
function test_finalize()
{
// test finalization
$this->schema->addNamespace('Poem');
$this->schema->add('Poem', 'Meter', 'iambic', 'string', false);
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->set('Poem', 'Meter', 'irregular');
$config->finalize();
$this->expectError('Cannot set directive after finalization');
$config->set('Poem', 'Meter', 'vedic');
$this->expectError('Cannot load directives after finalization');
$config->loadArray(array('Poem.Meter' => 'octosyllable'));
$this->expectError('Cannot load directives after finalization');
$config->loadIni(dirname(__FILE__) . '/ConfigTest-finalize.ini');
}
示例8: postprocessOptions
/**
* Add options to HTML Purifier config
*
* @param \HTMLPurifier_Config $config Config instance
*
* @return \HTMLPurifier_Config
*/
protected static function postprocessOptions($config, $options)
{
if ($options['HTML.SafeIframe'] && empty($options['URI.SafeIframeRegexp'])) {
$config->set('URI.SafeIframeRegexp', '%.*%');
}
return $config;
}
示例9: __construct
public function __construct()
{
$this->config = \HTMLPurifier_Config::createDefault();
$this->config->set('HTML.Allowed', 'p,h2,h3,h4,h5,h6,strong,em,u,strike,a[href],ul,ol,li,img[src|alt]');
}
示例10: fillAllowedElementsConfig
/**
* Configure allowed tags
*
* @param \HTMLPurifier_Config $config
*/
protected function fillAllowedElementsConfig($config)
{
$converter = new TagDefinitionConverter();
if ($this->allowedElements) {
$config->set('HTML.AllowedElements', $converter->getElements($this->allowedElements));
$config->set('HTML.AllowedAttributes', $converter->getAttributes($this->allowedElements));
}
}