]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/htmloutputter.php
A section
[quix0rs-gnu-social.git] / lib / htmloutputter.php
index b3b2a5ae4205eace525e5fab4bfc319e5fe0fb6e..f9245414f29348a90628363a21e7aeee879e6d38 100644 (file)
@@ -52,8 +52,9 @@ define('PAGE_TYPE_PREFS',
  * @author   Sarven Capadisli <csarven@controlyourself.ca>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://laconi.ca/
+ *
  * @see      Action
- * @see      HTMLOutputter
+ * @see      XMLOutputter
  */
 
 class HTMLOutputter extends XMLOutputter
@@ -107,6 +108,8 @@ class HTMLOutputter extends XMLOutputter
         }
 
         header('Content-Type: '.$type);
+        
+        $this->extraHeaders();
 
         $this->startXML('html',
                         '-//W3C//DTD XHTML 1.0 Strict//EN',
@@ -121,6 +124,27 @@ class HTMLOutputter extends XMLOutputter
                                           'lang' => $language));
     }
 
+    /**
+    *  Ends an HTML document
+    *
+    *  @return void
+    */
+    function endHTML()
+    {
+        $this->elementEnd('html');
+        $this->endXML();
+    }
+    
+    /**
+    *  To specify additional HTTP headers for the action
+    *
+    *  @return void
+    */
+    function extraHeaders()
+    {
+        // Needs to be overloaded
+    }
+
     /**
      * Output an HTML text input element
      *
@@ -143,20 +167,17 @@ class HTMLOutputter extends XMLOutputter
 
     function input($id, $label, $value=null, $instructions=null)
     {
-        $this->elementStart('p');
         $this->element('label', array('for' => $id), $label);
         $attrs = array('name' => $id,
                        'type' => 'text',
-                       'class' => 'input_text',
                        'id' => $id);
         if ($value) {
             $attrs['value'] = htmlspecialchars($value);
         }
         $this->element('input', $attrs);
         if ($instructions) {
-            $this->element('span', 'input_instructions', $instructions);
+            $this->element('p', 'form_guide', $instructions);
         }
-        $this->elementEnd('p');
     }
 
     /**
@@ -180,7 +201,6 @@ class HTMLOutputter extends XMLOutputter
     function checkbox($id, $label, $checked=false, $instructions=null,
                       $value='true', $disabled=false)
     {
-        $this->elementStart('p');
         $attrs = array('name' => $id,
                        'type' => 'checkbox',
                        'class' => 'checkbox',
@@ -196,14 +216,13 @@ class HTMLOutputter extends XMLOutputter
         }
         $this->element('input', $attrs);
         $this->text(' ');
-        $this->element('label', array('class' => 'checkbox_label',
+        $this->element('label', array('class' => 'checkbox',
                                       'for' => $id),
                        $label);
         $this->text(' ');
         if ($instructions) {
-            $this->element('span', 'input_instructions', $instructions);
+            $this->element('p', 'form_guide', $instructions);
         }
-        $this->elementEnd('p');
     }
 
     /**
@@ -228,7 +247,6 @@ class HTMLOutputter extends XMLOutputter
     function dropdown($id, $label, $content, $instructions=null,
                       $blank_select=false, $selected=null)
     {
-        $this->elementStart('p');
         $this->element('label', array('for' => $id), $label);
         $this->elementStart('select', array('id' => $id, 'name' => $id));
         if ($blank_select) {
@@ -245,9 +263,8 @@ class HTMLOutputter extends XMLOutputter
         }
         $this->elementEnd('select');
         if ($instructions) {
-            $this->element('span', 'input_instructions', $instructions);
+            $this->element('p', 'form_guide', $instructions);
         }
-        $this->elementEnd('p');
     }
 
     /**
@@ -257,15 +274,14 @@ class HTMLOutputter extends XMLOutputter
      *
      * @param string $id    element ID, must be unique on page
      * @param string $value hidden element value, default null
+     * @param string $name  name, if different than ID
      *
      * @return void
-     *
-     * @todo add a $name parameter
      */
 
-    function hidden($id, $value)
+    function hidden($id, $value, $name=null)
     {
-        $this->element('input', array('name' => $id,
+        $this->element('input', array('name' => ($name) ? $name : $id,
                                       'type' => 'hidden',
                                       'id' => $id,
                                       'value' => $value));
@@ -285,7 +301,6 @@ class HTMLOutputter extends XMLOutputter
 
     function password($id, $label, $instructions=null)
     {
-        $this->elementStart('p');
         $this->element('label', array('for' => $id), $label);
         $attrs = array('name' => $id,
                        'type' => 'password',
@@ -293,9 +308,8 @@ class HTMLOutputter extends XMLOutputter
                        'id' => $id);
         $this->element('input', $attrs);
         if ($instructions) {
-            $this->element('span', 'input_instructions', $instructions);
+            $this->element('p', 'form_guide', $instructions);
         }
-        $this->elementEnd('p');
     }
 
     /**
@@ -304,21 +318,21 @@ class HTMLOutputter extends XMLOutputter
      * @param string $id    element ID, must be unique on page
      * @param string $label text of the button
      * @param string $cls   class of the button, default 'submit'
+     * @param string $name  name, if different than ID
      *
      * @return void
      *
      * @todo add a $name parameter
      */
 
-    function submit($id, $label, $cls='submit')
+    function submit($id, $label, $cls='submit', $name=null, $title=null)
     {
-        $this->elementStart('p');
         $this->element('input', array('type' => 'submit',
                                       'id' => $id,
-                                      'name' => $id,
+                                      'name' => ($name) ? $name : $id,
                                       'class' => $cls,
-                                      'value' => $label));
-        $this->elementEnd('p');
+                                      'value' => $label,
+                                      'title' => $title));
     }
 
     /**
@@ -338,7 +352,6 @@ class HTMLOutputter extends XMLOutputter
 
     function textarea($id, $label, $content=null, $instructions=null)
     {
-        $this->elementStart('p');
         $this->element('label', array('for' => $id), $label);
         $this->element('textarea', array('rows' => 3,
                                          'cols' => 40,
@@ -346,8 +359,7 @@ class HTMLOutputter extends XMLOutputter
                                          'id' => $id),
                        ($content) ? $content : '');
         if ($instructions) {
-            $this->element('span', 'input_instructions', $instructions);
+            $this->element('p', 'form_guide', $instructions);
         }
-        $this->elementEnd('p');
     }
 }