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.4 2004/10/08 17:46:47 pmjones Exp $
  4.  
  5.  
  6.     var $regex = '/^(\<function\>)\n(.+)\n(\<\/function\>)(\s|$)/Umsi';
  7.     
  8.     function process(&$matches)
  9.     {
  10.         // default options
  11.         $opts = array(
  12.             'name' => null,
  13.             'access' => null,
  14.             'return' => null,
  15.             'params' => array(),
  16.             'throws' => array()
  17.         );
  18.         
  19.         // split apart the markup lines and loop through them
  20.         $lines explode("\n"$matches[2]);
  21.         foreach ($lines as $line{
  22.             
  23.             // skip blank lines
  24.             if (trim($line== ''{
  25.                 continue;
  26.             }
  27.             
  28.             // find the first ':' on the line; the left part is the 
  29.             // type, the right part is the value. skip lines without
  30.             // a ':' on them.
  31.             $pos strpos($line':');
  32.             if ($pos === false{
  33.                 continue;
  34.             }
  35.             
  36.             // $type is the line type: name, access, return, param, throws
  37.             // 012345678901234
  38.             // name: something
  39.             $type trim(substr($line0$pos));
  40.             $val trim(substr($line$pos+1));
  41.             
  42.             switch($type{
  43.             
  44.             case 'a':
  45.             case 'access':
  46.                 $opts['access'$val;
  47.                 break;
  48.                 
  49.             case 'n':
  50.             case 'name':
  51.                 $opts['name'$val;
  52.                 break;
  53.                 
  54.             case 'p':
  55.             case 'param':
  56.                 $tmp explode(','$val);
  57.                 $k count($tmp);
  58.                 if ($k == 1{
  59.                     $opts['params'][= array(
  60.                         'type' => $tmp[0],
  61.                         'descr' => null,
  62.                         'default' => null
  63.                     );
  64.                 elseif ($k == 2{
  65.                     $opts['params'][= array(
  66.                         'type' => $tmp[0],
  67.                         'descr' => $tmp[1],
  68.                         'default' => null
  69.                     );
  70.                 else {
  71.                     $opts['params'][= array(
  72.                         'type' => $tmp[0],
  73.                         'descr' => $tmp[1],
  74.                         'default' => $tmp[2]
  75.                     );
  76.                 }
  77.                 break;
  78.             
  79.             case 'r':
  80.             case 'return':
  81.             case 'returns':
  82.                 $opts['return'$val;
  83.                 break;
  84.             
  85.             case 't':
  86.             case 'throws':
  87.                 $tmp explode(','$val);
  88.                 $k count($tmp);
  89.                 if ($k == 1{
  90.                     $opts['throws'][= array(
  91.                         'type' => $tmp[0],
  92.                         'descr' => null
  93.                     );
  94.                 else {
  95.                     $opts['throws'][= array(
  96.                         'type' => $tmp[0],
  97.                         'descr' => $tmp[1]
  98.                     );
  99.                 }
  100.                 break;
  101.         
  102.             default:
  103.                 $opts[$type$val;
  104.                 break;
  105.             
  106.             }
  107.         }
  108.         
  109.         // add the token back in place
  110.         return $this->wiki->addToken($this->rule$opts$matches[4];
  111.     }
  112. }
  113.  
  114. ?>

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