]> git.mjollnir.org Git - s9y.git/commitdiff
TODO items:
authorgarvinhicking <garvinhicking>
Tue, 11 Apr 2006 13:34:13 +0000 (13:34 +0000)
committergarvinhicking <garvinhicking>
Tue, 11 Apr 2006 13:34:13 +0000 (13:34 +0000)
- Smartify image selector
- Insert Image ID from javascript
- Ensure ACL/permissions

12 files changed:
deployment/serendipity_editor.js
docs/NEWS
include/admin/plugins.inc.php
include/db/mysql.inc.php
include/db/mysqli.inc.php
include/db/postgres.inc.php
include/db/sqlite.inc.php
include/functions_config.inc.php
include/functions_images.inc.php
include/functions_plugins_admin.inc.php
serendipity_editor.js
templates/default/admin/media_items.tpl [new file with mode: 0644]

index 67d50c6f7618862ca7ef4f807f48b1fb5c8e959e..d8c6c72b29f59746cb12e04e545edc2027ef1e42 100644 (file)
@@ -225,14 +225,19 @@ function serendipity_imageSelector_done(textarea)
         styled = true;
     }
 
+    imgID = 0;
+    if (f['imgID']) {
+        imgID = f['imgID'].value;
+    }
+
     floating = 'center';
     if (f['serendipity[align]'][0].checked == true) {
-        img = "<img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
+        img = "<!--s9ymdb:" + imgID + "--><img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
     } else if (f['serendipity[align]'][1].checked == true) {
-        img = "<img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: left; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
+        img = "<!--s9ymdb:" + imgID + "--><img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: left; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
         floating = 'left';
     } else if (f['serendipity[align]'][2].checked == true) {
-        img = "<img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: right; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
+        img = "<!--s9ymdb:" + imgID + "--><img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: right; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
         floating = 'right';
     }
 
index 426df1d5f2046b0e0dee0c9345a27da5cbed7101..ee686c48b1150306ca9e076cd89290a6164ae629 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -1,6 +1,6 @@
 # $Id$
 
-Version 1.1-alpha1()
+Version 1.1-alpha4()
 ------------------------------------------------------------------------
 
    * Support template/theme/style-specific options via "config.inc.php"
@@ -10,10 +10,6 @@ Version 1.1-alpha1()
 
    * Make media manager able to store media properties (garvinhicking)
      TODO:
-        - Also delete properties when deleting an image
-        - Enforce permissions on readable files via ACL queries on the given directory/path
-        - Make JS emit the image ID somewhere in the <img> tag
-        - Make media selector smartyfied
         - Show more existing properties in edit interface [see TODO in file]
         - Read/Parse EXIF metadata, ask which to import [config option?]
         - Search/Filter for specific properties/keywords
index b9a9a6a7fc0b34aa362b131ed094af6cf2e3b5a6..e0f1630be063ead84be3172a73eb4f160e2ae67d 100644 (file)
@@ -335,6 +335,9 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
         }
     }
 ?>
+    <tr>
+        <td colspan="2" align="right"><?php printf(PLUGIN_AVAILABLE_COUNT, count($pluginstack)); ?></td>
+    </tr>
 </table>
 
 <?php
