I have created a Basic Joomla Component with Component Creator in order to prepare every single files in less the 1 minute :D (I'm lazy, i know.)
I have one view default and one for form edit.
I need to extend the class created by the Component Creator.
I have this controller.php
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
use \Joomla\CMS\Factory;
/**
* Class Doclf_usersController
*
* @since 1.6
*/
class Doclf_usersController extends \Joomla\CMS\MVC\Controller\BaseController
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param mixed $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.5
* @throws Exception
*/
public function display($cachable = false, $urlparams = false)
{
$app = Factory::getApplication();
$view = $app->input->getCmd('view', 'iscrizionelavoratoris');
$app->input->set('view', $view);
parent::display($cachable, $urlparams);
return $this;
}
Now i need to extend this class with my custom class, something like this
class DivStyle extends Doclf_usersController {
private $GetElementRisultato = "document.getElementById('risultato')";
private $StyleColor = '.style.color =';
private $Color = '"red"'
}
Unfortunately, it doesn't work...
I tried also extends \Joomla\CMS\MVC\Controller\BaseController
but no win....
Error is
0 syntax error, unexpected 'class' (T_CLASS), expecting function (T_FUNCTION) or const (T_CONST)
How can i add my new class extend?
Thanks in advance for your help :)
UPDATED CODE BUT STILL DOESN'T WORK :(
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
use \Joomla\CMS\Factory;
/**
* Class Doclf_usersController
*
* @since 1.6
*/class Doclf_usersController extends \Joomla\CMS\MVC\Controller\BaseController
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param mixed $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.5
* @throws Exception
*/
public function display($cachable = false, $urlparams = false)
{
$app = Factory::getApplication();
$view = $app->input->getCmd('view', 'iscrizionelavoratoris');
$app->input->set('view', $view);
parent::display($cachable, $urlparams);
return $this;
}
class DivStyle extends Doclf_usersController {
private $GetElementRisultato = "document.getElementById('risultato')";
private $StyleColor = '.style.color =';
private $Color = '"red"';
}
public function checkcodicefiscale() {
$cf = new CodiceFiscale();
$app = Factory::getApplication();
$input = $app->input;
$cf ->SetCF($input->get('codice_fiscale', ''));
if ($input->exists('codice_fiscale')) {
if ($cf->GetCodiceValido()) {
//Il codice fiscale è valido, procedo a verificare se esiste nel database
$db = JFactory::getDbo();
$query = "SELECT * FROM #__users_dati_anagrafici WHERE cf = '".$input->get('codice_fiscale')."'";
$result = $db->setQuery($query)->loadObject();
if ($result >0) {
//il codice fiscale esiste, pertanto procedo a bloccare il form
echo 'esiste';
} else {
}
// if($result != null)
// {$urlfile = $result->file;}
// else
// {}
echo '<script>
document.getElementById("risultato").style.color = "green";
document.getElementById("bar_inizio").classList.remove(\'active\');
document.getElementById("bar_inizio").classList.add(\'done\');
</script>';
echo 'Il Codice Fiscale è valido';
//return valido
jexit();
} else {
echo '<script>
document.getElementById("risultato").style.color = "red";
</script>';
print $cf->GetErrore();
jexit();
}
jexit();
} else {
jexit();
}
}
}