Difference between revisions of "API:EPrints/XHTML"

From EPrints Documentation
Jump to: navigation, search
 
Line 8: Line 8:
 
'''EPrints::XHTML''' - XHTML Module
 
'''EPrints::XHTML''' - XHTML Module
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_synopsis -->
 
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
  $xhtml = $repo-&gt;xhtml;
+
<source lang="perl">$xhtml = $repo->xhtml;
 
+
 
  $utf8_string = $xhtml-&gt;to_xhtml( $dom_node, %opts );
+
$utf8_string = $xhtml->to_xhtml( $dom_node, %opts );
 
+
 
  $xhtml_dom_node = $xhtml-&gt;input_field( $name, $value, type =&gt; "text" );
+
$xhtml_dom_node = $xhtml->input_field( $name, $value, type => "text" );
  $xhtml_dom_node = $xhtml-&gt;hidden_field( $name, $value );
+
$xhtml_dom_node = $xhtml->hidden_field( $name, $value );
  $xhtml_dom_node = $xhtml-&gt;text_area_field( $name, $value, rows =&gt; 4 );
+
$xhtml_dom_node = $xhtml->text_area_field( $name, $value, rows => 4 );
  $xhtml_dom_node = $xhtml-&gt;form( "get", $url );
+
$xhtml_dom_node = $xhtml->form( "get", $url );
 
+
 
  $xhtml_dom_node = $xhtml-&gt;data_element( $name, $value, indent =&gt; 4 );
+
$xhtml_dom_node = $xhtml->data_element( $name, $value, indent => 4 );</source>
 
+
 
  $page = $xhtml-&gt;page( %opts );
+
 
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<span style='display:none'>User Comments</span>
+
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_tree -->
 
<!-- Pod2Wiki=head_tree -->
 
===tree()===
 
