From: Andrey Kutejko Date: Sat, 22 Jun 2013 11:10:23 +0000 (+0300) Subject: autoload static class function instead of loadFunction X-Git-Tag: 0.5~218 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=70702139bf710e098a8560684193107a4bab7be6;p=ipf.git autoload static class function instead of loadFunction --- diff --git a/ipf/form.php b/ipf/form.php index 3df7f72..ac6f77d 100644 --- a/ipf/form.php +++ b/ipf/form.php @@ -111,7 +111,7 @@ abstract class IPF_Form implements Iterator { $top_errors = (isset($this->errors['__all__'])) ? $this->errors['__all__'] : array(); array_walk($top_errors, 'IPF_Form_htmlspecialcharsArray'); - return new IPF_Template_SafeString(IPF_Form_renderErrorsAsHTML($top_errors), true); + return new IPF_Template_SafeString(IPF_Form::renderErrorsAsHTML($top_errors), true); } public function get_top_errors() @@ -170,7 +170,7 @@ abstract class IPF_Form implements Iterator $hidden_fields[] = $bf; // Not rendered } else { if ($errors_on_separate_row and count($bf_errors)) { - $output[] = sprintf($error_row, IPF_Form_renderErrorsAsHTML($bf_errors)); + $output[] = sprintf($error_row, IPF_Form::renderErrorsAsHTML($bf_errors)); } if (strlen($bf->label) > 0) { $label = htmlspecialchars($bf->label, ENT_COMPAT, 'UTF-8'); @@ -197,7 +197,7 @@ abstract class IPF_Form implements Iterator } $errors = ''; if (!$errors_on_separate_row and count($bf_errors)) { - $errors = IPF_Form_renderErrorsAsHTML($bf_errors); + $errors = IPF_Form::renderErrorsAsHTML($bf_errors); } $output[] = sprintf($normal_row, $errors, $label, $bf->render_w(), $help_text); @@ -205,8 +205,7 @@ abstract class IPF_Form implements Iterator } } if (count($top_errors)) { - $errors = sprintf($error_row, - IPF_Form_renderErrorsAsHTML($top_errors)); + $errors = sprintf($error_row, IPF_Form::renderErrorsAsHTML($top_errors)); array_unshift($output, $errors); } if (count($hidden_fields)) { @@ -308,6 +307,17 @@ abstract class IPF_Form implements Iterator { return (false !== current($this->fields)); } + + public static function renderErrorsAsHTML($errors) + { + if (count($errors)==0) + return ''; + $tmp = array(); + foreach ($errors as $err) { + $tmp[] = '
  • '.$err.'
  • '; + } + return ''; + } } function IPF_Form_htmlspecialcharsArray(&$item, $key) @@ -315,14 +325,3 @@ function IPF_Form_htmlspecialcharsArray(&$item, $key) $item = htmlspecialchars($item, ENT_COMPAT, 'UTF-8'); } -function IPF_Form_renderErrorsAsHTML($errors) -{ - if (count($errors)==0) - return ''; - $tmp = array(); - foreach ($errors as $err) { - $tmp[] = '
  • '.$err.'
  • '; - } - return ''; -} - diff --git a/ipf/form/boundfield.php b/ipf/form/boundfield.php index 8791398..22416d8 100644 --- a/ipf/form/boundfield.php +++ b/ipf/form/boundfield.php @@ -81,8 +81,7 @@ class IPF_Form_BoundField public function fieldErrors() { - IPF::loadFunction('IPF_Form_renderErrorsAsHTML'); - return new IPF_Template_SafeString(IPF_Form_renderErrorsAsHTML($this->errors), true); + return new IPF_Template_SafeString(IPF_Form::renderErrorsAsHTML($this->errors), true); } public function __get($prop)