C3 Front End Model for Item, Test: localhost/index.php?option=com_depot&view=part&id=1

This commit is contained in:
Thomas Kuschel 2023-11-19 12:14:40 +01:00
parent bedb36c136
commit 464f7bd1ac
6 changed files with 119 additions and 4 deletions

View File

@ -49,7 +49,7 @@ CREATE TABLE `#__depot` (
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`ordering`,`state`,`manufacturer_id`,`stock_id`,`package_id`) VALUES
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1,1,9),
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8)
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8),
('R_120R','r_120r','resistor, metalic',46,'2023-11-15 23:40:00',3,1,1,2,11);
DROP TABLE IF EXISTS `#__depot_manufacturer`;

View File

@ -2,12 +2,12 @@
<extension type="component" method="upgrade">
<name>Depot</name>
<author>KW4NZ</author>
<creationDate>2023-11-18</creationDate>
<creationDate>2023-11-19</creationDate>
<copyright>(C) KW4NZ Thomas Kuschel</copyright>
<license>GPL v2 +; see LICENSE.md</license>
<authorEmail>thomas@kuschel.at</authorEmail>
<authorUrl>https://kuschel.at</authorUrl>
<version>0.9.13</version>
<version>0.9.14</version>
<description>COM_DEPOT_XML_DESCRIPTION</description>
<namespace path="src/">KW4NZ\Component\Depot</namespace>
<install> <!-- Runs on install -->
@ -25,10 +25,17 @@
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
<files folder="site/">
<files folder="site">
<folder>src</folder>
<folder>tmpl</folder>
<!--
<file>CODING_STANDARDS.md</file>
<file>LICENSE.md</file>
<file>README.md</file>
<folder>forms</folder>
<folder>language</folder>
-->
</files>
<administration>
<!--

View File

@ -0,0 +1,25 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
namespace KW4NZ\Component\Depot\Site\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
class DisplayController extends BaseController
{
protected $default_view = 'part';
public function display($cacheable = false, $urlparams = [])
{
return parent::display($cacheable, $urlparams);
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
namespace KW4NZ\Component\Depot\Site\Model;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ItemModel;
class PartModel extends ItemModel
{
public function getItem($pk = null)
{
if ($pk == null) {
$pk = Factory::getApplication()->input->getInt('id');
}
$db = $this->getDatabase();
$query = $db->createQuery()
->select('*')
->from($db->quoteName('#__depot', 'd'))
->where([
$db->quoteName('d.id') . ' = ' . $db->quote($pk),
$db->quoteName('d.state') . ' = 1',
]);
$db->setQuery($query);
$item = $db->loadObject();
return $item;
}
}

View File

@ -0,0 +1,27 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
namespace KW4NZ\Component\Depot\Site\View\Part;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView
{
protected $item;
public function display($tpl = null)
{
$this->item = $this->get('Item');
parent::display($tpl);
}
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Depot.Site
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.14
*/
defined('_JEXEC') or die;
?>
<h1>
<?= $this->item->component_name; ?>
</h1>