Overview
Comment: | Liste des fichiers et images liés à une page wiki |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c5be620e4bcf69cbbb5bf98b55a53485 |
User & Date: | bohwaz on 2015-04-01 04:12:31 |
Other Links: | manifest | tags |
Context
2015-04-01
| ||
06:09 | Icônes d'alignement des images check-in: c9250f642a user: bohwaz tags: trunk | |
04:12 | Liste des fichiers et images liés à une page wiki check-in: c5be620e4b user: bohwaz tags: trunk | |
02:54 | Affichage des images et fichiers dans le wiki + insertion d'image avec choix légende et alignement check-in: 152296c653 user: bohwaz tags: trunk | |
Changes
Modified src/include/lib/Garradin/Fichiers.php from [b8a1959299] to [99c5f5f1fe].
︙ | ︙ | |||
13 14 15 16 17 18 19 | public $taille; public $id_contenu; /** * Tailles de miniatures autorisées, pour ne pas avoir 500 fichiers générés avec 500 tailles différentes * @var array */ | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | public $taille; public $id_contenu; /** * Tailles de miniatures autorisées, pour ne pas avoir 500 fichiers générés avec 500 tailles différentes * @var array */ protected static $allowed_thumb_sizes = [200, 500]; const LIEN_COMPTA = 'compta_journal'; const LIEN_WIKI = 'wiki_pages'; const LIEN_MEMBRES = 'membres'; /** * Renvoie l'URL vers un fichier * @param integer $id Numéro du fichier * @param string $nom Nom de fichier avec extension * @param integer $size Taille de la miniature désirée (pour les images) * @return string URL du fichier */ static protected function _getURL($id, $nom, $size = false) { $url = WWW_URL . 'f/' . base_convert((int)$id, 10, 36) . '/' . $nom; if ($size) { $url .= '?' . self::_findThumbSize($size) . 'px'; } return $url; } /** * Renvoie la taille de miniature la plus proche de la taille demandée * @param integer $size Taille demandée * @return integer Taille possible */ static protected function _findThumbSize($size) { $size = (int) $size; if (in_array($size, self::$allowed_thumb_sizes)) { return $size; } foreach (self::$allowed_thumb_sizes as $s) { if ($s >= $size) return $size; } return max(self::$allowed_thumb_sizes); } /** * Constructeur de l'objet pour un fichier * @param integer $id Numéro unique du fichier */ public function __construct($id, $data = null) { if (is_null($data)) { $data = DB::getInstance()->simpleQuerySingle('SELECT fichiers.*, fc.hash, fc.taille, strftime(\'%s\', datetime) AS datetime FROM fichiers INNER JOIN fichiers_contenu AS fc ON fc.id = fichiers.id_contenu WHERE fichiers.id = ?;', true, (int)$id); } if (!$data) { throw new \InvalidArgumentException('Ce fichier n\'existe pas.'); } foreach ($data as $key=>$value) { $this->$key = $value; } } /** * Renvoie l'adresse d'accès au fichier * @param boolean $size Taille éventuelle de la miniature demandée * @return string URL d'accès au fichier */ public function getURL($size = false) { return self::_getURL($this->id, $this->nom, $size); } /** * 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 |
︙ | ︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 | Static_Cache::remove($cache_id); Static_Cache::remove($cache_id . '.thumb'); return $db->exec('END;'); } protected function getFilePathFromCache() { // Le cache est géré par ID contenu, pas ID fichier, pour minimiser l'espace disque utilisé $cache_id = 'fichiers.' . $this->id_contenu; // Le fichier n'existe pas dans le cache statique, on l'enregistre if (!Static_Cache::exists($cache_id)) | > > > > | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | Static_Cache::remove($cache_id); Static_Cache::remove($cache_id . '.thumb'); return $db->exec('END;'); } /** * Renvoie le chemin vers le fichier local en cache, et le crée s'il n'existe pas * @return string Chemin local */ protected function getFilePathFromCache() { // Le cache est géré par ID contenu, pas ID fichier, pour minimiser l'espace disque utilisé $cache_id = 'fichiers.' . $this->id_contenu; // Le fichier n'existe pas dans le cache statique, on l'enregistre if (!Static_Cache::exists($cache_id)) |
︙ | ︙ | |||
246 247 248 249 250 251 252 | public function serveThumbnail($width = self::TAILLE_MINIATURE) { if (!$this->image) { throw new \LogicException('Il n\'est pas possible de fournir une miniature pour un fichier qui n\'est pas une image.'); } | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | public function serveThumbnail($width = self::TAILLE_MINIATURE) { if (!$this->image) { throw new \LogicException('Il n\'est pas possible de fournir une miniature pour un fichier qui n\'est pas une image.'); } $width = self::_findThumbSize($width); $cache_id = 'fichiers.' . $this->id_contenu . '.thumb.' . (int)$width; $path = Static_Cache::getPath($cache_id); // La miniature n'existe pas dans le cache statique, on la crée if (!Static_Cache::exists($cache_id)) { |
︙ | ︙ | |||
477 478 479 480 481 482 483 484 485 486 487 488 489 490 | 'type' => $file['type'], 'image' => (int)$file['image'], ]); return new Fichiers($db->lastInsertRowID()); } static public function SkrivFichier($args, $content, $skriv) { $_args = []; foreach ($args as $value) { if (preg_match('/^\d+$/', $value)) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | 'type' => $file['type'], 'image' => (int)$file['image'], ]); return new Fichiers($db->lastInsertRowID()); } /** * Récupère la liste des fichiers liés à une ressource * * @param string $type Type de ressource * @param integer $id Numéro de ressource * @param boolean $images TRUE pour retourner seulement les images, * FALSE pour retourner les fichiers sans images, NULL pour tout retourner * @return array Liste des fichiers */ static public function listLinkedFiles($type, $id, $images = false) { $check = [self::LIEN_MEMBRES, self::LIEN_WIKI, self::LIEN_COMPTA]; if (!in_array($type, $check)) { throw new \LogicException('Type de lien de fichier inconnu.'); } $images = is_null($images) ? '' : ' AND image = ' . (int)$images; $files = DB::getInstance()->simpleStatementFetch('SELECT fichiers.* FROM fichiers INNER JOIN fichiers_'.$type.' AS fwp ON fwp.fichier = fichiers.id WHERE fwp.id = ? '.$images.' ORDER BY fichiers.nom COLLATE NOCASE;', \SQLITE3_ASSOC, (int)$id); foreach ($files as &$file) { $file['url'] = self::_getURL($file['id'], $file['nom']); $file['thumb'] = $file['image'] ? self::_getURL($file['id'], $file['nom'], 200) : false; } return $files; } /** * Callback utilisé pour l'extension <<fichier>> dans le wiki-texte * @param array $args Arguments passés à l'extension * @param string $content Contenu éventuel (en mode bloc) * @param object $skriv Objet SkrivLite */ static public function SkrivFichier($args, $content, $skriv) { $_args = []; foreach ($args as $value) { if (preg_match('/^\d+$/', $value)) |
︙ | ︙ | |||
509 510 511 512 513 514 515 516 517 518 519 520 521 522 | $out = '<aside class="fichier" data-type="'.$skriv->escape($file->type).'">'; $out.= '<a href="'.$file->getURL().'" class="internal-file">'.$skriv->escape($file->nom).'</a> '; $out.= '<small>('.$skriv->escape($file->type . ', ' . Utils::format_bytes($file->taille)).')</small>'; $out.= '</aside>'; return $out; } static public function SkrivImage($args, $content, $skriv) { $_args = []; $_align_values = ['droite', 'gauche', 'centre']; foreach ($args as $value) { | > > > > > > | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | $out = '<aside class="fichier" data-type="'.$skriv->escape($file->type).'">'; $out.= '<a href="'.$file->getURL().'" class="internal-file">'.$skriv->escape($file->nom).'</a> '; $out.= '<small>('.$skriv->escape($file->type . ', ' . Utils::format_bytes($file->taille)).')</small>'; $out.= '</aside>'; return $out; } /** * Callback utilisé pour l'extension <<image>> dans le wiki-texte * @param array $args Arguments passés à l'extension * @param string $content Contenu éventuel (en mode bloc) * @param object $skriv Objet SkrivLite */ static public function SkrivImage($args, $content, $skriv) { $_args = []; $_align_values = ['droite', 'gauche', 'centre']; foreach ($args as $value) { |
︙ | ︙ |
Modified src/templates/admin/wiki/_fichiers.tpl from [e94dce0bbd] to [1a0357459c].
︙ | ︙ | |||
13 14 15 16 17 18 19 | <input type="submit" id="f_submit" value="Envoyer le fichier" /> </p> </fieldset> </form> <form method="get" action="#" style="display: none;" id="insertImage"> <fieldset> | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | <input type="submit" id="f_submit" value="Envoyer le fichier" /> </p> </fieldset> </form> <form method="get" action="#" style="display: none;" id="insertImage"> <fieldset> <h3>Insérer une image dans le texte</h3> <dl> <dd class="image"></dd> <dt>Légende <i>(facultatif)</i></dt> <dd class="caption"> <input type="text" name="f_caption" size="50" /> </dd> <dt>Alignement :</dt> <dd class="align"> <input type="button" name="gauche" value="À gauche" /> <input type="button" name="centre" value="Au centre" /> <input type="button" name="droite" value="À droite" /> </dd> <dd class="cancel"> <input type="reset" value="Annuler" /> </dd> </dl> </fieldset> </form> {if !empty($images)} <ul class="gallery"> {foreach from=$images item="file"} <li> <figure> <a href="{$file.url|escape}" data-id="{$file.id}"><img src="{$file.thumb|escape}" alt="" title="{$file.nom|escape}" /></a> <p class="actions"> <a href="{$file.url|escape}" onclick="return !window.open(this.href);" class="icn" title="Télécharger">⇓</a> <a href="?delete={$file.id|escape}" class="icn" title="Supprimer">✘</a> </p> </figure> </li> {/foreach} </ul> {/if} {if !empty($fichiers)} <table class="list"> <tbody> {foreach from=$fichiers item="file"} <tr> <th>{$file.nom|escape}</th> <td>{$file.type|escape}</td> <td class="actions"> <a href="{$file.url|escape}" onclick="return !window.open(this.href);" class="icn" title="Télécharger">⇓</a> <a href="?delete={$file.id|escape}" class="icn" title="Supprimer">✘</a> </td> </tr> {/foreach} </tbody> </table> {/if} <script type="text/javascript"> {literal} uploadHelper($('#f_fichier'), { width: 1920, height: null, resize: true, bytes: 'o', size_error_msg: 'Le fichier %file fait %size, soit plus que la taille maximale autorisée de %max_size.' }); function insertImageHelper(file, from_upload) { if (!document.querySelectorAll) { window.parent.te_insertImage(file.id, 'centre'); return true; } var f = document.getElementById('insertImage'); f.style.display = 'block'; var inputs = f.querySelectorAll('input[type=button]'); for (var i = 0; i < inputs.length; i++) { inputs[i].onclick = function(e) { window.parent.te_insertImage(file.id, e.target.name, f.f_caption.value); }; } f.querySelector('dd.image').innerHTML = ''; var img = document.createElement('img'); img.src = file.thumb; img.alt = ''; f.querySelector('dd.image').appendChild(img); f.querySelector('dd.cancel input[type=reset]').onclick = function() { f.style.display = 'none'; if (from_upload) { location.href = location.href; } }; } function insertHelper(data) { var file = (data.file || data); if (file.image) { insertImageHelper(file, true); } else { window.parent.te_insertFile(data.file.id); } return true; } var gallery = document.getElementsByClassName('gallery'); if (gallery.length == 1 && document.querySelector) { gallery = gallery[0]; var items = gallery.getElementsByTagName('li'); for (var i = 0; i < items.length; i++) { var a = items[i].querySelector('figure > a'); a.onclick= function (e) { insertImageHelper({ id: this.getAttribute('data-id'), thumb: this.firstChild.src }); return false; }; } } //insertImageHelper({}) {/literal} </script> {include file="admin/_foot.tpl"} |
Modified src/www/admin/static/admin.css from [a582528eb9] to [15c2d8e99b].
1 2 3 4 5 6 7 8 9 10 11 12 13 | @charset "UTF-8"; @font-face { font-family: 'gicon'; src: url('font/garradin.eot?36341436'); src: url('font/garradin.eot?36341436#iefix') format('embedded-opentype'), url('font/garradin.woff?36341436') format('woff'), url('font/garradin.ttf?36341436') format('truetype'), url('font/garradin.svg?36341436#garradin') format('svg'); font-weight: normal; font-style: normal; } | > > | > > > > > > > > > | > > > > > > > > < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | @import url("wiki.css"); @charset "UTF-8"; @font-face { font-family: 'gicon'; src: url('font/garradin.eot?36341436'); src: url('font/garradin.eot?36341436#iefix') format('embedded-opentype'), url('font/garradin.woff?36341436') format('woff'), url('font/garradin.ttf?36341436') format('truetype'), url('font/garradin.svg?36341436#garradin') format('svg'); font-weight: normal; font-style: normal; } body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td, figure, article, aside, section, header, footer { padding: 0; margin: 0; } fieldset, img { border: 0; } table { border-collapse: collapse; border-spacing: 0; } ol, ul { list-style: none; } caption, th { text-align: left; } article, aside, figure, section, header, footer { display: block; } h1 { font-size: 2em; } h2 { font-size: 1.5em; } h3 { font-size: 1.2em; } h4 { font-size: 1em; } h5 { font-size: 0.9em; } h6 { font-size: 0.8em; } /* marron : #9c4f15 rgb(156, 79, 21) orange : #d98628 rgb(217, 134, 40) */ html { width: 100%; height: 100%; } |
︙ | ︙ | |||
108 109 110 111 112 113 114 | body#popup .page { margin: 1em 1em 1em 2.5em; } body#transparent .page { margin: 0; | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | body#popup .page { margin: 1em 1em 1em 2.5em; } body#transparent .page { margin: 0; padding: .2em; } span.error, b.error { color: #900; } span.confirm, b.confirm { |
︙ | ︙ | |||
368 369 370 371 372 373 374 375 376 | margin: 1em; color: red; } dd.help { color: #666; } table.list { | > > > > > > > > > > > > > > > > > > > > > < | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | margin: 1em; color: red; } dd.help { color: #666; } ul.gallery { text-align: center; } ul.gallery li { display: inline-block; margin: .3em; vertical-align: middle; width: 150px; } ul.gallery li img { max-width: 150px; max-height: 150px; } ul.gallery .actions { text-align: center; z-index: 100; } table.list { margin-bottom: 1em; width: 100%; } table.list.auto { width: auto; } |
︙ | ︙ | |||
504 505 506 507 508 509 510 | #rapport h3 { text-align: center; margin-bottom: .5em; } #rapport table { width: 100%; | < | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | #rapport h3 { text-align: center; margin-bottom: .5em; } #rapport table { width: 100%; } #rapport tr { vertical-align: top; } #rapport table table { |
︙ | ︙ | |||
778 779 780 781 782 783 784 | fieldset.wikiRevision { clear: both; } fieldset.wikiRevision #f_modification { width: 90%; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | fieldset.wikiRevision { clear: both; } fieldset.wikiRevision #f_modification { width: 90%; } .wikiFooter { font-size: 0.8em; color: #666; border-top: 0.1em solid #ccc; clear: both; } |
︙ | ︙ | |||
1243 1244 1245 1246 1247 1248 1249 | } form .fileUpload progress { width: 50%; } form#insertImage { | | | | | > > > > > > > | > > > > > | 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | } form .fileUpload progress { width: 50%; } form#insertImage { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000; background: rgb(0, 0, 0); background: rgba(0, 0, 0, 0.75); } form#insertImage fieldset { box-shadow: 5px 5px 10px #000; margin: 1em; padding: 1em; background: #ddd; border-radius: .5em; text-align: center; } form#insertImage dt { margin: .2em 0; } form#insertImage .align input { font-size: 1.2em; line-height: 32px; background: #fff; background-position: 5px center; background-repeat: no-repeat; |
︙ | ︙ | |||
1283 1284 1285 1286 1287 1288 1289 | background-image: url("pics/img_right.png"); } form#insertImage .align input[name="centre"] { background-image: url("pics/img_center.png"); } | > > > > > > > > > > | > > | 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 | background-image: url("pics/img_right.png"); } form#insertImage .align input[name="centre"] { background-image: url("pics/img_center.png"); } form#insertImage .cancel input { font-size: 0.8em; background: transparent; padding: 5px; border: 1px solid #ccc; border-radius: 5px; margin: .5em; color: #666; } form#insertImage .align input:hover, form#insertImage .cancel input:hover, { cursor: pointer; background-color: #eee; color: darkred; } |
Added src/www/admin/static/wiki.css version [93c5aa3121].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | .wikiContent p, .wikiContent h3, .wikiContent h4, .wikiContent h5, .wikiContent h6, .wikiContent ul, .wikiContent ol, .wikiContent table, .wikiContent blockquote { margin-bottom: 8pt; } .wikiContent ul, .wikiContent ol, .wikiContent dd { margin-left: 2em; } .wikiContent ul { list-style-type: disc; } .wikiContent ol { list-style-type: decimal; } .wikiContent aside.fichier { margin: 1em; } .wikiContent aside.fichier small { opacity: 0.7; } .wikiContent aside.fichier a { display: inline-block; margin-right: 1em; padding: .5em; padding-left: 1.8em; border: 1px solid #ccc; border-radius: .5em; background-repeat: no-repeat; background-position: .5em center; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAQCAYAAADAvYV+AAAAd0lEQVQoz2NgQAVNQDwDCTcw4AF3gPg/Er4xSBWnAXEHFL9HU/wWSS4FpFgZiJ+jKULHT4BYAWa6LhC/w6HwNRBrojvHEoi/oCn8BMQmuDzoBsQ/oQq/A7E9AwEQDMQ/gNiHgUggx0AN8IVI/AGkeA+ReCdJTgAAgMhKhf6mzTIAAAAASUVORK5CYII="); transition: background-color .2s, color .2s; } .wikiContent aside.fichier a:hover { background-color: #eee; color: darkred; } .wikiContent figure.image { text-align: center; } .wikiContent figure.image figcaption { font-style: italic; color: #666; margin-top: 2pt; } .wikiContent figure.image.centre { max-width: 500px; margin: 0 auto 8pt auto; } .wikiContent figure.image.gauche { max-width: 200px; float: left; margin: 0 8pt 4pt 0; } .wikiContent figure.image.droite { max-width: 200px; float: right; margin: 0 0 4pt 8pt; } .wikiContent figure.image.gauche figcaption, .wikiContent figure.image.droite figcaption { font-size: .8em; } |
Modified src/www/admin/wiki/_fichiers.php from [0e02822f72] to [5bd0f3495e].
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | if (isset($_POST['uploadHelper_status'])) { echo json_encode(['error' => $error]); exit; } } $tpl->assign('max_size', Utils::getMaxUploadSize()); $tpl->assign('error', $error); $tpl->assign('page', $page); $tpl->assign('sent', isset($_GET['sent']) ? true : false); $tpl->assign('custom_js', ['upload_helper.min.js']); $tpl->display('admin/wiki/_fichiers.tpl'); | > > > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | if (isset($_POST['uploadHelper_status'])) { echo json_encode(['error' => $error]); exit; } } $tpl->assign('fichiers', Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page['id'], false)); $tpl->assign('images', Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page['id'], true)); $tpl->assign('max_size', Utils::getMaxUploadSize()); $tpl->assign('error', $error); $tpl->assign('page', $page); $tpl->assign('sent', isset($_GET['sent']) ? true : false); $tpl->assign('custom_js', ['upload_helper.min.js']); $tpl->display('admin/wiki/_fichiers.tpl'); |