Index: acidfree.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/acidfree/acidfree.module,v
retrieving revision 1.147.2.30
diff -u -d -r1.147.2.30 acidfree.module
--- acidfree.module	31 Jan 2011 21:07:42 -0000	1.147.2.30
+++ acidfree.module	1 Feb 2011 15:36:17 -0000
@@ -96,9 +96,7 @@
 
 function acidfree_theme() {
     $items = array(
-/* NO_ALBUM_CONTENTS
             'acidfree_album_contents' => array('form'),
-*/
             'album_grid_view' => array('tid', 'nodes', 'teasers', 'links'),
             'album_list_view' => array('tid', 'nodes', 'teasers', 'links'),
             'acidfree_print_thumb_acidfree' => array('node'),
@@ -366,7 +364,7 @@
         case 'admin/help#acidfree':
             return t('<p>Because Acidfree is more than simply a storage and viewing module, it requires some depenencies for the album management.  First, it requires some form of image manipulation.  Drupal provides a frontend to the GD library that can do what is required.  Or, if you would rather use ImageMagick or libmagick (php-imagick module), set that up (copy the image.*.inc files to the includes directory) and select it.  Second, if you want lossless rotations for your images, you will require jpegtran or exiftran.</p><p>For video thumbnailing, there are three options.  You can choose a static image for all your videos (no thumbnail), upload your own thumbnail (user thumbnail) or have mplayer thumbnail them automatically for you.  If you choose the first option, you will be asked to give the dimensions of the video so it can be displayed correctly in the \'full\' view.  With option two, be sure to upload a thumbnail that is the same dimensions as the actual video (grab a frame from the video, do not resize it.)  The third option obviously implies that you have mplayer and all the win32 codecs installed on your <b>server</b> and that you are allowed to exec other programs (i.e., not running in safe mode.).  ');
         case 'admin/settings/acidfree':
-            return t('These settings affect all Acidfree albums and displays.  However, some items can be overridden on a per-album or per-image basis.');
+            return t('These settings affect all Acidfree albums and displays.  However, some items can be overridden on a per-album or per-image basis. To verify your Acidfree configuration, visit your ') . l('acidfree test page','acidfree/test') . '.';
         case 'admin/content/types/acidfree':
             return t("The common attributes that Acidfree will have are: 'Sticky at top of lists', which allows the albums to be sorted before the other media types (image, video, etc.) in the various album views;  and *not* 'Promoted to front page' because that would make all the albums show up at the top of the front page, which is probably not desirable.");
         default:
@@ -374,11 +372,6 @@
     }
 }
 
