/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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) { if (!$form instanceof JForm) { $this->_subject->setError('JERROR_NOT_A_FORM'); return false; } if (!$this->listId) { if ($this->debug) { $this->_subject->setError('No list selected in joomlamailer user plugin config!'); return false; } return; } // Check we are manipulating a valid form. $name = $form->getName(); if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) { return true; } // Add the registration fields to the form. JForm::addFormPath(__DIR__ . '/profiles'); $form->loadFile('profile', false); $mergeFields = $this->api->listMergeVars($this->listId); if (is_array($mergeFields) && count($mergeFields)) { $mergeFieldsConfig = $this->params->get('fields', array()); $elements = array(); foreach ($mergeFields as $field) { if (in_array($field['tag'], array('EMAIL', 'FNAME', 'LNAME', 'SIGNUPAPI')) || !in_array($field['tag'], $mergeFieldsConfig) || !$field['show'] || !$field['public']) { continue; } $attr = $options = ''; switch ($field['field_type']) { case 'url': $type = 'url'; break; case 'birthday': $type = 'birthday'; $attr = 'format="' . $this->params->get('dateFormat') . '"'; $field['helptext'] = $this->params->get('dateFormat'); break; case 'address': $type = 'address'; break; case 'phone': $type = 'tel'; break; case 'number': $type = 'number'; break; case 'radio': $type = 'radio'; if (isset($field['choices'])) { foreach ($field['choices'] as $choice) { $options .= '<option value="' . $choice . '">' . $choice . '</option>'; } } break; case 'dropdown': $type = 'list'; if (isset($field['choices'])) { foreach ($field['choices'] as $choice) { $options .= '<option value="' . $choice . '">' . $choice . '</option>'; } } $attr = 'multiple="false"'; break; default: $type = 'text'; } $elements[] = new SimpleXMLElement('<fieldset name="joomlamailer_merges"> <field name="' . $field['tag'] . '" type="' . $type . '" label="' . $field['name'] . '" description="' . $field['helptext'] . '" class="" size="" required="' . $field['req'] . '" ' . $attr . '>' . $options . ' </field> </fieldset>'); } if (count($elements)) { $form->setFields($elements, 'joomlamailer_merges'); } } $interests = $this->api->listInterestGroupings($this->listId); if (is_array($interests) && count($interests)) { $interestsConfig = $this->params->get('interests', array()); $elements = array(); foreach ($interests as $interest) { if (!in_array($interest['id'], $interestsConfig)) { continue; } $attr = ''; switch ($interest['form_field']) { case 'dropdown': $type = 'list'; break; case 'radio': $type = 'radio'; break; case 'checkboxes': $type = 'checkbox'; $attr = 'multiple="true"'; break; } $options = ''; foreach ($interest['groups'] as $group) { $options .= '<option value="' . $group['name'] . '">' . $group['name'] . '</option>'; } $elements[] = new SimpleXMLElement('<fieldset name="joomlamailer_groupings"> <field name="' . $interest['id'] . ($interest['form_field'] == 'checkbox' ? '][' : '') . '" type="' . $type . '" label="' . $interest['name'] . '" ' . $attr . '>' . $options . ' </field> </fieldset>'); } if (count($elements)) { $form->setFields($elements, 'joomlamailer_groupings'); } } return true; }