当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLPurifier_Config::getAllowedDirectivesForForm方法代码示例

本文整理汇总了PHP中HTMLPurifier_Config::getAllowedDirectivesForForm方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLPurifier_Config::getAllowedDirectivesForForm方法的具体用法?PHP HTMLPurifier_Config::getAllowedDirectivesForForm怎么用?PHP HTMLPurifier_Config::getAllowedDirectivesForForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLPurifier_Config的用法示例。


在下文中一共展示了HTMLPurifier_Config::getAllowedDirectivesForForm方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Returns HTML output for a configuration form
  * @param $config Configuration object of current form state
  * @param $allowed Optional namespace(s) and directives to restrict form to.
  */
 function render($config, $allowed = true, $render_controls = true)
 {
     $this->config = $config;
     $this->prepareGenerator($config);
     $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed);
     $all = array();
     foreach ($allowed as $key) {
         list($ns, $directive) = $key;
         $all[$ns][$directive] = $config->get($ns, $directive);
     }
     $ret = '';
     $ret .= $this->start('table', array('class' => 'hp-config'));
     $ret .= $this->start('thead');
     $ret .= $this->start('tr');
     $ret .= $this->element('th', 'Directive');
     $ret .= $this->element('th', 'Value');
     $ret .= $this->end('tr');
     $ret .= $this->end('thead');
     foreach ($all as $ns => $directives) {
         $ret .= $this->renderNamespace($ns, $directives);
     }
     if ($render_controls) {
         $ret .= $this->start('tbody');
         $ret .= $this->start('tr');
         $ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls'));
         $ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit'));
         $ret .= '[<a href="?">Reset</a>]';
         $ret .= $this->end('td');
         $ret .= $this->end('tr');
         $ret .= $this->end('tbody');
     }
     $ret .= $this->end('table');
     return $ret;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:39,代码来源:ConfigForm.php

示例2: prepareArrayFromForm

 /**
  * Prepares an array from a form into something usable for the more
  * strict parts of HTMLPurifier_Config
  *
  * @param array $array $_GET or $_POST array to import
  * @param string|bool $index Index/name that the config variables are in
  * @param array|bool $allowed List of allowed namespaces/directives
  * @param bool $mq_fix Boolean whether or not to enable magic quotes fix
  * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy
  *
  * @return array
  */
 public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null)
 {
     if ($index !== false) {
         $array = isset($array[$index]) && is_array($array[$index]) ? $array[$index] : array();
     }
     $mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc();
     $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema);
     $ret = array();
     foreach ($allowed as $key) {
         list($ns, $directive) = $key;
         $skey = "{$ns}.{$directive}";
         if (!empty($array["Null_{$skey}"])) {
             $ret[$ns][$directive] = null;
             continue;
         }
         if (!isset($array[$skey])) {
             continue;
         }
         $value = $mq ? stripslashes($array[$skey]) : $array[$skey];
         $ret[$ns][$directive] = $value;
     }
     return $ret;
 }
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:35,代码来源:HTMLPurifier.standalone.php

