/[drupal]/contributions/modules/zoomify/zoomify.module
ViewVC logotype

Contents of /contributions/modules/zoomify/zoomify.module

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


Revision 1.5 - (show annotations) (download) (as text)
Wed Jan 9 20:50:11 2008 UTC (22 months, 2 weeks ago) by kratib
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +18 -113 lines
File MIME type: text/x-php
Significant changes in file handling
1 <?php
2 // $Id: zoomify.module,v 1.4 2007/12/14 16:36:55 kratib Exp $
3
4 require_once('pathinfo_filename.inc');
5 require_once('rrmdir.inc');
6 require_once('zoomify.inc');
7
8 function zoomify_requirements($phase) {
9 $t = get_t();
10
11 // TODO: Check for python + PIL
12 // TODO: Check for ZoomifyImage script
13 }
14
15 function zoomify_menu($may_cache) {
16 $items = array();
17 if ($may_cache) {
18 $items[] = array(
19 'path' => 'admin/settings/zoomify',
20 'title' => t('Zoomify'),
21 'callback' => 'drupal_get_form',
22 'callback arguments' => array('zoomify_admin_settings'),
23 'access' => user_access('administer site configuration'),
24 'type' => MENU_NORMAL_ITEM,
25 'description' => t('Zoomify module settings.'),
26 );
27 } else {
28 if (arg(0) == 'node' && is_numeric(arg(1))) {
29 $node = node_load(arg(1));
30 $images = _zoomify_images($node);
31 if (!empty($images) && is_dir(_zoomify_nodepath($node))) {
32 $items[] = array(
33 'path' => 'node/'.arg(1).'/zoomify',
34 'title' => t('Zoomify'),
35 'callback' => 'zoomify_display',
36 'callback arguments' => array($node, $images),
37 'access' => user_access('access content'),
38 'type' => MENU_LOCAL_TASK,
39 'description' => t('View image using Zoomify viewer.'),
40 'weight' => 10,
41 );
42 }
43 }
44 }
45 return $items;
46 }
47
48 function zoomify_admin_settings() {
49 $form['zoomify_minimum_width'] = array(
50 '#type' => 'textfield',
51 '#title' => t('Minimum width'),
52 '#default_value' => variable_get('zoomify_minimum_width', 1024),
53 '#description' => t('Minimum image width that will be zoomified.'),
54 '#field_suffix' => t('px'),
55 '#size' => 12,
56 );
57 $form['zoomify_minimum_height'] = array(
58 '#type' => 'textfield',
59 '#title' => t('Minimum height'),
60 '#default_value' => variable_get('zoomify_minimum_height', 768),
61 '#description' => t('Minimum image height that will be zoomified.'),
62 '#field_suffix' => t('px'),
63 '#size' => 12,
64 );
65 $form['zoomify_width'] = array(
66 '#type' => 'textfield',
67 '#title' => t('Frame width'),
68 '#default_value' => variable_get('zoomify_width', '800px'),
69 '#description' => t('Width of the Zoomify frame. Any unit that HTML understands (px, em, %) can be entered here.'),
70 '#size' => 12,
71 );
72 $form['zoomify_height'] = array(
73 '#type' => 'textfield',
74 '#title' => t('Frame height'),
75 '#default_value' => variable_get('zoomify_height', '600px'),
76 '#description' => t('Height of the Zoomify frame. Any unit that HTML understands (px, em, %) can be entered here.'),
77 '#size' => 12,
78 );
79
80 return system_settings_form($form);
81 }
82
83 function theme_zoomify_admin_settings($form) {
84 $output = '';
85 $output .= drupal_render($form);
86 $output .= '<p class="cvs-version">$Id: zoomify.module,v 1.4 2007/12/14 16:36:55 kratib Exp $</p>';
87 return $output;
88 }
89
90 function zoomify_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
91 switch ($op) {
92 case 'insert':
93 _zoomify_insert_node($node);
94 break;
95 case 'delete':
96 _zoomify_delete_node($node);
97 break;
98 case 'update':
99 _zoomify_update_node($node);
100 break;
101 }
102 }
103
104 function zoomify_display($node, $images) {
105 return theme('zoomify', $node, $images);
106 }
107
108 function theme_zoomify($node, $images) {
109 drupal_set_title($node->title);
110 $viewer = base_path() . '/' . drupal_get_path('module', 'zoomify') . '/ZoomifyImage/www/zoomifyViewer.swf';
111 $fids = array_keys($images);
112 // TODO Find an elegant way to display all images, not just the first one.
113 $image = file_create_url(_zoomify_filepath($node, $fids[0]));
114 $width = variable_get('zoomify_width', 800);
115 $height = variable_get('zoomify_height', 600);
116 $nid = $node->nid;
117 $fid = $fids[0];
118 return <<<EOS
119 <div class="zoomify zoomify-node-$nid zoomify-file-$fid">
120 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" id="theMovie" width="$width" height="$height">
121 <param name="FlashVars" value="zoomifyImagePath=$image">
122 <param name="menu" value="false">
123 <param name="src" value="$viewer">
124 <embed flashvars="zoomifyImagePath=$image" src="$viewer" menu="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="theMovie" width="$width" height="$height"></embed>
125 </object>
126 </div>
127 EOS;
128 }
129

  ViewVC Help
Powered by ViewVC 1.1.2