Changeset 1091:d32eaf9fac5e for inc
- Timestamp:
- 12/20/12 23:59:54 (13 years ago)
- Branch:
- twig
- Location:
- inc/admin
- Files:
-
- 2 edited
-
class.dc.admincontext.php (modified) (3 diffs)
-
default-templates/js_helpers.html.twig (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.admincontext.php
r1089 r1091 23 23 protected $globals = array(); 24 24 protected $protected_globals = array(); 25 protected $memory = array(); 25 26 26 27 public function __construct($core) … … 126 127 return array( 127 128 '__' => new Twig_Function_Function("__", array('is_safe' => array('html'))), 128 'debug_info' => new Twig_Function_Method($this, 'getDebugInfo', array('is_safe' => array('html'))) 129 //,'page_menu' => new Twig_Function_Method($this, 'pageMenu', array('is_safe' => array('html'))) 129 'debug_info' => new Twig_Function_Method($this, 'getDebugInfo', array('is_safe' => array('html'))), 130 'memorize' => new Twig_Function_Method($this, 'setMemory', array('is_safe' => array('html'))), 131 'memorized' => new Twig_Function_Method($this, 'getMemory', array('is_safe' => array('html'))) 130 132 ); 131 133 } … … 461 463 return $di; 462 464 } 465 466 /** 467 Add a value in a namespace memory 468 469 This help keep variable when recalling Twig macros 470 471 @param string $ns A namespace 472 @param string $str A value to memorize in this namespace 473 */ 474 public function setMemory($ns,$str) 475 { 476 if (!array_key_exists($ns,$this->memory) || !in_array($str,$this->memory[$ns])) { 477 $this->memory[$ns][] = $str; 478 } 479 } 480 481 /** 482 Check if a value is previously memorized in a namespace 483 484 @param string $ns A namespace 485 @param string $str A value to search in this namespace 486 @return array True if exists 487 */ 488 public function getMemory($ns,$str) 489 { 490 return array_key_exists($ns,$this->memory) && in_array($str,$this->memory[$ns]); 491 } 463 492 } 464 493 ?> -
inc/admin/default-templates/js_helpers.html.twig
r1088 r1091 1 1 {# JS Helpers #} 2 3 {% macro load(src,type) -%} 4 {% if not memorized('jsload',src) -%} 5 {{ memorize('jsload',src) -}} 6 {% set type = type|default('text/javascript') -%} 7 <script type="{{ type }}" src="{{ theme_url }}{{ src }}"></script> 8 {%- endif %} 9 {%- endmacro %} 2 10 3 11 {% macro common() %} 4 12 <!-- jsCommon --> 5 <script type="text/javascript" src="{{theme_url}}js/jquery/jquery.js"></script>6 <script type="text/javascript" src="{{theme_url}}js/jquery/jquery.biscuit.js"></script>7 <script type="text/javascript" src="{{theme_url}}js/jquery/jquery.bgFade.js"></script>8 <script type="text/javascript" src="{{theme_url}}js/jquery/jquery.constantfooter.js"></script>9 <script type="text/javascript" src="{{theme_url}}js/common.js"></script>10 <script type="text/javascript" src="{{theme_url}}js/prelude.js"></script>13 {{ _self.load('js/jquery/jquery.js') }} 14 {{ _self.load('js/jquery/jquery.biscuit.js') }} 15 {{ _self.load('js/jquery/jquery.bgFade.js') }} 16 {{ _self.load('js/jquery/jquery.constantfooter.js') }} 17 {{ _self.load('js/common.js') }} 18 {{ _self.load('js/prelude.js') }} 11 19 <script type="text/javascript"> 12 20 //<![CDATA[ … … 58 66 {% macro load_IE7() %} 59 67 <!--[if lt IE 8]> 60 <script type="text/javascript" src="{{theme_url}}js/ie7/IE8.js"></script>68 {{ _self.load('ie7/IE8.js') }} 61 69 <link rel="stylesheet" type="text/css" href="{{theme_url}}style/iesucks.css" /> 62 70 <![endif]--> … … 66 74 {% if values is not iterable %}{% set values = [values] %} {% endif %} 67 75 <!-- jsConfirmClose --> 68 <script type="text/javascript" src="{{theme_url}}js/confirm-close.js"></script>76 {{ _self.load('js/confirm-close.js') }} 69 77 <script type="text/javascript"> 70 78 //<