/[drupal]/contributions/modules/swftools/simpleviewer/simpleviewer.module
ViewVC logotype

Contents of /contributions/modules/swftools/simpleviewer/simpleviewer.module

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


Revision 1.7 - (show annotations) (download) (as text)
Tue Mar 17 23:18:10 2009 UTC (8 months, 1 week ago) by stuartgreenfield
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +3 -1 lines
File MIME type: text/x-php
In response to #348437 reported by stormsweeper two changes are implemented. Added status report to main Drupal status page, and SWF Tools status, to give a warning if the zlib library isn't present. This library is needed to read height and width data from compressed swf files. Secondly, player modules now report a default height and width, so if all else fails we can fall back on those so that media content will display correctly. As part of this the sizing function has been separated in to a new swftools_set_size() function to try and clarify the code.
1 <?php
2 // $Id: simpleviewer.module,v 1.6 2009/03/06 19:48:01 stuartgreenfield Exp $
3
4 /**
5 * SWF Tools - simpleviewer.module
6 *
7 * Enables the use of SimpleViewer Flash
8 * for image gallery display. SimpleViewer must be downloaded separately.
9 *
10 * Author's Site.
11 * http://www.airtightinteractive.com/simpleviewer/
12 */
13
14 define('SIMPLEVIEWER', 'simpleviewer'); // 'player', shows multiple images.
15
16
17 /**
18 * Implementation of hook_swftools_methods().
19 */
20 function simpleviewer_swftools_methods() {
21
22 $methods = array();
23
24 $image_rotator = array(
25 'name' => SIMPLEVIEWER,
26 'module' => 'simpleviewer',
27 'shared_file' => 'simpleviewer/viewer.swf',
28 'file' => 'xmlDataPath',
29 'version' => '7',
30 'title' => t('SimpleViewer'),
31 'download' => 'http://www.airtightinteractive.com/simpleviewer/',
32 'width' => '700',
33 'height' => '600',
34 );
35
36 $methods[SWFTOOLS_IMAGE_DISPLAY_LIST][SIMPLEVIEWER] = $image_rotator;
37
38 return $methods;
39 }
40
41
42 /**
43 * Implementation of hook_menu().
44 */
45 function simpleviewer_menu() {
46 $items = array();
47
48 $items['admin/settings/swftools/simpleviewer'] = array(
49 'title' => 'SimpleViewer',
50 'description' => 'Settings for <a href="http://www.airtightinteractive.com/simpleviewer/">Airtight Interactive\'s SimpleViewer</a> image gallery.',
51 'weight' => 1,
52
53 'access arguments' => array('administer flash'),
54 'page callback' => 'drupal_get_form',
55 'page arguments' => array('simpleviewer_admin_form'),
56 'file' => 'simpleviewer.admin.inc',
57 'file path' => drupal_get_path('module', 'simpleviewer'),
58
59
60 );
61
62 return $items;
63 }
64
65 /**
66 * Implementation of swftools_flashvars hook
67 * Allows the Flash player provider to add variables to the Flashvars array.
68 * Other arrays can also be modified.
69 *
70 */
71 function simpleviewer_swftools_flashvars($action, &$methods, &$vars) {
72 $sv_vars = _simpleviewer_vars();
73
74 // Here we only assign 'other' settings to othervars, and return 'swf' settings
75 // as the flashvars. 'xml' settings are for the xml file only.
76 // See http://www.airtightinteractive.com/forum/viewtopic.php?t=4085&start=0
77 if (is_array($sv_vars['other'])) {
78 $vars->othervars = array_merge($sv_vars['other'], $vars->othervars);
79 }
80 return $sv_vars['swf'];
81 }
82
83
84 /**
85 * These are the default options and flashvars.
86 *
87 */
88 function _simpleviewer_vars() {
89
90 include_once(drupal_get_path('module', 'simpleviewer') .'/simpleviewer.admin.inc');
91 // Grab the admin form and use all of the default values as settings for the flash embedding.
92 $sv_vars = simpleviewer_admin_form(TRUE);
93
94 foreach (element_children($sv_vars) AS $name) {
95 $name_parts = explode('_', $name);
96 if ($name_parts[1] == 'xml') {
97 // The last part of the Drupal variable name matches the SimpleViewer XML option name
98 $return['xml'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
99 }
100 elseif ($name_parts[1] == 'swf') {
101 $return['swf'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
102 }
103 else {
104 $return['other'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
105 }
106 }
107 return $return;
108 }
109
110
111 function simpleviewer_simpleviewer_swftools_playlist($playlist_data, &$method, &$vars) {
112
113 $sv_vars = _simpleviewer_vars();
114
115 $xml_vars = array_merge($sv_vars['xml'], $vars->flashvars);
116
117 $xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
118 $xml .= '<simpleviewerGallery '.
119 'maxImageWidth="'. $xml_vars['maxImageWidth'] .'" '.
120 'maxImageHeight="'. $xml_vars['maxImageHeight'] .'" '.
121 'textColor="'. str_replace('#', '0x', $xml_vars['textColor']) .'" '.
122 'frameColor="'. str_replace('#', '0x', $xml_vars['frameColor']) .'" '.
123 'frameWidth="'. $xml_vars['frameWidth'] .'" '.
124 'stagePadding="'. $xml_vars['stagePadding'] .'" '.
125 'thumbnailColumns="'. $xml_vars['thumbnailColumns'] .'" '.
126 'thumbnailRows="'. $xml_vars['thumbnailRows'] .'" '.
127 'navPosition="'. $xml_vars['navPosition'] .'" '.
128 'title="'. $xml_vars['title'] .'" '.
129 'imagePath="'. $vars->params['base'] .'" '.
130 'thumbPath="'. $vars->params['base'] .'" '.
131 'enableRightClickOpen="'. $xml_vars['enableRightClickOpen'] .'" '.
132 'backgroundImagePath="'. $xml_vars['backgroundImagePath'] .'">';
133
134 foreach($playlist_data['playlist'] AS $track => $details) {
135 $xml .= '
136 <image>
137 <filename>'. $details['filename']. '</filename>
138 <caption>'. $details['description'] .'</caption>
139 </image>';
140 }
141
142 $xml .= "\n</simpleviewerGallery>";
143
144 return $xml;
145 }

  ViewVC Help
Powered by ViewVC 1.1.2