/** * 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); }
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; }
/** * * 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;}'); } } }
/** * 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; }
/** * 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(); }
/** * 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; } // get form name. $name = $form->getName(); $valid = array('com_content.article', 'com_categories.categorycom_content', 'com_templates.style', 'com_tags.tag', 'com_banners.banner', 'com_contact.contact', 'com_newsfeeds.newsfeed'); // only allow some forms :( 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; } $link = $this->getLink(); $hasMedia = false; if ($link) { $fields = $form->getFieldset(); foreach ($fields as $field) { $type = $field->getAttribute('type'); if (strtolower($type) === "media") { $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; }
/** * * get controls array from form * get all groups on the way * @param JForm $form */ private static function getControlsFromForm(JForm $form) { $fieldsets = $form->getFieldsets(); self::$arrGroupsAssoc = array(); $arrControls = array(); foreach ($fieldsets as $key => $fieldsetObj) { $fieldset = $form->getFieldset($key); foreach ($fieldset as $fieldName => $field) { $group = (string) $field->group; if (!empty($group)) { self::$arrGroupsAssoc[$field->group] = ""; } if ($field->type == "control") { //get controls array from the control (can be multiple children) $controls = $field->getControlFields(); foreach ($controls as $control) { $arrControls[] = $control; } //end control foreach } } } return $arrControls; }
protected function getInput() { if (!function_exists('xtcsortfn')) { function xtcsortfn($a, $b) { return strnatcmp($a[0], $b[0]); } } jimport('joomla.filesystem.folder'); JHTML::_('behavior.modal', 'a.modal'); $live_site = JURI::root(); $template = basename(dirname(dirname(dirname(__FILE__)))); $document = JFactory::getDocument(); $id = JRequest::getInt('id'); $document->addStyleSheet($live_site . "templates/{$template}/XTC/XTC.css", 'text/css'); $path = JPATH_ROOT . '/templates/' . $template; $files = JFolder::files($path . '/parameters', 'xml'); $onopen = "var iSize;\n var iFrame = this.asset;\n iFrame.addEvent('load', function(){\n var iBody = (iFrame.contentDocument) ? iFrame.contentDocument.getElementsByTagName('body')[0] : iFrame.contentWindow.document.getElementsByTagName('body')[0];\n\n\t iSize = {x:this.size.x, y:iBody.offsetHeight};\n var per = (window.innerHeight * 0.9).toInt();\n iSize.y = (iSize.y > per) ? per : iSize.y ;\n iFrame.setStyles({'height':'100%'});\n\n this.resize(iSize, false);\n }.bind(this));"; $parmsfound = false; $prefix = trim($this->element['group']); $label = trim($this->element['label']); $parameters = array(); foreach ($files as $file) { @(list($filename, $extension) = explode('.', $file, 2)); if ($extension != 'xml') { continue; } // Not an XML if (strpos($filename, $prefix) !== 0) { continue; } // Not the right prefix $xmlFile = $path . '/parameters/' . $file; if (is_readable($xmlFile)) { $xml = simplexml_load_file($xmlFile); $name = isset($xml->name) ? $xml->name : $filename; $description = isset($xml->description) ? trim($xml->description) : ''; } else { $name = $filename; $description = ''; } $thumbnail = ''; if (file_exists($path . '/parameters/' . $filename . '.gif')) { $thumbnail = $filename . '.gif'; } elseif (file_exists($path . '/parameters/' . $filename . '.jpg')) { $thumbnail = $filename . '.jpg'; } elseif (file_exists($path . '/parameters/' . $filename . '.png')) { $thumbnail = $filename . '.png'; } $fullimage = ''; if (file_exists($path . '/parameters/' . $filename . '_full.gif')) { $fullimage = $filename . '_full.gif'; } elseif (file_exists($path . '/parameters/' . $filename . '_full.jpg')) { $fullimage = $filename . '_full.jpg'; } elseif (file_exists($path . '/parameters/' . $filename . '_full.png')) { $fullimage = $filename . '_full.png'; } $parameters[] = array($name, $filename, $description, $thumbnail, $fullimage); } usort($parameters, "xtcsortfn"); $stringFilter = JFilterInput::getInstance(); require_once $path . '/XTC/XTC_library.php'; $templateParameters = xtcLoadParams($id); $html = ''; $navHtml = ''; $tabHtml = ''; $count = count($parameters); $openClass = $count == 1 ? ' open' : ''; foreach ($parameters as $i => $parameter) { // Draw parameters list($name, $filename, $description, $thumbnail, $fullimage) = $parameter; $params = isset($templateParameters->group->{$filename}) ? $templateParameters->group->{$filename} : new stdClass(); $tabid = $filename . $i; // Parameter Tab $active = $i == 0 ? ' class="active"' : ''; $navHtml .= '<li' . $active . '>'; $navHtml .= '<a href="#' . $tabid . '" data-toggle="tab">'; if ($thumbnail) { $thumbnailURL = $live_site . 'templates/' . $template . '/parameters/' . $thumbnail; $navHtml .= '<img class="img-rounded" src="' . $thumbnailURL . '" alt="" /><br/>'; } $navHtml .= '<center>' . $name . '</center>'; $navHtml .= '</a>'; $navHtml .= '</li>'; // Parameter Tab contents $form = new JForm('jxtc'); $form->addFieldPath(JPATH_ROOT . '/templates/' . $template . '/XTC/elements'); $xmlFile = $path . '/parameters/' . $filename . '.xml'; $form->loadFile($xmlFile); $getFieldsets = $form->getFieldsets(); $active = $i == 0 ? ' active' : ''; $tabHtml .= '<div class="tab-pane' . $active . '" id="' . $tabid . '">'; $tabHtml .= '<div class="xtc row-fluid">'; $tabHtml .= '<div class="span5">'; foreach ($getFieldsets as $fieldsets => $fieldset) { $label = trim($fieldset->label); if (empty($label)) { $label = trim($fieldset->name); } $fieldsetDescription = isset($fieldset->description) ? trim($fieldset->description) : ''; if (count($getFieldsets) > 1) { $tabHtml .= '<fieldset>'; if ($label) { $tabHtml .= '<legend>' . $label . '</legend>'; } if ($fieldsetDescription) { $tabHtml .= '<div class="well">' . $fieldsetDescription . '</div>'; } } foreach ($form->getFieldset($fieldset->name) as $field) { $xtcName = substr($field->name, 7, -1); if (isset($params->{$xtcName})) { $field->value = $params->{$xtcName}; } $field->name = str_replace('params[', 'xtcparam[' . $prefix . '][' . $filename . '][', $field->name); $field->id = $stringFilter->clean($field->name, 'cmd'); $tabHtml .= '<div class="control-group">'; $tabHtml .= '<div class="control-label">' . $field->getLabel() . '</div>'; $tabHtml .= '<div class="controls">' . $field->getInput() . '</div>'; $tabHtml .= '</div>'; } if (count($getFieldsets) > 1) { $tabHtml .= '</fieldset>'; } } $tabHtml .= '</div>'; // span5 if ($description || $fullimage) { $tabHtml .= '<div class="span1"></div>'; $tabHtml .= '<div class="span4"><div class="well">'; $tabHtml .= '<h3>' . $name . '</h3>'; if ($description) { $tabHtml .= $description . '<br/><br/>'; } if ($fullimage) { $fullimageURL = $live_site . 'templates/' . $template . '/parameters/' . $fullimage; $headerimg_size = getimagesize($path . '/layouts/' . $folder . '/' . $fullimage); $width = $headerimg_size[0]; $height = $headerimg_size[1]; $onclick = "onclick=\"MyWindow=window.open('{$fullimageURL}','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width={$width},height={$height}'); return false;\""; $tabHtml .= '<a class="btn btn-primary" href="#" ' . $onclick . '>' . JText::_('TPL_JXTC_VIEWLAYOUT') . '</a>'; } $tabHtml .= '</div></div>'; } $tabHtml .= '</div>'; // row-fluid $tabHtml .= '</div>'; // tab-pane } $html .= '<div class="tabbable">'; $html .= '<ul class="nav nav-tabs">' . $navHtml . '</ul>'; $html .= '<div class="tab-content">' . $tabHtml . '</div>'; $html .= '</div>'; return $html; }
/** * Runs on content preparation. * Called after the data for a JForm has been retrieved. * * @param string $context The context for the data * @param object $data An object containing the data for the form. * * @return boolean */ public function onContentPrepareData($context, $data) { if (is_object($data)) { $articleId = isset($data->id) ? $data->id : 0; if ($articleId > 0) { // Load the data from the database $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('data'); $query->from('#__content_ksextras'); $query->where('article_id = ' . $db->Quote($articleId)); $db->setQuery($query); $results = $db->loadObject(); // Check for a database error if ($db->getErrorNum()) { $this->_subject->setError($db->getErrorMsg()); return false; } $ksdata = count($results) ? json_decode(json_decode($results->data)) : new stdClass(); // Merge the data $data->attribs = array(); foreach ($this->ksfields as $ksfield) { $data->attribs[$ksfield] = isset($ksdata->{$ksfield}) ? $ksdata->{$ksfield} : ''; } } else { // Load the form JForm::addFormPath(dirname(__FILE__) . '/extras'); $form = new JForm('com_content.article'); $form->loadFile('testimonial', false); // Merge the default values $data->attribs = array(); foreach ($form->getFieldset('attribs') as $field) { $data->attribs[] = array($field->fieldname, $field->value); } } } return true; }
function getInput() { $formRegistration = new JForm('com_users.registration'); $formProfile = new JForm('com_users.registration'); $plugin = JPluginHelper::getPlugin('user', 'profile'); //load language com_user and plugin profile $language = JFactory::getLanguage(); $language_tag = $language->getTag(); JFactory::getLanguage()->load('lib_joomla', JPATH_SITE, $language_tag, true); JFactory::getLanguage()->load('com_users', JPATH_SITE, $language_tag, true); JFactory::getLanguage()->load('plg_user_profile', JPATH_ADMINISTRATOR, $language_tag, true); // Add the registration fields to the form. $formRegistration->loadFile(JPATH_ROOT . '/components/com_users/models/forms/registration.xml', false); // remove unused fiels of registrer form $formRegistration->removeField('captcha'); $formRegistration->removeField('spacer'); $formRegistration->removeField('password1'); $formRegistration->removeField('password2'); $formRegistration->removeField('email2'); //setting list box $class = $this->element['class'] ? (string) $this->element['class'] : ''; $social = $this->element['social'] ? (string) $this->element['social'] : ''; $html = '<ul class="profile-fields ' . $class . '" id="' . $this->id . '" version="' . JVERSION . '">'; $options = array(); switch ($social) { case 'facebook': $options[] = JHtml::_('select.option', '', JText::_('JNONE')); $options[] = JHtml::_('select.option', 'id', JText::_('ID')); $options[] = JHtml::_('select.option', 'name', 'Name'); $options[] = JHtml::_('select.option', 'username', 'Username'); $options[] = JHtml::_('select.option', 'email', 'Email'); $options[] = JHtml::_('select.option', 'link', 'Profile link'); //$options[] = JHtml::_('select.option', 'picture', 'Profile Picture'); $options[] = JHtml::_('select.option', 'birthday', 'Date of birth'); $options[] = JHtml::_('select.option', 'location', 'Location'); $options[] = JHtml::_('select.option', 'hometown', 'Hometown'); $options[] = JHtml::_('select.option', 'website', 'Website'); $options[] = JHtml::_('select.option', 'bio', 'About me'); $options[] = JHtml::_('select.option', 'quotes', 'Favorite Quotes'); break; case 'google': $options[] = JHtml::_('select.option', '', JText::_('JNONE')); $options[] = JHtml::_('select.option', 'id', JText::_('ID')); $options[] = JHtml::_('select.option', 'name', 'Name'); $options[] = JHtml::_('select.option', 'username', 'Username'); $options[] = JHtml::_('select.option', 'email', 'Email'); $options[] = JHtml::_('select.option', 'link', 'Profile link'); //$options[] = JHtml::_('select.option', 'picture', 'Profile Picture'); $options[] = JHtml::_('select.option', 'birthday', 'Date of birth'); break; case 'twitter': $options[] = JHtml::_('select.option', '', JText::_('JNONE')); $options[] = JHtml::_('select.option', 'id', JText::_('ID')); $options[] = JHtml::_('select.option', 'name', 'Name'); $options[] = JHtml::_('select.option', 'username', 'Screen Name'); $options[] = JHtml::_('select.option', 'link', 'Profile link'); //$options[] = JHtml::_('select.option', 'picture', 'Profile Picture'); $options[] = JHtml::_('select.option', 'birthday', 'Date of birth'); $options[] = JHtml::_('select.option', 'location', 'Location'); $options[] = JHtml::_('select.option', 'website', 'Website'); $options[] = JHtml::_('select.option', 'bio', 'Description'); $options[] = JHtml::_('select.option', 'status', 'Status'); break; } //add field from register form foreach ($formRegistration->getFieldsets() as $fieldset) { $fields = $formRegistration->getFieldset($fieldset->name); if (count($fields)) { foreach ($fields as $field) { $html .= '<li class="control-group">' . $field->getLabel(); if ($field->fieldname == 'name') { $html .= JHtml::_('select.genericlist', $options, '', 'class="name control-group"', 'value', 'text', 'name'); } elseif ($field->fieldname == 'username') { $html .= JHtml::_('select.genericlist', $options, '', 'class="username control-group"', 'value', 'text', $social == 'google' ? 'email' : 'username'); } elseif ($field->fieldname == 'email1') { $html .= JHtml::_('select.genericlist', $options, '', 'class="email1 control-group" disabled="disabled"', 'value', 'text', 'email'); if ($social == 'twitter') { $html .= '<br /><span style="color:red;line-height:200%">The Twitter API does not provide the user\'s email address. So if you turn off "editing email" the twitter users will have email type: screen_name@twitter.com</span>'; } } } } } //load fields of plugin profile if ($plugin != null) { $params = new JRegistry(); $params->loadString($plugin->params); $formProfile->loadFile(JPATH_ROOT . '/plugins/user/profile/profiles/profile.xml', false); $fields = array('address1', 'address2', 'city', 'region', 'country', 'postal_code', 'website', 'favoritebook', 'aboutme', 'dob'); //remove field unused $formProfile->removeField('tos', 'profile'); //$formProfile->removeField('city','profile'); //$formProfile->removeField('region','profile'); //$formProfile->removeField('country','profile'); $formProfile->removeField('postal_code', 'profile'); $formProfile->removeField('favoritebook', 'profile'); $formProfile->removeField('phone', 'profile'); //remove field disable in profile form foreach ($fields as $field) { if ($params->get('register-require_' . $field, 1) > 0) { $formProfile->setFieldAttribute($field, 'required', $params->get('register-require_' . $field) == 2 ? 'required' : '', 'profile'); } else { $formProfile->removeField($field, 'profile'); } } foreach ($formProfile->getFieldsets() as $fieldset) { $fields = $formProfile->getFieldset($fieldset->name); if (count($fields)) { $html .= '<li class="control-group"><h3 class="enable_profile_1">Profile plugin:</h3></li>'; foreach ($fields as $field) { $html .= '<li class="control-group">' . $field->getLabel(); if ($field->fieldname == 'address1') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_address1 enable_profile_1"', 'value', 'text', 'location'); } elseif ($field->fieldname == 'address2') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_address2 enable_profile_1"', 'value', 'text', ''); } elseif ($field->fieldname == 'city') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_city enable_profile_1"', 'value', 'text', 'hometown'); } elseif ($field->fieldname == 'region') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_region enable_profile_1"', 'value', 'text', ''); } elseif ($field->fieldname == 'country') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_country enable_profile_1"', 'value', 'text', ''); } elseif ($field->fieldname == 'website') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_website enable_profile_1"', 'value', 'text', 'website'); } elseif ($field->fieldname == 'aboutme') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_aboutme enable_profile_1"', 'value', 'text', 'bio'); } elseif ($field->fieldname == 'dob') { $html .= JHtml::_('select.genericlist', $options, '', 'class="profile_dob enable_profile_1"', 'value', 'text', 'birthday'); } } } } } $html .= "</ul>"; $html .= '<input class="socialinput" type="hidden" name="' . $this->name . '" value="' . $this->value . '" />'; return $html; }
$fieldSets = $form->getFieldsets('quickpublishcomponents'); foreach ($fieldSets as $name => $fieldSet) { //var_dump($name); ?> <div class="row-fluid"> <div class="span12"> <form id="modquickpublish<?php echo $name; ?> " name="modquickpublish<?php echo $name; ?> " action="index.php"> <?php foreach ($form->getFieldset($name) as $field) { ?> <div class="control-group"> <?php if (!in_array($field->type, array('Text', 'Textarea'))) { ?> <label class="control-label" for="inputEmail"> <?php echo $field->label; ?> </label> <?php } ?> <div class="controls"> <?php
/** * Render the initial plugin options, such as the plugin selector, and whether its rendered in front/back/both etc * * @return string */ public function top() { $data = $this->getData(); $c = $this->getState('c') + 1; $version = new JVersion(); $j3 = version_compare($version->RELEASE, '3.0') >= 0 ? true : false; $class = $j3 ? 'form-horizontal ' : 'adminform '; $str = array(); $str[] = '<div class="pane-slider content pane-down accordion-inner">'; $str[] = '<fieldset class="' . $class . 'pluginContainer" id="formAction_' . $c . '"><ul>'; $formName = 'com_fabrik.' . $this->getState('type') . '-plugin'; $topForm = new JForm($formName, array('control' => 'jform')); $topForm->repeatCounter = $c; $xmlFile = JPATH_SITE . '/administrator/components/com_fabrik/models/forms/' . $this->getState('type') . '-plugin.xml'; // Add the plugin specific fields to the form. $topForm->loadFile($xmlFile, false); $topForm->bind($data); // Filter the forms fieldsets for those starting with the correct $searchName prefix foreach ($topForm->getFieldsets() as $fieldset) { if ($fieldset->label != '') { $str[] = '<legend>' . $fieldset->label . '</legend>'; } foreach ($topForm->getFieldset($fieldset->name) as $field) { if (!$j3) { $str[] = '<li>' . $field->label . $field->input . '</li>'; } else { $str[] = '<div class="control-group"><div class="control-label">' . $field->label; $str[] = '</div><div class="controls">' . $field->input . '</div></div>'; } } } $str[] = '</ul>'; $str[] = '<div class="pluginOpts" style="clear:left"></div>'; if ($j3) { $str[] = '<div class="form-actions"><a href="#" class="btn btn-danger" data-button="removeButton">'; $str[] = '<i class="icon-delete"></i> ' . FText::_('COM_FABRIK_DELETE') . '</a></div>'; } else { $str[] = '<a href="#" class="delete removeButton">' . FText::_('COM_FABRIK_DELETE') . '</a>'; } $str[] = '</fieldset>'; $str[] = '</div>'; return implode("\n", $str); }
protected function getInput() { if (!function_exists('xtcsortfn')) { function xtcsortfn($a, $b) { return strnatcmp($a[0], $b[0]); } } jimport('joomla.filesystem.folder'); JHTML::_('behavior.modal', 'a.modal'); $template = basename(dirname(dirname(dirname(__FILE__)))); $live_site = JURI::root(); $document = JFactory::getDocument(); $id = JRequest::getInt('id'); $document->addStyleSheet($live_site . "templates/{$template}/XTC/XTC.css", 'text/css'); $path = JPATH_ROOT . '/templates/' . $template; $folders = JFolder::folders($path . '/layouts'); $layouts = array(); foreach ($folders as $folder) { // Parse parameter files $xmlFile = $path . '/layouts/' . $folder . '/config.xml'; if (is_readable($xmlFile)) { $xml = simplexml_load_file($xmlFile); $name = isset($xml->name) ? $xml->name : $folder; $description = isset($xml->description) ? trim($xml->description) : ''; } else { $name = $folder; $description = ''; } $thumbnail = ''; if (file_exists($path . '/layouts/' . $folder . '/thumbnail.gif')) { $thumbnail = 'thumbnail.gif'; } elseif (file_exists($path . '/layouts/' . $folder . '/thumbnail.jpg')) { $thumbnail = 'thumbnail.jpg'; } elseif (file_exists($path . '/layouts/' . $folder . '/thumbnail.png')) { $thumbnail = 'thumbnail.png'; } $fullimage = ''; if (file_exists($path . '/layouts/' . $folder . '/layout.gif')) { $fullimage = 'layout.gif'; } elseif (file_exists($path . '/layouts/' . $folder . '/layout.jpg')) { $fullimage = 'layout.jpg'; } elseif (file_exists($path . '/layouts/' . $folder . '/layout.png')) { $fullimage = 'layout.png'; } $layouts[] = array($name, $folder, $description, $thumbnail, $fullimage); } usort($layouts, "xtcsortfn"); $stringFilter = JFilterInput::getInstance(); require_once $path . '/XTC/XTC_library.php'; $templateParameters = xtcLoadParams($id); $html = ''; $navHtml = ''; $tabHtml = ''; $count = count($layouts); $openClass = $count == 1 ? ' open' : ''; foreach ($layouts as $i => $layout) { // Draw layouts list($name, $folder, $description, $thumbnail, $fullimage) = $layout; $params = isset($templateParameters->group->{$folder}) ? $templateParameters->group->{$folder} : new stdClass(); $tabid = $folder . $i; // Parameter Tab $active = $i == 0 ? ' class="active"' : ''; $navHtml .= '<li' . $active . '>'; $navHtml .= '<a href="#' . $tabid . '" data-toggle="tab">'; if ($thumbnail) { $thumbnailURL = $live_site . 'templates/' . $template . '/layouts/' . $folder . '/' . $thumbnail; $navHtml .= '<img class="img-rounded" src="' . $thumbnailURL . '" alt="" /><br/>'; } $navHtml .= '<center>' . $name . '</center>'; $navHtml .= '</a>'; $navHtml .= '</li>'; // Parameter Tab contents $form = new JForm('jxtc'); $form->addFieldPath(JPATH_ROOT . '/templates/' . $template . '/XTC/elements'); $xmlFile = $path . '/layouts/' . $folder . '/config.xml'; $form->loadFile($xmlFile); $getFieldsets = $form->getFieldsets(); $active = $i == 0 ? ' active' : ''; $tabHtml .= '<div class="tab-pane' . $active . '" id="' . $tabid . '">'; $tabHtml .= '<div class="xtc row-fluid">'; $tabHtml .= '<div class="span5">'; foreach ($getFieldsets as $fieldsets => $fieldset) { $label = trim($fieldset->label); if (empty($label)) { $label = trim($fieldset->name); } $fieldsetDescription = isset($fieldset->description) ? trim($fieldset->description) : ''; if (count($getFieldsets) > 1) { $tabHtml .= '<fieldset>'; if ($label) { $tabHtml .= '<legend>' . $label . '</legend>'; } if ($fieldsetDescription) { $tabHtml .= '<div class="well">' . $fieldsetDescription . '</div>'; } } foreach ($form->getFieldset($fieldset->name) as $field) { $xtcName = substr($field->name, 7, -1); if (isset($params->{$xtcName})) { $field->value = $params->{$xtcName}; } $field->name = str_replace('params[', 'xtcparam[layout][' . $folder . '][', $field->name); $field->id = $stringFilter->clean($field->name, 'cmd'); $tabHtml .= '<div class="control-group">'; $tabHtml .= '<div class="control-label">' . $field->getLabel() . '</div>'; $tabHtml .= '<div class="controls">' . $field->getInput() . '</div>'; $tabHtml .= '</div>'; } if (count($getFieldsets) > 1) { $tabHtml .= '</fieldset>'; } } $tabHtml .= '</div>'; // span5 if ($description || $fullimage) { $tabHtml .= '<div class="span1"></div>'; $tabHtml .= '<div class="span4"><div class="well">'; $tabHtml .= '<h3>' . $name . '</h3>'; if ($description) { $tabHtml .= $description . '<br/><br/>'; } if ($fullimage) { $fullimageURL = $live_site . 'templates/' . $template . '/layouts/' . $folder . '/' . $fullimage; $headerimg_size = getimagesize($path . '/layouts/' . $folder . '/' . $fullimage); $width = $headerimg_size[0]; $height = $headerimg_size[1]; $onclick = "onclick=\"MyWindow=window.open('{$fullimageURL}','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width={$width},height={$height}'); return false;\""; $tabHtml .= '<a class="btn btn-primary" href="#" ' . $onclick . '>' . JText::_('TPL_JXTC_VIEWLAYOUT') . '</a>'; } $tabHtml .= '</div></div>'; } $tabHtml .= '</div>'; // row-fluid $tabHtml .= '</div>'; // tab-pane } $html .= '<div class="tabbable">'; $html .= '<ul class="nav nav-tabs">' . $navHtml . '</ul>'; $html .= '<div class="tab-content">' . $tabHtml . '</div>'; $html .= '</div>'; return $html; }
/** * getQuickaddForm */ public static function getQuickaddForm($id, $path, $extension = null) { $content = ''; //JForm::addFormPath(AKHelper::_('path.get', null, $extension).'/models/forms'); //JForm::addFieldPath(AKHelper::_('path.get', null, $extension).'/models/fields'); try { $form = new JForm($id . '.quickaddform', array('control' => $id)); $form->loadFile(JPATH_ROOT . '/' . $path); } catch (Exception $e) { Jerror::raiseWarning(404, $e->getMessage()); return false; } // Set Category Extension if ($extension) { $form->setValue('extension', null, $extension); } $fieldset = $form->getFieldset('quickadd'); foreach ($fieldset as $field) { $content .= "<div class=\"control-group\" id=\"jform_basic_alias-wrap\">\n <div class=\"control-label\">\n {$field->label}\n </div>\n <div class=\"controls\">\n {$field->input}\n </div>\n </div>"; } if (JVERSION < 3) { $content = "<fieldset class=\"adminform form-horizontal\">{$content}</fieldset>"; } return $content; }
/** * Method to inject data into the form. * * @param JForm $form Form headers without data. * * @return void * * @since 2.0 */ protected function bindFormData($form) { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_shconfig.edit.settings.data', array()); if (empty($data)) { // We need to get the items from the database $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select($db->quoteName('name'))->select($db->quoteName('value'))->from($db->quoteName('#__sh_config')); // Build the where clause for specifying only required settings from the table $whereClause = array(); foreach ($form->getFieldset() as $field) { $whereClause[] = $db->quoteName('name') . ' = ' . $db->quote($field->fieldname); } $query->where($whereClause, 'OR'); $data = $db->setQuery($query)->loadAssocList('name', 'value'); } $form->bind($data); }
// No direct access defined('_HZEXEC_') or die; // create user params registry $params = new \Hubzero\Config\Registry($this->module->params); // load module params fields $fields = new JForm($this->module->module); $fields->loadFile(PATH_CORE . DS . 'modules' . DS . $this->module->module . DS . $this->module->module . '.xml', true, 'config/fields'); // This is done first as the 'renderModule' method loads the language file // which is needed when rendering the params below $module = Module::render($this->module, array('style' => 'none')); // create settings sub view $view = $this->view('parameters'); $view->admin = $this->admin; $view->module = $this->module; $view->params = $params->toArray(); $view->fields = $fields->getFieldset('basic'); $settingsHtml = trim($view->loadTemplate()); ?> <div class="module <?php echo strtolower($this->module->module) . ' ' . $params->get('moduleclass_sfx'); ?> draggable sortable" data-row="<?php echo $this->module->positioning->row; ?> " data-col="<?php echo $this->module->positioning->col; ?> "
/** * Render the initial plugin options, such as the plugin selector, and whether its rendered in front/back/both etc * * @return string */ public function top() { $data = $this->getData(); $c = $this->getState('c') + 1; $str = array(); $str[] = '<div class="pane-slider content pane-down">'; $str[] = '<fieldset class="adminform pluginContanier" id="formAction_' . $c . '"><ul>'; $formName = 'com_fabrik.' . $this->getState('type') . '-plugin'; $topForm = new JForm($formName, array('control' => 'jform')); $topForm->repeatCounter = $c; $xmlFile = JPATH_SITE . '/administrator/components/com_fabrik/models/forms/' . $this->getState('type') . '-plugin.xml'; // Add the plugin specific fields to the form. $topForm->loadFile($xmlFile, false); $topForm->bind($data); // Filer the forms fieldsets for those starting with the correct $serachName prefix foreach ($topForm->getFieldsets() as $fieldset) { if ($fieldset->label != '') { $str[] = '<legend>' . $fieldset->label . '</legend>'; } foreach ($topForm->getFieldset($fieldset->name) as $field) { $str[] = '<li>' . $field->label . $field->input . '</li>'; } } $str[] = '</ul>'; $str[] = '<div class="pluginOpts" style="clear:left"></div>'; $str[] = '<a href="#" class="delete removeButton">' . JText::_('COM_FABRIK_DELETE') . '</a>'; $str[] = '</fieldset>'; $str[] = '</div>'; return implode("\n", $str); }
/** * Method to get the field input markup. * * @since 1.6 * * @return string The field input markup. */ protected function getInput() { // Initialize variables. $document = JFactory::getDocument(); $options = array(); JHTML::stylesheet('administrator/components/com_fabrik/views/fabrikadmin.css'); $subForm = new JForm($this->name, array('control' => 'jform')); $xml = $this->element->children()->asFormattedXML(); $subForm->load($xml); /** * f3 hack */ $view = JRequest::getCmd('view', 'list'); switch ($view) { case 'item': $view = 'list'; $id = (int) $this->form->getValue('request.listid'); break; case 'module': $view = 'list'; $id = (int) $this->form->getValue('params.list_id'); break; default: $id = JRequest::getInt('id'); break; } $feModel = JModel::getInstance($view, 'FabrikFEModel'); $feModel->setId($id); $subForm->model = $feModel; /* * end */ $children = $this->element->children(); $subForm->setFields($children); $str = array(); $modalid = $this->id . '_modal'; // As JForm will render child fieldsets we have to hide it via CSS $fieldSetId = str_replace('jform_params_', '', $modalid); $css = '#' . $fieldSetId . ' { display: none; }'; $document->addStyleDeclaration($css); $str[] = '<div id="' . $modalid . '" style="display:none">'; $str[] = '<table class="adminlist">'; $str[] = '<thead><tr class="row0">'; $names = array(); foreach ($subForm->getFieldset($this->element->getAttribute('name') . '_modal') as $field) { $names[] = $field->element->getAttribute('name'); $str[] = '<th>' . $field->getLabel($field->name) . '</th>'; } $str[] = '<th></th>'; $str[] = '</tr></thead>'; $str[] = '<tbody><tr>'; foreach ($subForm->getFieldset($this->element->getAttribute('name') . '_modal') as $field) { $str[] = '<td>' . $field->getInput() . '</td>'; } $app = JFactory::getApplication(); $path = 'templates/' . $app->getTemplate() . '/images/menu/'; $str[] = '<td><div style="width:35px"><a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a>'; $str[] = '<a href="#" class="remove"><img src="' . $path . '/icon-16-delete.png" alt="' . JText::_('REMOVE') . '" /></a>'; $str[] = '</td>'; $str[] = '</tr></tbody>'; $str[] = '</table>'; $str[] = '</div>'; $form = implode("\n", $str); static $modalrepeat; if (!isset($modalrepeat)) { $modalrepeat = array(); } if (!array_key_exists($modalid, $modalrepeat)) { $modalrepeat[$modalid] = array(); } if (!isset($this->form->repeatCounter)) { $this->form->repeatCounter = 0; } if (!array_key_exists($this->form->repeatCounter, $modalrepeat[$modalid])) { // If loaded as js template then we don't want to repeat this again. (fabrik) $names = json_encode($names); $pane = str_replace('jform_params_', '', $modalid) . '-options'; $modalrepeat[$modalid][$this->form->repeatCounter] = true; $script = str_replace('-', '', $modalid) . " = new FabrikModalRepeat('{$modalid}', {$names}, '{$this->id}');"; if (JRequest::getVar('option') === 'com_fabrik') { FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script); } else { // Wont work when rendering in admin module page // @TODO test this now that the list and form pages are loading plugins via ajax (18/08/2012) JHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', true); $document->addScriptDeclaration("window.addEvent('domready', function() {\n\t\t\t" . $script . "\n\t\t\tif (typeOf(\$('{$pane}')) !== 'null') {\n\t\t\t \$('{$pane}').getParent().hide();\n\t\t\t}\n\t\t\t});"); } } $close = "function(c){" . $modalid . ".onClose(c);}"; $str[] = '<div class="button2-left">'; $str[] = ' <div class="blank">'; $str[] = '<a id="' . $modalid . '_button" />' . JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; 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 . '" />'; return implode("\n", $str); }
protected function getInput() { jimport('joomla.html.parameter'); jimport('joomla.html.pane'); $id = JRequest::getInt('id'); $live_site = JURI::root(); $template = basename(dirname(dirname(dirname(__FILE__)))); $path = JPATH_ROOT . '/templates/' . $template; $document = JFactory::getDocument(); $document->addStyleSheet($live_site . "templates/{$template}/XTC/XTC.css", 'text/css'); $xmlFile = JPATH_ROOT . '/templates/' . $template . '/XTC/XTC_config.xml'; if (!is_readable($xmlFile)) { return "No parameters found."; } else { if (is_readable($xmlFile)) { $xml = simplexml_load_file($xmlFile); $name = isset($xml->name) ? $xml->name : ''; $description = isset($xml->description) ? trim($xml->description) : ''; } else { $name = ''; $description = ''; } } $form = new JForm('jxtc'); $form->addFieldPath(JPATH_ROOT . '/templates/' . $template . '/XTC/elements'); $form->loadFile($xmlFile); $getFieldsets = $form->getFieldsets(); require_once $path . '/XTC/XTC_library.php'; $templateParameters = xtcLoadParams($id); $html = ''; $html .= '<div class="xtc row-fluid">'; $html .= '<div class="span5">'; foreach ($getFieldsets as $fieldsets => $fieldset) { $label = trim($fieldset->label); if (empty($label)) { $label = trim($fieldset->name); } $fieldsetDescription = isset($fieldset->description) ? trim($fieldset->description) : ''; if (count($getFieldsets) > 1) { // Split in xtc fieldsets $html .= '<fieldset>'; if ($label) { $html .= '<legend>' . $label . '</legend>'; } if ($fieldsetDescription) { $html .= '<div>' . $fieldsetDescription . '</div>'; } } foreach ($form->getFieldset($fieldset->name) as $field) { $xtcName = substr($field->name, 7, -1); if (isset($templateParameters->{$xtcName})) { $field->value = $templateParameters->{$xtcName}; } $field->name = str_replace('params[', 'jform[params][', $field->name); $html .= '<div class="control-group">'; $html .= '<div class="control-label">' . $field->getLabel() . '</div>'; $html .= '<div class="controls">' . $field->getInput() . '</div>'; $html .= '</div>'; } if (count($getFieldsets) > 1) { $html .= '</fieldset>'; } } $html .= '</div>'; //span if ($description) { $html .= '<div class="span1"></div>'; $html .= '<div class="span4">'; $html .= '<h3>' . $name . '</h3>'; $html .= '<div class="well">' . $description . '</div></div>'; } $html .= '</div>'; // row-fluid $html .= '<script type="text/javascript"> original = Joomla.submitbutton; Joomla.submitbutton = function(task) { if (task == "style.apply" || task == "style.save" || task == "style.save2copy") { form = document.getElementById("style-form"); form.action="index.php?option=com_jxtc&id=' . JRequest::getInt('id') . '" form.task.value = task.substr(6); form.submit(); } else { original(task); } } function switchpane(name) { pane = document.getElementById(name); if (pane.className == "xtcPane") { pane.setAttribute("class", "xtcPane open"); } else { pane.setAttribute("class", "xtcPane"); } } </script>'; return $html; }
/** * Method to get the field input markup. * * @since 1.6 * * @return string The field input markup. */ protected function getInput() { // Initialize variables. $app = JFactory::getApplication(); $document = JFactory::getDocument(); $options = array(); JHTML::stylesheet('administrator/components/com_fabrik/views/fabrikadmin.css'); $subForm = new JForm($this->name, array('control' => 'jform')); $xml = $this->element->children()->asXML(); $subForm->load($xml); $j3 = FabrikWorker::j3(); // Needed for repeating modals in gmaps viz $subForm->repeatCounter = (int) @$this->form->repeatCounter; /** * f3 hack */ $input = $app->input; $view = $input->get('view', 'list'); switch ($view) { case 'item': $view = 'list'; $id = (int) $this->form->getValue('request.listid'); break; case 'module': $view = 'list'; $id = (int) $this->form->getValue('params.list_id'); break; default: $id = $input->getInt('id'); break; } if ($view === 'element') { $pluginManager = FabrikWorker::getPluginManager(); $feModel = $pluginManager->getPluginFromId($id); } else { $feModel = JModelLegacy::getInstance($view, 'FabrikFEModel'); $feModel->setId($id); } $subForm->model = $feModel; // Hack for order by elements which we now want to store as ids $v = json_decode($this->value); if (isset($v->order_by)) { $formModel = $feModel->getFormModel(); foreach ($v->order_by as &$orderBy) { $elementModel = $formModel->getElement($orderBy, true); $orderBy = $elementModel ? $elementModel->getId() : $orderBy; } } $this->value = json_encode($v); /* * end */ $children = $this->element->children(); // $$$ rob 19/07/2012 not sure y but this fires a strict standard warning deep in JForm, suppress error for now @$subForm->setFields($children); $str = array(); $version = new JVersion(); $j32 = version_compare($version->RELEASE, '3.2') >= 0 ? true : false; $modalid = $j32 ? 'attrib-' . $this->id . '_modal' : $this->id . '_modal'; // As JForm will render child fieldsets we have to hide it via CSS $fieldSetId = str_replace('jform_params_', '', $modalid); $css = '#' . $fieldSetId . ' { display: none; }'; $document->addStyleDeclaration($css); $path = 'templates/' . $app->getTemplate() . '/images/menu/'; $str[] = '<div id="' . $modalid . '" style="display:none">'; $str[] = '<table class="adminlist ' . $this->element['class'] . ' table table-striped">'; $str[] = '<thead><tr class="row0">'; $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>'; } if ($j3) { $str[] = '<th><a href="#" class="add btn button btn-success"><i class="icon-plus"></i> </a></th>'; } else { $str[] = '<th><a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a></th>'; } $str[] = '</tr></thead>'; $str[] = '<tbody><tr>'; foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) { $str[] = '<td>' . $field->getInput() . '</td>'; } $str[] = '<td>'; if ($j3) { $str[] = '<div class="btn-group"><a class="add btn button btn-success"><i class="icon-plus"></i> </a>'; $str[] = '<a class="remove btn button btn-danger"><i class="icon-minus"></i> </a></div>'; } else { $str[] = '<a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a>'; $str[] = '<a href="#" class="remove"><img src="' . $path . '/icon-16-delete.png" alt="' . JText::_('REMOVE') . '" /></a>'; } $str[] = '</td>'; $str[] = '</tr></tbody>'; $str[] = '</table>'; $str[] = '</div>'; $form = implode("\n", $str); static $modalrepeat; if (!isset($modalrepeat)) { $modalrepeat = array(); } if (!array_key_exists($modalid, $modalrepeat)) { $modalrepeat[$modalid] = array(); } if (!isset($this->form->repeatCounter)) { $this->form->repeatCounter = 0; } if (!array_key_exists($this->form->repeatCounter, $modalrepeat[$modalid])) { // If loaded as js template then we don't want to repeat this again. (fabrik) $names = json_encode($names); $pane = str_replace('jform_params_', '', $modalid) . '-options'; $modalrepeat[$modalid][$this->form->repeatCounter] = true; $opts = new stdClass(); $opts->j3 = $j3; $opts = json_encode($opts); $script = str_replace('-', '', $modalid) . " = new FabrikModalRepeat('{$modalid}', {$names}, '{$this->id}', {$opts});"; $option = $input->get('option'); if ($option === 'com_fabrik') { FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script); } else { if ($j3) { $context = strtoupper($option); if ($context === 'COM_ADVANCEDMODULES') { $context = 'COM_MODULES'; } $j3pane = $context . '_' . str_replace('jform_params_', '', $modalid) . '_FIELDSET_LABEL'; if ($j32) { $j3pane = strtoupper(str_replace('attrib-', '', $j3pane)); } $script = "window.addEvent('domready', function() {\n\t\t\t\tvar a = jQuery(\"a:contains('{$j3pane}')\");\n\t\t\t\t\t\tif (a.length > 0) {\n\t\t\t\t\t\t\ta = a[0];\n\t\t\t\t\t\t\tvar href= a.get('href');\n\t\t\t\t\t\t\tjQuery(href)[0].destroy();\n\n\t\t\t\t\t\t\tvar accord = a.getParent('.accordion-group');\n\t\t\t\t\t\t\tif (typeOf(accord) !== 'null') {\n\t\t\t\t\t\t\t\taccord.destroy();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ta.destroy();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t" . $script . "\n\t\t\t\t\t\t}\n\t\t\t\t\t});"; } else { $script = "window.addEvent('domready', function() {\n\t\t\t" . $script . "\n\t\t\tif (typeOf(\$('{$pane}')) !== 'null') {\n\t\t\t \$('{$pane}').getParent().hide();\n\t\t\t}\n\t\t\t});"; } // Wont work when rendering in admin module page // @TODO test this now that the list and form pages are loading plugins via ajax (18/08/2012) FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script); } } if (is_array($this->value)) { $this->value = array_shift($this->value); } $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'); if ($j3) { $icon = $this->element['icon'] ? '<i class="icon-' . $this->element['icon'] . '"></i> ' : ''; $icon .= JText::_('JLIB_FORM_BUTTON_SELECT'); $str[] = '<button class="btn" id="' . $modalid . '_button" data-modal="' . $modalid . '">' . $icon . '</button>'; $str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />'; } else { $str[] = '<div class="button2-left">'; $str[] = ' <div class="blank">'; $str[] = ' <a id="' . $modalid . '_button" data-modal="' . $modalid . '">' . JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>'; $str[] = ' <input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />'; $str[] = ' </div>'; $str[] = '</div>'; } FabrikHelperHTML::framework(); FabrikHelperHTML::iniRequireJS(); return implode("\n", $str); }
/** * * We need to specially prepare the form because we're merging templateDetails.xml from a template and params.xml from the plugin. * @param JForm $form * @param mixed $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'); $default_settings_file = JPATH_ROOT . DS . 'templates' . DS . $this->template . DS . 'templateDefaults.json'; if (!$plg_file) { return false; } // params.xml should be loaded first and templateDetails.xml afterwards if ($tpl_file) { $form->loadFile($plg_file, false, '//form'); $form->loadFile($tpl_file, false, '//config'); } else { $form->loadFile($plg_file, false, '//form'); } // for users' own safety, we don't allow some things to be changed in the front-end if ($app->isSite()) { $jmstorage_fields = $form->getFieldset('jmstorage'); foreach ($jmstorage_fields as $name => $field) { $form->removeField($name, 'params'); } $form->removeField('config', 'params'); $jmlayoutbuilder_fields = $form->getFieldset('jmlayoutbuilder'); foreach ($jmlayoutbuilder_fields as $name => $field) { $form->removeField($name, 'params'); } $form->removeField('layout', 'params'); } // Hiding a notice to enable this plugin. If plugin is disabled then the notice is visible. That's it. if ($app->isAdmin()) { $doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important}'); } if (JFile::exists($default_settings_file)) { $settings_json = JFile::read($default_settings_file); if ($settings_json) { $defaults = json_decode($settings_json, true); if ($defaults && is_array($defaults)) { foreach ($form->getFieldset() as $field) { $field_name = $field->__get('fieldname'); if (array_key_exists($field_name, $defaults) && is_scalar($defaults[$field_name])) { $form->setFieldAttribute($field_name, 'default', $defaults[$field_name], $field->__get('group')); } } /*if (!empty($data) && isset($data->params)) { foreach ($data->params as $param_name => $param_value) { if (empty($param_value) && array_key_exists($param_name, $defaults) && is_scalar($defaults[$param_name])) { $data->params[$param_name] = $defaults[$param_name]; } } }*/ } } } } }
/** * 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 // @TODO: what and where??? $subForm->repeatCounter = (int) @$this->form->repeatCounter; $children = $this->element->children(); $subForm->setFields($children); // JHtml::_('sortablelist.sortable', $this->id . '_table', 'adminForm', 'asc', ''); // // 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'; // Build a Table $head_row_str = array(); $body_row_str = array(); $head_row_str[] = '<th></th>'; $body_row_str[] = '<td class="order nowrap center hidden-phone" style="width: 32px;">' . '<span class="sortable-handler" style="cursor: move;"><i class="icon-menu"></i></span>' . '<input type="text" class="width-20 text-area-order" value="0" size="5" name="order[]" style="display:none"></td>'; foreach ($subForm->getFieldset() as $field) { // Reset name to simple $field->name = (string) $field->element['name']; // Build heading $head_row_str[] = '<th>' . strip_tags($field->getLabel($field->name)); $head_row_str[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>'; $head_row_str[] = '</th>'; // Build body $body_row_str[] = '<td>' . $field->getInput() . '</td>'; } // Append buttons $head_row_str[] = '<th><div class="btn-group"><a href="#" class="add btn button btn-success"><span class="icon-plus"></span> </a></div></th>'; $body_row_str[] = '<td><div class="btn-group">'; $body_row_str[] = '<a class="add btn button btn-success"><span class="icon-plus"></span> </a>'; $body_row_str[] = '<a class="remove btn button btn-danger"><span class="icon-minus"></span> </a>'; $body_row_str[] = '</div></td>'; // Put all table parts together $table = '<table id="' . $this->id . '_table" class="adminlist ' . $this->element['class'] . ' table table-striped">' . '<thead><tr>' . '<td colspan="' . count($head_row_str) . '">Edição de itens de vídeo (até 3 itens)' . '<button class="close closebutton close-modal" style="float:right" type="button">×</button></td>' . '</tr><tr>' . implode("\n", $head_row_str) . '</tr></thead>' . '<tbody><tr class="dndlist-sortable">' . implode("\n", $body_row_str) . '</tr></tbody>' . '</table>'; // And finaly build a main container $str = array(); $str[] = '<div id="' . $this->id . '_container">'; // Add the table to modal $str[] = '<div id="' . $this->id . '_modal" class="modal hide">'; $str[] = $table; $str[] = '<div class="modal-footer">'; $str[] = '<button class="close-modal btn button btn-link">' . JText::_('JCANCEL') . '</button>'; $str[] = '<button class="save-modal-data btn button btn-primary">' . JText::_('JAPPLY') . '</button>'; $str[] = '</div>'; // Close modal container $str[] = '</div>'; // Close main container $str[] = '</div>'; // Button for display the modal window $select = (string) $this->element['select'] ? JText::_((string) $this->element['select']) : JText::_('JLIB_FORM_BUTTON_SELECT'); $icon = $this->element['icon'] ? '<span class="icon-' . $this->element['icon'] . '"></span> ' : ''; $str[] = '<button class="open-modal btn" id="' . $this->id . '_button" >' . $icon . $select . '</button>'; if (is_array($this->value)) { $this->value = array_shift($this->value); } $script = "(function (\$){\r\n\t\t\t\$(document).ready(function (){\t\t\t\t\r\n\t\t\t\t\$('#" . $this->id . "_table').on('change', '*[name^=\"url-\"]', function (e, target)\r\n\t\t\t\t{\r\n\t\t\t\t\tcompletarValores( \$(this), true );\r\n\t\t\t\t});\r\n\t\t\t\t\$('#" . $this->id . "_table').on('click', '*[name^=\"url-\"]', function (e, target)\r\n\t\t\t\t{\r\n\t\t\t\t\tcompletarValores( \$(this), false );\r\n\t\t\t\t});\r\n\t\t\t\t/*\$('#" . $this->id . "_table').on('click', '#" . $this->id . "_button', function (e, target)\r\n\t\t\t\t{\r\n\t\t\t\t\t\$('#" . $this->id . "_table *[name^=\"url-\"]').each(function(){\r\n\t\t\t\t\t\tcompletarValores( \$(this), false );\r\n\t\t\t\t\t});\r\n\t\t\t\t});*/\r\n\t\t\t});\r\n\t\t})(jQuery);"; $document = JFactory::getDocument(); $document->addScriptDeclaration($script); JHTML::script('modules/mod_videosdestaque/js/backend.js'); // Script params $data = array(); $data[] = 'data-container="#' . $this->id . '_container"'; $data[] = 'data-modal-element="#' . $this->id . '_modal"'; $data[] = 'data-repeatable-element="table tbody tr"'; $data[] = 'data-bt-add="a.add"'; $data[] = 'data-bt-remove="a.remove"'; $data[] = 'data-bt-modal-open="#' . $this->id . '_button"'; $data[] = 'data-bt-modal-close="button.close-modal"'; $data[] = 'data-bt-modal-save-data="button.save-modal-data"'; $data[] = 'data-maximum="' . $maximum . '"'; $data[] = 'data-input="#' . $this->id . '"'; // Hidden input, where the main value is $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'); $str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" class="form-field-repeatable" ' . implode(' ', $data) . ' />'; // Add scripts JHtml::_('bootstrap.framework'); JHtml::_('script', 'system/repeatable.js', true, true); return implode("\n", $str); //------------------------------------------------ // 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'; JHtml::_('sortablelist.sortable', $modalid . '_table', 'adminForm', 'asc', ''); $str = array(); $names = array(); $attributes = $this->element->attributes(); $str_cols = array(); $counter_cols = 1; foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) { $names[] = (string) $field->element->attributes()->name; $str_cols[] = '<th>' . strip_tags($field->getLabel($field->name)); $str_cols[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>'; $str_cols[] = '</th>'; $counter_cols++; } $str[] = '<div id="' . $modalid . '" style="display:none">'; $str[] = '<table id="' . $modalid . '_table" class="adminlist ' . $this->element['class'] . ' table table-striped">'; $str[] = '<thead><tr><td colspan="' . ($counter_cols + 1) . '">Edição de itens de vídeo (até 3 colunas)'; $str[] = '<button class="close closebutton" style="float:right" type="button">×</button></td></tr><tr>'; $str[] = '<th>Ordem</th>'; $str = array_merge($str, $str_cols); $str[] = '<th><a href="#" class="add btn button btn-success"><span class="icon-plus"></span> </a></th>'; $str[] = '</tr></thead>'; $str[] = '<tbody><tr class="dndlist-sortable">'; $str[] = '<td class="order nowrap center hidden-phone" style="width: 32px;">'; $str[] = '<span class="sortable-handler" style="cursor: move;"><i class="icon-menu"></i></span>'; $str[] = '<input type="text" class="width-20 text-area-order" value="0" size="5" name="order[]" style="display:none"></td>'; // $str[] = '<td><input type="text" class="width-20 text-area-order" value="0" size="5"></td>'; 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="icon-plus"></span> </a>'; $str[] = '<a class="remove btn button btn-danger"><span class="icon-minus"></span> </a></div>'; $str[] = '</td>'; $str[] = '</tr></tbody>'; $str[] = '</table>'; $str[] = '</div>'; $names = json_encode($names); //codigo replicado para o modulo por nao ser compativel com nova versao de repeatable da versao 3.4.1 JHTML::script('modules/mod_videosdestaque/js/repeatable.js'); // // 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\t\$('.closebutton').click(function(){\r\n\t\t\t\t\t// console.log(\$('#" . $modalid . "_table').parent().html());\r\n\t\t\t\t\t// console.log(\$('#" . $modalid . "_table').parent().prev().parent().html());\r\n\t\t\t\t\t\$('#" . $modalid . "_table').parent().hide();\r\n\t\t\t\t\t\$('#" . $modalid . "_table').parent().prev().hide();\r\n\t\t\t\t});\r\n\t\t\t\t\$('#" . $modalid . "_table').on('change', '*[name^=\"url-\"]', function (e, target)\r\n\t\t\t\t{\r\n\t\t\t\t\tcompletarValores( \$(this), true );\r\n\t\t\t\t});\r\n\t\t\t\t\$('#" . $modalid . "_table').on('click', '*[name^=\"url-\"]', function (e, target)\r\n\t\t\t\t{\r\n\t\t\t\t\tcompletarValores( \$(this), false );\r\n\t\t\t\t});\r\n\t\t\t\t/*\$('#" . $modalid . "_table').on('click', '#" . $modalid . "_button', function (e, target)\r\n\t\t\t\t{\r\n\t\t\t\t\t\$('#" . $modalid . "_table *[name^=\"url-\"]').each(function(){\r\n\t\t\t\t\t\tcompletarValores( \$(this), false );\r\n\t\t\t\t\t});\r\n\t\t\t\t});*/\r\n\t\t\t});\r\n\t\t})(jQuery);"; $document = JFactory::getDocument(); $document->addScriptDeclaration($script); JHTML::script('modules/mod_videosdestaque/js/backend.js'); $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); }
/** * * @param JForm $form form object * @param string $name name of the fieldset * @param string $group name of the group * @param string $type may be classic, table, params * @return string Raw HTML text */ public static function renderFieldset($form, $name, $defaults, $group = null, $type = 1, $title = 1) { $fieldsets = $form->getFieldsets($group); $fieldset = $fieldsets[$name]; if (is_array($defaults)) { $registry = new JRegistry(); $registry->loadArray($defaults); $defaults = $registry; } /*else if(is_string($item->params)) { $registry = new JRegistry; $registry->loadString($item->params); $defaults = $registry; }*/ $fields = $form->getFieldset($name); $defaultGetName = empty($group) ? '%2$s' : '%s.%s'; $doc = JFactory::getDocument(); $doc->addStyleSheet(JURI::root() . 'libraries/mint/forms/style.css'); $out = ''; switch ($type) { case FORM_STYLE_CLASSIC: if ($title && $fieldset->label) { $out .= '<fieldset class="adminform whitebg"><legend>' . JText::_($fieldset->label) . '</legend>'; } if (isset($fieldset->description) && !empty($fieldset->description)) { $out .= '<small class="small">' . JText::_($fieldset->description) . '</small>'; } $out .= '<ul class="adminformlist">'; foreach ($fields as $key => $field) { $out .= '<li>'; if (!$field->hidden) { $out .= $field->label; } $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= '</li>'; } $out .= '</ul>'; if ($title) { $out .= '</fieldset>'; } break; case FORM_STYLE_TABLE: if ($title && $fieldset->label) { $out .= '<legend>' . JText::_($fieldset->label) . '</legend>'; } if (isset($fieldset->description) && !empty($fieldset->description)) { $out .= '<small>' . JText::_($fieldset->description) . '</small><br /><br />'; } $out .= '<table class="table table-bordered table-striped table-hover">'; $i = 1; $hidden = array(); foreach ($fields as $key => $field) { if ($field->hidden) { $hidden[] = $field; continue; } if ($field->type == 'Caddress' || $field->type == 'Ccontacts' || $field->type == 'Clinks' || $field->type == 'Cobaltevents') { if (trim($out) == '<legend>' . JText::_($fieldset->label) . '</legend><table class="table table-bordered table-striped table-hover">') { $out = '<legend>' . JText::_($fieldset->label) . '</legend>'; } else { $out .= '</table>'; } //$out .= '<tr class="row'.$i = 1 - $i.'"><td colspan="2">'; if ($field->type != 'Cobaltevents') { $out .= '<legend>' . $field->label . '</legend>'; $out .= '<br />'; } $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); //$out .= '</td></tr>'; $out .= '<br /><table class="table table-bordered table-striped table-hover">'; } else { $out .= '<tr><td>'; if (substr($field->description, 0, 3) == 'XX_') { $out .= '<img src="' . JUri::root(true) . '/media/mint/icons/16/exclamation-button.png" alt="Important" class="pull-right">'; } $out .= $field->label; $out .= '</td><td nowrap="nowrap">'; $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= '</td></tr>'; } } $out .= '</table>'; foreach ($hidden as $field) { $out .= $field->input; } break; case FORM_STYLE_PARAMS: $hidden = array(); if ($title && $fieldset->label) { $out .= '<h2 class="params-title">' . JText::_($fieldset->label) . '</h2>'; } if (isset($fieldset->description) && !empty($fieldset->description)) { $out .= '<p class="params-description">' . JText::_($fieldset->description) . '</p>'; } foreach ($fields as $key => $field) { if ($field->hidden) { $hidden[] = $field; continue; } $switch = array('checkbox'); if (in_array(strtolower($field->type), $switch)) { $out .= '<div class="params-line">'; $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= $field->label; $out .= '</div>'; } else { $out .= '<div class="params-line">'; $out .= $field->label; $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); $out .= '</div>'; } } foreach ($hidden as $field) { $out .= $form->getInput($field->fieldname, $group, $defaults->get(sprintf($defaultGetName, $group, $field->fieldname))); } $out .= '<br />'; break; } return $out; }
/** * Display our CMC fields at the registration * * @param object $tab - The tab * @param JUser $user - The user * @param object $ui - The UI * @param object $postdata - The postdata * * @return string */ public function getDisplayRegistration($tab, $user, $ui, $postdata) { JHtml::_('stylesheet', JURI::root() . 'media/mod_cmc/css/cmc.css'); CompojoomHtmlBehavior::jquery(); $plugin = GetCmcTab::getPlugin(); $listid = $plugin->params->get('listid', ""); $interests = $plugin->params->get('interests', ''); $fields = $plugin->params->get('fields', ''); // Create the xml for JForm $builder = CmcHelperXmlbuilder::getInstance($plugin->params); // Load JS & Co JFactory::getDocument()->addScriptDeclaration("\n\t\t\tjQuery(document).ready(function(){\n\t\t\t\tvar \$ = jQuery;\n\n\t\t\t\t\$('#cmc_check_newsletter').on('click', function() {\n\t\t\t\t\tif(\$(this).prop('checked'))\n\t\t\t\t\t{\n\t\t\t\t\t\t\$('input.cmc_req').addClass('required');\n\t\t\t\t\t\t\$('#cmc_newsletter').show();\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t\$('input.cmc_req').removeClass('required');\n\t\t\t\t\t\t\$('#cmc_newsletter').hide();\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t\$('#cmc_newsletter').hide();\n\t\t\t});\n\t\t"); // We have to set the fields / interests manually for cb because they are no array! See explode if (!empty($fields)) { $fields = explode("|*|", $plugin->params->get('fields', '')); $builder->fields = $fields; } if (!empty($interests)) { $interests = explode("|*|", $plugin->params->get('interests', '')); $builder->interests = $interests; } $xml = $builder->build(); $form = new JForm('myform'); $form->addFieldPath(JPATH_ADMINISTRATOR . '/components/com_cmc/models/fields'); $form->load($xml); $fieldsets = $form->getFieldsets(); $ret = '<div class="cbFieldsContentsTab">'; $ret .= '<div class="sectiontableentry1 cbft_predefined cbtt_input form-group cb_form_line clearfix">'; $ret .= '<label for="name" id="cblabname" class="control-label col-sm-3">' . JText::_('PLG_CMCCB_SUBSCRIPTION') . '</label>'; $ret .= '<div class="cb_field col-sm-9">'; $ret .= '<input type="checkbox" name="cmc[newsletter]" id="cmc_check_newsletter" value="1" /> '; $ret .= '<label for="cmc_check_newsletter" id="cmc_newsletter_lbl">' . JText::_('PLG_CMCCB_NEWSLETTER') . '</label>'; $ret .= "</div>\n"; $ret .= "</div>"; $ret .= "<div id='cmc_td_newsletter' style='' class=\"cbFieldsContentsTab\">\n"; $ret .= "<div id=\"cmc_newsletter\" style=\"display: block;\">\n"; // Render Content foreach ($fieldsets as $key => $value) { if ($key != "cmc") { $ret .= '<div class="sectiontableentry1 cbft_predefined cbtt_input form-group cb_form_line clearfix">'; $ret .= '<label class="col-sm-12">' . JText::_($value->label) . '</label>'; $ret .= '</div>'; $fields = $form->getFieldset($key); foreach ($fields as $field) { $ret .= '<div class="sectiontableentry1 cbft_predefined cbtt_input form-group cb_form_line clearfix">'; $ret .= '<div class="control-label col-sm-3">' . $field->label . '</div>'; $ret .= '<div class="cb_field col-sm-9">'; $ret .= $field->input; $ret .= '</div>'; $ret .= '</div>'; } } } $ret .= '<input type="hidden" name="cmc[listid]" id="cmc_listid" value="' . $listid . '" />'; // End open tables / divs $ret .= "</div>\n"; $ret .= "</div>\n"; return $ret; }
/** * Method to store parameters as LESS variables * * @access public * @return boolean True on success * @since 1.5 */ function storeLessConf($folder, $cfgname, $layout, $attribs) { // Load the XML file into a JForm object $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true)); $jform->load($this->_getLayout()->params); // params is the XML file contents as a string $layout_type = $layout == 'items' ? 'item' : 'category'; $tmpldir = JPath::clean(JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates'); $less_path = JPath::clean($tmpldir . DS . $folder . DS . 'less/include/config_auto_' . $layout_type . '.less'); //echo "<pre>".$less_path."<br/>"; $var_pfx = '@FC' . ($layout == 'items' ? 'I' : 'C') . '_'; // Get 'attribs' fieldset $fieldSets = $jform->getFieldsets($groupname = 'attribs'); // Iterate though the form elements and only use parameters with cssprep="less" $less_data = "/* This is created automatically, do NOT edit this manually! \nThis is used by " . $layout_type . " layout to save parameters as less variables. \nNOTE: Make sure that this is imported by 'config.less' \n to make a parameter be a LESS variable, edit parameter in " . $layout_type . ".xml and add cssprep=\"less\" \n created parameters will be like: @FC" . ($layout == 'items' ? 'I' : 'C') . "_parameter_name: value; */\n\n"; foreach ($jform->getFieldsets($groupname) as $fsname => $fieldSet) { foreach ($jform->getFieldset($fsname) as $field) { if ($field->getAttribute('cssprep') != 'less') { continue; } // Only add parameters meant to be less variables if (is_array($attribs[$field->fieldname])) { continue; } // array parameters not supported $v = trim($attribs[$field->fieldname]); if (!strlen($v)) { $v = $field->getAttribute('default'); if (!strlen($v)) { continue; } // do not add empty parameters } $less_data .= $var_pfx . $field->fieldname . ': ' . $v . ";\n"; } } file_put_contents($less_path, $less_data); return true; }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialize variables. $options = array(); $subForm = new JForm($this->name, array('control' => 'jform')); $xml = $this->element->children()->asFormattedXML(); $subForm->load($xml); /** * f3 hack */ $view = JRequest::getCmd('view'); $feModel = JModel::getInstance($view, 'FabrikFEModel'); $feModel->setId(JRequest::getInt('id')); $subForm->model = $feModel; /* * end */ $subForm->setFields($this->element->children()); //$this->id = $this->id .'_'.$this->form->repeatCounter; $str = array(); $modalid = $this->id . '_modal'; $str[] = '<div id="' . $modalid . '" style="display:none">'; $str[] = '<table class="adminlist">'; $str[] = '<thead><tr class="row0">'; $names = array(); foreach ($subForm->getFieldset($this->element->getAttribute('name') . '_modal') as $field) { $names[] = $field->element->getAttribute('name'); $str[] = '<th>' . $field->getLabel($field->name) . '</th>'; } $str[] = '<th></th>'; $str[] = '</tr></thead>'; $str[] = '<tbody><tr>'; foreach ($subForm->getFieldset($this->element->getAttribute('name') . '_modal') as $field) { $str[] = '<td>' . $field->getInput() . '</td>'; } $app = JFactory::getApplication(); $path = 'templates/' . $app->getTemplate() . '/images/menu/'; $str[] = '<td><div style="width:35px"><a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a>'; $str[] = '<a href="#" class="remove"><img src="' . $path . '/icon-16-delete.png" alt="' . JText::_('REMOVE') . '" /></div></a>'; $str[] = '</td>'; $str[] = '</tr></tbody>'; $str[] = '</table>'; $str[] = '</div>'; $form = implode("\n", $str); static $modalrepeat; if (!isset($modalrepeat)) { $modalrepeat = array(); } if (!array_key_exists($modalid, $modalrepeat)) { $modalrepeat[$modalid] = array(); } if (!array_key_exists($this->form->repeatCounter, $modalrepeat[$modalid])) { //if loaded as js template then we don't want to repeat this again. (fabrik) $names = json_encode($names); $modalrepeat[$modalid][$this->form->repeatCounter] = true; $script = str_replace("-", "", $modalid) . " = new FabrikModalRepeat('{$modalid}', {$names}, '{$this->id}');"; FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', true, $script); } $close = "function(c){" . $modalid . ".onClose(c);}"; $str[] = '<div class="button2-left">'; $str[] = ' <div class="blank">'; $str[] = "<a id=\"" . $modalid . "_button\" />" . JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'); $str[] = "<input type=\"hidden\" name=\"{$this->name}\" id=\"{$this->id}\" value=\"{$value}\" />"; return implode("\n", $str); }
/** * Updates the component configuration. * It first fetches the config.xml file & reads all entries there. * Then we load the current component parameters from the db * and merge them with the .xml file. This way we ensure that * the db has all the current values for each setting even if the * user doesn't edit his config. * * @return array - the parameters */ public function updateConfiguration() { $settings = JPATH_ADMINISTRATOR . '/components/' . $this->component . '/config.xml'; $json = array(); $form = new JForm('config'); $form->loadFile($settings, true, '/config'); $params = JComponentHelper::getParams($this->component)->toArray(); $fieldsets = $form->getFieldsets(); foreach ($fieldsets as $fieldsetkey => $fieldset) { $fields = $form->getFieldset($fieldsetkey); foreach ($fields as $fieldkey => $field) { // If we have a group for this field, use it! if ($field->group) { $json[$field->group][$field->fieldname] = $field->value; } else { $json[$field->fieldname] = $field->value; } } } $merged = array_merge($json, $params); $this->updateParams($merged); return $merged; }
function display($tpl = null) { global $mainframe; //initialise variables $document = JFactory::getDocument(); $db = JFactory::getDBO(); $me = JFactory::getUser(); $cid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($cid, array(0)); $edit = JRequest::getVar('edit', true); if (!$cid) { $edit = false; } if (FLEXI_J16GE) { $form = $this->get('Form'); $form->setValue('password', null); $form->setValue('password2', null); } $form_folder = FLEXI_J16GE ? 'forms' . DS : ''; JHTML::_('behavior.tooltip'); //add css to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } //add js function to overload the joomla submitform $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js'); $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js'); // load language file for com_users component JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR, null, true); //create the toolbar if ($edit) { JToolBarHelper::title(JText::_('FLEXI_EDIT_AUTHOR'), 'authoredit'); } else { JToolBarHelper::title(JText::_('FLEXI_ADD_AUTHOR'), 'authoradd'); } $ctrl = FLEXI_J16GE ? 'users.' : ''; JToolBarHelper::apply($ctrl . 'apply'); JToolBarHelper::save($ctrl . 'save'); JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); JToolBarHelper::cancel($ctrl . 'cancel'); JToolBarHelper::help('screen.users.edit'); $user = $edit ? JUser::getInstance($cid[0]) : JUser::getInstance(); $myuser = JFactory::getUser(); $acl = JFactory::getACL(); // Check for post data in the event that we are returning // from a unsuccessful attempt to save data $post = JRequest::get('post'); if ($post) { $user->bind($post); } if ($user->get('id')) { $query = 'SELECT *' . ' FROM #__contact_details' . ' WHERE user_id = ' . (int) $cid[0]; $db->setQuery($query); $contact = $db->loadObjectList(); } else { $contact = NULL; // Get the default group id for a new user $config = JComponentHelper::getParams('com_users'); $newGrp = $config->get('new_usertype'); if (!FLEXI_J16GE) { $user->set('gid', $acl->get_group_id($newGrp, null, 'ARO')); } else { $user->set('gid', $newGrp); } } // ************************************************** // Include needed files and add needed js / css files // ************************************************** // Load pane behavior jimport('joomla.html.pane'); // Load tooltips FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); JHTML::_('behavior.tooltip'); // Add css to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Add js function to overload the joomla submitform $document->addScript('components/com_flexicontent/assets/js/admin.js'); $document->addScript('components/com_flexicontent/assets/js/validate.js'); // ******************** // Initialise variables // ******************** $cparams = JComponentHelper::getParams('com_flexicontent'); if (!FLEXI_J16GE) { $pane = JPane::getInstance('sliders'); $tpane = JPane::getInstance('tabs', array('startOffset' => 2, 'allowAllClose' => true, 'opacityTransition' => true, 'duration' => 600)); } // ************************************************************************************************* // Get author extended data, basic (described in author.xml) and category (described incategory.xml) // ************************************************************************************************* JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables'); $author_user_id = (int) $cid[0]; $flexiauthor_extdata = JTable::getInstance('flexicontent_authors_ext', ''); $flexiauthor_extdata->load($author_user_id); //echo "<pre>"; print_r($flexiauthor_extdata); echo "</pre>"; exit; // *********************** // AUTHOR basic parameters // *********************** // Load the DB parameter values and the XML description from file, // NOTE: this is one step for J1.5 via a JParameter object, but in J1.6+ the use of XML file // in JParameter is deprecated, instead we will JForm to load XML description and thus be able to render it $auth_xml = JPATH_COMPONENT . DS . 'models' . DS . $form_folder . 'author.xml'; if (FLEXI_J16GE) { $params_authorbasic = new JRegistry($flexiauthor_extdata->author_basicparams); } else { $params_authorbasic = new JParameter($flexiauthor_extdata->author_basicparams, $auth_xml); } //echo "<pre>"; print_r($params_authorbasic); echo "</pre>"; exit; if (FLEXI_J16GE) { // Read XML file $xml_string = str_replace('name="params"', 'name="authorbasicparams"', file_get_contents($auth_xml)); // Load the form description from the XML string $jform_authorbasic = new JForm('com_flexicontent.author', array('control' => 'jform', 'load_data' => true)); $jform_authorbasic->load($xml_string, $isFile = false); // Set DB parameter values into the JForm object foreach ($jform_authorbasic->getFieldset() as $fsetname => $field) { $jform_authorbasic->setValue($field->fieldname, $group = 'authorbasicparams', $value = $params_authorbasic->get($field->fieldname)); } } // ************************** // AUTHOR category parameters // ************************** // Load the DB parameter values and the XML description from file, // NOTE: this is one step for J1.5 via a JParameter object, but in J1.6+ the use of XML file // in JParameter is deprecated, instead we will JForm to load XML description and thus be able to render it $cat_xml = JPATH_COMPONENT . DS . 'models' . DS . $form_folder . 'category.xml'; if (FLEXI_J16GE) { $params_authorcat = new JRegistry($flexiauthor_extdata->author_catparams); } else { $params_authorcat = new JParameter($flexiauthor_extdata->author_catparams, $cat_xml); } //echo "<pre>"; print_r($params_authorcat); echo "</pre>"; exit; if (FLEXI_J16GE) { // Read XML file $xml_string = str_replace('name="params"', 'name="authorcatparams"', file_get_contents($cat_xml)); // Load the form description from the XML string $jform_authorcat = new JForm('com_flexicontent.category', array('control' => 'jform', 'load_data' => true)); $jform_authorcat->load($xml_string, $isFile = false); // Set DB parameter values into the JForm object foreach ($jform_authorcat->getFieldset() as $fsetname => $field) { $jform_authorcat->setValue($field->fieldname, $group = 'authorcatparams', $value = $params_authorcat->get($field->fieldname)); } } // ********************************************************************************** // Get Templates and apply Template Parameters values into the form fields structures // ********************************************************************************** $themes = flexicontent_tmpl::getTemplates(); $tmpls = $themes->category; if (FLEXI_J16GE) { $params_author = new JRegistry($user->params); } foreach ($tmpls as $tmpl) { if (FLEXI_J16GE) { $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; // ... values applied at the template form file } else { $tmpl->params->loadINI($flexiauthor_extdata->author_catparams); } } //$lists = array(); //$javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; //$lists['imagelist'] = JHTML::_('list.images', 'image', $flexiauthor_extdata->image, $javascript, '/images/stories/' ); if (!FLEXI_J16GE) { $userObjectID = $acl->get_object_id('users', $user->get('id'), 'ARO'); $userGroups = $acl->get_object_groups($userObjectID, 'ARO'); $userGroupName = strtolower($acl->get_group_name($userGroups[0], 'ARO')); $userIsAdmin = $userGroupName == 'administrator'; $myObjectID = $acl->get_object_id('users', $myuser->get('id'), 'ARO'); $myGroups = $acl->get_object_groups($myObjectID, 'ARO'); $myGroupName = strtolower($acl->get_group_name($myGroups[0], 'ARO')); $myIsAdmin = $myGroupName == 'administrator'; } else { } // ensure user can't add/edit group higher than themselves /* NOTE : This check doesn't work commented out for the time being if ( is_array( $myGroups ) && count( $myGroups ) > 0 ) { $excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' ); } else { $excludeGroups = array(); } if ( in_array( $userGroups[0], $excludeGroups ) ) { echo 'not auth'; $mainframe->redirect( 'index.php?option=com_flexicontent&controller=users&view=users', JText::_('NOT_AUTH') ); } */ /* if ( $userGroupName == 'super administrator' ) { // super administrators can't change $lists['gid'] = '<input type="hidden" name="gid" value="'. $currentUser->gid .'" /><strong>'. JText::_( 'Super Administrator' ) .'</strong>'; } else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) { */ if (FLEXI_ACCESS) { // Create the list of all groups except public and registered $query = 'SELECT id AS value, name AS text, level, ordering' . ' FROM #__flexiaccess_groups' . ' WHERE level > 1' . ' ORDER BY ordering ASC'; $db->setQuery($query); $allgroups = $db->loadObjectList(); if ($user->get('id')) { // get all the groups from the user $query = 'SELECT group_id' . ' FROM #__flexiaccess_members' . ' WHERE member_id = ' . (int) $cid[0]; $db->setQuery($query); $usergroups = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray(); } else { $usergroups = array(); } $lists['access'] = JHTML::_('select.genericlist', $allgroups, 'groups[]', 'size="10" multiple="multiple"', 'value', 'text', $usergroups); } if (!FLEXI_J16GE) { if ($userIsAdmin && $myIsAdmin) { // administrators can't change each other $lists['gid'] = '<input type="hidden" name="gid" value="' . $user->get('gid') . '" /><strong>' . JText::_('Administrator') . '</strong>'; } else { $gtree = $acl->get_group_children_tree(null, 'USERS', false); // remove users 'above' me //$i = 0; //while ($i < count( $gtree )) { // if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) { // array_splice( $gtree, $i, 1 ); // } else { // $i++; // } //} $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid')); } } else { if (!$user->get('id')) { $new_usertype = JComponentHelper::getParams('com_users')->get('new_usertype'); $usergroups = $new_usertype ? array($new_usertype) : array(); } else { $ugrps_qtmpl = 'SELECT group_id FROM #__user_usergroup_map AS ug WHERE ug.user_id = %d'; $query = sprintf($ugrps_qtmpl, intval($user->get('id'))); $db->setQuery($query); $usergroups = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray(); if ($db->getErrorMsg()) { echo $db->getErrorMsg(); } } } // build the html select list $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block')); // build the html select list $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail')); $this->assignRef('me', $me); $this->assignRef('document', $document); $this->assignRef('lists', $lists); if (!FLEXI_J16GE) { $this->assignRef('pane', $pane); $this->assignRef('tpane', $tpane); } $this->assignRef('user', $user); $this->assignRef('usergroups', $usergroups); $this->assignRef('contact', $contact); $this->assignRef('cparams', $cparams); $this->assignRef('params_authorbasic', $params_authorbasic); $this->assignRef('params_authorcat', $params_authorcat); if (FLEXI_J16GE) { $this->assignRef('jform_authorbasic', $jform_authorbasic); $this->assignRef('jform_authorcat', $jform_authorcat); } $this->assignRef('tmpls', $tmpls); if (FLEXI_J16GE) { $this->assignRef('form', $form); $this->assignRef('params_author', $params_author); } parent::display($tpl); }
/** * 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 // @TODO: what and where??? $subForm->repeatCounter = (int) @$this->form->repeatCounter; $children = $this->element->children(); $subForm->setFields($children); // 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'; // Build a Table $head_row_str = array(); $body_row_str = array(); foreach ($subForm->getFieldset() as $field) { // Reset name to simple $field->name = (string) $field->element['name']; // Build heading $head_row_str[] = '<th>' . strip_tags($field->getLabel($field->name)); $head_row_str[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>'; $head_row_str[] = '</th>'; // Build body $body_row_str[] = '<td>' . $field->getInput() . '</td>'; } // Append buttons $head_row_str[] = '<th><div class="btn-group"><a href="#" class="add btn button btn-success"><span class="icon-plus"></span> </a></div></th>'; $body_row_str[] = '<td><div class="btn-group">'; $body_row_str[] = '<a class="add btn button btn-success"><span class="icon-plus"></span> </a>'; $body_row_str[] = '<a class="remove btn button btn-danger"><span class="icon-minus"></span> </a>'; $body_row_str[] = '</div></td>'; // Put all table parts together $table = '<table id="' . $this->id . '_table" class="adminlist ' . $this->element['class'] . ' table table-striped">' . '<thead><tr>' . implode("\n", $head_row_str) . '</tr></thead>' . '<tbody><tr>' . implode("\n", $body_row_str) . '</tr></tbody>' . '</table>'; // And finaly build a main container $str = array(); $str[] = '<div id="' . $this->id . '_container">'; // Add the table to modal $str[] = '<div id="' . $this->id . '_modal" class="modal hide">'; $str[] = $table; $str[] = '<div class="modal-footer">'; $str[] = '<button class="close-modal btn button btn-link">' . JText::_('JCANCEL') . '</button>'; $str[] = '<button class="save-modal-data btn button btn-primary">' . JText::_('JAPPLY') . '</button>'; $str[] = '</div>'; // Close modal container $str[] = '</div>'; // Close main container $str[] = '</div>'; // Button for display the modal window $select = (string) $this->element['select'] ? JText::_((string) $this->element['select']) : JText::_('JLIB_FORM_BUTTON_SELECT'); $icon = $this->element['icon'] ? '<span class="icon-' . $this->element['icon'] . '"></span> ' : ''; $str[] = '<button class="open-modal btn" id="' . $this->id . '_button" >' . $icon . $select . '</button>'; if (is_array($this->value)) { $this->value = array_shift($this->value); } // Script params $data = array(); $data[] = 'data-container="#' . $this->id . '_container"'; $data[] = 'data-modal-element="#' . $this->id . '_modal"'; $data[] = 'data-repeatable-element="table tbody tr"'; $data[] = 'data-bt-add="a.add"'; $data[] = 'data-bt-remove="a.remove"'; $data[] = 'data-bt-modal-open="#' . $this->id . '_button"'; $data[] = 'data-bt-modal-close="button.close-modal"'; $data[] = 'data-bt-modal-save-data="button.save-modal-data"'; $data[] = 'data-maximum="' . $maximum . '"'; $data[] = 'data-input="#' . $this->id . '"'; // Hidden input, where the main value is $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'); $str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" class="form-field-repeatable" ' . implode(' ', $data) . ' />'; // Add scripts JHtml::_('bootstrap.framework'); JHtml::_('script', 'system/repeatable.js', true, true); return implode("\n", $str); }
function render() { $config = JComponentHelper::getParams(WBADVERT_NAME); $form = new JForm('jform'); $form->loadFile(WBADVERT_PATH . 'config.xml', false, '//config'); $form->bind($config->toArray()); $fieldSets = $form->getFieldsets(); $html[] = '<div class="control-fieldset">'; foreach ($form->getFieldset('component') as $field) { $field->name = 'params[' . $field->name . ']'; $html[] = $field->renderField(); } $html[] = '</div>'; return implode(PHP_EOL, $html); }