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

Source for file common.inc.php

Documentation is available at common.inc.php

  1. <?php
  2. /**
  3.  * Common information needed by all portions of the application
  4.  *
  5.  * phpDocumentor :: automatic documentation generator
  6.  * 
  7.  * PHP versions 4 and 5
  8.  *
  9.  * Copyright (c) 2001-2006 Gregory Beaver
  10.  * 
  11.  * LICENSE:
  12.  * 
  13.  * This library is free software; you can redistribute it
  14.  * and/or modify it under the terms of the GNU Lesser General
  15.  * Public License as published by the Free Software Foundation;
  16.  * either version 2.1 of the License, or (at your option) any
  17.  * later version.
  18.  * 
  19.  * This library is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22.  * Lesser General Public License for more details.
  23.  * 
  24.  * You should have received a copy of the GNU Lesser General Public
  25.  * License along with this library; if not, write to the Free Software
  26.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27.  *
  28.  * @package    phpDocumentor
  29.  * @author     Greg Beaver <cellog@php.net>
  30.  * @copyright  2001-2006 Gregory Beaver
  31.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  32.  * @version    CVS: $Id: common.inc.php,v 1.11 2007/06/01 19:48:47 ashnazg Exp $
  33.  * @filesource
  34.  * @link       http://www.phpdoc.org
  35.  * @link       http://pear.php.net/PhpDocumentor
  36.  * @see        parserDocBlock, parserInclude, parserPage, parserClass
  37.  * @see        parserDefine, parserFunction, parserMethod, parserVar
  38.  * @since      1.0rc1
  39.  */
  40. /** phpDocumentor version */
  41. if ('@PEAR-DIR@' != '@'.'PEAR-DIR@')
  42. {
  43.     /** @ignore */
  44.     define("PHPDOCUMENTOR_VER","@VER@");
  45. else {
  46.     define("PHPDOCUMENTOR_VER","1.4.0a2");
  47. }
  48. /** phpDocumentor version */
  49. define("PHPDOCUMENTOR_WEBSITE","http://www.phpdoc.org");
  50. define('SMART_PATH_DELIMITER'DIRECTORY_SEPARATOR )// set the correct path delimiter
  51. define('tokenizer_ext'extension_loaded('tokenizer'&& version_compare(phpversion(),"4.3.0",">="));
  52. // we just replace all the \ with / so that we can just operate on /
  53. define('PATH_DELIMITER''/' )// set the correct path delimiter
  54. define('PHPDOCUMENTOR_WINDOWS',substr(PHP_OS03== 'WIN');
  55. define('_IN_PHP5'phpversion(== '5.0.0RC1-dev' || phpversion(== '5.0.0RC2-dev' ||
  56.     version_compare(phpversion()'5.0.0''ge'));
  57. if ('@VER@' != '@'.'VER@')
  58. {
  59.     if (_IN_PHP5{
  60.         require_once 'PhpDocumentor/phpDocumentor/clone5.inc.php';
  61.     else {
  62.         require_once 'PhpDocumentor/phpDocumentor/clone.inc.php';
  63.     }
  64. else {
  65.     if (_IN_PHP5{
  66.         require_once dirname(__FILE__'/clone5.inc.php';
  67.     else {
  68.         require_once dirname(__FILE__'/clone.inc.php';
  69.     }
  70. }
  71. if (isset($_SERVER['argv'])) {
  72.     $argv $_SERVER['argv'];
  73.     $argc $_SERVER['argc'];
  74. }
  75.  
  76. /** used in phpdoc.php and new_phpdoc.php */
  77. function phpDocumentor_ConfigFileList($directory)
  78. {
  79.     $ret = array();
  80.     if (@is_dir($directory))
  81.     {
  82.         $ret = array();
  83.         $d @dir($directory)// thanks to Jason E Sweat (jsweat@users.sourceforge.net) for fix
  84.         while($d && $entry=$d->read())
  85.         {
  86.             $getentry = false;
  87.             if (strcmp($entry,"."!= 0 && strcmp($entry,".."!= 0)
  88.             {
  89.                 if (substr($entry,0,1!= "."$getentry = true;
  90.             }
  91.             if ($getentry == true)
  92.             {
  93.                 if (strpos($entry,'.ini'))
  94.                 if (is_file($directory PATH_DELIMITER . $entry))
  95.                 {
  96.                     $ret[str_replace('.ini','',$entry);
  97.                 }
  98.             }
  99.         }
  100.         if ($d$d->close();
  101.     else
  102.     {
  103.     }
  104.     return $ret;
  105. }
  106.  
  107.  
  108. /**
  109.  * Parse an .ini file
  110.  * 
  111.  * Works like {@link parse_ini_file}, except it will take a section like:
  112.  *
  113.  * <pre>
  114.  * [MYVAR]
  115.  * value1
  116.  * value2
  117.  * value3
  118.  * </pre>
  119.  *
  120.  * and return an associative array(MYVAR => array(value1, value2, value3))
  121.  * @return array 
  122.  * @param string full path to the ini file
  123.  * @param boolean add an associative index for each section [in brackets]
  124.  */
  125. function phpDocumentor_parse_ini_file($filename$process_sections = false)
  126. {
  127.     $ini_array = array();
  128.     $sec_name "";
  129.     $lines @file($filename);
  130.     if!$linesreturn $lines;
  131.     foreach($lines as $line)
  132.     {
  133.         // code by Greg Beaver, ignore comments
  134.         if ($line[0== ';'continue;
  135.         $line trim($line);
  136.         
  137.         if($line == "")
  138.         {
  139.             continue;
  140.         }
  141.         if($line[0== "[" && $line[strlen($line- 1== "]")
  142.         {
  143.             $sec_name substr($line1strlen($line- 2);
  144.         else
  145.         {
  146.             if (strpos($line,"="))
  147.             {
  148.                 $pos strpos($line"=");
  149.                 $property trim(substr($line0$pos));
  150.                 // code by Greg Beaver
  151.                 if (substr($property01== '"' && substr($property-1== '"'{
  152.                     $property stripcslashes(substr($property,1,count($property- 2));
  153.                 }
  154.                 $value trim(substr($line$pos + 1));
  155.                 if ($value == 'false'$value = false;
  156.                 if ($value == 'true'$value = true;
  157.                 if (substr($value01== '"' && substr($value,-1== '"')
  158.                 {
  159.                     $value stripcslashes(substr($value,1,count($value- 2));
  160.                 }
  161.                 // done additions
  162.                 
  163.                 if($process_sections)
  164.                 {
  165.                     if ($sec_name != '')
  166.                     $ini_array[$sec_name][$property$value;
  167.                     else
  168.                     $ini_array[$property$value;
  169.                 else
  170.                 {
  171.                     $ini_array[$property$value;
  172.                 }
  173.             else
  174.             {
  175.                 // code by Greg Beaver
  176.                 if (trim($line[0]== ';'continue;
  177.                 if($process_sections)
  178.                 {
  179.                     $ini_array[$sec_name][trim($line);
  180.                 }
  181.                 // done additions
  182.             }
  183.         }
  184.     }
  185.     return $ini_array;
  186. }
  187.  
  188.  
  189. if (!function_exists('array_key_exists'))
  190. {
  191. /** @ignore */
  192. function array_key_exists($key$search)
  193. {
  194.     foreach($search as $keys => $nul)
  195.     {
  196.         if ($key == $keysreturn true;
  197.     }
  198.     return false;
  199. }
  200. }
  201. if (!function_exists('is_a'))
  202. {
  203. /** @ignore */
  204. function is_a($classname$classquery)
  205. {
  206.     $father get_parent_class($classname);
  207.     if (strtolower($father== strtolower($classquery))
  208.     {
  209.         return true;
  210.     elseif (!empty($father))
  211.     {
  212.         return is_a($father$classquery);
  213.     else
  214.     {
  215.         return false;
  216.     }
  217. }
  218. }
  219.  
  220.  
  221. /** Debugging output */
  222. function debug($s)
  223. {
  224.     echo "$s\n";
  225. }
  226.  
  227. /**
  228.  * Returns a formatted var_dump for debugging purposes.
  229.  * @param string $s string to display
  230.  * @param mixed $v variable to display with var_dump()
  231.  * @param mixed $v... unlimited number of additional variables to display with var_dump()
  232.  */
  233. function fancy_debug($s,$v)
  234. {
  235.     if (isset($GLOBALS['dont_debug']&& $GLOBALS['dont_debug']return;
  236.     debug($s."\n\n</pre><blockquote><pre>");
  237.     var_dump($v);
  238.     if (func_num_args()>2)
  239.     {
  240.         for($i=2;$i<func_num_args();$i++)
  241.         {
  242.             $a func_get_arg($i);
  243. //            debug(" ");
  244.             var_dump($a);
  245.         }
  246.     }
  247.     debug("</pre></blockquote><pre>\n\n");
  248. }
  249.  
  250. /**
  251.  * Returns a lower-cased version of get_class for PHP 5
  252.  *
  253.  * get_class() returns case as declared in the file in PHP 5
  254.  */
  255. function phpDocumentor_get_class($object)
  256. {
  257.     return strtolower(get_class($object));
  258. }
  259.  
  260. ?>

Documentation generated on Mon, 11 Mar 2019 15:07:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.