Depot init
This commit is contained in:
0
admin/forms/dummy
Normal file
0
admin/forms/dummy
Normal file
1
admin/language/en-GB/com_depot.ini
Normal file
1
admin/language/en-GB/com_depot.ini
Normal file
@@ -0,0 +1 @@
|
||||
COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse"
|
4
admin/language/en-GB/com_depot.sys.ini
Normal file
4
admin/language/en-GB/com_depot.sys.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
COM_DEPOT_MENU="Depot"
|
||||
COM_DEPOT_MENU_MANUFACTURERS="Manufacturers"
|
||||
COM_DEPOT_MENU_STOCKS="Stock locations"
|
||||
COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse"
|
0
admin/layouts/dummy
Normal file
0
admin/layouts/dummy
Normal file
0
admin/services/dummy
Normal file
0
admin/services/dummy
Normal file
43
admin/sql/install.mysql.utf8.sql
Normal file
43
admin/sql/install.mysql.utf8.sql
Normal file
@@ -0,0 +1,43 @@
|
||||
DROP TABLE IF EXISTS `#__depot`;
|
||||
CREATE TABLE `#__depot`(
|
||||
`id` SERIAL,
|
||||
`component_name` VARCHAR(1024) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
|
||||
COMMENT 'unique component name (ASCII characters only)',
|
||||
`alias` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`description` VARCHAR(4000) NOT NULL DEFAULT '',
|
||||
`quantity` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`quantity_exp` INT(11) NOT NULL DEFAULT 0 COMMENT 'Exponent of the quantity (10^x of the number, usually 0 i.e. 10⁰)',
|
||||
`asset_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
|
||||
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`checked_out` INT(11) NOT NULL DEFAULT 0,
|
||||
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`modified_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
-- `parent_id` INT(11) NOT NULL DEFAULT 1,
|
||||
-- `level` INT(11) NOT NULL DEFAULT 0,
|
||||
`path` VARCHAR(400) NOT NULL DEFAULT '',
|
||||
`state` TINYINT(4) NOT NULL DEFAULT 0 COMMENT 'Published=1,Unpublished=0,Archived=2,Trashed=-2',
|
||||
`access` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
`category_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`params` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`image` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`manufacturer_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`datasheet_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`datasheet_alt` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`stock_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`version` int unsigned NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_state` (`state`),
|
||||
KEY `idx_stock_id` (`stock_id`),
|
||||
KEY `idx_manufacturer` (`manufacturer_id`),
|
||||
UNIQUE KEY `aliasindex` (`alias`,`manufacturer_id`,`stock_id`)
|
||||
) ENGINE=InnoDB
|
||||
AUTO_INCREMENT=0
|
||||
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
|
||||
`ordering`,`state`,`manufacturer_id`) VALUES
|
||||
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1),
|
||||
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2);
|
1
admin/sql/uninstall.mysql.utf8.sql
Normal file
1
admin/sql/uninstall.mysql.utf8.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS `#__depot`;
|
1
admin/sql/updates/mysql/0.0.1.sql
Normal file
1
admin/sql/updates/mysql/0.0.1.sql
Normal file
@@ -0,0 +1 @@
|
||||
-- database update
|
140
admin/src/Controller/DepotItemsController.php
Normal file
140
admin/src/Controller/DepotItemsController.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Depot item list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DepotItemsController extends AdminController
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_BANNERS'; //?????
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* @param ?MVCFactoryInterface $factory The factory.
|
||||
* @param ?CMSApplication $app The Application for the dispatcher
|
||||
* @param ?Input $input Input
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
|
||||
$this->registerTask('sticky_unpublish', 'sticky_publish');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Depot', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stick items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function sticky_publish()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
$ids = (array) $this->input->get('cid', [], 'int');
|
||||
$values = ['sticky_publish' => 1, 'sticky_unpublish' => 0];
|
||||
$task = $this->getTask();
|
||||
$value = ArrayHelper::getValue($values, $task, 0, 'int');
|
||||
|
||||
// Remove zero values resulting from input filter
|
||||
$ids = array_filter($ids);
|
||||
|
||||
if (empty($ids)) {
|
||||
$this->app->enqueueMessage(Text::_('COM_BANNERS_NO_BANNERS_SELECTED'), 'warning');
|
||||
} else {
|
||||
// Get the model.
|
||||
/** @var \Joomla\Component\Banners\Administrator\Model\BannerModel $model */
|
||||
$model = $this->getModel();
|
||||
|
||||
// Change the state of the records.
|
||||
if (!$model->stick($ids, $value)) {
|
||||
$this->app->enqueueMessage($model->getError(), 'warning');
|
||||
} else {
|
||||
if ($value == 1) {
|
||||
$ntext = 'COM_BANNERS_N_BANNERS_STUCK';
|
||||
} else {
|
||||
$ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK';
|
||||
}
|
||||
|
||||
$this->setMessage(Text::plural($ntext, \count($ids)));
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_banners&view=banners');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the number of published banners for quickicons
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function getQuickiconContent()
|
||||
{
|
||||
$model = $this->getModel('banners');
|
||||
|
||||
$model->setState('filter.published', 1);
|
||||
|
||||
$amount = (int) $model->getTotal();
|
||||
|
||||
$result = [];
|
||||
|
||||
$result['amount'] = $amount;
|
||||
$result['sronly'] = Text::plural('COM_BANNERS_N_QUICKICON_SRONLY', $amount);
|
||||
$result['name'] = Text::plural('COM_BANNERS_N_QUICKICON', $amount);
|
||||
|
||||
echo new JsonResponse($result);
|
||||
}
|
||||
}
|
48
admin/src/Controller/DepotsController.php
Normal file
48
admin/src/Controller/DepotsController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Depots list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DepotsController extends AdminController
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_DEPOT_DEPOTS';
|
||||
|
||||
/**
|
||||
* Method to get a model object, loading it if required
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Depot', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
}
|
71
admin/src/Controller/DisplayController.php
Normal file
71
admin/src/Controller/DisplayController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace KW4NZ\Component\Depot\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
// use Joomla\Component\Depot\Administrator\Helper\BannersHelper;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Depot display controller.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The default view.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'depots';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe URL parameters and their variable types
|
||||
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values
|
||||
*
|
||||
* @return BaseController|boolean This object to support chaining
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = [])
|
||||
{
|
||||
// BannersHelper::updateReset();
|
||||
|
||||
$view = $this->input->get('view', $this->default_view);
|
||||
$layout = $this->input->get('layout', 'default');
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Check for edit form.
|
||||
if ($view === 'depot' && $layout === 'edit' && !$this->checkEditId('com_depot.edit.depot', $id)) {
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
if (!\count($this->app->getMessageQueue())) {
|
||||
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
|
||||
}
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_depot&view=depots', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if ($view === 'client' && $layout === 'edit' && !$this->checkEditId('com_banners.edit.client', $id)) {
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
if (!\count($this->app->getMessageQueue())) {
|
||||
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
|
||||
}
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_banners&view=clients', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
return parent::display();
|
||||
}
|
||||
}
|
69
admin/src/Extension/DepotComponent.php
Normal file
69
admin/src/Extension/DepotComponent.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Extension;
|
||||
|
||||
use Joomla\CMS\Categories\CategoryServiceInterface;
|
||||
use Joomla\CMS\Categories\CategoryServiceTrait;
|
||||
use Joomla\CMS\Component\Router\RouterServiceInterface;
|
||||
use Joomla\CMS\Component\Router\RouterServiceTrait;
|
||||
use Joomla\CMS\Extension\BootableExtensionInterface;
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
|
||||
use Joomla\CMS\Tag\TagServiceInterface;
|
||||
use Joomla\CMS\Tag\TagServiceTrait;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use KW4NZ\Component\Depot\Administrator\Service\HTML\Depot;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
class DepotComponent extends MVCComponent implements
|
||||
BootableExtensionInterface,
|
||||
CategoryServiceInterface,
|
||||
RouterServiceInterface,
|
||||
TagServiceInterface
|
||||
{
|
||||
use HTMLRegistryAwareTrait;
|
||||
use RouterServiceTrait;
|
||||
use CategoryServiceTrait, TagServiceTrait {
|
||||
CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait;
|
||||
CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* Booting the extension. This is the function to set up the environment of the extension like
|
||||
* registering new class loaders, etc.
|
||||
*
|
||||
* If required, some initial set up can be done from services of the container, eg.
|
||||
* registering HTML services.
|
||||
*
|
||||
* @param ContainerInterface $container The container
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
public function boot(ContainerInterface $container)
|
||||
{
|
||||
$depot = new Depot();
|
||||
$depot->setDatabase($container->get(DatebaseInterface::class));
|
||||
|
||||
$this->getRegistry()->register('depot', $depot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the table name for the count items function for the given section.
|
||||
*
|
||||
* @param ?string $section The section
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getTableNameForSection(string $section = null)
|
||||
{
|
||||
|
||||
return 'depot';
|
||||
}
|
||||
}
|
211
admin/src/Model/DepotItemsModel.php
Normal file
211
admin/src/Model/DepotItemsModel.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
//use Joomla\CMS\MVC\Model\ListModel;
|
||||
//use Joomla\CMS\Factory;
|
||||
//use Joomla\Database\DatabaseInterface;
|
||||
//use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
\defined('_JEXEC') or die;
|
||||
/**
|
||||
* Depot list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DepotItemsModel extends ListModel {
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_BANNERS';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id',
|
||||
'name',
|
||||
'quantity',
|
||||
'state',
|
||||
'author',
|
||||
'created',
|
||||
'modifier',
|
||||
'language',
|
||||
'lft',
|
||||
'category_id',
|
||||
'access',
|
||||
'association',
|
||||
'published',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
protected function populateState($ordering = null, $direction = null) {
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Adjust the context to support modal layouts.
|
||||
if ($layout = $app->input->get('layout')) {
|
||||
$this->context .= '.' . $layout;
|
||||
}
|
||||
|
||||
// Adjust the context to support forced languages.
|
||||
$forcedLanguage = $app->input->get('forcedLanguage', '', 'CMD');
|
||||
if ($forcedLanguage) {
|
||||
$this->context .= '.' . $forcedLanguage;
|
||||
}
|
||||
|
||||
parent::populateState($ordering, $direction);
|
||||
|
||||
// If there's a forced language then define that filter for the query where clause
|
||||
if (!empty($forcedLanguage)) {
|
||||
$this->setState('filter.language', $forcedLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Initialize variables.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.name'),
|
||||
$db->quoteName('a.alias'),
|
||||
$db->quoteName('a.quantity'),
|
||||
$db->quoteName('a.quantity_exp'),
|
||||
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('')
|
||||
// @TODO, see J5 com_banners
|
||||
]
|
||||
)
|
||||
*/
|
||||
$query->select('a.id as id, a.name as name, a.quantity as quantity,
|
||||
a.quantity_exp as quantity_exp, a.manufacturer_id as manufacturer_id,
|
||||
a.datasheet_id as datasheet_id, a.datasheet_alt as datasheet_alt,
|
||||
a.stock_id as stock_id,
|
||||
a.greeting as greeting,
|
||||
a.state as state, a.created as created, a.access as access,
|
||||
a.modified as modified,
|
||||
a.checked_out as checked_out, a.checked_out_time as checked_out_time, a.catid as catid,
|
||||
a.lft as lft, a.rgt as rgt, a.parent_id as parent_id, a.level as level, a.path as path,
|
||||
a.image as imageInfo, a.latitude as latitude, a.longitude as longitude, a.alias as alias, a.language as language')
|
||||
->from($db->quoteName('#__jron', 'a'));
|
||||
|
||||
// Join over the categories.
|
||||
$query->select($db->quoteName('c.title', 'category_title'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON c.id = a.catid');
|
||||
|
||||
// Join with users table to get the username of the author
|
||||
$query->select($db->quoteName('u.username', 'author'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u') . ' ON u.id = a.created_by');
|
||||
|
||||
// Join with users table to get the username of the person who checked the record out
|
||||
$query->select($db->quoteName('u2.username', 'editor'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u2') . ' ON u2.id = a.checked_out');
|
||||
|
||||
// Join with users table to get the username of the last modifier of the stock
|
||||
$query->select($db->quoteName('u4.username', 'modifier'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u4') . ' ON u4.id = a.modified_by');
|
||||
|
||||
// Join with languages table to get the language title and image to display
|
||||
// Put these into fields called language_title and language_image so that
|
||||
// we can use the little com_content layout to display the map symbol
|
||||
$query->select($db->quoteName('l.title', 'language_title') . "," .$db->quoteName('l.image', 'language_image'))
|
||||
->join('LEFT', $db->quoteName('#__languages', 'l') . ' ON l.lang_code = a.language');
|
||||
|
||||
// Join over the associations - we just want to know if there are any, at this stage
|
||||
if (Associations::isEnabled())
|
||||
{
|
||||
$query->select('COUNT(asso2.id)>1 as association')
|
||||
->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_jron.item'))
|
||||
->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')
|
||||
->group('a.id');
|
||||
}
|
||||
|
||||
// Join over the access levels, to get the name of the access level
|
||||
$query->select('v.title AS access_level')
|
||||
->join('LEFT', '#__viewlevels AS v ON v.id = a.access');
|
||||
|
||||
// Filter: like / search
|
||||
$search = $this->getState('filter.search');
|
||||
|
||||
if (!empty($search)) {
|
||||
$like = $db->quote('%' . $search . '%');
|
||||
$query->where('a.name LIKE ' . $like);
|
||||
}
|
||||
|
||||
// Filter by (published) state
|
||||
$state = $this->getState('filter.state');
|
||||
|
||||
if (is_numeric($state)) {
|
||||
$query->where('a.state = ' . (int) $state);
|
||||
}
|
||||
elseif ($state === '') {
|
||||
$query->where('(a.state IN (0, 1))');
|
||||
}
|
||||
|
||||
// Filter by language, if the user has set that in the filter field
|
||||
$language = $this->getState('filter.language');
|
||||
if ($language) {
|
||||
$query->where('a.language = ' . $db->quote($language));
|
||||
}
|
||||
|
||||
// Filter by categories
|
||||
$catid = $this->getState('filter.category_id');
|
||||
if ($catid) {
|
||||
$query->where("a.catid = " . $db->quote($db->escape($catid)));
|
||||
}
|
||||
|
||||
// Display only records to which the user has access
|
||||
if (!$user->authorise('core.admin')) { // ie if not SuperUser
|
||||
$userAccessLevels = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $userAccessLevels . ')');
|
||||
$query->where('c.access IN (' . $userAccessLevels . ')');
|
||||
}
|
||||
|
||||
// exclude root part record
|
||||
$query->where('a.id > 1');
|
||||
|
||||
// Add the list ordering clause.
|
||||
$orderCol = $this->state->get('list.ordering', 'lft');
|
||||
$orderDirn = $this->state->get('list.direction', 'asc');
|
||||
|
||||
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn));
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
473
admin/src/Model/DepotModel.php
Normal file
473
admin/src/Model/DepotModel.php
Normal file
@@ -0,0 +1,473 @@
|
||||
<?php
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Table\TableInterface;
|
||||
use Joomla\CMS\Versioning\VersionableModelTrait;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DepotModel extends AdminModel
|
||||
{
|
||||
use VersionableModelTrait;
|
||||
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_DEPOT_DEPOT';
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_depot.depot';
|
||||
|
||||
/**
|
||||
* Batch copy/move command. If set to false, the batch copy/move command is not supported
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $batch_copymove = 'category_id';
|
||||
|
||||
/**
|
||||
* Allowed batch commands
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $batch_commands = [
|
||||
'client_id' => 'batchClient',
|
||||
'language_id' => 'batchLanguage',
|
||||
];
|
||||
|
||||
/**
|
||||
* Data cleanup after batch copying data
|
||||
*
|
||||
* @param TableInterface $table The table object containing the newly created item
|
||||
* @param integer $newId The id of the new item
|
||||
* @param integer $oldId The original item id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.2
|
||||
*/
|
||||
protected function cleanupPostBatchCopy(TableInterface $table, $newId, $oldId)
|
||||
{
|
||||
// Initialise clicks and impmade
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__depot'))
|
||||
->set($db->quoteName('clicks') . ' = 0')
|
||||
->set($db->quoteName('impmade') . ' = 0')
|
||||
->where($db->quoteName('id') . ' = :newId')
|
||||
->bind(':newId', $newId, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Batch client changes for a group of banners.
|
||||
*
|
||||
* @param string $value The new value matching a client.
|
||||
* @param array $pks An array of row IDs.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function batchClient($value, $pks, $contexts)
|
||||
{
|
||||
// Set the variables
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\BannerTable $table */
|
||||
$table = $this->getTable();
|
||||
|
||||
foreach ($pks as $pk) {
|
||||
if (!$user->authorise('core.edit', $contexts[$pk])) {
|
||||
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$table->reset();
|
||||
$table->load($pk);
|
||||
$table->cid = (int) $value;
|
||||
|
||||
if (!$table->store()) {
|
||||
$this->setError($table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
if (empty($record->id) || $record->state != -2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
return parent::canDelete($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to preprocess generating a new title in order to allow tables with alternative names
|
||||
* for alias and title to use the batch move and copy methods
|
||||
*
|
||||
* @param integer $categoryId The target category id
|
||||
* @param Table $table The \Joomla\CMS\Table\Table within which move or copy is taking place
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.8.12
|
||||
*/
|
||||
public function generateTitle($categoryId, $table)
|
||||
{
|
||||
// Alter the title & alias
|
||||
$data = $this->generateNewTitle($categoryId, $table->alias, $table->name);
|
||||
$table->name = $data['0'];
|
||||
$table->alias = $data['1'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can have its state changed.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
// Check against the category.
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.edit.state', 'com_banners.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
// Default to component settings if category not known.
|
||||
return parent::canEditState($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form. [optional]
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not. [optional]
|
||||
*
|
||||
* @return Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_depot.depot', 'depot', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Modify the form based on access controls.
|
||||
if (!$this->canEditState((object) $data)) {
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
//$form->setFieldAttribute('publish_up', 'disabled', 'true');
|
||||
//$form->setFieldAttribute('publish_down', 'disabled', 'true');
|
||||
$form->setFieldAttribute('state', 'disabled', 'true');
|
||||
//$form->setFieldAttribute('sticky', 'disabled', 'true');
|
||||
|
||||
// Disable fields while saving.
|
||||
// The controller has already verified this is a record you can edit.
|
||||
$form->setFieldAttribute('ordering', 'filter', 'unset');
|
||||
//$form->setFieldAttribute('publish_up', 'filter', 'unset');
|
||||
//$form->setFieldAttribute('publish_down', 'filter', 'unset');
|
||||
$form->setFieldAttribute('state', 'filter', 'unset');
|
||||
//$form->setFieldAttribute('sticky', 'filter', 'unset');
|
||||
}
|
||||
|
||||
// Don't allow to change the created_by user if not allowed to access com_users.
|
||||
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users')) {
|
||||
$form->setFieldAttribute('created_by', 'filter', 'unset');
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return mixed The data for the form.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$app = Factory::getApplication();
|
||||
$data = $app->getUserState('com_depot.edit.depot.data', []);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
|
||||
// Prime some default values.
|
||||
if ($this->getState('depot.id') == 0) {
|
||||
$filters = (array) $app->getUserState('com_depot.depots.filter');
|
||||
$filterCatId = $filters['category_id'] ?? null;
|
||||
|
||||
$data->set('catid', $app->getInput()->getInt('catid', $filterCatId));
|
||||
}
|
||||
}
|
||||
|
||||
$this->preprocessData('com_depot.depot', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to stick records.
|
||||
*
|
||||
* @param array $pks The ids of the items to publish.
|
||||
* @param integer $value The value of the published state
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function stick(&$pks, $value = 1)
|
||||
{
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\BannerTable $table */
|
||||
$table = $this->getTable();
|
||||
$pks = (array) $pks;
|
||||
|
||||
// Access checks.
|
||||
foreach ($pks as $i => $pk) {
|
||||
if ($table->load($pk)) {
|
||||
if (!$this->canEditState($table)) {
|
||||
// Prune items that you can't change.
|
||||
unset($pks[$i]);
|
||||
Factory::getApplication()->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to change the state of the records.
|
||||
if (!$table->stick($pks, $value, $this->getCurrentUser()->id)) {
|
||||
$this->setError($table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A protected method to get a set of ordering conditions.
|
||||
*
|
||||
* @param Table $table A record object.
|
||||
*
|
||||
* @return array An array of conditions to add to ordering queries.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getReorderConditions($table)
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
return [
|
||||
$db->quoteName('catid') . ' = ' . (int) $table->catid,
|
||||
$db->quoteName('state') . ' >= 0',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table prior to saving.
|
||||
*
|
||||
* @param Table $table A Table object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$date = Factory::getDate();
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if (empty($table->id)) {
|
||||
// Set the values
|
||||
$table->created = $date->toSql();
|
||||
$table->created_by = $user->id;
|
||||
|
||||
// Set ordering to the last item if not set
|
||||
if (empty($table->ordering)) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select('MAX(' . $db->quoteName('ordering') . ')')
|
||||
->from($db->quoteName('#__banners'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
} else {
|
||||
// Set the values
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->id;
|
||||
}
|
||||
|
||||
// Increment the content version number.
|
||||
$table->version++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows preprocessing of the Form object.
|
||||
*
|
||||
* @param Form $form The form object
|
||||
* @param array $data The data to be merged into the form object
|
||||
* @param string $group The plugin group to be executed
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.6.1
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
if ($this->canCreateCategory()) {
|
||||
$form->setFieldAttribute('catid', 'allowAdd', 'true');
|
||||
|
||||
// Add a prefix for categories created on the fly.
|
||||
$form->setFieldAttribute('catid', 'customPrefix', '#new#');
|
||||
}
|
||||
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
|
||||
// Create new category, if needed.
|
||||
$createCategory = true;
|
||||
|
||||
// If category ID is provided, check if it's valid.
|
||||
if (is_numeric($data['catid']) && $data['catid']) {
|
||||
$createCategory = !CategoriesHelper::validateCategoryId($data['catid'], 'com_banners');
|
||||
}
|
||||
|
||||
// Save New Category
|
||||
if ($createCategory && $this->canCreateCategory()) {
|
||||
$category = [
|
||||
// Remove #new# prefix, if exists.
|
||||
'title' => strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'],
|
||||
'parent_id' => 1,
|
||||
'extension' => 'com_banners',
|
||||
'language' => $data['language'],
|
||||
'published' => 1,
|
||||
];
|
||||
|
||||
/** @var \Joomla\Component\Categories\Administrator\Model\CategoryModel $categoryModel */
|
||||
$categoryModel = Factory::getApplication()->bootComponent('com_categories')
|
||||
->getMVCFactory()->createModel('Category', 'Administrator', ['ignore_request' => true]);
|
||||
|
||||
// Create new category.
|
||||
if (!$categoryModel->save($category)) {
|
||||
$this->setError($categoryModel->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the new category ID.
|
||||
$data['catid'] = $categoryModel->getState('category.id');
|
||||
}
|
||||
|
||||
// Alter the name for save as copy
|
||||
if ($input->get('task') == 'save2copy') {
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\BannerTable $origTable */
|
||||
$origTable = clone $this->getTable();
|
||||
$origTable->load($input->getInt('id'));
|
||||
|
||||
if ($data['name'] == $origTable->name) {
|
||||
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
|
||||
$data['name'] = $name;
|
||||
$data['alias'] = $alias;
|
||||
} else {
|
||||
if ($data['alias'] == $origTable->alias) {
|
||||
$data['alias'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$data['state'] = 0;
|
||||
}
|
||||
|
||||
if ($input->get('task') == 'save2copy' || $input->get('task') == 'copy') {
|
||||
$data['clicks'] = 0;
|
||||
$data['impmade'] = 0;
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the user allowed to create an on the fly category?
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 3.6.1
|
||||
*/
|
||||
private function canCreateCategory()
|
||||
{
|
||||
return $this->getCurrentUser()->authorise('core.create', 'com_depot');
|
||||
}
|
||||
}
|
189
admin/src/Model/DepotsModel.php
Normal file
189
admin/src/Model/DepotsModel.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace KW4NZ\Component\Jron\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
//use Joomla\CMS\Factory;
|
||||
//use Joomla\Database\DatabaseInterface;
|
||||
//use Joomla\CMS\Language\Associations;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
class JronitemsModel extends ListModel {
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'component_name',
|
||||
'alias',
|
||||
'description',
|
||||
'quantity',
|
||||
'quantity_exp',
|
||||
'asset_id',
|
||||
'state',
|
||||
'ordering',
|
||||
'author',
|
||||
'created',
|
||||
'created_by',
|
||||
'checked_out',
|
||||
'checked_out_time',
|
||||
'modifier',
|
||||
'language',
|
||||
'lft',
|
||||
'access',
|
||||
'association',
|
||||
'category_id',
|
||||
'published',
|
||||
'level', 'c.level',
|
||||
];
|
||||
}
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
protected function populateState($ordering = null, $direction = null) {
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Adjust the context to support modal layouts.
|
||||
if ($layout = $app->input->get('layout')) {
|
||||
$this->context .= '.' . $layout;
|
||||
}
|
||||
|
||||
// Adjust the context to support forced languages.
|
||||
$forcedLanguage = $app->input->get('forcedLanguage', '', 'CMD');
|
||||
if ($forcedLanguage) {
|
||||
$this->context .= '.' . $forcedLanguage;
|
||||
}
|
||||
|
||||
parent::populateState($ordering, $direction);
|
||||
|
||||
// If there's a forced language then define that filter for the query where clause
|
||||
if (!empty($forcedLanguage)) {
|
||||
$this->setState('filter.language', $forcedLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
protected function getListQuery() {
|
||||
|
||||
// Initialize variables.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.component_name'),
|
||||
$db->quoteName('a.alias'),
|
||||
$db->quoteName('a.description'),
|
||||
$db->quoteName('a.quantity'),
|
||||
$db->quoteName('a.quantity_exp'),
|
||||
$db->quoteName('a.asset_id'),
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('a.category_id'),
|
||||
$db->quoteName('a.state'),
|
||||
$db->quoteName('a.ordering'),
|
||||
]
|
||||
)
|
||||
)
|
||||
/*
|
||||
$query->select('a.id as id, a.name as name, a.quantity as quantity,
|
||||
a.quantity_exp as quantity_exp, a.manufacturer_id as manufacturer_id,
|
||||
a.datasheet_id as datasheet_id, a.datasheet_alt as datasheet_alt,
|
||||
a.stock_id as stock_id,
|
||||
a.greeting as greeting,
|
||||
a.state as state, a.created as created, a.access as access,
|
||||
a.modified as modified,
|
||||
a.checked_out as checked_out, a.checked_out_time as checked_out_time, a.catid as catid,
|
||||
a.lft as lft, a.rgt as rgt, a.parent_id as parent_id, a.level as level, a.path as path,
|
||||
a.image as imageInfo, a.latitude as latitude, a.longitude as longitude, a.alias as alias, a.language as language')
|
||||
->from($db->quoteName('#__jron', 'a'));
|
||||
*/
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('u.name', 'editor'),
|
||||
$db->quoteName('c.title', 'category_title'),
|
||||
// @TODO add manufacturers and stocks too
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__depot', 'a'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('a.checked_out'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.category_id'))
|
||||
// @TODO join also with manufacturers and stocks
|
||||
;
|
||||
//
|
||||
$published = (string) $this->getState('filter.published');
|
||||
if (is_numeric($published)) {
|
||||
$published = (int) $published;
|
||||
$query->where($db->quoteName('a.state') . ' = :published')
|
||||
->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where($db->quoteName('a.state') . ' IN (0, 1)');
|
||||
}
|
||||
|
||||
// Filter by category
|
||||
$category_id = $this->getState('filter.category_id');
|
||||
if (is_numeric($category_id)) {
|
||||
$category_id = (int) $category_id;
|
||||
$query->where($db->quoteName('a.category_id') . ' = :category_id')
|
||||
->bind(':category_id', $category_id, ParameterType::INTEGER);
|
||||
}
|
||||
// @TODO Filter by manufacturer and stock
|
||||
|
||||
// Filter by search in title
|
||||
if ($search = $this->getState('filter.search')) {
|
||||
if (stripos($search, 'id:') === 0) {
|
||||
$search = (int) substr($search, 3);
|
||||
$query->where($db->quoteName('a.id') . ' = :search')
|
||||
->bind(':search', $search, ParameterType::INTEGER);
|
||||
} else {
|
||||
$search = '%' . str_replace(' ', '%', trim($search)) . '%';
|
||||
$query->where('(' . $db->quoteName('a.component_name') . ' LIKE :search1 OR ' . $db->quoteName('a.alias') . ' LIKE :search2)')
|
||||
->bind([':search1', ':search2'], $search);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on the level.
|
||||
if ($level = (int) $this->getState('filter.level')) {
|
||||
$query->where($db->quoteName('c.level') . ' <= :level')
|
||||
->bind(':level', $level, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$orderCol = $this->state->get('list.ordering', 'a.component_name');
|
||||
$orderDirn = $this->state->get('list.direction', 'ASC');
|
||||
|
||||
|
||||
if ($orderCol === 'a.ordering' || $orderCol === 'category_title') {
|
||||
$ordering = [
|
||||
$db->quoteName('c.title') . ' ' . $db->escape($orderDirn),
|
||||
$db->quoteName('a.ordering') . ' ' . $db->escape($orderDirn),
|
||||
];
|
||||
} else {
|
||||
if ($orderCol === 'client_name') {
|
||||
$orderCol = 'cl.name';
|
||||
}
|
||||
|
||||
$ordering = $db->escape($orderCol) . ' ' . $db->escape($orderDirn);
|
||||
}
|
||||
|
||||
$query->order($ordering);
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
126
admin/src/Service/Html/Depot.php
Normal file
126
admin/src/Service/Html/Depot.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Service\Html;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Database\DatabaseAwareTrait;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner HTML class.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class Depot
|
||||
{
|
||||
use DatabaseAwareTrait;
|
||||
|
||||
/**
|
||||
* Display a batch widget for the client selector.
|
||||
*
|
||||
* @return string The necessary HTML for the widget.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function clients()
|
||||
{
|
||||
// Create the batch selector to change the client on a selection list.
|
||||
return implode(
|
||||
"\n",
|
||||
[
|
||||
'<label id="batch-client-lbl" for="batch-client-id">',
|
||||
Text::_('COM_BANNERS_BATCH_CLIENT_LABEL'),
|
||||
'</label>',
|
||||
'<select class="form-select" name="batch[client_id]" id="batch-client-id">',
|
||||
'<option value="">' . Text::_('COM_BANNERS_BATCH_CLIENT_NOCHANGE') . '</option>',
|
||||
'<option value="0">' . Text::_('COM_BANNERS_NO_CLIENT') . '</option>',
|
||||
HTMLHelper::_('select.options', static::clientlist(), 'value', 'text'),
|
||||
'</select>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function clientlist()
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('id', 'value'),
|
||||
$db->quoteName('component_name', 'text'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__depot_clients'))
|
||||
->order($db->quoteName('component_name'));
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$options = $db->loadObjectList();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pinned state on a grid
|
||||
*
|
||||
* @param integer $value The state value.
|
||||
* @param integer $i The row index
|
||||
* @param boolean $enabled An optional setting for access control on the action.
|
||||
* @param string $checkbox An optional prefix for checkboxes.
|
||||
*
|
||||
* @return string The Html code
|
||||
*
|
||||
* @see HTMLHelperJGrid::state
|
||||
* @since 2.5.5
|
||||
*/
|
||||
public function pinned($value, $i, $enabled = true, $checkbox = 'cb')
|
||||
{
|
||||
$states = [
|
||||
1 => [
|
||||
'sticky_unpublish',
|
||||
'COM_BANNERS_BANNERS_PINNED',
|
||||
'COM_BANNERS_BANNERS_HTML_UNPIN_BANNER',
|
||||
'COM_BANNERS_BANNERS_PINNED',
|
||||
true,
|
||||
'publish',
|
||||
'publish',
|
||||
],
|
||||
0 => [
|
||||
'sticky_publish',
|
||||
'COM_BANNERS_BANNERS_UNPINNED',
|
||||
'COM_BANNERS_BANNERS_HTML_PIN_BANNER',
|
||||
'COM_BANNERS_BANNERS_UNPINNED',
|
||||
true,
|
||||
'unpublish',
|
||||
'unpublish',
|
||||
],
|
||||
];
|
||||
|
||||
return HTMLHelper::_('jgrid.state', $states, $value, $i, 'depots.', $enabled, true, $checkbox);
|
||||
}
|
||||
}
|
209
admin/src/View/Depots/HtmlView.php
Normal file
209
admin/src/View/Depots/HtmlView.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_depot
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\View\Depots;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Pagination\Pagination;
|
||||
use Joomla\CMS\Toolbar\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
use KW4NZ\Component\Depot\Administrator\Model\DepotsModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of banners.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The search tools form
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.6
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
public $activeFilters = [];
|
||||
|
||||
/**
|
||||
* Category data
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $categories = [];
|
||||
|
||||
/**
|
||||
* An array of items
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var Pagination
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var Registry
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Is this view an Empty State
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $isEmptyState = false;
|
||||
|
||||
/**
|
||||
* Method to display the view.
|
||||
*
|
||||
* @param string $tpl A template file to load. [optional]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var DepotsModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->categories = $model->getCategoryOrders();
|
||||
$this->items = $model->getItems();
|
||||
$this->pagination = $model->getPagination();
|
||||
$this->state = $model->getState();
|
||||
$this->filterForm = $model->getFilterForm();
|
||||
$this->activeFilters = $model->getActiveFilters();
|
||||
|
||||
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
|
||||
$this->setLayout('emptystate');
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
// We do not need to filter by language when multilingual is disabled
|
||||
if (!Multilanguage::isEnabled()) {
|
||||
unset($this->activeFilters['language']);
|
||||
$this->filterForm->removeField('language', 'filter');
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
$canDo = ContentHelper::getActions('com_depot', 'category', $this->state->get('filter.category_id'));
|
||||
$user = $this->getCurrentUser();
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_DEPOT_MANAGER_DEPOTS'), 'bookmark depot');
|
||||
|
||||
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_depot', 'core.create')) > 0) {
|
||||
$toolbar->addNew('depot.add');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')))) {
|
||||
/** @var DropdownButton $dropdown */
|
||||
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
|
||||
->toggleSplit(false)
|
||||
->icon('icon-ellipsis-h')
|
||||
->buttonClass('btn btn-action')
|
||||
->listCheck(true);
|
||||
|
||||
$childBar = $dropdown->getChildToolbar();
|
||||
|
||||
if ($canDo->get('core.edit.state')) {
|
||||
if ($this->state->get('filter.published') != 2) {
|
||||
$childBar->publish('depot.publish')->listCheck(true);
|
||||
|
||||
$childBar->unpublish('depot.unpublish')->listCheck(true);
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') != -1) {
|
||||
if ($this->state->get('filter.published') != 2) {
|
||||
$childBar->archive('depot.archive')->listCheck(true);
|
||||
} elseif ($this->state->get('filter.published') == 2) {
|
||||
$childBar->publish('publish')->task('depot.publish')->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
$childBar->checkin('depot.checkin');
|
||||
|
||||
if ($this->state->get('filter.published') != -2) {
|
||||
$childBar->trash('depot.trash')->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('depot.delete', 'JTOOLBAR_EMPTY_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
// Add a batch button
|
||||
if (
|
||||
$user->authorise('core.create', 'com_depot')
|
||||
&& $user->authorise('core.edit', 'com_depot')
|
||||
&& $user->authorise('core.edit.state', 'com_depot')
|
||||
) {
|
||||
$childBar->popupButton('batch', 'JTOOLBAR_BATCH')
|
||||
->selector('collapseModal')
|
||||
->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->authorise('core.admin', 'com_depot') || $user->authorise('core.options', 'com_depot')) {
|
||||
$toolbar->preferences('com_depot');
|
||||
}
|
||||
|
||||
$toolbar->help('Depots');
|
||||
}
|
||||
}
|
0
admin/src/dummy
Normal file
0
admin/src/dummy
Normal file
195
admin/tmpl/depots/default.php
Normal file
195
admin/tmpl/depots/default.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
\defined('_JEXEC') or die;
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Banners\HtmlView $this */
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('table.columns')
|
||||
->useScript('multiselect');
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->get('id');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$saveOrder = $listOrder == 'a.ordering';
|
||||
|
||||
if ($saveOrder && !empty($this->items)) {
|
||||
$saveOrderingUrl = 'index.php?option=com_depot&task=depots.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
HTMLHelper::_('draggablelist.draggable');
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_depot&view=depots'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php
|
||||
// Search tools bar
|
||||
echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]);
|
||||
?>
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table" id="bannerList">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_BANNERS_BANNERS_TABLE_CAPTION'); ?>,
|
||||
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
|
||||
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
||||
</td>
|
||||
<th scope="col" class="w-1 text-center d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_NAME', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 text-center d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_STICKY', 'a.sticky', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CLIENT', 'client_name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_IMPRESSIONS', 'impmade', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CLICKS', 'clicks', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'a.language', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th scope="col" class="w-5 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody <?php if ($saveOrder) :
|
||||
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true"<?php
|
||||
endif; ?>>
|
||||
<?php foreach ($this->items as $i => $item) :
|
||||
$ordering = ($listOrder == 'ordering');
|
||||
$item->cat_link = Route::_('index.php?option=com_categories&extension=com_banners&task=edit&type=other&cid[]=' . $item->catid);
|
||||
$canCreate = $user->authorise('core.create', 'com_banners.category.' . $item->catid);
|
||||
$canEdit = $user->authorise('core.edit', 'com_banners.category.' . $item->catid);
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out);
|
||||
$canChange = $user->authorise('core.edit.state', 'com_banners.category.' . $item->catid) && $canCheckin;
|
||||
?>
|
||||
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
|
||||
</td>
|
||||
<td class="text-center d-none d-md-table-cell">
|
||||
<?php
|
||||
$iconClass = '';
|
||||
|
||||
if (!$canChange) {
|
||||
$iconClass = ' inactive';
|
||||
} elseif (!$saveOrder) {
|
||||
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
|
||||
}
|
||||
?>
|
||||
<span class="sortable-handler <?php echo $iconClass ?>">
|
||||
<span class="icon-ellipsis-v" aria-hidden="true"></span>
|
||||
</span>
|
||||
<?php if ($canChange && $saveOrder) : ?>
|
||||
<input type="text" name="order[]" size="5"
|
||||
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order hidden">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'banners.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
|
||||
</td>
|
||||
<th scope="row">
|
||||
<div class="break-word">
|
||||
<?php if ($item->checked_out) : ?>
|
||||
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'banners.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit) : ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_banners&task=banner.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->name); ?>">
|
||||
<?php echo $this->escape($item->name); ?></a>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($item->name); ?>
|
||||
<?php endif; ?>
|
||||
<div class="small break-word">
|
||||
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
|
||||
</div>
|
||||
<div class="small">
|
||||
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
<td class="text-center d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('banner.pinned', $item->sticky, $i, $canChange); ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->client_name; ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo Text::sprintf('COM_BANNERS_IMPRESSIONS', $item->impmade, $item->imptotal ?: Text::_('COM_BANNERS_UNLIMITED')); ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->clicks; ?> -
|
||||
<?php echo sprintf('%.2f%%', $item->impmade ? 100 * $item->clicks / $item->impmade : 0); ?>
|
||||
</td>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php // Load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php // Load the batch processing form. ?>
|
||||
<?php
|
||||
if (
|
||||
$user->authorise('core.create', 'com_banners')
|
||||
&& $user->authorise('core.edit', 'com_banners')
|
||||
&& $user->authorise('core.edit.state', 'com_banners')
|
||||
) : ?>
|
||||
<?php echo HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'collapseModal',
|
||||
[
|
||||
'title' => Text::_('COM_BANNERS_BATCH_OPTIONS'),
|
||||
'footer' => $this->loadTemplate('batch_footer')
|
||||
],
|
||||
$this->loadTemplate('batch_body')
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="boxchecked" value="0">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
0
admin/tmpl/dummy
Normal file
0
admin/tmpl/dummy
Normal file
Reference in New Issue
Block a user