Mercurial > dirlist-php
comparison index.php @ 15:3dbddf76760a
Add filename as title.
author | edogawaconan <me@myconan.net> |
---|---|
date | Wed, 22 Oct 2014 01:17:34 +0900 |
parents | c2a468e9f3ac |
children | 3c0b3a38a7fc |
comparison
equal
deleted
inserted
replaced
14:c2a468e9f3ac | 15:3dbddf76760a |
---|---|
43 function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); } | 43 function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); } |
44 function a($string) { return preg_replace("#(%2F)+#", "/", rawurlencode($string)); } | 44 function a($string) { return preg_replace("#(%2F)+#", "/", rawurlencode($string)); } |
45 function link_to($target, $title) { | 45 function link_to($target, $title) { |
46 $lightbox = ""; | 46 $lightbox = ""; |
47 if (substr($target, -1) !== "/" && preg_match("/(jpe?g|gif|png|webp)$/i", pathinfo($target, PATHINFO_EXTENSION)) === 1) { | 47 if (substr($target, -1) !== "/" && preg_match("/(jpe?g|gif|png|webp)$/i", pathinfo($target, PATHINFO_EXTENSION)) === 1) { |
48 $lightbox = ' data-lightbox="aa" '; | 48 $lightbox = ' data-lightbox="aa" data-title="' . $target . '" '; |
49 } | 49 } |
50 | 50 |
51 return('<a href="' . a($target) . '"' . $lightbox . ">" . h($title) . "</a>"); | 51 return('<a href="' . a($target) . '"' . $lightbox . ">" . h($title) . "</a>"); |
52 } | 52 } |
53 | 53 |