Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.217.35 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/123click/assets/ |
Upload File : |
PK ! ����6 6 include.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage include
* @copyright Copyright (C) 2010-2015 Nicholas K. Dionysopoulos
* @license GNU General Public License version 2, or later
*
* Initializes F0F
*/
defined('_JEXEC') or die();
if (!defined('F0F_INCLUDED'))
{
define('F0F_INCLUDED', '2.5.4');
// Register the F0F autoloader
require_once __DIR__ . '/autoloader/fof.php';
F0FAutoloaderFof::init();
// Register a debug log
if (defined('JDEBUG') && JDEBUG)
{
F0FPlatform::getInstance()->logAddLogger('fof.log.php');
}
}PK ! 0&0� �
view/html.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage view
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* FrameworkOnFramework HTML output class. Together with PHP-based view tempalates
* it will render your data into an HTML representation.
*
* @package FrameworkOnFramework
* @since 2.1
*/
class F0FViewHtml extends F0FViewRaw
{
/** @var bool Should I set the page title in the front-end of the site? */
public $setFrontendPageTitle = false;
/** @var string The translation key for the default page title */
public $defaultPageTitle = null;
/**
* Class constructor
*
* @param array $config 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();
}
if (isset($config['setFrontendPageTitle']))
{
$this->setFrontendPageTitle = (bool)$config['setFrontendPageTitle'];
}
if (isset($config['defaultPageTitle']))
{
$this->defaultPageTitle = $config['defaultPageTitle'];
}
parent::__construct($config);
}
/**
* Runs before rendering the view template, echoing HTML to put before the
* view template's generated HTML
*
* @return void
*/
protected function preRender()
{
$view = $this->input->getCmd('view', 'cpanel');
$task = $this->getModel()->getState('task', 'browse');
// Don't load the toolbar on CLI
if (!F0FPlatform::getInstance()->isCli())
{
$toolbar = F0FToolbar::getAnInstance($this->input->getCmd('option', 'com_foobar'), $this->config);
$toolbar->perms = $this->perms;
$toolbar->renderToolbar($view, $task, $this->input);
}
if (F0FPlatform::getInstance()->isFrontend())
{
if ($this->setFrontendPageTitle)
{
$this->setPageTitle();
}
}
$renderer = $this->getRenderer();
$renderer->preRender($view, $task, $this->input, $this->config);
}
/**
* Runs after rendering the view template, echoing HTML to put after the
* view template's generated HTML
*
* @return void
*/
protected function postRender()
{
$view = $this->input->getCmd('view', 'cpanel');
$task = $this->getModel()->getState('task', 'browse');
$renderer = $this->getRenderer();
if ($renderer instanceof F0FRenderAbstract)
{
$renderer->postRender($view, $task, $this->input, $this->config);
}
}
public function setPageTitle()
{
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$menus = $app->getMenu();
$menu = $menus->getActive();
$title = null;
// Get the option and view name
$option = empty($this->option) ? $this->input->getCmd('option', 'com_foobar') : $this->option;
$view = empty($this->view) ? $this->input->getCmd('view', $this->getName()) : $this->view;
// Get the default page title translation key
$default = empty($this->defaultPageTitle) ? $option . '_TITLE_' . $view : $this->defaultPageTitle;
$params = $app->getPageParameters($option);
// Set the default value for page_heading
if ($menu)
{
$params->def('page_heading', $params->get('page_title', $menu->title));
}
else
{
$params->def('page_heading', JText::_($default));
}
// Set the document title
$title = $params->get('page_title', '');
$sitename = $app->getCfg('sitename');
if ($title == $sitename)
{
$title = JText::_($default);
}
if (empty($title))
{
$title = $sitename;
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
$document->setTitle($title);
// Set meta
if ($params->get('menu-meta_description'))
{
$document->setDescription($params->get('menu-meta_description'));
}
if ($params->get('menu-meta_keywords'))
{
$document->setMetadata('keywords', $params->get('menu-meta_keywords'));
}
if ($params->get('robots'))
{
$document->setMetadata('robots', $params->get('robots'));
}
return $title;
}
}
PK ! 性a a
view/form.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage view
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* FrameworkOnFramework Form class. It preferrably renders an XML view template
* instead of a traditional PHP-based view template.
*
* @package FrameworkOnFramework
* @since 2.0
*/
class F0FViewForm extends F0FViewHtml
{
/** @var F0FForm The form to render */
protected $form;
/**
* Displays the view
*
* @param string $tpl The template to use
*
* @return boolean|null False if we can't render anything
*/
public function display($tpl = null)
{
$model = $this->getModel();
// Get the form
$this->form = $model->getForm();
$this->form->setModel($model);
$this->form->setView($this);
// Get the task set in the model
$task = $model->getState('task', 'browse');
// Call the relevant method
$method_name = 'on' . ucfirst($task);
if (method_exists($this, $method_name))
{
$result = $this->$method_name($tpl);
}
else
{
$result = $this->onDisplay();
}
// Bail out if we're told not to render anything
if ($result === false)
{
return;
}
// Show the view
// -- Output HTML before the view template
$this->preRender();
// -- Try to load a view template; if not exists render the form directly
$basePath = F0FPlatform::getInstance()->isBackend() ? 'admin:' : 'site:';
$basePath .= $this->config['option'] . '/';
$basePath .= $this->config['view'] . '/';
$path = $basePath . $this->getLayout();
if ($tpl)
{
$path .= '_' . $tpl;
}
$viewTemplate = $this->loadAnyTemplate($path);
// If there was no template file found, display the form
if ($viewTemplate instanceof Exception)
{
$viewTemplate = $this->getRenderedForm();
}
// -- Output the view template
echo $viewTemplate;
// -- Output HTML after the view template
$this->postRender();
}
/**
* Returns the HTML rendering of the F0FForm attached to this view. Very
* useful for customising a form page without having to meticulously hand-
* code the entire form.
*
* @return string The HTML of the rendered form
*/
public function getRenderedForm()
{
$html = '';
$renderer = $this->getRenderer();
if ($renderer instanceof F0FRenderAbstract)
{
// Load CSS and Javascript files defined in the form
$this->form->loadCSSFiles();
$this->form->loadJSFiles();
// Get the form's HTML
$html = $renderer->renderForm($this->form, $this->getModel(), $this->input);
}
return $html;
}
/**
* The event which runs when we are displaying the Add page
*
* @param string $tpl The view sub-template to use
*
* @return boolean True to allow display of the view
*/
protected function onAdd($tpl = null)
{
// Hide the main menu
JRequest::setVar('hidemainmenu', true);
// Get the model
$model = $this->getModel();
// Assign the item and form to the view
$this->item = $model->getItem();
return true;
}
}
PK ! a��*�f �f
view/view.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage view
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* FrameworkOnFramework View class. The View is the MVC component which gets the
* raw data from a Model and renders it in a way that makes sense. The usual
* rendering is HTML, but you can also output JSON, CSV, XML, or even media
* (images, videos, ...) and documents (Word, PDF, Excel...).
*
* @package FrameworkOnFramework
* @since 1.0
*/
abstract class F0FView extends F0FUtilsObject
{
/**
* The name of the view
*
* @var array
*/
protected $_name = null;
/**
* Registered models
*
* @var array
*/
protected $_models = array();
/**
* The base path of the view
*
* @var string
*/
protected $_basePath = null;
/**
* The default model
*
* @var string
*/
protected $_defaultModel = null;
/**
* Layout name
*
* @var string
*/
protected $_layout = 'default';
/**
* Layout extension
*
* @var string
*/
protected $_layoutExt = 'php';
/**
* Layout template
*
* @var string
*/
protected $_layoutTemplate = '_';
/**
* The set of search directories for resources (templates)
*
* @var array
*/
protected $_path = array('template' => array(), 'helper' => array());
/**
* The name of the default template source file.
*
* @var string
*/
protected $_template = null;
/**
* The output of the template script.
*
* @var string
*/
protected $_output = null;
/**
* Callback for escaping.
*
* @var string
* @deprecated 13.3
*/
protected $_escape = 'htmlspecialchars';
/**
* Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
*
* @var string
*/
protected $_charset = 'UTF-8';
/**
* The available renderer objects we can use to render views
*
* @var array Contains objects of the F0FRenderAbstract class
*/
public static $renderers = array();
/**
* Cache of the configuration array
*
* @var array
*/
protected $config = array();
/**
* The input object of this view
*
* @var F0FInput
*/
protected $input = null;
/**
* The chosen renderer object
*
* @var F0FRenderAbstract
*/
protected $rendererObject = null;
/**
* Should I run the pre-render step?
*
* @var boolean
*/
protected $doPreRender = true;
/**
* Should I run the post-render step?
*
* @var boolean
*/
protected $doPostRender = true;
/**
* Public constructor. Instantiates a F0FView object.
*
* @param array $config The configuration data array
*/
public function __construct($config = array())
{
// Make sure $config is an array
if (is_object($config))
{
$config = (array) $config;
}
elseif (!is_array($config))
{
$config = array();
}
// Get the input
if (array_key_exists('input', $config))
{
if ($config['input'] instanceof F0FInput)
{
$this->input = $config['input'];
}
else
{
$this->input = new F0FInput($config['input']);
}
}
else
{
$this->input = new F0FInput;
}
parent::__construct($config);
$component = 'com_foobar';
// Get the component name
if (array_key_exists('input', $config))
{
if ($config['input'] instanceof F0FInput)
{
$tmpInput = $config['input'];
}
else
{
$tmpInput = new F0FInput($config['input']);
}
$component = $tmpInput->getCmd('option', '');
}
else
{
$tmpInput = $this->input;
}
if (array_key_exists('option', $config))
{
if ($config['option'])
{
$component = $config['option'];
}
}
$config['option'] = $component;
// Get the view name
$view = null;
if (array_key_exists('input', $config))
{
$view = $tmpInput->getCmd('view', '');
}
if (array_key_exists('view', $config))
{
if ($config['view'])
{
$view = $config['view'];
}
}
$config['view'] = $view;
// Set the component and the view to the input array
if (array_key_exists('input', $config))
{
$tmpInput->set('option', $config['option']);
$tmpInput->set('view', $config['view']);
}
// Set the view name
if (array_key_exists('name', $config))
{
$this->_name = $config['name'];
}
else
{
$this->_name = $config['view'];
}
$tmpInput->set('view', $this->_name);
$config['input'] = $tmpInput;
$config['name'] = $this->_name;
$config['view'] = $this->_name;
// Get the component directories
$componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($config['option']);
// Set the charset (used by the variable escaping functions)
if (array_key_exists('charset', $config))
{
F0FPlatform::getInstance()->logDeprecated('Setting a custom charset for escaping in F0FView\'s constructor is deprecated. Override F0FView::escape() instead.');
$this->_charset = $config['charset'];
}
// User-defined escaping callback
if (array_key_exists('escape', $config))
{
$this->setEscape($config['escape']);
}
// Set a base path for use by the view
if (array_key_exists('base_path', $config))
{
$this->_basePath = $config['base_path'];
}
else
{
$this->_basePath = $componentPaths['main'];
}
// Set the default template search path
if (array_key_exists('template_path', $config))
{
// User-defined dirs
$this->_setPath('template', $config['template_path']);
}
else
{
$altView = F0FInflector::isSingular($this->getName()) ? F0FInflector::pluralize($this->getName()) : F0FInflector::singularize($this->getName());
$this->_setPath('template', $this->_basePath . '/views/' . $altView . '/tmpl');
$this->_addPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl');
}
// Set the default helper search path
if (array_key_exists('helper_path', $config))
{
// User-defined dirs
$this->_setPath('helper', $config['helper_path']);
}
else
{
$this->_setPath('helper', $this->_basePath . '/helpers');
}
// Set the layout
if (array_key_exists('layout', $config))
{
$this->setLayout($config['layout']);
}
else
{
$this->setLayout('default');
}
$this->config = $config;
if (!F0FPlatform::getInstance()->isCli())
{
$this->baseurl = F0FPlatform::getInstance()->URIbase(true);
$fallback = F0FPlatform::getInstance()->getTemplateOverridePath($component) . '/' . $this->getName();
$this->_addPath('template', $fallback);
}
}
/**
* Loads a template given any path. The path is in the format:
* [admin|site]:com_foobar/viewname/templatename
* e.g. admin:com_foobar/myview/default
*
* This function searches for Joomla! version override templates. For example,
* if you have run this under Joomla! 3.0 and you try to load
* admin:com_foobar/myview/default it will automatically search for the
* template files default.j30.php, default.j3.php and default.php, in this
* order.
*
* @param string $path See above
* @param array $forceParams A hash array of variables to be extracted in the local scope of the template file
*
* @return boolean False if loading failed
*/
public function loadAnyTemplate($path = '', $forceParams = array())
{
// Automatically check for a Joomla! version specific override
$throwErrorIfNotFound = true;
$suffixes = F0FPlatform::getInstance()->getTemplateSuffixes();
foreach ($suffixes as $suffix)
{
if (substr($path, -strlen($suffix)) == $suffix)
{
$throwErrorIfNotFound = false;
break;
}
}
if ($throwErrorIfNotFound)
{
foreach ($suffixes as $suffix)
{
$result = $this->loadAnyTemplate($path . $suffix, $forceParams);
if ($result !== false)
{
return $result;
}
}
}
$layoutTemplate = $this->getLayoutTemplate();
// Parse the path
$templateParts = $this->_parseTemplatePath($path);
// Get the paths
$componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($templateParts['component']);
$templatePath = F0FPlatform::getInstance()->getTemplateOverridePath($templateParts['component']);
// Get the default paths
$paths = array();
$paths[] = $templatePath . '/' . $templateParts['view'];
$paths[] = ($templateParts['admin'] ? $componentPaths['admin'] : $componentPaths['site']) . '/views/' . $templateParts['view'] . '/tmpl';
if (isset($this->_path) || property_exists($this, '_path'))
{
$paths = array_merge($paths, $this->_path['template']);
}
elseif (isset($this->path) || property_exists($this, 'path'))
{
$paths = array_merge($paths, $this->path['template']);
}
// Look for a template override
if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template)
{
$apath = array_shift($paths);
array_unshift($paths, str_replace($template, $layoutTemplate, $apath));
}
$filetofind = $templateParts['template'] . '.php';
$filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem');
$this->_tempFilePath = $filesystem->pathFind($paths, $filetofind);
if ($this->_tempFilePath)
{
// Unset from local scope
unset($template);
unset($layoutTemplate);
unset($paths);
unset($path);
unset($filetofind);
// Never allow a 'this' property
if (isset($this->this))
{
unset($this->this);
}
// Force parameters into scope
if (!empty($forceParams))
{
extract($forceParams);
}
// Start capturing output into a buffer
ob_start();
// Include the requested template filename in the local scope (this will execute the view logic).
include $this->_tempFilePath;
// Done with the requested template; get the buffer and clear it.
$this->_output = ob_get_contents();
ob_end_clean();
return $this->_output;
}
else
{
if ($throwErrorIfNotFound)
{
return new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $path), 500);
}
return false;
}
}
/**
* Overrides the default method to execute and display a template script.
* Instead of loadTemplate is uses loadAnyTemplate which allows for automatic
* Joomla! version overrides. A little slice of awesome pie!
*
* @param string $tpl The name of the template file to parse
*
* @return mixed A string if successful, otherwise a JError object.
*/
public function display($tpl = null)
{
F0FPlatform::getInstance()->setErrorHandling(E_ALL, 'ignore');
$result = $this->loadTemplate($tpl);
if ($result instanceof Exception)
{
F0FPlatform::getInstance()->raiseError($result->getCode(), $result->getMessage());
return $result;
}
echo $result;
}
/**
* Assigns variables to the view script via differing strategies.
*
* This method is overloaded; you can assign all the properties of
* an object, an associative array, or a single value by name.
*
* You are not allowed to set variables that begin with an underscore;
* these are either private properties for F0FView or private variables
* within the template script itself.
*
* @return boolean True on success, false on failure.
*
* @deprecated 13.3 Use native PHP syntax.
*/
public function assign()
{
F0FPlatform::getInstance()->logDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated. Use native PHP syntax.');
// Get the arguments; there may be 1 or 2.
$arg0 = @func_get_arg(0);
$arg1 = @func_get_arg(1);
// Assign by object
if (is_object($arg0))
{
// Assign public properties
foreach (get_object_vars($arg0) as $key => $val)
{
if (substr($key, 0, 1) != '_')
{
$this->$key = $val;
}
}
return true;
}
// Assign by associative array
if (is_array($arg0))
{
foreach ($arg0 as $key => $val)
{
if (substr($key, 0, 1) != '_')
{
$this->$key = $val;
}
}
return true;
}
// Assign by string name and mixed value. We use array_key_exists() instead of isset()
// because isset() fails if the value is set to null.
if (is_string($arg0) && substr($arg0, 0, 1) != '_' && func_num_args() > 1)
{
$this->$arg0 = $arg1;
return true;
}
// $arg0 was not object, array, or string.
return false;
}
/**
* Assign variable for the view (by reference).
*
* You are not allowed to set variables that begin with an underscore;
* these are either private properties for F0FView or private variables
* within the template script itself.
*
* @param string $key The name for the reference in the view.
* @param mixed &$val The referenced variable.
*
* @return boolean True on success, false on failure.
*
* @deprecated 13.3 Use native PHP syntax.
*/
public function assignRef($key, &$val)
{
F0FPlatform::getInstance()->logDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated. Use native PHP syntax.');
if (is_string($key) && substr($key, 0, 1) != '_')
{
$this->$key = &$val;
return true;
}
return false;
}
/**
* Escapes a value for output in a view script.
*
* If escaping mechanism is either htmlspecialchars or htmlentities, uses
* {@link $_encoding} setting.
*
* @param mixed $var The output to escape.
*
* @return mixed The escaped value.
*/
public function escape($var)
{
if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities')))
{
return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_charset);
}
return call_user_func($this->_escape, $var);
}
/**
* Method to get data from a registered model or a property of the view
*
* @param string $property The name of the method to call on the model or the property to get
* @param string $default The name of the model to reference or the default value [optional]
*
* @return mixed The return value of the method
*/
public function get($property, $default = null)
{
// If $model is null we use the default model
if (is_null($default))
{
$model = $this->_defaultModel;
}
else
{
$model = strtolower($default);
}
// First check to make sure the model requested exists
if (isset($this->_models[$model]))
{
// Model exists, let's build the method name
$method = 'get' . ucfirst($property);
// Does the method exist?
if (method_exists($this->_models[$model], $method))
{
// The method exists, let's call it and return what we get
$result = $this->_models[$model]->$method();
return $result;
}
}
// Degrade to F0FUtilsObject::get
$result = parent::get($property, $default);
return $result;
}
/**
* Method to get the model object
*
* @param string $name The name of the model (optional)
*
* @return mixed F0FModel object
*/
public function getModel($name = null)
{
if ($name === null)
{
$name = $this->_defaultModel;
}
return $this->_models[strtolower($name)];
}
/**
* Get the layout.
*
* @return string The layout name
*/
public function getLayout()
{
return $this->_layout;
}
/**
* Get the layout template.
*
* @return string The layout template name
*/
public function getLayoutTemplate()
{
return $this->_layoutTemplate;
}
/**
* Method to get the view name
*
* The model name by default parsed using the classname, or it can be set
* by passing a $config['name'] in the class constructor
*
* @return string The name of the model
*/
public function getName()
{
if (empty($this->_name))
{
$classname = get_class($this);
$viewpos = strpos($classname, 'View');
if ($viewpos === false)
{
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME'), 500);
}
$this->_name = strtolower(substr($classname, $viewpos + 4));
}
return $this->_name;
}
/**
* Method to add a model to the view.
*
* @param F0FMOdel $model The model to add to the view.
* @param boolean $default Is this the default model?
* @param String $name optional index name to store the model
*
* @return object The added model.
*/
public function setModel($model, $default = false, $name = null)
{
if (is_null($name))
{
$name = $model->getName();
}
$name = strtolower($name);
$this->_models[$name] = $model;
if ($default)
{
$this->_defaultModel = $name;
}
return $model;
}
/**
* Sets the layout name to use
*
* @param string $layout The layout name or a string in format <template>:<layout file>
*
* @return string Previous value.
*/
public function setLayout($layout)
{
$previous = $this->_layout;
if (strpos($layout, ':') === false)
{
$this->_layout = $layout;
}
else
{
// Convert parameter to array based on :
$temp = explode(':', $layout);
$this->_layout = $temp[1];
// Set layout template
$this->_layoutTemplate = $temp[0];
}
return $previous;
}
/**
* Allows a different extension for the layout files to be used
*
* @param string $value The extension.
*
* @return string Previous value
*/
public function setLayoutExt($value)
{
$previous = $this->_layoutExt;
if ($value = preg_replace('#[^A-Za-z0-9]#', '', trim($value)))
{
$this->_layoutExt = $value;
}
return $previous;
}
/**
* Sets the _escape() callback.
*
* @param mixed $spec The callback for _escape() to use.
*
* @return void
*
* @deprecated 2.1 Override F0FView::escape() instead.
*/
public function setEscape($spec)
{
F0FPlatform::getInstance()->logDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated. Override F0FView::escape() instead.');
$this->_escape = $spec;
}
/**
* Adds to the stack of view script paths in LIFO order.
*
* @param mixed $path A directory path or an array of paths.
*
* @return void
*/
public function addTemplatePath($path)
{
$this->_addPath('template', $path);
}
/**
* Adds to the stack of helper script paths in LIFO order.
*
* @param mixed $path A directory path or an array of paths.
*
* @return void
*/
public function addHelperPath($path)
{
$this->_addPath('helper', $path);
}
/**
* Overrides the built-in loadTemplate function with an F0F-specific one.
* Our overriden function uses loadAnyTemplate to provide smarter view
* template loading.
*
* @param string $tpl The name of the template file to parse
* @param boolean $strict Should we use strict naming, i.e. force a non-empty $tpl?
*
* @return mixed A string if successful, otherwise a JError object
*/
public function loadTemplate($tpl = null, $strict = false)
{
$paths = F0FPlatform::getInstance()->getViewTemplatePaths(
$this->input->getCmd('option', ''),
$this->input->getCmd('view', ''),
$this->getLayout(),
$tpl,
$strict
);
foreach ($paths as $path)
{
$result = $this->loadAnyTemplate($path);
if (!($result instanceof Exception))
{
break;
}
}
if ($result instanceof Exception)
{
F0FPlatform::getInstance()->raiseError($result->getCode(), $result->getMessage());
}
return $result;
}
/**
* Parses a template path in the form of admin:/component/view/layout or
* site:/component/view/layout to an array which can be used by
* loadAnyTemplate to locate and load the view template file.
*
* @param string $path The template path to parse
*
* @return array A hash array with the parsed path parts
*/
private function _parseTemplatePath($path = '')
{
$parts = array(
'admin' => 0,
'component' => $this->config['option'],
'view' => $this->config['view'],
'template' => 'default'
);
if (substr($path, 0, 6) == 'admin:')
{
$parts['admin'] = 1;
$path = substr($path, 6);
}
elseif (substr($path, 0, 5) == 'site:')
{
$path = substr($path, 5);
}
if (empty($path))
{
return;
}
$pathparts = explode('/', $path, 3);
switch (count($pathparts))
{
case 3:
$parts['component'] = array_shift($pathparts);
case 2:
$parts['view'] = array_shift($pathparts);
case 1:
$parts['template'] = array_shift($pathparts);
break;
}
return $parts;
}
/**
* Get the renderer object for this view
*
* @return F0FRenderAbstract
*/
public function &getRenderer()
{
if (!($this->rendererObject instanceof F0FRenderAbstract))
{
$this->rendererObject = $this->findRenderer();
}
return $this->rendererObject;
}
/**
* Sets the renderer object for this view
*
* @param F0FRenderAbstract &$renderer The render class to use
*
* @return void
*/
public function setRenderer(F0FRenderAbstract &$renderer)
{
$this->rendererObject = $renderer;
}
/**
* Finds a suitable renderer
*
* @return F0FRenderAbstract
*/
protected function findRenderer()
{
$filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem');
// Try loading the stock renderers shipped with F0F
if (empty(self::$renderers) || !class_exists('F0FRenderJoomla', false))
{
$path = dirname(__FILE__) . '/../render/';
$renderFiles = $filesystem->folderFiles($path, '.php');
if (!empty($renderFiles))
{
foreach ($renderFiles as $filename)
{
if ($filename == 'abstract.php')
{
continue;
}
@include_once $path . '/' . $filename;
$camel = F0FInflector::camelize($filename);
$className = 'F0FRender' . ucfirst(F0FInflector::getPart($camel, 0));
$o = new $className;
self::registerRenderer($o);
}
}
}
// Try to detect the most suitable renderer
$o = null;
$priority = 0;
if (!empty(self::$renderers))
{
foreach (self::$renderers as $r)
{
$info = $r->getInformation();
if (!$info->enabled)
{
continue;
}
if ($info->priority > $priority)
{
$priority = $info->priority;
$o = $r;
}
}
}
// Return the current renderer
return $o;
}
/**
* Registers a renderer object with the view
*
* @param F0FRenderAbstract &$renderer The render object to register
*
* @return void
*/
public static function registerRenderer(F0FRenderAbstract &$renderer)
{
self::$renderers[] = $renderer;
}
/**
* Sets the pre-render flag
*
* @param boolean $value True to enable the pre-render step
*
* @return void
*/
public function setPreRender($value)
{
$this->doPreRender = $value;
}
/**
* Sets the post-render flag
*
* @param boolean $value True to enable the post-render step
*
* @return void
*/
public function setPostRender($value)
{
$this->doPostRender = $value;
}
/**
* Load a helper file
*
* @param string $hlp The name of the helper source file automatically searches the helper paths and compiles as needed.
*
* @return void
*/
public function loadHelper($hlp = null)
{
// Clean the file name
$file = preg_replace('/[^A-Z0-9_\.-]/i', '', $hlp);
// Load the template script using the default Joomla! features
$filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem');
$helper = $filesystem->pathFind($this->_path['helper'], $this->_createFileName('helper', array('name' => $file)));
if ($helper == false)
{
$componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($this->config['option']);
$path = $componentPaths['main'] . '/helpers';
$helper = $filesystem->pathFind($path, $this->_createFileName('helper', array('name' => $file)));
if ($helper == false)
{
$path = $path = $componentPaths['alt'] . '/helpers';
$helper = $filesystem->pathFind($path, $this->_createFileName('helper', array('name' => $file)));
}
}
if ($helper != false)
{
// Include the requested template filename in the local scope
include_once $helper;
}
}
/**
* Returns the view's option (component name) and view name in an
* associative array.
*
* @return array
*/
public function getViewOptionAndName()
{
return array(
'option' => $this->config['option'],
'view' => $this->config['view'],
);
}
/**
* Sets an entire array of search paths for templates or resources.
*
* @param string $type The type of path to set, typically 'template'.
* @param mixed $path The new search path, or an array 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->_path[$type] = array();
// Actually add the user-specified directories
$this->_addPath($type, $path);
// Always add the fallback directories as last resort
switch (strtolower($type))
{
case 'template':
// Set the alternative template search dir
if (!F0FPlatform::getInstance()->isCli())
{
$fallback = F0FPlatform::getInstance()->getTemplateOverridePath($this->input->getCmd('option', '')) . '/' . $this->getName();
$this->_addPath('template', $fallback);
}
break;
}
}
/**
* Adds to the search path for templates and resources.
*
* @param string $type The type of path to add.
* @param mixed $path The directory or stream, or an array of either, to search.
*
* @return void
*/
protected function _addPath($type, $path)
{
// Just force to array
settype($path, 'array');
// Loop through the path directories
foreach ($path as $dir)
{
// No surrounding spaces allowed!
$dir = trim($dir);
// Add trailing separators as needed
if (substr($dir, -1) != DIRECTORY_SEPARATOR)
{
// Directory
$dir .= DIRECTORY_SEPARATOR;
}
// Add to the top of the search dirs
array_unshift($this->_path[$type], $dir);
}
}
/**
* 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
*
* @return string The filename
*/
protected function _createFileName($type, $parts = array())
{
$filename = '';
switch ($type)
{
case 'template':
$filename = strtolower($parts['name']) . '.' . $this->_layoutExt;
break;
default:
$filename = strtolower($parts['name']) . '.php';
break;
}
return $filename;
}
}
PK ! �Y��! �! view/raw.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage view
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* FrameworkOnFramework raw output class. It works like an HTML view, but the
* output is bare HTML.
*
* @package FrameworkOnFramework
* @since 2.1
*/
class F0FViewRaw extends F0FView
{
/** @var array Data lists */
protected $lists = null;
/** @var array Permissions map */
protected $perms = null;
/**
* Class constructor
*
* @param array $config 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();
}
parent::__construct($config);
$this->config = $config;
// Get the input
if (array_key_exists('input', $config))
{
if ($config['input'] instanceof F0FInput)
{
$this->input = $config['input'];
}
else
{
$this->input = new F0FInput($config['input']);
}
}
else
{
$this->input = new F0FInput;
}
if (!array_key_exists('option', $this->config))
{
$this->config['option'] = $this->input->getCmd('option', 'com_foobar');
}
if (!array_key_exists('view', $this->config))
{
$this->config['view'] = $this->input->getCmd('view', 'cpanel');
}
$this->lists = new F0FUtilsObject;
if (!F0FPlatform::getInstance()->isCli())
{
$platform = F0FPlatform::getInstance();
$perms = (object) array(
'create' => $platform->authorise('core.create' , $this->input->getCmd('option', 'com_foobar')),
'edit' => $platform->authorise('core.edit' , $this->input->getCmd('option', 'com_foobar')),
'editown' => $platform->authorise('core.edit.own' , $this->input->getCmd('option', 'com_foobar')),
'editstate' => $platform->authorise('core.edit.state' , $this->input->getCmd('option', 'com_foobar')),
'delete' => $platform->authorise('core.delete' , $this->input->getCmd('option', 'com_foobar')),
);
$this->aclperms = $perms;
$this->perms = $perms;
}
}
/**
* Displays the view
*
* @param string $tpl The template to use
*
* @return boolean|null False if we can't render anything
*/
public function display($tpl = null)
{
// Get the task set in the model
$model = $this->getModel();
$task = $model->getState('task', 'browse');
// Call the relevant method
$method_name = 'on' . ucfirst($task);
if (method_exists($this, $method_name))
{
$result = $this->$method_name($tpl);
}
else
{
$result = $this->onDisplay();
}
if ($result === false)
{
return;
}
// Show the view
if ($this->doPreRender)
{
$this->preRender();
}
parent::display($tpl);
if ($this->doPostRender)
{
$this->postRender();
}
}
/**
* Last chance to output something before rendering the view template
*
* @return void
*/
protected function preRender()
{
}
/**
* Last chance to output something after rendering the view template and
* before returning to the caller
*
* @return void
*/
protected function postRender()
{
}
/**
* Executes before rendering the page for the Browse task.
*
* @param string $tpl Subtemplate to use
*
* @return boolean Return true to allow rendering of the page
*/
protected function onBrowse($tpl = null)
{
// When in interactive browsing mode, save the state to the session
$this->getModel()->savestate(1);
return $this->onDisplay($tpl);
}
/**
* Executes before rendering a generic page, default to actions necessary
* for the Browse task.
*
* @param string $tpl Subtemplate to use
*
* @return boolean Return true to allow rendering of the page
*/
protected function onDisplay($tpl = null)
{
$view = $this->input->getCmd('view', 'cpanel');
if (in_array($view, array('cpanel', 'cpanels')))
{
return;
}
// Load the model
$model = $this->getModel();
// ...ordering
$this->lists->set('order', $model->getState('filter_order', 'id', 'cmd'));
$this->lists->set('order_Dir', $model->getState('filter_order_Dir', 'DESC', 'cmd'));
// Assign data to the view
$this->items = $model->getItemList();
$this->pagination = $model->getPagination();
// Pass page params on frontend only
if (F0FPlatform::getInstance()->isFrontend())
{
$params = JFactory::getApplication()->getParams();
$this->params = $params;
}
return true;
}
/**
* Executes before rendering the page for the Add task.
*
* @param string $tpl Subtemplate to use
*
* @return boolean Return true to allow rendering of the page
*/
protected function onAdd($tpl = null)
{
JRequest::setVar('hidemainmenu', true);
$model = $this->getModel();
$this->item = $model->getItem();
return true;
}
/**
* Executes before rendering the page for the Edit task.
*
* @param string $tpl Subtemplate to use
*
* @return boolean Return true to allow rendering of the page
*/
protected function onEdit($tpl = null)
{
// This perms are used only for hestetic reasons (ie showing toolbar buttons), "real" checks
// are made by the controller
// It seems that I can't edit records, maybe I can edit only this one due asset tracking?
if (!$this->perms->edit || !$this->perms->editown)
{
$model = $this->getModel();
if($model)
{
$table = $model->getTable();
// Ok, record is tracked, let's see if I can this record
if($table->isAssetsTracked())
{
$platform = F0FPlatform::getInstance();
if(!$this->perms->edit)
{
$this->perms->edit = $platform->authorise('core.edit', $table->getAssetName());
}
if(!$this->perms->editown)
{
$this->perms->editown = $platform->authorise('core.edit.own', $table->getAssetName());
}
}
}
}
return $this->onAdd($tpl);
}
/**
* Executes before rendering the page for the Read task.
*
* @param string $tpl Subtemplate to use
*
* @return boolean Return true to allow rendering of the page
*/
protected function onRead($tpl = null)
{
// All I need is to read the record
return $this->onAdd($tpl);
}
/**
* Determines if the current Joomla! version and your current table support
* AJAX-powered drag and drop reordering. If they do, it will set up the
* drag & drop reordering feature.
*
* @return boolean|array False if not suported, a table with necessary
* information (saveOrder: should you enabled DnD
* reordering; orderingColumn: which column has the
* ordering information).
*/
public function hasAjaxOrderingSupport()
{
if (version_compare(JVERSION, '3.0', 'lt'))
{
return false;
}
$model = $this->getModel();
if (!method_exists($model, 'getTable'))
{
return false;
}
$table = $this->getModel()->getTable();
if (!method_exists($table, 'getColumnAlias') || !method_exists($table, 'getTableFields'))
{
return false;
}
$orderingColumn = $table->getColumnAlias('ordering');
$fields = $table->getTableFields();
if (!is_array($fields) || !array_key_exists($orderingColumn, $fields))
{
return false;
}
$listOrder = $this->escape($model->getState('filter_order', null, 'cmd'));
$listDirn = $this->escape($model->getState('filter_order_Dir', 'ASC', 'cmd'));
$saveOrder = $listOrder == $orderingColumn;
if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=' . $this->config['option'] . '&view=' . $this->config['view'] . '&task=saveorder&format=json';
JHtml::_('sortablelist.sortable', 'itemsList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
return array(
'saveOrder' => $saveOrder,
'orderingColumn' => $orderingColumn
);
}
/**
* Returns the internal list of useful variables to the benefit of
* F0FFormHeader fields.
*
* @return array
*
* @since 2.0
*/
public function getLists()
{
return $this->lists;
}
/**
* Returns a reference to the permissions object of this view
*
* @return stdClass
*/
public function getPerms()
{
return $this->perms;
}
}
PK ! �V;� � view/csv.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage view
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* FrameworkOnFramework CSV View class. Automatically renders the data in CSV
* format.
*
* @package FrameworkOnFramework
* @since 1.0
*/
class F0FViewCsv extends F0FViewHtml
{
/**
* Should I produce a CSV header row.
*
* @var boolean
*/
protected $csvHeader = true;
/**
* The filename of the downloaded CSV file.
*
* @var string
*/
protected $csvFilename = null;
/**
* The columns to include in the CSV output. If it's empty it will be ignored.
*
* @var array
*/
protected $csvFields = array();
/**
* Public constructor. Instantiates a F0FViewCsv object.
*
* @param array $config The configuration data array
*/
public function __construct($config = array())
{
// Make sure $config is an array
if (is_object($config))
{
$config = (array) $config;
}
elseif (!is_array($config))
{
$config = array();
}
parent::__construct($config);
if (array_key_exists('csv_header', $config))
{
$this->csvHeader = $config['csv_header'];
}
else
{
$this->csvHeader = $this->input->getBool('csv_header', true);
}
if (array_key_exists('csv_filename', $config))
{
$this->csvFilename = $config['csv_filename'];
}
else
{
$this->csvFilename = $this->input->getString('csv_filename', '');
}
if (empty($this->csvFilename))
{
$view = $this->input->getCmd('view', 'cpanel');
$view = F0FInflector::pluralize($view);
$this->csvFilename = strtolower($view);
}
if (array_key_exists('csv_fields', $config))
{
$this->csvFields = $config['csv_fields'];
}
}
/**
* Executes before rendering a generic page, default to actions necessary for the Browse task.
*
* @param string $tpl Subtemplate to use
*
* @return boolean Return true to allow rendering of the page
*/
protected function onDisplay($tpl = null)
{
// Load the model
$model = $this->getModel();
$items = $model->getItemList();
$this->items = $items;
$platform = F0FPlatform::getInstance();
$document = $platform->getDocument();
if ($document instanceof JDocument)
{
$document->setMimeEncoding('text/csv');
}
$platform->setHeader('Pragma', 'public');
$platform->setHeader('Expires', '0');
$platform->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
$platform->setHeader('Cache-Control', 'public', false);
$platform->setHeader('Content-Description', 'File Transfer');
$platform->setHeader('Content-Disposition', 'attachment; filename="' . $this->csvFilename . '"');
if (is_null($tpl))
{
$tpl = 'csv';
}
F0FPlatform::getInstance()->setErrorHandling(E_ALL, 'ignore');
$hasFailed = false;
try
{
$result = $this->loadTemplate($tpl, true);
if ($result instanceof Exception)
{
$hasFailed = true;
}
}
catch (Exception $e)
{
$hasFailed = true;
}
if (!$hasFailed)
{
echo $result;
}
else
{
// Default CSV behaviour in case the template isn't there!
if (empty($items))
{
return;
}
$item = array_pop($items);
$keys = get_object_vars($item);
$keys = array_keys($keys);
$items[] = $item;
reset($items);
if (!empty($this->csvFields))
{
$temp = array();
foreach ($this->csvFields as $f)
{
if (in_array($f, $keys))
{
$temp[] = $f;
}
}
$keys = $temp;
}
if ($this->csvHeader)
{
$csv = array();
foreach ($keys as $k)
{
$k = str_replace('"', '""', $k);
$k = str_replace("\r", '\\r', $k);
$k = str_replace("\n", '\\n', $k);
$k = '"' . $k . '"';
$csv[] = $k;
}
echo implode(",", $csv) . "\r\n";
}
foreach ($items as $item)
{
$csv = array();
$item = (array) $item;
foreach ($keys as $k)
{
if (!isset($item[$k]))
{
$v = '';
}
else
{
$v = $item[$k];
}
if (is_array($v))
{
$v = 'Array';
}
elseif (is_object($v))
{
$v = 'Object';
}
$v = str_replace('"', '""', $v);
$v = str_replace("\r", '\\r', $v);
$v = str_replace("\n", '\\n', $v);
$v = '"' . $v . '"';
$csv[] = $v;
}
echo implode(",", $csv) . "\r\n";
}
}
return false;
}
}
PK ! ���( (
view/json.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage view
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* FrameworkOnFramework JSON View class. Renders the data as a JSON object or
* array. It can optionally output HAL links as well.
*
* @package FrameworkOnFramework
* @since 2.0
*/
class F0FViewJson extends F0FViewHtml
{
/**
* When set to true we'll add hypermedia to the output, implementing the
* HAL specification (http://stateless.co/hal_specification.html)
*
* @var boolean
*/
public $useHypermedia = false;
/**
* Public constructor
*
* @param array $config The component's configuration array
*/
public function __construct($config = array())
{
parent::__construct($config);
if (isset($config['use_hypermedia']))
{
$this->useHypermedia = (bool) $config['use_hypermedia'];
}
}
/**
* The event which runs when we are displaying the record list JSON view
*
* @param string $tpl The view sub-template to use
*
* @return boolean True to allow display of the view
*/
protected function onDisplay($tpl = null)
{
// Load the model
$model = $this->getModel();
$items = $model->getItemList();
$this->items = $items;
$document = F0FPlatform::getInstance()->getDocument();
if ($document instanceof JDocument)
{
if ($this->useHypermedia)
{
$document->setMimeEncoding('application/hal+json');
}
else
{
$document->setMimeEncoding('application/json');
}
}
if (is_null($tpl))
{
$tpl = 'json';
}
F0FPlatform::getInstance()->setErrorHandling(E_ALL, 'ignore');
$hasFailed = false;
try
{
$result = $this->loadTemplate($tpl, true);
if ($result instanceof Exception)
{
$hasFailed = true;
}
}
catch (Exception $e)
{
$hasFailed = true;
}
if ($hasFailed)
{
// Default JSON behaviour in case the template isn't there!
if ($this->useHypermedia)
{
$haldocument = $this->_createDocumentWithHypermedia($items, $model);
$json = $haldocument->render('json');
}
else
{
$json = json_encode($items);
}
// JSONP support
$callback = $this->input->get('callback', null, 'raw');
if (!empty($callback))
{
echo $callback . '(' . $json . ')';
}
else
{
$defaultName = $this->input->getCmd('view', 'joomla');
$filename = $this->input->getCmd('basename', $defaultName);
$document->setName($filename);
echo $json;
}
return false;
}
else
{
echo $result;
return false;
}
}
/**
* The event which runs when we are displaying a single item JSON view
*
* @param string $tpl The view sub-template to use
*
* @return boolean True to allow display of the view
*/
protected function onRead($tpl = null)
{
$model = $this->getModel();
$item = $model->getItem();
$this->item = $item;
$document = F0FPlatform::getInstance()->getDocument();
if ($document instanceof JDocument)
{
if ($this->useHypermedia)
{
$document->setMimeEncoding('application/hal+json');
}
else
{
$document->setMimeEncoding('application/json');
}
}
if (is_null($tpl))
{
$tpl = 'json';
}
F0FPlatform::getInstance()->setErrorHandling(E_ALL, 'ignore');
$hasFailed = false;
try
{
$result = $this->loadTemplate($tpl, true);
if ($result instanceof Exception)
{
$hasFailed = true;
}
}
catch (Exception $e)
{
$hasFailed = true;
}
if ($hasFailed)
{
// Default JSON behaviour in case the template isn't there!
if ($this->useHypermedia)
{
$haldocument = $this->_createDocumentWithHypermedia($item, $model);
$json = $haldocument->render('json');
}
else
{
$json = json_encode($item);
}
// JSONP support
$callback = $this->input->get('callback', null);
if (!empty($callback))
{
echo $callback . '(' . $json . ')';
}
else
{
$defaultName = $this->input->getCmd('view', 'joomla');
$filename = $this->input->getCmd('basename', $defaultName);
$document->setName($filename);
echo $json;
}
return false;
}
else
{
echo $result;
return false;
}
}
/**
* Creates a F0FHalDocument using the provided data
*
* @param array $data The data to put in the document
* @param F0FModel $model The model of this view
*
* @return F0FHalDocument A HAL-enabled document
*/
protected function _createDocumentWithHypermedia($data, $model = null)
{
// Create a new HAL document
if (is_array($data))
{
$count = count($data);
}
else
{
$count = null;
}
if ($count == 1)
{
reset($data);
$document = new F0FHalDocument(end($data));
}
else
{
$document = new F0FHalDocument($data);
}
// Create a self link
$uri = (string) (JUri::getInstance());
$uri = $this->_removeURIBase($uri);
$uri = JRoute::_($uri);
$document->addLink('self', new F0FHalLink($uri));
// Create relative links in a record list context
if (is_array($data) && ($model instanceof F0FModel))
{
$pagination = $model->getPagination();
if ($pagination->get('pages.total') > 1)
{
// Try to guess URL parameters and create a prototype URL
// NOTE: You are better off specialising this method
$protoUri = $this->_getPrototypeURIForPagination();
// The "first" link
$uri = clone $protoUri;
$uri->setVar('limitstart', 0);
$uri = JRoute::_((string) $uri);
$document->addLink('first', new F0FHalLink($uri));
// Do we need a "prev" link?
if ($pagination->get('pages.current') > 1)
{
$prevPage = $pagination->get('pages.current') - 1;
$limitstart = ($prevPage - 1) * $pagination->limit;
$uri = clone $protoUri;
$uri->setVar('limitstart', $limitstart);
$uri = JRoute::_((string) $uri);
$document->addLink('prev', new F0FHalLink($uri));
}
// Do we need a "next" link?
if ($pagination->get('pages.current') < $pagination->get('pages.total'))
{
$nextPage = $pagination->get('pages.current') + 1;
$limitstart = ($nextPage - 1) * $pagination->limit;
$uri = clone $protoUri;
$uri->setVar('limitstart', $limitstart);
$uri = JRoute::_((string) $uri);
$document->addLink('next', new F0FHalLink($uri));
}
// The "last" link?
$lastPage = $pagination->get('pages.total');
$limitstart = ($lastPage - 1) * $pagination->limit;
$uri = clone $protoUri;
$uri->setVar('limitstart', $limitstart);
$uri = JRoute::_((string) $uri);
$document->addLink('last', new F0FHalLink($uri));
}
}
return $document;
}
/**
* Convert an absolute URI to a relative one
*
* @param string $uri The URI to convert
*
* @return string The relative URL
*/
protected function _removeURIBase($uri)
{
static $root = null, $rootlen = 0;
if (is_null($root))
{
$root = rtrim(F0FPlatform::getInstance()->URIbase(), '/');
$rootlen = strlen($root);
}
if (substr($uri, 0, $rootlen) == $root)
{
$uri = substr($uri, $rootlen);
}
return ltrim($uri, '/');
}
/**
* Returns a JUri instance with a prototype URI used as the base for the
* other URIs created by the JSON renderer
*
* @return JUri The prototype JUri instance
*/
protected function _getPrototypeURIForPagination()
{
$protoUri = new JUri('index.php');
$protoUri->setQuery($this->input->getData());
$protoUri->delVar('savestate');
$protoUri->delVar('base_path');
return $protoUri;
}
}
PK ! ��' database/iterator.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Database iterator
*/
abstract class F0FDatabaseIterator implements Iterator
{
/**
* The database cursor.
*
* @var mixed
*/
protected $cursor;
/**
* The class of object to create.
*
* @var string
*/
protected $class;
/**
* The name of the column to use for the key of the database record.
*
* @var mixed
*/
private $_column;
/**
* The current database record.
*
* @var mixed
*/
private $_current;
/**
* The current database record as a F0FTable object.
*
* @var F0FTable
*/
private $_currentTable;
/**
* A numeric or string key for the current database record.
*
* @var scalar
*/
private $_key;
/**
* The number of fetched records.
*
* @var integer
*/
private $_fetched = 0;
/**
* A F0FTable object created using the class type $class, used by getTable
*
* @var F0FTable
*/
private $_tableObject = null;
/**
* Returns an iterator object for a specific database type
*
* @param string $dbName The database type, e.g. mysql, mysqli, sqlazure etc.
* @param mixed $cursor The database cursor
* @param string $column An option column to use as the iterator key
* @param string $class The table class of the returned objects
* @param array $config Configuration parameters to push to the table class
*
* @return F0FDatabaseIterator
*
* @throws InvalidArgumentException
*/
public static function &getIterator($dbName, $cursor, $column = null, $class, $config = array())
{
$className = 'F0FDatabaseIterator' . ucfirst($dbName);
$object = new $className($cursor, $column, $class, $config);
return $object;
}
/**
* Database iterator constructor.
*
* @param mixed $cursor The database cursor.
* @param string $column An option column to use as the iterator key.
* @param string $class The table class of the returned objects.
* @param array $config Configuration parameters to push to the table class
*
* @throws InvalidArgumentException
*/
public function __construct($cursor, $column = null, $class, $config = array())
{
// Figure out the type and prefix of the class by the class name
$parts = F0FInflector::explode($class);
if(count($parts) != 3)
{
throw new InvalidArgumentException('Invalid table name, expected a pattern like ComponentTableFoobar got '.$class);
}
$this->_tableObject = F0FTable::getInstance($parts[2], ucfirst($parts[0]) . ucfirst($parts[1]))->getClone();
$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 F0FTable instance
*
* @return F0FTable
*
* @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;
}
}
PK ! ���/7 /7 database/query/postgresql.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Query Building Class.
*
* @since 11.3
*/
class F0FDatabaseQueryPostgresql extends F0FDatabaseQuery implements F0FDatabaseQueryLimitable
{
/**
* @var object The FOR UPDATE element used in "FOR UPDATE" lock
* @since 11.3
*/
protected $forUpdate = null;
/**
* @var object The FOR SHARE element used in "FOR SHARE" lock
* @since 11.3
*/
protected $forShare = null;
/**
* @var object The NOWAIT element used in "FOR SHARE" and "FOR UPDATE" lock
* @since 11.3
*/
protected $noWait = null;
/**
* @var object The LIMIT element
* @since 11.3
*/
protected $limit = null;
/**
* @var object The OFFSET element
* @since 11.3
*/
protected $offset = null;
/**
* @var object The RETURNING element of INSERT INTO
* @since 11.3
*/
protected $returning = null;
/**
* Magic function to convert the query to a string, only for postgresql specific query
*
* @return string The completed query.
*
* @since 11.3
*/
public function __toString()
{
$query = '';
switch ($this->type)
{
case 'select':
$query .= (string) $this->select;
$query .= (string) $this->from;
if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}
if ($this->where)
{
$query .= (string) $this->where;
}
if ($this->group)
{
$query .= (string) $this->group;
}
if ($this->having)
{
$query .= (string) $this->having;
}
if ($this->order)
{
$query .= (string) $this->order;
}
if ($this->forUpdate)
{
$query .= (string) $this->forUpdate;
}
else
{
if ($this->forShare)
{
$query .= (string) $this->forShare;
}
}
if ($this->noWait)
{
$query .= (string) $this->noWait;
}
break;
case 'update':
$query .= (string) $this->update;
$query .= (string) $this->set;
if ($this->join)
{
$onWord = ' ON ';
// Workaround for special case of JOIN with UPDATE
foreach ($this->join as $join)
{
$joinElem = $join->getElements();
$joinArray = explode($onWord, $joinElem[0]);
$this->from($joinArray[0]);
$this->where($joinArray[1]);
}
$query .= (string) $this->from;
}
if ($this->where)
{
$query .= (string) $this->where;
}
break;
case 'insert':
$query .= (string) $this->insert;
if ($this->values)
{
if ($this->columns)
{
$query .= (string) $this->columns;
}
$elements = $this->values->getElements();
if (!($elements[0] instanceof $this))
{
$query .= ' VALUES ';
}
$query .= (string) $this->values;
if ($this->returning)
{
$query .= (string) $this->returning;
}
}
break;
default:
$query = parent::__toString();
break;
}
if ($this instanceof F0FDatabaseQueryLimitable)
{
$query = $this->processLimit($query, $this->limit, $this->offset);
}
return $query;
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear, or nothing to clear the whole query.
*
* @return F0FDatabaseQueryPostgresql Returns this object to allow chaining.
*
* @since 11.3
*/
public function clear($clause = null)
{
switch ($clause)
{
case 'limit':
$this->limit = null;
break;
case 'offset':
$this->offset = null;
break;
case 'forUpdate':
$this->forUpdate = null;
break;
case 'forShare':
$this->forShare = null;
break;
case 'noWait':
$this->noWait = null;
break;
case 'returning':
$this->returning = null;
break;
case 'select':
case 'update':
case 'delete':
case 'insert':
case 'from':
case 'join':
case 'set':
case 'where':
case 'group':
case 'having':
case 'order':
case 'columns':
case 'values':
parent::clear($clause);
break;
default:
$this->type = null;
$this->limit = null;
$this->offset = null;
$this->forUpdate = null;
$this->forShare = null;
$this->noWait = null;
$this->returning = null;
parent::clear($clause);
break;
}
return $this;
}
/**
* Casts a value to a char.
*
* Ensure that the value is properly quoted before passing to the method.
*
* Usage:
* $query->select($query->castAsChar('a'));
*
* @param string $value The value to cast as a char.
*
* @return string Returns the cast value.
*
* @since 11.3
*/
public function castAsChar($value)
{
return $value . '::text';
}
/**
* Concatenates an array of column names or values.
*
* Usage:
* $query->select($query->concatenate(array('a', 'b')));
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 11.3
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
return implode(' || ' . $this->quote($separator) . ' || ', $values);
}
else
{
return implode(' || ', $values);
}
}
/**
* Gets the current date and time.
*
* @return string Return string used in query to obtain
*
* @since 11.3
*/
public function currentTimestamp()
{
return 'NOW()';
}
/**
* Sets the FOR UPDATE lock on select's output row
*
* @param string $table_name The table to lock
* @param string $glue The glue by which to join the conditions. Defaults to ',' .
*
* @return F0FDatabaseQueryPostgresql FOR UPDATE query element
*
* @since 11.3
*/
public function forUpdate($table_name, $glue = ',')
{
$this->type = 'forUpdate';
if (is_null($this->forUpdate))
{
$glue = strtoupper($glue);
$this->forUpdate = new F0FDatabaseQueryElement('FOR UPDATE', 'OF ' . $table_name, "$glue ");
}
else
{
$this->forUpdate->append($table_name);
}
return $this;
}
/**
* Sets the FOR SHARE lock on select's output row
*
* @param string $table_name The table to lock
* @param string $glue The glue by which to join the conditions. Defaults to ',' .
*
* @return F0FDatabaseQueryPostgresql FOR SHARE query element
*
* @since 11.3
*/
public function forShare($table_name, $glue = ',')
{
$this->type = 'forShare';
if (is_null($this->forShare))
{
$glue = strtoupper($glue);
$this->forShare = new F0FDatabaseQueryElement('FOR SHARE', 'OF ' . $table_name, "$glue ");
}
else
{
$this->forShare->append($table_name);
}
return $this;
}
/**
* Used to get a string to extract year from date column.
*
* Usage:
* $query->select($query->year($query->quoteName('dateColumn')));
*
* @param string $date Date column containing year to be extracted.
*
* @return string Returns string to extract year from a date.
*
* @since 12.1
*/
public function year($date)
{
return 'EXTRACT (YEAR FROM ' . $date . ')';
}
/**
* Used to get a string to extract month from date column.
*
* Usage:
* $query->select($query->month($query->quoteName('dateColumn')));
*
* @param string $date Date column containing month to be extracted.
*
* @return string Returns string to extract month from a date.
*
* @since 12.1
*/
public function month($date)
{
return 'EXTRACT (MONTH FROM ' . $date . ')';
}
/**
* Used to get a string to extract day from date column.
*
* Usage:
* $query->select($query->day($query->quoteName('dateColumn')));
*
* @param string $date Date column containing day to be extracted.
*
* @return string Returns string to extract day from a date.
*
* @since 12.1
*/
public function day($date)
{
return 'EXTRACT (DAY FROM ' . $date . ')';
}
/**
* Used to get a string to extract hour from date column.
*
* Usage:
* $query->select($query->hour($query->quoteName('dateColumn')));
*
* @param string $date Date column containing hour to be extracted.
*
* @return string Returns string to extract hour from a date.
*
* @since 12.1
*/
public function hour($date)
{
return 'EXTRACT (HOUR FROM ' . $date . ')';
}
/**
* Used to get a string to extract minute from date column.
*
* Usage:
* $query->select($query->minute($query->quoteName('dateColumn')));
*
* @param string $date Date column containing minute to be extracted.
*
* @return string Returns string to extract minute from a date.
*
* @since 12.1
*/
public function minute($date)
{
return 'EXTRACT (MINUTE FROM ' . $date . ')';
}
/**
* Used to get a string to extract seconds from date column.
*
* Usage:
* $query->select($query->second($query->quoteName('dateColumn')));
*
* @param string $date Date column containing second to be extracted.
*
* @return string Returns string to extract second from a date.
*
* @since 12.1
*/
public function second($date)
{
return 'EXTRACT (SECOND FROM ' . $date . ')';
}
/**
* Sets the NOWAIT lock on select's output row
*
* @return F0FDatabaseQueryPostgresql NO WAIT query element
*
* @since 11.3
*/
public function noWait ()
{
$this->type = 'noWait';
if (is_null($this->noWait))
{
$this->noWait = new F0FDatabaseQueryElement('NOWAIT', null);
}
return $this;
}
/**
* Set the LIMIT clause to the query
*
* @param integer $limit An int of how many row will be returned
*
* @return F0FDatabaseQueryPostgresql Returns this object to allow chaining.
*
* @since 11.3
*/
public function limit($limit = 0)
{
if (is_null($this->limit))
{
$this->limit = new F0FDatabaseQueryElement('LIMIT', (int) $limit);
}
return $this;
}
/**
* Set the OFFSET clause to the query
*
* @param integer $offset An int for skipping row
*
* @return F0FDatabaseQueryPostgresql Returns this object to allow chaining.
*
* @since 11.3
*/
public function offset($offset = 0)
{
if (is_null($this->offset))
{
$this->offset = new F0FDatabaseQueryElement('OFFSET', (int) $offset);
}
return $this;
}
/**
* Add the RETURNING element to INSERT INTO statement.
*
* @param mixed $pkCol The name of the primary key column.
*
* @return F0FDatabaseQueryPostgresql Returns this object to allow chaining.
*
* @since 11.3
*/
public function returning($pkCol)
{
if (is_null($this->returning))
{
$this->returning = new F0FDatabaseQueryElement('RETURNING', $pkCol);
}
return $this;
}
/**
* Sets the offset and limit for the result set, if the database driver supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return F0FDatabaseQueryPostgresql Returns this object to allow chaining.
*
* @since 12.1
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 12.1
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit > 0)
{
$query .= ' LIMIT ' . $limit;
}
if ($offset > 0)
{
$query .= ' OFFSET ' . $offset;
}
return $query;
}
/**
* Add to the current date and time in Postgresql.
* Usage:
* $query->select($query->dateAdd());
* Prefixing the interval with a - (negative sign) will cause subtraction to be used.
*
* @param datetime $date The date to add to
* @param string $interval The string representation of the appropriate number of units
* @param string $datePart The part of the date to perform the addition on
*
* @return string The string with the appropriate sql for addition of dates
*
* @since 13.1
* @note Not all drivers support all units. Check appropriate references
* @link http://www.postgresql.org/docs/9.0/static/functions-datetime.html.
*/
public function dateAdd($date, $interval, $datePart)
{
if (substr($interval, 0, 1) != '-')
{
return "timestamp '" . $date . "' + interval '" . $interval . " " . $datePart . "'";
}
else
{
return "timestamp '" . $date . "' - interval '" . ltrim($interval, '-') . " " . $datePart . "'";
}
}
/**
* Return correct regexp operator for Postgresql.
*
* Ensure that the regexp operator is Postgresql compatible.
*
* Usage:
* $query->where('field ' . $query->regexp($search));
*
* @param string $value The regex pattern.
*
* @return string Returns the regex operator.
*
* @since 11.3
*/
public function regexp($value)
{
return ' ~* ' . $value;
}
/**
* Return correct rand() function for Postgresql.
*
* Ensure that the rand() function is Postgresql compatible.
*
* Usage:
* $query->Rand();
*
* @return string The correct rand function.
*
* @since 3.5
*/
public function Rand()
{
return ' RANDOM() ';
}
}
PK ! @�ʹ� � database/query/sqlite.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* SQLite Query Building Class.
*
* @since 12.1
*/
class F0FDatabaseQuerySqlite extends F0FDatabaseQueryPdo implements F0FDatabaseQueryPreparable, F0FDatabaseQueryLimitable
{
/**
* @var integer The offset for the result set.
* @since 12.1
*/
protected $offset;
/**
* @var integer The limit for the result set.
* @since 12.1
*/
protected $limit;
/**
* @var array Bounded object array
* @since 12.1
*/
protected $bounded = array();
/**
* Method to add a variable to an internal array that will be bound to a prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded array when the passed in value is null.
*
* @param string|integer $key The key that will be used in your SQL query to reference the value. Usually of
* the form ':key', but can also be an integer.
* @param mixed &$value The value that will be bound. The value is passed by reference to support output
* parameters such as those possible with stored procedures.
* @param integer $dataType Constant corresponding to a SQL datatype.
* @param integer $length The length of the variable. Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be used.
*
* @return F0FDatabaseQuerySqlite
*
* @since 12.1
*/
public function bind($key = null, &$value = null, $dataType = PDO::PARAM_STR, $length = 0, $driverOptions = array())
{
// Case 1: Empty Key (reset $bounded array)
if (empty($key))
{
$this->bounded = array();
return $this;
}
// Case 2: Key Provided, null value (unset key from $bounded array)
if (is_null($value))
{
if (isset($this->bounded[$key]))
{
unset($this->bounded[$key]);
}
return $this;
}
$obj = new stdClass;
$obj->value = &$value;
$obj->dataType = $dataType;
$obj->length = $length;
$obj->driverOptions = $driverOptions;
// Case 3: Simply add the Key/Value into the bounded array
$this->bounded[$key] = $obj;
return $this;
}
/**
* Retrieves the bound parameters array when key is null and returns it by reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 12.1
*/
public function &getBounded($key = null)
{
if (empty($key))
{
return $this->bounded;
}
else
{
if (isset($this->bounded[$key]))
{
return $this->bounded[$key];
}
}
}
/**
* Gets the number of characters in a string.
*
* Note, use 'length' to find the number of bytes in a string.
*
* Usage:
* $query->select($query->charLength('a'));
*
* @param string $field A value.
* @param string $operator Comparison operator between charLength integer value and $condition
* @param string $condition Integer value to compare charLength with.
*
* @return string The required char length call.
*
* @since 13.1
*/
public function charLength($field, $operator = null, $condition = null)
{
return 'length(' . $field . ')' . (isset($operator) && isset($condition) ? ' ' . $operator . ' ' . $condition : '');
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear, or nothing to clear the whole query.
*
* @return F0FDatabaseQuerySqlite Returns this object to allow chaining.
*
* @since 12.1
*/
public function clear($clause = null)
{
switch ($clause)
{
case null:
$this->bounded = array();
break;
}
parent::clear($clause);
return $this;
}
/**
* Concatenates an array of column names or values.
*
* Usage:
* $query->select($query->concatenate(array('a', 'b')));
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 11.1
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
return implode(' || ' . $this->quote($separator) . ' || ', $values);
}
else
{
return implode(' || ', $values);
}
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset. This method is used
* automatically by the __toString() method if it detects that the
* query implements the F0FDatabaseQueryLimitable interface.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 12.1
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit > 0 || $offset > 0)
{
$query .= ' LIMIT ' . $offset . ', ' . $limit;
}
return $query;
}
/**
* Sets the offset and limit for the result set, if the database driver supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return F0FDatabaseQuerySqlite Returns this object to allow chaining.
*
* @since 12.1
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Add to the current date and time.
* Usage:
* $query->select($query->dateAdd());
* Prefixing the interval with a - (negative sign) will cause subtraction to be used.
*
* @param datetime $date The date or datetime to add to
* @param string $interval The string representation of the appropriate number of units
* @param string $datePart The part of the date to perform the addition on
*
* @return string The string with the appropriate sql for addition of dates
*
* @since 13.1
* @link http://www.sqlite.org/lang_datefunc.html
*/
public function dateAdd($date, $interval, $datePart)
{
// SQLite does not support microseconds as a separate unit. Convert the interval to seconds
if (strcasecmp($datePart, 'microseconds') == 0)
{
$interval = .001 * $interval;
$datePart = 'seconds';
}
if (substr($interval, 0, 1) != '-')
{
return "datetime('" . $date . "', '+" . $interval . " " . $datePart . "')";
}
else
{
return "datetime('" . $date . "', '" . $interval . " " . $datePart . "')";
}
}
/**
* Gets the current date and time.
*
* Usage:
* $query->where('published_up < '.$query->currentTimestamp());
*
* @return string
*
* @since 3.4
*/
public function currentTimestamp()
{
return 'CURRENT_TIMESTAMP';
}
}
PK ! ~�HR� � database/query/pdomysql.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Query Building Class.
*
* @package Joomla.Platform
* @subpackage Database
* @since 3.4
*/
class F0FDatabaseQueryPdomysql extends F0FDatabaseQueryMysqli
{
}
PK ! �խ� database/query/sqlazure.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Query Building Class.
*
* @since 11.1
*/
class F0FDatabaseQuerySqlazure extends F0FDatabaseQuerySqlsrv
{
/**
* The character(s) used to quote SQL statement names such as table names or field names,
* etc. The child classes should define this as necessary. If a single character string the
* same character is used for both sides of the quoted name, else the first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
*
* @since 11.1
*/
protected $name_quotes = '';
}
PK ! �Y\=? ? database/query/preparable.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
if (!interface_exists('JDatabaseQueryPreparable'))
{
/**
* Joomla Database Query Preparable Interface.
* Adds bind/unbind methods as well as a getBounded() method
* to retrieve the stored bounded variables on demand prior to
* query execution.
*
* @since 12.1
*/
interface JDatabaseQueryPreparable
{
/**
* Method to add a variable to an internal array that will be bound to a prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded array when the passed in value is null.
*
* @param string|integer $key The key that will be used in your SQL query to reference the value. Usually of
* the form ':key', but can also be an integer.
* @param mixed &$value The value that will be bound. The value is passed by reference to support output
* parameters such as those possible with stored procedures.
* @param integer $dataType Constant corresponding to a SQL datatype.
* @param integer $length The length of the variable. Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be used.
*
* @return F0FDatabaseQuery
*
* @since 12.1
*/
public function bind($key = null, &$value = null, $dataType = PDO::PARAM_STR, $length = 0, $driverOptions = array());
/**
* Retrieves the bound parameters array when key is null and returns it by reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 12.1
*/
public function &getBounded($key = null);
}
}
interface F0FDatabaseQueryPreparable extends JDatabaseQueryPreparable
{
}PK ! ��l�� � database/query/mysqli.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Query Building Class.
*
* @since 11.1
*/
class F0FDatabaseQueryMysqli extends F0FDatabaseQuery implements F0FDatabaseQueryLimitable
{
/**
* @var integer The offset for the result set.
* @since 12.1
*/
protected $offset;
/**
* @var integer The limit for the result set.
* @since 12.1
*/
protected $limit;
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 12.1
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit > 0 || $offset > 0)
{
$query .= ' LIMIT ' . $offset . ', ' . $limit;
}
return $query;
}
/**
* Concatenates an array of column names or values.
*
* @param array $values An array of values to concatenate.
* @param string $separator As separator to place between each value.
*
* @return string The concatenated values.
*
* @since 11.1
*/
public function concatenate($values, $separator = null)
{
if ($separator)
{
$concat_string = 'CONCAT_WS(' . $this->quote($separator);
foreach ($values as $value)
{
$concat_string .= ', ' . $value;
}
return $concat_string . ')';
}
else
{
return 'CONCAT(' . implode(',', $values) . ')';
}
}
/**
* Sets the offset and limit for the result set, if the database driver supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return F0FDatabaseQuery Returns this object to allow chaining.
*
* @since 12.1
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
/**
* Return correct regexp operator for mysqli.
*
* Ensure that the regexp operator is mysqli compatible.
*
* Usage:
* $query->where('field ' . $query->regexp($search));
*
* @param string $value The regex pattern.
*
* @return string Returns the regex operator.
*
* @since 11.3
*/
public function regexp($value)
{
return ' REGEXP ' . $value;
}
/**
* Return correct rand() function for Mysql.
*
* Ensure that the rand() function is Mysql compatible.
*
* Usage:
* $query->Rand();
*
* @return string The correct rand function.
*
* @since 3.5
*/
public function Rand()
{
return ' RAND() ';
}
}
PK ! 1��� � database/query/oracle.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Oracle Query Building Class.
*
* @since 12.1
*/
class F0FDatabaseQueryOracle extends F0FDatabaseQueryPdo implements F0FDatabaseQueryPreparable, F0FDatabaseQueryLimitable
{
/**
* @var integer The offset for the result set.
* @since 12.1
*/
protected $offset;
/**
* @var integer The limit for the result set.
* @since 12.1
*/
protected $limit;
/**
* @var array Bounded object array
* @since 12.1
*/
protected $bounded = array();
/**
* Method to add a variable to an internal array that will be bound to a prepared SQL statement before query execution. Also
* removes a variable that has been bounded from the internal bounded array when the passed in value is null.
*
* @param string|integer $key The key that will be used in your SQL query to reference the value. Usually of
* the form ':key', but can also be an integer.
* @param mixed &$value The value that will be bound. The value is passed by reference to support output
* parameters such as those possible with stored procedures.
* @param integer $dataType Constant corresponding to a SQL datatype.
* @param integer $length The length of the variable. Usually required for OUTPUT parameters.
* @param array $driverOptions Optional driver options to be used.
*
* @return F0FDatabaseQueryOracle
*
* @since 12.1
*/
public function bind($key = null, &$value = null, $dataType = PDO::PARAM_STR, $length = 0, $driverOptions = array())
{
// Case 1: Empty Key (reset $bounded array)
if (empty($key))
{
$this->bounded = array();
return $this;
}
// Case 2: Key Provided, null value (unset key from $bounded array)
if (is_null($value))
{
if (isset($this->bounded[$key]))
{
unset($this->bounded[$key]);
}
return $this;
}
$obj = new stdClass;
$obj->value = &$value;
$obj->dataType = $dataType;
$obj->length = $length;
$obj->driverOptions = $driverOptions;
// Case 3: Simply add the Key/Value into the bounded array
$this->bounded[$key] = $obj;
return $this;
}
/**
* Retrieves the bound parameters array when key is null and returns it by reference. If a key is provided then that item is
* returned.
*
* @param mixed $key The bounded variable key to retrieve.
*
* @return mixed
*
* @since 12.1
*/
public function &getBounded($key = null)
{
if (empty($key))
{
return $this->bounded;
}
else
{
if (isset($this->bounded[$key]))
{
return $this->bounded[$key];
}
}
}
/**
* Clear data from the query or a specific clause of the query.
*
* @param string $clause Optionally, the name of the clause to clear, or nothing to clear the whole query.
*
* @return F0FDatabaseQueryOracle Returns this object to allow chaining.
*
* @since 12.1
*/
public function clear($clause = null)
{
switch ($clause)
{
case null:
$this->bounded = array();
break;
}
parent::clear($clause);
return $this;
}
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset. This method is used
* automatically by the __toString() method if it detects that the
* query implements the F0FDatabaseQueryLimitable interface.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 12.1
*/
public function processLimit($query, $limit, $offset = 0)
{
// Check if we need to mangle the query.
if ($limit || $offset)
{
$query = "SELECT joomla2.*
FROM (
SELECT joomla1.*, ROWNUM AS joomla_db_rownum
FROM (
" . $query . "
) joomla1
) joomla2";
// Check if the limit value is greater than zero.
if ($limit > 0)
{
$query .= ' WHERE joomla2.joomla_db_rownum BETWEEN ' . ($offset + 1) . ' AND ' . ($offset + $limit);
}
else
{
// Check if there is an offset and then use this.
if ($offset)
{
$query .= ' WHERE joomla2.joomla_db_rownum > ' . ($offset + 1);
}
}
}
return $query;
}
/**
* Sets the offset and limit for the result set, if the database driver supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return F0FDatabaseQueryOracle Returns this object to allow chaining.
*
* @since 12.1
*/
public function setLimit($limit = 0, $offset = 0)
{
$this->limit = (int) $limit;
$this->offset = (int) $offset;
return $this;
}
}
PK ! ��[�S S database/query/pdo.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* PDO Query Building Class.
*
* @since 12.1
*/
class F0FDatabaseQueryPdo extends F0FDatabaseQuery
{
}
PK ! ��l�� � database/query/limitable.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
if (!interface_exists('JDatabaseQueryLimitable'))
{
/**
* Joomla Database Query Limitable Interface.
* Adds bind/unbind methods as well as a getBounded() method
* to retrieve the stored bounded variables on demand prior to
* query execution.
*
* @since 12.1
*/
interface JDatabaseQueryLimitable
{
/**
* Method to modify a query already in string format with the needed
* additions to make the query limited to a particular number of
* results, or start at a particular offset. This method is used
* automatically by the __toString() method if it detects that the
* query implements the F0FDatabaseQueryLimitable interface.
*
* @param string $query The query in string format
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return string
*
* @since 12.1
*/
public function processLimit($query, $limit, $offset = 0);
/**
* Sets the offset and limit for the result set, if the database driver supports it.
*
* Usage:
* $query->setLimit(100, 0); (retrieve 100 rows, starting at first record)
* $query->setLimit(50, 50); (retrieve 50 rows, starting at 50th record)
*
* @param integer $limit The limit for the result set
* @param integer $offset The offset for the result set
*
* @return F0FDatabaseQuery Returns this object to allow chaining.
*
* @since 12.1
*/
public function setLimit($limit = 0, $offset = 0);
}
}
/**
* Joomla Database Query Limitable Interface.
* Adds bind/unbind methods as well as a getBounded() method
* to retrieve the stored bounded variables on demand prior to
* query execution.
*
* @since 12.1
*/
interface F0FDatabaseQueryLimitable extends JDatabaseQueryLimitable
{
}
PK ! �C�� � database/query/mysql.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Query Building Class.
*
* @since 11.1
* @deprecated Will be removed when the minimum supported PHP version no longer includes the deprecated PHP `mysql` extension
*/
class F0FDatabaseQueryMysql extends F0FDatabaseQueryMysqli
{
}
PK ! ���]
]
database/query/element.phpnu &1i� <?php
/**
* @package FrameworkOnFramework
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects
* instead of plain stdClass objects
*/
// Protect from unauthorized access
defined('F0F_INCLUDED') or die;
/**
* Query Element Class.
*
* @property-read string $name The name of the element.
* @property-read array $elements An array of elements.
* @property-read string $glue Glue piece.
*
* @since 11.1
*/
class F0FDatabaseQueryElement
{
/**
* @var string The name of the element.
* @since 11.1
*/
protected $name = null;
/**
* @var array An array of elements.
* @since 11.1
*/
protected $elements = null;
/**
* @var string Glue piece.
* @since 11.1
*/
protected $glue = null;
/**
* Constructor.
*
* @param string $name The name of the element.
* @param mixed $elements String or array.
* @param string $glue The glue for elements.
*
* @since 11.1
*/
public function __construct($name, $elements, $glue = ',')
{
$this->elements = array();
$this->name = $name;
$this->glue = $glue;
$this->append($elements);
}
/**
* Magic function to convert the query element to a string.
*
* @return string
*
* @since 11.1
*/
public function __toString()
{
if (substr($this->name, -2) == '()')
{
return PHP_EOL . substr($this->name, 0, -2) . '(' . implode($this->glue, $this->elements) . ')';
}
else
{
return PHP_EOL . $this->name . ' ' . implode($this->glue, $this->elements);
}
}
/**
* Appends element parts to the internal list.
*
* @param mixed $elements String or array.
*
* @return void
*
* @since 11.1
*/
public function append($elements)
{
if (is_array($elements))
{
$this->elements = array_merge($this->elements, $elements);
}
else
{
$this->elements = array_merge($this->elements, array($elements));
}
}
/**
* Gets the elements of this element.
*
* @return array
*
* @since 11.1
*/
public function getElements()
{
return $this->elements;
}
/**
* Method to provide deep copy support to nested objects and arrays
* when cloning.
*
* @return void
*
* @since 11.3
*/
public function __clone()
{
foreach ($this as $k => $v)
{
if (is_object($v) || is_array($v))
{
$this->{$k} = unserialize(serialize($v));
}
}
}
}
PK ! h�wJ"