diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php
index f9e08c2ac0..97546bf675 100644
--- a/administrator/components/com_admin/script.php
+++ b/administrator/components/com_admin/script.php
@@ -106,7 +106,6 @@ protected function updateManifestCaches()
$extensions[] = array('library', 'phputf8', '', 0);
$extensions[] = array('library', 'joomla', '', 0);
$extensions[] = array('library', 'idna_convert', '', 0);
- $extensions[] = array('library', 'fof', '', 0);
$extensions[] = array('library', 'phpass', '', 0);
// Modules site
@@ -1037,15 +1036,11 @@ public function deleteUnexistingFiles()
* @return void
*
* @since 3.2
+ * @deprecated
*/
protected function clearRadCache()
{
- jimport('joomla.filesystem.file');
- if (JFile::exists(JPATH_CACHE . '/fof/cache.php'))
- {
- JFile::delete(JPATH_CACHE . '/fof/cache.php');
- }
}
/**
diff --git a/administrator/manifests/libraries/fof.xml b/administrator/manifests/libraries/fof.xml
deleted file mode 100644
index 64710502ec..0000000000
--- a/administrator/manifests/libraries/fof.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
- FOF
- fof
- LIB_FOF_XML_DESCRIPTION
- 2014-03-09 12:54:48
- Nicholas K. Dionysopoulos / Akeeba Ltd
- nicholas@akeebabackup.com
- https://www.akeebabackup.com
- (C)2011-2014 Nicholas K. Dionysopoulos
- GNU GPLv2 or later
- 2.2.1
- Akeeba Ltd
- https://www.AkeebaBackup.com/download.html
-
-
- autoloader
- config
- controller
- database
- dispatcher
- encrypt
- form
- hal
- inflector
- integration
- input
- layout
- less
- model
- platform
- query
- render
- string
- table
- template
- toolbar
- utils
- view
-
- LICENSE.txt
- include.php
- index.html
- version.txt
-
-
\ No newline at end of file
diff --git a/build/phpcs/Joomla/ruleset.xml b/build/phpcs/Joomla/ruleset.xml
index 53fbd01296..522ea4e232 100644
--- a/build/phpcs/Joomla/ruleset.xml
+++ b/build/phpcs/Joomla/ruleset.xml
@@ -12,7 +12,6 @@
libraries/compat/password/*
- libraries/fof/*libraries/framework/*libraries/idna_convert/*libraries/phputf8/*
diff --git a/components/com_users/models/profile.php b/components/com_users/models/profile.php
index 1da5d1d53d..05cc651735 100644
--- a/components/com_users/models/profile.php
+++ b/components/com_users/models/profile.php
@@ -24,21 +24,6 @@ class UsersModelProfile extends JModelForm
*/
protected $data;
- public function __construct($config = array())
- {
- parent::__construct($config);
-
- // Load the Joomla! RAD layer
- if (!defined('FOF_INCLUDED'))
- {
- include_once JPATH_LIBRARIES . '/fof/include.php';
- }
-
- // Load the helper and model used for two factor authentication
- require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
- require_once JPATH_ADMINISTRATOR . '/components/com_users/helpers/users.php';
- }
-
/**
* Method to check in a user.
*
diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql
index df2f72942c..01b7a59958 100644
--- a/installation/sql/mysql/joomla.sql
+++ b/installation/sql/mysql/joomla.sql
@@ -308,7 +308,6 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`
(102, 'phputf8', 'library', 'phputf8', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(103, 'Joomla! Platform', 'library', 'joomla', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(104, 'IDNA Convert', 'library', 'idna_convert', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
-(105, 'FOF', 'library', 'fof', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(106, 'PHPass', 'library', 'phpass', '', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(200, 'mod_articles_archive', 'module', 'mod_articles_archive', '', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(201, 'mod_articles_latest', 'module', 'mod_articles_latest', '', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
diff --git a/language/en-GB/en-GB.lib_fof.sys.ini b/language/en-GB/en-GB.lib_fof.sys.ini
deleted file mode 100644
index 7a2ecf9c3e..0000000000
--- a/language/en-GB/en-GB.lib_fof.sys.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-; Joomla! Project
-; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
-; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
-; Note : All ini files need to be saved as UTF-8 - No BOM
-
-LIB_FOF_XML_DESCRIPTION="Framework-on-Framework (FOF) - A rapid component development framework for Joomla!"
diff --git a/language/en-GB/install.xml b/language/en-GB/install.xml
index 5db033420a..cc08dbcd74 100644
--- a/language/en-GB/install.xml
+++ b/language/en-GB/install.xml
@@ -22,7 +22,6 @@
en-GB.files_joomla.sys.inien-GB.finder_cli.inien-GB.ini
- en-GB.lib_fof.sys.inien-GB.lib_idna_convert.sys.inien-GB.lib_joomla.inien-GB.lib_joomla.sys.ini
diff --git a/libraries/cms.php b/libraries/cms.php
index b340b4acd9..78aca8a0dd 100644
--- a/libraries/cms.php
+++ b/libraries/cms.php
@@ -36,12 +36,6 @@
// Register the class aliases for Framework classes that have replaced their Platform equivilents
require_once __DIR__ . '/classmap.php';
-// Ensure FOF autoloader included - needed for things like content versioning where we need to get an FOFTable Instance
-if (!class_exists('FOFAutoloaderFof'))
-{
- include_once JPATH_LIBRARIES . '/fof/include.php';
-}
-
// Register a handler for uncaught exceptions that shows a pretty error page when possible
set_exception_handler(array('JErrorPage', 'render'));
diff --git a/libraries/fof/LICENSE.txt b/libraries/fof/LICENSE.txt
deleted file mode 100644
index 22f3612b03..0000000000
--- a/libraries/fof/LICENSE.txt
+++ /dev/null
@@ -1,347 +0,0 @@
-================================================================================
-Historical note
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-On February 21st, 2013 FOF changed its license to GPLv2 or later (instead of v3
-or later) so that it can be distributed with the Joomla! CMS without causing
-licensing issues.
-================================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
\ No newline at end of file
diff --git a/libraries/fof/autoloader/component.php b/libraries/fof/autoloader/component.php
deleted file mode 100644
index c1d03a872f..0000000000
--- a/libraries/fof/autoloader/component.php
+++ /dev/null
@@ -1,819 +0,0 @@
-getComponentBaseDirs($component);
- $fofComponents[$component] = file_exists($componentPaths['admin'] . '/fof.xml');
- }
-
- return $fofComponents[$component];
- }
-
- /**
- * Creates class aliases. On systems where eval() is enabled it creates a
- * real class. On other systems it merely creates an alias. The eval()
- * method is preferred as class_aliases result in the name of the class
- * being instanciated not being available, making it impossible to create
- * a class instance without passing a $config array :(
- *
- * @param string $original The name of the original (existing) class
- * @param string $alias The name of the new (aliased) class
- * @param boolean $autoload Should I try to autoload the $original class?
- *
- * @return void
- */
- private function class_alias($original, $alias, $autoload = true)
- {
- static $hasEval = null;
-
- if (is_null($hasEval))
- {
- $hasEval = false;
-
- if (function_exists('ini_get'))
- {
- $disabled_functions = ini_get('disabled_functions');
-
- if (!is_string($disabled_functions))
- {
- $hasEval = true;
- }
- else
- {
- $disabled_functions = explode(',', $disabled_functions);
- $hasEval = !in_array('eval', $disabled_functions);
- }
- }
- }
-
- if (!class_exists($original, $autoload))
- {
- return;
- }
-
- if ($hasEval)
- {
- $phpCode = "class $alias extends $original {}";
- eval($phpCode);
- }
- else
- {
- class_alias($original, $alias, $autoload);
- }
- }
-
- /**
- * Autoload Controllers
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_controller($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli) && is_null($isAdmin))
- {
- list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
- }
-
- if (strpos($class_name, 'Controller') === false)
- {
- return;
- }
-
- // Change from camel cased into a lowercase array
- $class_modified = preg_replace('/(\s)+/', '_', $class_name);
- $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
- $parts = explode('_', $class_modified);
-
- // We need three parts in the name
-
- if (count($parts) != 3)
- {
- return;
- }
-
- // We need the second part to be "controller"
-
- if ($parts[1] != 'controller')
- {
- return;
- }
-
- // Get the information about this class
- $component_raw = $parts[0];
- $component = 'com_' . $parts[0];
- $view = $parts[2];
-
- // Is this an FOF 2.1 or later component?
-
- if (!$this->isFOFComponent($component))
- {
- return;
- }
-
- // Get the alternate view and class name (opposite singular/plural name)
- $alt_view = FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view);
- $alt_class = FOFInflector::camelize($component_raw . '_controller_' . $alt_view);
-
- // Get the component's paths
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($component);
-
- // Get the proper and alternate paths and file names
- $file = "/controllers/$view.php";
- $altFile = "/controllers/$alt_view.php";
- $path = $componentPaths['main'];
- $altPath = $componentPaths['alt'];
-
- // Try to find the proper class in the proper path
-
- if (file_exists($path . $file))
- {
- @include_once $path . $file;
- }
-
- // Try to find the proper class in the alternate path
-
- if (!class_exists($class_name) && file_exists($altPath . $file))
- {
- @include_once $altPath . $file;
- }
-
- // Try to find the alternate class in the proper path
-
- if (!class_exists($alt_class) && file_exists($path . $altFile))
- {
- @include_once $path . $altFile;
- }
-
- // Try to find the alternate class in the alternate path
-
- if (!class_exists($alt_class) && file_exists($altPath . $altFile))
- {
- @include_once $altPath . $altFile;
- }
-
- // If the alternate class exists just map the class to the alternate
-
- if (!class_exists($class_name) && class_exists($alt_class))
- {
- $this->class_alias($alt_class, $class_name);
- }
-
- // No class found? Map to FOFController
- elseif (!class_exists($class_name))
- {
- if ($view != 'default')
- {
- $defaultClass = FOFInflector::camelize($component_raw . '_controller_default');
- $this->class_alias($defaultClass, $class_name);
- }
- else
- {
- $this->class_alias('FOFController', $class_name);
- }
- }
- }
-
- /**
- * Autoload Models
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_model($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli) && is_null($isAdmin))
- {
- list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
- }
-
- if (strpos($class_name, 'Model') === false)
- {
- return;
- }
-
- // Change from camel cased into a lowercase array
- $class_modified = preg_replace('/(\s)+/', '_', $class_name);
- $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
- $parts = explode('_', $class_modified);
-
- // We need three parts in the name
-
- if (count($parts) != 3)
- {
- return;
- }
-
- // We need the second part to be "model"
-
- if ($parts[1] != 'model')
- {
- return;
- }
-
- // Get the information about this class
- $component_raw = $parts[0];
- $component = 'com_' . $parts[0];
- $view = $parts[2];
-
- // Is this an FOF 2.1 or later component?
-
- if (!$this->isFOFComponent($component))
- {
- return;
- }
-
- // Get the alternate view and class name (opposite singular/plural name)
- $alt_view = FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view);
- $alt_class = FOFInflector::camelize($component_raw . '_model_' . $alt_view);
-
- // Get the proper and alternate paths and file names
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($component);
-
- $file = "/models/$view.php";
- $altFile = "/models/$alt_view.php";
- $path = $componentPaths['main'];
- $altPath = $componentPaths['alt'];
-
- // Try to find the proper class in the proper path
-
- if (file_exists($path . $file))
- {
- @include_once $path . $file;
- }
-
- // Try to find the proper class in the alternate path
-
- if (!class_exists($class_name) && file_exists($altPath . $file))
- {
- @include_once $altPath . $file;
- }
-
- // Try to find the alternate class in the proper path
-
- if (!class_exists($alt_class) && file_exists($path . $altFile))
- {
- @include_once $path . $altFile;
- }
-
- // Try to find the alternate class in the alternate path
-
- if (!class_exists($alt_class) && file_exists($altPath . $altFile))
- {
- @include_once $altPath . $altFile;
- }
-
- // If the alternate class exists just map the class to the alternate
-
- if (!class_exists($class_name) && class_exists($alt_class))
- {
- $this->class_alias($alt_class, $class_name);
- }
-
- // No class found? Map to FOFModel
- elseif (!class_exists($class_name))
- {
- if ($view != 'default')
- {
- $defaultClass = FOFInflector::camelize($component_raw . '_model_default');
- $this->class_alias($defaultClass, $class_name);
- }
- else
- {
- $this->class_alias('FOFModel', $class_name, true);
- }
- }
- }
-
- /**
- * Autoload Views
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_view($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli) && is_null($isAdmin))
- {
- list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
- }
-
- if (strpos($class_name, 'View') === false)
- {
- return;
- }
-
- // Change from camel cased into a lowercase array
- $class_modified = preg_replace('/(\s)+/', '_', $class_name);
- $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
- $parts = explode('_', $class_modified);
-
- // We need at least three parts in the name
-
- if (count($parts) < 3)
- {
- return;
- }
-
- // We need the second part to be "view"
-
- if ($parts[1] != 'view')
- {
- return;
- }
-
- // Get the information about this class
- $component_raw = $parts[0];
- $component = 'com_' . $parts[0];
- $view = $parts[2];
-
- if (count($parts) > 3)
- {
- $format = $parts[3];
- }
- else
- {
- $input = new FOFInput;
- $format = $input->getCmd('format', 'html', 'cmd');
- }
-
- // Is this an FOF 2.1 or later component?
-
- if (!$this->isFOFComponent($component))
- {
- return;
- }
-
- // Get the alternate view and class name (opposite singular/plural name)
- $alt_view = FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view);
- $alt_class = FOFInflector::camelize($component_raw . '_view_' . $alt_view);
-
- // Get the proper and alternate paths and file names
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($component);
-
- $protoFile = "/models/$view";
- $protoAltFile = "/models/$alt_view";
- $path = $componentPaths['main'];
- $altPath = $componentPaths['alt'];
-
- $formats = array($format);
-
- if ($format != 'html')
- {
- $formats[] = 'raw';
- }
-
- foreach ($formats as $currentFormat)
- {
- $file = $protoFile . '.' . $currentFormat . '.php';
- $altFile = $protoAltFile . '.' . $currentFormat . '.php';
-
- // Try to find the proper class in the proper path
-
- if (!class_exists($class_name) && file_exists($path . $file))
- {
- @include_once $path . $file;
- }
-
- // Try to find the proper class in the alternate path
-
- if (!class_exists($class_name) && file_exists($altPath . $file))
- {
- @include_once $altPath . $file;
- }
-
- // Try to find the alternate class in the proper path
-
- if (!class_exists($alt_class) && file_exists($path . $altFile))
- {
- @include_once $path . $altFile;
- }
-
- // Try to find the alternate class in the alternate path
-
- if (!class_exists($alt_class) && file_exists($altPath . $altFile))
- {
- @include_once $altPath . $altFile;
- }
- }
-
- // If the alternate class exists just map the class to the alternate
-
- if (!class_exists($class_name) && class_exists($alt_class))
- {
- $this->class_alias($alt_class, $class_name);
- }
-
- // No class found? Map to FOFModel
- elseif (!class_exists($class_name))
- {
- if ($view != 'default')
- {
- $defaultClass = FOFInflector::camelize($component_raw . '_view_default');
- $this->class_alias($defaultClass, $class_name);
- }
- else
- {
- if (!file_exists(self::$fofPath . '/view/' . $format . '.php'))
- {
- $default_class = 'FOFView';
- }
- else
- {
- $default_class = 'FOFView' . ucfirst($format);
- }
-
- $this->class_alias($default_class, $class_name, true);
- }
- }
- }
-
- /**
- * Autoload Tables
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_table($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli) && is_null($isAdmin))
- {
- list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
- }
-
- if (strpos($class_name, 'Table') === false)
- {
- return;
- }
-
- // Change from camel cased into a lowercase array
- $class_modified = preg_replace('/(\s)+/', '_', $class_name);
- $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
- $parts = explode('_', $class_modified);
-
- // We need three parts in the name
-
- if (count($parts) != 3)
- {
- return;
- }
-
- // We need the second part to be "model"
-
- if ($parts[1] != 'table')
- {
- return;
- }
-
- // Get the information about this class
- $component_raw = $parts[0];
- $component = 'com_' . $parts[0];
- $view = $parts[2];
-
- // Is this an FOF 2.1 or later component?
-
- if (!$this->isFOFComponent($component))
- {
- return;
- }
-
- // Get the alternate view and class name (opposite singular/plural name)
- $alt_view = FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view);
- $alt_class = FOFInflector::camelize($component_raw . '_table_' . $alt_view);
-
- // Get the proper and alternate paths and file names
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($component);
-
- $file = "/tables/$view.php";
- $altFile = "/tables/$alt_view.php";
- $path = $componentPaths['admin'];
-
- // Try to find the proper class in the proper path
-
- if (file_exists($path . $file))
- {
- @include_once $path . $file;
- }
-
- // Try to find the alternate class in the proper path
-
- if (!class_exists($alt_class) && file_exists($path . $altFile))
- {
- @include_once $path . $altFile;
- }
-
- // If the alternate class exists just map the class to the alternate
-
- if (!class_exists($class_name) && class_exists($alt_class))
- {
- $this->class_alias($alt_class, $class_name);
- }
-
- // No class found? Map to FOFModel
- elseif (!class_exists($class_name))
- {
- if ($view != 'default')
- {
- $defaultClass = FOFInflector::camelize($component_raw . '_table_default');
- $this->class_alias($defaultClass, $class_name);
- }
- else
- {
- $this->class_alias('FOFTable', $class_name, true);
- }
- }
- }
-
- /**
- * Autoload Helpers
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_helper($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli) && is_null($isAdmin))
- {
- list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
- }
-
- if (strpos($class_name, 'Helper') === false)
- {
- return;
- }
-
- // Change from camel cased into a lowercase array
- $class_modified = preg_replace('/(\s)+/', '_', $class_name);
- $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
- $parts = explode('_', $class_modified);
-
- // We need three parts in the name
-
- if (count($parts) != 3)
- {
- return;
- }
-
- // We need the second part to be "model"
-
- if ($parts[1] != 'helper')
- {
- return;
- }
-
- // Get the information about this class
- $component_raw = $parts[0];
- $component = 'com_' . $parts[0];
- $view = $parts[2];
-
- // Is this an FOF 2.1 or later component?
-
- if (!$this->isFOFComponent($component))
- {
- return;
- }
-
- // Get the alternate view and class name (opposite singular/plural name)
- $alt_view = FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view);
- $alt_class = FOFInflector::camelize($component_raw . '_helper_' . $alt_view);
-
- // Get the proper and alternate paths and file names
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($component);
-
- $file = "/helpers/$view.php";
- $altFile = "/helpers/$alt_view.php";
- $path = $componentPaths['main'];
- $altPath = $componentPaths['alt'];
-
- // Try to find the proper class in the proper path
-
- if (file_exists($path . $file))
- {
- @include_once $path . $file;
- }
-
- // Try to find the proper class in the alternate path
-
- if (!class_exists($class_name) && file_exists($altPath . $file))
- {
- @include_once $altPath . $file;
- }
-
- // Try to find the alternate class in the proper path
-
- if (!class_exists($alt_class) && file_exists($path . $altFile))
- {
- @include_once $path . $altFile;
- }
-
- // Try to find the alternate class in the alternate path
-
- if (!class_exists($alt_class) && file_exists($altPath . $altFile))
- {
- @include_once $altPath . $altFile;
- }
-
- // If the alternate class exists just map the class to the alternate
-
- if (!class_exists($class_name) && class_exists($alt_class))
- {
- $this->class_alias($alt_class, $class_name);
- }
- }
-
- /**
- * Autoload Toolbars
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_toolbar($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli) && is_null($isAdmin))
- {
- list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
- }
-
- if (strpos($class_name, 'Toolbar') === false)
- {
- return;
- }
-
- // Change from camel cased into a lowercase array
- $class_modified = preg_replace('/(\s)+/', '_', $class_name);
- $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
- $parts = explode('_', $class_modified);
-
- // We need two parts in the name
-
- if (count($parts) != 2)
- {
- return;
- }
-
- // We need the second part to be "model"
-
- if ($parts[1] != 'toolbar')
- {
- return;
- }
-
- // Get the information about this class
- $component_raw = $parts[0];
- $component = 'com_' . $parts[0];
-
- $platformDirs = FOFPlatform::getInstance()->getPlatformBaseDirs();
-
- // Get the proper and alternate paths and file names
- $file = "/components/$component/toolbar.php";
- $path = ($isAdmin || $isCli) ? $platformDirs['admin'] : $platformDirs['public'];
- $altPath = ($isAdmin || $isCli) ? $platformDirs['public'] : $platformDirs['admin'];
-
- // Try to find the proper class in the proper path
-
- if (file_exists($path . $file))
- {
- @include_once $path . $file;
- }
-
- // Try to find the proper class in the alternate path
-
- if (!class_exists($class_name) && file_exists($altPath . $file))
- {
- @include_once $altPath . $file;
- }
-
- // No class found? Map to FOFToolbar
-
- if (!class_exists($class_name))
- {
- $this->class_alias('FOFToolbar', $class_name, true);
- }
- }
-
- /**
- * Autoload Fields
- *
- * @param string $class_name The name of the class to load
- *
- * @return void
- */
- public function autoload_fof_field($class_name)
- {
- FOFPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading $class_name");
-
- // @todo
- }
-}
diff --git a/libraries/fof/autoloader/fof.php b/libraries/fof/autoloader/fof.php
deleted file mode 100644
index ed8df1c323..0000000000
--- a/libraries/fof/autoloader/fof.php
+++ /dev/null
@@ -1,116 +0,0 @@
-dispatcher;
-
- // Sanity check
-
- if (empty($dispatcherData))
- {
- return;
- }
-
- $options = $xml->xpath('dispatcher/option');
-
- if (!empty($options))
- {
- foreach ($options as $option)
- {
- $key = (string) $option['name'];
- $ret['dispatcher'][$key] = (string) $option;
- }
- }
- }
-
- /**
- * Return a configuration variable
- *
- * @param string &$configuration Configuration variables (hashed array)
- * @param string $var The variable we want to fetch
- * @param mixed $default Default value
- *
- * @return mixed The variable's value
- */
- public function get(&$configuration, $var, $default)
- {
- if (isset($configuration['dispatcher'][$var]))
- {
- return $configuration['dispatcher'][$var];
- }
- else
- {
- return $default;
- }
- }
-}
diff --git a/libraries/fof/config/domain/interface.php b/libraries/fof/config/domain/interface.php
deleted file mode 100644
index 603caeb0b3..0000000000
--- a/libraries/fof/config/domain/interface.php
+++ /dev/null
@@ -1,41 +0,0 @@
-xpath('table');
-
- // Sanity check
- if (empty($tableData))
- {
- return;
- }
-
- foreach ($tableData as $aTable)
- {
- $key = (string) $aTable['name'];
-
- $ret['tables'][$key]['behaviors'] = (string) $aTable->behaviors;
- $ret['tables'][$key]['tablealias'] = $aTable->xpath('tablealias');
- $ret['tables'][$key]['fields'] = array();
- $ret['tables'][$key]['relations'] = array();
-
- $fieldData = $aTable->xpath('field');
-
- if (!empty($fieldData))
- {
- foreach ($fieldData as $field)
- {
- $k = (string) $field['name'];
- $ret['tables'][$key]['fields'][$k] = (string) $field;
- }
- }
-
- $relationsData = $aTable->xpath('relation');
-
- if (!empty($relationsData))
- {
- foreach ($relationsData as $relationData)
- {
- $type = (string)$relationData['type'];
- $itemName = (string)$relationData['name'];
-
- if (empty($type) || empty($itemName))
- {
- continue;
- }
-
- $tableClass = (string)$relationData['tableClass'];
- $localKey = (string)$relationData['localKey'];
- $remoteKey = (string)$relationData['remoteKey'];
- $ourPivotKey = (string)$relationData['ourPivotKey'];
- $theirPivotKey = (string)$relationData['theirPivotKey'];
- $pivotTable = (string)$relationData['pivotTable'];
- $default = (string)$relationData['default'];
-
- $default = !in_array($default, array('no', 'false', 0));
-
- $relation = array(
- 'type' => $type,
- 'itemName' => $itemName,
- 'tableClass' => empty($tableClass) ? null : $tableClass,
- 'localKey' => empty($localKey) ? null : $localKey,
- 'remoteKey' => empty($remoteKey) ? null : $remoteKey,
- 'default' => $default,
- );
-
- if (!empty($ourPivotKey) || !empty($theirPivotKey) || !empty($pivotTable))
- {
- $relation['ourPivotKey'] = empty($ourPivotKey) ? null : $ourPivotKey;
- $relation['theirPivotKey'] = empty($theirPivotKey) ? null : $theirPivotKey;
- $relation['pivotTable'] = empty($pivotTable) ? null : $pivotTable;
- }
-
- $ret['tables'][$key]['relations'][] = $relation;
- }
- }
- }
- }
-
- /**
- * Return a configuration variable
- *
- * @param string &$configuration Configuration variables (hashed array)
- * @param string $var The variable we want to fetch
- * @param mixed $default Default value
- *
- * @return mixed The variable's value
- */
- public function get(&$configuration, $var, $default)
- {
- $parts = explode('.', $var);
-
- $view = $parts[0];
- $method = 'get' . ucfirst($parts[1]);
-
- if (!method_exists($this, $method))
- {
- return $default;
- }
-
- array_shift($parts);
- array_shift($parts);
-
- $ret = $this->$method($view, $configuration, $parts, $default);
-
- return $ret;
- }
-
- /**
- * Internal method to return the magic field mapping
- *
- * @param string $table The table for which we will be fetching a field map
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options; key 0 defines the table we want to fetch
- * @param string $default Default magic field mapping; empty if not defined
- *
- * @return array Field map
- */
- protected function getField($table, &$configuration, $params, $default = '')
- {
- $fieldmap = array();
-
- if (isset($configuration['tables']['*']) && isset($configuration['tables']['*']['fields']))
- {
- $fieldmap = $configuration['tables']['*']['fields'];
- }
-
- if (isset($configuration['tables'][$table]) && isset($configuration['tables'][$table]['fields']))
- {
- $fieldmap = array_merge($fieldmap, $configuration['tables'][$table]['fields']);
- }
-
- $map = $default;
-
- if (empty($params[0]))
- {
- $map = $fieldmap;
- }
- elseif (isset($fieldmap[$params[0]]))
- {
- $map = $fieldmap[$params[0]];
- }
-
- return $map;
- }
-
- /**
- * Internal method to get table alias
- *
- * @param string $table The table for which we will be fetching table alias
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options; key 0 defines the table we want to fetch
- * @param string $default Default table alias
- *
- * @return string Table alias
- */
- protected function getTablealias($table, &$configuration, $params, $default = '')
- {
- $tablealias = $default;
-
- if (isset($configuration['tables']['*'])
- && isset($configuration['tables']['*']['tablealias'])
- && isset($configuration['tables']['*']['tablealias'][0]))
- {
- $tablealias = (string) $configuration['tables']['*']['tablealias'][0];
- }
-
- if (isset($configuration['tables'][$table])
- && isset($configuration['tables'][$table]['tablealias'])
- && isset($configuration['tables'][$table]['tablealias'][0]))
- {
- $tablealias = (string) $configuration['tables'][$table]['tablealias'][0];
- }
-
- return $tablealias;
- }
-
- /**
- * Internal method to get table behaviours
- *
- * @param string $table The table for which we will be fetching table alias
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options; key 0 defines the table we want to fetch
- * @param string $default Default table alias
- *
- * @return string Table behaviours
- */
- protected function getBehaviors($table, &$configuration, $params, $default = '')
- {
- $behaviors = $default;
-
- if (isset($configuration['tables']['*'])
- && isset($configuration['tables']['*']['behaviors']))
- {
- $behaviors = (string) $configuration['tables']['*']['behaviors'];
- }
-
- if (isset($configuration['tables'][$table])
- && isset($configuration['tables'][$table]['behaviors']))
- {
- $behaviors = (string) $configuration['tables'][$table]['behaviors'];
- }
-
- return $behaviors;
- }
-
- /**
- * Internal method to get table relations
- *
- * @param string $table The table for which we will be fetching table alias
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options; key 0 defines the table we want to fetch
- * @param string $default Default table alias
- *
- * @return array Table relations
- */
- protected function getRelations($table, &$configuration, $params, $default = '')
- {
- $relations = $default;
-
- if (isset($configuration['tables']['*'])
- && isset($configuration['tables']['*']['relations']))
- {
- $relations = $configuration['tables']['*']['relations'];
- }
-
- if (isset($configuration['tables'][$table])
- && isset($configuration['tables'][$table]['relations']))
- {
- $relations = $configuration['tables'][$table]['relations'];
- }
-
- return $relations;
- }
-}
diff --git a/libraries/fof/config/domain/views.php b/libraries/fof/config/domain/views.php
deleted file mode 100644
index 2dcd2cd570..0000000000
--- a/libraries/fof/config/domain/views.php
+++ /dev/null
@@ -1,281 +0,0 @@
-xpath('view');
-
- // Sanity check
-
- if (empty($viewData))
- {
- return;
- }
-
- foreach ($viewData as $aView)
- {
- $key = (string) $aView['name'];
-
- // Parse ACL options
- $ret['views'][$key]['acl'] = array();
- $aclData = $aView->xpath('acl/task');
-
- if (!empty($aclData))
- {
- foreach ($aclData as $acl)
- {
- $k = (string) $acl['name'];
- $ret['views'][$key]['acl'][$k] = (string) $acl;
- }
- }
-
- // Parse taskmap
- $ret['views'][$key]['taskmap'] = array();
- $taskmapData = $aView->xpath('taskmap/task');
-
- if (!empty($taskmapData))
- {
- foreach ($taskmapData as $map)
- {
- $k = (string) $map['name'];
- $ret['views'][$key]['taskmap'][$k] = (string) $map;
- }
- }
-
- // Parse controller configuration
- $ret['views'][$key]['config'] = array();
- $optionData = $aView->xpath('config/option');
-
- if (!empty($optionData))
- {
- foreach ($optionData as $option)
- {
- $k = (string) $option['name'];
- $ret['views'][$key]['config'][$k] = (string) $option;
- }
- }
-
- // Parse the toolbar
- $ret['views'][$key]['toolbar'] = array();
- $toolBar = $aView->xpath('toolbar');
-
- if (!empty($toolBar))
- {
- $toolbarAttributes = $toolBar[0]->attributes();
-
- // If a toolbar title is specified, create a title element.
- if (isset($toolbarAttributes['title']))
- {
- $ret['views'][$key]['toolbar']['title'] = array(
- 'value' => (string) $toolbarAttributes['title']
- );
- }
-
- // Parse the toolbar buttons data
- $toolbarData = $aView->xpath('toolbar/button');
-
- if (!empty($toolbarData))
- {
- foreach ($toolbarData as $button)
- {
- $k = (string) $button['type'];
- $ret['views'][$key]['toolbar'][$k] = current($button->attributes());
- $ret['views'][$key]['toolbar'][$k]['value'] = (string) $button;
- }
- }
- }
- }
- }
-
- /**
- * Return a configuration variable
- *
- * @param string &$configuration Configuration variables (hashed array)
- * @param string $var The variable we want to fetch
- * @param mixed $default Default value
- *
- * @return mixed The variable's value
- */
- public function get(&$configuration, $var, $default)
- {
- $parts = explode('.', $var);
-
- $view = $parts[0];
- $method = 'get' . ucfirst($parts[1]);
-
- if (!method_exists($this, $method))
- {
- return $default;
- }
-
- array_shift($parts);
- array_shift($parts);
-
- $ret = $this->$method($view, $configuration, $parts, $default);
-
- return $ret;
- }
-
- /**
- * Internal function to return the task map for a view
- *
- * @param string $view The view for which we will be fetching a task map
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options (not used)
- * @param array $default ßDefault task map; empty array if not provided
- *
- * @return array The task map as a hash array in the format task => method
- */
- protected function getTaskmap($view, &$configuration, $params, $default = array())
- {
- $taskmap = array();
-
- if (isset($configuration['views']['*']) && isset($configuration['views']['*']['taskmap']))
- {
- $taskmap = $configuration['views']['*']['taskmap'];
- }
-
- if (isset($configuration['views'][$view]) && isset($configuration['views'][$view]['taskmap']))
- {
- $taskmap = array_merge($taskmap, $configuration['views'][$view]['taskmap']);
- }
-
- if (empty($taskmap))
- {
- return $default;
- }
-
- return $taskmap;
- }
-
- /**
- * Internal method to return the ACL mapping (privilege required to access
- * a specific task) for the given view's tasks
- *
- * @param string $view The view for which we will be fetching a task map
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options; key 0 defines the task we want to fetch
- * @param string $default Default ACL option; empty (no ACL check) if not defined
- *
- * @return string The privilege required to access this view
- */
- protected function getAcl($view, &$configuration, $params, $default = '')
- {
- $aclmap = array();
-
- if (isset($configuration['views']['*']) && isset($configuration['views']['*']['acl']))
- {
- $aclmap = $configuration['views']['*']['acl'];
- }
-
- if (isset($configuration['views'][$view]) && isset($configuration['views'][$view]['acl']))
- {
- $aclmap = array_merge($aclmap, $configuration['views'][$view]['acl']);
- }
-
- $acl = $default;
-
- if (isset($aclmap['*']))
- {
- $acl = $aclmap['*'];
- }
-
- if (isset($aclmap[$params[0]]))
- {
- $acl = $aclmap[$params[0]];
- }
-
- return $acl;
- }
-
- /**
- * Internal method to return the a configuration option for the view. These
- * are equivalent to $config array options passed to the Controller
- *
- * @param string $view The view for which we will be fetching a task map
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options; key 0 defines the option variable we want to fetch
- * @param mixed $default Default option; null if not defined
- *
- * @return string The setting for the requested option
- */
- protected function getConfig($view, &$configuration, $params, $default = null)
- {
- $ret = $default;
-
- if (isset($configuration['views']['*'])
- && isset($configuration['views']['*']['config'])
- && isset($configuration['views']['*']['config'][$params[0]]))
- {
- $ret = $configuration['views']['*']['config'][$params[0]];
- }
-
- if (isset($configuration['views'][$view])
- && isset($configuration['views'][$view]['config'])
- && isset($configuration['views'][$view]['config'][$params[0]]))
- {
- $ret = $configuration['views'][$view]['config'][$params[0]];
- }
-
- return $ret;
- }
-
- /**
- * Internal method to return the toolbar infos.
- *
- * @param string $view The view for which we will be fetching buttons
- * @param array &$configuration The configuration parameters hash array
- * @param array $params Extra options
- * @param string $default Default option
- *
- * @return string The toolbar data for this view
- */
- protected function getToolbar($view, &$configuration, $params, $default = '')
- {
- $toolbar = array();
-
- if (isset($configuration['views']['*']) && isset($configuration['views']['*']['toolbar']))
- {
- $toolbar = $configuration['views']['*']['toolbar'];
- }
-
- if (isset($configuration['views'][$view]) && isset($configuration['views'][$view]['toolbar']))
- {
- $toolbar = array_merge($toolbar, $configuration['views'][$view]['toolbar']);
- }
-
- if (empty($toolbar))
- {
- return $default;
- }
-
- return $toolbar;
- }
-}
diff --git a/libraries/fof/config/provider.php b/libraries/fof/config/provider.php
deleted file mode 100644
index 9f9a8a5541..0000000000
--- a/libraries/fof/config/provider.php
+++ /dev/null
@@ -1,212 +0,0 @@
-isCli())
- {
- $order = array('cli', 'backend');
- }
- elseif (FOFPlatform::getInstance()->isBackend())
- {
- $order = array('backend');
- }
- else
- {
- $order = array('frontend');
- }
-
- $order[] = 'common';
-
- $order = array_reverse($order);
- self::$configurations[$component] = array();
-
- foreach ($order as $area)
- {
- $config = $this->parseComponentArea($component, $area);
- self::$configurations[$component] = array_merge_recursive(self::$configurations[$component], $config);
- }
- }
-
- /**
- * Returns the value of a variable. Variables use a dot notation, e.g.
- * view.config.whatever where the first part is the domain, the rest of the
- * parts specify the path to the variable.
- *
- * @param string $variable The variable name
- * @param mixed $default The default value, or null if not specified
- *
- * @return mixed The value of the variable
- */
- public function get($variable, $default = null)
- {
- static $domains = null;
-
- if (is_null($domains))
- {
- $domains = $this->getDomains();
- }
-
- list($component, $domain, $var) = explode('.', $variable, 3);
-
- if (!isset(self::$configurations[$component]))
- {
- $this->parseComponent($component);
- }
-
- if (!in_array($domain, $domains))
- {
- return $default;
- }
-
- $class = 'FOFConfigDomain' . ucfirst($domain);
- $o = new $class;
-
- return $o->get(self::$configurations[$component], $var, $default);
- }
-
- /**
- * Parses the configuration options of a specific component area
- *
- * @param string $component Which component's cionfiguration to parse
- * @param string $area Which area to parse (frontend, backend, cli)
- *
- * @return array A hash array with the configuration data
- */
- protected function parseComponentArea($component, $area)
- {
- // Initialise the return array
- $ret = array();
-
- // Get the folders of the component
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($component);
- $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
-
- // Check that the path exists
- $path = $componentPaths['admin'];
- $path = $filesystem->pathCheck($path);
-
- if (!$filesystem->folderExists($path))
- {
- return $ret;
- }
-
- // Read the filename if it exists
- $filename = $path . '/fof.xml';
-
- if (!$filesystem->fileExists($filename))
- {
- return $ret;
- }
-
- $data = file_get_contents($filename);
-
- // Load the XML data in a SimpleXMLElement object
- $xml = simplexml_load_string($data);
-
- if (!($xml instanceof SimpleXMLElement))
- {
- return $ret;
- }
-
- // Get this area's data
- $areaData = $xml->xpath('//' . $area);
-
- if (empty($areaData))
- {
- return $ret;
- }
-
- $xml = array_shift($areaData);
-
- // Parse individual configuration domains
- $domains = $this->getDomains();
-
- foreach ($domains as $dom)
- {
- $class = 'FOFConfigDomain' . ucfirst($dom);
-
- if (class_exists($class, true))
- {
- $o = new $class;
- $o->parseDomain($xml, $ret);
- }
- }
-
- // Finally, return the result
- return $ret;
- }
-
- /**
- * Gets a list of the available configuration domain adapters
- *
- * @return array A list of the available domains
- */
- protected function getDomains()
- {
- static $domains = array();
-
- if (empty($domains))
- {
- $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
-
- $files = $filesystem->folderFiles(__DIR__ . '/domain', '.php');
-
- if (!empty($files))
- {
- foreach ($files as $file)
- {
- $domain = basename($file, '.php');
-
- if ($domain == 'interface')
- {
- continue;
- }
-
- $domain = preg_replace('/[^A-Za-z0-9]/', '', $domain);
- $domains[] = $domain;
- }
-
- $domains = array_unique($domains);
- }
- }
-
- return $domains;
- }
-}
diff --git a/libraries/fof/controller/controller.php b/libraries/fof/controller/controller.php
deleted file mode 100644
index 7b7b211a50..0000000000
--- a/libraries/fof/controller/controller.php
+++ /dev/null
@@ -1,3313 +0,0 @@
-getCmd('option', 'com_foobar');
- $config['view'] = !is_null($view) ? $view : $input->getCmd('view', 'cpanel');
-
- // Get the class base name, e.g. FoobarController
- $classBaseName = ucfirst(str_replace('com_', '', $config['option'])) . 'Controller';
-
- // Get the class name suffixes, in the order to be searched for: plural, singular, 'default'
- $classSuffixes = array(
- FOFInflector::pluralize($config['view']),
- FOFInflector::singularize($config['view']),
- 'default'
- );
-
- // Get the path names for the component
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
- $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
-
- // Look for the best classname match
- foreach ($classSuffixes as $suffix)
- {
- $className = $classBaseName . ucfirst($suffix);
-
- if (class_exists($className))
- {
- // The class is already loaded. We have a match!
- break;
- }
-
- // The class is not already loaded. Try to find and load it.
- $searchPaths = array(
- $componentPaths['main'] . '/controllers',
- $componentPaths['admin'] . '/controllers'
- );
-
- // If we have a searchpath in the configuration please search it first
-
- if (array_key_exists('searchpath', $config))
- {
- array_unshift($searchPaths, $config['searchpath']);
- }
- else
- {
- $configProvider = new FOFConfigProvider;
- $searchPath = $configProvider->get($config['option'] . '.views.' . FOFInflector::singularize($config['view']) . '.config.searchpath', null);
-
- if ($searchPath)
- {
- array_unshift($searchPaths, $componentPaths['admin'] . '/' . $searchPath);
- array_unshift($searchPaths, $componentPaths['main'] . '/' . $searchPath);
- }
- }
-
- /**
- * Try to find the path to this file. First try to find the
- * format-specific controller file, e.g. foobar.json.php for
- * format=json, then the regular one-size-fits-all controller
- */
-
- $format = $input->getCmd('format', 'html');
- $path = null;
-
- if (!empty($format))
- {
- $path = $filesystem->pathFind(
- $searchPaths, strtolower($suffix) . '.' . strtolower($format) . '.php'
- );
- }
-
- if (!$path)
- {
- $path = $filesystem->pathFind(
- $searchPaths, strtolower($suffix) . '.php'
- );
- }
-
- // The path is found. Load the file and make sure the expected class name exists.
-
- if ($path)
- {
- require_once $path;
-
- if (class_exists($className))
- {
- // The class was loaded successfully. We have a match!
- break;
- }
- }
- }
-
- if (!class_exists($className))
- {
- // If no specialised class is found, instantiate the generic FOFController
- $className = 'FOFController';
- }
-
- $instance = new $className($config);
-
- return $instance;
- }
-
- /**
- * Public constructor of the Controller class
- *
- * @param array $config Optional configuration parameters
- */
- public function __construct($config = array())
- {
- // Make sure $config is an array
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config))
- {
- $config = array();
- }
-
- $this->methods = array();
- $this->message = null;
- $this->messageType = 'message';
- $this->paths = array();
- $this->redirect = null;
- $this->taskMap = array();
-
- // Cache the config
- $this->config = $config;
-
- // Get the input for this MVC triad
-
- if (array_key_exists('input', $config))
- {
- $input = $config['input'];
- }
- else
- {
- $input = null;
- }
-
- if (array_key_exists('input_options', $config))
- {
- $input_options = $config['input_options'];
- }
- else
- {
- $input_options = array();
- }
-
- if ($input instanceof FOFInput)
- {
- $this->input = $input;
- }
- else
- {
- $this->input = new FOFInput($input, $input_options);
- }
-
- // Load the configuration provider
- $this->configProvider = new FOFConfigProvider;
-
- // Determine the methods to exclude from the base class.
- $xMethods = get_class_methods('FOFController');
-
- // Some methods must always be considered valid tasks
- $iMethods = array('accesspublic', 'accessregistered', 'accessspecial',
- 'add', 'apply', 'browse', 'cancel', 'copy', 'edit', 'orderdown',
- 'orderup', 'publish', 'read', 'remove', 'save', 'savenew',
- 'saveorder', 'unpublish', 'display', 'archive', 'trash');
-
- // Get the public methods in this class using reflection.
- $r = new ReflectionClass($this);
- $rMethods = $r->getMethods(ReflectionMethod::IS_PUBLIC);
-
- foreach ($rMethods as $rMethod)
- {
- $mName = $rMethod->getName();
-
- // Add default display method if not explicitly declared.
- if (!in_array($mName, $xMethods) || in_array($mName, $iMethods))
- {
- $this->methods[] = strtolower($mName);
-
- // Auto register the methods as tasks.
- $this->taskMap[strtolower($mName)] = $mName;
- }
- }
-
- // Get the default values for the component and view names
- $classNameParts = FOFInflector::explode(get_class($this));
-
- if (count($classNameParts) == 3)
- {
- $defComponent = "com_" . $classNameParts[0];
- $defView = $classNameParts[2];
- }
- else
- {
- $defComponent = 'com_foobar';
- $defView = 'cpanel';
- }
-
- $this->component = $this->input->get('option', $defComponent, 'cmd');
- $this->view = $this->input->get('view', $defView, 'cmd');
- $this->layout = $this->input->get('layout', null, 'cmd');
-
- // Overrides from the config
- if (array_key_exists('option', $config))
- {
- $this->component = $config['option'];
- }
-
- if (array_key_exists('view', $config))
- {
- $this->view = $config['view'];
- }
-
- if (array_key_exists('layout', $config))
- {
- $this->layout = $config['layout'];
- }
-
- $this->layout = $this->configProvider->get($this->component . '.views.' . FOFInflector::singularize($this->view) . '.config.layout', $this->layout);
-
- $this->input->set('option', $this->component);
-
- // Set the bareComponent variable
- $this->bareComponent = str_replace('com_', '', strtolower($this->component));
-
- // Set the $name variable
- $this->name = $this->bareComponent;
-
- // Set the basePath variable
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($this->component);
- $basePath = $componentPaths['main'];
-
- if (array_key_exists('base_path', $config))
- {
- $basePath = $config['base_path'];
- }
-
- $altBasePath = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.base_path', null
- );
-
- if (!is_null($altBasePath))
- {
- $platformDirs = FOFPlatform::getInstance()->getPlatformBaseDirs();
- $basePath = $platformDirs['public'] . '/' . $altBasePath;
- }
-
- $this->basePath = $basePath;
-
- // If the default task is set, register it as such
- $defaultTask = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.default_task', 'display'
- );
-
- if (array_key_exists('default_task', $config))
- {
- $this->registerDefaultTask($config['default_task']);
- }
- else
- {
- $this->registerDefaultTask($defaultTask);
- }
-
- // Set the models prefix
-
- if (empty($this->model_prefix))
- {
- if (array_key_exists('model_prefix', $config))
- {
- // User-defined prefix
- $this->model_prefix = $config['model_prefix'];
- }
- else
- {
- $this->model_prefix = $this->name . 'Model';
- $this->model_prefix = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.model_prefix', $this->model_prefix
- );
- }
- }
-
- // Set the default model search path
-
- if (array_key_exists('model_path', $config))
- {
- // User-defined dirs
- $this->addModelPath($config['model_path'], $this->model_prefix);
- }
- else
- {
- $modelPath = $this->basePath . '/models';
- $altModelPath = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.model_path', null
- );
-
- if (!is_null($altModelPath))
- {
- $modelPath = $this->basePath . '/' . $altModelPath;
- }
-
- $this->addModelPath($modelPath, $this->model_prefix);
- }
-
- // Set the default view search path
-
- if (array_key_exists('view_path', $config))
- {
- // User-defined dirs
- $this->setPath('view', $config['view_path']);
- }
- else
- {
- $viewPath = $this->basePath . '/views';
- $altViewPath = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.view_path', null
- );
-
- if (!is_null($altViewPath))
- {
- $viewPath = $this->basePath . '/' . $altViewPath;
- }
-
- $this->setPath('view', $viewPath);
- }
-
- // Set the default view.
-
- if (array_key_exists('default_view', $config))
- {
- $this->default_view = $config['default_view'];
- }
- else
- {
- if (empty($this->default_view))
- {
- $this->default_view = $this->getName();
- }
-
- $this->default_view = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.default_view', $this->default_view
- );
- }
-
- // Set the CSRF protection
-
- if (array_key_exists('csrf_protection', $config))
- {
- $this->csrfProtection = $config['csrf_protection'];
- }
-
- $this->csrfProtection = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.csrf_protection', $this->csrfProtection
- );
-
- // Set any model/view name overrides
-
- if (array_key_exists('viewName', $config))
- {
- $this->setThisViewName($config['viewName']);
- }
- else
- {
- $overrideViewName = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.viewName', null
- );
-
- if ($overrideViewName)
- {
- $this->setThisViewName($overrideViewName);
- }
- }
-
- if (array_key_exists('modelName', $config))
- {
- $this->setThisModelName($config['modelName']);
- }
- else
- {
- $overrideModelName = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.modelName', null
- );
-
- if ($overrideModelName)
- {
- $this->setThisModelName($overrideModelName);
- }
- }
-
- // Caching
-
- if (array_key_exists('cacheableTasks', $config))
- {
- if (is_array($config['cacheableTasks']))
- {
- $this->cacheableTasks = $config['cacheableTasks'];
- }
- }
- else
- {
- $cacheableTasks = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.cacheableTasks', null
- );
-
- if ($cacheableTasks)
- {
- $cacheableTasks = explode(',', $cacheableTasks);
-
- if (count($cacheableTasks))
- {
- $temp = array();
-
- foreach ($cacheableTasks as $t)
- {
- $temp[] = trim($t);
- }
-
- $temp = array_unique($temp);
- $this->cacheableTasks = $temp;
- }
- }
- }
-
- // Bit mask for auto routing on setRedirect
- $this->autoRouting = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.config.autoRouting', $this->autoRouting
- );
-
- if (array_key_exists('autoRouting', $config))
- {
- $this->autoRouting = $config['autoRouting'];
- }
-
- // Apply task map
- $taskmap = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.taskmap'
- );
-
- if (is_array($taskmap) && !empty($taskmap))
- {
- foreach ($taskmap as $aliasedtask => $realmethod)
- {
- $this->registerTask($aliasedtask, $realmethod);
- }
- }
- }
-
- /**
- * Adds to the stack of model paths in LIFO order.
- *
- * @param mixed $path The directory (string) , or list of directories (array) to add.
- * @param string $prefix A prefix for models
- *
- * @return void
- */
- public static function addModelPath($path, $prefix = '')
- {
- FOFModel::addIncludePath($path, $prefix);
- }
-
- /**
- * Adds to the search path for templates and resources.
- *
- * @param string $type The path type (e.g. 'model', 'view').
- * @param mixed $path The directory string or stream array to search.
- *
- * @return FOFController A FOFController object to support chaining.
- */
- protected function addPath($type, $path)
- {
- // Just force path to array
- settype($path, 'array');
-
- $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
-
- if (!isset($this->paths[$type]))
- {
- $this->paths[$type] = array();
- }
-
- // Loop through the path directories
- foreach ($path as $dir)
- {
- // No surrounding spaces allowed!
- $dir = rtrim($filesystem->pathCheck($dir, '/'), '/') . '/';
-
- // Add to the top of the search dirs
- array_unshift($this->paths[$type], $dir);
- }
-
- return $this;
- }
-
- /**
- * Add one or more view paths to the controller's stack, in LIFO order.
- *
- * @param mixed $path The directory (string) or list of directories (array) to add.
- *
- * @return FOFController This object to support chaining.
- */
- public function addViewPath($path)
- {
- $this->addPath('view', $path);
-
- return $this;
- }
-
- /**
- * Authorisation check
- *
- * @param string $task The ACO Section Value to check access on.
- *
- * @return boolean True if authorised
- *
- * @deprecated 2.0 Use JAccess instead.
- */
- public function authorise($task)
- {
- FOFPlatform::getInstance()->logDeprecated(__CLASS__ . '::' .__METHOD__ . ' is deprecated. Use checkACL() instead.');
-
- return true;
- }
-
- /**
- * Create the filename for a resource.
- *
- * @param string $type The resource type to create the filename for.
- * @param array $parts An associative array of filename information. Optional.
- *
- * @return string The filename.
- */
- protected static function createFileName($type, $parts = array())
- {
- $filename = '';
-
- switch ($type)
- {
- case 'controller':
- if (!empty($parts['format']))
- {
- if ($parts['format'] == 'html')
- {
- $parts['format'] = '';
- }
- else
- {
- $parts['format'] = '.' . $parts['format'];
- }
- }
- else
- {
- $parts['format'] = '';
- }
-
- $filename = strtolower($parts['name'] . $parts['format'] . '.php');
- break;
-
- case 'view':
- if (!empty($parts['type']))
- {
- $parts['type'] = '.' . $parts['type'];
- }
- else
- {
- $parts['type'] = '';
- }
-
- $filename = strtolower($parts['name'] . '/view' . $parts['type'] . '.php');
- break;
- }
-
- return $filename;
- }
-
- /**
- * Executes a given controller task. The onBefore and onAfter
- * methods are called automatically if they exist.
- *
- * @param string $task The task to execute, e.g. "browse"
- *
- * @throws Exception Exception thrown if the onBefore returns false
- *
- * @return null|bool False on execution failure
- */
- public function execute($task)
- {
- $this->task = $task;
-
- $method_name = 'onBefore' . ucfirst($task);
-
- if (!method_exists($this, $method_name))
- {
- $result = $this->onBeforeGenericTask($task);
- }
- elseif (method_exists($this, $method_name))
- {
- $result = $this->$method_name();
- }
- else
- {
- $result = true;
- }
-
- if ($result)
- {
- $plugin_event = FOFInflector::camelize('on before ' . $this->bareComponent . ' controller ' . $this->view . ' ' . $task);
- $plugin_result = FOFPlatform::getInstance()->runPlugins($plugin_event, array(&$this, &$this->input));
-
- if (in_array(false, $plugin_result, true))
- {
- $result = false;
- }
- }
-
- if (!$result)
- {
- throw new Exception(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
- }
-
- // Do not allow the display task to be directly called
- $task = strtolower($task);
-
- if (isset($this->taskMap[$task]))
- {
- $doTask = $this->taskMap[$task];
- }
- elseif (isset($this->taskMap['__default']))
- {
- $doTask = $this->taskMap['__default'];
- }
- else
- {
- $doTask = null;
- }
-
- if ($doTask == 'display')
- {
- FOFPlatform::getInstance()->setHeader('Status', '400 Bad Request', true);
-
- throw new Exception('Bad Request', 400);
- }
-
- $this->doTask = $doTask;
-
- $ret = $this->$doTask();
-
- $method_name = 'onAfter' . ucfirst($task);
-
- if (method_exists($this, $method_name))
- {
- $result = $this->$method_name();
- }
- else
- {
- $result = true;
- }
-
- if ($result)
- {
- $plugin_event = FOFInflector::camelize('on after ' . $this->bareComponent . ' controller ' . $this->view . ' ' . $task);
- $plugin_result = FOFPlatform::getInstance()->runPlugins($plugin_event, array(&$this, &$this->input, &$ret));
-
- if (in_array(false, $plugin_result, true))
- {
- $result = false;
- }
- }
-
- if (!$result)
- {
- throw new Exception(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
- }
-
- return $ret;
- }
-
- /**
- * Default task. Assigns a model to the view and asks the view to render
- * itself.
- *
- * YOU MUST NOT USETHIS TASK DIRECTLY IN A URL. It is supposed to be
- * used ONLY inside your code. In the URL, use task=browse instead.
- *
- * @param bool $cachable Is this view cacheable?
- * @param bool $urlparams Add your safe URL parameters (see further down in the code)
- *
- * @return bool
- */
- public function display($cachable = false, $urlparams = false)
- {
- $document = FOFPlatform::getInstance()->getDocument();
-
- if ($document instanceof JDocument)
- {
- $viewType = $document->getType();
- }
- else
- {
- $viewType = $this->input->getCmd('format', 'html');
- }
-
- $view = $this->getThisView();
-
- // Get/Create the model
-
- if ($model = $this->getThisModel())
- {
- // Push the model into the view (as default)
- $view->setModel($model, true);
- }
-
- // Set the layout
- $view->setLayout(is_null($this->layout) ? 'default' : $this->layout);
-
- // Display the view
- $conf = FOFPlatform::getInstance()->getConfig();
-
- if (FOFPlatform::getInstance()->isFrontend() && $cachable && ($viewType != 'feed') && $conf->get('caching') >= 1)
- {
- // Get a JCache object
- $option = $this->input->get('option', 'com_foobar', 'cmd');
- $cache = JFactory::getCache($option, 'view');
-
- // Set up a cache ID based on component, view, task and user group assignment
- $user = FOFPlatform::getInstance()->getUser();
-
- if ($user->guest)
- {
- $groups = array();
- }
- else
- {
- $groups = $user->groups;
- }
-
- // Set up safe URL parameters
-
- if (!is_array($urlparams))
- {
- $urlparams = array(
- 'option' => 'CMD',
- 'view' => 'CMD',
- 'task' => 'CMD',
- 'format' => 'CMD',
- 'layout' => 'CMD',
- 'id' => 'INT',
- );
- }
-
- if (is_array($urlparams))
- {
- $app = JFactory::getApplication();
-
- $registeredurlparams = null;
-
- if (version_compare(JVERSION, '3.0', 'ge'))
- {
- if (property_exists($app, 'registeredurlparams'))
- {
- $registeredurlparams = $app->registeredurlparams;
- }
- }
- else
- {
- $registeredurlparams = $app->get('registeredurlparams');
- }
-
- if (empty($registeredurlparams))
- {
- $registeredurlparams = new stdClass;
- }
-
- foreach ($urlparams AS $key => $value)
- {
- // Add your safe url parameters with variable type as value {@see JFilterInput::clean()}.
- $registeredurlparams->$key = $value;
- }
-
- if (version_compare(JVERSION, '3.0', 'ge'))
- {
- $app->registeredurlparams = $registeredurlparams;
- }
- else
- {
- $app->set('registeredurlparams', $registeredurlparams);
- }
- }
-
- // Create the cache ID after setting the registered URL params, as they are used to generate the ID
- $cacheId = md5(serialize(array(JCache::makeId(), $view->getName(), $this->doTask, $groups)));
-
- // Get the cached view or cache the current view
- $cache->get($view, 'display', $cacheId);
- }
- else
- {
- // Display without caching
- $view->display();
- }
-
- return true;
- }
-
- /**
- * Implements a default browse task, i.e. read a bunch of records and send
- * them to the browser.
- *
- * @return boolean
- */
- public function browse()
- {
- if ($this->input->get('savestate', -999, 'int') == -999)
- {
- $this->input->set('savestate', true);
- }
-
- // Do I have a form?
- $model = $this->getThisModel();
-
- if (empty($this->layout))
- {
- $formname = 'form.default';
- }
- else
- {
- $formname = 'form.' . $this->layout;
- }
-
- $model->setState('form_name', $formname);
-
- $form = $model->getForm();
-
- if ($form !== false)
- {
- $this->hasForm = true;
- }
-
- $this->display(in_array('browse', $this->cacheableTasks));
-
- return true;
- }
-
- /**
- * Single record read. The id set in the request is passed to the model and
- * then the item layout is used to render the result.
- *
- * @return bool
- */
- public function read()
- {
- // Load the model
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- // Set the layout to item, if it's not set in the URL
-
- if (is_null($this->layout))
- {
- $this->layout = 'item';
- }
-
- // Do I have a form?
- $model->setState('form_name', 'form.' . $this->layout);
-
- $item = $model->getItem();
-
- if (!($item instanceof FOFTable))
- {
- return false;
- }
-
- $itemKey = $item->getKeyName();
-
- if ($item->$itemKey != $model->getId())
- {
- return false;
- }
-
- $formData = is_object($item) ? $item->getData() : array();
- $form = $model->getForm($formData);
-
- if ($form !== false)
- {
- $this->hasForm = true;
- }
-
- // Display
- $this->display(in_array('read', $this->cacheableTasks));
-
- return true;
- }
-
- /**
- * Single record add. The form layout is used to present a blank page.
- *
- * @return false|void
- */
- public function add()
- {
- // Load and reset the model
- $model = $this->getThisModel();
- $model->reset();
-
- // Set the layout to form, if it's not set in the URL
-
- if (is_null($this->layout))
- {
- $this->layout = 'form';
- }
-
- // Do I have a form?
- $model->setState('form_name', 'form.' . $this->layout);
-
- $item = $model->getItem();
-
- if (!($item instanceof FOFTable))
- {
- return false;
- }
-
- $formData = is_object($item) ? $item->getData() : array();
- $form = $model->getForm($formData);
-
- if ($form !== false)
- {
- $this->hasForm = true;
- }
-
- // Display
- $this->display(in_array('add', $this->cacheableTasks));
- }
-
- /**
- * Single record edit. The ID set in the request is passed to the model,
- * then the form layout is used to edit the result.
- *
- * @return bool
- */
- public function edit()
- {
- // Load the model
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $status = $model->checkout();
-
- if (!$status)
- {
- // Redirect on error
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
- $this->setRedirect($url, $model->getError(), 'error');
-
- return false;
- }
-
- // Set the layout to form, if it's not set in the URL
-
- if (is_null($this->layout))
- {
- $this->layout = 'form';
- }
-
- // Do I have a form?
- $model->setState('form_name', 'form.' . $this->layout);
-
- $item = $model->getItem();
-
- if (!($item instanceof FOFTable))
- {
- return false;
- }
-
- $itemKey = $item->getKeyName();
-
- if ($item->$itemKey != $model->getId())
- {
- return false;
- }
-
- $formData = is_object($item) ? $item->getData() : array();
- $form = $model->getForm($formData);
-
- if ($form !== false)
- {
- $this->hasForm = true;
- }
-
- // Display
- $this->display(in_array('edit', $this->cacheableTasks));
-
- return true;
- }
-
- /**
- * Save the incoming data and then return to the Edit task
- *
- * @return bool
- */
- public function apply()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $model = $this->getThisModel();
- $result = $this->applySave();
-
- // Redirect to the edit task
-
- if ($result)
- {
- $id = $this->input->get('id', 0, 'int');
- $textkey = strtoupper($this->component) . '_LBL_' . strtoupper($this->view) . '_SAVED';
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . $this->view . '&task=edit&id=' . $id . $this->getItemidURLSuffix();
- $this->setRedirect($url, JText::_($textkey));
- }
-
- return $result;
- }
-
- /**
- * Duplicates selected items
- *
- * @return bool
- */
- public function copy()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $status = $model->copy();
-
- // Redirect
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
-
- if (!$status)
- {
- $this->setRedirect($url, $model->getError(), 'error');
-
- return false;
- }
- else
- {
- FOFPlatform::getInstance()->setHeader('Status', '201 Created', true);
- $this->setRedirect($url);
-
- return true;
- }
- }
-
- /**
- * Save the incoming data and then return to the Browse task
- *
- * @return bool
- */
- public function save()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $result = $this->applySave();
-
- // Redirect to the display task
-
- if ($result)
- {
- $textkey = strtoupper($this->component) . '_LBL_' . strtoupper($this->view) . '_SAVED';
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
- $this->setRedirect($url, JText::_($textkey));
- }
-
- return $result;
- }
-
- /**
- * Save the incoming data and then return to the Add task
- *
- * @return bool
- */
- public function savenew()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $result = $this->applySave();
-
- // Redirect to the display task
-
- if ($result)
- {
- $textkey = strtoupper($this->component) . '_LBL_' . strtoupper($this->view) . '_SAVED';
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . $this->view . '&task=add' . $this->getItemidURLSuffix();
- $this->setRedirect($url, JText::_($textkey));
- }
-
- return $result;
- }
-
- /**
- * Cancel the edit, check in the record and return to the Browse task
- *
- * @return bool
- */
- public function cancel()
- {
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $model->checkin();
-
- // Remove any saved data
- JFactory::getSession()->set($model->getHash() . 'savedata', null);
-
- // Redirect to the display task
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
- $this->setRedirect($url);
-
- return true;
- }
-
- /**
- * Sets the access to public. Joomla! 1.5 compatibility.
- *
- * @return bool
- *
- * @deprecated since 2.0
- */
- public function accesspublic()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setaccess(0);
- }
-
- /**
- * Sets the access to registered. Joomla! 1.5 compatibility.
- *
- * @return bool
- *
- * @deprecated since 2.0
- */
- public function accessregistered()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setaccess(1);
- }
-
- /**
- * Sets the access to special. Joomla! 1.5 compatibility.
- *
- * @return bool
- *
- * @deprecated since 2.0
- */
- public function accessspecial()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setaccess(2);
- }
-
- /**
- * Publish (set enabled = 1) an item.
- *
- * @return bool
- */
- public function publish()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setstate(1);
- }
-
- /**
- * Unpublish (set enabled = 0) an item.
- *
- * @return bool
- */
- public function unpublish()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setstate(0);
- }
-
- /**
- * Archive (set enabled = 2) an item.
- *
- * @return bool
- */
- public function archive()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setstate(2);
- }
-
- /**
- * Trash (set enabled = -2) an item.
- *
- * @return bool
- */
- public function trash()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- return $this->setstate(-2);
- }
-
- /**
- * Saves the order of the items
- *
- * @return bool
- */
- public function saveorder()
- {
- // CSRF prevention
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $ordering = $model->getTable()->getColumnAlias('ordering');
- $ids = $model->getIds();
- $orders = $this->input->get('order', array(), 'array');
-
- if ($n = count($ids))
- {
- for ($i = 0; $i < $n; $i++)
- {
- $model->setId($ids[$i]);
- $neworder = (int) $orders[$i];
-
- $item = $model->getItem();
-
- if (!($item instanceof FOFTable))
- {
- return false;
- }
-
- $key = $item->getKeyName();
-
- if ($item->$key == $ids[$i])
- {
- $item->$ordering = $neworder;
- $model->save($item);
- }
- }
- }
-
- $status = $model->reorder();
-
- // Redirect
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
- $this->setRedirect($url);
-
- return $status;
- }
-
- /**
- * Moves selected items one position down the ordering list
- *
- * @return bool
- */
- public function orderdown()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $status = $model->move(1);
-
- // Redirect
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
-
- if (!$status)
- {
- $this->setRedirect($url, $model->getError(), 'error');
- }
- else
- {
- $this->setRedirect($url);
- }
-
- return $status;
- }
-
- /**
- * Moves selected items one position up the ordering list
- *
- * @return bool
- */
- public function orderup()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $status = $model->move(-1);
-
- // Redirect
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
-
- if (!$status)
- {
- $this->setRedirect($url, $model->getError(), 'error');
- }
- else
- {
- $this->setRedirect($url);
- }
-
- return $status;
- }
-
- /**
- * Delete selected item(s)
- *
- * @return bool
- */
- public function remove()
- {
- // CSRF prevention
-
- if ($this->csrfProtection)
- {
- $this->_csrfProtection();
- }
-
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $status = $model->delete();
-
- // Redirect
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
-
- if (!$status)
- {
- $this->setRedirect($url, $model->getError(), 'error');
- }
- else
- {
- $this->setRedirect($url);
- }
-
- return $status;
- }
-
- /**
- * Redirects the browser or returns false if no redirect is set.
- *
- * @return boolean False if no redirect exists.
- */
- public function redirect()
- {
- if ($this->redirect)
- {
- $app = JFactory::getApplication();
- $app->enqueueMessage($this->message, $this->messageType);
- $app->redirect($this->redirect);
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true if there is a redirect set in the controller
- *
- * @return boolean
- */
- public function hasRedirect()
- {
- return !empty($this->redirect);
- }
-
- /**
- * Register the default task to perform if a mapping is not found.
- *
- * @param string $method The name of the method in the derived class to perform if a named task is not found.
- *
- * @return FOFController A FOFController object to support chaining.
- */
- public function registerDefaultTask($method)
- {
- $this->registerTask('__default', $method);
-
- return $this;
- }
-
- /**
- * Register (map) a task to a method in the class.
- *
- * @param string $task The task.
- * @param string $method The name of the method in the derived class to perform for this task.
- *
- * @return FOFController A FOFController object to support chaining.
- */
- public function registerTask($task, $method)
- {
- if (in_array(strtolower($method), $this->methods))
- {
- $this->taskMap[strtolower($task)] = $method;
- }
-
- return $this;
- }
-
- /**
- * Unregister (unmap) a task in the class.
- *
- * @param string $task The task.
- *
- * @return FOFController This object to support chaining.
- */
- public function unregisterTask($task)
- {
- unset($this->taskMap[strtolower($task)]);
-
- return $this;
- }
-
- /**
- * Sets the internal message that is passed with a redirect
- *
- * @param string $text Message to display on redirect.
- * @param string $type Message type. Optional, defaults to 'message'.
- *
- * @return string Previous message
- */
- public function setMessage($text, $type = 'message')
- {
- $previous = $this->message;
- $this->message = $text;
- $this->messageType = $type;
-
- return $previous;
- }
-
- /**
- * Sets an entire array of search paths for resources.
- *
- * @param string $type The type of path to set, typically 'view' or 'model'.
- * @param string $path The new set of search paths. If null or false, resets to the current directory only.
- *
- * @return void
- */
- protected function setPath($type, $path)
- {
- // Clear out the prior search dirs
- $this->paths[$type] = array();
-
- // Actually add the user-specified directories
- $this->addPath($type, $path);
- }
-
- /**
- * Registers a redirection with an optional message. The redirection is
- * carried out when you use the redirect method.
- *
- * @param string $url The URL to redirect to
- * @param string $msg The message to be pushed to the application
- * @param string $type The message type to be pushed to the application, e.g. 'error'
- *
- * @return FOFController This object to support chaining
- */
- public function setRedirect($url, $msg = null, $type = null)
- {
- // Do the logic only if we're parsing a raw url (index.php?foo=bar&etc=etc)
- if (strpos($url, 'index.php') === 0)
- {
- $isAdmin = FOFPlatform::getInstance()->isBackend();
- $auto = false;
-
- if (($this->autoRouting == 2 || $this->autoRouting == 3) && $isAdmin)
- {
- $auto = true;
- }
- elseif (($this->autoRouting == 1 || $this->autoRouting == 3) && !$isAdmin)
- {
- $auto = true;
- }
-
- if ($auto)
- {
- $url = JRoute::_($url, false);
- }
- }
-
- $this->redirect = $url;
-
- if ($msg !== null)
- {
- // Controller may have set this directly
- $this->message = $msg;
- }
-
- // Ensure the type is not overwritten by a previous call to setMessage.
- if (empty($type))
- {
- if (empty($this->messageType))
- {
- $this->messageType = 'message';
- }
- }
-
- // If the type is explicitly set, set it.
- else
- {
- $this->messageType = $type;
- }
-
- return $this;
- }
-
- /**
- * Sets the published state (the enabled field) of the selected item(s)
- *
- * @param integer $state The desired state. 0 is unpublished, 1 is published.
- *
- * @return bool
- */
- final protected function setstate($state = 0)
- {
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $status = $model->publish($state);
-
- // Redirect
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
-
- if (!$status)
- {
- $this->setRedirect($url, $model->getError(), 'error');
- }
- else
- {
- $this->setRedirect($url);
- }
-
- return $status;
- }
-
- /**
- * Sets the access level of the selected item(s).
- *
- * @param integer $level The desired viewing access level ID
- *
- * @return bool
- */
- final protected function setaccess($level = 0)
- {
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $id = $model->getId();
-
- $item = $model->getItem();
-
- if (!($item instanceof FOFTable))
- {
- return false;
- }
-
- $key = $item->getKeyName();
- $loadedid = $item->$key;
-
- if ($id == $loadedid)
- {
- $item->access = $level;
- $status = $model->save($item);
- }
- else
- {
- $status = false;
- }
-
- // Redirect
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->component . '&view=' . FOFInflector::pluralize($this->view) . $this->getItemidURLSuffix();
-
- if (!$status)
- {
- $this->setRedirect($url, $model->getError(), 'error');
- }
- else
- {
- $this->setRedirect($url);
- }
-
- return $status;
- }
-
- /**
- * Common method to handle apply and save tasks
- *
- * @return boolean Returns true on success
- */
- final protected function applySave()
- {
- // Load the model
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $id = $model->getId();
-
- $data = $this->input->getData();
-
- if (!$this->onBeforeApplySave($data))
- {
- return false;
- }
-
- // Set the layout to form, if it's not set in the URL
-
- if (is_null($this->layout))
- {
- $this->layout = 'form';
- }
-
- // Do I have a form?
- $model->setState('form_name', 'form.' . $this->layout);
-
- $status = $model->save($data);
-
- if ($status && ($id != 0))
- {
- FOFPlatform::getInstance()->setHeader('Status', '201 Created', true);
-
- // Try to check-in the record if it's not a new one
- $status = $model->checkin();
-
- if ($status)
- {
- $status = $this->onAfterApplySave();
- }
- }
-
- $this->input->set('id', $model->getId());
-
- if (!$status)
- {
- // Redirect on error
- $id = $model->getId();
-
- if ($customURL = $this->input->get('returnurl', '', 'string'))
- {
- $customURL = base64_decode($customURL);
- }
-
- if (!empty($customURL))
- {
- $url = $customURL;
- }
- elseif ($id != 0)
- {
- $url = 'index.php?option=' . $this->component . '&view=' . $this->view . '&task=edit&id=' . $id . $this->getItemidURLSuffix();
- }
- else
- {
- $url = 'index.php?option=' . $this->component . '&view=' . $this->view . '&task=add' . $this->getItemidURLSuffix();
- }
-
- $this->setRedirect($url, '
' . implode('
', $model->getErrors()) . '
', 'error');
-
- return false;
- }
- else
- {
- $session = JFactory::getSession();
- $session->set($model->getHash() . 'savedata', null);
-
- return true;
- }
- }
-
- /**
- * Returns the default model associated with the current view
- *
- * @param array $config Configuration variables for the model
- *
- * @return FOFModel The global instance of the model (singleton)
- */
- final public function getThisModel($config = array())
- {
- if (!is_object($this->_modelObject))
- {
- // Make sure $config is an array
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config))
- {
- $config = array();
- }
-
- if (!empty($this->modelName))
- {
- $parts = FOFInflector::explode($this->modelName);
- $modelName = ucfirst(array_pop($parts));
- $prefix = FOFInflector::implode($parts);
- }
- else
- {
- $prefix = ucfirst($this->bareComponent) . 'Model';
- $modelName = ucfirst(FOFInflector::pluralize($this->view));
- }
-
- if (!array_key_exists('input', $config) || !($config['input'] instanceof FOFInput))
- {
- $config['input'] = $this->input;
- }
-
- $this->_modelObject = $this->getModel($modelName, $prefix, $config);
- }
-
- return $this->_modelObject;
- }
-
- /**
- * Method to get a model object, loading it if required.
- *
- * @param string $name The model name. Optional.
- * @param string $prefix The class prefix. Optional.
- * @param array $config Configuration array for model. Optional.
- *
- * @return object The model.
- */
- public function getModel($name = '', $prefix = '', $config = array())
- {
- // Make sure $config is an array
-
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config) || empty($config))
- {
- // array_merge is required to create a copy instead of assigning by reference
- $config = array_merge($this->config);
- }
-
- if (empty($name))
- {
- $name = $this->getName();
- }
-
- if (empty($prefix))
- {
- $prefix = $this->model_prefix;
- }
-
- if ($model = $this->createModel($name, $prefix, $config))
- {
- // Task is a reserved state
- $model->setState('task', $this->task);
-
- // Let's get the application object and set menu information if it's available
- if (!FOFPlatform::getInstance()->isCli())
- {
- $app = JFactory::getApplication();
- $menu = $app->getMenu();
-
- if (is_object($menu))
- {
- if ($item = $menu->getActive())
- {
- $params = $menu->getParams($item->id);
-
- // Set default state data
- $model->setState('parameters.menu', $params);
- }
- }
- }
- }
-
- return $model;
- }
-
- /**
- * Returns current view object
- *
- * @param array $config Configuration variables for the model
- *
- * @return FOFView The global instance of the view object (singleton)
- */
- final public function getThisView($config = array())
- {
- if (!is_object($this->_viewObject))
- {
- // Make sure $config is an array
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config) || empty($config))
- {
- // array_merge is required to create a copy instead of assigning by reference
- $config = array_merge($this->config);
- }
-
- $prefix = null;
- $viewName = null;
- $viewType = null;
-
- if (!empty($this->viewName))
- {
- $parts = FOFInflector::explode($this->viewName);
- $viewName = ucfirst(array_pop($parts));
- $prefix = FOFInflector::implode($parts);
- }
- else
- {
- $prefix = ucfirst($this->bareComponent) . 'View';
- $viewName = ucfirst($this->view);
- }
-
- $document = FOFPlatform::getInstance()->getDocument();
-
- if ($document instanceof JDocument)
- {
- $viewType = $document->getType();
- }
- else
- {
- $viewType = $this->input->getCmd('format', 'html');
- }
-
- if (($viewType == 'html') && $this->hasForm)
- {
- $viewType = 'form';
- }
-
- if (!array_key_exists('input', $config) || !($config['input'] instanceof FOFInput))
- {
- $config['input'] = $this->input;
- }
-
- $config['input']->set('base_path', $this->basePath);
-
- $this->_viewObject = $this->getView($viewName, $viewType, $prefix, $config);
- }
-
- return $this->_viewObject;
- }
-
- /**
- * Method to get the controller name
- *
- * The dispatcher name is set by default parsed using the classname, or it can be set
- * by passing a $config['name'] in the class constructor
- *
- * @throws Exception
- *
- * @return string The name of the dispatcher
- */
- public function getName()
- {
- if (empty($this->name))
- {
- if (empty($this->bareComponent))
- {
- $r = null;
-
- if (!preg_match('/(.*)Controller/i', get_class($this), $r))
- {
- throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'), 500);
- }
-
- $this->name = strtolower($r[1]);
- }
- else
- {
- $this->name = $this->bareComponent;
- }
- }
-
- return $this->name;
- }
-
- /**
- * Get the last task that is being performed or was most recently performed.
- *
- * @return string The task that is being performed or was most recently performed.
- */
- public function getTask()
- {
- return $this->task;
- }
-
- /**
- * Gets the available tasks in the controller.
- *
- * @return array Array[i] of task names.
- */
- public function getTasks()
- {
- return $this->methods;
- }
-
- /**
- * Method to get a reference to the current view and load it if necessary.
- *
- * @param string $name The view name. Optional, defaults to the controller name.
- * @param string $type The view type. Optional.
- * @param string $prefix The class prefix. Optional.
- * @param array $config Configuration array for view. Optional.
- *
- * @throws Exception
- *
- * @return FOFView Reference to the view or an error.
- */
- public function getView($name = '', $type = '', $prefix = '', $config = array())
- {
- // Make sure $config is an array
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config))
- {
- $config = array();
- }
-
- if (empty($name))
- {
- $name = $this->getName();
- }
-
- if (empty($prefix))
- {
- $prefix = $this->getName() . 'View';
- }
-
- $signature = md5($name . $type . $prefix . serialize($config));
-
- if (empty($this->viewsCache[$signature]))
- {
- if ($view = $this->createView($name, $prefix, $type, $config))
- {
- $this->viewsCache[$signature] = & $view;
- }
- else
- {
- throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_NOT_FOUND', $name, $type, $prefix), 500);
- }
- }
-
- return $this->viewsCache[$signature];
- }
-
- /**
- * Creates a new model object
- *
- * @param string $name The name of the model class, e.g. Items
- * @param string $prefix The prefix of the model class, e.g. FoobarModel
- * @param array $config The configuration parameters for the model class
- *
- * @return FOFModel The model object
- */
- protected function createModel($name, $prefix = '', $config = array())
- {
- // Make sure $config is an array
-
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config))
- {
- $config = array();
- }
-
- $result = null;
-
- // Clean the model name
- $modelName = preg_replace('/[^A-Z0-9_]/i', '', $name);
- $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
-
- $result = FOFModel::getAnInstance($modelName, $classPrefix, $config);
-
- return $result;
- }
-
- /**
- * Method to load and return a model object.
- *
- * @param string $name The name of the model.
- * @param string $prefix Optional model prefix.
- * @param array $config Configuration array for the model. Optional.
- *
- * @return mixed Model object on success; otherwise null
- */
- protected function &_createModel($name, $prefix = '', $config = array())
- {
- FOFPlatform::getInstance()->logDeprecated(__CLASS__ . '::' .__METHOD__ . ' is deprecated. Use createModel() instead.');
-
- return $this->createModel($name, $prefix, $config);
- }
-
- /**
- * Creates a View object instance and returns it
- *
- * @param string $name The name of the view, e.g. Items
- * @param string $prefix The prefix of the view, e.g. FoobarView
- * @param string $type The type of the view, usually one of Html, Raw, Json or Csv
- * @param array $config The configuration variables to use for creating the view
- *
- * @return FOFView
- */
- protected function createView($name, $prefix = '', $type = '', $config = array())
- {
- // Make sure $config is an array
-
- if (is_object($config))
- {
- $config = (array) $config;
- }
- elseif (!is_array($config))
- {
- $config = array();
- }
-
- $result = null;
-
- // Clean the view name
- $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
- $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
- $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
-
- if (!isset($config['input']))
- {
- $config['input'] = $this->input;
- }
-
- if (($config['input'] instanceof FOFInput))
- {
- $tmpInput = $config['input'];
- }
- else
- {
- $tmpInput = new FOFInput($config['input']);
- }
-
- // Guess the component name and view
-
- if (!empty($prefix))
- {
- preg_match('/(.*)View$/', $prefix, $m);
- $component = 'com_' . strtolower($m[1]);
- }
- else
- {
- $component = '';
- }
-
- if (empty($component) && array_key_exists('input', $config))
- {
- $component = $tmpInput->get('option', $component, 'cmd');
- }
-
- if (array_key_exists('option', $config))
- {
- if ($config['option'])
- {
- $component = $config['option'];
- }
- }
-
- $config['option'] = $component;
-
- $view = strtolower($viewName);
-
- if (empty($view) && array_key_exists('input', $config))
- {
- $view = $tmpInput->get('view', $view, 'cmd');
- }
-
- if (array_key_exists('view', $config))
- {
- if ($config['view'])
- {
- $view = $config['view'];
- }
- }
-
- $config['view'] = $view;
-
- if (array_key_exists('input', $config))
- {
- $tmpInput->set('option', $config['option']);
- $tmpInput->set('view', $config['view']);
- $config['input'] = $tmpInput;
- }
-
- // Get the component directories
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
-
- // Get the base paths where the view class files are expected to live
- $basePaths = array(
- $componentPaths['main'],
- $componentPaths['alt']
- );
- $basePaths = array_merge($this->paths['view']);
-
- // Get the alternate (singular/plural) view name
- $altViewName = FOFInflector::isPlural($viewName) ? FOFInflector::singularize($viewName) : FOFInflector::pluralize($viewName);
-
- $suffixes = array(
- $viewName,
- $altViewName,
- 'default'
- );
-
- $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
-
- foreach ($suffixes as $suffix)
- {
- // Build the view class name
- $viewClass = $classPrefix . ucfirst($suffix);
-
- if (class_exists($viewClass))
- {
- // The class is already loaded
- break;
- }
-
- // The class is not loaded. Let's load it!
- $viewPath = $this->createFileName('view', array('name' => $suffix, 'type' => $viewType));
- $path = $filesystem->pathFind($basePaths, $viewPath);
-
- if ($path)
- {
- require_once $path;
- }
-
- if (class_exists($viewClass))
- {
- // The class was loaded successfully
- break;
- }
- }
-
- if (!class_exists($viewClass))
- {
- $viewClass = 'FOFView' . ucfirst($type);
- }
-
- $templateOverridePath = FOFPlatform::getInstance()->getTemplateOverridePath($config['option']);
-
- // Setup View configuration options
-
- if (!array_key_exists('template_path', $config))
- {
- $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::pluralize($config['view']) . '/tmpl';
-
- if ($templateOverridePath)
- {
- $config['template_path'][] = $templateOverridePath . '/' . FOFInflector::pluralize($config['view']);
- }
-
- $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::singularize($config['view']) . '/tmpl';
-
- if ($templateOverridePath)
- {
- $config['template_path'][] = $templateOverridePath . '/' . FOFInflector::singularize($config['view']);
- }
-
- $config['template_path'][] = $componentPaths['main'] . '/views/' . $config['view'] . '/tmpl';
-
- if ($templateOverridePath)
- {
- $config['template_path'][] = $templateOverridePath . '/' . $config['view'];
- }
- }
-
- $extraTemplatePath = $this->configProvider->get($config['option'] . '.views.' . $config['view'] . '.config.template_path', null);
-
- if ($extraTemplatePath)
- {
- array_unshift($config['template_path'], $componentPaths['main'] . '/' . $extraTemplatePath);
- }
-
- if (!array_key_exists('helper_path', $config))
- {
- $config['helper_path'] = array(
- $componentPaths['main'] . '/helpers',
- $componentPaths['admin'] . '/helpers'
- );
- }
-
- $extraHelperPath = $this->configProvider->get($config['option'] . '.views.' . $config['view'] . '.config.helper_path', null);
-
- if ($extraHelperPath)
- {
- $config['helper_path'][] = $componentPaths['main'] . '/' . $extraHelperPath;
- }
-
- // Set the use_hypermedia flag in $config if it's not already set
-
- if (!isset($config['use_hypermedia']))
- {
- $config['use_hypermedia'] = $this->configProvider->get($config['option'] . '.views.' . $config['view'] . '.config.use_hypermedia', false);
- }
-
- $result = new $viewClass($config);
-
- return $result;
- }
-
- /**
- * Deprecated function to create a View object instance
- *
- * @param string $name The name of the view, e.g. 'Items'
- * @param string $prefix The prefix of the view, e.g. 'FoobarView'
- * @param string $type The view type, e.g. 'html'
- * @param array $config The configuration array for the view
- *
- * @return FOFView
- *
- * @see FOFController::createView
- *
- * @deprecated since version 2.0
- */
- protected function &_createView($name, $prefix = '', $type = '', $config = array())
- {
- FOFPlatform::getInstance()->logDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated. Use createView() instead.');
-
- return $this->createView($name, $prefix, $type, $config);
- }
-
- /**
- * Set the name of the view to be used by this Controller
- *
- * @param string $viewName The name of the view
- *
- * @return void
- */
- public function setThisViewName($viewName)
- {
- $this->viewName = $viewName;
- }
-
- /**
- * Set the name of the model to be used by this Controller
- *
- * @param string $modelName The name of the model
- *
- * @return void
- */
- public function setThisModelName($modelName)
- {
- $this->modelName = $modelName;
- }
-
- /**
- * Checks if the current user has enough privileges for the requested ACL
- * area.
- *
- * @param string $area The ACL area, e.g. core.manage.
- *
- * @return boolean True if the user has the ACL privilege specified
- */
- protected function checkACL($area)
- {
- if (in_array(strtolower($area), array('false','0','no','403')))
- {
- return false;
- }
-
- if (in_array(strtolower($area), array('true','1','yes')))
- {
- return true;
- }
- elseif (empty($area))
- {
- return true;
- }
- else
- {
- // Check if we're dealing with ids
- $ids = null;
-
- // First, check if there is an asset for this record
- $table = $this->getThisModel()->getTable();
-
- if ($table && $table->isAssetsTracked())
- {
- $ids = $this->getThisModel()->getId() ? $this->getThisModel()->getId() : null;
- }
-
- // Generic or Asset tracking
-
- if (empty($ids))
- {
- return FOFPlatform::getInstance()->authorise($area, $this->component);
- }
- else
- {
- if (!is_array($ids))
- {
- $ids = array($ids);
- }
-
- $resource = FOFInflector::singularize($this->view);
- $isEditState = ($area == 'core.edit.state');
-
- foreach ($ids as $id)
- {
- $asset = $this->component . '.' . $resource . '.' . $id;
-
- // Dedicated permission found, check it!
-
- if (FOFPlatform::getInstance()->authorise($area, $asset) )
- {
- return true;
- }
-
- // Fallback on edit.own, if not edit.state. First test if the permission is available.
-
- if ((!$isEditState) && (FOFPlatform::getInstance()->authorise('core.edit.own', $asset)))
- {
- $table = $this->getThisModel()->getTable();
- $table->load($id);
-
- $created_by = $table->getColumnAlias('created_by');
-
- if ($table && isset($table->$created_by))
- {
- // Now test the owner is the user.
- $owner_id = (int) $table->$created_by;
-
- // If the owner matches 'me' then do the test.
- if ($owner_id == FOFPlatform::getInstance()->getUser()->id)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- }
- }
- }
-
- return false;
- }
-
- /**
- * A catch-all method for all tasks without a corresponding onBefore
- * method. Applies the ACL preferences defined in fof.xml.
- *
- * @param string $task The task being executed
- *
- * @return boolean True to allow execution of the task
- */
- protected function onBeforeGenericTask($task)
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.' . $task, ''
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * Execute something before applySave is called. Return false to prevent
- * applySave from executing.
- *
- * @param array &$data The data upon which applySave will act
- *
- * @return boolean True to allow applySave to run
- */
- protected function onBeforeApplySave(&$data)
- {
- return true;
- }
-
- /**
- * Execute something after applySave has run.
- *
- * @return boolean True to allow normal return, false to cause a 403 error
- */
- protected function onAfterApplySave()
- {
- return true;
- }
-
- /**
- * ACL check before changing the access level; override to customise
- *
- * @return boolean True to allow accesspublic() to run
- */
- protected function onBeforeAccesspublic()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.accesspublic', 'core.edit.state');
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the access level; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeAccessregistered()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.accessregistered', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the access level; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeAccessspecial()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.accessspecial', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before adding a new record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeAdd()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.add', 'core.create'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before saving a new/modified record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeApply()
- {
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $id = $model->getId();
-
- if(!$id)
- {
- $defaultPrivilege = 'core.create';
- }
- else
- {
- $defaultPrivilege = 'core.edit';
- }
-
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.apply', $defaultPrivilege
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before allowing someone to browse
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeBrowse()
- {
- $defaultPrivilege = '';
-
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.browse', $defaultPrivilege
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before cancelling an edit
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeCancel()
- {
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $id = $model->getId();
-
- if(!$id)
- {
- $defaultPrivilege = 'core.create';
- }
- else
- {
- $defaultPrivilege = 'core.edit';
- }
-
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.cancel', $defaultPrivilege
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before editing a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeEdit()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.edit', 'core.edit'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the ordering of a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeOrderdown()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.orderdown', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the ordering of a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeOrderup()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.orderup', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the publish status of a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforePublish()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.publish', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before removing a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeRemove()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.remove', 'core.delete'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before saving a new/modified record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeSave()
- {
- $model = $this->getThisModel();
-
- if (!$model->getId())
- {
- $model->setIDsFromRequest();
- }
-
- $id = $model->getId();
-
- if(!$id)
- {
- $defaultPrivilege = 'core.create';
- }
- else
- {
- $defaultPrivilege = 'core.edit';
- }
-
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.save', $defaultPrivilege
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before saving a new/modified record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeSavenew()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.savenew', 'core.create'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the ordering of a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeSaveorder()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.saveorder', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * ACL check before changing the publish status of a record; override to customise
- *
- * @return boolean True to allow the method to run
- */
- protected function onBeforeUnpublish()
- {
- $privilege = $this->configProvider->get(
- $this->component . '.views.' .
- FOFInflector::singularize($this->view) . '.acl.unpublish', 'core.edit.state'
- );
-
- return $this->checkACL($privilege);
- }
-
- /**
- * Gets a URL suffix with the Itemid parameter. If it's not the front-end of the site, or if
- * there is no Itemid set it returns an empty string.
- *
- * @return string The &Itemid=123 URL suffix, or an empty string if Itemid is not applicable
- */
- public function getItemidURLSuffix()
- {
- if (FOFPlatform::getInstance()->isFrontend() && ($this->input->getCmd('Itemid', 0) != 0))
- {
- return '&Itemid=' . $this->input->getInt('Itemid', 0);
- }
- else
- {
- return '';
- }
- }
-
- /**
- * Applies CSRF protection by means of a standard Joomla! token (nonce) check.
- * Raises a 403 Access Forbidden error through the platform if the check fails.
- *
- * TODO Move this check inside the platform
- *
- * @return boolean True if the CSRF check is successful
- *
- * @throws Exception
- */
- protected function _csrfProtection()
- {
- static $isCli = null, $isAdmin = null;
-
- if (is_null($isCli))
- {
- $isCli = FOFPlatform::getInstance()->isCli();
- $isAdmin = FOFPlatform::getInstance()->isBackend();
- }
-
- switch ($this->csrfProtection)
- {
- // Never
- case 0:
- return true;
- break;
-
- // Always
- case 1:
- break;
-
- // Only back-end and HTML format
- case 2:
- if ($isCli)
- {
- return true;
- }
- elseif (!$isAdmin && ($this->input->get('format', 'html', 'cmd') != 'html'))
- {
- return true;
- }
- break;
-
- // Only back-end
- case 3:
- if (!$isAdmin)
- {
- return true;
- }
- break;
- }
-
- $hasToken = false;
- $session = JFactory::getSession();
-
- // Joomla! 1.5/1.6/1.7/2.5 (classic Joomla! API) method
- if (method_exists('JUtility', 'getToken'))
- {
- $token = JUtility::getToken();
- $hasToken = $this->input->get($token, false, 'none') == 1;
-
- if (!$hasToken)
- {
- $hasToken = $this->input->get('_token', null, 'none') == $token;
- }
- }
-
- // Joomla! 2.5+ (Platform 12.1+) method
- if (!$hasToken)
- {
- if (method_exists($session, 'getToken'))
- {
- $token = $session->getToken();
- $hasToken = $this->input->get($token, false, 'none') == 1;
-
- if (!$hasToken)
- {
- $hasToken = $this->input->get('_token', null, 'none') == $token;
- }
- }
- }
-
- // Joomla! 2.5+ formToken method
- if (!$hasToken)
- {
- if (method_exists($session, 'getFormToken'))
- {
- $token = $session->getFormToken();
- $hasToken = $this->input->get($token, false, 'none') == 1;
-
- if (!$hasToken)
- {
- $hasToken = $this->input->get('_token', null, 'none') == $token;
- }
- }
- }
-
- if (!$hasToken)
- {
- FOFPlatform::getInstance()->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
-
- return false;
- }
- }
-}
diff --git a/libraries/fof/database/iterator.php b/libraries/fof/database/iterator.php
deleted file mode 100644
index c937a59f28..0000000000
--- a/libraries/fof/database/iterator.php
+++ /dev/null
@@ -1,244 +0,0 @@
-_tableObject = FOFTable::getInstance($parts[2], ucfirst($parts[0]) . ucfirst($parts[1]));
-
- $this->cursor = $cursor;
- $this->class = 'stdClass';
- $this->_column = $column;
- $this->_fetched = 0;
- $this->next();
- }
-
- /**
- * Database iterator destructor.
- */
- public function __destruct()
- {
- if ($this->cursor)
- {
- $this->freeResult($this->cursor);
- }
- }
-
- /**
- * The current element in the iterator.
- *
- * @return object
- *
- * @see Iterator::current()
- */
- public function current()
- {
- return $this->_currentTable;
- }
-
- /**
- * The key of the current element in the iterator.
- *
- * @return scalar
- *
- * @see Iterator::key()
- */
- public function key()
- {
- return $this->_key;
- }
-
- /**
- * Moves forward to the next result from the SQL query.
- *
- * @return void
- *
- * @see Iterator::next()
- */
- public function next()
- {
- // Set the default key as being the number of fetched object
- $this->_key = $this->_fetched;
-
- // Try to get an object
- $this->_current = $this->fetchObject();
-
- // If an object has been found
- if ($this->_current)
- {
- $this->_currentTable = $this->getTable();
-
- // Set the key as being the indexed column (if it exists)
- if (isset($this->_current->{$this->_column}))
- {
- $this->_key = $this->_current->{$this->_column};
- }
-
- // Update the number of fetched object
- $this->_fetched++;
- }
- }
-
- /**
- * Rewinds the iterator.
- *
- * This iterator cannot be rewound.
- *
- * @return void
- *
- * @see Iterator::rewind()
- */
- public function rewind()
- {
- }
-
- /**
- * Checks if the current position of the iterator is valid.
- *
- * @return boolean
- *
- * @see Iterator::valid()
- */
- public function valid()
- {
- return (boolean) $this->_current;
- }
-
- /**
- * Method to fetch a row from the result set cursor as an object.
- *
- * @return mixed Either the next row from the result set or false if there are no more rows.
- */
- abstract protected function fetchObject();
-
- /**
- * Method to free up the memory used for the result set.
- *
- * @return void
- */
- abstract protected function freeResult();
-
- /**
- * Returns the data in $this->_current as a FOFTable instance
- *
- * @return FOFTable
- *
- * @throws OutOfBoundsException
- */
- protected function getTable()
- {
- if (!$this->valid())
- {
- throw new OutOfBoundsException('Cannot get item past iterator\'s bounds', 500);
- }
-
- $this->_tableObject->bind($this->_current);
-
- return $this->_tableObject;
- }
-}
diff --git a/libraries/fof/database/iterator/mysql.php b/libraries/fof/database/iterator/mysql.php
deleted file mode 100644
index 085ed87c55..0000000000
--- a/libraries/fof/database/iterator/mysql.php
+++ /dev/null
@@ -1,51 +0,0 @@
-cursor);
- }
-
- /**
- * Method to fetch a row from the result set cursor as an object.
- *
- * @return mixed Either the next row from the result set or false if there are no more rows.
- */
- protected function fetchObject()
- {
- return @mysql_fetch_object($this->cursor, $this->class);
- }
-
- /**
- * Method to free up the memory used for the result set.
- *
- * @return void
- */
- protected function freeResult()
- {
- @mysql_free_result($this->cursor);
- }
-}
diff --git a/libraries/fof/database/iterator/mysqli.php b/libraries/fof/database/iterator/mysqli.php
deleted file mode 100644
index 11fc3e37c3..0000000000
--- a/libraries/fof/database/iterator/mysqli.php
+++ /dev/null
@@ -1,51 +0,0 @@
-cursor);
- }
-
- /**
- * Method to fetch a row from the result set cursor as an object.
- *
- * @return mixed Either the next row from the result set or false if there are no more rows.
- */
- protected function fetchObject()
- {
- return @mysqli_fetch_object($this->cursor, $this->class);
- }
-
- /**
- * Method to free up the memory used for the result set.
- *
- * @return void
- */
- protected function freeResult()
- {
- @mysqli_free_result($this->cursor);
- }
-}
diff --git a/libraries/fof/database/iterator/pdo.php b/libraries/fof/database/iterator/pdo.php
deleted file mode 100644
index 2a38e9f4aa..0000000000
--- a/libraries/fof/database/iterator/pdo.php
+++ /dev/null
@@ -1,68 +0,0 @@
-cursor) && $this->cursor instanceof PDOStatement)
- {
- return @$this->cursor->rowCount();
- }
- else
- {
- return 0;
- }
- }
-
- /**
- * Method to fetch a row from the result set cursor as an object.
- *
- * @return mixed Either the next row from the result set or false if there are no more rows.
- */
- protected function fetchObject()
- {
- if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
- {
- return @$this->cursor->fetchObject($this->class);
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Method to free up the memory used for the result set.
- *
- * @return void
- */
- protected function freeResult()
- {
- if (!empty($this->cursor) && $this->cursor instanceof PDOStatement)
- {
- @$this->cursor->closeCursor();
- }
- }
-}
diff --git a/libraries/fof/dispatcher/dispatcher.php b/libraries/fof/dispatcher/dispatcher.php
deleted file mode 100644
index b39cb9f238..0000000000
--- a/libraries/fof/dispatcher/dispatcher.php
+++ /dev/null
@@ -1,719 +0,0 @@
-getCmd('option', 'com_foobar');
- $config['view'] = !is_null($view) ? $view : $input->getCmd('view', '');
-
- $input->set('option', $config['option']);
- $input->set('view', $config['view']);
-
- $config['input'] = $input;
-
- $className = ucfirst(str_replace('com_', '', $config['option'])) . 'Dispatcher';
-
- if (!class_exists($className))
- {
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
-
- $searchPaths = array(
- $componentPaths['main'],
- $componentPaths['main'] . '/dispatchers',
- $componentPaths['admin'],
- $componentPaths['admin'] . '/dispatchers'
- );
-
- if (array_key_exists('searchpath', $config))
- {
- array_unshift($searchPaths, $config['searchpath']);
- }
-
- $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
-
- $path = $filesystem->pathFind(
- $searchPaths, 'dispatcher.php'
- );
-
- if ($path)
- {
- require_once $path;
- }
- }
-
- if (!class_exists($className))
- {
- $className = 'FOFDispatcher';
- }
-
- $instance = new $className($config);
-
- return $instance;
- }
-
- /**
- * Public constructor
- *
- * @param array $config The configuration variables
- */
- public function __construct($config = array())
- {
- // Cache the config
- $this->config = $config;
-
- // Get the input for this MVC triad
- if (array_key_exists('input', $config))
- {
- $this->input = $config['input'];
- }
- else
- {
- $this->input = new FOFInput;
- }
-
- // Get the default values for the component name
- $this->component = $this->input->getCmd('option', 'com_foobar');
-
- // Load the component's fof.xml configuration file
- $configProvider = new FOFConfigProvider;
- $this->defaultView = $configProvider->get($this->component . '.dispatcher.default_view', $this->defaultView);
-
- // Get the default values for the view name
- $this->view = $this->input->getCmd('view', null);
-
- if (empty($this->view))
- {
- // Do we have a task formatted as controller.task?
- $task = $this->input->getCmd('task', '');
-
- if (!empty($task) && (strstr($task, '.') !== false))
- {
- list($this->view, $task) = explode('.', $task, 2);
- $this->input->set('task', $task);
- }
- }
-
- if (empty($this->view))
- {
- $this->view = $this->defaultView;
- }
-
- $this->layout = $this->input->getCmd('layout', null);
-
- // Overrides from the config
- if (array_key_exists('option', $config))
- {
- $this->component = $config['option'];
- }
-
- if (array_key_exists('view', $config))
- {
- $this->view = empty($config['view']) ? $this->view : $config['view'];
- }
-
- if (array_key_exists('layout', $config))
- {
- $this->layout = $config['layout'];
- }
-
- $this->input->set('option', $this->component);
- $this->input->set('view', $this->view);
- $this->input->set('layout', $this->layout);
- }
-
- /**
- * The main code of the Dispatcher. It spawns the necessary controller and
- * runs it.
- *
- * @throws Exception
- *
- * @return null
- */
- public function dispatch()
- {
- $platform = FOFPlatform::getInstance();
-
- if (!$platform->authorizeAdmin($this->input->getCmd('option', 'com_foobar')))
- {
- return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
- }
-
- $this->transparentAuthentication();
-
- // Merge English and local translations
- $platform->loadTranslations($this->component);
-
- $canDispatch = true;
-
- if ($platform->isCli())
- {
- $canDispatch = $canDispatch && $this->onBeforeDispatchCLI();
- }
-
- $canDispatch = $canDispatch && $this->onBeforeDispatch();
-
- if (!$canDispatch)
- {
- $platform->setHeader('Status', '403 Forbidden', true);
-
- return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
- }
-
- // Get and execute the controller
- $option = $this->input->getCmd('option', 'com_foobar');
- $view = $this->input->getCmd('view', $this->defaultView);
- $task = $this->input->getCmd('task', null);
-
- if (empty($task))
- {
- $task = $this->getTask($view);
- }
-
- // Pluralise/sungularise the view name for typical tasks
- if (in_array($task, array('edit', 'add', 'read')))
- {
- $view = FOFInflector::singularize($view);
- }
- elseif (in_array($task, array('browse')))
- {
- $view = FOFInflector::pluralize($view);
- }
-
- $this->input->set('view', $view);
- $this->input->set('task', $task);
-
- $config = $this->config;
- $config['input'] = $this->input;
-
- $controller = FOFController::getTmpInstance($option, $view, $config);
- $status = $controller->execute($task);
-
- if (!$this->onAfterDispatch())
- {
- $platform->setHeader('Status', '403 Forbidden', true);
-
- return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
- }
-
- $format = $this->input->get('format', 'html', 'cmd');
- $format = empty($format) ? 'html' : $format;
-
- if ($format == 'html')
- {
- // In HTML views perform a redirection
- if ($controller->redirect())
- {
- return;
- }
- }
- else
- {
- // In non-HTML views just exit the application with the proper HTTP headers
- if ($controller->hasRedirect())
- {
- $headers = $platform->sendHeaders();
- jexit();
- }
- }
- }
-
- /**
- * Tries to guess the controller task to execute based on the view name and
- * the HTTP request method.
- *
- * @param string $view The name of the view
- *
- * @return string The best guess of the task to execute
- */
- protected function getTask($view)
- {
- // Get a default task based on plural/singular view
- $request_task = $this->input->getCmd('task', null);
- $task = FOFInflector::isPlural($view) ? 'browse' : 'edit';
-
- // Get a potential ID, we might need it later
- $id = $this->input->get('id', null, 'int');
-
- if ($id == 0)
- {
- $ids = $this->input->get('ids', array(), 'array');
-
- if (!empty($ids))
- {
- $id = array_shift($ids);
- }
- }
-
- // Check the request method
-
- if (!isset($_SERVER['REQUEST_METHOD']))
- {
- $_SERVER['REQUEST_METHOD'] = 'GET';
- }
-
- $requestMethod = strtoupper($_SERVER['REQUEST_METHOD']);
-
- switch ($requestMethod)
- {
- case 'POST':
- case 'PUT':
- if (!is_null($id))
- {
- $task = 'save';
- }
- break;
-
- case 'DELETE':
- if ($id != 0)
- {
- $task = 'delete';
- }
- break;
-
- case 'GET':
- default:
- // If it's an edit without an ID or ID=0, it's really an add
- if (($task == 'edit') && ($id == 0))
- {
- $task = 'add';
- }
-
- // If it's an edit in the frontend, it's really a read
- elseif (($task == 'edit') && FOFPlatform::getInstance()->isFrontend())
- {
- $task = 'read';
- }
- break;
- }
-
- return $task;
- }
-
- /**
- * Executes right before the dispatcher tries to instantiate and run the
- * controller.
- *
- * @return boolean Return false to abort
- */
- public function onBeforeDispatch()
- {
- return true;
- }
-
- /**
- * Sets up some environment variables, so we can work as usually on CLI, too.
- *
- * @return boolean Return false to abort
- */
- public function onBeforeDispatchCLI()
- {
- JLoader::import('joomla.environment.uri');
- JLoader::import('joomla.application.component.helper');
-
- // Trick to create a valid url used by JURI
- $this->_originalPhpScript = '';
-
- // We have no Application Helper (there is no Application!), so I have to define these constants manually
- $option = $this->input->get('option', '', 'cmd');
-
- if ($option)
- {
- $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($option);
-
- if (!defined('JPATH_COMPONENT'))
- {
- define('JPATH_COMPONENT', $componentPaths['main']);
- }
-
- if (!defined('JPATH_COMPONENT_SITE'))
- {
- define('JPATH_COMPONENT_SITE', $componentPaths['site']);
- }
-
- if (!defined('JPATH_COMPONENT_ADMINISTRATOR'))
- {
- define('JPATH_COMPONENT_ADMINISTRATOR', $componentPaths['admin']);
- }
- }
-
- return true;
- }
-
- /**
- * Executes right after the dispatcher runs the controller.
- *
- * @return boolean Return false to abort
- */
- public function onAfterDispatch()
- {
- // If we have to log out the user, please do so now
-
- if ($this->fofAuth_LogoutOnReturn && $this->_fofAuth_isLoggedIn)
- {
- FOFPlatform::getInstance()->logoutUser();
- }
-
- return true;
- }
-
- /**
- * Transparently authenticates a user
- *
- * @return void
- */
- public function transparentAuthentication()
- {
- // Only run when there is no logged in user
-
- if (!FOFPlatform::getInstance()->getUser()->guest)
- {
- return;
- }
-
- // @todo Check the format
- $format = $this->input->getCmd('format', 'html');
-
- if (!in_array($format, $this->fofAuth_Formats))
- {
- return;
- }
-
- foreach ($this->fofAuth_AuthMethods as $method)
- {
- // If we're already logged in, don't bother
-
- if ($this->_fofAuth_isLoggedIn)
- {
- continue;
- }
-
- // This will hold our authentication data array (username, password)
- $authInfo = null;
-
- switch ($method)
- {
- case 'HTTPBasicAuth_TOTP':
-
- if (empty($this->fofAuth_Key))
- {
- continue;
- }
-
- if (!isset($_SERVER['PHP_AUTH_USER']))
- {
- continue;
- }
-
- if (!isset($_SERVER['PHP_AUTH_PW']))
- {
- continue;
- }
-
- if ($_SERVER['PHP_AUTH_USER'] != '_fof_auth')
- {
- continue;
- }
-
- $encryptedData = $_SERVER['PHP_AUTH_PW'];
-
- $authInfo = $this->_decryptWithTOTP($encryptedData);
- break;
-
- case 'QueryString_TOTP':
- $encryptedData = $this->input->get('_fofauthentication', '', 'raw');
-
- if (empty($encryptedData))
- {
- continue;
- }
-
- $authInfo = $this->_decryptWithTOTP($encryptedData);
- break;
-
- case 'HTTPBasicAuth_Plaintext':
- if (!isset($_SERVER['PHP_AUTH_USER']))
- {
- continue;
- }
-
- if (!isset($_SERVER['PHP_AUTH_PW']))
- {
- continue;
- }
-
- $authInfo = array(
- 'username' => $_SERVER['PHP_AUTH_USER'],
- 'password' => $_SERVER['PHP_AUTH_PW']
- );
- break;
-
- case 'QueryString_Plaintext':
- $jsonencoded = $this->input->get('_fofauthentication', '', 'raw');
-
- if (empty($jsonencoded))
- {
- continue;
- }
-
- $authInfo = json_decode($jsonencoded, true);
-
- if (!is_array($authInfo))
- {
- $authInfo = null;
- }
- elseif (!array_key_exists('username', $authInfo) || !array_key_exists('password', $authInfo))
- {
- $authInfo = null;
- }
- break;
-
- case 'SplitQueryString_Plaintext':
- $authInfo = array(
- 'username' => $this->input->get('_fofauthentication_username', '', 'raw'),
- 'password' => $this->input->get('_fofauthentication_password', '', 'raw'),
- );
-
- if (empty($authInfo['username']))
- {
- $authInfo = null;
- }
-
- break;
-
- default:
- continue;
-
- break;
- }
-
- // No point trying unless we have a username and password
- if (!is_array($authInfo))
- {
- continue;
- }
-
- $this->_fofAuth_isLoggedIn = FOFPlatform::getInstance()->loginUser($authInfo);
- }
- }
-
- /**
- * Decrypts a transparent authentication message using a TOTP
- *
- * @param string $encryptedData The encrypted data
- *
- * @return array The decrypted data
- */
- private function _decryptWithTOTP($encryptedData)
- {
- if (empty($this->fofAuth_Key))
- {
- $this->_fofAuth_CryptoKey = null;
-
- return null;
- }
-
- $totp = new FOFEncryptTotp($this->fofAuth_timeStep);
- $period = $totp->getPeriod();
- $period--;
-
- for ($i = 0; $i <= 2; $i++)
- {
- $time = ($period + $i) * $this->fofAuth_timeStep;
- $otp = $totp->getCode($this->fofAuth_Key, $time);
- $this->_fofAuth_CryptoKey = hash('sha256', $this->fofAuth_Key . $otp);
-
- $aes = new FOFEncryptAes($this->_fofAuth_CryptoKey);
- $ret = $aes->decryptString($encryptedData);
- $ret = rtrim($ret, "\000");
-
- $ret = json_decode($ret, true);
-
- if (!is_array($ret))
- {
- continue;
- }
-
- if (!array_key_exists('username', $ret))
- {
- continue;
- }
-
- if (!array_key_exists('password', $ret))
- {
- continue;
- }
-
- // Successful decryption!
- return $ret;
- }
-
- // Obviously if we're here we could not decrypt anything. Bail out.
- $this->_fofAuth_CryptoKey = null;
-
- return null;
- }
-
- /**
- * Creates a decryption key for use with the TOTP decryption method
- *
- * @param integer $time The timestamp used for TOTP calculation, leave empty to use current timestamp
- *
- * @return string THe encryption key
- */
- private function _createDecryptionKey($time = null)
- {
- $totp = new FOFEncryptTotp($this->fofAuth_timeStep);
- $otp = $totp->getCode($this->fofAuth_Key, $time);
-
- $key = hash('sha256', $this->fofAuth_Key . $otp);
-
- return $key;
- }
-
- /**
- * Main function to detect if we're running in a CLI environment and we're admin
- *
- * @return array isCLI and isAdmin. It's not an associtive array, so we can use list.
- */
- public static function isCliAdmin()
- {
- static $isCLI = null;
- static $isAdmin = null;
-
- if (is_null($isCLI) && is_null($isAdmin))
- {
- $isCLI = FOFPlatform::getInstance()->isCli();
- $isAdmin = FOFPlatform::getInstance()->isBackend();
- }
-
- return array($isCLI, $isAdmin);
- }
-}
diff --git a/libraries/fof/encrypt/aes.php b/libraries/fof/encrypt/aes.php
deleted file mode 100644
index 1ad7952a9c..0000000000
--- a/libraries/fof/encrypt/aes.php
+++ /dev/null
@@ -1,239 +0,0 @@
-_keyString = $key;
-
- switch ($strength)
- {
- case 256:
- default:
- $this->_cipherType = MCRYPT_RIJNDAEL_256;
- break;
-
- case 192:
- $this->_cipherType = MCRYPT_RIJNDAEL_192;
- break;
-
- case 128:
- $this->_cipherType = MCRYPT_RIJNDAEL_128;
- break;
- }
-
- switch (strtoupper($mode))
- {
- case 'ECB':
- $this->_cipherMode = MCRYPT_MODE_ECB;
- break;
-
- case 'CBC':
- $this->_cipherMode = MCRYPT_MODE_CBC;
- break;
- }
- }
-
- /**
- * Encrypts a string using AES
- *
- * @param string $stringToEncrypt The plaintext to encrypt
- * @param bool $base64encoded Should I Base64-encode the result?
- *
- * @return string The cryptotext. Please note that the first 16 bytes of
- * the raw string is the IV (initialisation vector) which
- * is necessary for decoding the string.
- */
- public function encryptString($stringToEncrypt, $base64encoded = true)
- {
- if (strlen($this->_keyString) != 32)
- {
- $key = hash('sha256', $this->_keyString, true);
- }
- else
- {
- $key = $this->_keyString;
- }
-
- // Set up the IV (Initialization Vector)
- $iv_size = mcrypt_get_iv_size($this->_cipherType, $this->_cipherMode);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_URANDOM);
-
- if (empty($iv))
- {
- $iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_RANDOM);
- }
-
- if (empty($iv))
- {
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- }
-
- // Encrypt the data
- $cipherText = mcrypt_encrypt($this->_cipherType, $key, $stringToEncrypt, $this->_cipherMode, $iv);
-
- // Prepend the IV to the ciphertext
- $cipherText = $iv . $cipherText;
-
- // Optionally pass the result through Base64 encoding
- if ($base64encoded)
- {
- $cipherText = base64_encode($cipherText);
- }
-
- // Return the result
- return $cipherText;
- }
-
- /**
- * Decrypts a ciphertext into a plaintext string using AES
- *
- * @param string $stringToDecrypt The ciphertext to decrypt. The first 16 bytes of the raw string must contain the IV (initialisation vector).
- * @param bool $base64encoded Should I Base64-decode the data before decryption?
- *
- * @return string The plain text string
- */
- public function decryptString($stringToDecrypt, $base64encoded = true)
- {
- if (strlen($this->_keyString) != 32)
- {
- $key = hash('sha256', $this->_keyString, true);
- }
- else
- {
- $key = $this->_keyString;
- }
-
- if ($base64encoded)
- {
- $stringToDecrypt = base64_decode($stringToDecrypt);
- }
-
- // Calculate the IV size
- $iv_size = mcrypt_get_iv_size($this->_cipherType, $this->_cipherMode);
-
- // Extract IV
- $iv = substr($stringToDecrypt, 0, $iv_size);
- $stringToDecrypt = substr($stringToDecrypt, $iv_size);
-
- // Decrypt the data
- $plainText = mcrypt_decrypt($this->_cipherType, $key, $stringToDecrypt, $this->_cipherMode, $iv);
-
- return $plainText;
- }
-
- /**
- * Is AES encryption supported by this PHP installation?
- *
- * @return boolean
- */
- public static function isSupported()
- {
- if (!function_exists('mcrypt_get_key_size'))
- {
- return false;
- }
-
- if (!function_exists('mcrypt_get_iv_size'))
- {
- return false;
- }
-
- if (!function_exists('mcrypt_create_iv'))
- {
- return false;
- }
-
- if (!function_exists('mcrypt_encrypt'))
- {
- return false;
- }
-
- if (!function_exists('mcrypt_decrypt'))
- {
- return false;
- }
-
- if (!function_exists('mcrypt_list_algorithms'))
- {
- return false;
- }
-
- if (!function_exists('hash'))
- {
- return false;
- }
-
- if (!function_exists('hash_algos'))
- {
- return false;
- }
-
- if (!function_exists('base64_encode'))
- {
- return false;
- }
-
- if (!function_exists('base64_decode'))
- {
- return false;
- }
-
- $algorightms = mcrypt_list_algorithms();
-
- if (!in_array('rijndael-128', $algorightms))
- {
- return false;
- }
-
- if (!in_array('rijndael-192', $algorightms))
- {
- return false;
- }
-
- if (!in_array('rijndael-256', $algorightms))
- {
- return false;
- }
-
- $algorightms = hash_algos();
-
- if (!in_array('sha256', $algorightms))
- {
- return false;
- }
-
- return true;
- }
-}
diff --git a/libraries/fof/encrypt/base32.php b/libraries/fof/encrypt/base32.php
deleted file mode 100644
index b76e7ff124..0000000000
--- a/libraries/fof/encrypt/base32.php
+++ /dev/null
@@ -1,222 +0,0 @@
- 0)
- {
- throw new Exception('Length must be divisible by 8');
- }
-
- if (!preg_match('/^[01]+$/', $str))
- {
- throw new Exception('Only 0\'s and 1\'s are permitted');
- }
-
- preg_match_all('/.{8}/', $str, $chrs);
- $chrs = array_map('bindec', $chrs[0]);
-
- // I'm just being slack here
- array_unshift($chrs, 'C*');
-
- return call_user_func_array('pack', $chrs);
- }
-
- /**
- * fromBin
- *
- * Converts a correct binary string to base32
- *
- * @param string $str The string of 0's and 1's you want to convert
- *
- * @return string String encoded as base32
- *
- * @throws exception
- */
- private function fromBin($str)
- {
- if (strlen($str) % 8 > 0)
- {
- throw new Exception('Length must be divisible by 8');
- }
-
- if (!preg_match('/^[01]+$/', $str))
- {
- throw new Exception('Only 0\'s and 1\'s are permitted');
- }
-
- // Base32 works on the first 5 bits of a byte, so we insert blanks to pad it out
- $str = preg_replace('/(.{5})/', '000$1', $str);
-
- // We need a string divisible by 5
- $length = strlen($str);
- $rbits = $length & 7;
-
- if ($rbits > 0)
- {
- // Excessive bits need to be padded
- $ebits = substr($str, $length - $rbits);
- $str = substr($str, 0, $length - $rbits);
- $str .= "000$ebits" . str_repeat('0', 5 - strlen($ebits));
- }
-
- preg_match_all('/.{8}/', $str, $chrs);
- $chrs = array_map(array($this, '_mapcharset'), $chrs[0]);
-
- return join('', $chrs);
- }
-
- /**
- * toBin
- *
- * Accepts a base32 string and returns an ascii binary string
- *
- * @param string $str The base32 string to convert
- *
- * @return string Ascii binary string
- *
- * @throws Exception
- */
- private function toBin($str)
- {
- if (!preg_match('/^[' . self::CSRFC3548 . ']+$/', $str))
- {
- throw new Exception('Must match character set');
- }
-
- // Convert the base32 string back to a binary string
- $str = join('', array_map(array($this, '_mapbin'), str_split($str)));
-
- // Remove the extra 0's we added
- $str = preg_replace('/000(.{5})/', '$1', $str);
-
- // Unpad if nessicary
- $length = strlen($str);
- $rbits = $length & 7;
-
- if ($rbits > 0)
- {
- $str = substr($str, 0, $length - $rbits);
- }
-
- return $str;
- }
-
- /**
- * fromString
- *
- * Convert any string to a base32 string
- * This should be binary safe...
- *
- * @param string $str The string to convert
- *
- * @return string The converted base32 string
- */
- public function encode($str)
- {
- return $this->fromBin($this->str2bin($str));
- }
-
- /**
- * toString
- *
- * Convert any base32 string to a normal sctring
- * This should be binary safe...
- *
- * @param string $str The base32 string to convert
- *
- * @return string The normal string
- */
- public function decode($str)
- {
- $str = strtoupper($str);
-
- return $this->bin2str($this->tobin($str));
- }
-
- /**
- * _mapcharset
- *
- * Used with array_map to map the bits from a binary string
- * directly into a base32 character set
- *
- * @param string $str The string of 0's and 1's you want to convert
- *
- * @return string Resulting base32 character
- *
- * @access private
- */
- private function _mapcharset($str)
- {
- // Huh!
- $x = self::CSRFC3548;
-
- return $x[bindec($str)];
- }
-
- /**
- * _mapbin
- *
- * Used with array_map to map the characters from a base32
- * character set directly into a binary string
- *
- * @param string $chr The caracter to map
- *
- * @return string String of 0's and 1's
- *
- * @access private
- */
- private function _mapbin($chr)
- {
- return sprintf('%08b', strpos(self::CSRFC3548, $chr));
- }
-}
diff --git a/libraries/fof/encrypt/totp.php b/libraries/fof/encrypt/totp.php
deleted file mode 100644
index d291471453..0000000000
--- a/libraries/fof/encrypt/totp.php
+++ /dev/null
@@ -1,181 +0,0 @@
-_timeStep = $timeStep;
- $this->_passCodeLength = $passCodeLength;
- $this->_secretLength = $secretLength;
- $this->_pinModulo = pow(10, $this->_passCodeLength);
-
- if (is_null($base32))
- {
- $this->_base32 = new FOFEncryptBase32;
- }
- else
- {
- $this->_base32 = $base32;
- }
- }
-
- /**
- * Get the time period based on the $time timestamp and the Time Step
- * defined. If $time is skipped or set to null the current timestamp will
- * be used.
- *
- * @param int|null $time Timestamp
- *
- * @return int The time period since the UNIX Epoch
- */
- public function getPeriod($time = null)
- {
- if (is_null($time))
- {
- $time = time();
- }
-
- $period = floor($time / $this->_timeStep);
-
- return $period;
- }
-
- /**
- * Check is the given passcode $code is a valid TOTP generated using secret
- * key $secret
- *
- * @param string $secret The Base32-encoded secret key
- * @param string $code The passcode to check
- *
- * @return boolean True if the code is valid
- */
- public function checkCode($secret, $code)
- {
- $time = $this->getPeriod();
-
- for ($i = -1; $i <= 1; $i++)
- {
- if ($this->getCode($secret, ($time + $i) * $this->_timeStep) == $code)
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Gets the TOTP passcode for a given secret key $secret and a given UNIX
- * timestamp $time
- *
- * @param string $secret The Base32-encoded secret key
- * @param int $time UNIX timestamp
- *
- * @return string
- */
- public function getCode($secret, $time = null)
- {
- $period = $this->getPeriod($time);
- $secret = $this->_base32->decode($secret);
-
- $time = pack("N", $period);
- $time = str_pad($time, 8, chr(0), STR_PAD_LEFT);
-
- $hash = hash_hmac('sha1', $time, $secret, true);
- $offset = ord(substr($hash, -1));
- $offset = $offset & 0xF;
-
- $truncatedHash = $this->hashToInt($hash, $offset) & 0x7FFFFFFF;
- $pinValue = str_pad($truncatedHash % $this->_pinModulo, $this->_passCodeLength, "0", STR_PAD_LEFT);
-
- return $pinValue;
- }
-
- /**
- * Extracts a part of a hash as an integer
- *
- * @param string $bytes The hash
- * @param string $start The char to start from (0 = first char)
- *
- * @return string
- */
- protected function hashToInt($bytes, $start)
- {
- $input = substr($bytes, $start, strlen($bytes) - $start);
- $val2 = unpack("N", substr($input, 0, 4));
-
- return $val2[1];
- }
-
- /**
- * Returns a QR code URL for easy setup of TOTP apps like Google Authenticator
- *
- * @param string $user User
- * @param string $hostname Hostname
- * @param string $secret Secret string
- *
- * @return string
- */
- public function getUrl($user, $hostname, $secret)
- {
- $url = sprintf("otpauth://totp/%s@%s?secret=%s", $user, $hostname, $secret);
- $encoder = "https://chart.googleapis.com/chart?chs=200x200&chld=Q|2&cht=qr&chl=";
- $encoderURL = $encoder . urlencode($url);
-
- return $encoderURL;
- }
-
- /**
- * Generates a (semi-)random Secret Key for TOTP generation
- *
- * @return string
- */
- public function generateSecret()
- {
- $secret = "";
-
- for ($i = 1; $i <= $this->_secretLength; $i++)
- {
- $c = rand(0, 255);
- $secret .= pack("c", $c);
- }
- $base32 = new FOFEncryptBase32;
-
- return $this->_base32->encode($secret);
- }
-}
diff --git a/libraries/fof/form/field.php b/libraries/fof/form/field.php
deleted file mode 100644
index aaffd32eab..0000000000
--- a/libraries/fof/form/field.php
+++ /dev/null
@@ -1,38 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- $params = $this->getOptions();
-
- $db = FOFPlatform::getInstance()->getDbo();
- $query = $db->getQuery(true);
-
- $query->select('a.id AS value, a.title AS text');
- $query->from('#__viewlevels AS a');
- $query->group('a.id, a.title, a.ordering');
- $query->order('a.ordering ASC');
- $query->order($query->qn('title') . ' ASC');
-
- // Get the options.
- $db->setQuery($query);
- $options = $db->loadObjectList();
-
- // If params is an array, push these options to the array
- if (is_array($params))
- {
- $options = array_merge($params, $options);
- }
-
- // If all levels is allowed, push it into the array.
- elseif ($params)
- {
- array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
- }
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($options, $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- $params = $this->getOptions();
-
- $db = FOFPlatform::getInstance()->getDbo();
- $query = $db->getQuery(true);
-
- $query->select('a.id AS value, a.title AS text');
- $query->from('#__viewlevels AS a');
- $query->group('a.id, a.title, a.ordering');
- $query->order('a.ordering ASC');
- $query->order($query->qn('title') . ' ASC');
-
- // Get the options.
- $db->setQuery($query);
- $options = $db->loadObjectList();
-
- // If params is an array, push these options to the array
- if (is_array($params))
- {
- $options = array_merge($params, $options);
- }
-
- // If all levels is allowed, push it into the array.
- elseif ($params)
- {
- array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
- }
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($options, $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/actions.php b/libraries/fof/form/field/actions.php
deleted file mode 100644
index 0118e01202..0000000000
--- a/libraries/fof/form/field/actions.php
+++ /dev/null
@@ -1,253 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the field configuration
- *
- * @return array
- */
- protected function getConfig()
- {
- // If no custom options were defined let's figure out which ones of the
- // defaults we shall use...
- $config = array(
- 'published' => 1,
- 'unpublished' => 1,
- 'archived' => 0,
- 'trash' => 0,
- 'all' => 0,
- );
-
- $stack = array();
-
- if (isset($this->element['show_published']))
- {
- $config['published'] = FOFStringUtils::toBool($this->element['show_published']);
- }
-
- if (isset($this->element['show_unpublished']))
- {
- $config['unpublished'] = FOFStringUtils::toBool($this->element['show_unpublished']);
- }
-
- if (isset($this->element['show_archived']))
- {
- $config['archived'] = FOFStringUtils::toBool($this->element['show_archived']);
- }
-
- if (isset($this->element['show_trash']))
- {
- $config['trash'] = FOFStringUtils::toBool($this->element['show_trash']);
- }
-
- if (isset($this->element['show_all']))
- {
- $config['all'] = FOFStringUtils::toBool($this->element['show_all']);
- }
-
- return $config;
- }
-
- /**
- * Method to get the field options.
- *
- * @since 2.0
- *
- * @return array The field option objects.
- */
- protected function getOptions()
- {
- return null;
- }
-
- /**
- * Method to get a
- *
- * @param string $enabledFieldName Name of the enabled/published field
- *
- * @return FOFFormFieldPublished Field
- */
- protected function getPublishedField($enabledFieldName)
- {
- $attributes = array(
- 'name' => $enabledFieldName,
- 'type' => 'published',
- );
-
- if ($this->element['publish_up'])
- {
- $attributes['publish_up'] = (string) $this->element['publish_up'];
- }
-
- if ($this->element['publish_down'])
- {
- $attributes['publish_down'] = (string) $this->element['publish_down'];
- }
-
- foreach ($attributes as $name => $value)
- {
- if (!is_null($value))
- {
- $renderedAttributes[] = $name . '="' . $value . '"';
- }
- }
-
- $publishedXml = new SimpleXMLElement('');
-
- $publishedField = new FOFFormFieldPublished($this->form);
-
- // Pass required objects to the field
- $publishedField->item = $this->item;
- $publishedField->rowid = $this->rowid;
- $publishedField->setup($publishedXml, $this->item->{$enabledFieldName});
-
- return $publishedField;
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- throw new Exception(__CLASS__ . ' cannot be used in single item display forms');
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- if (!($this->item instanceof FOFTable))
- {
- throw new Exception(__CLASS__ . ' needs a FOFTable to act upon');
- }
-
- $config = $this->getConfig();
-
- // Initialise
- $prefix = '';
- $checkbox = 'cb';
- $publish_up = null;
- $publish_down = null;
- $enabled = true;
-
- $html = '
';
-
- return $html;
- }
-}
diff --git a/libraries/fof/form/field/button.php b/libraries/fof/form/field/button.php
deleted file mode 100644
index 5eddc81445..0000000000
--- a/libraries/fof/form/field/button.php
+++ /dev/null
@@ -1,102 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getInput()
- {
- $this->label = '';
-
- $text = $this->element['text'];
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
- $icon = $this->element['icon'] ? (string) $this->element['icon'] : '';
- $onclick = $this->element['onclick'] ? 'onclick="' . (string) $this->element['onclick'] . '"' : '';
-
- $this->value = JText::_($text);
-
- if ($icon)
- {
- $icon = '';
- }
-
- return '';
- }
-
- /**
- * Method to get the field title.
- *
- * @return string The field title.
- */
- protected function getTitle()
- {
- return null;
- }
-}
diff --git a/libraries/fof/form/field/cachehandler.php b/libraries/fof/form/field/cachehandler.php
deleted file mode 100644
index 883aef5f1f..0000000000
--- a/libraries/fof/form/field/cachehandler.php
+++ /dev/null
@@ -1,105 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/calendar.php b/libraries/fof/form/field/calendar.php
deleted file mode 100644
index d9b360b4aa..0000000000
--- a/libraries/fof/form/field/calendar.php
+++ /dev/null
@@ -1,209 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- return $this->getCalendar('static');
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- return $this->getCalendar('repeatable');
- }
-
- /**
- * Method to get the calendar input markup.
- *
- * @param string $display The display to render ('static' or 'repeatable')
- *
- * @return string The field input markup.
- *
- * @since 2.1.rc4
- */
- protected function getCalendar($display)
- {
- // Initialize some field attributes.
- $format = $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d';
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
- $default = $this->element['default'] ? (string) $this->element['default'] : '';
-
- // PHP date doesn't use percentages (%) for the format, but the calendar Javascript
- // DOES use it (@see: calendar-uncompressed.js). Therefore we have to convert it.
- $formatJS = $format;
- $formatPHP = str_replace(array('%', 'H:M:S'), array('', 'H:i:s'), $formatJS);
-
- // Check for empty date values
- if (empty($this->value) || $this->value == '0000-00-00 00:00:00' || $this->value == '0000-00-00')
- {
- if ($default == 'now')
- {
- $this->value = $default;
- }
- else
- {
- $this->value = 0;
- }
- }
-
- // Get some system objects.
- $config = FOFPlatform::getInstance()->getConfig();
- $user = JFactory::getUser();
- $date = FOFPlatform::getInstance()->getDate($this->value, 'UTC');
-
- // If a known filter is given use it.
- switch (strtoupper((string) $this->element['filter']))
- {
- case 'SERVER_UTC':
- // Convert a date to UTC based on the server timezone.
- if ((int) $this->value)
- {
- // Get a date object based on the correct timezone.
- $date->setTimezone(new DateTimeZone($config->get('offset')));
- }
- break;
-
- case 'USER_UTC':
- // Convert a date to UTC based on the user timezone.
- if ((int) $this->value)
- {
- // Get a date object based on the correct timezone.
- $date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
- }
- break;
-
- default:
- break;
- }
-
- // Transform the date string.
- $this->value = $date->format($formatPHP, true, false);
-
- if ($display == 'static')
- {
- // Build the attributes array.
- $attributes = array();
-
- if ($this->element['size'])
- {
- $attributes['size'] = (int) $this->element['size'];
- }
- if ($this->element['maxlength'])
- {
- $attributes['maxlength'] = (int) $this->element['maxlength'];
- }
- if ($this->element['class'])
- {
- $attributes['class'] = (string) $this->element['class'];
- }
- if ((string) $this->element['readonly'] == 'true')
- {
- $attributes['readonly'] = 'readonly';
- }
- if ((string) $this->element['disabled'] == 'true')
- {
- $attributes['disabled'] = 'disabled';
- }
- if ($this->element['onchange'])
- {
- $attributes['onchange'] = (string) $this->element['onchange'];
- }
- if ($this->required)
- {
- $attributes['required'] = 'required';
- $attributes['aria-required'] = 'true';
- }
-
- return JHtml::_('calendar', $this->value, $this->name, $this->id, $formatJS, $attributes);
- }
- else
- {
- return '' .
- htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
- '';
- }
- }
-}
diff --git a/libraries/fof/form/field/captcha.php b/libraries/fof/form/field/captcha.php
deleted file mode 100644
index 254749dbe6..0000000000
--- a/libraries/fof/form/field/captcha.php
+++ /dev/null
@@ -1,93 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- return $this->getInput();
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- return $this->getInput();
- }
-}
diff --git a/libraries/fof/form/field/checkbox.php b/libraries/fof/form/field/checkbox.php
deleted file mode 100644
index 5d74f4f1ec..0000000000
--- a/libraries/fof/form/field/checkbox.php
+++ /dev/null
@@ -1,132 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
- $value = $this->element['value'] ? (string) $this->element['value'] : '1';
- $disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
- $onclick = $this->element['onclick'] ? ' onclick="' . (string) $this->element['onclick'] . '"' : '';
- $required = $this->required ? ' required="required" aria-required="true"' : '';
-
- if (empty($this->value))
- {
- $checked = (isset($this->element['checked'])) ? ' checked="checked"' : '';
- }
- else
- {
- $checked = ' checked="checked"';
- }
-
- return '' .
- '' .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
- $value = $this->element['value'] ? (string) $this->element['value'] : '1';
- $disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
- $onclick = $this->element['onclick'] ? ' onclick="' . (string) $this->element['onclick'] . '"' : '';
- $required = $this->required ? ' required="required" aria-required="true"' : '';
-
- if (empty($this->value))
- {
- $checked = (isset($this->element['checked'])) ? ' checked="checked"' : '';
- }
- else
- {
- $checked = ' checked="checked"';
- }
-
- return '' .
- '' .
- '';
- }
-}
diff --git a/libraries/fof/form/field/components.php b/libraries/fof/form/field/components.php
deleted file mode 100644
index 9a23e877f1..0000000000
--- a/libraries/fof/form/field/components.php
+++ /dev/null
@@ -1,240 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.1
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.1
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get a list of all installed components and also translates them.
- *
- * The manifest_cache is used to get the extension names, since JInstaller is also
- * translating those names in stead of the name column. Else some of the translations
- * fails.
- *
- * @since 2.1
- *
- * @return array An array of JHtml options.
- */
- protected function getOptions()
- {
- $db = FOFPlatform::getInstance()->getDbo();
-
- // Check for client_ids override
- if ($this->client_ids !== null)
- {
- $client_ids = $this->client_ids;
- }
- else
- {
- $client_ids = $this->element['client_ids'];
- }
-
- $client_ids = explode(',', $client_ids);
-
- // Calculate client_ids where clause
- foreach ($client_ids as &$client_id)
- {
- $client_id = (int) trim($client_id);
- $client_id = $db->q($client_id);
- }
-
- $query = $db->getQuery(true)
- ->select(
- array(
- $db->qn('name'),
- $db->qn('element'),
- $db->qn('client_id'),
- $db->qn('manifest_cache'),
- )
- )
- ->from($db->qn('#__extensions'))
- ->where($db->qn('type') . ' = ' . $db->q('component'))
- ->where($db->qn('client_id') . ' IN (' . implode(',', $client_ids) . ')');
- $db->setQuery($query);
- $components = $db->loadObjectList('element');
-
- // Convert to array of objects, so we can use sortObjects()
- // Also translate component names with JText::_()
- $aComponents = array();
- $user = JFactory::getUser();
-
- foreach ($components as $component)
- {
- // Don't show components in the list where the user doesn't have access for
- // TODO: perhaps add an option for this
- if (!$user->authorise('core.manage', $component->element))
- {
- continue;
- }
-
- $oData = (object) array(
- 'value' => $component->element,
- 'text' => $this->translate($component, 'component')
- );
- $aComponents[$component->element] = $oData;
- }
-
- // Reorder the components array, because the alphabetical
- // ordering changed due to the JText::_() translation
- uasort(
- $aComponents,
- function ($a, $b) {
- return strcasecmp($a->text, $b->text);
- }
- );
-
- return $aComponents;
- }
-
- /**
- * Translate a list of objects with JText::_().
- *
- * @param array $item The array of objects
- * @param string $type The extension type (e.g. component)
- *
- * @since 2.1
- *
- * @return string $text The translated name of the extension
- *
- * @see administrator/com_installer/models/extension.php
- */
- public function translate($item, $type)
- {
- $platform = FOFPlatform::getInstance();
-
- // Map the manifest cache to $item. This is needed to get the name from the
- // manifest_cache and NOT from the name column, else some JText::_() translations fails.
- $mData = json_decode($item->manifest_cache);
-
- if ($mData)
- {
- foreach ($mData as $key => $value)
- {
- if ($key == 'type')
- {
- // Ignore the type field
- continue;
- }
-
- $item->$key = $value;
- }
- }
-
- $lang = $platform->getLanguage();
-
- switch ($type)
- {
- case 'component':
- $source = JPATH_ADMINISTRATOR . '/components/' . $item->element;
- $lang->load("$item->element.sys", JPATH_ADMINISTRATOR, null, false, false)
- || $lang->load("$item->element.sys", $source, null, false, false)
- || $lang->load("$item->element.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
- || $lang->load("$item->element.sys", $source, $lang->getDefault(), false, false);
- break;
- }
-
- $text = JText::_($item->name);
-
- return $text;
- }
-}
diff --git a/libraries/fof/form/field/editor.php b/libraries/fof/form/field/editor.php
deleted file mode 100644
index d8991127dc..0000000000
--- a/libraries/fof/form/field/editor.php
+++ /dev/null
@@ -1,103 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '
' . $this->value . '
';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '
' . $this->value . '
';
- }
-}
diff --git a/libraries/fof/form/field/email.php b/libraries/fof/form/field/email.php
deleted file mode 100644
index 7e890870c4..0000000000
--- a/libraries/fof/form/field/email.php
+++ /dev/null
@@ -1,176 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
- $dolink = $this->element['show_link'] == 'true';
- $empty_replacement = '';
-
- if ($this->element['empty_replacement'])
- {
- $empty_replacement = (string) $this->element['empty_replacement'];
- }
-
- if (!empty($empty_replacement) && empty($this->value))
- {
- $this->value = JText::_($empty_replacement);
- }
-
- $innerHtml = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
-
- if ($dolink)
- {
- $innerHtml = '' .
- $innerHtml . '';
- }
-
- return '' .
- $innerHtml .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- // Initialise
- $class = '';
- $show_link = false;
- $link_url = '';
- $empty_replacement = '';
-
- // Get field parameters
- if ($this->element['class'])
- {
- $class = (string) $this->element['class'];
- }
-
- if ($this->element['show_link'] == 'true')
- {
- $show_link = true;
- }
-
- if ($this->element['url'])
- {
- $link_url = $this->element['url'];
- }
- else
- {
- $link_url = 'mailto:' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
- }
-
- if ($this->element['empty_replacement'])
- {
- $empty_replacement = (string) $this->element['empty_replacement'];
- }
-
- // Get the (optionally formatted) value
- if (!empty($empty_replacement) && empty($this->value))
- {
- $this->value = JText::_($empty_replacement);
- }
-
- $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
-
- // Create the HTML
- $html = '';
-
- if ($show_link)
- {
- $html .= '';
- }
-
- $html .= $value;
-
- if ($show_link)
- {
- $html .= '';
- }
-
- $html .= '';
-
- return $html;
- }
-}
diff --git a/libraries/fof/form/field/groupedlist.php b/libraries/fof/form/field/groupedlist.php
deleted file mode 100644
index 079cfdc04d..0000000000
--- a/libraries/fof/form/field/groupedlist.php
+++ /dev/null
@@ -1,188 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- $selected = self::getOptionName($this->getGroups(), $this->value);
-
- if (is_null($selected))
- {
- $selected = array(
- 'group' => '',
- 'item' => ''
- );
- }
-
- return 'id . '-item" class="fof-groupedlist-item ' . $class . '>' .
- htmlspecialchars($selected['item'], ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- $selected = self::getOptionName($this->getGroups(), $this->value);
-
- if (is_null($selected))
- {
- $selected = array(
- 'group' => '',
- 'item' => ''
- );
- }
-
- return '' .
- htmlspecialchars($selected['group'], ENT_COMPAT, 'UTF-8') .
- '' .
- '' .
- htmlspecialchars($selected['item'], ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Gets the active option's label given an array of JHtml options
- *
- * @param array $data The JHtml options to parse
- * @param mixed $selected The currently selected value
- * @param string $groupKey Group name
- * @param string $optKey Key name
- * @param string $optText Value name
- *
- * @return mixed The label of the currently selected option
- */
- public static function getOptionName($data, $selected = null, $groupKey = 'items', $optKey = 'value', $optText = 'text')
- {
- $ret = null;
-
- foreach ($data as $dataKey => $group)
- {
- $label = $dataKey;
- $noGroup = is_int($dataKey);
-
- if (is_array($group))
- {
- $subList = $group[$groupKey];
- $label = $group[$optText];
- $noGroup = false;
- }
- elseif (is_object($group))
- {
- // Sub-list is in a property of an object
- $subList = $group->$groupKey;
- $label = $group->$optText;
- $noGroup = false;
- }
- else
- {
- throw new RuntimeException('Invalid group contents.', 1);
- }
-
- if ($noGroup)
- {
- $label = '';
- }
-
- $match = FOFFormFieldList::getOptionName($data, $selected, $optKey, $optText);
-
- if (!is_null($match))
- {
- $ret = array(
- 'group' => $label,
- 'item' => $match
- );
- break;
- }
- }
-
- return $ret;
- }
-}
diff --git a/libraries/fof/form/field/hidden.php b/libraries/fof/form/field/hidden.php
deleted file mode 100644
index d32ff7fbf6..0000000000
--- a/libraries/fof/form/field/hidden.php
+++ /dev/null
@@ -1,96 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- return $this->getInput();
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- return $this->getInput();
- }
-}
diff --git a/libraries/fof/form/field/image.php b/libraries/fof/form/field/image.php
deleted file mode 100644
index 29f8f84b41..0000000000
--- a/libraries/fof/form/field/image.php
+++ /dev/null
@@ -1,20 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $imgattr = array(
- 'id' => $this->id
- );
-
- if ($this->element['class'])
- {
- $imgattr['class'] = (string) $this->element['class'];
- }
-
- if ($this->element['style'])
- {
- $imgattr['style'] = (string) $this->element['style'];
- }
-
- if ($this->element['width'])
- {
- $imgattr['width'] = (string) $this->element['width'];
- }
-
- if ($this->element['height'])
- {
- $imgattr['height'] = (string) $this->element['height'];
- }
-
- if ($this->element['align'])
- {
- $imgattr['align'] = (string) $this->element['align'];
- }
-
- if ($this->element['rel'])
- {
- $imgattr['rel'] = (string) $this->element['rel'];
- }
-
- if ($this->element['alt'])
- {
- $alt = JText::_((string) $this->element['alt']);
- }
- else
- {
- $alt = null;
- }
-
- if ($this->element['title'])
- {
- $imgattr['title'] = JText::_((string) $this->element['title']);
- }
-
- $path = (string) $this->element['directory'];
- $path = trim($path, '/' . DIRECTORY_SEPARATOR);
-
- if ($this->value && file_exists(JPATH_ROOT . '/' . $path . '/' . $this->value))
- {
- $src = FOFPlatform::getInstance()->URIroot() . '/' . $path . '/' . $this->value;
- }
- else
- {
- $src = '';
- }
-
- return JHtml::image($src, $alt, $imgattr);
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- return $this->getStatic();
- }
-}
diff --git a/libraries/fof/form/field/integer.php b/libraries/fof/form/field/integer.php
deleted file mode 100644
index cbb80d0e94..0000000000
--- a/libraries/fof/form/field/integer.php
+++ /dev/null
@@ -1,104 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/language.php b/libraries/fof/form/field/language.php
deleted file mode 100644
index e0e2a84888..0000000000
--- a/libraries/fof/form/field/language.php
+++ /dev/null
@@ -1,125 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Method to get the field options.
- *
- * @since 2.0
- *
- * @return array The field option objects.
- */
- protected function getOptions()
- {
- $options = parent::getOptions();
-
- $noneoption = $this->element['none'] ? $this->element['none'] : null;
-
- if ($noneoption)
- {
- array_unshift($options, JHtml::_('select.option', '*', JText::_($noneoption)));
- }
-
- return $options;
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/list.php b/libraries/fof/form/field/list.php
deleted file mode 100644
index c0de5d21df..0000000000
--- a/libraries/fof/form/field/list.php
+++ /dev/null
@@ -1,360 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(self::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $show_link = false;
- $link_url = '';
-
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- if ($this->element['show_link'] == 'true')
- {
- $show_link = true;
- }
-
- if ($this->element['url'])
- {
- $link_url = $this->element['url'];
- }
- else
- {
- $show_link = false;
- }
-
- if ($show_link && ($this->item instanceof FOFTable))
- {
- // Replace [ITEM:ID] in the URL with the item's key value (usually:
- // the auto-incrementing numeric ID)
- $keyfield = $this->item->getKeyName();
- $replace = $this->item->$keyfield;
- $link_url = str_replace('[ITEM:ID]', $replace, $link_url);
-
- // Replace the [ITEMID] in the URL with the current Itemid parameter
- $link_url = str_replace('[ITEMID]', JFactory::getApplication()->input->getInt('Itemid', 0), $link_url);
-
- // Replace other field variables in the URL
- $fields = $this->item->getFields();
-
- foreach ($fields as $fielddata)
- {
- $fieldname = $fielddata->Field;
-
- if (empty($fieldname))
- {
- $fieldname = $fielddata->column_name;
- }
-
- $search = '[ITEM:' . strtoupper($fieldname) . ']';
- $replace = $this->item->$fieldname;
- $link_url = str_replace($search, $replace, $link_url);
- }
- }
- else
- {
- $show_link = false;
- }
-
- $html = '';
-
- if ($show_link)
- {
- $html .= '';
- }
-
- $html .= htmlspecialchars(self::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8');
-
- if ($show_link)
- {
- $html .= '';
- }
-
- $html .= '';
-
- return $html;
- }
-
- /**
- * Gets the active option's label given an array of JHtml options
- *
- * @param array $data The JHtml options to parse
- * @param mixed $selected The currently selected value
- * @param string $optKey Key name
- * @param string $optText Value name
- *
- * @return mixed The label of the currently selected option
- */
- public static function getOptionName($data, $selected = null, $optKey = 'value', $optText = 'text')
- {
- $ret = null;
-
- foreach ($data as $elementKey => &$element)
- {
- if (is_array($element))
- {
- $key = $optKey === null ? $elementKey : $element[$optKey];
- $text = $element[$optText];
- }
- elseif (is_object($element))
- {
- $key = $optKey === null ? $elementKey : $element->$optKey;
- $text = $element->$optText;
- }
- else
- {
- // This is a simple associative array
- $key = $elementKey;
- $text = $element;
- }
-
- if (is_null($ret))
- {
- $ret = $text;
- }
- elseif ($selected == $key)
- {
- $ret = $text;
- }
- }
-
- return $ret;
- }
-
- /**
- * Method to get the field options.
- *
- * Ordering is disabled by default. You can enable ordering by setting the
- * 'order' element in your form field. The other order values are optional.
- *
- * - order What to order. Possible values: 'name' or 'value' (default = false)
- * - order_dir Order direction. Possible values: 'asc' = Ascending or 'desc' = Descending (default = 'asc')
- * - order_case_sensitive Order case sensitive. Possible values: 'true' or 'false' (default = false)
- *
- * @return array The field option objects.
- *
- * @since Ordering is available since FOF 2.1.b2.
- */
- protected function getOptions()
- {
- // Ordering is disabled by default for backward compatibility
- $order = false;
-
- // Set default order direction
- $order_dir = 'asc';
-
- // Set default value for case sensitive sorting
- $order_case_sensitive = false;
-
- if ($this->element['order'] && $this->element['order'] !== 'false')
- {
- $order = $this->element['order'];
- }
-
- if ($this->element['order_dir'])
- {
- $order_dir = $this->element['order_dir'];
- }
-
- if ($this->element['order_case_sensitive'])
- {
- // Override default setting when the form element value is 'true'
- if ($this->element['order_case_sensitive'] == 'true')
- {
- $order_case_sensitive = true;
- }
- }
-
- // Create a $sortOptions array in order to apply sorting
- $i = 0;
- $sortOptions = array();
-
- foreach ($this->element->children() as $option)
- {
- $name = JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname));
-
- $sortOptions[$i] = new stdClass;
- $sortOptions[$i]->option = $option;
- $sortOptions[$i]->value = $option['value'];
- $sortOptions[$i]->name = $name;
- $i++;
- }
-
- // Only order if it's set
- if ($order)
- {
- jimport('joomla.utilities.arrayhelper');
- FOFUtilsArray::sortObjects($sortOptions, $order, $order_dir == 'asc' ? 1 : -1, $order_case_sensitive, false);
- }
-
- // Initialise the options
- $options = array();
-
- // Do we have a class and method source for our options?
- $source_file = empty($this->element['source_file']) ? '' : (string) $this->element['source_file'];
- $source_class = empty($this->element['source_class']) ? '' : (string) $this->element['source_class'];
- $source_method = empty($this->element['source_method']) ? '' : (string) $this->element['source_method'];
- $source_key = empty($this->element['source_key']) ? '*' : (string) $this->element['source_key'];
- $source_value = empty($this->element['source_value']) ? '*' : (string) $this->element['source_value'];
- $source_translate = empty($this->element['source_translate']) ? 'true' : (string) $this->element['source_translate'];
- $source_translate = in_array(strtolower($source_translate), array('true','yes','1','on')) ? true : false;
-
- if ($source_class && $source_method)
- {
- // Maybe we have to load a file?
- if (!empty($source_file))
- {
- $source_file = FOFTemplateUtils::parsePath($source_file, true);
-
- if (FOFPlatform::getInstance()->getIntegrationObject('filesystem')->fileExists($source_file))
- {
- include_once $source_file;
- }
- }
-
- // Make sure the class exists
- if (class_exists($source_class, true))
- {
- // ...and so does the option
- if (in_array($source_method, get_class_methods($source_class)))
- {
- // Get the data from the class
- $source_data = $source_class::$source_method();
-
- // Loop through the data and prime the $options array
- foreach ($source_data as $k => $v)
- {
- $key = (empty($source_key) || ($source_key == '*')) ? $k : $v[$source_key];
- $value = (empty($source_value) || ($source_value == '*')) ? $v : $v[$source_value];
-
- if ($source_translate)
- {
- $value = JText::_($value);
- }
-
- $options[] = JHtml::_('select.option', $key, $value, 'value', 'text');
- }
- }
- }
- }
-
- // Get the field $options
- foreach ($sortOptions as $sortOption)
- {
- $option = $sortOption->option;
- $name = $sortOption->name;
-
- // Only add elements.
- if ($option->getName() != 'option')
- {
- continue;
- }
-
- $tmp = JHtml::_('select.option', (string) $option['value'], $name, 'value', 'text', ((string) $option['disabled'] == 'true'));
-
- // Set some option attributes.
- $tmp->class = (string) $option['class'];
-
- // Set some JavaScript option attributes.
- $tmp->onclick = (string) $option['onclick'];
-
- // Add the option object to the result set.
- $options[] = $tmp;
- }
-
- reset($options);
-
- return $options;
- }
-}
diff --git a/libraries/fof/form/field/media.php b/libraries/fof/form/field/media.php
deleted file mode 100644
index f21a8247bd..0000000000
--- a/libraries/fof/form/field/media.php
+++ /dev/null
@@ -1,153 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $imgattr = array(
- 'id' => $this->id
- );
-
- if ($this->element['class'])
- {
- $imgattr['class'] = (string) $this->element['class'];
- }
-
- if ($this->element['style'])
- {
- $imgattr['style'] = (string) $this->element['style'];
- }
-
- if ($this->element['width'])
- {
- $imgattr['width'] = (string) $this->element['width'];
- }
-
- if ($this->element['height'])
- {
- $imgattr['height'] = (string) $this->element['height'];
- }
-
- if ($this->element['align'])
- {
- $imgattr['align'] = (string) $this->element['align'];
- }
-
- if ($this->element['rel'])
- {
- $imgattr['rel'] = (string) $this->element['rel'];
- }
-
- if ($this->element['alt'])
- {
- $alt = JText::_((string) $this->element['alt']);
- }
- else
- {
- $alt = null;
- }
-
- if ($this->element['title'])
- {
- $imgattr['title'] = JText::_((string) $this->element['title']);
- }
-
- if ($this->value && file_exists(JPATH_ROOT . '/' . $this->value))
- {
- $src = FOFPlatform::getInstance()->URIroot() . $this->value;
- }
- else
- {
- $src = '';
- }
-
- return JHtml::image($src, $alt, $imgattr);
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- return $this->getStatic();
- }
-}
diff --git a/libraries/fof/form/field/model.php b/libraries/fof/form/field/model.php
deleted file mode 100644
index a3b1e75f5b..0000000000
--- a/libraries/fof/form/field/model.php
+++ /dev/null
@@ -1,274 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->id;
- $format_string = '';
- $show_link = false;
- $link_url = '';
- $empty_replacement = '';
-
- // Get field parameters
- if ($this->element['class'])
- {
- $class = (string) $this->element['class'];
- }
-
- if ($this->element['format'])
- {
- $format_string = (string) $this->element['format'];
- }
-
- if ($this->element['show_link'] == 'true')
- {
- $show_link = true;
- }
-
- if ($this->element['url'])
- {
- $link_url = $this->element['url'];
- }
- else
- {
- $show_link = false;
- }
-
- if ($show_link && ($this->item instanceof FOFTable))
- {
- // Replace [ITEM:ID] in the URL with the item's key value (usually:
- // the auto-incrementing numeric ID)
- $keyfield = $this->item->getKeyName();
- $replace = $this->item->$keyfield;
- $link_url = str_replace('[ITEM:ID]', $replace, $link_url);
-
- // Replace the [ITEMID] in the URL with the current Itemid parameter
- $link_url = str_replace('[ITEMID]', JFactory::getApplication()->input->getInt('Itemid', 0), $link_url);
-
- // Replace other field variables in the URL
- $fields = $this->item->getFields();
-
- foreach ($fields as $fielddata)
- {
- $fieldname = $fielddata->Field;
-
- if (empty($fieldname))
- {
- $fieldname = $fielddata->column_name;
- }
-
- $search = '[ITEM:' . strtoupper($fieldname) . ']';
- $replace = $this->item->$fieldname;
- $link_url = str_replace($search, $replace, $link_url);
- }
- }
- else
- {
- $show_link = false;
- }
-
- if ($this->element['empty_replacement'])
- {
- $empty_replacement = (string) $this->element['empty_replacement'];
- }
-
- $value = FOFFormFieldList::getOptionName($this->getOptions(), $this->value);
-
- // Get the (optionally formatted) value
- if (!empty($empty_replacement) && empty($value))
- {
- $value = JText::_($empty_replacement);
- }
-
- if (empty($format_string))
- {
- $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
- }
- else
- {
- $value = sprintf($format_string, $value);
- }
-
- // Create the HTML
- $html = '';
-
- if ($show_link)
- {
- $html .= '';
- }
-
- $html .= $value;
-
- if ($show_link)
- {
- $html .= '';
- }
-
- $html .= '';
-
- return $html;
- }
-
- /**
- * Method to get the field options.
- *
- * @return array The field option objects.
- */
- protected function getOptions()
- {
- $options = array();
-
- // Initialize some field attributes.
- $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
- $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
- $translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
- $applyAccess = $this->element['apply_access'] ? (string) $this->element['apply_access'] : 'false';
- $modelName = (string) $this->element['model'];
- $nonePlaceholder = (string) $this->element['none'];
-
- if (!empty($nonePlaceholder))
- {
- $options[] = JHtml::_('select.option', JText::_($nonePlaceholder), null);
- }
-
- // Process field atrtibutes
- $applyAccess = strtolower($applyAccess);
- $applyAccess = in_array($applyAccess, array('yes', 'on', 'true', '1'));
-
- // Explode model name into model name and prefix
- $parts = FOFInflector::explode($modelName);
- $mName = ucfirst(array_pop($parts));
- $mPrefix = FOFInflector::implode($parts);
-
- // Get the model object
- $config = array('savestate' => 0);
- $model = FOFModel::getTmpInstance($mName, $mPrefix, $config);
-
- if ($applyAccess)
- {
- $model->applyAccessFiltering();
- }
-
- // Process state variables
- foreach ($this->element->children() as $stateoption)
- {
- // Only add elements.
- if ($stateoption->getName() != 'state')
- {
- continue;
- }
-
- $stateKey = (string) $stateoption['key'];
- $stateValue = (string) $stateoption;
-
- $model->setState($stateKey, $stateValue);
- }
-
- // Set the query and get the result list.
- $items = $model->getItemList(true);
-
- // Build the field options.
- if (!empty($items))
- {
- foreach ($items as $item)
- {
- if ($translate == true)
- {
- $options[] = JHtml::_('select.option', $item->$key, JText::_($item->$value));
- }
- else
- {
- $options[] = JHtml::_('select.option', $item->$key, $item->$value);
- }
- }
- }
-
- // Merge any additional options in the XML definition.
- $options = array_merge(parent::getOptions(), $options);
-
- return $options;
- }
-}
diff --git a/libraries/fof/form/field/ordering.php b/libraries/fof/form/field/ordering.php
deleted file mode 100644
index c938c5a96b..0000000000
--- a/libraries/fof/form/field/ordering.php
+++ /dev/null
@@ -1,162 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Method to get the field input markup for this field type.
- *
- * @since 2.0
- *
- * @return string The field input markup.
- */
- protected function getInput()
- {
- throw new Exception(__CLASS__ . ' cannot be used in input forms');
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- throw new Exception(__CLASS__ . ' cannot be used in single item display forms');
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- if (!($this->item instanceof FOFTable))
- {
- throw new Exception(__CLASS__ . ' needs a FOFTable to act upon');
- }
-
- $html = '';
-
- $viewObject = $this->form->getView();
-
- $ordering = $viewObject->getLists()->order == 'ordering';
-
- if (!$viewObject->hasAjaxOrderingSupport())
- {
- // Ye olde Joomla! 2.5 method
- $disabled = $ordering ? '' : 'disabled="disabled"';
- $html .= '';
- $html .= $viewObject->pagination->orderUpIcon($this->rowid, true, 'orderup', 'Move Up', $ordering);
- $html .= '';
- $html .= $viewObject->pagination->orderDownIcon($this->rowid, $viewObject->pagination->total, true, 'orderdown', 'Move Down', $ordering);
- $html .= '';
- $html .= 'getPerms()->editstate)
- {
- $disableClassName = '';
- $disabledLabel = '';
-
- $hasAjaxOrderingSupport = $viewObject->hasAjaxOrderingSupport();
-
- if (!$hasAjaxOrderingSupport['saveOrder'])
- {
- $disabledLabel = JText::_('JORDERINGDISABLED');
- $disableClassName = 'inactive tip-top';
- }
-
- $html .= '';
- $html .= '';
- $html .= '';
- $html .= 'value . '" class="input-mini text-area-order " />';
- }
- else
- {
- $html .= '';
- $html .= '';
- $html .= '';
- }
- }
-
- return $html;
- }
-}
diff --git a/libraries/fof/form/field/password.php b/libraries/fof/form/field/password.php
deleted file mode 100644
index 48881ea5a1..0000000000
--- a/libraries/fof/form/field/password.php
+++ /dev/null
@@ -1,104 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/plugins.php b/libraries/fof/form/field/plugins.php
deleted file mode 100644
index fde254d840..0000000000
--- a/libraries/fof/form/field/plugins.php
+++ /dev/null
@@ -1,104 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/published.php b/libraries/fof/form/field/published.php
deleted file mode 100644
index 219c4694f0..0000000000
--- a/libraries/fof/form/field/published.php
+++ /dev/null
@@ -1,219 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Method to get the field options.
- *
- * @since 2.0
- *
- * @return array The field option objects.
- */
- protected function getOptions()
- {
- $options = parent::getOptions();
-
- if (!empty($options))
- {
- return $options;
- }
-
- // If no custom options were defined let's figure out which ones of the
- // defaults we shall use...
-
- $config = array(
- 'published' => 1,
- 'unpublished' => 1,
- 'archived' => 0,
- 'trash' => 0,
- 'all' => 0,
- );
-
- $configMap = array(
- 'show_published' => array('published', 1),
- 'show_unpublished' => array('unpublished', 1),
- 'show_archived' => array('archived', 0),
- 'show_trash' => array('trash', 0),
- 'show_all' => array('all', 0),
- );
-
- foreach ($configMap as $attribute => $preferences)
- {
- list($configKey, $default) = $preferences;
-
- switch (strtolower($this->element[$attribute]))
- {
- case 'true':
- case '1':
- case 'yes':
- $config[$configKey] = true;
-
- case 'false':
- case '0':
- case 'no':
- $config[$configKey] = false;
-
- default:
- $config[$configKey] = $default;
- }
- }
-
- if ($config['published'])
- {
- $stack[] = JHtml::_('select.option', '1', JText::_('JPUBLISHED'));
- }
-
- if ($config['unpublished'])
- {
- $stack[] = JHtml::_('select.option', '0', JText::_('JUNPUBLISHED'));
- }
-
- if ($config['archived'])
- {
- $stack[] = JHtml::_('select.option', '2', JText::_('JARCHIVED'));
- }
-
- if ($config['trash'])
- {
- $stack[] = JHtml::_('select.option', '-2', JText::_('JTRASHED'));
- }
-
- if ($config['all'])
- {
- $stack[] = JHtml::_('select.option', '*', JText::_('JALL'));
- }
-
- return $stack;
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- if (!($this->item instanceof FOFTable))
- {
- throw new Exception(__CLASS__ . ' needs a FOFTable to act upon');
- }
-
- // Initialise
- $prefix = '';
- $checkbox = 'cb';
- $publish_up = null;
- $publish_down = null;
- $enabled = true;
-
- // Get options
- if ($this->element['prefix'])
- {
- $prefix = (string) $this->element['prefix'];
- }
-
- if ($this->element['checkbox'])
- {
- $checkbox = (string) $this->element['checkbox'];
- }
-
- if ($this->element['publish_up'])
- {
- $publish_up = (string) $this->element['publish_up'];
- }
-
- if ($this->element['publish_down'])
- {
- $publish_down = (string) $this->element['publish_down'];
- }
-
- // @todo Enforce ACL checks to determine if the field should be enabled or not
- // Get the HTML
- return JHTML::_('jgrid.published', $this->value, $this->rowid, $prefix, $enabled, $checkbox, $publish_up, $publish_down);
- }
-}
diff --git a/libraries/fof/form/field/radio.php b/libraries/fof/form/field/radio.php
deleted file mode 100644
index ea1b0e500f..0000000000
--- a/libraries/fof/form/field/radio.php
+++ /dev/null
@@ -1,104 +0,0 @@
-static))
- {
- $this->static = $this->getStatic();
- }
-
- return $this->static;
- break;
-
- case 'repeatable':
- if (empty($this->repeatable))
- {
- $this->repeatable = $this->getRepeatable();
- }
-
- return $this->static;
- break;
-
- default:
- return parent::__get($name);
- }
- }
-
- /**
- * Get the rendering of this field type for static display, e.g. in a single
- * item view (typically a "read" task).
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getStatic()
- {
- $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-
- /**
- * Get the rendering of this field type for a repeatable (grid) display,
- * e.g. in a view listing many item (typically a "browse" task)
- *
- * @since 2.0
- *
- * @return string The field HTML
- */
- public function getRepeatable()
- {
- $class = $this->element['class'] ? (string) $this->element['class'] : '';
-
- return '' .
- htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
- '';
- }
-}
diff --git a/libraries/fof/form/field/rules.php b/libraries/fof/form/field/rules.php
deleted file mode 100644
index 4b21ff7ec1..0000000000
--- a/libraries/fof/form/field/rules.php
+++ /dev/null
@@ -1,633 +0,0 @@
-getInput3x();
- }
- else
- {
- return $this->getInput25();
- }
- }
-
- protected function getInput25()
- {
- JHtml::_('behavior.tooltip');
-
- // Initialise some field attributes.
- $section = $this->element['section'] ? (string) $this->element['section'] : '';
- $component = $this->element['component'] ? (string) $this->element['component'] : '';
- $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
-
- // Get the actions for the asset.
- $actions = JAccess::getActions($component, $section);
-
- // Iterate over the children and add to the actions.
- foreach ($this->element->children() as $el)
- {
- if ($el->getName() == 'action')
- {
- $actions[] = (object) array('name' => (string) $el['name'], 'title' => (string) $el['title'],
- 'description' => (string) $el['description']);
- }
- }
-
- // Get the explicit rules for this asset.
- if ($section == 'component')
- {
- // Need to find the asset id by the name of the component.
- $db = FOFPlatform::getInstance()->getDbo();
- $query = $db->getQuery(true);
- $query->select($db->quoteName('id'));
- $query->from($db->quoteName('#__assets'));
- $query->where($db->quoteName('name') . ' = ' . $db->quote($component));
- $db->setQuery($query);
- $assetId = (int) $db->loadResult();
-
- if ($error = $db->getErrorMsg())
- {
- JError::raiseNotice(500, $error);
- }
- }
- else
- {
- // Find the asset id of the content.
- // Note that for global configuration, com_config injects asset_id = 1 into the form.
- $assetId = $this->form->getValue($assetField);
-
- // ==== FOF Library fix - Start ====
- // If there is no assetId (let's say we are dealing with a new record), let's ask the table
- // to give it to us. Here you should implement your logic (ie getting default permissions from
- // the component or from the category)
- if(!$assetId)
- {
- $table = $this->form->getModel()->getTable();
- $assetId = $table->getAssetParentId();
- }
- // ==== FOF Library fix - End ====
- }
-
- // Use the compact form for the content rules (deprecated).
- //if (!empty($component) && $section != 'component') {
- // return JHtml::_('rules.assetFormWidget', $actions, $assetId, $assetId ? null : $component, $this->name, $this->id);
- //}
-
- // Full width format.
-
- // Get the rules for just this asset (non-recursive).
- $assetRules = JAccess::getAssetRules($assetId);
-
- // Get the available user groups.
- $groups = $this->getUserGroups();
-
- // Build the form control.
- $curLevel = 0;
-
- // Prepare output
- $html = array();
- $html[] = '
';
- $html[] = '
' . JText::_('JLIB_RULES_SETTINGS_DESC') . '
';
- $html[] = '
';
-
- // Start a row for each user group.
- foreach ($groups as $group)
- {
- $difLevel = $group->level - $curLevel;
-
- if ($difLevel > 0)
- {
- $html[] = '
';
-
- // The calculated setting is not shown for the root group of global configuration.
- $canCalculateSettings = ($group->parent_id || !empty($component));
- if ($canCalculateSettings)
- {
- $html[] = '
';
-
- $html[] = ' ';
-
- // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
- if (($assetRule === true) && ($inheritedRule === false))
- {
- $html[] = JText::_('JLIB_RULES_CONFLICT');
- }
-
- $html[] = '
';
-
- // Build the Calculated Settings column.
- // The inherited settings column is not displayed for the root group in global configuration.
- if ($canCalculateSettings)
- {
- $html[] = '
';
-
- // This is where we show the current effective settings considering currrent group, path and cascade.
- // Check whether this is a component or global. Change the text slightly.
-
- if (JAccess::checkGroup($group->value, 'core.admin', $assetId) !== true)
- {
- if ($inheritedRule === null)
- {
- $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . '';
- }
- elseif ($inheritedRule === true)
- {
- $html[] = '' . JText::_('JLIB_RULES_ALLOWED') . '';
- }
- elseif ($inheritedRule === false)
- {
- if ($assetRule === false)
- {
- $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . '';
- }
- else
- {
- $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED')
- . '';
- }
- }
- }
- elseif (!empty($component))
- {
- $html[] = '' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
- . '';
- }
- else
- {
- // Special handling for groups that have global admin because they can't be denied.
- // The admin rights can be changed.
- if ($action->name === 'core.admin')
- {
- $html[] = '' . JText::_('JLIB_RULES_ALLOWED') . '';
- }
- elseif ($inheritedRule === false)
- {
- // Other actions cannot be changed.
- $html[] = ''
- . JText::_('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '';
- }
- else
- {
- $html[] = '' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
- . '';
- }
- }
-
- $html[] = '
';
-
- // The calculated setting is not shown for the root group of global configuration.
- $canCalculateSettings = ($group->parent_id || !empty($component));
-
- if ($canCalculateSettings)
- {
- $html[] = '
';
-
- $html[] = ' ';
-
- // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
- if (($assetRule === true) && ($inheritedRule === false))
- {
- $html[] = JText::_('JLIB_RULES_CONFLICT');
- }
-
- $html[] = '
';
-
- // Build the Calculated Settings column.
- // The inherited settings column is not displayed for the root group in global configuration.
- if ($canCalculateSettings)
- {
- $html[] = '
';
-
- // This is where we show the current effective settings considering currrent group, path and cascade.
- // Check whether this is a component or global. Change the text slightly.
-
- if (JAccess::checkGroup($group->value, 'core.admin', $assetId) !== true)
- {
- if ($inheritedRule === null)
- {
- $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . '';
- }
- elseif ($inheritedRule === true)
- {
- $html[] = '' . JText::_('JLIB_RULES_ALLOWED') . '';
- }
- elseif ($inheritedRule === false)
- {
- if ($assetRule === false)
- {
- $html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . '';
- }
- else
- {
- $html[] = ' ' . JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED')
- . '';
- }
- }
- }
- elseif (!empty($component))
- {
- $html[] = ' ' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
- . '';
- }
- else
- {
- // Special handling for groups that have global admin because they can't be denied.
- // The admin rights can be changed.
- if ($action->name === 'core.admin')
- {
- $html[] = '' . JText::_('JLIB_RULES_ALLOWED') . '';
- }
- elseif ($inheritedRule === false)
- {
- // Other actions cannot be changed.
- $html[] = ' '
- . JText::_('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '';
- }
- else
- {
- $html[] = ' ' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
- . '';
- }
- }
-
- $html[] = '