chore: update project structure with basic mvc approach

This commit is contained in:
Marvin Flock
2025-03-28 14:23:12 +01:00
parent 0c9a94a07f
commit 4ca16747af
16 changed files with 4011 additions and 4710 deletions
+4
View File
@@ -71,6 +71,10 @@ export const config = {
src: './releasefiles/administrator/language/**/**', src: './releasefiles/administrator/language/**/**',
dest: 'sourcefiles/com_sportsmanager/admin/language' dest: 'sourcefiles/com_sportsmanager/admin/language'
}, },
{
src: './releasefiles/administrator/services/**/**',
dest: 'sourcefiles/com_sportsmanager/admin/services'
},
{ {
src: './releasefiles/sportsmanager.xml', src: './releasefiles/sportsmanager.xml',
dest: 'sourcefiles/com_sportsmanager/' dest: 'sourcefiles/com_sportsmanager/'
@@ -1,23 +0,0 @@
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
// Require the base controller
require_once (JPATH_COMPONENT.DS.'controller.php');
// Require specific controller if requested
//if($controller = JRequest::getVar('controller')) {
// require_once (JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
//}
// Create the controller
//$classname = 'AutosController'.$controller;
//$controller = new $classname( );
// Perform the Request task
//$controller->execute( JRequest::getVar('task'));
// Redirect if set by the controller
//$controller->redirect();
?>
@@ -1,31 +0,0 @@
<?php
/*
* Sports Manager (C) 2006-2020, Sven Nickel
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* General Controller of SportsManager component
*/
class SportsManagerController extends JControllerLegacy
{
/**
* display task
*
* @return void
*/
function display($cachable = false, $urlparams = false)
{
// set default view if not set
$input = JFactory::getApplication()->input;
$input->set('view', $input->getCmd('view', 'SportsManager'));
// call parent behavior
parent::display($cachable);
}
}
@@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_inlinecontact
*
* @copyright (C) Alexander Niklaus. All rights reserved.
* @license GNU General Public License version 2 or later
* @link https://an-software.net
*/
defined('_JEXEC') or die;
use Dtfb\Component\com_sportsmanager\Administrator\Extension\SportsmanagerComponent;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* The contact service provider.
*
* @since 1.0.0
*/
return new class implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 1.0.0
*/
public function register(Container $container): void
{
$container->registerServiceProvider(new MVCFactory('\\Dtfb\\Component\\com_sportsmanager'));
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Dtfb\\Component\\com_sportsmanager'));
$container->set(
ComponentInterface::class,
function (Container $container) {
$component = new SportsmanagerComponent($container->get(ComponentDispatcherFactoryInterface::class));
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
return $component;
}
);
}
};
@@ -1,19 +0,0 @@
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import joomla controller library
jimport('joomla.application.component.controller');
// Get an instance of the controller prefixed by HelloWorld
$controller = JControllerLegacy::getInstance('SportsManager');
// Get the task
$jinput = JFactory::getApplication()->input;
$task = $jinput->get('task', "", 'STR' );
// Perform the Request task
$controller->execute($task);
// Redirect if set by the controller
$controller->redirect();
@@ -0,0 +1,20 @@
<?php
/*
* Sports Manager (C) 2006-2020, Sven Nickel
*/
namespace Dtfb\Component\com_sportsmanager\Administrator\Controller;
// No direct access to this file
use Joomla\CMS\MVC\Controller\BaseController;
defined('_JEXEC') or die('Restricted access');
/**
* General Controller of SportsManager component
* @since 1.0.0
*/
class DisplayController extends BaseController
{
protected $default_view = 'sportsmanager';
}
@@ -0,0 +1,15 @@
<?php
namespace Dtfb\Component\com_sportsmanager\Administrator\Extension;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Extension\MVCComponent;
use function defined;
/**
* Component class for com_sportsmanager
*
* @since 2.0.0
*/
class SportsmanagerComponent extends MVCComponent {}
@@ -0,0 +1,32 @@
<?php
/*
* Sports Manager (C) 2006-2020, Sven Nickel
*/
namespace Dtfb\Component\com_sportsmanager\Administrator\View\Sportsmanager;
// No direct access to this file
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
defined('_JEXEC') or die('Restricted access');
/**
* SportsManager View
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView
{
function display($tpl = null): void
{
ToolbarHelper::title(Text::_('COM_SPORTSMANAGER'));
?>
<h2><?php echo Text::_('COM_SPORTSMANAGER'); ?> Copyright &copy; 2006 &#8211; 2014 Sven Nickel</h2>
<?php
// Display the template
parent::display($tpl);
}
}
@@ -1,8 +1,8 @@
<?php <?php
/* /*
* Sports Manager (C) 2006-2020, Sven Nickel * Sports Manager (C) 2006-2020, Sven Nickel
*/ */
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
@@ -1 +0,0 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1 +0,0 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1 +0,0 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -1,49 +0,0 @@
<?php
/*
* Sports Manager (C) 2006-2020, Sven Nickel
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* SportsManager View
*/
class SportsManagerViewSportsManager extends JViewLegacy
{
/**
* SportsManager view display method
* @return void
*/
function display($tpl = null)
{
JToolbarHelper::title(JText::_('COM_SPORTSMANAGER'));
?>
<h2><?php echo JText::_('COM_SPORTSMANAGER'); ?> Copyright &copy; 2006 &#8211; 2014 Sven Nickel</h2>
<?php
/*
// Get data from the model
$items = $this->get('Items');
$pagination = $this->get('Pagination');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Assign data to the view
$this->items = $items;
$this->pagination = $pagination;
*/
// Display the template
parent::display($tpl);
}
}
File diff suppressed because it is too large Load Diff
@@ -1,57 +1,46 @@
<?php <?php
/* /*
* Sports Manager (C) 2006-2020, Sven Nickel * Sports Manager (C) 2006-2020, Sven Nickel
*/ */
// Check to ensure this file is included in Joomla! namespace Dtfb\Component\com_sportsmanager\Site\Controller;
defined('_JEXEC') or die();
jimport('joomla.application.component.controller'); // Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController; use Joomla\CMS\MVC\Controller\BaseController;
/** /**
* @package SportsManager.Site * @package SportsManager.Site
* @subpackage com_sportsmanager * @subpackage com_sportsmanager
* *
* @copyright Copyright (C) 2020 John Smith. All rights reserved. * @copyright Copyright (C) 2020 John Smith. All rights reserved.
* @license GNU General Public License version 3; see LICENSE * @license GNU General Public License version 3; see LICENSE
*/ */
/** /**
* Class DisplayController * Class DisplayController
* @since 2.0.0 * @since 2.0.0
* The DisplayController class handles the display of views in the application. * The DisplayController class handles the display of views in the application.
* It extends the BaseController class. * It extends the BaseController class.
*/ */
class DisplayController extends BaseController { class DisplayController extends BaseController {
/** /**
* Displays the view for the given URL parameters. * Displays the view for the given URL parameters.
* *
* @param bool $cachable Whether the view can be cached or not. Default is false. * @param bool $cachable Whether the view can be cached or not. Default is false.
* @param array $urlparams The URL parameters to be passed to the view. Default is an empty array. * @param array $urlparams The URL parameters to be passed to the view. Default is an empty array.
* @param array $safeurlparams An associative array of 'safe' URL parameters and their variable types. * @param array|null $safeurlparams An associative array of 'safe' URL parameters and their variable types.
* *
* @return void * @return void
* @throws Exception * @throws Exception
* @since 2.0.0 * @since 2.0.0
*/ */
public function display($cachable = false, $urlparams = array(), $safeurlparams = null) { public function display($cachable = false, $urlparams = array(), array $safeurlparams = null): void
{
$document = Factory::getDocument(); require_once JPATH_SITE . '/components/com_sportsmanager/sportsmanager.php';
$viewName = $this->input->getCmd('view', 'default'); }
$viewFormat = $document->getType(); }
$view = $this->getView($viewName, $viewFormat);
$view->document = $document;
$app = JFactory::getApplication();
$input = $app->input;
$layout = $input->get('layout', '', 'STRING');
//var_dump($layout);
$view->display($layout);
}
}
+7 -6
View File
@@ -8,18 +8,19 @@
<license>GNU/GPL</license> <license>GNU/GPL</license>
<version>2.0.0</version> <version>2.0.0</version>
<description>Verwaltung von Spielern und Vereinen in Mannschafts- und Individualwettbewerben</description> <description>Verwaltung von Spielern und Vereinen in Mannschafts- und Individualwettbewerben</description>
<namespace path="src">Dtfb\Component\com_sportsmanager</namespace>
<files folder="site"> <files folder="site">
<filename>index.html</filename> <filename>index.html</filename>
<filename>admin.php</filename> <filename>admin.php</filename>
<filename>api.php</filename> <filename>api.php</filename>
<filename>controller.php</filename>
<filename>database.php</filename>
<filename>sportsmanager.php</filename> <filename>sportsmanager.php</filename>
<filename>mathparser.php</filename> <filename>mathparser.php</filename>
<filename>tools.php</filename> <filename>tools.php</filename>
<filename>js/jquery.min.js</filename> <filename>js/jquery.min.js</filename>
<folder>images</folder> <folder>database</folder>
<folder>images</folder>
<folder>models</folder> <folder>models</folder>
<folder>src</folder>
<folder>util</folder> <folder>util</folder>
<folder>views</folder> <folder>views</folder>
</files> </files>
@@ -35,10 +36,10 @@
<administration> <administration>
<files folder="admin"> <files folder="admin">
<filename>access.xml</filename> <filename>access.xml</filename>
<filename>sportsmanager.php</filename>
<filename>controller.php</filename>
<filename>index.html</filename> <filename>index.html</filename>
<folder>views</folder> <folder>services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files> </files>
<languages folder="admin"> <languages folder="admin">
<language tag="en-GB">language/en-GB/en-GB.com_sportsmanager.ini <language tag="en-GB">language/en-GB/en-GB.com_sportsmanager.ini