Initial Joomla test questions component

This commit is contained in:
Wojtek
2026-10-14 22:29:10 +02:00
commit 9b093b278d
44 changed files with 964 additions and 0 deletions
@@ -0,0 +1,25 @@
<?php
namespace Komponent\Component\Testquestions\Administrator\View\Categories;
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
class HtmlView extends BaseHtmlView
{
protected $items;
public function display($tpl = null)
{
$this->items = $this->get('Items');
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_CATEGORIES'));
ToolbarHelper::addNew('category.add', 'JTOOLBAR_NEW');
ToolbarHelper::editList('category.edit', 'JTOOLBAR_EDIT');
ToolbarHelper::deleteList('', 'categories.delete', 'JTOOLBAR_DELETE');
ToolbarHelper::link('index.php?option=com_testquestions&view=questions', 'COM_TESTQUESTIONS', 'back');
return parent::display($tpl);
}
}
@@ -0,0 +1,27 @@
<?php
namespace Komponent\Component\Testquestions\Administrator\View\Category;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
class HtmlView extends BaseHtmlView
{
protected $form;
protected $item;
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
ToolbarHelper::save('category.save', 'JTOOLBAR_SAVE');
ToolbarHelper::link(
'index.php?option=com_testquestions&view=questions',
'JTOOLBAR_CANCEL',
'cancel'
);
return parent::display($tpl);
}
}
@@ -0,0 +1,37 @@
<?php
namespace Komponent\Component\Testquestions\Administrator\View\Question;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Toolbar\ToolbarHelper;
class HtmlView extends BaseHtmlView
{
protected $form;
protected $item;
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->addToolbar();
return parent::display($tpl);
}
protected function addToolbar()
{
$this->getDocument()->setTitle($this->item->id
? \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_EDIT_QUESTION')
: \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_NEW_QUESTION'));
ToolbarHelper::apply('question.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('question.save', 'JTOOLBAR_SAVE');
ToolbarHelper::link(
'index.php?option=com_testquestions&view=questions',
'JTOOLBAR_CANCEL',
'cancel'
);
}
}
@@ -0,0 +1,55 @@
<?php
namespace Komponent\Component\Testquestions\Administrator\View\Questions;
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView
{
protected $items;
protected $pagination;
protected $state;
protected $categories;
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->categories = $this->get('Categories');
if (count($errors = $this->get('Errors'))) {
throw new \RuntimeException(implode("\n", $errors));
}
$this->addToolbar();
return parent::display($tpl);
}
protected function addToolbar()
{
$user = $this->getCurrentUser();
$this->getDocument()->setTitle(Text::_('COM_TESTQUESTIONS'));
if ($user->authorise('core.create', 'com_testquestions')) {
ToolbarHelper::addNew('question.add', 'JTOOLBAR_NEW');
}
if ($user->authorise('core.edit', 'com_testquestions')) {
ToolbarHelper::editList('question.edit', 'JTOOLBAR_EDIT');
}
if ($user->authorise('core.delete', 'com_testquestions')) {
ToolbarHelper::deleteList('', 'questions.delete', 'JTOOLBAR_DELETE');
}
ToolbarHelper::link(
'index.php?option=com_testquestions&view=categories',
'COM_TESTQUESTIONS_MANAGE_CATEGORIES',
'list'
);
}
}