Example #1
0
 protected function getInput()
 {
     $end = $this->element['end'];
     $styles = $this->element['styles'];
     $background = $this->element['background'] ? 'background-image: url(' . $this->getPathToImages() . '/images/' . $this->element['background'] . ');' : '';
     $tag = $this->element['tag'];
     if ($end == '1') {
         // $html = '</li></'.$tag.'><li>';
         $html = '</' . $tag . '><div><div>';
     } else {
         // $html = '</li><'.$tag.' style="'.$background.$styles.'" ><li>';
         $html = '</div></div><' . $tag . ' style="' . $background . $styles . '" >';
     }
     // var_dump($html);
     $identifier = 'menustyles';
     $form = new JForm($identifier);
     JForm::addFormPath(JPATH_SITE . '/modules/mod_slideshowck/elements/test');
     if (!($formexists = $form->loadFile($identifier, false))) {
         echo '<p style="color:red">' . JText::_('Problem loading the file : ' . $identifier . '.xml') . '</p>';
         return '';
     }
     $fields = $form->getFieldset();
     foreach ($fields as $key => $field) {
         // echo '<div class="ckpopup_row">';
         $html .= $form->getLabel(str_replace($identifier . "_", "", $key), $identifier);
         $html .= $form->getInput(str_replace($identifier . "_", "", $key), $identifier);
         // echo '</div>';
     }
     return $html;
 }
 /**
  * Event method that runs on content preparation
  *
  * @param   JForm    $form  The form object
  * @param   integer  $data  The form data
  *
  * @return bool
  */
 public function onContentPrepareForm($form, $data)
 {
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     $name = $form->getName();
     if (!in_array($name, array('com_content.article'))) {
         return true;
     }
     $include_categories = $this->params->get('include_categories');
     if (empty($include_categories)) {
         return true;
     }
     if (empty($data)) {
         $input = JFactory::getApplication()->input;
         $data = (object) $input->post->get('jform', array(), 'array');
     }
     if (is_array($data)) {
         jimport('joomla.utilities.arrayhelper');
         $data = JArrayHelper::toObject($data);
     }
     if (empty($data->catid)) {
         return true;
     }
     if (!in_array($data->catid, $include_categories)) {
         return true;
     }
     JForm::addFormPath(__DIR__ . '/form');
     $form->loadFile('form');
     if (!empty($data->id)) {
         $data = $this->loadTest($data);
     }
     return true;
 }
Example #3
0
 /**
  * Injects several fields into specific forms.
  *
  * @param   JForm  $form  The form to be altered.
  * @param   array  $data  The associated data for the form.
  *
  * @return  boolean
  *
  * @since   2.0
  */
 public function onContentPrepareForm($form, $data)
 {
     // Check we are manipulating a valid form
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     // Check if the password field needs injecting
     if ($this->params->get('use_ldap_password', false) && in_array($form->getName(), $this->passwordForms)) {
         // Check if this user should have a profile
         if (SHLdapHelper::isUserLdap(isset($data->id) ? $data->id : 0)) {
             if ($this->params->get('ldap_password_layout_edit', true)) {
                 // Check if this is in the 'edit' layout or in the save state
                 if (strtolower(JFactory::getApplication()->input->get('layout')) === 'edit' || strtolower(JFactory::getApplication()->input->get('task')) === 'save') {
                     $form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false);
                 }
             } else {
                 $form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false);
             }
         }
     }
     // Check if the domain field needs injecting
     if ($this->params->get('use_ldap_domain', false) && in_array($form->getName(), $this->domainForms)) {
         $form->loadFile(realpath(__DIR__) . '/forms/ldap_domain.xml', false, false);
     }
     return true;
 }
Example #4
0
 /**
  * Method to test if the Captcha is correct.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  * @param   Registry          $input    An optional Registry object with the entire data set to validate against the entire form.
  * @param   JForm             $form     The form object for which the field is being tested.
  *
  * @return  boolean  True if the value is valid, false otherwise.
  *
  * @since   2.5
  */
 public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null)
 {
     $app = JFactory::getApplication();
     $plugin = $app->get('captcha');
     if ($app->isSite()) {
         $plugin = $app->getParams()->get('captcha', $plugin);
     }
     $namespace = $element['namespace'] ?: $form->getName();
     // Use 0 for none
     if ($plugin === 0 || $plugin === '0') {
         return true;
     } else {
         $captcha = JCaptcha::getInstance((string) $plugin, array('namespace' => (string) $namespace));
     }
     // Test the value.
     if (!$captcha->checkAnswer($value)) {
         $error = $captcha->getError();
         if ($error instanceof Exception) {
             return $error;
         } else {
             return new JException($error);
         }
     }
     return true;
 }
