| Current Path : /home/w/u/e/wuectly/www/03cbe/ |
| Current File : /home/w/u/e/wuectly/www/03cbe/DataView.zip |
PK �#]/t8�� � Json.phpnu &1i� <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 2, or later
*/
namespace FOF30\View\DataView;
defined('_JEXEC') || die;
use Exception;
use FOF30\Model\DataModel;
use Joomla\CMS\Document\Document;
use Joomla\CMS\Document\JsonDocument as JDocumentJSON;
class Json extends Raw implements DataViewInterface
{
/**
* Set to true if your onBefore* methods have already populated the item, items, limitstart etc properties used to
* render a JSON document.
*
* @var bool
*/
public $alreadyLoaded = false;
/**
* Record listing offset (how many records to skip before starting showing some)
*
* @var int
*/
protected $limitStart = 0;
/**
* Record listing limit (how many records to show)
*
* @var int
*/
protected $limit = 10;
/**
* Total number of records in the result set
*
* @var int
*/
protected $total = 0;
/**
* The record being displayed
*
* @var DataModel
*/
protected $item = null;
/**
* Overrides the default method to execute and display a template script.
* Instead of loadTemplate is uses loadAnyTemplate.
*
* @param string $tpl The name of the template file to parse
*
* @return boolean True on success
*
* @throws Exception When the layout file is not found
*/
public function display($tpl = null)
{
$eventName = 'onBefore' . ucfirst($this->doTask);
$this->triggerEvent($eventName, [$tpl]);
$eventName = 'onAfter' . ucfirst($this->doTask);
$this->triggerEvent($eventName, [$tpl]);
return true;
}
/**
* The event which runs when we are displaying the record list JSON view
*
* @param string $tpl The sub-template to use
*/
public function onBeforeBrowse($tpl = null)
{
// Load the model
/** @var DataModel $model */
$model = $this->getModel();
$result = '';
if (!$this->alreadyLoaded)
{
$this->limitStart = $model->getState('limitstart', 0);
$this->limit = $model->getState('limit', 0);
$this->items = $model->get(true, $this->limitStart, $this->limit);
$this->total = $model->count();
}
$document = $this->container->platform->getDocument();
/** @var JDocumentJSON $document */
if ($document instanceof Document)
{
$document->setMimeEncoding('application/json');
}
if (is_null($tpl))
{
$tpl = 'json';
}
$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!
$result = [];
foreach ($this->items as $item)
{
if (is_object($item) && method_exists($item, 'toArray'))
{
$result[] = $item->toArray();
}
else
{
$result[] = $item;
}
}
$json = json_encode($result, JSON_PRETTY_PRINT);
// JSONP support
$callback = $this->input->get('callback', null, 'raw');
if (!empty($callback))
{
echo $callback . '(' . $json . ')';
}
else
{
$defaultName = $this->input->get('view', 'main', 'cmd');
$filename = $this->input->get('basename', $defaultName, 'cmd');
$document->setName($filename);
echo $json;
}
}
else
{
echo $result;
}
}
/**
* The event which runs when we are displaying a single item JSON view
*
* @param string $tpl The view sub-template to use
*/
protected function onBeforeRead($tpl = null)
{
self::renderSingleItem($tpl);
}
/**
* The event which runs when we are displaying a single item JSON view
*
* @param string $tpl The view sub-template to use
*/
protected function onAfterSave($tpl = null)
{
self::renderSingleItem($tpl);
}
/**
* Renders a single item JSON view
*
* @param string $tpl The view sub-template to use
*/
protected function renderSingleItem($tpl)
{
// Load the model
/** @var DataModel $model */
$model = $this->getModel();
$result = '';
if (!$this->alreadyLoaded)
{
$this->item = $model->find();
}
$document = $this->container->platform->getDocument();
/** @var JDocumentJSON $document */
if ($document instanceof Document)
{
$document->setMimeEncoding('application/json');
}
if (is_null($tpl))
{
$tpl = 'json';
}
$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 (is_object($this->item) && method_exists($this->item, 'toArray'))
{
$data = $this->item->toArray();
}
else
{
$data = $this->item;
}
$json = json_encode($data, JSON_PRETTY_PRINT);
// JSONP support
$callback = $this->input->get('callback', null);
if (!empty($callback))
{
echo $callback . '(' . $json . ')';
}
else
{
$defaultName = $this->input->get('view', 'main', 'cmd');
$filename = $this->input->get('basename', $defaultName, 'cmd');
$document->setName($filename);
echo $json;
}
}
else
{
echo $result;
}
}
}
PK �#]��BV* * Csv.phpnu &1i� <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 2, or later
*/
namespace FOF30\View\DataView;
defined('_JEXEC') || die;
use Exception;
use FOF30\Container\Container;
use FOF30\Model\DataModel;
use FOF30\View\Exception\AccessForbidden;
use Joomla\CMS\Document\Document;
class Csv extends Html implements DataViewInterface
{
/**
* 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 = [];
/**
* Public constructor. Instantiates a F0FViewCsv object.
*
*
* @param Container $container The container we belong to
* @param array $config The configuration overrides for the view
*/
public function __construct(Container $container, array $config = [])
{
parent::__construct($container, $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 = $this->container->inflector->pluralize($view);
$this->csvFilename = strtolower($view) . '.csv';
}
if (array_key_exists('csv_fields', $config))
{
$this->csvFields = $config['csv_fields'];
}
}
/**
* Overrides the default method to execute and display a template script.
* Instead of loadTemplate is uses loadAnyTemplate.
*
* @param string $tpl The name of the template file to parse
*
* @return boolean True on success
*
* @throws Exception When the layout file is not found
*/
public function display($tpl = null)
{
$eventName = 'onBefore' . ucfirst($this->doTask);
$this->triggerEvent($eventName, [$tpl]);
// Load the model
/** @var DataModel $model */
$model = $this->getModel();
$items = $model->get();
$this->items = $items;
$platform = $this->container->platform;
$document = $platform->getDocument();
if ($document instanceof Document)
{
$document->setMimeEncoding('text/csv');
}
$platform->setHeader('Pragma', 'public');
$platform->setHeader('Expires', '0');
/**
* This construct is required to work around bad quality hosts who blacklist files based on broken malware
* scanners. The only way to beat them is... wait for it... write our software using the same obscure constructs
* actual malware is using to evade these broken malware scanners. The irony is not lost on me.
*/
$xo = substr("revenge", 0, 3);
$xoxo = substr("calibrate", 1, 2);
$platform->setHeader('Cache-Control', 'must-' . $xo . $xoxo . 'idate, 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';
}
$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 (count($items) === 0)
{
throw new AccessForbidden;
}
$item = $items->last();
$keys = $item->getData();
$keys = array_keys($keys);
reset($items);
if (!empty($this->csvFields))
{
$temp = [];
foreach ($this->csvFields as $f)
{
$exist = false;
// If we have a dot and it isn't part of the field name, we are dealing with relations
if (!$model->hasField($f) && strpos($f, '.'))
{
$methods = explode('.', $f);
$object = $item;
// Let's see if the relation exists
foreach ($methods as $method)
{
if (isset($object->$method) || property_exists($object, $method))
{
$exist = true;
$object = $object->$method;
}
else
{
$exist = false;
break;
}
}
}
if (in_array($f, $keys))
{
$temp[] = $f;
}
elseif ($exist)
{
$temp[] = $f;
}
}
$keys = $temp;
}
if ($this->csvHeader)
{
$csv = [];
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 = [];
foreach ($keys as $k)
{
// If our key contains a dot and it isn't part of the field name, we are dealing with relations
if (!$model->hasField($k) && strpos($k, '.'))
{
$methods = explode('.', $k);
$v = $item;
foreach ($methods as $method)
{
$v = $v->$method;
}
}
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";
}
}
$eventName = 'onAfter' . ucfirst($this->doTask);
$this->triggerEvent($eventName, [$tpl]);
return true;
}
}
PK �#]�t�! ! DataViewInterface.phpnu &1i� <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 2, or later
*/
namespace FOF30\View\DataView;
defined('_JEXEC') || die;
use Exception;
use FOF30\Container\Container;
use Joomla\CMS\Pagination\Pagination;
use stdClass;
interface DataViewInterface
{
/**
* 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 supported, otherwise a table with necessary information (saveOrder: should
* you enable DnD reordering; orderingColumn: which column has the ordering information).
*/
public function hasAjaxOrderingSupport();
/**
* Returns the internal list of useful variables to the benefit of header fields.
*
* @return stdClass
*/
public function getLists();
/**
* Returns a reference to the permissions object of this view
*
* @return stdClass
*/
public function getPerms();
/**
* Returns a reference to the pagination object of this view
*
* @return Pagination
*/
public function getPagination();
/**
* 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
*
* @throws Exception
*/
public function getName();
/**
* Returns a reference to the container attached to this View
*
* @return Container
*/
public function &getContainer();
/**
* Escapes a value for output in a view script.
*
* @param mixed $var The output to escape.
*
* @return string The escaped value.
*/
public function escape($var);
/**
* Returns the task being rendered by the view
*
* @return string
*/
public function getTask();
/**
* Get the layout.
*
* @return string The layout name
*/
public function getLayout();
/**
* Add a JS script file to the page generated by the CMS.
*
* There are three combinations of defer and async (see http://www.w3schools.com/tags/att_script_defer.asp):
* * $defer false, $async true: The script is executed asynchronously with the rest of the page
* (the script will be executed while the page continues the parsing)
* * $defer true, $async false: The script is executed when the page has finished parsing.
* * $defer false, $async false. (default) The script is loaded and executed immediately. When it finishes
* loading the browser continues parsing the rest of the page.
*
* When you are using $defer = true there is no guarantee about the load order of the scripts. Whichever
* script loads first will be executed first. The order they appear on the page is completely irrelevant.
*
* @param string $uri A path definition understood by parsePath, e.g. media://com_example/js/foo.js
* @param string $version (optional) Version string to be added to the URL
* @param string $type MIME type of the script
* @param boolean $defer Adds the defer attribute, see above
* @param boolean $async Adds the async attribute, see above
*
* @return $this Self, for chaining
*/
public function addJavascriptFile($uri, $version = null, $type = 'text/javascript', $defer = false, $async = false);
/**
* Adds an inline JavaScript script to the page header
*
* @param string $script The script content to add
* @param string $type The MIME type of the script
*
* @return $this Self, for chaining
*/
public function addJavascriptInline($script, $type = 'text/javascript');
/**
* Add a CSS file to the page generated by the CMS
*
* @param string $uri A path definition understood by parsePath, e.g. media://com_example/css/foo.css
* @param string $version (optional) Version string to be added to the URL
* @param string $type MIME type of the stylesheeet
* @param string $media Media target definition of the style sheet, e.g. "screen"
* @param array $attribs Array of attributes
*
* @return $this Self, for chaining
*/
public function addCssFile($uri, $version = null, $type = 'text/css', $media = null, $attribs = []);
/**
* Adds an inline stylesheet (inline CSS) to the page header
*
* @param string $css The stylesheet content to add
* @param string $type The MIME type of the script
*
* @return $this Self, for chaining
*/
public function addCssInline($css, $type = 'text/css');
}
PK �#]�D�2 2 Html.phpnu &1i� <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 2, or later
*/
namespace FOF30\View\DataView;
defined('_JEXEC') || die;
use Exception;
use FOF30\Render\RenderInterface;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
class Html extends Raw implements DataViewInterface
{
/** @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;
public function setPageTitle()
{
if (!$this->container->platform->isFrontend())
{
return '';
}
/** @var SiteApplication $app */
$app = Factory::getApplication();
$document = Factory::getDocument();
$menus = $app->getMenu();
$menu = $menus->getActive();
$title = null;
// Get the option and view name
$option = $this->container->componentName;
$view = $this->getName();
// Get the default page title translation key
$default = empty($this->defaultPageTitle) ? $option . '_TITLE_' . $view : $this->defaultPageTitle;
$params = $app->getParams($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', Text::_($default));
}
// Set the document title
$title = $params->get('page_title', '');
$sitename = $app->get('sitename');
if ($title == $sitename)
{
$title = Text::_($default);
}
if (empty($title))
{
$title = $sitename;
}
elseif ($app->get('sitename_pagetitles', 0) == 1)
{
$title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $title);
}
elseif ($app->get('sitename_pagetitles', 0) == 2)
{
$title = Text::sprintf('JPAGETITLE', $title, $app->get('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;
}
/**
* Runs before rendering the view template, echoing HTML to put before the
* view template's generated HTML
*
* @return void
*
* @throws Exception
*/
protected function preRender()
{
$view = $this->getName();
$task = $this->task;
// Don't load the toolbar on CLI
$platform = $this->container->platform;
if (!$platform->isCli())
{
$toolbar = $this->container->toolbar;
$toolbar->perms = $this->permissions;
$toolbar->renderToolbar($view, $task);
}
if ($platform->isFrontend() && $this->setFrontendPageTitle)
{
$this->setPageTitle();
}
$renderer = $this->container->renderer;
$renderer->preRender($view, $task);
}
/**
* Runs after rendering the view template, echoing HTML to put after the
* view template's generated HTML
*
* @return void
*
* @throws Exception
*/
protected function postRender()
{
$view = $this->getName();
$task = $this->task;
$renderer = $this->container->renderer;
if ($renderer instanceof RenderInterface)
{
$renderer->postRender($view, $task);
}
}
/**
* Executes before rendering the page for the Add task.
*/
protected function onBeforeAdd()
{
// Hide main menu
Factory::getApplication()->input->set('hidemainmenu', true);
parent::onBeforeAdd();
}
/**
* Executes before rendering the page for the Edit task.
*/
protected function onBeforeEdit()
{
// Hide main menu
Factory::getApplication()->input->set('hidemainmenu', true);
parent::onBeforeEdit();
}
}
PK �#]�ut�g'