-/* NO_ALBUM_CONTENTS
-function acidfree_album_contents_access($node) {
-    return node_access('update', $node) && $node->type == 'acidfree';
-}
-*/
 function acidfree_album_view_access($view, $node) {
     return node_access('view', $node) && 
             variable_get('acidfree_show_alternate_view', true) &&
@@ -405,6 +398,7 @@
 
 function acidfree_menu() {
     $items = array();
+
     $items['admin/settings/acidfree'] = array(
             'title' => 'Acidfree',
             'page callback' => 'drupal_get_form',
@@ -414,6 +408,7 @@
             'access arguments' => array('administer site configuration'),
             'type' => MENU_NORMAL_ITEM,
         );
+
     $items['acidfree/test'] = array(
             'page callback' => 'acidfree_test',
             'page arguments' => array('acidfree',1),
@@ -422,6 +417,7 @@
             'access arguments' => array('administer site configuration'),
             'type' => MENU_SUGGESTED_ITEM
         );
+
     $items['acidfree'] = array(
             'page callback' => 'acidfree_page',
             'page arguments' => array('acidfree',1),
@@ -430,6 +426,7 @@
             'access arguments' => array('access content'),
             'type' => MENU_SUGGESTED_ITEM
         );
+
     $items['user/%user/acidfree'] = array(
             'page callback' => 'acidfree_page',
             'page arguments' => array('per_user_album', 1),
@@ -438,6 +435,7 @@
             'access arguments' => array('access content'),  //Pachkov.Sergey
             'type' => MENU_SUGGESTED_ITEM,
         );
+
     $items['acidfree/thumbnail/%acidfree_node'] = array(
         'title' => 'Thumbnail',
         'page callback' => 'acidfree_fetch_thumb',
@@ -445,16 +443,7 @@
             'access callback' => 'node_access',
             'access arguments' => array('view', 2),
         );
-/* NO_ALBUM_CONTENTS
-    $items['node/%acidfree_album/contents'] = array(
-            'page callback' => 'drupal_get_form',
-            'page arguments' => array('acidfree_album_contents', 1),
-            'type' => MENU_LOCAL_TASK,
-            'title' => 'Album contents',
-            'access callback' => 'acidfree_album_contents_access',
-            'access arguments' => array(1),
-        );
-*/
+
     foreach (array('list'=>'List view', 'grid'=>'Grid view') as $k=>$v) {
         $items["node/%acidfree_album/$k"] = array(
                 'page callback' => 'acidfree_album_view',
@@ -476,36 +465,16 @@
             'weight' => 5,
         );
 
-    /* FIXME
-     * kjh: not sure why this is here since it doesn't work 
     $items["node/%/contents"] = array(
-        'title' => t('Album contents'),
+        'title' => t('Mass update'),
         'page callback' => 'drupal_get_form',
-        'page arguments' => array('acidfree_album_contents', 1),
+        'page arguments' => array('acidfree_contents_mode', 1),
         'access callback' => 'user_access',
-        'access arguments' => array('use album contents mode'),
-        'type' => MENU_LOCAL_TASK
+        'access arguments' => array('acidfree mass update'),
+        'type' => MENU_LOCAL_TASK,
+        'weight' => 6,
     );
-    */
     
-    /* FIXME
-     * kjh: there is no variable named album here and it doesn't
-       make sense to have a variable since the menu is cached by
-       drupal
-    $other_view = array('grid' => 'list', 'list' => 'grid');
-    $view_name = array('grid' => t('Grid'), 'list' => t('List'));
-    $view = $other_view[$album->view];
-
-    $items["node/%/{$view}"] = Array(
-        'title' => $view_name[$view],
-        'page callback' => 'acidfree_album_view',
-        'page arguments' => array("album_{$view}_view", 1),
-        'access arguments' => array(1), 
-        'type' => MENU_LOCAL_TASK,
-        'weight' => -4,
-        );
-    */
-
     $items['user/%user/edit/acidfree'] = array(
         'title' => t('My Albums'),
         'page callback' => 'acidfree_page',
@@ -930,24 +899,6 @@
     if (function_exists('_class_video_manipulation_options'))
         $form = array_merge($form, acidfree_call('_class_video_manipulation_options'));
 
-/* NO_ALBUM_CONTENTS
-    $form['album_contents'] = array(
-            '#type' => 'fieldset',
-            '#title' => t('Album Contents'),
-            '#collapsible' => 'true',
-        );
-    $form['album_contents']['acidfree_content_fields_all'] = array(
-            '#title' => t('Show all fields available in "Album Contents" view'),
-            '#type' => 'checkbox',
-            '#default_value' => variable_get('acidfree_content_fields_all', true),
-        );
-    $form['album_contents']['fields']['#type'] = 'fieldset';
-    $form['album_contents']['fields']['#title'] = t('Fields to show');
-    $form['album_contents']['fields']['#collapsible'] = true;
-    $form['album_contents']['fields']['#collapsed'] = variable_get('acidfree_content_fields_all', true);
-    $form['album_contents']['fields']['#description'] = t('The album contents view gets very cluttered.  To remedy this, you may pick and choose which field elements appear on the form and what column they appear in.  The form will render with two columns and you may put any item in either column.');
-    $form['album_contents']['fields']['acidfree_content_fields'] = _album_contents_available_fields();
-*/
     drupal_set_title(t('Acidfree settings'));
 
     return system_settings_form($form);
@@ -990,9 +941,8 @@
     $perms[] = 'edit own acidfree albums';
     $perms[] = 'acidfree mass import';
     $perms[] = 'can upload to any album';
-/* NO_ALBUM_CONTENTS
-    $perms[] = 'use album contents mode';
-*/
+    $perms[] = 'acidfree mass update';
+
     if (variable_get('acidfree_per_user_albums', 0)) {
         $perms[] = 'get a per-user album';
     }
@@ -1928,6 +1878,9 @@
     }
     
     drupal_add_js(drupal_get_path('module', 'acidfree').'/acidfree.js');
+    // Under the old interface, we got a parent node. Now we may get a nid.
+    // NOTE: this may be unneeded eventually, but some sites that migrated
+    // to 6.x seem to behave differently than new 6.x sites.
     if (is_numeric($parent)) {
         $parent=node_load($parent);
     }
@@ -2050,6 +2003,126 @@
     return $form;
 }
 
+/*
+ * Displays a form allowing users to edit multiple items at once.
+ */
+
+function acidfree_contents_mode($form_state, $parent) {
+
+    $parent = node_load($parent);
+
+    drupal_set_title(t('%title Contents', array('%title' => $parent->title)));
+    drupal_add_js(drupal_get_path('module', 'acidfree').'/acidfree.js');
+
+    $form = array();
+
+    $vid = acidfree_get_vocab_id();
+
+    $nodes_per_page = min(15, variable_get('acidfree_num_thumbs', 15));
+    if ($nodes_per_page <= 0) {
+      $nodes_per_page = 15;
+    }
+
+    $pnode = _album_from_tid($parent->tid);
+
+    $pager_sort = $pnode->order_by;
+    if (!$pager_sort || $pager_sort == '<default>') {
+        $pager_sort = variable_get('acidfree_order', 'node.nid DESC');
+    }
+    $pager_sort = _acidfree_content_sort_clause($pnode);
+
+    $nodes = _acidfree_get_children($parent->tid, $nodes_per_page, 
+        ALBUM_PAGER, true, $pager_sort);
+    if (count($nodes) == 0)
+        return array('empty' => array('#value' => t("This album is empty")."<br/>"));
+
+    $form['pager'] = array(
+        '#value' => theme('pager', NULL, $nodes_per_page, ALBUM_PAGER));
+
+    $form['batch'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Batch Update'),
+        '#collapsible' => true,
+    );
+    
+    $form['batch']['help'] = array(
+        '#type' => 'item',
+        '#value' => t('Use this section to move or copy all the selected items to another album, or to delete all the selected items.'),
+    );
+
+    $form['batch']['select'] = array(
+        '#type' => 'select',
+        '#default_value' => '0',
+        '#options' => array('0'=>' -- ', 'all'=>t('All'), 
+            'none'=>t('None'), 'invert'=>t('Invert')),
+        '#attributes' => array('onchange' => 'select_nodes(this);'),
+        '#title' => 'Select',
+        );
+    $form['batch']['parent'] = _acidfree_parent_select($parent->tid);
+    $form['batch']['parent'][$vid]['#attributes'] = 
+        array('onchange' => 'update_parent_selects(this);');
+    $form['batch']['parent'][$vid]['#title'] = t('Destination');
+    $form['batch']['parent']['#weight'] = 1;
+    _acidfree_filter_taxonomy($form['batch']['parent'][$vid]);
+
+    $form['batch']['move'] = array( '#weight'=> 2, '#type' => 'submit', '#value' =>t('Move'));
+    $form['batch']['copy'] = array( '#weight'=> 2, '#type' => 'submit', '#value' =>t('Copy'));
+    $form['batch']['delete'] = array('#weight'=> 2, '#type' => 'submit','#value' =>t('Delete'));
+
+    $form['nodes']['#tree'] = true;
+    $i = 0;
+
+    foreach ($nodes as $child) {
+
+        $child = node_load($child);
+        
+        //$form['nodes'][$i] = array(
+            //'#type' => 'fieldset',
+            //'#title' => $child->title,
+            //'#collapsible' => 0,
+        //);
+
+        $form['nodes'][$i]['nid'] = array(
+            '#type' => 'hidden',
+            '#value' => $child->nid,
+        );
+
+        $form['nodes'][$i]['type'] = array(
+            '#type' => 'hidden',
+            '#value' => $child->type,
+            //'#tree' => true,
+        );
+        $form['nodes'][$i]['checked'] = array(
+            '#type' => 'checkbox',
+            '#default_value' => 0,
+            //'#tree' => true,
+        );
+
+        $form['nodes'][$i]['thumb'] = array(
+            '#type' => 'item',
+            '#value' => '<div class="acidfree-contents-field">' . 
+                theme("acidfree_print_thumb_{$child->type}", 
+                node_load($child->nid)) .  '</div>',
+        );
+
+        $form['nodes'][$i]['divider'] = array(
+            '#type' => 'item',
+            '#value' => '<div style="clear: both" /><hr/>',
+        );
+
+        $i++;
+    }
+
+    return $form;
+}
+
+function _acidfree_render_thumbnail($content, $element)
+{
+    $nid = $element['nid']['#value'];
+    $type = $element['type']['#value'];
+    return $content . $thumbnail;
+}
+
 /* tags we recognize:
  *   style => css style info for the image
  *   size => image size in pixels (can be WxH or just largest dimension)
