當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTMLPurifier_Config::prepareArrayFromForm方法代碼示例

本文整理匯總了PHP中HTMLPurifier_Config::prepareArrayFromForm方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTMLPurifier_Config::prepareArrayFromForm方法的具體用法?PHP HTMLPurifier_Config::prepareArrayFromForm怎麽用?PHP HTMLPurifier_Config::prepareArrayFromForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTMLPurifier_Config的用法示例。


在下文中一共展示了HTMLPurifier_Config::prepareArrayFromForm方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: mergeArrayFromForm

 /**
  * Merges in configuration values from $_GET/$_POST to object. NOT STATIC.
  *
  * @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
  */
 public function mergeArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true)
 {
     $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def);
     $this->loadArray($ret);
 }
開發者ID:dingdong2310,項目名稱:g5_theme,代碼行數:13,代碼來源:HTMLPurifier.standalone.php

示例3: 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


注:本文中的HTMLPurifier_Config::prepareArrayFromForm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。