Difference between revisions of "API:EPrints/XHTML"

From EPrints Documentation
Jump to: navigation, search
Line 29: Line 29:
 
    
 
    
 
   $page = $xhtml->page( %opts );
 
   $page = $xhtml->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 -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_tree -->
 +
===tree()===
 +
  $xhtml-&gt;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-&gt;create_element( "p" ), # &lt;p&gt; is appended
 +
  ]);
 +
 
 +
  &lt;dl&gt;
 +
    &lt;dt&gt;fruit&lt;/dt&gt;
 +
    &lt;dd&gt;
 +
      &lt;ul&gt;
 +
        &lt;li&gt;apple&lt;/li&gt;
 +
        &lt;li&gt;orange&lt;/li&gt;
 +
      &lt;/ul&gt;
 +
    &lt;/dd&gt;
 +
    &lt;dt&gt;vegetable&lt;/dt&gt;
 +
    &lt;dd&gt;
 +
      &lt;ul&gt;
 +
        &lt;li&gt;potato&lt;/li&gt;
 +
        &lt;li&gt;carrot&lt;/li&gt;
 +
      &lt;/ul&gt;
 +
    &lt;/dd&gt;
 +
    &lt;dt&gt;animal&lt;/dt&gt;
 +
    &lt;dd&gt;
 +
      &lt;dl&gt;
 +
        &lt;dt&gt;cat&lt;/dt&gt;
 +
        &lt;dd&gt;
 +
          &lt;ul&gt;
 +
            &lt;li&gt;lion&lt;/li&gt;
 +
            &lt;li&gt;leopard&lt;/li&gt;
 +
          &lt;/ul&gt;
 +
        &lt;/dd&gt;
 +
      &lt;/dl&gt;
 +
    &lt;/dd&gt;
 +
  &lt;/dl&gt;
 +
  &lt;ul&gt;
 +
    &lt;li&gt;soup&lt;/li&gt;
 +
  &lt;/ul&gt;
 +
  &lt;p /&gt;
 
    
 
    
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 90: Line 148:
 
  $node = $xhtml-&gt;hidden_field( $name, $value, %opts );
 
  $node = $xhtml-&gt;hidden_field( $name, $value, %opts );
 
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 -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_action_button -->
 +
===action_button===
 +
 +
$node = $xhtml-&gt;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.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 204: Line 277:
 
  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
 +
aliases - map tab index to alias name
 
    
 
    
 +
<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 -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_tree -->
 +
===tree===
 +
 +
$node = $xhtml-&gt;tree( $root [, OPTIONS ] )
 +
Render a tree using a combination of definition lists (DLs) and unordered lists (ULs).
 +
 +
Options:
 +
 +
  render_li - custom render method for leaf nodes
 +
  render_dt - custom render method for root elements
 +
 
 +
<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 -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_copyright -->
 +
==COPYRIGHT==
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<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>
 
<span style='display:none'>User Comments</span>

Revision as of 10:46, 25 August 2011

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.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::XHTML - XHTML Module

User Comments


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 );
 
 $page = $xhtml->page( %opts );
 

User Comments


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 />
 

User Comments


DESCRIPTION

The XHTML object facilitates the creation of XHTML objects.

User Comments


METHODS

User Comments


form

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

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

User Comments


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.

User Comments


hidden_field

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

Returns an XHTML hidden input field.

User Comments


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.

User Comments


text_area_field

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

Returns an XHTML textarea input.

User Comments


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

User Comments


to_xhtml

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

Returns $node as valid XHTML.

User Comments


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.

User Comments


page

$page = $xhtml->page( $map, %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.

Option "page_id" set's the XML id of the <body> to be "page_YOURID". Useful when you want to use CSS to tweak elements on one page only.

Option "template" uses a different template to "default.xml".

User Comments


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
 

User Comments


tree

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

Render a tree using a combination of definition lists (DLs) and unordered lists (ULs).

Options:

 render_li - custom render method for leaf nodes
 render_dt - custom render method for root elements
 

User Comments


COPYRIGHT

User Comments