noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Package_Repository Class Reference

connect to NOALYSS_PACKAGE and fetch the file web.xml , it displays content of this file , build the appropriate object for installing More...

+ Collaboration diagram for Package_Repository:

Public Member Functions

 __construct ()
 
 can_download ()
 check that NOALYSS_HOME exists and is writable
 
 display_noalyss_info ()
 Get info for Noalyss code : version #, announce, path to the last version.
 
 find_plugin ($p_code)
 return a SimpleXMLElement of the plugin thanks its code, it returns NULL if no plugin is found
 
 find_template ($p_code)
 return a SimpleXMLElement of the db template thanks its code, it returns NULL if no template is found
 
 getContent ()
 
 make_object ($p_type, $p_id)
 
 read_package_xml ($p_file)
 Read xml file from the package.
 
 setContent ($content)
 set content
 

Static Public Member Functions

static getTimeCacheSecond ()
 
static setTimeCacheSecond (int $time_cache_second)
 

Static Public Attributes

static $time_cache_second = 3600
 

Protected Attributes

 $content
 

Detailed Description

connect to NOALYSS_PACKAGE and fetch the file web.xml , it displays content of this file , build the appropriate object for installing

Definition at line 31 of file package_repository.class.php.

Constructor & Destructor Documentation

◆ __construct()

Package_Repository::__construct ( )
See also
package_repository.test.php

Definition at line 40 of file package_repository.class.php.

41 {
42 if ( DEBUGNOALYSS > 1) self::$time_cache_second=1;
43 // Check we can resolve the name
44 $host=parse_url(NOALYSS_PACKAGE_REPOSITORY,PHP_URL_HOST);
45 $file=$_ENV['TMP']."/web.xml";
46
47 if ( file_exists($file) ) {
48 $date_time=new \DateTime();
49 $file_tmstamp=filemtime($file);
50
51 $delta=$date_time->getTimestamp() - $file_tmstamp;
52
53 // if file too old , refresh it
54 if ( $delta > self::$time_cache_second ) {
55 $web_repo = file_get_contents(NOALYSS_PACKAGE_REPOSITORY."/web.xml");
56 $f_file= fopen($file,"w+");
57 fwrite($f_file,$web_repo);
58 fclose($f_file);
59 $this->setContent($web_repo);
60 } else {
61 $this->setContent(file_get_contents($file));
62 }
63 } elseif( gethostbyname($host) != $host) {
64 $content=file_get_contents(NOALYSS_PACKAGE_REPOSITORY."/web.xml");
65 $this->content=simplexml_load_string($content);
66 $file=$_ENV['TMP']."/web.xml";
67 $f_file= fopen($file,"w+");
68 fwrite($f_file,$this->content->saveXML());
69 fclose($f_file);
70 } else {
71 $this->content=NULL;
72 }
73
74
75
76 }
else $card content[$j]['j_montant']
setContent($content)
set content
if( $delta< 0) elseif( $delta==0)

References $content, $delta, $file, content, elseif, and setContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ can_download()

Package_Repository::can_download ( )

check that NOALYSS_HOME exists and is writable

Definition at line 114 of file package_repository.class.php.

115 {
116 $download_dir=NOALYSS_HOME."/tmp";
117 if (is_dir($download_dir)&&is_writable($download_dir))
118 {
119 return TRUE;
120 }
121 return FALSE;
122 }

◆ display_noalyss_info()

Package_Repository::display_noalyss_info ( )

Get info for Noalyss code : version #, announce, path to the last version.

Definition at line 128 of file package_repository.class.php.

129 {
130 global $g_user;
131 if ( $this->content == NULL ) {
132 throw new Exception(_("Problème réseau"),10);
133 }
134 switch ($g_user->lang)
135 {
136 case 'fr_FR.utf8':
137 echo "<pre>";
138 echo $this->content->core->description;
139 echo "</pre>";
140
141 break;
142 case 'en_US.utf8':
143 break;
144 case 'nl_NL.utf8':
145 break;
146 }
147 }
global $g_user
if no group available , then stop
_("actif, passif,charge,...")

References $g_user, _, and content.

◆ find_plugin()

Package_Repository::find_plugin ( $p_code)

return a SimpleXMLElement of the plugin thanks its code, it returns NULL if no plugin is found

Parameters
string$p_codecode of the plugin
Returns
SimpleXMLElement or NULL if not found

Definition at line 154 of file package_repository.class.php.

155 {
156 if ( $this->content == NULL ) {
157 throw new Exception(_("Problème réseau"),10);
158 }
159 $a_plugin=$this->content->xpath('//plugins/plugin');
160 $nb_plugin=count($a_plugin);
161 for ($i=0; $i<$nb_plugin; $i++)
162 {
163 if (trim($a_plugin[$i]->code)==$p_code)
164 {
165 return $a_plugin[$i];
166 }
167 }
168 return NULL;
169 }
$a_plugin
for($e=0;$e< $nb_dirscan;$e++) $nb_plugin

