/[drupal]/contributions/modules/slideshow_creator/slideshow_creator.cck.inc
ViewVC logotype

Contents of /contributions/modules/slideshow_creator/slideshow_creator.cck.inc

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


Revision 1.4 - (show annotations) (download) (as text)
Sat Feb 16 00:24:45 2008 UTC (21 months, 1 week ago) by brmassa
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.3: +4 -2 lines
File MIME type: text/x-php
Misc:
* Some function renamed to avoid be accidentally called by a hook.
1 <?php
2 /**
3 * $Id: slideshow_creator.cck.inc,v 1.3 2008/02/15 22:30:04 brmassa Exp $
4 * @file slideshow_creator.cck.inc
5 * @author Bruno Massa http://drupal.org/user/67164
6 * Create true slideshows using CCK module.
7 * Project Page : http://drupal.org/project/slideshow_creator
8 * Support Queue : http://drupal.org/project/issues/slideshow_creator
9 */
10
11 /**
12 * Implementation of hook_field_info().
13 */
14 function slideshow_creator_field_info() {
15 return array(
16 'slideshow' => array('label' => 'Slideshow'),
17 );
18 }
19
20 /**
21 * Implementation of hook_field_formatter().
22 */
23 function slideshow_creator_field_formatter($field, $item, $formatter) {
24 $attributes = array();
25 array_push($attributes, empty($item['name']) ? '' : 'name='. $item['name']);
26 array_push($attributes, empty($item['rotate']) ? '' : 'rotate='. $item['rotate']);
27 array_push($attributes, empty($item['blend']) ? '' : 'blend='. $item['blend']);
28 array_push($attributes, empty($item['height']) ? '' : 'height='. $item['height']);
29 array_push($attributes, empty($item['width']) ? '' : 'width='. $item['width']);
30 array_push($attributes, empty($item['layout']) ? '' : 'layout='. $item['layout']);
31 if (!empty($item['url']) or !empty($item['dir'])) {
32 if ($urls = split("\n", $item['url'])) {
33 while (list($index, $url) = each($urls)) {
34 $urls[$index] = 'img=|'. $url;
35 }
36 }
37 if ($dirs = split("\n", $item['dir'])) {
38 while (list($index, $url) = each($dirs)) {
39 $dirs[$index] = 'dir=|'. $url;
40 }
41 }
42 $images = array_merge($urls, $dirs);
43
44 include drupal_get_path('module', 'slideshow_creator') .'/slideshow_creator.inc';
45 return _slideshow_creator_process_text('[slideshow: 2,'. implode(',', $attributes) .','. implode(',', $images) .']');
46 }
47 return '';
48 }
49
50 /**
51 * Implementation of hook_field_formatter_info().
52 */
53 function slideshow_creator_field_formatter_info() {
54 $formatters = array(
55 'default' => array(
56 'label' => 'Default',
57 'field types' => array('slideshow'),
58 ),
59 );
60 return $formatters;
61 }
62
63 /**
64 * Implementation of hook_field_settings(): how this field should behave
65 */
66 function slideshow_creator_field_settings($op, $field) {
67 if ($op == 'database columns') {
68 $columns = array(
69 'url' => array('type' => 'text'),
70 'dir' => array('type' => 'text'),
71 'name' => array('type' => 'varchar', 'length' => 255, 'not null' => true),
72 'layout' => array('type' => 'varchar', 'length' => 255),
73 'rotate' => array('type' => 'float'),
74 'blend' => array('type' => 'float'),
75 'height' => array('type' => 'float'),
76 'width' => array('type' => 'float')
77 );
78 return $columns;
79 }
80 }
81
82 /**
83 * Implementation of hook_widget().
84 *
85 * defines the widget fields
86 */
87 function slideshow_creator_widget($op, &$node, $field, &$items) {
88 switch ($op) {
89 case 'form':
90 $form = array();
91 $form[$field['field_name']] = array(
92 '#type' => 'fieldset',
93 '#title' => t($field['widget']['label']),
94 '#weight' => $field['widget']['weight'],
95 '#collapsible' => true,
96 '#collapsed' => false,
97 '#tree' => true
98 );
99 $form[$field['field_name']][0]['url'] = array(
100 '#type' => 'textarea',
101 '#title' => t('Image'),
102 '#default_value' => $items[0]['url'],
103 '#description' => t('On each line, fill your slides using the <b>IMAGE_URL|LINK|TITLE|DESCRIPTION|TARGET</b> pattern.')
104 );
105 $form[$field['field_name']][0]['dir'] = array(
106 '#type' => 'textarea',
107 '#title' => t('Image directory'),
108 '#default_value' => $items[0]['dir'],
109 '#description' => t('On each line, fill your slides using the <b>DIR_IMAGE|DIR_RECURSIVE|DIR_LINK|TITLE|DESCRIPTION|TARGET</b> pattern.')
110 );
111 $form[$field['field_name']][0]['rotate'] = array(
112 '#type' => 'textfield',
113 '#title' => t('Rotation'),
114 '#default_value' => $items[0]['rotate'],
115 '#description' => t('The rotation speed, in seconds. Leave it blank for no rotation.'),
116 '#weight' => 1
117 );
118 $form[$field['field_name']][0]['blend'] = array(
119 '#type' => 'textfield',
120 '#title' => t('Blend'),
121 '#default_value' => $items[0]['blend'],
122 '#description' => t('The blending speed, in seconds. Leave it blank for no blending.'),
123 '#weight' => 1
124 );
125 $form[$field['field_name']][0]['width'] = array(
126 '#type' => 'textfield',
127 '#title' => t('Width'),
128 '#default_value' => $items[0]['width'],
129 '#description' => t('The image width, in pixels.'),
130 '#weight' => 2
131 );
132 $form[$field['field_name']][0]['height'] = array(
133 '#type' => 'textfield',
134 '#title' => t('Height'),
135 '#default_value' => $items[0]['height'],
136 '#description' => t('The image height, in pixels.'),
137 '#weight' => 2
138 );
139 $form[$field['field_name']][0]['layout'] = array(
140 '#type' => 'textfield',
141 '#title' => t('Layout'),
142 '#default_value' => $items[0]['layout'],
143 '#description' => t('The customized layout name. Leave it blank for default layout.'),
144 '#weight' => 3
145 );
146 return $form;
147 case 'validate':
148 $error_field = $field['field_name'] .'][0][';
149 if (!empty($items[0]['height']) and !is_numeric($items[0]['height'])) {
150 form_set_error($error_field .'height', t('Height') .' '. t('must be a number.'));
151 }
152 if (!empty($items[0]['width']) and !is_numeric($items[0]['width'])) {
153 form_set_error($error_field .'width', t('Width') .' '. t('must be a number.'));
154 }
155 if (!empty($items[0]['rotate']) and !is_numeric($items[0]['rotate'])) {
156 form_set_error($error_field .'rotate', t('Rotation') .' '. t('must be a number.'));
157 }
158 if (!empty($items[0]['blend']) and !is_numeric($items[0]['blend'])) {
159 form_set_error($error_field .'blend', t('Blend') .' '. t('must be a number.'));
160 }
161 return;
162 }
163 }
164
165 /**
166 * Implementation of hook_widget_info().
167 */
168 function slideshow_creator_widget_info() {
169 return array(
170 'slideshow' => array(
171 'label' => t('Slideshow'),
172 'field types' => array('slideshow'),
173 ),
174 );
175 }
176
177 /**
178 * Format the slideshow widget
179 *
180 * @ingroup themeable
181 */
182 function theme_slideshow_creator_view_image($file, $alt = '', $title = '', $attributes = null, $getsize = true) {
183 return theme('slideshow_creator_image', $file, $alt, $title, $attributes , $getsize);
184 }

  ViewVC Help
Powered by ViewVC 1.1.2