Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file Function.php

Documentation is available at Function.php

  1. <?php
  2.  
  3. // $Id: Function.php,v 1.3 2004/10/08 17:46:47 pmjones Exp $
  4.  
  5.     
  6.     var $conf = array(
  7.         // list separator for params and throws
  8.         'list_sep' => ', ',
  9.         
  10.         // the "main" format string
  11.         'format_main' => '%access %return <b>%name</b> ( %params ) %throws',
  12.         
  13.         // the looped format string for required params
  14.         'format_param' => '%type <i>%descr</i>',
  15.         
  16.         // the looped format string for params with default values
  17.         'format_paramd' => '[%type <i>%descr</i> default %default]',
  18.         
  19.         // the looped format string for throws
  20.         'format_throws' => '<b>throws</b> %type <i>%descr</i>'
  21.     );
  22.     
  23.     /**
  24.     * 
  25.     * Renders a token into text matching the requested format.
  26.     * 
  27.     * @access public
  28.     * 
  29.     * @param array $options The "options" portion of the token (second
  30.     *  element).
  31.     * 
  32.     * @return string The text rendered from the token options.
  33.     * 
  34.     */
  35.     
  36.     function token($options)
  37.     {
  38.         extract($options)// name, access, return, params, throws
  39.         
  40.         // build the baseline output
  41.         $output $this->conf['format_main'];
  42.         $output str_replace('%access'htmlspecialchars($access)$output);
  43.         $output str_replace('%return'htmlspecialchars($return)$output);
  44.         $output str_replace('%name'htmlspecialchars($name)$output);
  45.         
  46.         // build the set of params
  47.         $list = array();
  48.         foreach ($params as $key => $val{
  49.             
  50.             // is there a default value?
  51.             if ($val['default']{
  52.                 $tmp $this->conf['format_paramd'];
  53.             else {
  54.                 $tmp $this->conf['format_param'];
  55.             }
  56.             
  57.             // add the param elements
  58.             $tmp str_replace('%type'htmlspecialchars($val['type'])$tmp);
  59.             $tmp str_replace('%descr'htmlspecialchars($val['descr'])$tmp);
  60.             $tmp str_replace('%default'htmlspecialchars($val['default'])$tmp);
  61.             $list[$tmp;
  62.         }
  63.         
  64.         // insert params into output
  65.         $tmp implode($this->conf['list_sep']$list);
  66.         $output str_replace('%params'$tmp$output);
  67.         
  68.         // build the set of throws
  69.         $list = array();
  70.         foreach ($throws as $key => $val{
  71.                $tmp $this->conf['format_throws'];
  72.             $tmp str_replace('%type'htmlspecialchars($val['type'])$tmp);
  73.             $tmp str_replace('%descr'htmlspecialchars($val['descr'])$tmp);
  74.             $list[$tmp;
  75.         }
  76.         
  77.         // insert throws into output
  78.         $tmp implode($this->conf['list_sep']$list);
  79.         $output str_replace('%throws'$tmp$output);
  80.         
  81.         // close the div and return the output
  82.         $output .= '</div>';
  83.         return "\n$output\n\n";
  84.     }
  85. }
  86. ?>

Documentation generated on Mon, 11 Mar 2019 14:28:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.