| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: image_plugin_argument_validate_image_size.inc,v 1.2 2009/08/26 18:41:44 joachim Exp $ 3 4 /** 5 * @file 6 * Views validation plugin for image size argument. 7 */ 8 9 /** 10 * Validation handler for image size. 11 * 12 * Validates an image size argument and allows to restrict which image sizes 13 * are valid. 14 */ 15 class image_plugin_argument_validate_image_size extends views_plugin_argument_validate { 16 var $image_sizes = array(); 17 18 function init(&$view, &$argument, $id = NULL) { 19 parent::init($view, $argument, $id); 20 $this->image_sizes = image_get_sizes(); 21 } 22 23 function validate_form(&$form, &$form_state) { 24 $image_size_options = array(); 25 foreach ($this->image_sizes as $key => $size) { 26 $image_size_options[$key] = $size['label']; 27 } 28 29 $form['image_size'] = array( 30 '#type' => 'select', 31 '#title' => t('Image sizes'), 32 '#options' => $image_size_options, 33 '#default_value' => $this->get_argument(), 34 '#multiple' => TRUE, 35 '#required' => TRUE, 36 '#process' => array('views_process_dependency'), 37 '#dependency' => array('edit-options-validate-type' => array($this->id)), 38 '#description' => t("Which image sizes are allowed to be passed through this argument. Both 'original' and '_original' are valid."), 39 ); 40 } 41 42 function get_argument() { 43 return isset($this->argument->options['image_size']) ? $this->argument->options['image_size'] : array_keys($this->image_sizes); 44 } 45 46 function validate_argument($argument) { 47 // Allow 'original' as well as '_original'. It's really up to the handler to 48 // deal with this and change it before it gets here, but seeing as we 49 // promise to do this in the UI we should back it up here. 50 if ($argument == 'original') { 51 $argument = '_original'; 52 } 53 54 return $this->argument->options['image_size'][$argument]; 55 } 56 } 57
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 |