![]() |
Xataface 2.0
Xataface Application Framework
|
00001 <?php 00002 00003 class Dataface_HelpTool { 00004 00005 00006 var $contents; 00007 00008 public static function &getInstance(){ 00009 static $instance = 0; 00010 if ( !is_object($instance) ) $instance = new Dataface_HelpTool(); 00011 return $instance; 00012 } 00013 00014 function getContents($path=null){ 00015 if ( !isset($this->contents) ){ 00016 $this->contents = array('Users'=>array(),'Administrators'=>array(),'Developers'=>array()); 00017 00018 } 00019 00020 } 00021 00022 function createSection($name, $url, $path, $description='', $target='User'){ 00023 return array('name'=>$name,'url'=>$url,'path'=>$path,'description'=>$description,'target'=>$target); 00024 } 00025 00026 function buildSection($path, $url){ 00027 if ( is_readable($path) and is_file($path) ){ 00028 $name = ucwords(str_replace('_',' ',basename($path))); 00029 $description = ''; 00030 $target = 'User'; 00031 00032 $fh = fopen($path,'r'); 00033 $beginning = fread($fh, 1024); 00034 fclose($fh); 00035 00036 00037 00038 if ( preg_match('/<title>(.*?)</title>/i', $beginning, $matches) ){ 00039 $name = $matches[1]; 00040 } 00041 if ( preg_match('/<meta name="description" content="([^"]+)".*?>/is', $beginning, $matches) ){ 00042 $description = $matches[1]; 00043 } 00044 if ( preg_match('/<meta name="target-audience" content="([^"]+)".*?>/is', $beginning, $matches) ){ 00045 $target = $matches[1]; 00046 } 00047 00048 return $this->createSection($name, $url, $path, $description, $target); 00049 00050 } else { 00051 return null; 00052 } 00053 00054 } 00055 00056 function getDocRootForLanguage($docRoot, $lang=null){ 00057 if ( !isset($lang) ){ 00058 $app =& Dataface_Application::getInstance(); 00059 if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang']; 00060 } 00061 if (is_dir($docRoot.'/'.$lang) and is_readable($docRoot.'/'.$lang) ){ 00062 return $docRoot.'/'.$lang; 00063 } 00064 return $docRoot; 00065 } 00066 00067 function getModuleDocRoot($moduleName, $lang=null){ 00068 if ( !isset($lang) ){ 00069 $app =& Dataface_Application::getInstance(); 00070 if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang']; 00071 } 00072 $moduleName2 = preg_replace('/^modules_/','',$moduleName); 00073 $docsDir = DATAFACE_PATH.'modules/'.$moduleName2.'/docs'; 00074 return $this->getDocRootForLanguage($docsDir, $lang); 00075 } 00076 00077 function getTableDocRoot($tablename, $lang=null){ 00078 if ( !isset($lang) ){ 00079 $app =& Dataface_Application::getInstance(); 00080 if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang']; 00081 } 00082 $docsDir = DATAFACE_SITE_PATH.'tables/'.$tablename.'/docs'; 00083 return $this->getDocRootForLanguage($docsDir, $lang); 00084 } 00085 00086 function getApplicationDocRoot($lang=null){ 00087 if ( !isset($lang) ){ 00088 $app =& Dataface_Application::getInstance(); 00089 if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang']; 00090 } 00091 $docsDir = DATAFACE_SITE_PATH.'/docs'; 00092 return $this->getDocRootForLanguage($docsDir, $lang); 00093 } 00094 00095 00096 function getDatafaceDocRoot($lang=null){ 00097 if ( !isset($lang) ){ 00098 $app =& Dataface_Application::getInstance(); 00099 if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang']; 00100 } 00101 $docsDir = DATAFACE_PATH.'/docs'; 00102 return $this->getDocRootForLanguage($docsDir, $lang); 00103 } 00104 00105 00106 function getContents($path){ 00107 00108 } 00109 00110 00111 00112 00113 00114 00115 00116 }