| Current Path : /home/cbequiperp/www/administrator/components/com_flexicontent/views/tagelement/ |
| Current File : /home/cbequiperp/www/administrator/components/com_flexicontent/views/tagelement/view.html.php |
<?php
/**
* @package FLEXIcontent
* @version 3.3
*
* @author Emmanuel Danan, Georgios Papadakis, Yannick Berges, others, see contributor page
* @link https://flexicontent.org
* @copyright Copyright © 2018, FLEXIcontent team, All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die('Restricted access');
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
JLoader::register('FlexicontentViewBaseRecords', JPATH_ADMINISTRATOR . '/components/com_flexicontent/helpers/base/view_records.php');
/**
* HTML View class for the FLEXIcontent tagelement screen
*/
class FlexicontentViewTagelement extends FlexicontentViewBaseRecords
{
var $proxy_option = 'com_tags';
var $title_propname = 'name';
var $state_propname = 'published';
var $db_tbl = 'flexicontent_tags';
var $name_singular = 'tag';
public function display($tpl = null)
{
/**
* Initialise variables
*/
global $globalcats;
$app = JFactory::getApplication();
$jinput = $app->input;
$document = JFactory::getDocument();
$user = JFactory::getUser();
$cparams = JComponentHelper::getParams('com_flexicontent');
$session = JFactory::getSession();
$db = JFactory::getDbo();
$option = $jinput->getCmd('option', '');
$view = $jinput->getCmd('view', '');
$task = $jinput->getCmd('task', '');
$layout = $jinput->getString('layout', 'default');
$isAdmin = $app->isClient('administrator');
$isCtmpl = $jinput->getCmd('tmpl') === 'component';
// Some flags & constants
$useAssocs = flexicontent_db::useAssociations();
// Load Joomla language files of other extension
if (!empty($this->proxy_option))
{
JFactory::getLanguage()->load($this->proxy_option, JPATH_ADMINISTRATOR, 'en-GB', true);
JFactory::getLanguage()->load($this->proxy_option, JPATH_ADMINISTRATOR, null, true);
}
// Get model
$model = $this->getModel();
$model_s = $this->getModel($this->name_singular);
// Performance statistics
if ($print_logging_info = $cparams->get('print_logging_info'))
{
global $fc_run_times;
}
/**
* Get filters and ordering
*/
$count_filters = 0;
// Order and order direction
$filter_order = $model->getState('filter_order');
$filter_order_Dir = $model->getState('filter_order_Dir');
// Various filters
$filter_state = $model->getState('filter_state');
$filter_assigned = $model->getState('filter_assigned');
if (strlen($filter_state)) $count_filters++;
if (strlen($filter_assigned)) $count_filters++;
// Text search
$scope = $model->getState('scope');
$search = $model->getState('search');
$search = StringHelper::trim(StringHelper::strtolower($search));
/**
* Add css and js to document
*/
if ($layout !== 'indexer')
{
// Add css to document
if ($isAdmin)
{
!JFactory::getLanguage()->isRtl()
? $document->addStyleSheet(JUri::base(true).'/components/com_flexicontent/assets/css/flexicontentbackend.css', array('version' => FLEXI_VHASH))
: $document->addStyleSheet(JUri::base(true).'/components/com_flexicontent/assets/css/flexicontentbackend_rtl.css', array('version' => FLEXI_VHASH));
!JFactory::getLanguage()->isRtl()
? $document->addStyleSheet(JUri::base(true).'/components/com_flexicontent/assets/css/' . (FLEXI_J40GE ? 'j4x.css' : 'j3x.css'), array('version' => FLEXI_VHASH))
: $document->addStyleSheet(JUri::base(true).'/components/com_flexicontent/assets/css/' . (FLEXI_J40GE ? 'j4x_rtl.css' : 'j3x_rtl.css'), array('version' => FLEXI_VHASH));
}
else
{
!JFactory::getLanguage()->isRtl()
? $document->addStyleSheet(JUri::base(true).'/components/com_flexicontent/assets/css/flexicontent.css', array('version' => FLEXI_VHASH))
: $document->addStyleSheet(JUri::base(true).'/components/com_flexicontent/assets/css/flexicontent_rtl.css', array('version' => FLEXI_VHASH));
}
// Add JS frameworks
flexicontent_html::loadFramework('select2');
// Load custom behaviours: form validation, popup tooltips
JHtml::_('behavior.formvalidator');
JHtml::_('bootstrap.tooltip');
// Add js function to overload the joomla submitform validation
$document->addScript(JUri::root(true).'/components/com_flexicontent/assets/js/admin.js', array('version' => FLEXI_VHASH));
$document->addScript(JUri::root(true).'/components/com_flexicontent/assets/js/validate.js', array('version' => FLEXI_VHASH));
}
/**
* Create Submenu & Toolbar
*/
// Create Submenu (and also check access to current view)
// NA
// Create document/toolbar titles
$doc_title = JText::_( 'FLEXI_SELECTITEM' );
$document->setTitle($doc_title);
// Create the toolbar
// NA
/**
* Get data from the model, note data retrieval must be before
* getTotal() and getPagination() because it also calculates total rows
*/
if ( $print_logging_info ) $start_microtime = microtime(true);
$rows = $this->get('Data');
if ( $print_logging_info ) @$fc_run_times['execute_main_query'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
// Create pagination object
$pagination = $this->get('Pagination');
/**
* Get assigned items (via separate query), do this is if not already retrieved
* when we order by assigned items, then this is already done via main DB query
*/
if ($filter_order !== 'nrassigned')
{
$rowids = array();
foreach ($rows as $row)
{
$rowids[] = $row->id;
}
if ( $print_logging_info ) $start_microtime = microtime(true);
$rowtotals = $model->getAssignedItems($rowids);
if ( $print_logging_info ) @$fc_run_times['execute_sec_queries'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
foreach ($rows as $row)
{
$row->nrassigned = isset($rowtotals[$row->id]) ? $rowtotals[$row->id]->nrassigned : 0;
}
}
/**
* Create List Filters
*/
$lists = array();
// Build publication state filter
$fieldname = 'filter_state';
$elementid = 'filter_state';
$value = $filter_state;
//$options = JHtml::_('jgrid.publishedOptions');
$options = array();
foreach ($model_s->supported_conditions as $condition_value => $condition_name)
{
$options[] = JHtml::_('select.option', $condition_value, JText::_($condition_name));
}
array_unshift($options, JHtml::_('select.option', '', '-'/*'FLEXI_STATE'*/));
$lists[$elementid] = $this->getFilterDisplay(array(
'label' => JText::_('FLEXI_STATE'),
'html' => JHtml::_('select.genericlist',
$options,
$fieldname,
array(
'class' => $this->select_class,
'size' => '1',
'onchange' => 'if (!!document.adminForm.limitstart) document.adminForm.limitstart.value=0; Joomla.submitform();',
),
'value',
'text',
$value,
$elementid,
$translate = true
),
));
// Build orphaned/assigned filter
$options = array(
JHtml::_('select.option', '', '-'/*'FLEXI_ALL_TAGS'*/),
JHtml::_('select.option', 'O', 'FLEXI_ORPHANED'),
JHtml::_('select.option', 'A', 'FLEXI_ASSIGNED'),
);
$fieldname = 'filter_assigned';
$elementid = 'filter_assigned';
$value = $filter_assigned;
$lists[$elementid] = $this->getFilterDisplay(array(
'label' => JText::_('FLEXI_ASSIGNED'),
'html' => JHtml::_('select.genericlist',
$options,
$fieldname,
array(
'class' => $this->select_class,
'size' => '1',
'onchange' => 'if (!!document.adminForm.limitstart) document.adminForm.limitstart.value=0; Joomla.submitform();',
),
'value',
'text',
$value,
$elementid,
$translate = true
),
));
// Build text search scope
$scopes = null;
$lists['scope_tip'] = '';
$lists['scope'] = $this->getScopeSelectorDisplay($scopes, $scope);
$this->scope_title = isset($scopes[$scope]) ? $scopes[$scope] : reset($scopes);
// Text search filter value
$lists['search'] = $search;
// Table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
/**
* Assign data to template
*/
$this->count_filters = $count_filters;
$this->lists = $lists;
$this->rows = $rows;
$this->pagination = $pagination;
$this->perms = FlexicontentHelperPerm::getPerm();
$this->option = $option;
$this->view = $view;
$this->state = $this->get('State');
/**
* Render view's template
*/
if ( $print_logging_info ) { global $fc_run_times; $start_microtime = microtime(true); }
parent::display($tpl);
if ( $print_logging_info ) @$fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
}
}