Example #5
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since    3.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'jevents')
 {
     // Association content items
     $app = JFactory::getApplication();
     $assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_article');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
Example #6
0
 /**
  * Method to preprocess the form
  *
  * @param   JForm   $form   A form object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @since   3.2
  * @throws  Exception if there is an error loading the form.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.path');
     $lang = JFactory::getLanguage();
     $module = $this->getState()->get('module.name');
     $basePath = JPATH_BASE;
     $formFile = JPath::clean($basePath . '/modules/' . $module . '/' . $module . '.xml');
     // Load the core and/or local language file(s).
     $lang->load($module, $basePath, null, false, true) || $lang->load($module, $basePath . '/modules/' . $module, null, false, true);
     if (file_exists($formFile)) {
         // Get the module form.
         if (!$form->loadFile($formFile, false, '//config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         // Attempt to load the xml file.
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the default advanced params
     JForm::addFormPath(JPATH_BASE . '/components/com_config/model/form');
     $form->loadFile('modules_advanced', false);
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="combo" type="combo" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldCombo($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
 }
Example #8
0
 /**
  * 
  * Enter description here ...
  * @param JForm $form
  * @param unknown $data
  */
 function onContentPrepareForm($form, $data)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $this->template = $this->getTemplateName();
     if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) {
         jimport('joomla.filesystem.path');
         //JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params');
         $plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml');
         $tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml');
         if (!$plg_file) {
             return false;
         }
         if ($tpl_file) {
             $form->loadFile($plg_file, false, '//form');
             $form->loadFile($tpl_file, false, '//config');
         } else {
             $form->loadFile($plg_file, false, '//form');
         }
         if ($app->isSite()) {
             $jmstorage_fields = $form->getFieldset('jmstorage');
             foreach ($jmstorage_fields as $name => $field) {
                 $form->removeField($name, 'params');
             }
             $form->removeField('config', 'params');
         }
         if ($app->isAdmin()) {
             $doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}');
         }
     }
 }
 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="moduletag" type="moduletag" label="Module Tag" description="Module Tag listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldModuletag($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertContains('<option value="nav">nav</option>', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with various opening tags, verify nav tag is in list.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  * @todo    Should check all the attributes have come in properly.
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="componentlayout" type="componentlayout" extension="com_content" client_id="0" view="blog" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldComponentlayout($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="accesslevel" type="accesslevel" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldAccessLevel($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="color" type="color" disabled="true" onchange="window.reload()" class="inputbox" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldColor($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
 }
Example #13
0
 /**
  * Tests the JForm::__construct method
  */
 public function testConstruct()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInspector($form);
     $this->assertThat($field instanceof JFormField, $this->isTrue(), 'Line:' . __LINE__ . ' The JFormField constuctor should return a JFormField object.');
     $this->assertThat($field->getForm(), $this->identicalTo($form), 'Line:' . __LINE__ . ' The internal form should be identical to the variable passed in the contructor.');
 }
 /**
  * Test the getOptions method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetOptions()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="radio" type="radio"><option value="0">No</option><item value="1">Yes</item></field></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldRadio($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->logicalNot($this->StringContains('Yes')), 'Line:' . __LINE__ . ' The field should not contain a Yes option.');
 }
 public static function getInstance(JForm $form)
 {
     if (!array_key_exists($form->getName(), self::$instances)) {
         self::$instances[$form->getName()] = new RokSubfieldForm($form);
     }
     self::$instances[$form->getName()]->updateDataParams();
     return self::$instances[$form->getName()];
 }
 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="helpsite" type="helpsite" label="Help Site" description="Help Site listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldHelpsite($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertContains('<option value="http://help.joomla.org/proxy/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with a link to the help site.');
 }
Example #17
0
 protected function preprocessForm(JForm $form, $data, $groups = '')
 {
     $obj = is_array($data) ? JArrayHelper::toObject($data, 'JObject') : $data;
     if (isset($obj->alias) && $obj->id > 0) {
         $form->setFieldAttribute('type', 'readonly', 'true');
     }
     parent::preprocessForm($form, $data);
 }
Example #18
0
 /**
  * Override preprocessForm to load the user plugin group instead of content.
  *
  * @param   JForm   $form   A JForm object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @since   1.6
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'user')
 {
     $userParams = JComponentHelper::getParams('com_users');
     //Add the choice for site language at registration time
     if ($userParams->get('site_language') == 1 && $userParams->get('frontend_userparams') == 1) {
         $form->loadFile('sitelang', false);
     }
 }
Example #19
0
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="rules" type="rules" section="component" component="com_content" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldRules($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
     // TODO: Should check all the attributes have come in properly.
 }
Example #20
0
 /**
  * adds additional fields to the user editing form
  *
  * @param   JForm  $form  The form to be altered.
  * @param   mixed  $data  The associated data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareForm($form, $data)
 {
     $version = new JVersion();
     if (!$version->isCompatible('3.4')) {
         return true;
     }
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     $params = JComponentHelper::getParams('com_jce');
     if ((bool) $params->get('replace_media_manager', 1) === false) {
         return;
     }
     // get form name.
     $name = $form->getName();
     $valid = array('com_akrecipes.recipe', 'com_categories.categorycom_akrecipes', 'com_akrecipes.ingredient', 'com_akrecipes.brand', 'com_akrecipes.cuisine', 'com_akrecipes.brand', 'com_akrecipes.product');
     // only allow some forms, see - https://github.com/joomla/joomla-cms/pull/8657
     if (!in_array($name, $valid)) {
         return true;
     }
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     if ($user->getParam('editor', $config->get('editor')) !== "jce") {
         return true;
     }
     if (!JPluginHelper::getPlugin('editors', 'jce')) {
         return true;
     }
     $hasMedia = false;
     $fields = $form->getFieldset();
     foreach ($fields as $field) {
         $type = $field->getAttribute('type');
         if (strtolower($type) === "media") {
             // get filter value for field, eg: images, media, files
             $filter = $field->getAttribute('filter', 'images');
             // get file browser link
             $link = $this->getLink($filter);
             // link not available for environment
             if (empty($link)) {
                 continue;
             }
             $name = $field->getAttribute('name');
             $group = (string) $field->group;
             $form->setFieldAttribute($name, 'link', $link, $group);
             $form->setFieldAttribute($name, 'class', 'input-large wf-media-input', $group);
             $hasMedia = true;
         }
     }
     if ($hasMedia) {
         // Include jQuery
         JHtml::_('jquery.framework');
         $document = JFactory::getDocument();
         $document->addScriptDeclaration('jQuery(document).ready(function($){$(".wf-media-input").removeAttr("readonly");});');
     }
     return true;
 }
Example #21
0
 public static function getForm()
 {
     $myForm = new JForm('callback');
     // Добавили путь где лежит форма здесь form.xml лежит в корне модуля
     $myForm->addFormPath(__DIR__);
     // Прочитали и вернули
     $myForm->loadFile('form', false);
     return $myForm;
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="filelist" type="filelist" directory="modules/mod_finder/tmpl" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldFileList($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
     // TODO: Should check all the attributes have come in properly.
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $expected = '<form><field name="usergroup" type="usergroup" class="inputbox" disabled="true" onclick="window.reload()">' . '<option value="*">None</option><item value="fake">Fake</item></field></form>';
     $this->assertThat($form->load($expected), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldUsergroup($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
     // TODO: Should check all the attributes have come in properly.
 }
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="file" type="file" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldFile($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     // $this->markTestIncomplete('Problems encountered in next assertion');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
     // TODO: Should check all the attributes have come in properly.
 }
Example #25
0
 protected function preprocessForm(\JForm $form, $data, $group = 'content')
 {
     // if no data, grab the posted form data.
     if (!$data instanceof JObject) {
         $data = JFactory::getApplication()->input->get('jform', $data, 'array');
         $data = JArrayHelper::toObject($data);
     }
     $params = new JRegistry();
     $params->loadArray($data->params);
     if ($params->get('discovery.url')) {
         $plugin = $params->get('discovery.type');
         $language = JFactory::getLanguage();
         $language->load('plg_harvest_' . $plugin);
         $path = JPATH_ROOT . '/plugins/harvest/' . $plugin . '/forms/harvest.xml';
         $form->loadFile($path, false);
         foreach (JPluginHelper::getPlugin('ingest') as $plugin) {
             $language->load('plg_ingest_' . $plugin->name);
             $path = JPATH_ROOT . '/plugins/ingest/' . $plugin->name . '/forms/ingest.xml';
             $form->loadFile($path, false);
         }
         $form->removeField('originating_url');
         $form->removeField('harvester');
         // hide the run_once value (users cannot set it after discovery)
         $form->setFieldAttribute("run_once", 'type', 'hidden');
         $form->setFieldAttribute("run_once", 'class', '');
     } else {
         $form->removeField('state');
         $form->removeField('harvested');
         $form->removeField('url', 'params.discovery');
         $form->removeField('type', 'params.discovery');
     }
     parent::preprocessForm($form, $data, $group);
 }
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   3.2
  */
 protected function getInput()
 {
     // Initialize variables.
     $subForm = new JForm($this->name, array('control' => 'jform'));
     $xml = $this->element->children()->asXML();
     $subForm->load($xml);
     // Needed for repeating modals in gmaps
     $subForm->repeatCounter = (int) @$this->form->repeatCounter;
     $children = $this->element->children();
     $subForm->setFields($children);
     $modalid = $this->id . '_modal';
     $str = array();
     $str[] = '<div id="' . $modalid . '" style="display:none">';
     $str[] = '<table id="' . $modalid . '_table" class="adminlist ' . $this->element['class'] . ' table table-striped">';
     $str[] = '<thead><tr>';
     $names = array();
     $attributes = $this->element->attributes();
     foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
         $names[] = (string) $field->element->attributes()->name;
         $str[] = '<th>' . strip_tags($field->getLabel($field->name));
         $str[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>';
         $str[] = '</th>';
     }
     $str[] = '<th><a href="#" class="add btn button btn-success"><span class="fa fa-plus"></span> </a></th>';
     $str[] = '</tr></thead>';
     $str[] = '<tbody><tr>';
     foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
         $str[] = '<td>' . $field->getInput() . '</td>';
     }
     $str[] = '<td>';
     $str[] = '<div class="btn-group"><a class="add btn button btn-success"><span class="fa fa-plus"></span> </a>';
     $str[] = '<a class="remove btn button btn-danger"><span class="fa fa-minus"></span> </a></div>';
     $str[] = '</td>';
     $str[] = '</tr></tbody>';
     $str[] = '</table>';
     $str[] = '</div>';
     $names = json_encode($names);
     JHtml::_('script', 'system/repeatable.js', true, true);
     // If a maximum value isn't set then we'll make the maximum amount of cells a large number
     $maximum = $this->element['maximum'] ? (int) $this->element['maximum'] : '999';
     $script = "(function (\$){\r\n\t\t\t\$(document).ready(function (){\r\n\t\t\t\tvar repeatable = new \$.JRepeatable('{$modalid}', {$names}, '{$this->id}', '{$maximum}');\r\n\t\t\t});\r\n\t\t})(jQuery);";
     $document = JFactory::getDocument();
     $document->addScriptDeclaration($script);
     $select = (string) $this->element['select'] ? JText::_((string) $this->element['select']) : JText::_('JLIB_FORM_BUTTON_SELECT');
     $icon = $this->element['icon'] ? '<i class="icon-' . $this->element['icon'] . '"></i> ' : '';
     $str[] = '<button class="btn" id="' . $modalid . '_button" data-modal="' . $modalid . '">' . $icon . $select . '</button>';
     if (is_array($this->value)) {
         $this->value = array_shift($this->value);
     }
     $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
     $str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />';
     JText::script('JAPPLY');
     JText::script('JCANCEL');
     return implode("\n", $str);
 }
