Exemplo n.º 1
0
 protected function getInput()
 {
     JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php");
     JEVHelper::ConditionalFields($this->element, $this->form->getName());
     $input = parent::getInput();
     return $input;
 }
Exemplo n.º 2
0
 /**
  * Method to get the field input markup.
  * Adds the remaining fields for the database connection to the form
  *
  * @return  string  The field input markup
  * @since   3.1
  */
 protected function getInput()
 {
     $numberOfFields = 6;
     $this->form->loadFile('database');
     // Remove field 'prefix' is required
     $prefix = (string) $this->element['prefix'];
     if ($prefix == 'false' || $prefix == '0') {
         $this->form->removeField('prefix', 'db');
         $numberOfFields--;
     }
     // If second database connection is required remove
     // checkbox and change 'required' field attributes
     if ($this->required) {
         $this->form->removeField('database');
         $this->form->setFieldAttribute('db_type', 'required', 'true', 'db');
         $this->form->setFieldAttribute('db_host', 'required', 'true', 'db');
         $this->form->setFieldAttribute('db_user', 'required', 'true', 'db');
         $this->form->setFieldAttribute('db_name', 'required', 'true', 'db');
         $this->form->setFieldAttribute('prefix', 'required', 'true', 'db');
     }
     // Create individual IDs for each of the fields
     $id = str_replace('database_', '', $this->id);
     $this->form->setFieldAttribute('enabled', 'id', 'enabled_' . $id, 'db');
     $this->form->setFieldAttribute('db_type', 'id', 'db_type_' . $id, 'db');
     $this->form->setFieldAttribute('db_host', 'id', 'db_host_' . $id, 'db');
     $this->form->setFieldAttribute('db_user', 'id', 'db_user_' . $id, 'db');
     $this->form->setFieldAttribute('db_pass', 'id', 'db_pass_' . $id, 'db');
     $this->form->setFieldAttribute('db_name', 'id', 'db_name_' . $id, 'db');
     $this->form->setFieldAttribute('prefix', 'id', 'prefix_' . $id, 'db');
     $script = 'var group = jQuery(\'#' . $this->id . '\').parent().parent();';
     $script .= 'for(var i = 0; i < ' . $numberOfFields . '; i++){group = group.next();group.toggleClass(\'hide\');}';
     if (!$this->value && !isset($this->form->joomScriptLoaded)) {
         JFactory::getDocument()->addScriptDeclaration('jQuery(document).ready(function(){
   if(!jQuery(\'#' . $this->id . '\').prop(\'checked\')){jQuery(\'#db_enabled_' . $id . '\').val(\'0\');
   ' . $script . '}else{jQuery(\'#db_enabled_' . $id . '\').val(\'1\');}});');
         $this->form->joomScriptLoaded = true;
     }
     $this->element['onclick'] = $script . 'jQuery(\'#db_enabled_' . $id . '\').val(1 - jQuery(\'#db_enabled_' . $id . '\').val());';
     return parent::getInput();
 }