| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * Theme & preprocess functions for the Views Slideshow: Imageflow module. 6 */ 7 8 /** 9 * We'll grab only the first image from each row. 10 */ 11 function template_preprocess_views_slideshow_imageflow(&$vars) { 12 // Initialize our $images array. 13 $vars['images'] = array(); 14 15 // Strip all images from the $rows created by the original view query. 16 foreach($vars['rows'] as $item) { 17 preg_match('@(<\s*img\s+[^>]*>)@i', $item, $matches); 18 if ($image = $matches[1]) { 19 // We need to add a URL to 'longdesc', as required by the plugin. 20 // If our image is in an anchor tag, use its URL. 21 preg_match('@<\s*a\s+href\s*=\s*"\s*([^"]+)\s*"[^>]*>[^<]*'. preg_quote($image) .'[^<]*<\s*/a\s*>@i', $item, $urls); 22 if (!($url = $urls[1])) { 23 // Otherwise link to the original image. 24 preg_match('@src\s*=\s*"([^"]+)"@i', $image, $urls); 25 if (!($url = $urls[1])) { 26 // If we get this far, there are probably more serious problems. 27 // But for now, we'll go to the front page instead. 28 $url = url('<front>'); 29 } 30 } 31 32 // Add the URL to the image's longdesc tag. 33 $image = preg_replace('@img\s+@i', 'img longdesc="'. $url .'" ', $image); 34 35 // Add the image to our image array to display. 36 $vars['images'][] = $image; 37 } 38 } 39 40 // Find the path to our plugin. 41 $path = views_slideshow_imageflow_path(); 42 43 // Add the required JS and CSS. 44 $packed = views_slideshow_imageflow_variable_get('packed') ? '.packed' : ''; 45 drupal_add_js($path .'/imageflow'. $packed .'.js'); 46 47 // Only include the CSS if we're supposed to. 48 // @see issue at http://drupal.org/node/769968. 49 if (views_slideshow_imageflow_variable_get('include_css')) { 50 drupal_add_css($path .'/imageflow'. $packed .'.css'); 51 } 52 53 $drupal_path = drupal_get_path('module', 'views_slideshow_imageflow') . '/themes'; 54 drupal_add_js($drupal_path .'/js/views_slideshow_imageflow.js'); 55 56 $view = $vars['view']; 57 $rows = $vars['rows']; 58 $options = $vars['options']; 59 switch ($options['views_slideshow_imageflow']['start']) { 60 case 'start': 61 $start = 1; 62 break; 63 case 'end': 64 $start = sizeof($rows); 65 break; 66 case 'middle': 67 $start = ceil(sizeof($rows) / 2); 68 break; 69 case 'random': 70 $start = rand(1, sizeof($rows)); 71 break; 72 } 73 74 // Deal with views created before various options were available: 75 // @TODO: Do this in an update function instead? 76 $options['views_slideshow_imageflow']['captions'] = isset($options['views_slideshow_imageflow']['captions']) ? $options['views_slideshow_imageflow']['captions'] : TRUE; 77 $options['views_slideshow_imageflow']['imageFocusM'] = isset($options['views_slideshow_imageflow']['imageFocusM']) ? $options['views_slideshow_imageflow']['imageFocusM'] : 1.0; 78 $options['views_slideshow_imageflow']['scrollbarP'] = isset($options['views_slideshow_imageflow']['scrollbarP']) ? $options['views_slideshow_imageflow']['scrollbarP'] : 0.6; 79 $options['views_slideshow_imageflow']['imageFocusMax'] = isset($options['views_slideshow_imageflow']['imageFocusMax']) ? $options['views_slideshow_imageflow']['imageFocusMax'] : 4; 80 $settings = array( 81 'aspectRatio' => $options['views_slideshow_imageflow']['aspect_ratio'], 82 'imagesHeight' => $options['views_slideshow_imageflow']['images_height'], 83 'imageCursor' => $options['views_slideshow_imageflow']['image_cursor'], 84 'sliderCursor' => $options['views_slideshow_imageflow']['slider_cursor'], 85 'startID' => $start, 86 'slider' => $options['views_slideshow_imageflow']['slider'], 87 'captions' => $options['views_slideshow_imageflow']['captions'], 88 'imageFocusM' => $options['views_slideshow_imageflow']['imageFocusM'], 89 'scrollbarP' => $options['views_slideshow_imageflow']['scrollbarP'], 90 'imageFocusMax' => $options['views_slideshow_imageflow']['imageFocusMax'], 91 'onClick' => $options['views_slideshow_imageflow']['onClick'], 92 ); 93 drupal_add_js(array('viewsSlideshowImageFlow' => array('views-slideshow-imageflow-images-'. $vars['id'] => $settings)), 'setting'); 94 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |