Overview
Comment:Callback pour insertion de fichier dans page wiki
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 619af651cae9d7647c536d33ddcc59fe03e00788
User & Date: bohwaz on 2015-03-10 05:17:29
Other Links: manifest | tags
Context
2015-03-11
00:11
correction numérotage automatique des comptes fix [26b1f1a224dcd294542c56bbb057f0ab1a5aeb7d] check-in: 39e72e6333 user: bohwaz tags: trunk
2015-03-10
05:17
Callback pour insertion de fichier dans page wiki check-in: 619af651ca user: bohwaz tags: trunk
05:01
Insertion de fichier en JS à la fin de l'upload check-in: 0c126d2308 user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/Fichiers.php from [ad60ab4d6d] to [bcab4fa050].

31
32
33
34
35
36
37

38
39






40
41
42
43
44
45
46
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53







+


+
+
+
+
+
+







	 * @param  integer $width  Largeur
	 * @param  integer $height Hauteur
	 * @param  boolean $crop   TRUE si on doit cropper aux dimensions indiquées
	 * @return void
	 */
	public function getThumbnail($width, $height, $crop = false)
	{
		// FIXME
	}

	/**
	 * Lier un fichier à un contenu
	 * @param  string $type       Type de contenu (constantes LIEN_*)
	 * @param  integer $foreign_id ID du contenu lié
	 * @return boolean TRUE en cas de succès
	 */
	public function linkTo($type, $foreign_id)
	{
		$db = DB::getInstance();
		$check = [self::LIEN_MEMBRES, self::LIEN_WIKI, self::LIEN_COMPTA];

		if (!in_array($type, $check))
		{
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
86
87
88
89
90
91
92










93
94
95
96
97
98
99







-
-
-
-
-
-
-
-
-
-







		{
			$db->simpleExec('DELETE FROM fichiers_contenu WHERE id = ?;', (int)$id_contenu);
		}

		$db->simpleExec('DELETE FROM fichiers WHERE id = ?;', (int)$this->id);

		return $db->exec('END;');
	}

	/**
	 * Modifie les informations du fichier
	 * @param  string $nom   Le nom du fichier (avec extension)
	 * @return boolean TRUE en cas de succès
	 */
	public function edit($nom)
	{

	}

	/**
	 * Envoie le fichier au client HTTP
	 * @return void
	 */
	public function serve()
218
219
220
221
222
223
224
225

226
227
228
229
230
231
232
215
216
217
218
219
220
221

222
223
224
225
226
227
228
229







-
+







				return 'Erreur inconnue: ' . $error;
		}
	}

	/**
	 * Upload du fichier par POST
	 * @param  array  $file  Caractéristiques du fichier envoyé
	 * @return boolean TRUE en cas de succès
	 * @return object Un objet Fichiers en cas de succès
	 */
	static public function upload($file)
	{
		if (!empty($file['error']))
		{
			throw new UserException(self::getErrorMessage($file['error']));
		}
278
279
280
281
282
283
284






285
286
287
288
289
290
291
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294







+
+
+
+
+
+







		]);

		$db->exec('END;');

		return new Fichiers($db->lastInsertRowID());
	}

	/**
	 * Envoie un fichier déjà stocké
	 * @param  string $name Nom du fichier
	 * @param  string $hash Hash SHA1 du contenu du fichier
	 * @return object       Un objet Fichiers en cas de succès
	 */
	static public function uploadExistingHash($name, $hash)
	{
		$db = DB::getInstance();
		$name = preg_replace('/[^\d\w._-]/ui', '', $name);

		$file = $db->simpleQuerySingle('SELECT * FROM fichiers 
			INNER JOIN fichiers_contenu AS fc ON fc.id = fichiers.id_contenu AND fc.hash = ?;', true, trim($hash));
300
301
302
303
304
305
306
307


















303
304
305
306
307
308
309

310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327







-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
			'nom'			=>	$name,
			'type'			=>	$file['type'],
			'image'			=>	(int)$file['image'],
		]);

		return new Fichiers($db->lastInsertRowID());
	}
}

	static public function SkrivHTML($args, $content, $skriv)
	{
		if (empty($args['id']) && !empty($content))
		{
			$args = ['id' => (int)$content];
		}

		if (empty($args['id']))
		{
			return $this->parseError('Aucun numéro de fichier indiqué.');
		}

		$db = DB::getInstance();

		// FIXME
	}
}

Modified src/include/lib/Garradin/Utils.php from [f6e82cd370] to [07f19bdcc3].

386
387
388
389
390
391
392

393
394
395
396
397
398
399
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400







+







     * @return string      Texte HTML
     */
    static public function SkrivToHTML($str)
    {
        if (!self::$skriv)
        {
            self::$skriv = new \KD2\SkrivLite;
            self::$skriv->registerExtension('fichier', ['Fichiers', 'SkrivHTML']);
        }

        $str = self::$skriv->render($str);

        return $str;
    }

Modified src/include/lib/Garradin/Wiki.php from [e177dfd955] to [93dce48266].

512
513
514
515
516
517
518
519
520
512
513
514
515
516
517
518









-
-
                $flat[$node['parent']]['children'][$id] = &$node;
            }
        }

        return $tree;
    }
}

?>