X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fhtmloutputter.php;h=06603ac05485660b206726ad217a769756f9713b;hb=db4ffca5350a11835c2c990f8d77d7cabb365a43;hp=143612b8fd934343bd44a20e6667f041b0a2a52f;hpb=2e5b34269308e7f771f5c44b5fdc46ceb4df1a21;p=quix0rs-gnu-social.git diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 143612b8fd..06603ac054 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -101,27 +101,53 @@ class HTMLOutputter extends XMLOutputter $type = common_negotiate_type($cp, $sp); if (!$type) { - common_user_error(_('This page is not available in a '. - 'media type you accept'), 406); - exit(0); + throw new ClientException(_('This page is not available in a '. + 'media type you accept'), 406); } } header('Content-Type: '.$type); + $this->extraHeaders(); + $this->startXML('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); - // FIXME: correct language for interface - - $language = common_language(); + $language = $this->getLanguage(); $this->elementStart('html', array('xmlns' => 'http://www.w3.org/1999/xhtml', 'xml:lang' => $language, 'lang' => $language)); } + function getLanguage() + { + // FIXME: correct language for interface + return common_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 * @@ -144,20 +170,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); + $attrs['value'] = $value; } $this->element('input', $attrs); if ($instructions) { - $this->element('span', 'input_instructions', $instructions); + $this->element('p', 'form_guide', $instructions); } - $this->elementEnd('p'); } /** @@ -181,13 +204,12 @@ 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', 'id' => $id); if ($value) { - $attrs['value'] = htmlspecialchars($value); + $attrs['value'] = $value; } if ($checked) { $attrs['checked'] = 'checked'; @@ -197,14 +219,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'); } /** @@ -229,7 +250,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) { @@ -238,7 +258,7 @@ class HTMLOutputter extends XMLOutputter foreach ($content as $value => $option) { if ($value == $selected) { $this->element('option', array('value' => $value, - 'selected' => $value), + 'selected' => 'selected'), $option); } else { $this->element('option', array('value' => $value), $option); @@ -246,9 +266,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'); } /** @@ -258,15 +277,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)); @@ -286,7 +304,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', @@ -294,9 +311,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'); } /** @@ -305,21 +321,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)); } /** @@ -339,7 +355,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, @@ -347,8 +362,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'); } }