{jcomments on}

Overview

Task map

JControllerLegacy implements a task map used by JControllerLegacy::execute to enable routing of the task to a method defined by a derivative class of JControllerLegacy such as JControllerAdmin and JControllerForm or their descendant classes.

Populating the Task map

The task map is populated by reference to the relative complementary public methods of the derivative class compared to JControllerLegacy. The public methods of the derivative class are secured using ReflectionClass::getMethods(ReflectionMethod::IS_PUBLIC) whereas the set of public methods of JControllerLegacy is determined more widely using the PHP API function get_class_methods. The resultant task map contains all of the public functions of the derivative class excluding any functions of the same name (irrespective of signature or parameter list) as JControllerLegacy.

Properties

JControllerLegacy::$basePath

 

JControllerLegacy::$default_view

 

JControllerLegacy::$doTask

 

JControllerLegacy::$message

 

JControllerLegacy::$methods

 

JControllerLegacy::$name

 

JControllerLegacy::$model_prefix

 

JControllerLegacy::$paths

 

JControllerLegacy::$redirect

 

JControllerLegacy::$task

 

JControllerLegacy::$taskMap

 

JControllerLegacy::$input

 

JControllerLegacy::$instance

 

Methods

JControllerLegacy::__construct($config = array())

JControllerLegacy::__construct is the constructor or parent constructor for an instance of the JControllerLegacy class.

JControllerLegacy::createView($name, $prefix = '', $type = '', $config = array())

The JControllerLegacy::createView method searchs for and, if found, loads a JViewLegacy object given by the catenated values of the optional prefix, $prefix and the name, $name.

Pseudo code

  1. construct the JViewLegacy class definition file name using JControllerLegacy::createFileName according to the pattern, converted to lower case as follows: <$name>/view.<$type>.php; for example "view.html.php";
  2. search for the class definition file using JPath::find function and the path list provided by JControllerLegacy::$paths['view']; and
  3. if the class definition is found, load the class definition and instantiate a new instance of the JViewLegacy class.

Note

Where a call is made to createView and the file name for the view is resolved using JControllerLegacy::createFileName, the path and file name generated is converted to lower case. Accordingly, a HTML view with the name 'DocumentList' is accessed from the directory 'documentlist/view.html.php'; this behaviour may create cross-platform issues depending on whether the underlying filesystem is case sensitive or case insensitive.

JControllerLegacy::getView($name = '', $type = '', $prefix = '', $config = array())

The JControllerLegacy::getView method returns a reference to current JViewLegacy object associated with the JControllerLegacy instance, or the named JViewLegacy instance which is loaded using JControllerLegacy::createView by reference to the provided, or default values of $name and $prefix which are as follows –

$name – the name of the controller, using JControllerLegacy::getName();

$prefix – the prefix of the view comprising the name of the controller provided by JControllerLegacy::getName() catenated with 'View'.

JControllerLegacy::redirect()

Psuedo code

  1. if a redirection URL has not been assigned to JControllerLegacy::$redirect, return false;
  2. otherwise –
  3. enqueue both a redirection message and message type to the application message queue using JApplicationCms<JApplicationWeb<JApplicationBase::enqueueMessage($message, $type);
  4. execute JApplicationCms<JApplicationWeb<JApplicationBase::redirect($url, $moved [false]) which, in turn –
    1. stores the contents of the application message queue provided by JApplicationCms<JApplicationWeb<JApplicationBase::$_messageQueue to the global JSession object; and
    2. makes a call to JApplicationWeb<JApplicationBase::redirect($url, $moved [false]) which –
      1. converts relative URLs to absolute URL references and performs basic checks on the resultant URL to ensure that it does not violate the HTTP protocol;
      2. if the HTTP protocol headers have been sent to the client or the user agent is Microsoft Internet Explorer (JApplicationWebClient::TRIDENT), injects a redirection script into the output;
      3. otherwise, output a HTTP 1.1 '301 Moved permanently', or a '303 See other' and the relevant URL to the client;
      4. close the application by calling JApplicationBase::close($code [0]) which calls the PHP function exit($code) to terminate the application;
      5. impliedly, by virtue of the call to exit($code), the session_write_close() function is called to serialize the session data to the persistent store.