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

Contents of /contributions/modules/brilliant_gallery/brilliant_gallery.module

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


Revision 1.53 - (show annotations) (download) (as text)
Mon Jul 7 20:24:24 2008 UTC (16 months, 3 weeks ago) by tjfulopp
Branch: MAIN
CVS Tags: HEAD
Changes since 1.52: +77 -74 lines
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 /* $Id: brilliant_gallery.module,v 1.49 2008/05/05 23:24:20 tjfulopp Exp $ */
3
4 sess_write('vacilando', 'this is a test');
5
6 if ( module_exists('views') ) {
7 require(drupal_get_path('module', 'brilliant_gallery') .'/views.inc');
8 }
9
10 /**
11 * Display help and module information
12 * @param section which section of the site we're displaying help
13 * @return help text for section
14 */
15 function brilliant_gallery_help($section='') {
16
17 $output = '';
18
19 switch ($section) {
20 case "admin/help#brilliant_gallery":
21 $output = '<p>'. t("Highly customizable Drupal module creating a table gallery of quality-scaled images from any number of folders."). '</p>';
22 break;
23 }
24
25 return $output;
26 } // function brilliant_gallery_help
27
28
29 /**
30 * Valid permissions for this module
31 * @return array An array of valid permissions for the onthisdate module
32 */
33 function brilliant_gallery_perm() {
34
35 return array('access brilliant_gallery'); #, 'administer brilliant_gallery'
36
37 } // function brilliant_gallery_perm
38
39
40 /**
41 * Generate HTML for the Brilliant gallery block
42 * @param op the operation from the URL
43 * @param delta offset
44 * @returns block HTML
45 */
46 function brilliant_gallery_block($op='list', $delta=0) {
47 // listing of blocks, such as on the admin/block page
48 if ($op == "list") {
49 $block[0]["info"] = t("Brilliant gallery");
50 return $block;
51 } else if ($op == 'view') {
52 // our block content
53 // content variable that will be returned for display
54 $block_content = '';
55
56 #$block_content .= l($links->title, 'node/'.$links->nid) . '<br />';
57 #$block_content .= l('vacilando', 'http://www.vacilando.org') . '<br />';
58
59 $block_content .= render_brilliant_gallery();
60
61 // set up the block
62 $block['subject'] = 'Brilliant gallery';
63 $block['content'] = $block_content;
64 return $block;
65 }
66 } // end brilliant_gallery_block
67
68
69 function brilliant_gallery_all() {
70 // content variable that will be returned for display
71 $page_content = '';
72
73 $page_content .= render_brilliant_gallery();
74
75 return $page_content;
76 }
77
78
79 function brilliant_gallery_admin() {
80 $form['brilliant_gallery_folder'] = array(
81 '#type' => 'textfield',
82 '#title' => t('Path to the main gallery folder'),
83 '#default_value' => variable_get('brilliant_gallery_folder', ''),
84 '#size' => 50,
85 '#maxlength' => 100,
86 '#description' => t("Path to the main folder in which your individual gallery folders will be placed. This folder must exist under your 'files' folder. Exclude trailing slashes. Example: <i>albums</i>")
87 );
88 $form['brilliant_gallery_maxcol'] = array(
89 '#type' => 'textfield',
90 '#title' => t('Maximum number of table columns'),
91 '#default_value' => variable_get('brilliant_gallery_maxcol', 5),
92 '#size' => 2,
93 '#maxlength' => 2,
94 '#description' => t("The maximum number of columns displayed in the table.")
95 );
96 $form['brilliant_gallery_maximagewidth'] = array(
97 '#type' => 'textfield',
98 '#title' => t('Maximum width of table images'),
99 '#default_value' => variable_get('brilliant_gallery_maximagewidth', 150),
100 '#size' => 3,
101 '#maxlength' => 4,
102 '#description' => t("The maximum width of thumbnails in the table (height calculated automatically).")
103 );
104 $form['brilliant_gallery_bcgcolour'] = array(
105 '#type' => 'colorpicker',
106 '#title' => t('Table background colour'),
107 '#default_value' => variable_get('brilliant_gallery_bcgcolour', '#000000'),
108 '#size' => 8,
109 '#maxlength' => 7,
110 '#description' => t("Pick colour of the background of the table that holds the images.")
111 );
112 $form['brilliant_gallery_bcgcolour_textfield'] = array(
113 '#type' => 'colorpicker_textfield',
114 '#title' => t('Current background color'),
115 '#description' => t(''),
116 '#default_value' => variable_get('brilliant_gallery_bcgcolour_textfield', '#000000'),
117 '#colorpicker' => 'brilliant_gallery_bcgcolour',
118 );
119 $form['brilliant_gallery_padding'] = array(
120 '#type' => 'textfield',
121 '#title' => t('Table cell padding'),
122 '#default_value' => variable_get('brilliant_gallery_padding', 3),
123 '#size' => 3,
124 '#maxlength' => 3,
125 '#description' => t("Cell padding (around each image) in pixels.")
126 );
127 $form['brilliant_gallery_overbrowser'] = array(
128 '#type' => 'select',
129 '#title' => t('Overlay browser'),
130 '#required' => FALSE,
131 '#options' => array(
132 'lightbox' => t('Lightbox'),
133 'thickbox' => t('Thickbox'),
134 'greyboxr' => t('Greybox Redux'),
135 'none' => t('None'),
136 ),
137 '#default_value' => variable_get('brilliant_gallery_overbrowser', 'thickbox'),
138 '#description' => t('Select the overlay image browser (must be installed, of course).'),
139 );
140 $form['brilliant_gallery_maxwidth'] = array(
141 '#type' => 'textfield',
142 '#title' => t('Maximum width of full image'),
143 '#default_value' => variable_get('brilliant_gallery_maxwidth', '1000'),
144 '#size' => 5,
145 '#maxlength' => 5,
146 '#description' => t("Very large images will be scaled down to this width (in pixels) for display before they get displayed by the overlay browser.")
147 );
148 $form['brilliant_gallery_caption'] = array(
149 '#type' => 'checkbox',
150 '#title' => t('Display file name as caption'),
151 '#default_value' => variable_get('brilliant_gallery_caption', ''),
152 #'#size' => 5,
153 #'#maxlength' => 5,
154 '#description' => t("Check this if you want the overlay browser to display a caption based on the image file name (dots and underscores are automatically replaced by spaces).")
155 );
156 $form['brilliant_gallery_sort'] = array(
157 '#type' => 'radios',
158 '#title' => t('Sort or randomize image order'),
159 '#default_value' => variable_get('brilliant_gallery_sort', '1'),
160 '#options' => array('1' => t('Sort images by their file names alphabetically.'),
161 '' => t('The order of your gallery images will always be randomized (on each page load or cache refresh).')),
162 #'#description' => t("")
163 );
164 $form['brilliant_gallery_cache'] = array(
165 '#type' => 'radios',
166 '#title' => t('Database or file system caching of images'),
167 '#default_value' => variable_get('brilliant_gallery_cache', 'd'),
168 '#options' => array('d' => t('Use the <i>cache</i> table of Drupal.'),
169 'f' => t('Use the temporary directory you have set in <i>/admin/settings/file-system</i>. Faster than database caching!')),
170 '#description' => t("Only images (not the table as such) are cached so that they can be served quicker at subsequent requests.")
171 );
172 return system_settings_form($form);
173 }
174
175 # Probably not the right way of doing it but it works...
176 function brilliant_gallery_perms() {
177 header("HTTP/1.1 301 Moved Permanently");
178 header("Location: " . url("admin/user/access", NULL, "module-brilliant_gallery", TRUE));
179 exit();
180 }
181
182 function brilliant_gallery_menu() {
183
184 $items = array();
185
186 $items[] = array(
187 'path' => 'admin/settings/brilliant_gallery',
188 'title' => t('Brilliant gallery'),
189 'description' => t('Brilliant gallery module settings'),
190 'callback' => 'drupal_get_form',
191 'callback arguments' => 'brilliant_gallery_admin',
192 'access' => user_access('access administration pages'),
193 'type' => MENU_NORMAL_ITEM,
194 );
195
196 # Probably not the right way of doing it but it works...
197 $items[] = array(
198 'path' => 'admin/settings/brilliant_gallery/brilliant_gallery_perms',
199 #'path' => 'admin/user/access#module-brilliant_gallery',
200 'title' => t('Configure permissions'),
201 'description' => t('Configure access permissions for the Brilliant gallery module'),
202 'callback' => 'brilliant_gallery_perms',
203 #'callback arguments' => 'brilliant_gallery_perms',
204 'access' => user_access('access administration pages'),
205 'type' => MENU_NORMAL_ITEM,
206 );
207
208 $items[] = array(
209 'path' => 'brilliant_gallery',
210 'title' => t('Brilliant gallery'),
211 'callback' => 'brilliant_gallery_all',
212 'access' => user_access('access brilliant_gallery'),
213 'type' => MENU_CALLBACK
214 ); # The type MENU_CALLBACK tells Drupal to not display the link in the user's menu, just use this function when the URL is accessed. Use MENU_NORMAL_ITEM if you want the user to see the link in the side navigation block.
215
216 return $items;
217 }
218
219 function render_brilliant_gallery( $thisfolder = '', $colcountoverride = '', $widthoverride = '', $sortoverride = '', $maximumnumbertoshow = '', $colouroverride = '', $beginfromoverride = 1, $captionyesnotext = '' ) {
220 #drupal_add_css(drupal_get_path('module', 'brilliant_gallery') .'/brilliant_gallery.css');
221 # First some household cleaning. Delete expired cache files at 11:11 (if someone calls this script, of course!)
222 if ( date( 'h' ) == '11' and date( 'i' ) == '11' ) {
223 #if ( date( 'h' ) == '12' ) {
224 #echo date( 'h' );
225 cleantmpdir();
226 }
227 # Patching a possible problem with i18n
228 $langcode = '';
229 if ( function_exists('i18n_get_lang') ) { $langcode = i18n_get_lang(); }
230 #$result = '</p>';
231 $result = '';
232 $galleryfolder = variable_get('brilliant_gallery_folder', '');
233 if ( substr( $galleryfolder, strlen( $galleryfolder ) - 1, 1 ) == '/' or substr( $galleryfolder, 0, 1 ) == '/' ) {
234 #watchdog('error', 'failed to notify "weblogs.com" (site)');
235 #form_set_error('yemail', t('Header injection attempt detected. Do not enter line feed characters into the from field!'));
236 return 'Main gallery folder path must not begin or end with a slash; please fix it in the <a href="/admin/settings/brilliant_gallery">settings page</a>.';
237 }
238 if ( $thisfolder <> '' ) {
239 $galleryfolder .= '/' . $thisfolder;
240 }
241 if ( $colcountoverride == '' ) {
242 $columns = variable_get('brilliant_gallery_maxcol', 3);
243 } else {
244 $columns = $colcountoverride;
245 }
246 if ( $widthoverride == '' ) {
247 $imagewidth = variable_get('brilliant_gallery_maximagewidth', 150);
248 } else {
249 $imagewidth = $widthoverride;
250 }
251 if ( $sortoverride == '' or strtolower( $sortoverride ) == 'sort' ) {
252 $brilliant_gallery_sort = variable_get('brilliant_gallery_sort', '1');
253 } else {
254 $brilliant_gallery_sort = $sortoverride;
255 }
256 if ( $colouroverride == '' ) {
257 $bgcolour = variable_get('brilliant_gallery_bcgcolour_textfield', '#000000');
258 } else {
259 $bgcolour = $colouroverride;
260 }
261 if ( $captionyesornot == 'yes' or $captionyesornot == '' or ( variable_get('brilliant_gallery_caption', '') <> '' and $captionyesornot <> 'no' ) ) {
262 $showcaption = 'filename';
263 } else if ( $captionyesornot == 'no' ) {
264 $showcaption = '';
265 } else {
266 $showcaption = $captionyesornot;
267 }
268 $padding = variable_get('brilliant_gallery_padding', 3);
269 $overbrowser = variable_get('brilliant_gallery_overbrowser', 'thickbox');
270 $fullresolutionmaxwidth = variable_get('brilliant_gallery_maxwidth', '1000'); # Totally full resolution display would be impractical, so this is the maximum width of "full" resolution.
271 $path = url(file_directory_path() . '/' . $galleryfolder, NULL, NULL, TRUE);
272 # url() ads i18n codes to the URL ... we need to remove them here...
273 if ( $langcode <> '' ) {
274 $path = str_replace( '/' . $langcode . '/', '/', $path );
275 }
276 # Non-clean URLs need removing ?q=
277 $path = str_replace( "?q=", "", $path );
278 $absolpath = realpath(file_directory_path() . '/' . $galleryfolder);
279 #$result .= $absolpath;
280
281 # Load Directory Into Array
282 $poct = -1;
283 $retval_dimensions = array();
284 $handle = opendir($absolpath);
285 $imagemaxh = 0;
286 while ( $file = readdir($handle) ) {
287 $testending = strtolower( substr( $file, -4, 4 ) );
288 if ( !testext( $file ) and strtolower( $testending ) <> '.mpg' and strtolower( $testending ) <> '.swf' and strtolower( $testending ) <> '.mov' ) { continue; }
289 $poct += 1; # Index of a real image or something we are going to display.
290 #$retval[$poct] = $file;
291 $retval_dimensions[$poct]['file'] = $file;
292
293 # Is image horizontally or vertically oriented?
294 $temp = getimagesize( $absolpath . '/' . $file );
295 if ( $temp === false ) { continue; }
296 if ( ( $temp[0] - $temp[1] ) >= 0 ) {
297 # this is a horizontal image
298 $retval_dimensions[$poct]['imgw'] = $imagewidth;
299 $retval_dimensions[$poct]['imgh'] = round( ($temp[1]/$temp[0]) * $imagewidth );
300 if ( $temp[0] > $fullresolutionmaxwidth ) {
301 $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth;
302 $retval_dimensions[$poct]['imghbig'] = round( ($temp[1]/$temp[0]) * $fullresolutionmaxwidth );
303 } else {
304 $retval_dimensions[$poct]['smallenough'] = true;
305 }
306 #$result .= $imgw . ' / ' . $imgh;
307 } else {
308 # this is a vertical image .... a
309 $retval_dimensions[$poct]['imgw'] = round( ($temp[0]/$temp[1])*($temp[0]/$temp[1])*$imagewidth );
310 $retval_dimensions[$poct]['imgh'] = round( ($temp[0]/$temp[1])*$imagewidth );
311 if ( $temp[0] > $fullresolutionmaxwidth ) {
312 $retval_dimensions[$poct]['imgwbig'] = round( ($temp[0]/$temp[1])*($temp[0]/$temp[1])*$fullresolutionmaxwidth );
313 $retval_dimensions[$poct]['imghbig'] = round( ($temp[0]/$temp[1])*$fullresolutionmaxwidth );
314 } else {
315 $retval_dimensions[$poct]['smallenough'] = true;
316 }
317 #$result .= $imgw . ' / ' . $imgh;
318 }
319 if ( $imagemaxh < $retval_dimensions[$poct]['imgh'] ) $imagemaxh = $retval_dimensions[$poct]['imgh'];
320
321 }
322 @closedir( $handle );
323 $maxpoct = count( $retval_dimensions );
324 if ( $brilliant_gallery_sort == '1' ) {
325 sort( $retval_dimensions );
326 } else {
327 shuffle( $retval_dimensions );
328 }
329 #print_r( $retval_dimensions );
330
331 $style_ul = "width: " . ( ( $imagewidth + 2*$padding ) * $columns ) . "px;"; # Total 'width' controls the number of thumbnails in each row. The number, in pixels, should be calculated thusly: [maximum width desired for thumbnails] + [padding - if any, x 2] + [margin - if any, x 2] + [border - if any, x 2] x [number of thumbnails desired in each row]
332 $column_count = 0;
333 #$pocetobr = 0;
334 $setname = mt_rand( 1, 9999999 );
335 #$result .= '<!-- Brilliant Gallery Table Beginning --><table border="0" rules="none" frame="box" cellpadding="0" cellspacing="0" bgcolor="' . $bgcolour . '"';
336 $result .= '<!-- Brilliant Gallery Table Beginning -->';
337 #$result .= '<ul class="brilliant_gallery" style="' . $style_ul . '">';
338 $result .= '<ul style="' . $style_ul . '">';
339 #if ( $thisfolder <> '' ) {
340 #$result .= ' align="center"';
341 # }
342 #$result .= ' style="width:' . $columns*$imagewidth . 'px;">'; #cell-spacing: 5px;
343 #$result .= ' style="width:' . $columns*$imagewidth . 'px;"';
344 #$result .= '>' . "\n"; #cell-spacing: 5px;
345 $maxpoct_show = '';
346 if ( $maximumnumbertoshow <> '' and is_numeric( $maximumnumbertoshow ) ) {
347 $maxpoct_show = $maximumnumbertoshow;
348 }
349 $retval = array(); # Thanks to Micha³ Albrecht!
350 $cnt = 0;
351 for ( $poct = 1; $poct <= $maxpoct; $poct++ ) {
352 if ( $poct < $beginfromoverride ) { continue; } # Begin only from $beginfromoverride image.
353 $cnt += 1; if ( $cnt > $maxpoct_show and $maxpoct_show <> '' ) { continue; } # Do not show more than $maxpoct_show (if defined).
354 $retval[$poct-1] = $retval_dimensions[$poct-1]['file'];
355 $fullimgpath = $path . '/' . $retval[$poct-1];
356 #if ($column_count == 0) { $result .= ('<tr>'); }
357 #$result .= ('<td align="center" bgcolor="' . $bgcolour . '" style="padding: ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px;vertical-align: middle;">');
358 #$result .= ('<td align="center" bgcolor="' . $bgcolour . '" style="padding: ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px;vertical-align: middle;">' . "\n");
359 #$pocetobr += 1;
360 if ( testext( $retval[$poct-1] ) ) {
361 $caption = str_replace(array('.', '_'), ' ', basename($retval[$poct-1], strrchr($retval[$poct-1], '.')));
362 #$smallenough = false;
363 $imgw = $retval_dimensions[$poct-1]['imgw'];
364 $imgh = $retval_dimensions[$poct-1]['imgh'];
365 $imgwbig = $retval_dimensions[$poct-1]['imgwbig'];
366 $imghbig = $retval_dimensions[$poct-1]['imghbig'];
367 $smallenough = $retval_dimensions[$poct-1]['smallenough'];
368 $style_li = "float: left; width: " . $imagewidth . "px; list-style: none; background: " . $bgcolour . "; height: " . $imagemaxh . "px; padding: " . $padding . "px; text-align: center; margin: 0; border: none;"; #$style_li = "float: left; list-style: none; background: #000; width: 44px; height: 33px; padding: 4px; text-align: center; margin: 0; border: none;";
369 $result .= ('<li style="' . $style_li . '">' . "\n");
370 # Get this module's path:
371 $modulepath = url(drupal_get_path('module', 'brilliant_gallery'), NULL, NULL, TRUE);
372 # url() ads i18n codes to the URL ... we need to remove them here...
373 if ( $langcode <> '' ) {
374 $modulepath = str_replace( '/' . $langcode . '/', '/', $modulepath );
375 }
376 # Non-clean URLs need removing ?q=
377 $modulepath = str_replace( "?q=", "", $modulepath );
378 if ( $smallenough === true ) {
379 $result .= '<a href="' . $fullimgpath . '"';
380 } else {
381 # Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
382 $result .= '<a href="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&amp;imgw=' . $imgwbig . '&amp;imgh=' . $imghbig . '"'; #&dummy=.jpg
383 }
384
385 switch( $overbrowser ) {
386 case 'thickbox':
387 $result .= ' class="thickbox"';
388 $result .= ' rel="img_' . $setname . '"';
389 #$attributes['class'] = $link_class;
390 #$attributes['rel'] = 'img_' . ($node->nid? $node->nid: time()); // 'insert' has no $node->nid
391 break;
392 case 'lightbox':
393 $result .= ' rel="lightbox[' . $setname . ']"';
394 #$attributes['rel'] = 'lightbox[' . ($node->nid? $node->nid: time()) . ']'; // 'insert' has no $node->nid
395 break;
396 case 'greyboxr':
397 $result .= ' class="greybox"';
398 #$result .= ' rel="gb_imageset[' . $setname . ']"';
399 break;
400 default:
401 break;
402 }
403
404 if ( $showcaption <> '' ) {
405 if ( $showcaption <> 'filename' ) {
406 $caption = $showcaption;
407 }
408 $result .= ' title="' . $caption . '"';
409 }
410 $result .= '>';
411 # Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
412 /*
413 $modulepath = url(drupal_get_path('module', 'brilliant_gallery'), NULL, NULL, TRUE);
414 # url() ads i18n codes to the URL ... we need to remove them here...
415 if ( $langcode <> '' ) {
416 $modulepath = str_replace( '/' . $langcode . '/', '/', $modulepath );
417 }
418 # Non-clean URLs need removing ?q=
419 $modulepath = str_replace( "?q=", "", $modulepath );
420 */
421 #$result .= '<img style="display: block;border:0" src="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&imgw=' . $imgw . '&imgh=' . $imgh . '" />'; # width="' . $imgw . '"
422 $result .= '<img style="border:0" alt="" src="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&amp;imgw=' . $imgw . '&amp;imgh=' . $imgh . '" />'; # width="' . $imgw . '"
423 #$result .= '</a>';
424 $result .= '</a>' . "\n";
425
426 } else {
427 $result .= '<a href="' . $fullimgpath . '">';
428 #$result .= '<center>' . $retval[$poct-1] . '</center>';
429 $result .= $retval[$poct-1];
430 #brokenimage("Error loading PNG");
431 #$result .= '</a>';
432 $result .= '</a>' . "\n";
433
434 }
435 #$result .= '</td>';
436 $result .= '</li>' . "\n";
437
438 $column_count += 1;
439 #if ($column_count == $columns) { $result .= ("</tr>\n"); $column_count = 0; }
440 }
441 #if ($column_count <> 0) { $result .= ("</tr>"); }
442 #if ($column_count <> 0) { $result .= ("</tr>\n"); }
443 #$result .= "</table>\n";
444 $result .= "</ul>\n";
445 $result .= '<br style="clear: both;" />';
446 #$result .= '<p>';
447 return $result;
448 }
449
450
451 # Implementation of hook_filter().
452 function brilliant_gallery_filter($op, $delta = 0, $format = -1, $text = '') {
453 switch ($op) {
454 case 'no cache':
455 return true; # See http://drupal.org/node/194318#comment-640952
456
457 case 'list':
458 return array(0 => t('Brilliant Gallery Tag'));
459
460 case 'description':
461 return t('Substitutes a special Brilliant Gallery Tag with the actual gallery table.');
462
463 case 'prepare':
464 return $text;
465
466 case 'process':
467 # process it here........
468 $text = replace_brilliant_gallery_tags( $text );
469 return $text;
470 }
471 }
472
473
474 function replace_brilliant_gallery_tags( $str ) {
475 # [bg|path/to/gallery_folder|colcountoverride|widthoverride|sortorrandomoverride|maximumnumbertoshow|colouroverride|beginfromoverride|caption-yes-no-text]
476 # no slashes around this path!
477 $matchlink = '';
478 $orig_match = '';
479 preg_match_all( "/(\[)bg(\|).*(\])/", $str, $matches);
480 foreach ( $matches[0] as $match ) {
481 $orig_match[] = $match;
482 $match = substr( $match, 1, ( strlen( $match ) - 2 ) );
483 $match = explode( "|", $match );
484 $matchlink[] = render_brilliant_gallery( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6], $match[7], $match[8] );
485 }
486 $str = str_replace( $orig_match, $matchlink, $str );
487 return $str;
488 }
489
490
491 function cleantmpdir() { # Delete "bg_*" files from the temp directory if they are expired.
492 $bgcachexpire = 3600*24*3; # Cache expiration time. This is primarily set in image.php - use the same value here.
493 $directory = file_directory_temp();
494
495 if( !$dirhandle = @opendir($directory) )
496 return;
497
498 while( false !== ($filename = readdir($dirhandle)) ) {
499 if( $filename != "." && $filename != ".." &&
500 substr( $filename, 0, 3 ) == 'bg_'
501 ) {
502 $filename = $directory. "/". $filename;
503
504 if( @filemtime($filename) < (time()-$bgcachexpire) )
505 #echo $filename . ' ';
506 @unlink($filename);
507 }
508 }
509 }
510
511 function testext( $filename ) {
512 if ( substr( strtolower( $filename ), -4, 4 ) == ".jpg" or substr( strtolower( $filename ), -5, 5 ) == ".jpeg" or substr( strtolower( $filename ), -4, 4 ) == ".gif" or substr( strtolower( $filename ), -4, 4 ) == ".png" ) {
513 return true;
514 }
515 # Otherwise return false.
516 return false;
517 }
518
519 function brokenimage($msg) {
520 $im = imagecreatetruecolor(150, 30);
521 $bgc = imagecolorallocate($im, 0, 0, 0);
522 $tc = imagecolorallocate($im, 255, 255, 255);
523 imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
524 imagestring($im, 1, 5, 5, $msg, $tc);
525 imagejpeg($im);
526 exit();
527 }
528
529
530 /**
531 * Implementation of hook_filter_tips().
532 *
533 * This hook allows filters to provide help text to users during the content
534 * editing process. Short tips are provided on the content editing screen, while
535 * long tips are provided on a separate linked page. Short tips are optional,
536 * but long tips are highly recommended.
537 */
538 /*
539 function brilliant_gallery_filter_tips($delta, $format, $long = FALSE) {
540 switch ($delta) {
541 case 0:
542 if ($long) {
543 return t('Every instance of "foo" in the input text will be replaced with "%replacement".', array('%replacement' => variable_get('filter_example_foo_'. $format, 'bar')));
544 }
545 break;
546
547 case 1:
548 if ($long) {
549 return t('Every instance of the special &lt;time /&gt; tag will be replaced with the current date and time in the user\'s specified time zone.');
550 }
551 else {
552 return t('Use &lt;time /&gt; to display the current date/time.');
553 }
554 break;
555 }
556 }
557 */

  ViewVC Help
Powered by ViewVC 1.1.2