noalyss Version-9
package_noalyss.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22/**
23 * @file
24 * @brief package noalyss is the mother class of the class to install and download package
25 */
26/**
27 * @class Package_Noalyss
28 * @brief package noalyss is the mother class of the class to install and download package
29 */
30
31abstract class Package_Noalyss
32{
33
34 private $file;
35 private $path;
36 private $name;
37 private $description;
38
39 function __construct($name, $description, $full_path)
40 {
41 $this->file=basename(trim($full_path));
42 $this->path=dirname(trim($full_path));
43
44 $this->description=$description;
45 $this->name=$name;
46 }
47
48 public function get_path()
49 {
50 return $this->path;
51 }
52
53 public function set_path($path)
54 {
55 $this->path=$path;
56 return $this;
57 }
58
59 public function get_file()
60 {
61 return $this->file;
62 }
63
64 public function get_name()
65 {
66 return $this->name;
67 }
68
69 public function get_description()
70 {
71 return $this->description;
72 }
73
74 public function set_file($file)
75 {
76 $this->file=$file;
77 return $this;
78 }
79
80 public function set_name($name)
81 {
82 $this->name=$name;
83 return $this;
84 }
85
87 {
88 $this->description=$description;
89 return $this;
90 }
91
92 /**
93 * check that NOALYSS_HOME exists and is writable
94 */
95 function can_download()
96 {
97 $download_dir=NOALYSS_HOME."/tmp";
98 if (is_dir($download_dir)&&is_writable($download_dir))
99 {
100 return TRUE;
101 }
102 return FALSE;
103 }
104
105 function download()
106 {
107 if ( ! $this->can_download() ) return false;
108 // If install is writable then download
109
110
111 $full=$this->get_path()."/".$this->get_file();
112 $file = file_get_contents(NOALYSS_PACKAGE_REPOSITORY."/".$full);
113 $fh_file=fopen(NOALYSS_HOME."/tmp/".$this->get_file(),"w+");
114
115 fwrite($fh_file, $file);
116 fclose($fh_file);
117 return TRUE;
118
119 }
120
121 abstract function install();
122
123 abstract function can_install();
124}
$from_poste name
package noalyss is the mother class of the class to install and download package
can_download()
check that NOALYSS_HOME exists and is writable
set_description($description)
__construct($name, $description, $full_path)