Example #27
0
 /**
  * Method to test whether a record can be deleted.
  *
  * @param JForm $record a record object.
  * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
  */
 protected function canEditState($record)
 {
     if (!empty($record)) {
         if ($record instanceof JForm) {
             return JoomDOCAccessDocument::editState($record->getValue('id'), $record->getValue('checked_out'), $record->getValue('path'));
         } else {
             return JoomDOCAccessDocument::editState($record->id, $record->checked_out, $record->path);
         }
     }
     return parent::canEditState($record);
 }
Example #28
0
 /**
  * Function that gets the config settings
  *
  * @return    Object
  */
 protected function getAssignments()
 {
     if (!isset($this->assignments)) {
         $xmlfile = JPATH_ADMINISTRATOR . '/components/com_advancedmodules/assignments.xml';
         $assignments = new JForm('assignments', array('control' => 'advancedparams'));
         $assignments->loadFile($xmlfile, 1, '//config');
         $assignments->bind($this->item->advancedparams);
         $this->assignments = $assignments;
     }
     return $this->assignments;
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="mysqli" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldDatabaseConnection($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "Mysqli" option.');
     $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="non-existing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldDatabaseConnection($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "None" option.');
     // TODO: Should check all the attributes have come in properly.
 }
Example #30
0
 /**
  * Display configurations for registration
  *
  * @return  void
  */
 public function displayTask()
 {
     $config = new \JForm('com_members.registration');
     $config->loadFile(dirname(dirname(__DIR__)) . DS . 'config' . DS . 'config.xml', true, '/config');
     $config->bind($this->config->toArray());
     $this->config = $config;
     $this->view->params = $config->getFieldset('registration');
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Output the HTML
     $this->view->display();
 }