noalyss Version-9
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
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 More...
 
 display_noalyss_info ()
 Get info for Noalyss code : version #, announce, path to the last version. More...
 
 find_plugin ($p_code)
 return a SimpleXMLElement of the plugin thanks its code, it returns NULL if no plugin is found More...
 
 find_template ($p_code)
 return a SimpleXMLElement of the db template thanks its code, it returns NULL if no template is found More...
 
 getContent ()
 
 make_object ($p_type, $p_id)
 
 read_package_xml ($p_file)
 Read xml file from the package. More...
 
 setContent ($content)
 set content More...
 

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

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

◆ display_noalyss_info()

Package_Repository::display_noalyss_info ( )

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

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

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

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 153 of file package_repository.class.php.

154 {
155 if ( $this->content == NULL ) {
156 throw new Exception(_("Problème réseau"),10);
157 }
158 $a_plugin=$this->content->xpath('//plugins/plugin');
159 $nb_plugin=count($a_plugin);
160 for ($i=0; $i<$nb_plugin; $i++)
161 {
162 if (trim($a_plugin[$i]->code)==$p_code)
163 {
164 return $a_plugin[$i];
165 }
166 }
167 return NULL;
168 }
$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 176 of file package_repository.class.php.

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

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

Referenced by make_object().

◆ getContent()

Package_Repository::getContent ( )

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

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

References $content.

◆ getTimeCacheSecond()

static Package_Repository::getTimeCacheSecond ( )
static
Returns
int

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

79 : int
80 {
82 }

References $time_cache_second.

◆ make_object()

Package_Repository::make_object (   $p_type,
  $p_id 
)

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

194 {
195 if ( $this->content == NULL ) {
196 throw new Exception(_("Problème réseau"),10);
197 }
198 switch ($p_type)
199 {
200 case "core":
201 // Create an object to download & install the core
202 $obj=new Package_Core("Noalyss", "Core", $this->content->core->path);
203 return $obj;
204 break;
205 case 'template':
206 // create an object to download & install the template
207 $db=$this->find_template($p_id);
208 if ($db == NULL ) {
209 throw new Exception(_("Modèle non trouvé"),1002);
210 }
211 $obj=new Package_Template($db->name,$db->description,$db->path);
212 return $obj;
213 case 'plugin':
214 // create an object to download & install a plugin
215 $plugin = $this->find_plugin($p_id);
216 if ($plugin==NULL)
217 {
218 throw new Exception(_("Extension non trouvée"), 1001);
219 }
220 $obj=new Package_Plugin($plugin->name,$plugin->description,$plugin->path);
221 return $obj;
222 break;
223 case 'contrib':
224 //create an object to download & install a contrib
225 default:
226 break;
227 }
228 }
Class Package Core to install the core , if possible.
Manage the installation of plug.
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
Show , download and install template database for accountancy from the Package repository.

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 234 of file package_repository.class.php.

235 {
236 $dom=new DomDocument('1.0');
237 $dom->load($p_file);
238 $xml=simplexml_import_dom($dom);
239 return $xml;
240 }
switch($op2) $xml
Definition: ajax_card.php:806
$dom
Definition: xml.php:15

References $dom, and $xml.

◆ setContent()

Package_Repository::setContent (   $content)

set content

Parameters
$contentxml file to be parsed
Returns
Package_Repository

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

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

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 87 of file package_repository.class.php.

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

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 getTimeCacheSecond(), and setTimeCacheSecond().


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