From: Tim Düsterhus Date: Sun, 28 Aug 2011 10:08:45 +0000 (+0200) Subject: Renaming Plugins to camelcase X-Git-Tag: 2.0.0_Beta_1~1810^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bab9f68aaee64504bdc0ccb8bfdc5c135de445b1;p=GitHub%2FWoltLab%2FWCF.git Renaming Plugins to camelcase --- diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmlCheckboxesFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmlCheckboxesFunctionTemplatePlugin.class.php new file mode 100644 index 0000000000..a88bd06958 --- /dev/null +++ b/wcfsetup/install/files/lib/system/template/plugin/HtmlCheckboxesFunctionTemplatePlugin.class.php @@ -0,0 +1,87 @@ + + * @package com.woltlab.wcf + * @subpackage system.template.plugin + * @category Community Framework + */ +class HtmlCheckboxesFunctionTemplatePlugin implements IFunctionTemplatePlugin { + protected $disableEncoding = false; + + /** + * @see wcf\system\template\IFunctionTemplatePlugin::execute() + */ + public function execute($tagArgs, TemplateEngine $tplObj) { + // get options + if (isset($tagArgs['output']) && is_array($tagArgs['output'])) { + if (isset($tagArgs['values']) && is_array($tagArgs['values'])) { + $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']); + } + else { + $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']); + } + } + + if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) { + throw new SystemException("missing 'options' argument in htmlCheckboxes tag"); + } + + if (!isset($tagArgs['name'])) { + throw new SystemException("missing 'name' argument in htmlCheckboxes tag"); + } + + if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) { + $this->disableEncoding = true; + } + else { + $this->disableEncoding = false; + } + + // get selected values + if (isset($tagArgs['selected'])) { + if (!is_array($tagArgs['selected'])) $tagArgs['selected'] = array($tagArgs['selected']); + } + else { + $tagArgs['selected'] = array(); + } + if (!isset($tagArgs['separator'])) { + $tagArgs['separator'] = ''; + } + + // build html + $html = ''; + foreach ($tagArgs['options'] as $key => $value) { + if (!empty($html)) $html .= $tagArgs['separator']; + $html .= ''; + } + + return $html; + } + + /** + * Executes StringUtil::encodeHTML on the given text if disableEncoding is false. + * @see wcf\util\StringUtil::encodeHTML() + */ + protected function encodeHTML($text) { + if (!$this->disableEncoding) { + $text = StringUtil::encodeHTML($text); + } + + return $text; + } +} diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php new file mode 100644 index 0000000000..3bf178b03c --- /dev/null +++ b/wcfsetup/install/files/lib/system/template/plugin/HtmlOptionsFunctionTemplatePlugin.class.php @@ -0,0 +1,128 @@ + + * @package com.woltlab.wcf + * @subpackage system.template.plugin + * @category Community Framework + */ +class HtmlOptionsFunctionTemplatePlugin extends HtmlCheckboxesFunctionTemplatePlugin { + protected $selected = array(); + + /** + * @see wcf\system\template\IFunctionTemplatePlugin::execute() + */ + public function execute($tagArgs, TemplateEngine $tplObj) { + if (isset($tagArgs['output']) && is_array($tagArgs['output'])) { + if (count($tagArgs['output'])) { + if (isset($tagArgs['values']) && is_array($tagArgs['values'])) { + if (count($tagArgs['output']) == count($tagArgs['values'])) { + $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']); + } + else { + $tagArgs['options'] = array(); + } + } + else { + $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']); + } + } + else { + $tagArgs['options'] = array(); + } + } + + if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) { + throw new SystemException("missing 'options' argument in htmlOptions tag"); + } + + if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) { + $this->disableEncoding = true; + } + else { + $this->disableEncoding = false; + } + + // get selected values + $this->selected = array(); + if (isset($tagArgs['selected'])) { + $this->selected = $tagArgs['selected']; + if (!is_array($this->selected)) $this->selected = array($this->selected); + } + + // create option list + $htmloptions = $this->makeOptionGroup(null, $tagArgs['options']); + + // create also a 'select' tag + if (isset($tagArgs['name'])) { + // unset all system vars + unset($tagArgs['options'], $tagArgs['selected'], $tagArgs['output'], $tagArgs['values'], $tagArgs['disableEncoding']); + + // generate 'select' parameters + $params = ''; + foreach ($tagArgs as $key => $value) { + $params .= ' '.$key.'="'.$this->encodeHTML($value).'"'; + } + + $htmloptions = ''."\n".$htmloptions."\n"; + } + + return $htmloptions; + } + + /** + * Makes the html for an option group. + * + * @param string $key + * @param array $values + * @return string html code of an option group + */ + protected function makeOptionGroup($key, $values) { + $html = ''; + if ($key !== null) { + $html = ''."\n"; + } + + foreach ($values as $childKey => $value) { + if (is_array($value)) { + $html .= $this->makeOptionGroup($childKey, $value); + } + else { + $html .= $this->makeOption($childKey, $value); + } + } + + if ($key !== null) { + $html .= "\n"; + } + + return $html; + } + + /** + * Makes the html for an option. + * + * @param string $key + * @param string $value + * @return string html code of an option tag + */ + protected function makeOption($key, $value) { + $value = $this->encodeHTML($value); + return '\n"; + } +} diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmlcheckboxesFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmlcheckboxesFunctionTemplatePlugin.class.php deleted file mode 100644 index 41fe0fff2d..0000000000 --- a/wcfsetup/install/files/lib/system/template/plugin/HtmlcheckboxesFunctionTemplatePlugin.class.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.template.plugin - * @category Community Framework - */ -class HtmlcheckboxesFunctionTemplatePlugin implements IFunctionTemplatePlugin { - protected $disableEncoding = false; - - /** - * @see wcf\system\template\IFunctionTemplatePlugin::execute() - */ - public function execute($tagArgs, TemplateEngine $tplObj) { - // get options - if (isset($tagArgs['output']) && is_array($tagArgs['output'])) { - if (isset($tagArgs['values']) && is_array($tagArgs['values'])) { - $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']); - } - else { - $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']); - } - } - - if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) { - throw new SystemException("missing 'options' argument in htmlCheckboxes tag"); - } - - if (!isset($tagArgs['name'])) { - throw new SystemException("missing 'name' argument in htmlCheckboxes tag"); - } - - if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) { - $this->disableEncoding = true; - } - else { - $this->disableEncoding = false; - } - - // get selected values - if (isset($tagArgs['selected'])) { - if (!is_array($tagArgs['selected'])) $tagArgs['selected'] = array($tagArgs['selected']); - } - else { - $tagArgs['selected'] = array(); - } - if (!isset($tagArgs['separator'])) { - $tagArgs['separator'] = ''; - } - - // build html - $html = ''; - foreach ($tagArgs['options'] as $key => $value) { - if (!empty($html)) $html .= $tagArgs['separator']; - $html .= ''; - } - - return $html; - } - - /** - * Executes StringUtil::encodeHTML on the given text if disableEncoding is false. - * @see wcf\util\StringUtil::encodeHTML() - */ - protected function encodeHTML($text) { - if (!$this->disableEncoding) { - $text = StringUtil::encodeHTML($text); - } - - return $text; - } -} diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmloptionsFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmloptionsFunctionTemplatePlugin.class.php deleted file mode 100644 index e474cc017b..0000000000 --- a/wcfsetup/install/files/lib/system/template/plugin/HtmloptionsFunctionTemplatePlugin.class.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.template.plugin - * @category Community Framework - */ -class HtmloptionsFunctionTemplatePlugin extends HtmlcheckboxesFunctionTemplatePlugin { - protected $selected = array(); - - /** - * @see wcf\system\template\IFunctionTemplatePlugin::execute() - */ - public function execute($tagArgs, TemplateEngine $tplObj) { - if (isset($tagArgs['output']) && is_array($tagArgs['output'])) { - if (count($tagArgs['output'])) { - if (isset($tagArgs['values']) && is_array($tagArgs['values'])) { - if (count($tagArgs['output']) == count($tagArgs['values'])) { - $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']); - } - else { - $tagArgs['options'] = array(); - } - } - else { - $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']); - } - } - else { - $tagArgs['options'] = array(); - } - } - - if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) { - throw new SystemException("missing 'options' argument in htmloptions tag"); - } - - if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) { - $this->disableEncoding = true; - } - else { - $this->disableEncoding = false; - } - - // get selected values - $this->selected = array(); - if (isset($tagArgs['selected'])) { - $this->selected = $tagArgs['selected']; - if (!is_array($this->selected)) $this->selected = array($this->selected); - } - - // create option list - $htmloptions = $this->makeOptionGroup(null, $tagArgs['options']); - - // create also a 'select' tag - if (isset($tagArgs['name'])) { - // unset all system vars - unset($tagArgs['options'], $tagArgs['selected'], $tagArgs['output'], $tagArgs['values'], $tagArgs['disableEncoding']); - - // generate 'select' parameters - $params = ''; - foreach ($tagArgs as $key => $value) { - $params .= ' '.$key.'="'.$this->encodeHTML($value).'"'; - } - - $htmloptions = ''."\n".$htmloptions."\n"; - } - - return $htmloptions; - } - - /** - * Makes the html for an option group. - * - * @param string $key - * @param array $values - * @return string html code of an option group - */ - protected function makeOptionGroup($key, $values) { - $html = ''; - if ($key !== null) { - $html = ''."\n"; - } - - foreach ($values as $childKey => $value) { - if (is_array($value)) { - $html .= $this->makeOptionGroup($childKey, $value); - } - else { - $html .= $this->makeOption($childKey, $value); - } - } - - if ($key !== null) { - $html .= "\n"; - } - - return $html; - } - - /** - * Makes the html for an option. - * - * @param string $key - * @param string $value - * @return string html code of an option tag - */ - protected function makeOption($key, $value) { - $value = $this->encodeHTML($value); - return '\n"; - } -}