From a7221027661bd1fd46dafa48a66215068126d51e Mon Sep 17 00:00:00 2001 From: Bruno Pesenti Date: Sun, 12 Feb 2017 18:52:59 +0100 Subject: [PATCH] =?UTF-8?q?Single=20(WP=20et=20ZP=20termin=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -alt -title (pour lightbox) --- .gitignore | 3 ++ functions.php | 87 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index e43b0f9..6985fb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .DS_Store +/.settings +/.buildpath +/.project diff --git a/functions.php b/functions.php index e985292..e52f1cd 100644 --- a/functions.php +++ b/functions.php @@ -464,53 +464,76 @@ function zenphoto_handler($atts, $content=null) { $caption = ! empty( $atts['caption'] ) ? $atts['caption'] : ''; $caption = filter_var($caption, FILTER_SANITIZE_STRING); + //echo "album: " . $album . " image: " . $image . "
"; + $rnd = rand (1000, 9999); //$size = 610; $folder = false; + //echo "folder1: " . $folder . "
"; $zenphoto_img = ""; // Si ALBUM mais pas IMAGE - //if ((isset($atts['album'])) && (!isset($atts['image']))) { - if (($album != "") && ($image == "")) { - require('../Connections/cnx.php'); - - $mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable); - if (mysqli_connect_errno()) { - printf("Échec de la connexion : %s\n", mysqli_connect_error()); - exit(); - } - // Trouver l'ID de l'album - $album_id_query = "SELECT `id` FROM `" . $zp_prefix . "albums` WHERE `folder` = '" . $atts['album'] . "'"; - if ($result = $mysqli->query($album_id_query)) { - if ($mysqli->affected_rows != 0) { - $row = $result->fetch_row(); - $album_id = $row[0]; - } - else { - _e("Unknow album.", 'CreatorThemeRes-child' ); - } - $result->close(); - } + //echo "album2: " . $album . " image2: " . $image . "
"; - // Trouver le filename de la plus récente image de l'album - $img_album_query = "SELECT filename FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "' ORDER BY `id` DESC LIMIT 1"; + //if (($album != "") && ($image == "")) { + require('../Connections/cnx.php'); + + + $mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable); + if (mysqli_connect_errno()) { + printf("Échec de la connexion : %s\n", mysqli_connect_error()); + exit(); + } + // Trouver l'ID de l'album + $album_id_query = "SELECT `id` FROM `" . $zp_prefix . "albums` WHERE `folder` = '" . $atts['album'] . "'"; + if ($result = $mysqli->query($album_id_query)) { + if ($mysqli->affected_rows != 0) { + $row = $result->fetch_row(); + $album_id = $row[0]; + } + else { + _e("Unknow album.", 'CreatorThemeRes-child' ); + } + $result->close(); + } + + + $img_query = "SELECT `desc`, `title`, `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "'"; + if ($result = $mysqli->query($img_query)) { + if ($mysqli->affected_rows != 0) { + $capt = $result->fetch_row(); + } + else { + _e("Unknow image.", 'CreatorThemeRes-child' ); + } + $result->close(); + } + + + if (($album != "") && ($image == "")) { + // Trouver le filename de la plus récente image de l'album + $img_album_query = "SELECT `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "' ORDER BY `id` DESC LIMIT 1"; if ($result = $mysqli->query($img_album_query)) { if ($mysqli->affected_rows != 0) { $row = $result->fetch_row(); - $img_album = $row[0]; + $img_album = $row[0]; } else { - _e("Unknow image.", 'CreatorThemeRes-child' ); + _e("Unknow image.", 'CreatorThemeRes-child' ); } - $result->close(); + $result->close(); } $image = $img_album; $folder = true; - } + } // album != "" + if ($capt[0] != "") $title = $capt[0]; + elseif ($capt[1] != "") $title = $capt[1]; + elseif ($capt[2] != "") $title = $capt[2]; + $img = substr($image, 0, strlen($image) - 4); $filename = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . 'cache/' . $album . '/' . urlencode($img) . '_' . $size . '_watermark.jpg'; @@ -518,7 +541,7 @@ function zenphoto_handler($atts, $content=null) { $zenphoto_img = (($caption != "") ? '
' : ''); - if ($folder == false) $zenphoto_link = ''; + if ($folder == false) $zenphoto_link = ''; else $zenphoto_link = ''; $zenphoto_img .= $zenphoto_link; @@ -534,7 +557,7 @@ function zenphoto_handler($atts, $content=null) { */ $zenphoto_img .= '…'; + $zenphoto_img .= 'srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="' . $img . '" />'; $zenphoto_img .= ''; $zenphoto_img .= (($caption != "") ? '

' . $caption . '

' : ''); @@ -862,7 +885,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); $pattern = '/
]*>(.*?)\<\/div>/'; //$pattern = '/
]*>(.*?)\<\/div>/'; preg_match_all($pattern, $content, $matches, PREG_SET_ORDER); - var_dump($matches); + //var_dump($matches); /* echo "matches[0][0]"; //
...
echo "matches[0][1]"; // 1114 @@ -890,7 +913,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); if (substr_count($court, "wordpress") > 0) $meta = creator_get_exif( $court ); elseif (substr_count($court, "zenphoto") > 0) { - echo $court; + //echo $court; $img = explode("/", $court); $zp_image = end($img); $zp_album = prev($img); @@ -914,7 +937,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); $pattern2 = '/]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU'; preg_match_all($pattern2, $content , $matches4, PREG_SET_ORDER); - var_dump($matches4); + //var_dump($matches4); for ($i = 0; $i <= (count($matches4) - 1); $i++) { $ancien = $matches4[$i][0];