===tree()===
  $xhtml-&gt;tree([ # dl
+
<pre>  $xhtml-&gt;tree([ # dl
 
     [ "fruit", # dt
 
     [ "fruit", # dt
 
       [ "apple", "orange", ], # ul {li, li}
 
       [ "apple", "orange", ], # ul {li, li}
Line 55: Line 47:
 
   ]);
 
   ]);
 
    
 
    
   &lt;dl&gt;
+
   <dl>
     &lt;dt&gt;fruit&lt;/dt&gt;
+
     <dt>fruit</dt>
     &lt;dd&gt;
+
     <dd>
       &lt;ul&gt;
+
       <ul>
         &lt;li&gt;apple&lt;/li&gt;
+
         <li>apple</li>
         &lt;li&gt;orange&lt;/li&gt;
+
         <li>orange</li>
       &lt;/ul&gt;
+
       </ul>
     &lt;/dd&gt;
+
     </dd>
     &lt;dt&gt;vegetable&lt;/dt&gt;
+
     <dt>vegetable</dt>
     &lt;dd&gt;
+
     <dd>
       &lt;ul&gt;
+
       <ul>
         &lt;li&gt;potato&lt;/li&gt;
+
         <li>potato</li>
         &lt;li&gt;carrot&lt;/li&gt;
+
         <li>carrot</li>
       &lt;/ul&gt;
+
       </ul>
     &lt;/dd&gt;
+
     </dd>
     &lt;dt&gt;animal&lt;/dt&gt;
+
     <dt>animal</dt>
     &lt;dd&gt;
+
     <dd>
       &lt;dl&gt;
+
       <dl>
         &lt;dt&gt;cat&lt;/dt&gt;
+
         <dt>cat</dt>
         &lt;dd&gt;
+
         <dd>
           &lt;ul&gt;
+
           <ul>
             &lt;li&gt;lion&lt;/li&gt;
+
             <li>lion</li>
             &lt;li&gt;leopard&lt;/li&gt;
+
             <li>leopard</li>
           &lt;/ul&gt;
+
           </ul>
         &lt;/dd&gt;
+
         </dd>
       &lt;/dl&gt;
+
       </dl>
     &lt;/dd&gt;
+
     </dd>
   &lt;/dl&gt;
+
   </dl>
   &lt;ul&gt;
+
   <ul>
     &lt;li&gt;soup&lt;/li&gt;
+
     <li>soup</li>
   &lt;/ul&gt;
+
   </ul>
   &lt;p /&gt;
+
   <p /></pre>
 
+
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<span style='display:none'>User Comments</span>
+
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_description -->
 
<!-- Pod2Wiki=head_description -->
 
==DESCRIPTION==
 
==DESCRIPTION==
 
The XHTML object facilitates the creation of XHTML objects.
 
The XHTML object facilitates the creation of XHTML objects.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<!-- Pod2Wiki=head_form -->
<span style='display:none'>User Comments</span>
+
<!-- Edit below this comment -->
+
 
+
 
+
<!-- Pod2Wiki= -->
+
</div>
+
<!-- Pod2Wiki=item_form -->
+
 
===form===
 
===form===
  
$node = $xhtml-&gt;form( $method [, $action] )
+
<source lang="perl">$node = $xhtml->form( $method [, $action] )
 +
 
 +
</source>
 
Returns an XHTML form. If $action isn't defined uses the current URL.
 
Returns an XHTML form. If $action isn't defined uses the current URL.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_input_field -->
<!-- Pod2Wiki=item_input_field -->
+
 
===input_field===
 
===input_field===
  
$node = $xhtml-&gt;input_field( $name, $value, %opts )
+
<source lang="perl">$node = $xhtml->input_field( $name, $value, %opts )
  $node = $xhtml-&gt;input_field( "name", "Bob", type =&gt; "text" );
+
 
 
+
</source>
 +
<pre>  $node = $xhtml-&gt;input_field( "name", "Bob", type =&gt; "text" );</pre>
 +
 
 
Returns an XHTML input field with name $name and value $value. Specify "noenter" to prevent the form being submitted when the user presses the enter key.
 
Returns an XHTML input field with name $name and value $value. Specify "noenter" to prevent the form being submitted when the user presses the enter key.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_hidden_field -->
<!-- Pod2Wiki=item_hidden_field -->
+
 
===hidden_field===
 
===hidden_field===
  
$node = $xhtml-&gt;hidden_field( $name, $value, %opts );
+
<source lang="perl">$node = $xhtml->hidden_field( $name, $value, %opts );
 +
 
 +
</source>
 
Returns an XHTML hidden input field.
 
Returns an XHTML hidden input field.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_action_button -->
<!-- Pod2Wiki=item_action_button -->
+
 
===action_button===
 
===action_button===
  
$node = $xhtml-&gt;action_button( $name, $value, %opts )
+
<source lang="perl">$node = $xhtml->action_button( $name, $value, %opts )
 +
 
 +
</source>
 
Creates a submit button that is styled to an EPrints form button.
 
Creates a submit button that is styled to an EPrints form button.
  
 
$value is the text shown on the button.
 
$value is the text shown on the button.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_action_icon -->
<!-- Pod2Wiki=item_text_area_field -->
+
===action_icon===
 +
 
 +
<source lang="perl">$node = $xhtml->action_icon( $name, $src, %opts )
 +
 
 +
</source>
 +
Creates an image button that links to $src.
 +
 
 +
For usability it is strongly recommended to supply the alt= attribute.
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_text_area_field -->
 
===text_area_field===
 
===text_area_field===
  
$node = $xhtml-&gt;text_area_field( $name, $value, %opts )
+
<source lang="perl">$node = $xhtml->text_area_field( $name, $value, %opts )
 +
 
 +
</source>
 
Returns an XHTML textarea input.
 
Returns an XHTML textarea input.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_data_element -->
<!-- Pod2Wiki=item_data_element -->
+
 
===data_element===
 
===data_element===
  
$node = $xhtml-&gt;data_element( $name, $value, %opts )
+
<source lang="perl">$node = $xhtml->data_element( $name, $value, %opts )
 +
 
 +
</source>
 
Create a new element named $name containing a text node containing $value.
 
Create a new element named $name containing a text node containing $value.
  
Line 193: Line 183:
 
indent - amount of whitespace to indent by
 
indent - amount of whitespace to indent by
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_to_xhtml -->
<!-- Pod2Wiki=item_to_xhtml -->
+
 
===to_xhtml===
 
===to_xhtml===
  
$utf8_string = $xhtml-&gt;to_xhtml( $node, %opts )
+
<source lang="perl">$utf8_string = $xhtml->to_xhtml( $node, %opts )
 +
 
 +
</source>
 
Returns $node as valid XHTML.
 
Returns $node as valid XHTML.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_to_text_dump -->
<!-- Pod2Wiki=item_to_text_dump -->
+
 
===to_text_dump===
 
===to_text_dump===
  
$string = $xhtml-&gt;to_text_dump( $tree, %opts )
+
<source lang="perl">$string = $xhtml->to_text_dump( $tree, %opts )
 +
 
 +
</source>
 
Dumps the XHTML contents of $tree as a utf8 string, stripping tags and converting common HTML layout elements into their plain-text equivalent.
 
Dumps the XHTML contents of $tree as a utf8 string, stripping tags and converting common HTML layout elements into their plain-text equivalent.
  
 
Options:
 
Options:
  
  width - word-wrap after the given number of columns
+
<pre>  width - word-wrap after the given number of columns
 
   show_links - see below
 
   show_links - see below
   preformatted - equivalent to wrapping $tree in &lt;pre&gt;&lt;/pre&gt;
+
   preformatted - equivalent to wrapping $tree in &lt;pre&gt;&lt;/pre&gt;</pre>
 
+
 
 
XHTML elements are removed with the following exceptions:
 
XHTML elements are removed with the following exceptions:
  
Line 237: Line 225:
 
&lt;a href="foo"&gt;bar&lt;/a&gt; will be replaced by "bar &lt;foo&gt;" if '''show_links''' is set.
 
&lt;a href="foo"&gt;bar&lt;/a&gt; will be replaced by "bar &lt;foo&gt;" if '''show_links''' is set.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_box -->
<!-- Pod2Wiki=item_page -->
+
===box===
===page===
+
  
$page = $xhtml-&gt;page( $map, %opts )
+
<source lang="perl">$node = $xhtml->box( $content, %opts )
Returns an EPrints::Page object describing an XHTML page filled out with the templates provided in $map.
+
  
$map is a hash of XHTML DOM fragments. At least "title" and "page" should be defined. Use "links" to add items to the header.
+
</source>
 +
Render a collapsible box.
  
Option "page_id" set's the XML id of the &lt;body&gt; to be "page_YOURID". Useful when you want to use CSS to tweak elements on one page only.
+
Options:
 +
 
 +
* basename = ep_box
 +
: Prefix to use for identifying page elements.
 +
 
 +
* collapsed = 1
 +
: Should the box start rolled up.
 +
 
 +
* show_label
 +
: Label shown when the box is hidden (in the link).
 +
 
 +
* hide_label
 +
: Label shown when the box is visible (in the link).
 +
 
 +
* show_icon_url = "style/images/plus.png"
 +
: The url of the icon to use instead of the [+].
  
Option "template" uses a different template to "default.xml".
+
* hide_icon_url = "style/images/minus.png"
 +
: The url of the icon to use instead of the [-].
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_tabs -->
<!-- Pod2Wiki=item_tabs -->
+
 
===tabs===
 
===tabs===
  
$node = $xhtml-&gt;tabs( $labels, $contents, %opts )
+
<source lang="perl">$node = $xhtml->tabs( $labels, $contents, %opts )
 +
 
 +
</source>
 
Render a tabbed box where:
 
Render a tabbed box where:
  
labels - an array of label XHTML fragments
+
<pre> labels - an array of label XHTML fragments
  contents - an array of content XHTML fragments
+
  contents - an array of content XHTML fragments</pre>
 
+
 
 
Options:
 
Options:
  
base_url - the link to follow under non-JS (default = current URL)
+
<pre> base_url - the link to follow under non-JS (default = current URL)
 
  basename - prefix for tab identifiers (default = "ep_tabs")
 
  basename - prefix for tab identifiers (default = "ep_tabs")
 
  current - index of tab to show first (default = 0)
 
  current - index of tab to show first (default = 0)
 
  expensive - array of tabs to not javascript-link
 
  expensive - array of tabs to not javascript-link
  aliases - map tab index to alias name
+
  aliases - map tab index to alias name</pre>
 
+
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
<span style='display:none'>User Comments</span>
+
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_tree -->
<!-- Pod2Wiki=item_tree -->
+
 
===tree===
 
===tree===
  
$node = $xhtml-&gt;tree( $root, OPTIONS )  
+
<source lang="perl">$node = $xhtml->tree( $root, OPTIONS )
 +
 +
</source>
 
Render a tree using definition lists (DLs).
 
Render a tree using definition lists (DLs).
  
 
Options:
 
Options:
  
  prefix - id to use for the parent &lt;div&gt; and class prefix
+
<pre>  prefix - id to use for the parent &lt;div&gt;
   render_value - custom renderer for values
+
  class
 
+
    HTML class to use for div and prefix for open/close, defaults to
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
    'prefix' option
<span style='display:none'>User Comments</span>
+
   render_value - custom renderer for values</pre>
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_action_list -->
 +
===action_list===
 +
 
 +
<source lang="perl">$node = $xhtml->action_list( $actions, %opts )
 +
 
 +
</source>
 +
Returns an unordered list (&lt;UL&gt;) of actions on a single line. $actions is an array reference of XHTML fragments (e.g. icons or buttons).
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_action_definition_list -->
 +
===action_definition_list===
 +
 
 +
<source lang="perl">$node = $xhtml->action_definition_list( $actions, $definitions, %opts )
 +
 
 +
</source>
 +
Returns a definition list (&lt;DL&gt;) of actions plus their definitions. $actions is an array reference of XHTML fragments (e.g. icons or buttons).
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_doc_type -->
 +
===doc_type===
 +
 
 +
<source lang="perl">$str = $xhtml->doc_type
 +
 
 +
</source>
 +
Returns the default DOCTYPE as a string.
 +
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_copyright -->
 
<!-- Pod2Wiki=head_copyright -->
 
==COPYRIGHT==
 
==COPYRIGHT==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #ccepadding: 0em 1em 0em 1em; font-size: 80%; '>
+
Copyright 2000-2011 University of Southampton.
<span style='display:none'>User Comments</span>
+
 
 +
This file is part of EPrints http://www.eprints.org/.
 +
 
 +
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 +
 
 +
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 +
 
 +
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
 +
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->
+
<!-- Edit below this comment -->

Latest revision as of 09:56, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.3, 3.2) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::XHTML - XHTML Module


SYNOPSIS

$xhtml = $repo->xhtml;
 
$utf8_string = $xhtml->to_xhtml( $dom_node, %opts );
 
$xhtml_dom_node = $xhtml->input_field( $name, $value, type => "text" );
$xhtml_dom_node = $xhtml->hidden_field( $name, $value );
$xhtml_dom_node = $xhtml->text_area_field( $name, $value, rows => 4 );
$xhtml_dom_node = $xhtml->form( "get", $url );
 
$xhtml_dom_node = $xhtml->data_element( $name, $value, indent => 4 );


tree()

  $xhtml->tree([ # dl
    [ "fruit", # dt
      [ "apple", "orange", ], # ul {li, li}
    ],
    [ "vegetable", # dt
      [ "potato", "carrot", ], # ul {li, li}
    ],
    [ "animal", # dt
      [ "cat", # dt
        [ "lion", "leopard", ], # ul {li, li}
      ],
    ],
    "soup", # ul {li}
    $xml->create_element( "p" ), # <p> is appended
  ]);
  
  <dl>
    <dt>fruit</dt>
    <dd>
      <ul>
        <li>apple</li>
        <li>orange</li>
      </ul>
    </dd>
    <dt>vegetable</dt>
    <dd>
      <ul>
        <li>potato</li>
        <li>carrot</li>
      </ul>
    </dd>
    <dt>animal</dt>
    <dd>
      <dl>
        <dt>cat</dt>
        <dd>
          <ul>
            <li>lion</li>
            <li>leopard</li>
          </ul>
        </dd>
      </dl>
    </dd>
  </dl>
  <ul>
    <li>soup</li>
  </ul>
  <p />


DESCRIPTION

The XHTML object facilitates the creation of XHTML objects.


METHODS

form

$node = $xhtml->form( $method [, $action] )

Returns an XHTML form. If $action isn't defined uses the current URL.


input_field

$node = $xhtml->input_field( $name, $value, %opts )
  $node = $xhtml->input_field( "name", "Bob", type => "text" );

Returns an XHTML input field with name $name and value $value. Specify "noenter" to prevent the form being submitted when the user presses the enter key.


hidden_field

$node = $xhtml->hidden_field( $name, $value, %opts );

Returns an XHTML hidden input field.


action_button

$node = $xhtml->action_button( $name, $value, %opts )

Creates a submit button that is styled to an EPrints form button.

$value is the text shown on the button.


action_icon

$node = $xhtml->action_icon( $name, $src, %opts )

Creates an image button that links to $src.

For usability it is strongly recommended to supply the alt= attribute.


text_area_field

$node = $xhtml->text_area_field( $name, $value, %opts )

Returns an XHTML textarea input.


data_element

$node = $xhtml->data_element( $name, $value, %opts )

Create a new element named $name containing a text node containing $value.

Options: indent - amount of whitespace to indent by


to_xhtml

$utf8_string = $xhtml->to_xhtml( $node, %opts )

Returns $node as valid XHTML.


to_text_dump

$string = $xhtml->to_text_dump( $tree, %opts )

Dumps the XHTML contents of $tree as a utf8 string, stripping tags and converting common HTML layout elements into their plain-text equivalent.

Options:

  width - word-wrap after the given number of columns
  show_links - see below
  preformatted - equivalent to wrapping $tree in <pre></pre>

XHTML elements are removed with the following exceptions:

<br /> is replaced by a newline.

<p>...</p> will have a blank line above and below.

<img /> is replaced with the content of the alt attribute.

<hr /> will insert a line of dashes if width is set.

<a href="foo">bar</a> will be replaced by "bar <foo>" if show_links is set.


box

$node = $xhtml->box( $content, %opts )

Render a collapsible box.

Options:

  • basename = ep_box
Prefix to use for identifying page elements.
  • collapsed = 1
Should the box start rolled up.
  • show_label
Label shown when the box is hidden (in the link).
  • hide_label
Label shown when the box is visible (in the link).
  • show_icon_url = "style/images/plus.png"
The url of the icon to use instead of the [+].
  • hide_icon_url = "style/images/minus.png"
The url of the icon to use instead of the [-].


tabs

$node = $xhtml->tabs( $labels, $contents, %opts )

Render a tabbed box where:

 labels - an array of label XHTML fragments
 contents - an array of content XHTML fragments

Options:

 base_url - the link to follow under non-JS (default = current URL)
 basename - prefix for tab identifiers (default = "ep_tabs")
 current - index of tab to show first (default = 0)
 expensive - array of tabs to not javascript-link
 aliases - map tab index to alias name


tree

$node = $xhtml->tree( $root, OPTIONS )

Render a tree using definition lists (DLs).

Options:

  prefix - id to use for the parent <div>
  class
    HTML class to use for div and prefix for open/close, defaults to
    'prefix' option
  render_value - custom renderer for values


action_list

$node = $xhtml->action_list( $actions, %opts )

Returns an unordered list (<UL>) of actions on a single line. $actions is an array reference of XHTML fragments (e.g. icons or buttons).


action_definition_list

$node = $xhtml->action_definition_list( $actions, $definitions, %opts )

Returns a definition list (<DL>) of actions plus their definitions. $actions is an array reference of XHTML fragments (e.g. icons or buttons).


doc_type

$str = $xhtml->doc_type

Returns the default DOCTYPE as a string.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.