[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/ -> AkActionController.php (summary)

(no description)

File Size: 2991 lines (118 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 12 files
 AkActionView/AkPhpTemplateHandler.php
 AkActionWebService.php
 AkStream.php
 AkActionController/AkPaginator.php
 AkXhtmlValidator.php
 AkDispatcher.php
 AkActionWebService/AkActionWebServiceServer.php
 AkActionView.php
 AkObject.php
 AkActiveRecord.php
 AkActionView/AkHelperLoader.php
 AkActionController/AkCacheHandler.php

Defines 1 class

AkActionController:: (154 methods):
  handleRequest()
  process()
  _sendMimeContentType()
  respondToFormat()
  _identifyRequest()
  handleResponse()
  _loadActionView()
  loadPlugins()
  instantiateHelpers()
  getCurrentControllerHelper()
  getModuleHelper()
  _validateGeneratedXhtml()
  setModel()
  setModels()
  instantiateIncludedModelClasses()
  instantiateModelClass()
  render()
  renderToString()
  renderAction()
  renderFile()
  renderTemplate()
  renderText()
  renderNothing()
  renderPartial()
  renderPartialCollection()
  renderWithLayout()
  renderWithoutLayout()
  eraseRenderResults()
  _addVariablesToAssigns()
  _addInstanceVariablesToAssigns()
  _getProtectedInstanceVariables()
  t()
  redirectTo()
  redirectToAction()
  rewriteOptions()
  getControllerName()
  __getControllerName_PHP4_fix()
  getModuleName()
  setModuleName()
  _removeModuleNameFromControllerName()
  _getTemplateBasePath()
  _getIncludedControllerNames()
  defaultUrlOptions()
  urlFor()
  addToUrl()
  getActionName()
  _doubleRenderError()
  _hasPerformed()
  _getRequestOrigin()
  _getCompleteRequestUri()
  _closeSession()
  _hasTemplate()
  _templateIsPublic()
  _isTemplateExemptFromLayout()
  _assertExistanceOfTemplateFile()
  getDefaultTemplateName()
  setDefaultTemplateName()
  rewrite()
  toString()
  _rewriteUrl()
  _rewriteAuthentication()
  _rewritePath()
  buildQueryString()
  setLayout()
  getLayoutConditions()
  _addLayoutConditions()
  getActiveLayout()
  renderWithALayout()
  _canApplyLayout()
  _isCandidateForLayout()
  _pickLayout()
  _doesActionHasLayout()
  appendBeforeFilter()
  prependBeforeFilter()
  beforeFilter()
  appendAfterFilter()
  prependAfterFilter()
  afterFilter()
  appendAroundFilter()
  prependAroundFilter()
  aroundFilter()
  skipBeforeFilter()
  skipAfterFilter()
  _skipFilter()
  beforeFilters()
  afterFilters()
  includedActions()
  excludedActions()
  _appendFilterToChain()
  _prependFilterToChain()
  _ensureFilterRespondsToBeforeAndAfter()
  _extractConditions()
  _addActionConditions()
  _conditionArray()
  _filterId()
  performActionWithoutFilters()
  performActionWithFilters()
  performAction()
  beforeAction()
  afterAction()
  _callFilters()
  _actionIsExempted()
  _handleFlashAttribute()
  _handleFlashOptions()
  _mergeFlashOnFlashNow()
  _paginationValidateOptions()
  paginate()
  _paginationCreateAndRetrieveCollections()
  _paginationCountCollection()
  _paginationFindCollection()
  _paginationLoadPaginatorAndCollection()
  setSslRequiredActions()
  setSslAllowedActions()
  _isSslRequired()
  _isSslAllowed()
  _ensureProperProtocol()
  defaultAccountSubdomain()
  accountUrl()
  accountHost()
  accountDomain()
  getAccountSubdomain()
  sendFile()
  sendData()
  sendDataAsStream()
  _sendFileHeaders()
  redirectToLocale()
  api()
  _authenticateOrRequestWithHttpBasic()
  _authenticateWithHttpBasic()
  _requestHttpBasicAuthentication()
  _authenticate()
  _getUserNameAndPassword()
  _authorization()
  _decodeCredentials()
  _encodeCredentials()
  _authenticationRequest()
  _ensureActionExists()
  _renderActionNotExists()
  _isActionForbidden()
  _initExtensions()
  _initCacheHandler()
  getAppliedCacheType()
  cacheConfigured()
  cachePage()
  getCachedPage()
  expirePage()
  fragmentCacheKey()
  cacheTplFragmentStart()
  cacheTplFragmentEnd()
  writeFragment()
  readFragment()
  expireFragment()
  expireAction()
  AkActionController()


Class: AkActionController  - X-Ref


handleRequest()   X-Ref
Old fashioned way of dispatching requests. Please use AkDispatcher or roll your own.


process(&$Request, &$Response)   X-Ref
No description

_sendMimeContentType()   X-Ref
No description

respondToFormat($options = array()   X-Ref
Used to respond to multiple formats on the same action.
The format gets detected by the requested file extension or the
accept headers.

Example 1:
If you need to perform some calculations inste
----

function listing()
{
$this->listings = $this->listing->find(..);
if (!$this->respondToFormat()) {
// default html response here
}
}
// handles action listing in format xml
function _handleListingAsXml()
{
$this->renderText($this->listing->toXml($this->listings));
}


Example 2:
If you just render a standard template by default

function listing()
{
// if its the standard format it will render the template post.tpl
$this->respondToFormat();
}
// handles action listing in format xml
function _handleListingAsXml()
{
$this->renderText($this->listing->toXml($this->listings));
}

param: array $options
return: boolean true if there is a format action, false if not

_identifyRequest()   X-Ref
No description

handleResponse()   X-Ref
No description

_loadActionView()   X-Ref
No description

loadPlugins()   X-Ref
No description

instantiateHelpers()   X-Ref
Creates an instance of each available helper and links it into into current controller.

Per example, if a helper TextHelper is located into the file text_helper.php.
An instance is created on current controller
at $this->text_helper. This instance is also available on the view by calling $text_helper.

Helpers can be found at lib/AkActionView/helpers (this might change in a future)

getCurrentControllerHelper()   X-Ref
No description

getModuleHelper()   X-Ref
No description

_validateGeneratedXhtml()   X-Ref
No description

setModel($model)   X-Ref
Methods for loading desired models into this controller


setModels($models)   X-Ref
No description

instantiateIncludedModelClasses($models = array()   X-Ref
No description

instantiateModelClass($model_class_name, $finder_options = array()   X-Ref
No description

render($options = null, $status = 200)   X-Ref
Renders the content that will be returned to the browser as the Response body.

=== Rendering an action

Action rendering is the most common form and the type used automatically by
Action Controller when nothing else is specified. By default, actions are
rendered within the current layout (if one exists).

* Renders the template for the action "goal" within the current controller

$this->render(array('action'=>'goal'));

* Renders the template for the action "short_goal" within the current controller,
but without the current active layout

$this->render(array('action'=>'short_goal','layout'=>false));

* Renders the template for the action "long_goal" within the current controller,
but with a custom layout

$this->render(array('action'=>'long_goal','layout'=>'spectacular'));

=== Rendering partials

Partial rendering is most commonly used together with Ajax calls that only update
one or a few elements on a page without reloading. Rendering of partials from
the controller makes it possible to use the same partial template in
both the full-page rendering (by calling it from within the template) and when
sub-page updates happen (from the controller action responding to Ajax calls).
By default, the current layout is not used.

* Renders the partial located at app/views/controller/_win.tpl

$this->render(array('partial'=>'win'));

* Renders the partial with a status code of 500 (internal error)

$this->render(array('partial'=>'broken','status'=>500));

* Renders the same partial but also makes a local variable available to it

$this->render(array('partial' => 'win', 'locals' => array('name'=>'david')));

* Renders a collection of the same partial by making each element of $wins available through
the local variable "win" as it builds the complete Response

$this->render(array('partial'=>'win','collection'=>$wins));

* Renders the same collection of partials, but also renders the win_divider partial in between
each win partial.

$this->render(array('partial'=>'win','collection'=>$wins,'spacer_template'=>'win_divider'));

=== Rendering a template

Template rendering works just like action rendering except that it takes a
path relative to the template root.
The current layout is automatically applied.

* Renders the template located in app/views/weblog/show.tpl
$this->render(array('template'=>'weblog/show'));

=== Rendering a file

File rendering works just like action rendering except that it takes a
filesystem path. By default, the path is assumed to be absolute, and the
current layout is not applied.

* Renders the template located at the absolute filesystem path
$this->render(array('file'=>'/path/to/some/template.tpl'));
$this->render(array('file'=>'c:/path/to/some/template.tpl'));

* Renders a template within the current layout, and with a 404 status code
$this->render(array('file' => '/path/to/some/template.tpl', 'layout' => true, 'status' => 404));
$this->render(array('file' => 'c:/path/to/some/template.tpl', 'layout' => true, 'status' => 404));

* Renders a template relative to the template root and chooses the proper file extension
$this->render(array('file' => 'some/template', 'use_full_path' => true));


=== Rendering text

Rendering of text is usually used for tests or for rendering prepared content,
such as a cache. By default, text
rendering is not done within the active layout.

* Renders the clear text "hello world" with status code 200
$this->render(array('text' => 'hello world!'));

* Renders the clear text "Explosion!"  with status code 500
$this->render(array('text' => "Explosion!", 'status' => 500 ));

* Renders the clear text "Hi there!" within the current active layout (if one exists)
$this->render(array('text' => "Explosion!", 'layout' => true));

* Renders the clear text "Hi there!" within the layout
* placed in "app/views/layouts/special.tpl"
$this->render(array('text' => "Explosion!", 'layout => "special"));


=== Rendering an inline template

Rendering of an inline template works as a cross between text and action
rendering where the source for the template
is supplied inline, like text, but its evaled by PHP, like action. By default,
PHP is used for rendering and the current layout is not used.

* Renders "hello, hello, hello, again"
$this->render(array('inline' => "<?php echo str_repeat('hello, ', 3).'again'?>" ));

* Renders "hello david"
$this->render(array('inline' => "<?php echo  'hello ' . $name ?>", 'locals' => array('name' => 'david')));


=== Rendering nothing

Rendering nothing is often convenient in combination with Ajax calls that
perform their effect client-side or
when you just want to communicate a status code. Due to a bug in Safari, nothing
actually means a single space.

* Renders an empty Response with status code 200
$this->render(array('nothing' => true));

* Renders an empty Response with status code 401 (access denied)
$this->render(array('nothing' => true, 'status' => 401));

renderToString($options = null)   X-Ref
Renders according to the same rules as <tt>render</tt>, but returns the result in a string instead
of sending it as the Response body to the browser.


renderAction($_action_name, $status = null, $with_layout = true)   X-Ref
No description

renderFile($template_path, $status = null, $use_full_path = false, $locals = array()   X-Ref
No description

renderTemplate($template, $status = null, $type = 'tpl', $local_assigns = array()   X-Ref
No description

renderText($text = null, $status = null)   X-Ref
No description

renderNothing($status = null)   X-Ref
No description

renderPartial($partial_path = null, $object = null, $local_assigns = null, $status = null)   X-Ref
No description

renderPartialCollection($partial_name, $collection, $partial_spacer_template = null, $local_assigns = null, $status = null)   X-Ref
No description

renderWithLayout($template_name = null, $status = null, $layout = null)   X-Ref
No description

renderWithoutLayout($template_name = null, $status = null)   X-Ref
No description

eraseRenderResults()   X-Ref
Clears the rendered results, allowing for another render to be performed.


_addVariablesToAssigns()   X-Ref
No description

_addInstanceVariablesToAssigns()   X-Ref
No description

_getProtectedInstanceVariables()   X-Ref
No description

t($string, $array = null)   X-Ref
Use this to translate strings in the scope of your controller


redirectTo($options = array()   X-Ref
Redirects the browser to the target specified in +options+. This parameter can take one of three forms:

* <tt>Array</tt>: The URL will be generated by calling $this->UrlFor with the +options+.
* <tt>String starting with protocol:// (like http://)</tt>: Is passed straight through
as the target for redirection.
* <tt>String not containing a protocol</tt>: The current protocol and host is prepended to the string.
* <tt>back</tt>: Back to the page that issued the Request-> Useful for forms that are
triggered from multiple places.
Short-hand for redirectTo(Request->env["HTTP_REFERER"])

Examples:
redirectTo(array('action' => 'show', 'id' => 5));
redirectTo('http://www.akelos.com');
redirectTo('/images/screenshot.jpg');
redirectTo('back');

The redirection happens as a "302 Moved" header.

redirectToAction($action, $options = array()   X-Ref
No description

rewriteOptions($options)   X-Ref
This methods are required for retrieving available controllers for URL Routing


getControllerName()   X-Ref
No description

__getControllerName_PHP4_fix($class_name)   X-Ref
No description

getModuleName()   X-Ref
No description

setModuleName($module_name)   X-Ref
No description

_removeModuleNameFromControllerName($controller_name)   X-Ref
Removes the modules name from the controller if exists and sets it.

return: $controller_name

_getTemplateBasePath()   X-Ref
No description

_getIncludedControllerNames()   X-Ref
No description

defaultUrlOptions($options)   X-Ref
Overwrite to implement a number of default options that all urlFor-based methods will use.
The default options should come in
the form of a  an array, just like the one you would use for $this->UrlFor directly. Example:

function defaultUrlOptions($options)
{
return array('project' => ($this->Project->isActive() ? $this->Project->url_name : 'unknown'));
}

As you can infer from the example, this is mostly useful for situations where you want to
centralize dynamic decisions about the urls as they stem from the business domain.
Please note that any individual $this->UrlFor call can always override the defaults set
by this method.

urlFor($options = array()   X-Ref
Returns a URL that has been rewritten according to the options array and the defined Routes.
(For doing a complete redirect, use redirectTo).

<tt>$this->UrlFor</tt> is used to:

All keys given to $this->UrlFor are forwarded to the Route module, save for the following:
* <tt>anchor</tt> -- specifies the anchor name to be appended to the path. For example,
<tt>$this->UrlFor(array('controller' => 'posts', 'action' => 'show', 'id' => 10, 'anchor' => 'comments'</tt>
will produce "/posts/show/10#comments".
* <tt>only_path</tt> --  if true, returns the absolute URL (omitting the protocol, host name, and port)
* <tt>trailing_slash</tt> --  if true, adds a trailing slash, as in "/archive/2005/". Note that this
is currently not recommended since it breaks caching.
* <tt>host</tt> -- overrides the default (current) host if provided
* <tt>protocol</tt> -- overrides the default (current) protocol if provided

The URL is generated from the remaining keys in the array. A URL contains two key parts: the <base> and a query string.
Routes composes a query string as the key/value pairs not included in the <base>.

The default Routes setup supports a typical Akelos Framework path of "controller/action/id"
where action and id are optional, with
action defaulting to 'index' when not given. Here are some typical $this->UrlFor statements
and their corresponding URLs:

$this->UrlFor(array('controller'=>'posts','action'=>'recent')); //  'proto://host.com/posts/recent'
$this->UrlFor(array('controller'=>'posts','action'=>'index')); // 'proto://host.com/posts'
$this->UrlFor(array('controller'=>'posts','action'=>'show','id'=>10)); // 'proto://host.com/posts/show/10'

When generating a new URL, missing values may be filled in from the current
Request's parameters. For example,
<tt>$this->UrlFor(array('action'=>'some_action'));</tt> will retain the current controller,
as expected. This behavior extends to other parameters, including <tt>controller</tt>,
<tt>id</tt>, and any other parameters that are placed into a Route's path.

The URL helpers such as <tt>$this->UrlFor</tt> have a limited form of memory:
when generating a new URL, they can look for missing values in the current Request's parameters.
Routes attempts to guess when a value should and should not be
taken from the defaults. There are a few simple rules on how this is performed:

* If the controller name begins with a slash, no defaults are used: <tt>$this->UrlFor(array('controller'=>'/home'));</tt>
* If the controller changes, the action will default to index unless provided

The final rule is applied while the URL is being generated and is best illustrated by an example. Let us consider the
route given by <tt>map->connect('people/:last/:first/:action', array('action' => 'bio', 'controller' => 'people'))</tt>.

Suppose that the current URL is "people/hh/david/contacts". Let's consider a few
different cases of URLs which are generated from this page.

* <tt>$this->UrlFor(array('action'=>'bio'));</tt> -- During the generation of this URL,
default values will be used for the first and
last components, and the action shall change. The generated URL will be, "people/hh/david/bio".
* <tt>$this->UrlFor(array('first'=>'davids-little-brother'));</tt> This
generates the URL 'people/hh/davids-little-brother' -- note
that this URL leaves out the assumed action of 'bio'.

However, you might ask why the action from the current Request, 'contacts', isn't
carried over into the new URL. The answer has to do with the order in which
the parameters appear in the generated path. In a nutshell, since the
value that appears in the slot for <tt>first</tt> is not equal to default value
for <tt>first</tt> we stop using defaults. On it's own, this rule can account
for much of the typical Akelos Framework URL behavior.

Although a convienence, defaults can occasionaly get in your way. In some cases
a default persists longer than desired.
The default may be cleared by adding <tt>'name' => null</tt> to <tt>$this->UrlFor</tt>'s options.
This is often required when writing form helpers, since the defaults in play
may vary greatly depending upon where the helper is used from. The following line
will redirect to PostController's default action, regardless of the page it is
displayed on:

$this->UrlFor(array('controller' => 'posts', 'action' => null));

If you explicitly want to create a URL that's almost the same as the current URL, you can do so using the
overwrite_params options. Say for your posts you have different views for showing and printing them.
Then, in the show view, you get the URL for the print view like this

$this->UrlFor(array('overwrite_params' => array('action' => 'print')));

This takes the current URL as is and only exchanges the action. In contrast,
<tt>$this->UrlFor(array('action'=>'print'));</tt>
would have slashed-off the path components after the changed action.

addToUrl($options = array()   X-Ref
No description

getActionName()   X-Ref
No description

_doubleRenderError($message = null)   X-Ref
No description

_hasPerformed()   X-Ref
No description

_getRequestOrigin()   X-Ref
No description

_getCompleteRequestUri()   X-Ref
No description

_closeSession()   X-Ref
No description

_hasTemplate($template_name = null)   X-Ref
No description

_templateIsPublic($template_name = null)   X-Ref
No description

_isTemplateExemptFromLayout($template_name = null)   X-Ref
No description

_assertExistanceOfTemplateFile($template_name)   X-Ref
No description

getDefaultTemplateName($default_action_name = null)   X-Ref
No description

setDefaultTemplateName($template_name)   X-Ref
No description

rewrite($options = array()   X-Ref
No description

toString()   X-Ref
No description

_rewriteUrl($path, $options)   X-Ref
Given a path and options, returns a rewritten URL string


_rewriteAuthentication($options)   X-Ref
No description

_rewritePath($options)   X-Ref
No description

buildQueryString($array, $only_keys = null)   X-Ref
Returns a query string with escaped keys and values from the passed array. If the passed
array contains an 'id' it'll
be added as a path element instead of a regular parameter pair.


setLayout($template_name, $conditions = array()   X-Ref
If a layout is specified, all actions rendered through render and render_action will have their result assigned
to <tt>$this->content_for_layout</tt>, which can then be used by the layout to insert their contents with
<tt><?php echo  $$this->content_for_layout ?></tt>. This layout can itself depend on instance variables assigned during action
performance and have access to them as any normal template would.


getLayoutConditions()   X-Ref
No description

_addLayoutConditions($conditions)   X-Ref
No description

getActiveLayout($passed_layout = null)   X-Ref
Returns the name of the active layout. If the layout was specified as a method reference, this method
is called and the return value is used. Likewise if( the layout was specified as an inline method (through a method
object). If the layout was defined without a directory, layouts is assumed. So <tt>setLayout('weblog/standard')</tt> will return
weblog/standard, but <tt>setLayout('standard')</tt> will return layouts/standard.


renderWithALayout($options = null, $status = null, $layout = null)   X-Ref
No description

_canApplyLayout($template_with_options, $options)   X-Ref
No description

_isCandidateForLayout($options)   X-Ref
No description

_pickLayout($template_with_options, $options, $layout = null)   X-Ref
No description

_doesActionHasLayout()   X-Ref
No description

appendBeforeFilter()   X-Ref
The passed <tt>filters</tt> will be appended to the array of filters that's run _before_ actions
on this controller are performed.


prependBeforeFilter()   X-Ref
The passed <tt>filters</tt> will be prepended to the array of filters that's run _before_ actions
on this controller are performed.


beforeFilter()   X-Ref
Short-hand for appendBeforeFilter since that's the most common of the two.


appendAfterFilter()   X-Ref
The passed <tt>filters</tt> will be appended to the array of filters that's run _after_ actions
on this controller are performed.


prependAfterFilter()   X-Ref
The passed <tt>filters</tt> will be prepended to the array of filters that's run _after_ actions
on this controller are performed.


afterFilter()   X-Ref
Short-hand for appendAfterFilter since that's the most common of the two.


appendAroundFilter()   X-Ref
The passed <tt>filters</tt> will have their +before+ method appended to the array of filters that's run both before actions
on this controller are performed and have their +after+ method prepended to the after actions. The filter objects must all
respond to both +before+ and +after+. So if you do appendAroundFilter(new A(), new B()), the callstack will look like:

B::before()
A::before()
A::after()
B::after()

prependAroundFilter()   X-Ref
The passed <tt>filters</tt> will have their +before+ method prepended to the array of filters that's run both before actions
on this controller are performed and have their +after+ method appended to the after actions. The filter objects must all
respond to both +before+ and +after+. So if you do appendAroundFilter(new A(), new B()), the callstack will look like:

A::before()
B::before()
B::after()
A::after()

aroundFilter()   X-Ref
Short-hand for appendAroundFilter since that's the most common of the two.


skipBeforeFilter($filters)   X-Ref
Removes the specified filters from the +before+ filter chain.
This is especially useful for managing the chain in inheritance hierarchies where only one out
of many sub-controllers need a different hierarchy.


skipAfterFilter($filters)   X-Ref
Removes the specified filters from the +after+ filter chain. Note that this only works for skipping method-reference
filters, not instances. This is especially useful for managing the chain in inheritance hierarchies where only one out
of many sub-controllers need a different hierarchy.


_skipFilter(&$filters, $type)   X-Ref
No description

beforeFilters()   X-Ref
Returns all the before filters for this class.


afterFilters()   X-Ref
Returns all the after filters for this class and all its ancestors.


includedActions()   X-Ref
Returns a mapping between filters and the actions that may run them.


excludedActions()   X-Ref
Returns a mapping between filters and actions that may not run them.


_appendFilterToChain($condition, $filters)   X-Ref
No description

_prependFilterToChain($condition, $filters)   X-Ref
No description

_ensureFilterRespondsToBeforeAndAfter(&$filter_object)   X-Ref
No description

_extractConditions(&$filters)   X-Ref
No description

_addActionConditions($filters, $conditions)   X-Ref
No description

_conditionArray($actions, $filter_actions)   X-Ref
No description

_filterId($filters)   X-Ref
No description

performActionWithoutFilters($action)   X-Ref
No description

performActionWithFilters($method = '')   X-Ref
No description

performAction($method = '')   X-Ref
No description

beforeAction($method = '')   X-Ref
Calls all the defined before-filter filters, which are added by using "beforeFilter($method)".
If any of the filters return false, no more filters will be executed and the action is aborted.


afterAction($method = '')   X-Ref
Calls all the defined after-filter filters, which are added by using "afterFilter($method)".
If any of the filters return false, no more filters will be executed.


_callFilters(&$filters, $method = '')   X-Ref
No description

_actionIsExempted($filter, $method = '')   X-Ref
No description

_handleFlashAttribute()   X-Ref
No description

_handleFlashOptions()   X-Ref
No description

_mergeFlashOnFlashNow()   X-Ref
No description

_paginationValidateOptions($collection_id, $options = array()   X-Ref
No description

paginate($collection_id, $options = array()   X-Ref
Returns a paginator and a collection of Active Record model instances
for the paginator's current page. This is designed to be used in a
single action.

+options+ are:
<tt>singular_name</tt>:: the singular name to use, if it can't be inferred by
singularizing the collection name
<tt>class_name</tt>:: the class name to use, if it can't be inferred by
camelizing the singular name
<tt>per_page</tt>::   the maximum number of items to include in a
single page. Defaults to 10
<tt>conditions</tt>:: optional conditions passed to Model::find('all', $this->params); and
Model::count()
<tt>order</tt>::      optional order parameter passed to Model::find('all', $this->params);
<tt>order_by</tt>::   (deprecated, used :order) optional order parameter passed to Model::find('all', $this->params)
<tt>joins</tt>::      optional joins parameter passed to Model::find('all', $this->params)
and Model::count()
<tt>join</tt>::       (deprecated, used :joins or :include) optional join parameter passed to Model::find('all', $this->params)
and Model::count()
<tt>include</tt>::    optional eager loading parameter passed to Model::find('all', $this->params)
and Model::count()

Creates a +before_filter+ which automatically paginates an Active
Record model for all actions in a controller (or certain actions if
specified with the <tt>actions</tt> option).

+options+ are the same as PaginationHelper::paginate, with the addition
of:
<tt>actions</tt>:: an array of actions for which the pagination is
active. Defaults to +null+ (i.e., every action)

_paginationCreateAndRetrieveCollections()   X-Ref
No description

_paginationCountCollection(&$model, $conditions, $joins)   X-Ref
Returns the total number of items in the collection to be paginated for
the +model+ and given +conditions+. Override this method to implement a
custom counter.


_paginationFindCollection(&$model, $options, &$paginator)   X-Ref
Returns a collection of items for the given +$model+ and +$options['conditions']+,
ordered by +$options['order']+, for the current page in the given +$paginator+.
Override this method to implement a custom finder.


_paginationLoadPaginatorAndCollection($collection_id, $options)   X-Ref


setSslRequiredActions($actions)   X-Ref
Specifies that the named actions requires an SSL connection to be performed (which is enforced by ensure_proper_protocol).


setSslAllowedActions($actions)   X-Ref
No description

_isSslRequired()   X-Ref
Returns true if the current action is supposed to run as SSL


_isSslAllowed()   X-Ref
No description

_ensureProperProtocol()   X-Ref
No description

defaultAccountSubdomain()   X-Ref
Account location is a set of methods that supports the account-key-as-subdomain
way of identifying the current scope. These methods allow you to easily produce URLs that
match this style and to get the current account key from the subdomain.

The methods are: getAccountUrl, getAccountHost, and getAccountDomain.

Example:

include_once('AkAccountLocation.php');

class ApplicationController extends AkActionController
{
var $before_filter = '_findAccount';

function _findAccount()
{
$this->account = Account::find(array('conditions'=>array('username = ?', $this->account_domain)));
}

class AccountController extends ApplicationController
{
function new_account()
{
$this->new_account = Account::create($this->params['new_account']);
$this->redirectTo(array('host' => $this->accountHost($this->new_account->username), 'controller' => 'weblog'));
}

function authenticate()
{
$this->session[$this->account_domain] = 'authenticated';
$this->redirectTo(array('controller => 'weblog'));
}

function _isAuthenticated()
{
return !empty($this->session['account_domain']) ? $this->session['account_domain'] == 'authenticated' : false;
}
}

// The view:
Your domain: {account_url?}

By default, all the methods will query for $this->account->username as the account key, but you can
specialize that by overwriting defaultAccountSubdomain. You can of course also pass it in
as the first argument to all the methods.

accountUrl($account_subdomain = null, $use_ssl = null)   X-Ref
No description

accountHost($account_subdomain = null)   X-Ref
No description

accountDomain()   X-Ref
No description

getAccountSubdomain()   X-Ref
No description

sendFile($path, $options = array()   X-Ref
Sends the file by streaming it 4096 bytes at a time. This way the
whole file doesn't need to be read into memory at once.  This makes
it feasible to send even large files.

Be careful to sanitize the path parameter if it coming from a web
page.  sendFile($params['path']) allows a malicious user to
download any file on your server.

Options:
* <tt>filename</tt> - suggests a filename for the browser to use.
Defaults to realpath($path).
* <tt>type</tt> - specifies an HTTP content type.
Defaults to 'application/octet-stream'.
* <tt>disposition</tt> - specifies whether the file will be shown inline or downloaded.
Valid values are 'inline' and 'attachment' (default).
* <tt>stream</tt> - whether to send the file to the user agent as it is read (true)
or to read the entire file before sending (false). Defaults to true.
* <tt>buffer_size</tt> - specifies size (in bytes) of the buffer used to stream the file.
Defaults to 4096.

The default Content-Type and Content-Disposition headers are
set to download arbitrary binary files in as many browsers as
possible.  IE versions 4, 5, 5.5, and 6 are all known to have
a variety of quirks (especially when downloading over SSL).

Simple download:
sendFile('/path/to.zip');

Show a JPEG in browser:
sendFile('/path/to.jpeg', array('type' => 'image/jpeg', 'disposition' => 'inline'));

Read about the other Content-* HTTP headers if you'd like to
provide the user with more information (such as Content-Description).
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11

Also be aware that the document may be cached by proxies and browsers.
The Pragma and Cache-Control headers declare how the file may be cached
by intermediaries.  They default to require clients to validate with
the server before releasing cached responses.  See
http://www.mnot.net/cache_docs/ for an overview of web caching and
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
for the Cache-Control header spec.

sendData($data, $options = array()   X-Ref
Send binary data to the user as a file download.  May set content type, apparent file name,
and specify whether to show data inline or download as an attachment.

Options:
* <tt>filename</tt> - Suggests a filename for the browser to use.
* <tt>type</tt> - specifies an HTTP content type.
Defaults to 'application/octet-stream'.
* <tt>disposition</tt> - specifies whether the file will be shown inline or downloaded.
Valid values are 'inline' and 'attachment' (default).

Generic data download:
sendData($buffer)

Download a dynamically-generated tarball:
sendData(Ak::compress('dir','tgz'), array('filename' => 'dir.tgz'));

Display an image Active Record in the browser:
sendData($image_data, array('type' =>Ak::mime_content_type('image_name.png'), 'disposition' => 'inline'));

See +sendFile+ for more information on HTTP Content-* headers and caching.

sendDataAsStream($data, $options)   X-Ref
Creates a file for streaming from a file.
This way you might free memory usage is file is too large


_sendFileHeaders(&$options)   X-Ref
No description

redirectToLocale($locale)   X-Ref
No description

api($protocol = 'xml_rpc')   X-Ref
No description

_authenticateOrRequestWithHttpBasic($realm = AK_APP_NAME, $login_procedure)   X-Ref
Simple Basic example:

class PostsController extends ApplicationController
{
var $_authorized_users = array('bermi' => 'secret');

function __construct(){
$this->beforeFilter(array('authenticate' => array('except' => array('index'))));
}

function index() {
$this->renderText("Everyone can see me!");
}

function edit(){
$this->renderText("I'm only accessible if you know the password");
}

function authenticate(){
return $this->_authenticateOrRequestWithHttpBasic('App name', $this->_authorized_users);
}
}

Here is a more advanced Basic example where only Atom feeds and the XML API is protected by HTTP authentication,
the regular HTML interface is protected by a session approach:

class ApplicationController extends AkActionController
{
var $models = 'account';

function __construct() {
$this->beforeFilter(array('_setAccount', 'authenticate'));
}

function _setAccount() {
$this->Account = $this->account->findFirstBy('url_name', array_pop($this->Request->getSubdomains()));
}

function authenticate() {
if($this->Request->isFormat('XML', 'ATOM')){
if($User = $this->_authenticateWithHttpBasic($Account)){
$this->CurrentUser = $User;
}else{
$this->_requestHttpBasicAuthentication();
}
}else{
if($this->isSessionAuthenticated()){
$this->CurrentUser = $Account->user->find($_SESSION['authenticated']['user_id']);
}else{
$this->redirectTo(array('controller'=>'login'));
return false;
}
}
}
}

On shared hosts, Apache sometimes doesn't pass authentication headers to
FCGI instances. If your environment matches this description and you cannot
authenticate, try this rule in public/.htaccess (replace the plain one):

RewriteRule ^(.*)$ index.php [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]

_authenticateWithHttpBasic($login_procedure)   X-Ref
No description

_requestHttpBasicAuthentication($realm = AK_APP_NAME)   X-Ref
No description

_authenticate($login_procedure)   X-Ref
This is method takes a $login_procedure for performing access authentication.

If an array is given, it will check the key for a user and the value will be verified to match given password.

You can pass and array like array('handler' => $Account, 'method' => 'verifyCredentials'), which will call

$Account->verifyCredentials($user_name, $password, $Controller)

You can also pass an object which implements an "authenticate" method. when calling

$this->_authenticate(new User());

It will call the $User->authenticate($user_name, $password, $Controller)

In both cases the authentication method should return true for valid credentials or false is invalid.

return: bool

_getUserNameAndPassword()   X-Ref
No description

_authorization()   X-Ref
No description

_decodeCredentials()   X-Ref
No description

_encodeCredentials($user_name, $password)   X-Ref
No description

_authenticationRequest($realm)   X-Ref
No description

_ensureActionExists()   X-Ref
No description

_renderActionNotExists()   X-Ref
No description

_isActionForbidden()   X-Ref
No description

_initExtensions()   X-Ref
########################################################################
#
#               Modules
#
########################################################################


_initCacheHandler()   X-Ref
No description

getAppliedCacheType()   X-Ref
No description

cacheConfigured()   X-Ref
########################################################################
#
#               START Module: AkActionControllerCaching
#
########################################################################


cachePage($content, $path = null)   X-Ref
No description

getCachedPage($path = null, $lang = null)   X-Ref
No description

expirePage($options)   X-Ref
No description

fragmentCacheKey($key)   X-Ref
No description

cacheTplFragmentStart($key, $options = array()   X-Ref
No description

cacheTplFragmentEnd($key, $options = array()   X-Ref
No description

writeFragment($key, $content, $options = array()   X-Ref
No description

readFragment($key, $options = array()   X-Ref
No description

expireFragment($key, $options = array()   X-Ref
No description

expireAction($options = array()   X-Ref
No description

AkActionController()   X-Ref
Function for getting the singleton controller;

return: AkActionController instance



Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6