Changeset 1609
- Timestamp:
- 01/30/07 10:03:24 (2 years ago)
- Location:
- branches/0.11/src
- Files:
-
- 5 modified
-
filter/AgaviExecutionFilter.class.php (modified) (2 diffs)
-
renderer/AgaviPhpRenderer.class.php (modified) (5 diffs)
-
renderer/AgaviPhptalRenderer.class.php (modified) (3 diffs)
-
renderer/AgaviRenderer.class.php (modified) (4 diffs)
-
renderer/AgaviSmartyRenderer.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/src/filter/AgaviExecutionFilter.class.php
r1600 r1609 326 326 $actionAttributes = $container->getAttributes(); 327 327 } 328 329 $response->clear(); 328 330 329 331 if($viewName !== AgaviView::NONE) { … … 383 385 } 384 386 } 385 $nextOutput = $layer->getRenderer()->render($layer, $attributes, $output); 387 $moreAssigns = array( 388 'container' => $container, 389 'inner' => $nextOutput, 390 'view' => $viewInstance, 391 ); 392 $nextOutput = $layer->getRenderer()->render($layer, $attributes, $output, $moreAssigns); 386 393 $output = array(); 387 394 $output[$layer->getName()] = $nextOutput; -
branches/0.11/src/renderer/AgaviPhpRenderer.class.php
r1568 r1609 39 39 * used during rendering. 40 40 */ 41 pr otected $_layer = null;41 private $layer = null; 42 42 43 43 /** … … 45 45 * rendering. 46 46 */ 47 pr otected $_attributes = null;47 private $attributes = null; 48 48 49 49 /** … … 51 51 * rendering. 52 52 */ 53 protected $_slots = null; 53 private $slots = null; 54 55 /** 56 * @var array Temporary storage for additional assigns, used during 57 * rendering. 58 */ 59 private $additionalAssigns = null; 54 60 55 61 /** … … 59 65 * @param array The template variables. 60 66 * @param array The slots. 67 * @param array Associative array of additional assigns. 61 68 * 62 69 * @return string A rendered result. … … 65 72 * @since 0.11.0 66 73 */ 67 public function render(AgaviTemplateLayer $layer, array &$attributes , array &$slots = array())74 public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) 68 75 { 69 76 // DO NOT USE VARIABLES IN HERE, THEY MIGHT INTERFERE WITH TEMPLATE VARS 70 $this->_layer = $layer; 71 $this->_attributes =& $attributes; 72 $this->_slots =& $slots; 73 unset($layer, $attributes, $slots); 77 $this->layer = $layer; 78 $this->attributes =& $attributes; 79 $this->slots =& $slots; 80 foreach($moreAssigns as $moreAssignName => &$moreAssign) { 81 if(isset($this->moreAssignNames[$moreAssignName])) { 82 $moreAssignName = $this->moreAssignNames[$moreAssignName]; 83 } 84 $this->moreAssigns[$moreAssignName] =& $moreAssign; 85 } 86 unset($layer, $attributes, $slots, $moreAssigns); 74 87 75 88 if($this->extractVars) { 76 extract($this-> _attributes, EXTR_REFS | EXTR_PREFIX_INVALID, '_');89 extract($this->attributes, EXTR_REFS | EXTR_PREFIX_INVALID, '_'); 77 90 } else { 78 ${$this->varName} =& $this-> _attributes;91 ${$this->varName} =& $this->attributes; 79 92 } 80 93 81 ${$this->slotsVarName} =& $this-> _slots;94 ${$this->slotsVarName} =& $this->slots; 82 95 83 96 extract($this->assigns); 84 97 98 extract($this->moreAssigns, EXTR_REFS); 99 85 100 ob_start(); 86 101 87 require($this-> _layer->getResourceStreamIdentifier());102 require($this->layer->getResourceStreamIdentifier()); 88 103 89 104 $retval = ob_get_contents(); 90 105 ob_end_clean(); 91 106 92 unset($this-> _layer, $this->_attributes, $this->_slots);107 unset($this->layer, $this->attributes, $this->slots, $this->moreAssigns); 93 108 94 109 return $retval; -
branches/0.11/src/renderer/AgaviPhptalRenderer.class.php
r1568 r1609 83 83 * @param array The template variables. 84 84 * @param array The slots. 85 * @param array Associative array of additional assigns. 85 86 * 86 87 * @return string A rendered result. … … 90 91 * @since 0.11.0 91 92 */ 92 public function render(AgaviTemplateLayer $layer, array &$attributes , array &$slots = array())93 public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) 93 94 { 94 95 $engine = $this->getEngine(); … … 108 109 } 109 110 111 foreach($moreAssigns as $key => $value) { 112 if(isset($this->moreAssignNames[$key])) { 113 $key = $this->moreAssignNames[$key]; 114 } 115 $engine->set($key, $value); 116 } 117 110 118 $engine->setTemplate($layer->getResourceStreamIdentifier()); 111 119 -
branches/0.11/src/renderer/AgaviRenderer.class.php
r1568 r1609 61 61 62 62 /** 63 * @var array An array of names for the "more" assigns. 64 */ 65 protected $moreAssignNames = array(); 66 67 /** 63 68 * Initialize this Renderer. 64 69 * … … 85 90 } 86 91 if(isset($parameters['assigns'])) { 87 foreach($parameters['assigns'] as $factory => $var) { 88 $getter = 'get' . str_replace('_', '', $factory); 89 $this->assigns[$var] = $this->context->$getter(); 92 foreach($parameters['assigns'] as $item => $var) { 93 $getter = 'get' . str_replace('_', '', $item); 94 if(method_exists($this->context, $getter)) { 95 $this->assigns[$var] = $this->context->$getter(); 96 } else { 97 $this->moreAssignNames[$item] = $var; 98 } 90 99 } 91 100 } … … 124 133 * @param array The template variables. 125 134 * @param array The slots. 135 * @param array Associative array of additional assigns. 126 136 * 127 137 * @return string A rendered result. … … 130 140 * @since 0.11.0 131 141 */ 132 abstract public function render(AgaviTemplateLayer $layer, array &$attributes , array &$slots = array());142 abstract public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()); 133 143 } 134 144 -
branches/0.11/src/renderer/AgaviSmartyRenderer.class.php
r1568 r1609 114 114 * @param array The template variables. 115 115 * @param array The slots. 116 * @param array Associative array of additional assigns. 116 117 * 117 118 * @return string A rendered result. … … 120 121 * @since 0.11.0 121 122 */ 122 public function render(AgaviTemplateLayer $layer, array &$attributes , array &$slots = array())123 public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) 123 124 { 124 125 $engine = $this->getEngine(); … … 138 139 } 139 140 141 foreach($moreAssigns as $key => &$value) { 142 if(isset($this->moreAssignNames[$key])) { 143 $key = $this->moreAssignNames[$key]; 144 } 145 $engine->assign_by_ref($key, $value); 146 } 147 140 148 return $this->getEngine()->fetch($layer->getResourceStreamIdentifier()); 141 149 }

