/[drupal]/contributions/modules/acidfree/class_image.inc
ViewVC logotype

Contents of /contributions/modules/acidfree/class_image.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.14 - (show annotations) (download) (as text)
Thu May 10 05:07:29 2007 UTC (2 years, 6 months ago) by vhmauery
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.13: +2 -1 lines
File MIME type: text/x-php
only count acidfree terms to decide if item has multiple parents
1 <?php
2 /* ex: set tabstop=4 expandtab shiftwidth=4 softtabstop=4: */
3 /*
4 Acidfree image Albums for Drupal
5 Copyright (C) 2005 Vernon Mauery
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 /**
23 * @file
24 * The is the class implementation of the image. All the acidfree elements
25 * must be defined in this same manner, which makes creating a new class
26 * relatively simple -- copy one of the existing classes and modify the
27 * relevant functions.
28 */
29
30 //require_once('image_manip.inc');
31
32 function class_image_register() {
33 $class = new stdClass();
34 if (!module_exists('image')) {
35 return $class;
36 }
37 $class->class = 'image';
38 $class->name = t('image');
39 $class->addme = t('Add an image');
40 $class->max_size = 2*(1 << 20);
41 /* i.e. reports image/pjpeg as mime type for jpegs. grrr. */
42 $class->mime_ext = Array('image/jpeg'=>'jpg', 'image/pjpeg'=>'jpg', 'image/png'=>'png', 'image/gif' => 'gif');
43 $class->form_alter = '_class_image_form_alter';
44 $class->nodeapi = '_class_image_nodeapi';
45 $class->access = 'create images';
46 return $class;
47 }
48
49 function theme_acidfree_print_thumb_image(&$node, $parent=null) {
50 $vid = acidfree_get_vocab_id();
51 if (count($node->taxonomy[$vid]) > 1 && $parent) {
52 $p = "pid={$parent->tid}";
53 }
54 $info = image_get_info(file_create_path($node->images['thumbnail']));
55
56 $image = _acidfree_image_display($node, 'thumbnail', array('width' => $info['width'], 'height' => $info['height']));
57
58 $h = $info['height'] + variable_get('acidfree_extra_length',12);
59 $w = $info['width'] + variable_get('acidfree_extra_length',12);
60
61 $path = "node/{$node->nid}";
62 $overlay = l('', $path, array('title' => $node->title), $p, NULL, true, true);
63 $image = l($image, $path, array('title' => $node->title), $p, NULL, true, true);
64 $title = l($node->title, $path, array('title' => $node->title), $p, NULL, true, true);
65
66 $imagediv = '<div class="acidfree-cell"><div class="acidfree-item acidfree-image">';
67 $imagediv .= "<div class='acidfree-thumbnail' style='width: {$w}px; height: {$h}px;'>";
68 $imagediv .= $image . '<div class="acidfree-overlay">' . $overlay . '</div></div>';
69 $imagediv .= "<p>$title</p></div></div>";
70 return $imagediv;
71 }
72
73 function _class_image_rotate(&$node) {
74 if ($node->rotate != 0) {
75 _image_remove($node);
76 $large_path = file_create_path($node->images['_original']);
77 acidfree_rotate_image($large_path, $node->rotate);
78 $filesize = filesize($large_path);
79 db_query("UPDATE {files} SET filesize=%d WHERE filename='%s' AND nid=%d",
80 $filesize, '_original', $node->nid);
81 _image_build_derivatives($node);
82 }
83 }
84
85 function _class_image_form_alter($form_id, &$form) {
86 $vid = acidfree_get_vocab_id();
87 if (($arg = _path_match('node', 'add', 'image', '%d'))) {
88 $album = acidfree_get_node_by_id($arg[0]);
89 $form['taxonomy'][$vid]['#default_value'] = array($album->tid);
90 }
91 _acidfree_filter_taxonomy($form['taxonomy'][$vid]);
92 $js_attrs = array('onchange' => 'set_title(this.value);');
93 $form['image']['#attributes'] = is_array($form['image']['#attributes']) ?
94 array_merge($js_attrs, $form['image']['#attributes']) : $js_attrs;
95 $form['body']['#rows'] = 5;
96 $rotate_options = Array(
97 '270' => t('Counterclockwise'),
98 '0' => t('No rotation'),
99 '90' => t('Clockwise'),
100 'auto'=>t('Use exif orientation tag'),
101 );
102 $form['rotate'] = array(
103 '#type' => 'select',
104 '#title' => t('Rotate image'),
105 '#default_value' => '0',
106 '#options' => $rotate_options,
107 '#acidfree_form' => true,
108 '#attributes' => array('class' => 'rotate'),
109 );
110 if (($arg = _path_match('album', '%d', 'contents'))) {
111 unset($form['image']);
112 unset($form['format']);
113 }
114 }
115
116 function theme_acidfree_view_image($image) {
117 // add some other divs for theming purposes
118 $image = '<div class="acidfree-item acidfree-image">'.$image.'</div>';
119 return $image;
120 }
121
122 function _class_image_view_alter(&$node) {
123 if (isset($node->content)) {
124 //dump_msg($node->content);
125 $request = ($_GET['size']) ? $_GET['size'] : 'preview';
126 $image = $node->content['image']['#value'];
127 // if we are not viewing the original, link to the original
128 if (user_access('view original images') &&
129 ($node->images[$request] != $node->images['_original'])) {
130 $image = l($image, "node/{$node->nid}", array(), 'size=_original', null, null, true);
131 }
132 $node->content['image']['#value'] = theme('acidfree_view_image', $image);
133 }
134 }
135 ?>

  ViewVC Help
Powered by ViewVC 1.1.2