From f295465ad40e8c38cea8bcfcb47722426c93f6f0 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 25 Apr 2008 02:43:31 +0000 Subject: [PATCH] [3.1.0] Allow index to be false for config from for creation - Static-ify Printer_ConfigForm's get* functions git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1690 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 2 ++ library/HTMLPurifier/Config.php | 8 ++++---- library/HTMLPurifier/Printer/ConfigForm.php | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 67373440..6d0d2539 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier + HTMLPurifier_HTMLModule->addElement() + HTMLPurifier_HTMLModule->addBlankElement() + HTMLPurifier_LanguageFactory::instance() +# Printer_ConfigForm's get*() functions were static-ified +! Allow index to be false for config from form creation - InterchangeBuilder now alphabetizes its lists - Validation error in configdoc output fixed - Iconv and other encoding errors muted even with custom error handlers that diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php index 0ed8ecc8..fdcd73f5 100644 --- a/library/HTMLPurifier/Config.php +++ b/library/HTMLPurifier/Config.php @@ -403,7 +403,7 @@ class HTMLPurifier_Config * @param $mq_fix Boolean whether or not to enable magic quotes fix * @param $schema Instance of HTMLPurifier_ConfigSchema to use, if not global copy */ - public static function loadArrayFromForm($array, $index, $allowed = true, $mq_fix = true, $schema = null) { + public static function loadArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) { $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $schema); $config = HTMLPurifier_Config::create($ret, $schema); return $config; @@ -413,7 +413,7 @@ class HTMLPurifier_Config * Merges in configuration values from $_GET/$_POST to object. NOT STATIC. * @note Same parameters as loadArrayFromForm */ - public function mergeArrayFromForm($array, $index, $allowed = true, $mq_fix = true) { + 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); } @@ -422,8 +422,8 @@ class HTMLPurifier_Config * Prepares an array from a form into something usable for the more * strict parts of HTMLPurifier_Config */ - public static function prepareArrayFromForm($array, $index, $allowed = true, $mq_fix = true, $schema = null) { - $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : 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); diff --git a/library/HTMLPurifier/Printer/ConfigForm.php b/library/HTMLPurifier/Printer/ConfigForm.php index 6c5c000e..addda702 100644 --- a/library/HTMLPurifier/Printer/ConfigForm.php +++ b/library/HTMLPurifier/Printer/ConfigForm.php @@ -55,14 +55,14 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer /** * Retrieves styling, in case it is not accessible by webserver */ - public function getCSS() { + public static function getCSS() { return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css'); } /** * Retrieves JavaScript, in case it is not accessible by webserver */ - public function getJavaScript() { + public static function getJavaScript() { return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js'); } @@ -86,8 +86,8 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer $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->element('th', 'Directive', array('class' => 'hp-directive')); + $ret .= $this->element('th', 'Value', array('class' => 'hp-value')); $ret .= $this->end('tr'); $ret .= $this->end('thead'); foreach ($all as $ns => $directives) { -- 2.11.4.GIT