index 7056da4d263fe96b4baeda0f506b89a86e3b7384..27ad8b636b035a4d9e0ba3d8e0ea6652b1280a61 100644 (file)
@@ -118,9 +118,13 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
 
             $rows = array();
             while (($row = mysql_fetch_array($c, $result_type))) {
-                if (!empty($assocKey) && !empty($assocVal)) {
+                if (!empty($assocKey)) {
                     // You can fetch a key-associated array via the two function parameters assocKey and assocVal
-                    $rows[$row[$assocKey]] = $row[$assocVal];
+                    if (empty($assocVal)) {
+                        $rows[$row[$assocKey]] = $row;
+                    } else {
+                        $rows[$row[$assocKey]] = $row[$assocVal];
+                    }
                 } else {
                     $rows[] = $row;
                 }
index d46ac27d15605df0030c36779d3f5a0066155334..e4fd46df5b4c899dc9c9bdc83afd8bc054ae2367 100644 (file)
@@ -107,9 +107,13 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
 
             $rows = array();
             while ($row = mysqli_fetch_array($c, $result_type)) {
-                if (!empty($assocKey) && !empty($assocVal)) {
+                if (!empty($assocKey)) {
                     // You can fetch a key-associated array via the two function parameters assocKey and assocVal
-                    $rows[$row[$assocKey]] = $row[$assocVal];
+                    if (empty($assocVal)) {
+                        $rows[$row[$assocKey]] = $row;
+                    } else {
+                        $rows[$row[$assocKey]] = $row[$assocVal];
+                    }
                 } else {
                     $rows[] = $row;
                 }
index 33bbbaabdd3a828622061d96a789fbdb9a83a5e9..b6459dcee610cc7348075b64679fd3ee26791a23 100644 (file)
@@ -242,10 +242,14 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
         default:
             $rows = array();
             for ($i = 0; $i < $n; $i++) {
-                if (!empty($assocKey) && !empty($assocVal)) {
+                if (!empty($assocKey)) {
                     // You can fetch a key-associated array via the two function parameters assocKey and assocVal
                     $row = pg_fetch_array($serendipity['dbLastResult'], $i, $result_type);
-                    $rows[$row[$assocKey]] = $row[$assocVal];
+                    if (empty($assocVal)) {
+                        $rows[$row[$assocKey]] = $row;
+                    } else {
+                        $rows[$row[$assocKey]] = $row[$assocVal];
+                    }
                 } else {
                     $rows[] = pg_fetch_array($serendipity['dbLastResult'], $i, $result_type);
                 }
index ab043390628c7eddd8b6d4a6f7d6598126237cd6..c8bc7b5b988a8a430b2e2b44900529040d1de42f 100644 (file)
@@ -173,11 +173,11 @@ function serendipity_db_in_sql($col, &$search_ids, $type = ' OR ') {
     if (!is_array($search_ids)) {
         return false;
     }
-    
+
     foreach($search_ids AS $id) {
         $sql[] = $col . ' = ' . $id;
     }
-    
+
     $cond = '(' . implode($type, $sql) . ')';
     return $cond;
 }
@@ -221,7 +221,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
         fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE QUERY: ' . $sql . "\n\n");
         fclose($fp);
     }
-    
+
     if ($reportErr && !$expectError) {
         $res = sqlite_query($sql, $serendipity['dbConn']);
     } else {
@@ -257,9 +257,13 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
         $rows = array();
 
         while (($row = serendipity_db_sqlite_fetch_array($res, $type_map[$result_type]))) {
-            if (!empty($assocKey) && !empty($assocVal)) {
+            if (!empty($assocKey)) {
                 // You can fetch a key-associated array via the two function parameters assocKey and assocVal
-                $rows[$row[$assocKey]] = $row[$assocVal];
+                if (empty($assocVal)) {
+                    $rows[$row[$assocKey]] = $row;
+                } else {
+                    $rows[$row[$assocKey]] = $row[$assocVal];
+                }
             } else {
                 $rows[] = $row;
             }
index c16d2b88be4ab2cfd4f9b2ccbcb38cbe12c4665a..b42deeba131257450733faba67795f9179027208 100644 (file)
@@ -1505,9 +1505,10 @@ function serendipity_ACLCheck($authorid, $artifact_id, $artifact_type, $artifact
  * @param   array       Associative array that holds the SQL part array to be used in other functions like serendipity_fetchEntries()
  * @param   boolean     Some queries do not need to joins categories. When ACLs need to be applied, this column is required, so if $append_category is set to true it will perform this missing JOIN.
  * @param   string      The ACL type ('category', 'directory')
+ * @param   string      ACL mode
  * @return  true        True if ACLs were applied, false if not.
  */
-function serendipity_ACL_SQL(&$cond, $append_category = false, $type = 'category') {
+function serendipity_ACL_SQL(&$cond, $append_category = false, $type = 'category', $mode = 'read') {
     global $serendipity;
 
     // A global configuration item controls whether the blog should apply ACLs or not!
@@ -1549,7 +1550,7 @@ function serendipity_ACL_SQL(&$cond, $append_category = false, $type = 'category
         $cond['joins'] .= " LEFT JOIN {$serendipity['dbPrefix']}authorgroups AS acl_a
                                    ON acl_a.authorid = " . $read_id . "
                             LEFT JOIN {$serendipity['dbPrefix']}access AS acl_acc
-                                   ON (    acl_acc.artifact_mode = 'read'
+                                   ON (    acl_acc.artifact_mode = '" . $mode . "'
                                        AND acl_acc.artifact_type = '" . $type . "'
                                        " . $sql_artifact . "
                                       )";
index daac416c678e4c5c7af24559b8b7221de9010370..82995d2dd226d4bec37df3b376ab14d598bcf4e1 100644 (file)
@@ -125,18 +125,40 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order
  * @param   int     The ID of an media item
  * @return  array   The media info data
  */
-function serendipity_fetchImageFromDatabase($id) {
+function serendipity_fetchImageFromDatabase($id, $mode = 'read') {
     global $serendipity;
 
-    $cond = array(
-        'and' => "WHERE id = " . (int)$id
-    );
-    serendipity_ACL_SQL($cond, false, 'directory');
+    if (is_array($id)) {
+        $cond = array(
+            'and' => "WHERE i.id IN (" . implode(',', $id) . ")"
+        );
+        $single   = false;
+        $assocKey = 'id';
+        $assocVal = false;
+    } else {
+        $cond = array(
+            'and' => "WHERE i.id = " . (int)$id
+        );
+        $single   = true;
+        $assocKey = false;
+        $assocVal = false;
+    }
 
-    $rs = serendipity_db_query("SELECT i.*
+    if ($serendipity['dbType'] == 'postgres') {
+        $cond['group']    = '';
+        $cond['distinct'] = 'DISTINCT';
+    } else {
+        $cond['group']    = 'GROUP BY i.id';
+        $cond['distinct'] = '';
+    }
+
+    serendipity_ACL_SQL($cond, false, 'directory', $mode);
+
+    $rs = serendipity_db_query("SELECT {$cond['distinct']} i.id, i.name, i.extension, i.mime, i.size, i.dimensions_width, i.dimensions_height, i.date, i.thumbnail_name, i.authorid, i.path, i.hotlink
                                   FROM {$serendipity['dbPrefix']}images AS i
                                        {$cond['joins']}
-                                       {$cond['and']}", true, 'assoc');
+                                       {$cond['and']}
+                                       {$cond['group']}", $single, 'assoc', false, $assocKey, $assocVal);
     return $rs;
 }
 
@@ -225,7 +247,7 @@ function serendipity_deleteImage($id) {
     }
 
     serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}images WHERE id = ". (int)$id);
-
+    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}mediaproperties WHERE mediaid = ". (int)$id);
 }
 
 /**
@@ -1400,111 +1422,21 @@ function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = fa
     </tr>
     <tr>
 <?php
-        $x = 0;
         foreach ($serendipity['imageList'] as $k => $file) {
-            ++$x; $preview = '';
-                       $sThumbSource = serendipity_getThumbNailPath($file['path'], $file['name'], $file['extension'], $file['thumbnail_name']);
-                       $img          = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $sThumbSource;
-                       if (!isset($file['imgsrc'])) {
-               $file['imgsrc'] = $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . (!empty($file['thumbnail_name']) ? '.' . $file['thumbnail_name'] : '') . '.' . $file['extension'];
-                       }
-                       $i        = @getimagesize($img);
-            $is_image = serendipity_isImage($file);
-
             if (!($serendipity['authorid'] == $file['authorid'] || $file['authorid'] == '0' || serendipity_checkPermission('adminImagesViewOthers'))) {
                 // This is a fail-safe continue. Basically a non-matching file should already be filtered in SQL.
                 continue;
             }
 
-            /* If it is an image, and the thumbnail exists */
-            if ($is_image && file_exists($img)) {
-                $preview .= '<img src="' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $sThumbSource . '" border="0" title="' . $file['path'] . $file['name'] . '" alt="'. $file['name'] . '" />';
-                if ($url) {
-                    $preview = '<a href="'. $url .'&amp;serendipity[image]='. $file['id'] .'">'. $preview .'</a>';
-                }
-            } elseif ($is_image && $file['hotlink']) {
-                $sizes = serendipity_calculate_aspect_size($file['dimensions_width'], $file['dimensions_height'], $serendipity['thumbSize']);
-                $preview .= '<img src="' . $file['path'] . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" border="0" title="' . $file['path'] . '" alt="'. $file['name'] . '" />';
-                if ($url) {
-                    $preview = '<a href="'. $url .'&amp;serendipity[image]='. $file['id'] .'">'. $preview .'</a>';
-                }
-            /* If it's not an image, or the thumbnail does not exist */
-            } else {
-                $mimeicon = serendipity_getTemplateFile('admin/img/mime_' . preg_replace('@[^a-z0-9\-\_]@i', '-', $file['mime']) . '.png');
-                if (!$mimeicon) {
-                    $mimeicon = serendipity_getTemplateFile('admin/img/mime_unknown.png');
-                }
-                $preview .= '<img src="'. $mimeicon .'" title="' . $file['path'] . $file['name'] . ' (' . $file['mime'] . ')" alt="'. $file['mime'] .'" /><br /><span style="font-weight: bold; font-size: 8pt">- ' . (($file['hotlink']) ? MEDIA_HOTLINKED : $file['mime']) .' -</span>';
-                if ($url) {
-                    $preview .= '<br /><a href="' . $url . '&amp;serendipity[image]=' . $file['id'] . '">' . $file['name'] . '.' . $file['extension'] . '</a>';
-                }
-                $preview .= '</div>';
-            }
-
-?>
-                <td nowrap="nowrap" align="center" valign="<?php echo $manage ? 'top' : 'middle' ?>" width="<?php echo round(1/$lineBreak*100) ?>%" class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo (($i % 2) ? 'even' : 'uneven') ?>">
-<?php
-if ( !$manage ) {
-    echo $preview;
-} else { ?>
-                    <table width="100%" border="0" cellspacing="0" cellpadding="3">
-                        <tr>
-                            <td valign="top" width="16" rowspan="3">
-<?php
-                if ($serendipity['authorid'] == $file['authorid'] || $file['authorid'] == '0' || serendipity_checkPermission('adminImagesMaintainOthers')) {
-                    $popupWidth = ($is_image ? ($file['dimensions_width'] + 20) : 600);
-                    $popupHeight = ($is_image ? ($file['dimensions_height'] + 20) : 500);
-?>
-                            <img class="serendipityImageButton" title="<?php echo MEDIA_FULLSIZE; ?>" alt="<?php echo MEDIA_FULLSIZE; ?>" src="<?php echo serendipity_getTemplateFile('admin/img/big_zoom.png') ?>"   border="0" onclick="F1 = window.open('<?php echo ($file['hotlink'] ? $file['path'] : $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.'. $file['extension']); ?>','Zoom','height=<?php echo $popupHeight; ?>,width=<?php echo $popupWidth; ?>,top='+ (screen.height-<?php echo $popupHeight ?>)/2 +',left='+ (screen.width-<?php echo $popupWidth ?>)/2 +',toolbar=no,menubar=no,location=no,resize=1,resizable=1<?php echo ($is_image ? '' : ',scrollbars=yes'); ?>');" /><br />
-                            <img class="serendipityImageButton" title="<?php echo MEDIA_RENAME; ?>" alt="<?php echo MEDIA_RENAME; ?>" src="<?php echo serendipity_getTemplateFile('admin/img/big_rename.png') ?>" border="0" onclick="rename('<?php echo $file['id']; ?>', '<?php echo addslashes($file['name']); ?>')" /><br />
-                            <?php if ($is_image && !$file['hotlink']) { ?><img class="serendipityImageButton" title="<?php echo IMAGE_RESIZE; ?>"   alt="<?php echo IMAGE_RESIZE; ?>"   src="<?php echo serendipity_getTemplateFile('admin/img/big_resize.png') ?>" border="0" onclick="location.href='?serendipity[adminModule]=images&amp;serendipity[adminAction]=scaleSelect&amp;serendipity[fid]=<?php echo $file['id']; ?>';" /><br /><?php } ?>
-                            <?php if ($is_image && !$file['hotlink']) { ?><a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=rotateCCW&amp;serendipity[fid]=<?php echo $file['id']; ?>"><img class="serendipityImageButton" title="<?php echo IMAGE_ROTATE_LEFT; ?>" alt="<?php echo IMAGE_ROTATE_LEFT; ?>" src="<?php echo serendipity_getTemplateFile('admin/img/big_rotate_ccw.png') ?>" border="0" /></a><br /><?php } ?>
-                            <?php if ($is_image && !$file['hotlink']) { ?><a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=rotateCW&amp;serendipity[fid]=<?php echo $file['id']; ?>"><img class="serendipityImageButton" title="<?php echo IMAGE_ROTATE_RIGHT; ?>" alt="<?php echo IMAGE_ROTATE_RIGHT; ?>" src="<?php echo serendipity_getTemplateFile('admin/img/big_rotate_cw.png') ?>" border="0" /></a><br /><?php } ?>
-                            <a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=properties&amp;serendipity[fid]=<?php echo $file['id']; ?>"><img class="serendipityImageButton" title="<?php echo MEDIA_PROP; ?>"   alt="<?php echo MEDIA_PROP; ?>"   src="<?php echo serendipity_getTemplateFile('admin/img/configure.png') ?>" border="0" /></a><br />
-                            <a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=delete&amp;serendipity[fid]=<?php echo $file['id']; ?>"><img class="serendipityImageButton" title="<?php echo MEDIA_DELETE; ?>"   alt="<?php echo MEDIA_DELETE; ?>"   src="<?php echo serendipity_getTemplateFile('admin/img/big_delete.png') ?>" border="0" /></a><br />
-<?php
-                }
-?>
-                            </td>
-                            <td colspan="2">
-                                <div class="serendipity_media_filename" style="font-weight: bold; font-size: 8pt"><?php echo $file['name'] . '.' . $file['extension']; ?></div>
-                                <div class="serendipity_media_author" style="font-size: 8pt"><?php echo ($file['authorid'] != '0' ? $file['authorname'] : ''); ?></div>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td align="center" colspan="2"><?php echo $preview ?></td>
-                        </tr>
-                        <tr>
-                            <td colspan="2" height="10" align="center" style="font-size: 8pt">
-<?php
-                if ($is_image && !$file['hotlink']) {
-                    echo ORIGINAL_SHORT . ': ' . $file['dimensions_width'] . 'x' . $file['dimensions_height'] .', ';
-                    echo THUMBNAIL_SHORT . ': ' . $i[0] . 'x' . $i[1];
-                } elseif ($file['hotlink']) {
-                    echo wordwrap($file['path'], 45, '<br />', 1);
-                } else {
-                    echo SORT_ORDER_SIZE . ': ' . number_format(round($file['size']/1024, 2), NUMBER_FORMAT_DECIMALS, NUMBER_FORMAT_DECPOINT, NUMBER_FORMAT_THOUSANDS) . 'kb';
-                }
-?>
-                            </td>
-                        </tr>
-                    </table>
-<?php } ?>
-        </td>
-<?php
-        // Newline?
-        if ($x % $lineBreak == 0) {
-?>
-    </tr>
-    <tr>
-<?php
+            serendipity_prepareMedia($serendipity['imageList'][$k], $url);
         }
+
+        serendipity_showMedia($serendipity['imageList'], $url, $manage, $lineBreak, true);
     }
 ?>
     </tr>
 </table>
 <?php
-}
 } // End serendipity_displayImageList()
 
 /**
@@ -2022,6 +1954,9 @@ function serendipity_showPropertyForm(&$new_media, $keywordsPerBlock = 3, $manag
         return true;
     }
 
+    $mirror = array();
+    serendipity_checkPropertyAccess($new_media, $mirror, 'read');
+
     $dprops   = explode(';', $serendipity['mediaProperties']);
     $keywords = explode(';', $serendipity['mediaKeywords']);
 
@@ -2045,6 +1980,10 @@ function serendipity_showPropertyForm(&$new_media, $keywordsPerBlock = 3, $manag
 
     foreach($new_media AS $idx => $media) {
         $props =& serendipity_fetchMediaProperties($media['image_id']);
+
+        serendipity_prepareMedia($media['internal']);
+        serendipity_showMedia($file, $url, false, 1, false);
+
         echo '<input type="hidden" name="serendipity[mediaProperties][' . $idx . '][image_id]"          value="' . (int)$media['image_id'] . '" />' . "\n";
 
         echo '<h3>' . MEDIA_PROP . '</h3>';
@@ -2133,12 +2072,13 @@ function serendipity_parsePropertyForm() {
         return false;
     }
 
+    serendipity_checkPropertyAccess($serendipity['POST']['mediaProperties'], $serendipity['POST']['mediaKeywords'], 'write');
+
     foreach($serendipity['POST']['mediaProperties'] AS $id => $media) {
         serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}mediaproperties
                                     WHERE mediaid = " . (int)$media['image_id'] . "
                                       AND property_subgroup = ''
-                                      AND (property_group = 'base_property'
-                                       OR  property_group = 'base_keyword')");
+                                      AND property_group = 'base_property'");
         foreach($media AS $key => $val) {
             if ($key == 'image_id') continue;
             $q = sprintf("INSERT INTO {$serendipity['dbPrefix']}mediaproperties
@@ -2152,6 +2092,11 @@ function serendipity_parsePropertyForm() {
     }
 
     foreach($serendipity['POST']['mediaKeywords'] AS $id => $keywords) {
+        serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}mediaproperties
+                                    WHERE mediaid = " . (int)$serendipity['POST']['mediaProperties'][$id]['image_id'] . "
+                                      AND property_subgroup = ''
+                                      AND property_group = 'base_keyword'");
+
         foreach($keywords AS $keyword => $checked) {
             $q = sprintf("INSERT INTO {$serendipity['dbPrefix']}mediaproperties
                                       (mediaid, property_group, property_subgroup, property, value)
@@ -2193,4 +2138,139 @@ function &serendipity_fetchMediaProperties($id) {
         }
     }
     return $props;
+}
+
+/**
+ * Checks if properties to a specific image are allowed to be fetched
+ *
+ * @param  array    Array of image metadata
+ * @param  array    Array of additional image metadata
+ * @param  string   ACL toggle type ('read', 'write')
+ * @return array    Stripped Array of image metadata
+ *
+ */
+function serendipity_checkPropertyAccess(&$new_media, &$additional, $mode = 'read') {
+    global $serendipity;
+
+    // Strip out images we don't have access to
+    $ids = array();
+    foreach($new_media AS $id => $item) {
+        $ids[] = $item['image_id'];
+    }
+
+    $valid_images = serendipity_fetchImageFromDatabase($ids, $mode);
+    foreach ($new_media AS $id => $media) {
+        if (!isset($valid_images[$media['image_id']])) {
+            unset($new_media[$id]);
+            unset($additional[$id]);
+        } else {
+            $new_media[$id]['internal'] = $valid_images[$media['image_id']];
+        }
+    }
+
+    return true;
+}
+
+/**
+ * Prepare a media item for showing
+ *
+ * @param  array    Array of image metadata
+ * @param  string   URL for maintenance tasks
+ * @return bool
+ *
+ */
+function serendipity_prepareMedia(&$file, $url = '') {
+    global $serendipity;
+    static $full_perm = null;
+
+    if ($full_perm === null) {
+        $full_perm = serendipity_checkPermission('adminImagesMaintainOthers');
+    }
+
+       $sThumbSource = serendipity_getThumbNailPath($file['path'], $file['name'], $file['extension'], $file['thumbnail_name']);
+       $img          = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $sThumbSource;
+       if (!isset($file['imgsrc'])) {
+       $file['imgsrc'] = $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . (!empty($file['thumbnail_name']) ? '.' . $file['thumbnail_name'] : '') . '.' . $file['extension'];
+       }
+       $file['dim']       = @getimagesize($img);
+    $file['is_image']  = serendipity_isImage($file);
+    $file['full_file'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.'. $file['extension'];
+
+    if ($full_perm || $serendipity['authorid'] == $file['authorid'] || $file['authorid'] == '0') {
+        $file['is_editable'] = true;
+    } else {
+        $file['is_editable'] = false;
+    }
+
+    /* If it is an image, and the thumbnail exists */
+    if ($file['is_image'] && file_exists($img)) {
+        $file['preview'] .= '<img src="' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $sThumbSource . '" border="0" title="' . $file['path'] . $file['name'] . '" alt="'. $file['name'] . '" />';
+        if ($url) {
+            $file['preview'] = '<a href="'. $url .'&amp;serendipity[image]='. $file['id'] .'">'. $file['preview'] .'</a>';
+        }
+    } elseif ($file['is_image'] && $file['hotlink']) {
+        $sizes = serendipity_calculate_aspect_size($file['dimensions_width'], $file['dimensions_height'], $serendipity['thumbSize']);
+        $file['preview'] .= '<img src="' . $file['path'] . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" border="0" title="' . $file['path'] . '" alt="'. $file['name'] . '" />';
+        if ($url) {
+            $file['preview'] = '<a href="'. $url .'&amp;serendipity[image]='. $file['id'] .'">'. $file['preview'] .'</a>';
+        }
+    /* If it's not an image, or the thumbnail does not exist */
+    } else {
+        $mimeicon = serendipity_getTemplateFile('admin/img/mime_' . preg_replace('@[^a-z0-9\-\_]@i', '-', $file['mime']) . '.png');
+        if (!$mimeicon) {
+            $mimeicon = serendipity_getTemplateFile('admin/img/mime_unknown.png');
+        }
+        $file['preview'] .= '<img src="'. $mimeicon .'" title="' . $file['path'] . $file['name'] . ' (' . $file['mime'] . ')" alt="'. $file['mime'] .'" /><br /><span style="font-weight: bold; font-size: 8pt">- ' . (($file['hotlink']) ? MEDIA_HOTLINKED : $file['mime']) .' -</span>';
+        if ($url) {
+            $file['preview'] .= '<br /><a href="' . $url . '&amp;serendipity[image]=' . $file['id'] . '">' . $file['name'] . '.' . $file['extension'] . '</a>';
+        }
+        $file['preview'] .= '</div>';
+    }
+
+    $file['popupWidth']   = ($file['is_image'] ? ($file['dimensions_width']  + 20) : 600);
+    $file['popupHeight']  = ($file['is_image'] ? ($file['dimensions_height'] + 20) : 500);
+    if ($file['hotlink']) {
+        $file['nice_hotlink'] = wordwrap($file['path'], 45, '<br />', 1);
+    }
+    $file['nice_size']    = number_format(round($file['size']/1024, 2), NUMBER_FORMAT_DECIMALS, NUMBER_FORMAT_DECPOINT, NUMBER_FORMAT_THOUSANDS);
+
+    return true;
+}
+
+/**
+ * Prints a media item
+ *
+ * @param  array    Array of image metadata
+ * @param  string   URL for maintenance tasks
+ * @param  boolean  Whether to show maintenance task items
+ * @param  int      how many media items to display per row
+ * @param  boolean  Enclose within a table cell?
+ * @return boolean
+ *
+ */
+function serendipity_showMedia(&$file, $url = '', $manage = false, $lineBreak = 3, $enclose = true) {
+    global $serendipity;
+
+    serendipity_smarty_init();
+    $media = array(
+        'manage'       => $manage,
+        'lineBreak'    => $lineBreak,
+        'lineBreakP'   => round(1/$lineBreak*100),
+        'url'          => $url,
+        'enclose'      => $enclose,
+        'zoomIMG'      => serendipity_getTemplateFile('admin/img/big_zoom.png'),
+        'renameIMG'    => serendipity_getTemplateFile('admin/img/big_rename.png'),
+        'resizeIMG'    => serendipity_getTemplateFile('admin/img/big_resize.png'),
+        'rotatecwIMG'  => serendipity_getTemplateFile('admin/img/big_rotate_ccw.png'),
+        'rotateccwIMG' => serendipity_getTemplateFile('admin/img/big_rotate_cw.png'),
+        'configureIMG' => serendipity_getTemplateFile('admin/img/configure.png'),
+        'deleteIMG'    => serendipity_getTemplateFile('admin/img/big_delete.png')
+
+    );
+    $media['files'] =& $file;
+
+    $serendipity['smarty']->assign('media', $media);
+    $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_items.tpl', 'serendipityPath'));
+
+    return true;
 }
\ No newline at end of file
index bfa9933f46e80af63addb94136a491e139d7b72f..cfe870397505c349041a0d5994ec4d8b9db83a3b 100644 (file)
@@ -79,6 +79,7 @@ function show_plugins($event_only = false)
         $plugin_placements = array('left', 'right', 'hide');\r
     }\r
 \r
+    $total = 0;\r
     foreach ($plugin_placements as $plugin_placement) {\r
         $plugins = serendipity_plugin_api::enum_plugins($plugin_placement);\r
 \r
@@ -88,6 +89,7 @@ function show_plugins($event_only = false)
 \r
         $sort_idx = 0;\r
         foreach ($plugins as $plugin_data) {\r
+            $total++;\r
             $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);\r
             $key    = urlencode($plugin_data['name']);\r
             $is_plugin_owner    = ($plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'));\r
@@ -174,6 +176,9 @@ function show_plugins($event_only = false)
         }\r
     }\r
 ?>\r
+        <tr>\r
+            <td colspan="6" align="right"><?php printf(PLUGIN_AVAILABLE_COUNT, $total); ?></td>\r
+        </tr>\r
         </table>\r
         <br />\r
         <div>\r
@@ -310,7 +315,7 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
                 $value = $plugin->get_config($config_item, false, true);\r
             }\r
         }\r
-        \r
+\r
         if (isset($_POST['serendipity'][$postkey][$config_item])) {\r
             if (is_array($_POST['serendipity'][$postkey][$config_item])) {\r
                 $hvalue = $_POST['serendipity'][$postkey][$config_item];\r
@@ -348,7 +353,7 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
                 } else {\r
                     $selected_options = array($hvalue => $hvalue);\r
                 }\r
-                \r
+\r
                 $pre_selected = (array)$cbag->get('select_preselected');\r
                 $select_size  = $cbag->get('select_size');\r
                 $select = $cbag->get('select_values');\r
@@ -499,7 +504,7 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
             case 'hidden':\r
                 ?><tr><td colspan="2"><input class="direction_<?php echo $lang_direction; ?>" type="hidden" name="serendipity[<?php echo $postKey; ?>][<?php echo $config_item; ?>]" value="<?php echo $cbag->get('value'); ?>" /></td></tr><?php\r
                 break;\r
-            \r
+\r
             default:\r
                 // Unknown configuration key. Let the plugin handle it.\r
                 $addData = func_get_args();\r
@@ -522,8 +527,8 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
 <br />\r
 <?php\r
     }\r
-    \r
-    if ($showSubmit) { \r
+\r
+    if ($showSubmit) {\r
 ?>\r
     <div style="padding-left: 20px">\r
         <input type="submit" name="SAVECONF" value="<?php echo SAVE; ?>" class="serendipityPrettyButton" />\r
@@ -555,6 +560,6 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
 <?php\r
         }\r
     }\r
-    \r
+\r
     return true;\r
 }\r
index 67d50c6f7618862ca7ef4f807f48b1fb5c8e959e..d8c6c72b29f59746cb12e04e545edc2027ef1e42 100644 (file)
@@ -225,14 +225,19 @@ function serendipity_imageSelector_done(textarea)
         styled = true;
     }
 
+    imgID = 0;
+    if (f['imgID']) {
+        imgID = f['imgID'].value;
+    }
+
     floating = 'center';
     if (f['serendipity[align]'][0].checked == true) {
-        img = "<img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
+        img = "<!--s9ymdb:" + imgID + "--><img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
     } else if (f['serendipity[align]'][1].checked == true) {
-        img = "<img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: left; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
+        img = "<!--s9ymdb:" + imgID + "--><img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: left; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
         floating = 'left';
     } else if (f['serendipity[align]'][2].checked == true) {
-        img = "<img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: right; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
+        img = "<!--s9ymdb:" + imgID + "--><img width='" + imgWidth + "' height='" + imgHeight + "' " + (styled ? 'style="float: right; border: 0px; padding-left: 5px; padding-right: 5px;"' : '') + ' src="' + img + "\" alt=\"\" />";
         floating = 'right';
     }
 
diff --git a/templates/default/admin/media_items.tpl b/templates/default/admin/media_items.tpl
new file mode 100644 (file)
index 0000000..655ff10
--- /dev/null
@@ -0,0 +1,50 @@
+{foreach from=$media.files item="file" name="mediafiles"}
+    {if $media.enclose}
+    <td nowrap="nowrap" align="center" valign="{if $media.manage}top{else}middle{/if}" width="{$media.lineBreakP}%" class="serendipity_admin_list_item serendipity_admin_list_item_even">
+    {/if}
+
+    {if NOT $media.manage}
+        {$file.preview}
+    {else}
+        <table width="100%" border="0" cellspacing="0" cellpadding="3">
+            <tr>
+                <td valign="top" width="16" rowspan="3">
+                {if $file.is_editable}
+                    <img class="serendipityImageButton" title="{$CONST.MEDIA_FULLSIZE}" alt="{$CONST.MEDIA_FULLSIZE}" src="{$media.zoomIMG}"   border="0" onclick="F1 = window.open('{if $file.hotlink}{$file.path}{else}{$full_file}{/if}', 'Zoom', 'height={$file.popupHeight},width={$file.popupWidth},top='+ (screen.height-{$file.popupHeight})/2 +',left='+ (screen.width-{$file.popupWidth})/2 +',toolbar=no,menubar=no,location=no,resize=1,resizable=1{if NOT $file.is_image},scrollbars=yes{/if}');" /><br />
+                    <img class="serendipityImageButton" title="{$CONST.MEDIA_RENAME}"   alt="{$CONST.MEDIA_RENAME}"   src="{$media.renameIMG}" border="0" onclick="rename('{$file.id}', '{$file.name|escape:javascript}'')" /><br />
+                    {if $file.is_image AND NOT $file.hotlink}<img class="serendipityImageButton" title="{$CONST.IMAGE_RESIZE}"   alt="{$CONST.IMAGE_RESIZE}" src="{$media.resizeIMG}" border="0" onclick="location.href='?serendipity[adminModule]=images&amp;serendipity[adminAction]=scaleSelect&amp;serendipity[fid]={$file.id}';" /><br />{/if}
+                    {if $file.is_image AND NOT $file.hotlink}<a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=rotateCCW&amp;serendipity[fid]={$file.id}"><img class="serendipityImageButton" title="{$CONST.IMAGE_ROTATE_LEFT}"  alt="{$CONST.IMAGE_ROTATE_LEFT}"  src="{$media.rotateccwIMG}" border="0" /></a><br />{/if}
+                    {if $file.is_image AND NOT $file.hotlink}<a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=rotateCW&amp;serendipity[fid]={$file.id}"><img  class="serendipityImageButton" title="{$CONST.IMAGE_ROTATE_RIGHT}" alt="{$CONST.IMAGE_ROTATE_RIGHT}" src="{$media.rotateccwIMG}" border="0" /></a><br />{/if}
+                    <a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=properties&amp;serendipity[fid]={$file.id}"><img class="serendipityImageButton" title="{$CONST.MEDIA_PROP}" alt="{$CONST.MEDIA_PROP}"    src="{$media.configureIMG}" border="0" /></a><br />
+                    <a href="?serendipity[adminModule]=images&amp;serendipity[adminAction]=delete&amp;serendipity[fid]={$file.id}"><img class="serendipityImageButton" title="{$CONST.MEDIA_DELETE}"   alt="{$CONST.MEDIA_DELETE}"  src="{$media.deleteIMG}"    border="0" /></a><br />
+                {/if}
+                </td>
+                <td colspan="2">
+                    <div class="serendipity_media_filename" style="font-weight: bold; font-size: 8pt">{$file.name}.{$file.extension}</div>
+                    <div class="serendipity_media_author"   style="font-size: 8pt">{if $file.authorid != 0}{$file.authorname}{else}<br />{/if}</div>
+                </td>
+            </tr>
+            <tr>
+                <td align="center" colspan="2">{$file.preview}</td>
+            </tr>
+            <tr>
+                <td colspan="2" height="10" align="center" style="font-size: 8pt">
+                {if $file.hotlink}
+                    {$file.nice_hotlink}
+                {else}
+                    {if $file.is_image}
+                    {$CONST.ORIGINAL_SHORT}: {$file.dimensions_width}x{$file.dimensions_height},
+                    {$CONST.THUMBNAIL_SHORT}: {$file.dim.0}x{$file.dim.1}
+                    {/if}
+                    <br />{$file.nice_size}kb
+                {/if}
+                </td>
+            </tr>
+        </table>
+    {/if}
+    </td>
+
+    {if $media.enclose AND (($smarty.foreach.mediafiles.iteration % $media.lineBreak) == 0)}
+    </tr><tr>
+    {/if}
+{/foreach}
\ No newline at end of file