diff options
-rw-r--r-- | controller/ajax.php | 4 | ||||
-rw-r--r-- | controller/installation.php | 51 | ||||
-rw-r--r-- | model/Album.php | 6 | ||||
-rw-r--r-- | model/Article.php | 60 | ||||
-rw-r--r-- | model/Image.php | 6 | ||||
-rw-r--r-- | à faire après livraison.txt | 8 |
6 files changed, 73 insertions, 62 deletions
diff --git a/controller/ajax.php b/controller/ajax.php index 13f5c08..24710d8 100644 --- a/controller/ajax.php +++ b/controller/ajax.php | |||
@@ -18,7 +18,9 @@ if(isset($_GET['action']) && isset($_GET['page']) && $_GET['action'] == 'upload_ | |||
18 | // paramètre "true" parce qu'on reçoit une requête AJAX | 18 | // paramètre "true" parce qu'on reçoit une requête AJAX |
19 | $Image = new Image(true); | 19 | $Image = new Image(true); |
20 | $Image->upload(); | 20 | $Image->upload(); |
21 | |||
21 | echo($Image->reponseAjax); // attendu par l'éditeur | 22 | echo($Image->reponseAjax); // attendu par l'éditeur |
23 | // attention ici aux var_dump() ou echo() qui trainent | ||
22 | 24 | ||
23 | $Image->makeThumbnail(630); // => taille de la <div> | 25 | $Image->makeThumbnail(630); // => taille de la <div> |
24 | // on pourra l'agrandir en cliquant dessus | 26 | // on pourra l'agrandir en cliquant dessus |
@@ -42,7 +44,7 @@ if(isset($_GET['action']) && $_GET['action'] == 'restauration' | |||
42 | $_SESSION['fileSize'] = $_GET['file_size']; | 44 | $_SESSION['fileSize'] = $_GET['file_size']; |
43 | $_SESSION['fileName'] = $_GET['file_name']; | 45 | $_SESSION['fileName'] = $_GET['file_name']; |
44 | //echo("file infos send"); | 46 | //echo("file infos send"); |
45 | var_dump($_SESSION['fileName']); | 47 | //var_dump($_SESSION['fileName']); |
46 | exit(); // stop !! | 48 | exit(); // stop !! |
47 | } | 49 | } |
48 | } | 50 | } |
diff --git a/controller/installation.php b/controller/installation.php index 3745189..6ae35e7 100644 --- a/controller/installation.php +++ b/controller/installation.php | |||
@@ -50,13 +50,13 @@ function installation() | |||
50 | require('view/backup.php'); | 50 | require('view/backup.php'); |
51 | exit(); | 51 | exit(); |
52 | } | 52 | } |
53 | |||
54 | if(!file_exists('data/index.php')) | 53 | if(!file_exists('data/index.php')) |
55 | { | 54 | { |
56 | createIndexPHP('data/index.php', $droitsFichiers); | 55 | createIndexPHP('data/index.php', $droitsFichiers); |
57 | } | 56 | } |
58 | 57 | ||
59 | $listePages = array('menu', 'melaine', 'musique', 'discographie', 'presse', 'jaime', 'peinture', 'archives', 'legal'); | 58 | $listePages = array('menu', 'melaine', 'musique', 'discographie', 'presse', 'jaime', 'peinture', 'archives', 'legal'); |
59 | $sousDossiers = array('html', 'html-maxi-images', 'images', 'images-mini'); | ||
60 | foreach ($listePages as $page) | 60 | foreach ($listePages as $page) |
61 | { | 61 | { |
62 | if(!file_exists('data/' . $page)) | 62 | if(!file_exists('data/' . $page)) |
@@ -68,41 +68,17 @@ function installation() | |||
68 | { | 68 | { |
69 | createIndexPHP('data/' . $page . '/index.php', $droitsFichiers); | 69 | createIndexPHP('data/' . $page . '/index.php', $droitsFichiers); |
70 | } | 70 | } |
71 | if(!file_exists('data/' . $page . '/html')) | 71 | foreach ($sousDossiers as $dossier) |
72 | { | ||
73 | mkdir('data/' . $page . '/html'); | ||
74 | chmod('data/' . $page . '/html', $droitsDossiers); | ||
75 | } | ||
76 | if(!file_exists('data/' . $page . '/html/index.php')) | ||
77 | { | ||
78 | createIndexPHP('data/' . $page . '/html/index.php', $droitsFichiers); | ||
79 | } | ||
80 | if(!file_exists('data/' . $page . '/html-mini-images')) | ||
81 | { | ||
82 | mkdir('data/' . $page . '/html-mini-images'); | ||
83 | chmod('data/' . $page . '/html-mini-images', $droitsDossiers); | ||
84 | } | ||
85 | if(!file_exists('data/' . $page . '/html-mini-images/index.php')) | ||
86 | { | ||
87 | createIndexPHP('data/' . $page . '/html-mini-images/index.php', $droitsFichiers); | ||
88 | } | ||
89 | if(!file_exists('data/' . $page . '/images')) | ||
90 | { | 72 | { |
91 | mkdir('data/' . $page . '/images'); | 73 | if(!file_exists('data/' . $page . '/' . $dossier)) |
92 | chmod('data/' . $page . '/images', $droitsDossiers); | 74 | { |
93 | } | 75 | mkdir('data/' . $page . '/' . $dossier); |
94 | if(!file_exists('data/' . $page . '/images/index.php')) | 76 | chmod('data/' . $page . '/' . $dossier, $droitsDossiers); |
95 | { | 77 | } |
96 | createIndexPHP('data/' . $page . '/images/index.php', $droitsFichiers); | 78 | if(!file_exists('data/' . $page . '/' . $dossier . '/index.php')) |
97 | } | 79 | { |
98 | if(!file_exists('data/' . $page . '/images-mini')) | 80 | createIndexPHP('data/' . $page . '/' . $dossier . '/index.php', $droitsFichiers); |
99 | { | 81 | } |
100 | mkdir('data/' . $page . '/images-mini'); | ||
101 | chmod('data/' . $page . '/images-mini', $droitsDossiers); | ||
102 | } | ||
103 | if(!file_exists('data/' . $page . '/images-mini/index.html')) | ||
104 | { | ||
105 | createIndexPHP('data/' . $page . '/images-mini/index.php', $droitsFichiers); | ||
106 | } | 82 | } |
107 | // if(!file_exists('data/' . $page . '/multimedia')) | 83 | // if(!file_exists('data/' . $page . '/multimedia')) |
108 | // { | 84 | // { |
@@ -110,7 +86,8 @@ function installation() | |||
110 | // chmod('data/' . $page . '/multimedia', 0777); | 86 | // chmod('data/' . $page . '/multimedia', 0777); |
111 | // } | 87 | // } |
112 | } | 88 | } |
113 | // dossiers supplémentaires dans discographie | 89 | |
90 | // dossier supplémentaire dans discographie | ||
114 | if(!file_exists('data/discographie/json')) | 91 | if(!file_exists('data/discographie/json')) |
115 | { | 92 | { |
116 | mkdir('data/discographie/json'); | 93 | mkdir('data/discographie/json'); |
@@ -120,6 +97,7 @@ function installation() | |||
120 | { | 97 | { |
121 | createIndexPHP('data/discographie/json/index.php', $droitsFichiers); | 98 | createIndexPHP('data/discographie/json/index.php', $droitsFichiers); |
122 | } | 99 | } |
100 | |||
123 | // fichiers temporaires pour upload des grosses archives | 101 | // fichiers temporaires pour upload des grosses archives |
124 | if(!file_exists('data/tmp')) | 102 | if(!file_exists('data/tmp')) |
125 | { | 103 | { |
@@ -130,7 +108,6 @@ function installation() | |||
130 | { | 108 | { |
131 | createIndexPHP('data/tmp/index.php', $droitsFichiers); | 109 | createIndexPHP('data/tmp/index.php', $droitsFichiers); |
132 | } | 110 | } |
133 | // le modèle donnera les droits 0666 (octal) aux nouveaux fichiers à l'intérieur des dossiers | ||
134 | 111 | ||
135 | // créer le melainePHP.zip | 112 | // créer le melainePHP.zip |
136 | if(!file_exists("data/melainePHP.zip")) | 113 | if(!file_exists("data/melainePHP.zip")) |
diff --git a/model/Album.php b/model/Album.php index 95dac50..b4b7afe 100644 --- a/model/Album.php +++ b/model/Album.php | |||
@@ -57,14 +57,10 @@ class Album extends Article | |||
57 | if(!empty($erreur)) | 57 | if(!empty($erreur)) |
58 | {} | 58 | {} |
59 | } | 59 | } |
60 | 60 | ||
61 | // encodage avec un tableau simple | ||
62 | $albumJSON = json_encode([$titre, $annee, $pochette, $pochetteMini]); | 61 | $albumJSON = json_encode([$titre, $annee, $pochette, $pochetteMini]); |
63 | //var_dump($albumJSON); die(); | 62 | //var_dump($albumJSON); die(); |
64 | 63 | ||
65 | // encodage avec un tableau associatif | ||
66 | //$albumJSON = json_encode(['titre' => $titre, 'annee' => $annee,'pochette' => $pochette]); | ||
67 | |||
68 | $nom_fichier = 'data/' . $this->page . '/' . $this->format . '/' . $this->time . '.' . $this->format; | 64 | $nom_fichier = 'data/' . $this->page . '/' . $this->format . '/' . $this->time . '.' . $this->format; |
69 | 65 | ||
70 | $fichier = fopen($nom_fichier, 'w'); // w pour créer ou écraser | 66 | $fichier = fopen($nom_fichier, 'w'); // w pour créer ou écraser |
diff --git a/model/Article.php b/model/Article.php index f9c5b89..bad6948 100644 --- a/model/Article.php +++ b/model/Article.php | |||
@@ -49,33 +49,47 @@ class Article | |||
49 | //var_dump($this->fileList); die(); | 49 | //var_dump($this->fileList); die(); |
50 | } | 50 | } |
51 | 51 | ||
52 | private function makeHtmlMiniImages($content) | ||
53 | { | ||
54 | return $content; | ||
55 | } | ||
56 | |||
52 | // GET | 57 | // GET |
53 | 58 | ||
54 | // SET | 59 | // SET |
55 | /*public function setFileName() | ||
56 | { | ||
57 | if(file_exists('data/' . $this->page . '/' . $this->format . '/' . $this->fileCode . '.' . $this->format)) | ||
58 | { | ||
59 | $this->fileName = 'data/' . $this->page . '/' . $this->format . '/' . $this->fileCode . '.' . $this->format; | ||
60 | } | ||
61 | }*/ | ||
62 | 60 | ||
63 | // fonctions CRUD (create - read - update - delete) | 61 | // fonctions CRUD (create - read - update - delete) |
64 | 62 | ||
65 | // create | 63 | // create |
66 | public function create($content) | 64 | public function create($content) |
67 | { | 65 | { |
68 | //$format = 'html'; | 66 | // $format dépend de la classe qui a été instanciée |
69 | 67 | ||
70 | // nommer les fichiers avec le timestamp pour: | 68 | // nommer les fichiers avec le timestamp pour: |
71 | // - les trier par ordre chronologique | 69 | // - les trier par ordre chronologique |
72 | // - rendre quasi impossible d'avoir deux fois le même nom | 70 | // - rendre quasi impossible d'avoir deux fois le même nom |
73 | $fileName = 'data/' . $this->page . '/' . $this->format . '/' . $this->time . '.' . $this->format; | ||
74 | 71 | ||
72 | if($this->format == 'html') | ||
73 | { | ||
74 | // html version images normales | ||
75 | $contentMaxi = $content; | ||
76 | $fileName = 'data/' . $this->page . '/' . $this->format . '-maxi-images/' . $this->time . '.' . $this->format; | ||
77 | $file = fopen($fileName, 'w'); // w pour créer ou écraser | ||
78 | fputs($file, $contentMaxi); | ||
79 | fclose($file); | ||
80 | chmod($fileName, 0666); | ||
81 | |||
82 | // html version petites images | ||
83 | $content = self::makeHtmlMiniImages($content); | ||
84 | } | ||
85 | |||
86 | $fileName = 'data/' . $this->page . '/' . $this->format . '/' . $this->time . '.' . $this->format; | ||
75 | $file = fopen($fileName, 'w'); // w pour créer ou écraser | 87 | $file = fopen($fileName, 'w'); // w pour créer ou écraser |
76 | fputs($file, $content); | 88 | fputs($file, $content); |
77 | fclose($file); | 89 | fclose($file); |
78 | chmod($fileName, 0666); | 90 | chmod($fileName, 0666); |
91 | |||
92 | |||
79 | } | 93 | } |
80 | 94 | ||
81 | // read | 95 | // read |
@@ -96,8 +110,29 @@ class Article | |||
96 | // update | 110 | // update |
97 | public function update($content) | 111 | public function update($content) |
98 | { | 112 | { |
113 | if($this->format == 'html') | ||
114 | { | ||
115 | // html version images normales | ||
116 | $contentMaxi = $content; | ||
117 | $fileName = 'data/' . $this->page . '/' . $this->format . '-maxi-images/' . $this->fileCode . '.' . $this->format; | ||
118 | if(file_exists($fileName) && empty($content)) | ||
119 | { | ||
120 | $this->delete(); | ||
121 | } | ||
122 | elseif(!empty($content)) | ||
123 | { | ||
124 | $file = fopen($fileName, 'w'); // w pour créer ou écraser | ||
125 | fputs($file, $contentMaxi); | ||
126 | fclose($file); | ||
127 | chmod($fileName, 0666); | ||
128 | } | ||
129 | |||
130 | // html version petites images | ||
131 | $content = self::makeHtmlMiniImages($content); | ||
132 | } | ||
133 | |||
134 | // json ou html version petites images | ||
99 | $fileName = 'data/' . $this->page . '/' . $this->format . '/' . $this->fileCode . '.' . $this->format; | 135 | $fileName = 'data/' . $this->page . '/' . $this->format . '/' . $this->fileCode . '.' . $this->format; |
100 | //var_dump(file_get_contents($fileName)); die(); | ||
101 | if(file_exists($fileName) && empty($content)) | 136 | if(file_exists($fileName) && empty($content)) |
102 | { | 137 | { |
103 | $this->delete(); | 138 | $this->delete(); |
@@ -107,8 +142,7 @@ class Article | |||
107 | $file = fopen($fileName, 'w'); // w pour créer ou écraser | 142 | $file = fopen($fileName, 'w'); // w pour créer ou écraser |
108 | fputs($file, $content); | 143 | fputs($file, $content); |
109 | fclose($file); | 144 | fclose($file); |
110 | //chown($this->fileName, 'http'); | 145 | chmod($fileName, 0666); |
111 | chmod($fileName, 0666); | ||
112 | } | 146 | } |
113 | } | 147 | } |
114 | 148 | ||
diff --git a/model/Image.php b/model/Image.php index 61f25c6..1cc0e22 100644 --- a/model/Image.php +++ b/model/Image.php | |||
@@ -67,7 +67,7 @@ class Image | |||
67 | if($imageLibrary == 'imagick') | 67 | if($imageLibrary == 'imagick') |
68 | { | 68 | { |
69 | $Image = new Imagick($this->path . $_FILES['upload']['name']); | 69 | $Image = new Imagick($this->path . $_FILES['upload']['name']); |
70 | 70 | ||
71 | $source = $Image->getImageGeometry(); | 71 | $source = $Image->getImageGeometry(); |
72 | if($source['width'] > $largeur) | 72 | if($source['width'] > $largeur) |
73 | { | 73 | { |
@@ -82,17 +82,13 @@ class Image | |||
82 | { | 82 | { |
83 | // cette fonction fonctionne pour tous les formats | 83 | // cette fonction fonctionne pour tous les formats |
84 | $source = imagecreatefromstring(file_get_contents($this->path . $_FILES['upload']['name'])); | 84 | $source = imagecreatefromstring(file_get_contents($this->path . $_FILES['upload']['name'])); |
85 | |||
86 | $nomMiniImage = $this->pathMini . $this->pathInfos['filename'] . '-mini.jpg'; | 85 | $nomMiniImage = $this->pathMini . $this->pathInfos['filename'] . '-mini.jpg'; |
87 | |||
88 | $forme = imagesy($source) / imagesx($source); | 86 | $forme = imagesy($source) / imagesx($source); |
89 | var_dump($forme); | ||
90 | 87 | ||
91 | if(imagesx($source) > $largeur) | 88 | if(imagesx($source) > $largeur) |
92 | { | 89 | { |
93 | // créer un rectangle noir | 90 | // créer un rectangle noir |
94 | $destination = imagecreatetruecolor($largeur, $largeur * $forme); | 91 | $destination = imagecreatetruecolor($largeur, $largeur * $forme); |
95 | //var_dump($destination); | ||
96 | 92 | ||
97 | // sélectionne un rectangle dans l'image source | 93 | // sélectionne un rectangle dans l'image source |
98 | // et le place dans un rectangle dans la nouvelle | 94 | // et le place dans un rectangle dans la nouvelle |
diff --git a/à faire après livraison.txt b/à faire après livraison.txt index 965d456..1617552 100644 --- a/à faire après livraison.txt +++ b/à faire après livraison.txt | |||
@@ -1,4 +1,10 @@ | |||
1 | créer page peinture | 1 | déplacer les livres |
2 | |||
3 | images des articles en grand et miniature | ||
4 | |||
5 | bouton partage et lien d'encre sur tous les articles | ||
6 | |||
7 | créer galerie page peinture | ||
2 | 8 | ||
3 | hyperlien avec liens relatifs (par exemple dans emoi des mots) | 9 | hyperlien avec liens relatifs (par exemple dans emoi des mots) |
4 | 10 | ||