]> git.andy128k.dev Git - ipf.git/commitdiff
autoload static class function instead of loadFunction
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 22 Jun 2013 11:10:23 +0000 (14:10 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 22 Jun 2013 11:10:23 +0000 (14:10 +0300)
ipf/form.php
ipf/form/boundfield.php

index 3df7f72737e0552c4dbb29e22ed87f1081333490..ac6f77d0ccb43efd9656e39ba95f119917f46270 100644 (file)
@@ -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[] = '<li>'.$err.'</li>';
+        }
+        return '<ul class="errorlist">'.implode("\n", $tmp).'</ul>';
+    }
 }
 
 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[] = '<li>'.$err.'</li>';
-    }
-    return '<ul class="errorlist">'.implode("\n", $tmp).'</ul>';
-}
-
index 8791398975efd85817ae421494e89abdbb240244..22416d8b10272d563f237b97082874fb072b11d3 100644 (file)
@@ -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)