diff options
author | polo <ordipolo@gmx.fr> | 2022-02-28 02:15:31 +0100 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2022-02-28 02:15:31 +0100 |
commit | abd968a1c573b1862bd0728f0b7b6a88e307900a (patch) | |
tree | ef985fe5757b4516c199a06eb37a5e22f7c5b259 /model | |
parent | f19db76cc3b21785619ffd24bfb34692a3aaa66a (diff) | |
download | melaine-abd968a1c573b1862bd0728f0b7b6a88e307900a.zip |
sauvegarde zip
Diffstat (limited to 'model')
-rw-r--r-- | model/Album.php | 33 | ||||
-rw-r--r-- | model/Article.php | 8 | ||||
-rw-r--r-- | model/Image.php | 5 |
3 files changed, 34 insertions, 12 deletions
diff --git a/model/Album.php b/model/Album.php index 9c90a6b..3f13939 100644 --- a/model/Album.php +++ b/model/Album.php | |||
@@ -7,16 +7,32 @@ class Album extends Article | |||
7 | 7 | ||
8 | public function __construct($page) | 8 | public function __construct($page) |
9 | { | 9 | { |
10 | $this->format = 'json'; // vaut 'html' dans la classe mère | ||
11 | |||
10 | // pour: page, fileCode, time et makeFileList() | 12 | // pour: page, fileCode, time et makeFileList() |
11 | parent::__construct($page); | 13 | parent::__construct($page); |
12 | //$this->page = $page; | ||
13 | //$this->fileCode = ''; // désigne un fichier json et un html | ||
14 | $this->format = 'json'; // vaut 'html' dans la classe mère | ||
15 | //$this->time = time(); | ||
16 | //$this->makeFileList(); | ||
17 | } | 14 | } |
18 | 15 | ||
19 | // GET | 16 | // GET |
17 | public function getAllJSON() // pour la page album | ||
18 | { | ||
19 | // mettre le JSON dans fileList[$i]['content'] | ||
20 | parent::readAll(); | ||
21 | |||
22 | $this->format = 'html'; | ||
23 | |||
24 | for($i = 0; $i < $this->fileListCount; $i++) | ||
25 | { | ||
26 | $content = json_decode($this->fileList[$i]['content'], true); | ||
27 | $this->fileList[$i]['titre'] = $content[0]; | ||
28 | $this->fileList[$i]['annee'] = $content[1]; | ||
29 | $this->fileList[$i]['pochette'] = $content[2]; | ||
30 | $this->fileList[$i]['pochetteMini'] = $content[3]; | ||
31 | } | ||
32 | |||
33 | // on remet comme avant | ||
34 | $this->format = 'json'; | ||
35 | } | ||
20 | 36 | ||
21 | // SET | 37 | // SET |
22 | 38 | ||
@@ -70,6 +86,7 @@ class Album extends Article | |||
70 | // permet de ne pas la remplacer par la nouvelle | 86 | // permet de ne pas la remplacer par la nouvelle |
71 | 87 | ||
72 | $this->format = 'html'; | 88 | $this->format = 'html'; |
89 | |||
73 | for($i = 0; $i < $this->fileListCount; $i++) | 90 | for($i = 0; $i < $this->fileListCount; $i++) |
74 | { | 91 | { |
75 | // ajout du JSON | 92 | // ajout du JSON |
@@ -103,7 +120,7 @@ class Album extends Article | |||
103 | { | 120 | { |
104 | for($i = 0; $i < $this->fileListCount; $i++) | 121 | for($i = 0; $i < $this->fileListCount; $i++) |
105 | { | 122 | { |
106 | if($_SESSION['target'] == $this->fileList[$i]['fileCode']) | 123 | if($this->fileCode == $this->fileList[$i]['fileCode']) |
107 | { | 124 | { |
108 | // json | 125 | // json |
109 | $this->oneAlbum['fileCode'] = $this->fileList[$i]['fileCode']; | 126 | $this->oneAlbum['fileCode'] = $this->fileList[$i]['fileCode']; |
@@ -127,7 +144,7 @@ class Album extends Article | |||
127 | } | 144 | } |
128 | 145 | ||
129 | // page d'un album | 146 | // page d'un album |
130 | public static function readOneHTML($fileCode) | 147 | /*public static function readOneHTML($fileCode) |
131 | { | 148 | { |
132 | if(file_exists('data/discographie/html/' . $fileCode . '.html')) | 149 | if(file_exists('data/discographie/html/' . $fileCode . '.html')) |
133 | { | 150 | { |
@@ -137,7 +154,7 @@ class Album extends Article | |||
137 | { | 154 | { |
138 | return(''); | 155 | return(''); |
139 | } | 156 | } |
140 | } | 157 | }*/ |
141 | 158 | ||
142 | public function getVignetteJSON() | 159 | public function getVignetteJSON() |
143 | { | 160 | { |
diff --git a/model/Article.php b/model/Article.php index fa9fce1..4ef3a5b 100644 --- a/model/Article.php +++ b/model/Article.php | |||
@@ -18,6 +18,12 @@ | |||
18 | // $fileList[$fileCode] => [$fileName => 'code', $content => 'contenu'], etc | 18 | // $fileList[$fileCode] => [$fileName => 'code', $content => 'contenu'], etc |
19 | 19 | ||
20 | 20 | ||
21 | // ma struture est mauvaise, elle n'est pas très orientée objet | ||
22 | // créer une classe structure de données | ||
23 | // celle-ci sera instanciée dans la première (ou pas du tout) | ||
24 | // et accesssible avec des GET et des SET | ||
25 | |||
26 | |||
21 | class Article | 27 | class Article |
22 | { | 28 | { |
23 | // pour tous les articles | 29 | // pour tous les articles |
@@ -25,8 +31,6 @@ class Article | |||
25 | public $format = 'html'; // vaut 'html' ou 'json' | 31 | public $format = 'html'; // vaut 'html' ou 'json' |
26 | public $fileListCount; | 32 | public $fileListCount; |
27 | public $fileList; // = toutes les données | 33 | public $fileList; // = toutes les données |
28 | //protected $articles; // contenu de toute la page | ||
29 | //protected $nbArticles; // un fichier = un article | ||
30 | 34 | ||
31 | // pour un article (ou album) spécifique | 35 | // pour un article (ou album) spécifique |
32 | //public $fileName = ''; // = $_SESSION['nomFichier'] | 36 | //public $fileName = ''; // = $_SESSION['nomFichier'] |
diff --git a/model/Image.php b/model/Image.php index ac05f24..793bd8d 100644 --- a/model/Image.php +++ b/model/Image.php | |||
@@ -3,7 +3,6 @@ | |||
3 | 3 | ||
4 | class Image | 4 | class Image |
5 | { | 5 | { |
6 | private const MAX_WEIGHT = 2000000; // à adapter au php.ini | ||
7 | private $page; | 6 | private $page; |
8 | private $ajax; // vaut true avec le ckeditor | 7 | private $ajax; // vaut true avec le ckeditor |
9 | public $path; | 8 | public $path; |
@@ -26,10 +25,12 @@ class Image | |||
26 | 25 | ||
27 | public function upload() | 26 | public function upload() |
28 | { | 27 | { |
28 | global $maxWeight; | ||
29 | |||
29 | // traitement et enregistrement de l'image | 30 | // traitement et enregistrement de l'image |
30 | if (isset($_FILES['upload']) AND $_FILES['upload']['error'] == 0) // 0 signifie ok | 31 | if (isset($_FILES['upload']) AND $_FILES['upload']['error'] == 0) // 0 signifie ok |
31 | { | 32 | { |
32 | if ($_FILES['upload']['size'] <= self::MAX_WEIGHT) | 33 | if ($_FILES['upload']['size'] <= $maxWeight) |
33 | { | 34 | { |
34 | $this->pathInfos = pathinfo($_FILES['upload']['name']); | 35 | $this->pathInfos = pathinfo($_FILES['upload']['name']); |
35 | $extension = $this->pathInfos['extension']; | 36 | $extension = $this->pathInfos['extension']; |