45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Komponent\Component\Testquestions\Administrator\Controller;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\MVC\Controller\FormController;
|
|
|
|
class SetController extends FormController
|
|
{
|
|
protected $view_item = 'set';
|
|
protected $view_list = 'sets';
|
|
|
|
public function addvariant(): void
|
|
{
|
|
$parentId = $this->input->getInt('parent_id');
|
|
$this->setRedirect('index.php?option=com_testquestions&view=set&layout=edit&parent_id=' . $parentId);
|
|
}
|
|
|
|
public function cancel($key = null)
|
|
{
|
|
$parentId = $this->input->getInt('parent_id');
|
|
$formData = (array) $this->input->post->get('jform', [], 'array');
|
|
$parentId = (int) ($formData['parent_id'] ?? $parentId);
|
|
|
|
if ($parentId < 1) {
|
|
$itemId = $this->input->getInt('id');
|
|
if ($itemId > 0) {
|
|
$item = $this->getModel()->getItem($itemId);
|
|
$parentId = (int) ($item->parent_id ?? 0);
|
|
}
|
|
}
|
|
|
|
if ($parentId > 0) {
|
|
$this->setRedirect('index.php?option=com_testquestions&task=set.edit&id=' . $parentId);
|
|
|
|
return true;
|
|
}
|
|
|
|
$this->setRedirect('index.php?option=com_testquestions&view=sets');
|
|
|
|
return true;
|
|
}
|
|
}
|