| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Source view] [Print]
(no description)
| Author: | Bermi Ferrer |
| Copyright: | Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org |
| License: | GNU Lesser General Public License |
| File Size: | 469 lines (20 kb) |
| Included or required: | 3 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
AkActionView:: (28 methods):
_loadHelpers()
_registerTemplateHandler()
AkActionView()
renderFile()
render()
renderTemplate()
addSharedAttributes()
pickTemplateExtension()
delegateTemplateExists()
fileIsPublic()
getFullTemplatePath()
_templateExists()
_readTemplateFile()
evaluateAssigns()
_delegateRender()
_assignVariablesFromController()
_javascriptTemplateExists()
renderPartial()
renderPartialCollection()
renderCollectionOfPartials()
_partialPathPiece()
_partialPathName()
_partialCounterName()
_extractingObject()
_addObjectToLocalAssigns()
_addObjectToLocalAssigns_()
_addGlobalVar()
_getGlobals()
Class: AkActionView - X-Ref
Action View templates can be written in two ways. If the template file has a +.tpl+ extension then it uses PHP.| _loadHelpers($helper_dir = null) X-Ref |
| No description |
| _registerTemplateHandler($extension, $className) X-Ref |
| Register a class that knows how to handle template files with the given extension. This can be used to implement new template types. The constructor for the class must take the AkActionView instance as a parameter, and the class must implement a "render" method that takes the contents of the template to render as well as the array of local assigns available to the template. The "render" method ought to return the rendered template as a string. |
| AkActionView($base_path = null, $assigns_for_first_render = array() X-Ref |
| No description |
| renderFile($template_path, $use_full_path = true, $local_assigns = array() X-Ref |
| Renders the template present at <tt>template_path</tt>. If <tt>use_full_path</tt> is set to true, it's relative to the template_root, otherwise it's absolute. The array in <tt>local_assigns</tt> is made available as local variables. |
| render($options = array() X-Ref |
| Renders the template present at <tt>template_path</tt> (relative to the template_root). The array in <tt>local_assigns</tt> is made available as local variables. |
| renderTemplate($____template_extension, $____template, $____file_path = null, $____local_assigns = array() X-Ref |
| No description |
| addSharedAttributes(&$local_assigns) X-Ref |
| No description |
| pickTemplateExtension($template_path) X-Ref |
| No description |
| delegateTemplateExists($template_path) X-Ref |
| No description |
| fileIsPublic($template_path) X-Ref |
| Returns true is the file may be rendered implicitly. |
| getFullTemplatePath($template_path, $extension) X-Ref |
| No description |
| _templateExists($template_path, $extension) X-Ref |
| No description |
| _readTemplateFile($template_path) X-Ref |
| This method reads a template file. |
| evaluateAssigns() X-Ref |
| No description |
| _delegateRender($handler, $template, $local_assigns, $file_path) X-Ref |
| No description |
| _assignVariablesFromController() X-Ref |
| No description |
| _javascriptTemplateExists($template_path) X-Ref |
| No description |
| renderPartial($partial_path, $object, $local_assigns = array() X-Ref |
| Partial Views There's also a convenience method for rendering sub templates within the current controller that depends on a single object (we call this kind of sub templates for partials). It relies on the fact that partials should follow the naming convention of being prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own. In a template for AdvertiserController::account: <?= $controller->render(array('partial' => 'account')); ?> This would render "advertiser/_account.tpl" and pass the instance variable $controller->account in as a local variable $account to the template for display. In another template for Advertiser::buy, we could have: <?= $controller->render(array('partial' =>'account','locals'=>array('account'=>$buyer))); ?> <?php foreach($advertisements as $ad) : ?> <?= $controller->render(array('partial'=>'ad','locals'=>array('ad'=>$ad))); ?> <?php endforeach; ?> This would first render "advertiser/_account.tpl" with $buyer passed in as the local variable $account, then render "advertiser/_ad.tpl" and pass the local variable $ad to the template for display. == Rendering a collection of partials The example of partial use describes a familiar pattern where a template needs to iterate over an array and render a sub template for each of the elements. This pattern has been implemented as a single method that accepts an array and renders a partial by the same name as the elements contained within. So the three-lined example in "Using partials" can be rewritten with a single line: <?= $controller->render(array('partial'=>'ad','collection'=>(array)$advertisements)); ?> This will render "advertiser/_ad.tpl" and pass the local variable +ad+ to the template for display. An iteration counter will automatically be made available to the template with a name of the form +partial_name_counter+. In the case of the example above, the template would be fed +ad_counter+. == Rendering shared partials Two controllers can share a set of partials and render them like this: <?= $controller->render(array('partial'=>'advertiser/ad', 'locals' => array('ad' => $advertisement ))); ?> This will render the partial "advertiser/_ad.tpl" regardless of which controller this is being called from. |
| renderPartialCollection($partial_name, $collection, $partial_spacer_template = null, $local_assigns = array() X-Ref |
| No description |
| renderCollectionOfPartials($partial_name, $collection, $partial_spacer_template = null, $local_assigns = array() X-Ref |
| No description |
| _partialPathPiece($partial_path) X-Ref |
| No description |
| _partialPathName($partial_path) X-Ref |
| No description |
| _partialCounterName($partial_name) X-Ref |
| No description |
| _extractingObject($partial_name, &$deprecated_local_assigns) X-Ref |
| No description |
| _addObjectToLocalAssigns($partial_name, $local_assigns, &$object) X-Ref |
| No description |
| _addObjectToLocalAssigns_($partial_name, &$local_assigns, $object) X-Ref |
| No description |
| _addGlobalVar($var_name, $value, $_retrieve = false) X-Ref |
| Variables assigned using this method will act on any controller or action. Use this in conjunction with your application helpers in order to allow variable passing from inside your views. This is used for example on the capture helper. |
| _getGlobals() X-Ref |
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |