primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

234
libraries/f0f/view/csv.php Normal file
View File

@ -0,0 +1,234 @@
<?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;
}
}

136
libraries/f0f/view/form.php Normal file
View File

@ -0,0 +1,136 @@
<?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;
}
}

176
libraries/f0f/view/html.php Normal file
View File

@ -0,0 +1,176 @@
<?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;
}
}

360
libraries/f0f/view/json.php Normal file
View File

@ -0,0 +1,360 @@
<?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;
}
}

356
libraries/f0f/view/raw.php Normal file
View File

@ -0,0 +1,356 @@
<?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;
}
}

1175
libraries/f0f/view/view.php Normal file

File diff suppressed because it is too large Load Diff