Open Sencillo  2015.003
Long live the simplicity of PHP
 All Data Structures Namespaces Functions
lib_identificator.php
1 <?php
2 /*~ mod_identificator.php
3 .---------------------------------------------------------------------------.
4 | Software: Sencillo Libraries Identificator |
5 | Version: 2014.011 |
6 | Contact: ph@mastery.sk |
7 | ------------------------------------------------------------------------- |
8 | Author: Bc. Peter Horváth (original founder) |
9 | Copyright (c) 2014, Bc. Peter Horváth. All Rights Reserved. |
10 | ------------------------------------------------------------------------- |
11 | License: Distributed under the General Public License (GPL) |
12 | http://www.gnu.org/copyleft/gpl.html |
13 | This program is distributed in the hope that it will be useful - WITHOUT |
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
15 | FITNESS FOR A PARTICULAR PURPOSE. |
16 '---------------------------------------------------------------------------'
17 ~*/
27 class library
28 {
29  protected $all_data_sencillo;
30  protected $readsql;
31  protected $files;
32  protected $modules;
33 
34  public $lib;
35 
39  private function createStructure()
40  {
41  $this->lib=array("id"=>array(),
42  "function"=>array(),
43  "boxid"=>array(),
44  "status"=>array());
45  $this->all_data_sencillo=array("left"=>array(),
46  "center"=>array(),
47  "right"=>array(),
48  "foot"=>array(),
49  "admin"=>array());
50  $this->readsql="SELECT * FROM cms_boxid";
51  $this->files = scandir('./fw_libraries/');
52  if(file_exists("./fw_modules/"))
53  {
54  $this->modules = scandir('./fw_modules/');
55  }
56  }
57 
61  private function openFiles()
62  {
63  foreach($this->files as $value)
64  {
65  $test=(($value!='.')&&($value!='..')&&($value!='lib_identificator.php')&&($value!='examples')?true:false);
66 
67  if(($value!='.')&&($value!='..')&&($value!='lib_identificator.php')&&($value!='examples'))
68  {
69  $this->lib['id'][]=$value;
70  }
71  }
72 
73  foreach($this->lib['id'] as $value)
74  {
75  try
76  {
77  //require("./fw_libraries/".$value);
78  $NAME=explode(".",$value);
79  $MOD_DESC=$NAME[0].','.$NAME[1];
80  $this->lib['name'][]=$NAME[2];
81  $this->lib['function'][]=$MOD_DESC;
82  $this->lib['version'][]=$VERSION;
83  $this->lib['status'][]='OK:'.$value;
84  $this->lib['path'][]="./fw_libraries/".$value;
85  }
86  catch(Exception $e)
87  {
88  $this->lib['status']=array('ERROR:'.$value.':'.$e);
89  }
90  }
91  }
92 
96  private function openModules()
97  {
98  foreach($this->modules as $value)
99  {
100  $test=((file_exists("./fw_modules/".$value."/"))&&($value!='.')&&($value!='..')&&($value!='lib_identificator.php')&&($value!='examples')?true:false);
101 
102  if((file_exists("./fw_modules/".$value."/"))&&($value!='.')&&($value!='..')&&($value!='lib_identificator.php')&&($value!='examples'))
103  {
104  $this->lib['id'][]=$value;
105  }
106  }
107 
108  foreach($this->lib['id'] as $value)
109  {
110  try
111  {
112  $this->lib['name'][]=$value;
113  $this->lib['function'][]='custom_module';
114  $this->lib['status'][]='OK:'.$value;
115  $this->lib['path'][]="./fw_modules/".$value."/info_".$value.".php";//information about module
116  $this->lib['path'][]="./fw_modules/".$value."/update_".$value.".php";//update database for module
117  $this->lib['path'][]="./fw_modules/".$value."/install_".$value.".php";//installer
118  $this->lib['path'][]="./fw_modules/".$value."/main_".$value.".php";//main module
119  $this->lib['path'][]="./fw_modules/".$value."/".$value.".php";//basic module
120  }
121  catch(Exception $e)
122  {
123  $this->lib['status'][]='ERROR:'.$value.':'.$e;
124  }
125  }
126  }
127 
131  public function start()
132  {
133  $this->createStructure();
134  $this->openFiles();
135  $this->openModules();
136  }
137 
142  public function export()
143  {
144  return $this->all_data_sencillo;
145  }
146 
151  public function status()
152  {
153  return $this->lib;
154  }
155 
160  public function exportPath()
161  {
162  return array_unique($this->lib['path']);
163  }
164 }
165 ?>