示例3: test_getAllowedDirectivesForForm

 public function test_getAllowedDirectivesForForm()
 {
     $this->schema->add('Unused.Unused', 'Foobar', 'string', false);
     $this->schema->add('Partial.Allowed', true, 'bool', false);
     $this->schema->add('Partial.Unused', 'Foobar', 'string', false);
     $this->schema->add('All.Allowed', true, 'bool', false);
     $this->schema->add('All.Blacklisted', 'Foobar', 'string', false);
     // explicitly blacklisted
     $this->schema->add('All.DefinitionID', 'Foobar', 'string', true);
     // auto-blacklisted
     $this->schema->add('All.DefinitionRev', 2, 'int', false);
     // auto-blacklisted
     $input = array('Partial.Allowed', 'All', '-All.Blacklisted');
     $output = HTMLPurifier_Config::getAllowedDirectivesForForm($input, $this->schema);
     $expect = array(array('Partial', 'Allowed'), array('All', 'Allowed'));
     $this->assertEqual($output, $expect);
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:17,代码来源:ConfigTest.php

示例4: updatepurifierconfigAction

 /**
  * @Route("/purifierconfig")
  * @Method("POST")
  *
  * Update HTMLPurifier configuration.
  *
  * @param Request $request
  *
  * @return RedirectResponse
  *
  * @throws AccessDeniedException Thrown if the user doesn't have admin access to the module
  */
 public function updatepurifierconfigAction(Request $request)
 {
     $this->checkCsrfToken();
     // Security check
     if (!SecurityUtil::checkPermission('ZikulaSecurityCenterModule::', '::', ACCESS_ADMIN)) {
         throw new AccessDeniedException();
     }
     // Load HTMLPurifier Classes
     $purifier = SecurityCenterUtil::getpurifier();
     // Update module variables.
     $config = $request->request->get('purifierConfig', null);
     $config = \HTMLPurifier_Config::prepareArrayFromForm($config, false, true, true, $purifier->config->def);
     $allowed = \HTMLPurifier_Config::getAllowedDirectivesForForm(true, $purifier->config->def);
     foreach ($allowed as $allowedDirective) {
         list($namespace, $directive) = $allowedDirective;
         $directiveKey = $namespace . '.' . $directive;
         $def = $purifier->config->def->info[$directiveKey];
         if (isset($config[$namespace]) && array_key_exists($directive, $config[$namespace]) && is_null($config[$namespace][$directive])) {
             unset($config[$namespace][$directive]);
             if (count($config[$namespace]) <= 0) {
                 unset($config[$namespace]);
             }
         }
         if (isset($config[$namespace]) && isset($config[$namespace][$directive])) {
             if (is_int($def)) {
                 $directiveType = abs($def);
             } else {
                 $directiveType = isset($def->type) ? $def->type : 0;
             }
             switch ($directiveType) {
                 case \HTMLPurifier_VarParser::LOOKUP:
                     $value = explode(PHP_EOL, $config[$namespace][$directive]);
                     $config[$namespace][$directive] = array();
                     foreach ($value as $val) {
                         $val = trim($val);
                         if (!empty($val)) {
                             $config[$namespace][$directive][$val] = true;
                         }
                     }
                     if (empty($config[$namespace][$directive])) {
                         unset($config[$namespace][$directive]);
                     }
                     break;
                 case \HTMLPurifier_VarParser::ALIST:
                     $value = explode(PHP_EOL, $config[$namespace][$directive]);
                     $config[$namespace][$directive] = array();
                     foreach ($value as $val) {
                         $val = trim($val);
                         if (!empty($val)) {
                             $config[$namespace][$directive][] = $val;
                         }
                     }
                     if (empty($config[$namespace][$directive])) {
                         unset($config[$namespace][$directive]);
                     }
                     break;
                 case \HTMLPurifier_VarParser::HASH:
                     $value = explode(PHP_EOL, $config[$namespace][$directive]);
                     $config[$namespace][$directive] = array();
                     foreach ($value as $val) {
                         list($i, $v) = explode(':', $val);
                         $i = trim($i);
                         $v = trim($v);
                         if (!empty($i) && !empty($v)) {
                             $config[$namespace][$directive][$i] = $v;
                         }
                     }
                     if (empty($config[$namespace][$directive])) {
                         unset($config[$namespace][$directive]);
                     }
                     break;
             }
         }
         if (isset($config[$namespace]) && array_key_exists($directive, $config[$namespace]) && is_null($config[$namespace][$directive])) {
             unset($config[$namespace][$directive]);
             if (count($config[$namespace]) <= 0) {
                 unset($config[$namespace]);
             }
         }
     }
     $this->setVar('htmlpurifierConfig', serialize($config));
     // clear all cache and compile directories
     ModUtil::apiFunc('ZikulaSettingsModule', 'admin', 'clearallcompiledcaches');
     // the module configuration has been updated successfuly
     $request->getSession()->getFlashBag()->add('status', $this->__('Done! Saved HTMLPurifier configuration.'));
     return new RedirectResponse($this->get('router')->generate('zikulasecuritycentermodule_admin_modifyconfig', array(), RouterInterface::ABSOLUTE_URL));
 }
开发者ID:rmaiwald,项目名称:core,代码行数:99,代码来源:AdminController.php

示例5: updatepurifierconfig

    /**
     * Update HTMLPurifier configuration.
     *
     * @return void
     */
    public function updatepurifierconfig()
    {
        $this->checkCsrfToken();

        // Security check
        if (!SecurityUtil::checkPermission('SecurityCenter::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // Load HTMLPurifier Classes
        $purifier = SecurityCenter_Util::getpurifier();

        // Update module variables.
        $config = FormUtil::getPassedValue('purifierConfig', null, 'POST');
        $config = HTMLPurifier_Config::prepareArrayFromForm($config, false, true, true, $purifier->config->def);
//echo "\r\n\r\n<pre>" . print_r($config, true) . "</pre>\r\n\r\n";

        $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm(true, $purifier->config->def);
        foreach ($allowed as $allowedDirective) {
            list($namespace, $directive) = $allowedDirective;

            $directiveKey = $namespace . '.' . $directive;
            $def = $purifier->config->def->info[$directiveKey];

            if (isset($config[$namespace])
                    && array_key_exists($directive, $config[$namespace])
                    && is_null($config[$namespace][$directive])) {
                unset($config[$namespace][$directive]);

                if (count($config[$namespace]) <= 0) {
                    unset($config[$namespace]);
                }
            }

            if (isset($config[$namespace]) && isset($config[$namespace][$directive])) {
                if (is_int($def)) {
                    $directiveType = abs($def);
                } else {
                    $directiveType = (isset($def->type) ? $def->type : 0);
                }

                switch ($directiveType) {
                    case HTMLPurifier_VarParser::LOOKUP:
                        $value = explode(PHP_EOL, $config[$namespace][$directive]);
                        $config[$namespace][$directive] = array();
                        foreach ($value as $val) {
                            $val = trim($val);
                            if (!empty($val)) {
                                $config[$namespace][$directive][$val] = true;
                            }
                        }
                        if (empty($config[$namespace][$directive])) {
                            unset($config[$namespace][$directive]);
                        }
                        break;
                    case HTMLPurifier_VarParser::ALIST:
                        $value = explode(PHP_EOL, $config[$namespace][$directive]);
                        $config[$namespace][$directive] = array();
                        foreach ($value as $val) {
                            $val = trim($val);
                            if (!empty($val)) {
                                $config[$namespace][$directive][] = $val;
                            }
                        }
                        if (empty($config[$namespace][$directive])) {
                            unset($config[$namespace][$directive]);
                        }
                        break;
                    case HTMLPurifier_VarParser::HASH:
                        $value = explode(PHP_EOL, $config[$namespace][$directive]);
                        $config[$namespace][$directive] = array();
                        foreach ($value as $val) {
                            list($i, $v) = explode(':', $val);
                            $i = trim($i);
                            $v = trim($v);
                            if (!empty($i) && !empty($v)) {
                                $config[$namespace][$directive][$i] = $v;
                            }
                        }
                        if (empty($config[$namespace][$directive])) {
                            unset($config[$namespace][$directive]);
                        }
                        break;
                }
            }

            if (isset($config[$namespace])
                    && array_key_exists($directive, $config[$namespace])
                    && is_null($config[$namespace][$directive])) {
                unset($config[$namespace][$directive]);

                if (count($config[$namespace]) <= 0) {
                    unset($config[$namespace]);
                }
            }
//.........这里部分代码省略.........
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Admin.php

示例6: prepareArrayFromForm

 /**
  * Prepares an array from a form into something usable for the more
  * strict parts of HTMLPurifier_Config
  * @static
  */
 function prepareArrayFromForm($array, $index, $allowed = true, $mq_fix = true)
 {
     $array = isset($array[$index]) && is_array($array[$index]) ? $array[$index] : array();
     $mq = version_compare(PHP_VERSION, '6.0.0', '<') && @get_magic_quotes_gpc() && $mq_fix;
     $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed);
     $ret = array();
     foreach ($allowed as $key) {
         list($ns, $directive) = $key;
         $skey = "{$ns}.{$directive}";
         if (!empty($array["Null_{$skey}"])) {
             $ret[$ns][$directive] = null;
             continue;
         }
         if (!isset($array[$skey])) {
             continue;
         }
         $value = $mq ? stripslashes($array[$skey]) : $array[$skey];
         $ret[$ns][$directive] = $value;
     }
     return $ret;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:26,代码来源:Config.php


注:本文中的HTMLPurifier_Config::getAllowedDirectivesForForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。