Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
HelpTool.php
Go to the documentation of this file.
1 <?php
2 
4 
5 
6  var $contents;
7 
8  public static function &getInstance(){
9  static $instance = 0;
10  if ( !is_object($instance) ) $instance = new Dataface_HelpTool();
11  return $instance;
12  }
13 
14  function getContents($path=null){
15  if ( !isset($this->contents) ){
16  $this->contents = array('Users'=>array(),'Administrators'=>array(),'Developers'=>array());
17 
18  }
19 
20  }
21 
22  function createSection($name, $url, $path, $description='', $target='User'){
23  return array('name'=>$name,'url'=>$url,'path'=>$path,'description'=>$description,'target'=>$target);
24  }
25 
26  function buildSection($path, $url){
27  if ( is_readable($path) and is_file($path) ){
28  $name = ucwords(str_replace('_',' ',basename($path)));
29  $description = '';
30  $target = 'User';
31 
32  $fh = fopen($path,'r');
33  $beginning = fread($fh, 1024);
34  fclose($fh);
35 
36 
37 
38  if ( preg_match('/<title>(.*?)</title>/i', $beginning, $matches) ){
39  $name = $matches[1];
40  }
41  if ( preg_match('/<meta name="description" content="([^"]+)".*?>/is', $beginning, $matches) ){
42  $description = $matches[1];
43  }
44  if ( preg_match('/<meta name="target-audience" content="([^"]+)".*?>/is', $beginning, $matches) ){
45  $target = $matches[1];
46  }
47 
48  return $this->createSection($name, $url, $path, $description, $target);
49 
50  } else {
51  return null;
52  }
53 
54  }
55 
56  function getDocRootForLanguage($docRoot, $lang=null){
57  if ( !isset($lang) ){
59  if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang'];
60  }
61  if (is_dir($docRoot.'/'.$lang) and is_readable($docRoot.'/'.$lang) ){
62  return $docRoot.'/'.$lang;
63  }
64  return $docRoot;
65  }
66 
67  function getModuleDocRoot($moduleName, $lang=null){
68  if ( !isset($lang) ){
70  if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang'];
71  }
72  $moduleName2 = preg_replace('/^modules_/','',$moduleName);
73  $docsDir = DATAFACE_PATH.'modules/'.$moduleName2.'/docs';
74  return $this->getDocRootForLanguage($docsDir, $lang);
75  }
76 
77  function getTableDocRoot($tablename, $lang=null){
78  if ( !isset($lang) ){
80  if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang'];
81  }
82  $docsDir = DATAFACE_SITE_PATH.'tables/'.$tablename.'/docs';
83  return $this->getDocRootForLanguage($docsDir, $lang);
84  }
85 
86  function getApplicationDocRoot($lang=null){
87  if ( !isset($lang) ){
89  if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang'];
90  }
91  $docsDir = DATAFACE_SITE_PATH.'/docs';
92  return $this->getDocRootForLanguage($docsDir, $lang);
93  }
94 
95 
96  function getDatafaceDocRoot($lang=null){
97  if ( !isset($lang) ){
99  if ( isset($app->_conf['lang']) ) $lang = $app->_conf['lang'];
100  }
101  $docsDir = DATAFACE_PATH.'/docs';
102  return $this->getDocRootForLanguage($docsDir, $lang);
103  }
104 
105 
106  function getContents($path){
107 
108  }
109 
110 
111 
112 
113 
114 
115 
116 }