]> git.mjollnir.org Git - s9y.git/commitdiff
On the fly update of the media databas: Not only images are added but video and audio...
authorbrockhaus <brockhaus>
Tue, 7 Aug 2007 14:17:49 +0000 (14:17 +0000)
committerbrockhaus <brockhaus>
Tue, 7 Aug 2007 14:17:49 +0000 (14:17 +0000)
docs/NEWS
include/functions_images.inc.php

index 25d64da28878b0db97ee1fe5030c7ff7c383cf91..6a0fe8209a124426276e518fdcb1af408ca14d20 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.3 ()
 ------------------------------------------------------------------------
 
+    * On the fly update of the media databas: Not only images are added
+      but video and audio, too. (brockhaus)
+
     * New spam blocking method for trackbacks: ip validation. The 
       senders ip is compared with the ip of the host, the trackback is
       set to. If they don't match, the trackback is rejected/moderated.
index 9a43c9a7c82dcc338633727ed69ecb8321099cfe..7a3adec7111946894d447d93e1fb5ac87e18eb04 100644 (file)
@@ -1407,7 +1407,8 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
         // in the database
 
         $nCount = 0;
-        if ($serendipity['onTheFlySynch'] && serendipity_checkPermission('adminImagesSync') && $serendipity['current_image_hash'] != $serendipity['last_image_hash']) {
+        if ($debug) echo "<p>Image Sync Right: " . serendipity_checkPermission('adminImagesSync') . " Onthefly Sync: " . $serendipity['onTheFlySynch'] . " Hash: " . $serendipity['current_image_hash'] . "!=" . $serendipity['last_image_hash']. "</p>";
+        if ($serendipity['onTheFlySynch'] && serendipity_checkPermission('adminImagesSync') && ($debug  || ($serendipity['current_image_hash'] != $serendipity['last_image_hash']))) {
             $aResultSet = serendipity_db_query("SELECT path, name, extension, thumbnail_name, id
                                                 FROM {$serendipity['dbPrefix']}images", false, 'assoc');
             if ($debug) echo "<p>Got images: <pre>" . print_r($aResultSet, true) . "</pre></p>";
@@ -1454,7 +1455,7 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
 
                 // MTG: 21/01/06: put files which have just 'turned up' into the database
                 $aImageData = serendipity_getImageData($sFile);
-                if (serendipity_isImage($aImageData)) {
+                if (serendipity_isMedia($aImageData)) {
                     $nPos = strrpos($sFile, "/");
                     if (is_bool($nPos) && !$nPos) {
                        $sFileName  = $sFile;
@@ -1587,6 +1588,49 @@ function serendipity_isImage(&$file, $strict = false) {
     return (0 === strpos(strtolower($file['displaymime']), 'image/'));
 }
 
+/**
+ * Check if a media item is a video
+ *
+ * @access public
+ * @param   array       File information
+ * @return  boolean     True if the file is a video
+ */
+function serendipity_isVideo($file) {
+    global $serendipity;
+
+    $file['displaymime'] = $file['mime'];
+
+    return (0 === strpos(strtolower($file['displaymime']), 'video/'));
+}
+
+/**
+ * Check if a media item is an audio
+ *
+ * @access public
+ * @param   array       File information
+ * @return  boolean     True if the file is an audio
+ */
+function serendipity_isAudio($file) {
+    global $serendipity;
+
+    $file['displaymime'] = $file['mime'];
+
+    return (0 === strpos(strtolower($file['displaymime']), 'audio/'));
+}
+
+/**
+ * Check if a media item is a media file (image, video or audio)
+ *
+ * @access public
+ * @param   array       File information
+ * @return  boolean     True if the file is an audio
+ */
+function serendipity_isMedia(&$file, $strict = false) {
+    global $serendipity;
+
+    return serendipity_isImage($file, $strict) || serendipity_isVideo($file) || serendipity_isAudio($file);
+}
+
 /**
  * Recursively delete a directory tree
  *