Source for file interface.php

Documentation is available at interface.php

  1. <?php
  2. /**
  3.  * @package     FrameworkOnFramework
  4.  * @subpackage  platform
  5.  * @copyright   Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  6.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8. // Protect from unauthorized access
  9. defined('_JEXEC'or die;
  10.  
  11. /**
  12.  * Part of the FOF Platform Abstraction Layer. It implements everything that
  13.  * depends on the platform FOF is running under, e.g. the Joomla! CMS front-end,
  14.  * the Joomla! CMS back-end, a CLI Joomla! Platform app, a bespoke Joomla!
  15.  * Platform / Framework web application and so on.
  16.  *
  17.  * This is the abstract class implementing some basic housekeeping functionality
  18.  * and provides the static interface to get the appropriate Platform object for
  19.  * use in the rest of the framework.
  20.  *
  21.  * @package  FrameworkOnFramework
  22.  * @since    2.1
  23.  */
  24. {
  25.     /**
  26.      * Set the error Handling, if possible
  27.      *
  28.      * @param   integer  $level      PHP error level (E_ALL)
  29.      * @param   string   $log_level  What to do with the error (ignore, callback)
  30.      * @param   array    $options    Options for the error handler
  31.      *
  32.      * @return  void 
  33.      */
  34.     public function setErrorHandling($level$log_level$options array());
  35.     /**
  36.      * Returns the ordering of the platform class. Files with a lower ordering
  37.      * number will be loaded first.
  38.      *
  39.      * @return  integer 
  40.      */
  41.     public function getOrdering();
  42.  
  43.     /**
  44.      * Is this platform enabled? This is used for automatic platform detection.
  45.      * If the environment we're currently running in doesn't seem to be your
  46.      * platform return false. If many classes return true, the one with the
  47.      * lowest order will be picked by FOFPlatform.
  48.      *
  49.      * @return  boolean 
  50.      */
  51.     public function isEnabled();
  52.  
  53.     /**
  54.      * Returns the base (root) directories for a given component. The
  55.      * "component" is used in the sense of what we call "component" in Joomla!,
  56.      * "plugin" in WordPress and "module" in Drupal, i.e. an application which
  57.      * is running inside our main application (CMS).
  58.      *
  59.      * The return is a table with the following keys:
  60.      * * main    The normal location of component files. For a back-end Joomla!
  61.      *          component this is the administrator/components/com_example
  62.      *          directory.
  63.      * * alt    The alternate location of component files. For a back-end
  64.      *          Joomla! component this is the front-end directory, e.g.
  65.      *          components/com_example
  66.      * * site    The location of the component files serving the public part of
  67.      *          the application.
  68.      * * admin    The location of the component files serving the administrative
  69.      *          part of the application.
  70.      *
  71.      * All paths MUST be absolute. All four paths MAY be the same if the
  72.      * platform doesn't make a distinction between public and private parts,
  73.      * or when the component does not provide both a public and private part.
  74.      * All of the directories MUST be defined and non-empty.
  75.      *
  76.      * @param   string  $component  The name of the component. For Joomla! this
  77.      *                               is something like "com_example"
  78.      *
  79.      * @return  array  A hash array with keys main, alt, site and admin.
  80.      */
  81.     public function getComponentBaseDirs($component);
  82.  
  83.     /**
  84.      * Return a list of the view template paths for this component. The paths
  85.      * are in the format site:/component_name/view_name/layout_name or
  86.      * admin:/component_name/view_name/layout_name
  87.      *
  88.      * The list of paths returned is a prioritised list. If a file is
  89.      * found in the first path the other paths will not be scanned.
  90.      *
  91.      * @param   string   $component  The name of the component. For Joomla! this
  92.      *                                is something like "com_example"
  93.      * @param   string   $view       The name of the view you're looking a
  94.      *                                template for
  95.      * @param   string   $layout     The layout name to load, e.g. 'default'
  96.      * @param   string   $tpl        The sub-template name to load (null by default)
  97.      * @param   boolean  $strict     If true, only the specified layout will be
  98.      *                                searched for. Otherwise we'll fall back to
  99.      *                                the 'default' layout if the specified layout
  100.      *                                is not found.
  101.      *
  102.      * @return  array 
  103.      */
  104.     public function getViewTemplatePaths($component$view$layout 'default'$tpl null$strict false);
  105.  
  106.     /**
  107.      * Get application-specific suffixes to use with template paths. This allows
  108.      * you to look for view template overrides based on the application version.
  109.      *
  110.      * @return  array  A plain array of suffixes to try in template names
  111.      */
  112.     public function getTemplateSuffixes();
  113.  
  114.     /**
  115.      * Return the absolute path to the application's template overrides
  116.      * directory for a specific component. We will use it to look for template
  117.      * files instead of the regular component directorues. If the application
  118.      * does not have such a thing as template overrides return an empty string.
  119.      *
  120.      * @param   string   $component  The name of the component for which to fetch the overrides
  121.      * @param   boolean  $absolute   Should I return an absolute or relative path?
  122.      *
  123.      * @return  string  The path to the template overrides directory
  124.      */
  125.     public function getTemplateOverridePath($component$absolute true);
  126.  
  127.     /**
  128.      * Load the translation files for a given component. The
  129.      * "component" is used in the sense of what we call "component" in Joomla!,
  130.      * "plugin" in WordPress and "module" in Drupal, i.e. an application which
  131.      * is running inside our main application (CMS).
  132.      *
  133.      * @param   string  $component  The name of the component. For Joomla! this
  134.      *                               is something like "com_example"
  135.      *
  136.      * @return  void 
  137.      */
  138.     public function loadTranslations($component);
  139.  
  140.     /**
  141.      * By default FOF will only use the Controller's onBefore* methods to
  142.      * perform user authorisation. In some cases, like the Joomla! back-end,
  143.      * you alos need to perform component-wide user authorisation in the
  144.      * Dispatcher. This method MUST implement this authorisation check. If you
  145.      * do not need this in your platform, please always return true.
  146.      *
  147.      * @param   string  $component  The name of the component.
  148.      *
  149.      * @return  boolean  True to allow loading the component, false to halt loading
  150.      */
  151.     public function authorizeAdmin($component);
  152.  
  153.     /**
  154.      * This method will try retrieving a variable from the request (input) data.
  155.      * If it doesn't exist it will be loaded from the user state, typically
  156.      * stored in the session. If it doesn't exist there either, the $default
  157.      * value will be used. If $setUserState is set to true, the retrieved
  158.      * variable will be stored in the user session.
  159.      *
  160.      * @param   string    $key           The user state key for the variable
  161.      * @param   string    $request       The request variable name for the variable
  162.      * @param   FOFInput  $input         The FOFInput object with the request (input) data
  163.      * @param   mixed     $default       The default value. Default: null
  164.      * @param   string    $type          The filter type for the variable data. Default: none (no filtering)
  165.      * @param   boolean   $setUserState  Should I set the user state with the fetched value?
  166.      *
  167.      * @return  mixed  The value of the variable
  168.      */
  169.     public function getUserStateFromRequest($key$request$input$default null$type 'none'$setUserState true);
  170.  
  171.     /**
  172.      * Load plugins of a specific type. Obviously this seems to only be required
  173.      * in the Joomla! CMS.
  174.      *
  175.      * @param   string  $type  The type of the plugins to be loaded
  176.      *
  177.      * @return void 
  178.      */
  179.     public function importPlugin($type);
  180.  
  181.     /**
  182.      * Execute plugins (system-level triggers) and fetch back an array with
  183.      * their return values.
  184.      *
  185.      * @param   string  $event  The event (trigger) name, e.g. onBeforeScratchMyEar
  186.      * @param   array   $data   A hash array of data sent to the plugins as part of the trigger
  187.      *
  188.      * @return  array  A simple array containing the resutls of the plugins triggered
  189.      */
  190.     public function runPlugins($event$data);
  191.  
  192.     /**
  193.      * Perform an ACL check. Please note that FOF uses by default the Joomla!
  194.      * CMS convention for ACL privileges, e.g core.edit for the edit privilege.
  195.      * If your platform uses different conventions you'll have to override the
  196.      * FOF defaults using fof.xml or by specialising the controller.
  197.      *
  198.      * @param   string  $action     The ACL privilege to check, e.g. core.edit
  199.      * @param   string  $assetname  The asset name to check, typically the component's name
  200.      *
  201.      * @return  boolean  True if the user is allowed this action
  202.      */
  203.     public function authorise($action$assetname);
  204.  
  205.     /**
  206.      * Returns a user object.
  207.      *
  208.      * @param   integer  $id  The user ID to load. Skip or use null to retrieve
  209.      *                         the object for the currently logged in user.
  210.      *
  211.      * @return  JUser  The JUser object for the specified user
  212.      */
  213.     public function getUser($id null);
  214.  
  215.     /**
  216.      * Returns the JDocument object which handles this component's response. You
  217.      * may also return null and FOF will a. try to figure out the output type by
  218.      * examining the "format" input parameter (or fall back to "html") and b.
  219.      * FOF will not attempt to load CSS and Javascript files (as it doesn't make
  220.      * sense if there's no JDocument to handle them).
  221.      *
  222.      * @return  JDocument 
  223.      */
  224.     public function getDocument();
  225.  
  226.     /**
  227.      * Is this the administrative section of the component?
  228.      *
  229.      * @return  boolean 
  230.      */
  231.     public function isBackend();
  232.  
  233.     /**
  234.      * Is this the public section of the component?
  235.      *
  236.      * @return  boolean 
  237.      */
  238.     public function isFrontend();
  239.  
  240.     /**
  241.      * Is this a component running in a CLI application?
  242.      *
  243.      * @return  boolean 
  244.      */
  245.     public function isCli();
  246.  
  247.     /**
  248.      * Is AJAX re-ordering supported? This is 100% Joomla!-CMS specific. All
  249.      * other platforms should return false and never ask why.
  250.      *
  251.      * @return  boolean 
  252.      */
  253.     public function supportsAjaxOrdering();
  254.  
  255.     /**
  256.      * Performs a check between two versions. Use this function instead of PHP version_compare
  257.      * so we can mock it while testing
  258.      *
  259.      * @param   string  $version1  First version number
  260.      * @param   string  $version2  Second version number
  261.      * @param   string  $operator  Operator (see version_compare for valid operators)
  262.      *
  263.      * @return  boolean 
  264.      */
  265.     public function checkVersion($version1$version2$operator);
  266.  
  267.     /**
  268.      * Saves something to the cache. This is supposed to be used for system-wide
  269.      * FOF data, not application data.
  270.      *
  271.      * @param   string  $key      The key of the data to save
  272.      * @param   string  $content  The actual data to save
  273.      *
  274.      * @return  boolean  True on success
  275.      */
  276.     public function setCache($key$content);
  277.  
  278.     /**
  279.      * Retrieves data from the cache. This is supposed to be used for system-side
  280.      * FOF data, not application data.
  281.      *
  282.      * @param   string  $key      The key of the data to retrieve
  283.      * @param   string  $default  The default value to return if the key is not found or the cache is not populated
  284.      *
  285.      * @return  string  The cached value
  286.      */
  287.     public function getCache($key$default null);
  288.  
  289.     /**
  290.      * Clears the cache of system-wide FOF data. You are supposed to call this in
  291.      * your components' installation script post-installation and post-upgrade
  292.      * methods or whenever you are modifying the structure of database tables
  293.      * accessed by FOF. Please note that FOF's cache never expires and is not
  294.      * purged by Joomla!. You MUST use this method to manually purge the cache.
  295.      *
  296.      * @return  boolean  True on success
  297.      */
  298.     public function clearCache();
  299.  
  300.     /**
  301.      * Is the global FOF cache enabled?
  302.      *
  303.      * @return  boolean 
  304.      */
  305.     public function isGlobalFOFCacheEnabled();
  306.  
  307.     /**
  308.      * logs in a user
  309.      *
  310.      * @param   array  $authInfo  authentification information
  311.      *
  312.      * @return  boolean  True on success
  313.      */
  314.     public function loginUser($authInfo);
  315.  
  316.     /**
  317.      * logs out a user
  318.      *
  319.      * @return  boolean  True on success
  320.      */
  321.     public function logoutUser();
  322.  
  323. }

Documentation generated on Tue, 19 Nov 2013 15:05:49 +0100 by phpDocumentor 1.4.3