References $a_plugin, $i, $nb_plugin, _, and content.

Referenced by make_object().

◆ find_template()

Package_Repository::find_template ( $p_code)

return a SimpleXMLElement of the db template thanks its code, it returns NULL if no template is found

Parameters
string$p_codecode of the template
Returns
SimpleXMLElement or NULL if not found

Definition at line 177 of file package_repository.class.php.

178 {
179 if ( $this->content == NULL ) {
180 throw new Exception(_("Problème réseau"),10);
181 }
182 $a_template=$this->content->xpath('//database_template/dbtemplate');
184 for ($i=0; $i<$nb_template; $i++)
185 {
186 if (trim($a_template[$i]->code)==$p_code)
187 {
188 return $a_template[$i];
189 }
190 }
191 return NULL;
192 }
if( $xml==NULL) $a_template

References $a_template, $i, $nb_template, _, and content.

Referenced by make_object().

◆ getContent()

Package_Repository::getContent ( )

Definition at line 95 of file package_repository.class.php.

96 {
97 return $this->content;
98 }

References $content.

◆ getTimeCacheSecond()

static Package_Repository::getTimeCacheSecond ( )
static
Returns
int

Definition at line 80 of file package_repository.class.php.

80 : int
81 {
82 return self::$time_cache_second;
83 }

◆ make_object()

Package_Repository::make_object ( $p_type,
$p_id )

Definition at line 194 of file package_repository.class.php.

195 {
196 if ( $this->content == NULL ) {
197 throw new Exception(_("Problème réseau"),10);
198 }
199 switch ($p_type)
200 {
201 case "core":
202 // Create an object to download & install the core
203 $obj=new Package_Core("Noalyss", "Core", $this->content->core->path);
204 return $obj;
205 break;
206 case 'template':
207 // create an object to download & install the template
208 $db=$this->find_template($p_id);
209 if ($db == NULL ) {
210 throw new Exception(_("Modèle non trouvé"),1002);
211 }
212 $obj=new Package_Template($db->name,$db->description,$db->path);
213 return $obj;
214 case 'plugin':
215 // create an object to download & install a plugin
216 $plugin = $this->find_plugin($p_id);
217 if ($plugin==NULL)
218 {
219 throw new Exception(_("Extension non trouvée"), 1001);
220 }
221 $obj=new Package_Plugin($plugin->name,$plugin->description,$plugin->path);
222 return $obj;
223 break;
224 case 'contrib':
225 //create an object to download & install a contrib
226 default:
227 break;
228 }
229 }
catch(Exception $e) $obj
find_template($p_code)
return a SimpleXMLElement of the db template thanks its code, it returns NULL if no template is found
find_plugin($p_code)
return a SimpleXMLElement of the plugin thanks its code, it returns NULL if no plugin is found

References $obj, $p_id, $p_type, _, content, find_plugin(), and find_template().

+ Here is the call graph for this function:

◆ read_package_xml()

Package_Repository::read_package_xml ( $p_file)

Read xml file from the package.

Parameters
string$p_file
Returns
SimpleXMLElement

Definition at line 235 of file package_repository.class.php.

236 {
237 $dom=new DomDocument('1.0');
238 $dom->load($p_file);
239 $xml=simplexml_import_dom($dom);
240 return $xml;
241 }
switch($op2) $xml

References $xml.

◆ setContent()

Package_Repository::setContent ( $content)

set content

Parameters
$contentxml file to be parsed
Returns
Package_Repository

Definition at line 105 of file package_repository.class.php.

106 {
107 $this->content=simplexml_load_string($content);
108 if ( $this->content==false ) throw new Exception ("XML INVALIDE [$content]",EXC_INVALID);
109 return $this;
110 }
const EXC_INVALID
Definition constant.php:358

References $content, content, and EXC_INVALID.

Referenced by __construct().

◆ setTimeCacheSecond()

static Package_Repository::setTimeCacheSecond ( int $time_cache_second)
static
Parameters
int$time_cache_second

Definition at line 88 of file package_repository.class.php.

88 :void
89 {
90 self::$time_cache_second = $time_cache_second;
91
92 }

References $time_cache_second.

Field Documentation

◆ $content

Package_Repository::$content
protected

Definition at line 34 of file package_repository.class.php.

Referenced by __construct(), getContent(), and setContent().

◆ $time_cache_second

Package_Repository::$time_cache_second = 3600
static

Definition at line 35 of file package_repository.class.php.

Referenced by setTimeCacheSecond().


The documentation for this class was generated from the following file: