Changeset 12954 for trunk/include/template.class.php
- Timestamp:
- Jan 24, 2012, 8:24:47 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/template.class.php
r12920 r12954 115 115 $this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') ); 116 116 $this->smarty->register_function('combine_css', array(&$this, 'func_combine_css') ); 117 $this->smarty->register_function('define_derivative', array(&$this, 'func_define_derivative') ); 117 118 $this->smarty->register_compiler_function('get_combined_css', array(&$this, 'func_get_combined_css') ); 118 119 $this->smarty->register_block('footer_script', array(&$this, 'block_footer_script') ); … … 545 546 $this->html_style .= $content; 546 547 } 548 } 549 550 function func_define_derivative($params, &$smarty) 551 { 552 !empty($params['name']) or fatal_error('define_derviative missing name'); 553 if (isset($params['type'])) 554 { 555 $derivative = ImageStdParams::get_by_type($params['type']); 556 $smarty->assign( $params['name'], $derivative); 557 return; 558 } 559 !empty($params['width']) or fatal_error('define_derviative missing width'); 560 !empty($params['height']) or fatal_error('define_derviative missing height'); 561 562 $derivative = new DerivativeParams( SizingParams::classic( intval($params['width']), intval($params['height'])) ); 563 if (isset($params['crop'])) 564 { 565 if (is_bool($params['crop'])) 566 { 567 $derivative->sizing->max_crop = $params['crop'] ? 1:0; 568 } 569 else 570 { 571 $derivative->sizing->max_crop = round($params['crop']/100, 2); 572 } 573 574 if ($derivative->sizing->max_crop) 575 { 576 $minw = empty($params['min_width']) ? $derivative->max_width() : intval($params['min_width']); 577 $minw <= $derivative->max_width() or fatal_error('define_derviative invalid min_width'); 578 $minh = empty($params['min_height']) ? $derivative->max_height() : intval($params['min_height']); 579 $minh <= $derivative->max_height() or fatal_error('define_derviative invalid min_height'); 580 581 $derivative->sizing->min_size = array($minw, $minh); 582 } 583 } 584 585 ImageStdParams::apply_global($derivative); 586 $smarty->assign( $params['name'], $derivative); 547 587 } 548 588
Note: See TracChangeset
for help on using the changeset viewer.