protected function getMedia($imgName, $img = null, $i = null) { $link = (string) $this->element['img']['link']; if (!self::$mediaInitialised) { // Load the modal behavior script. JHtml::_('behavior.modal'); // Build the script. $script = array(); $script[] = ' function jInsertFieldValue(value, id) {'; $script[] = ' var old_id = document.id(id).value;'; $script[] = ' if (old_id != id) {'; $script[] = ' var elem = document.id(id)'; $script[] = ' elem.value = value;'; $script[] = ' elem.fireEvent("change");'; $script[] = ' }'; $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); self::$mediaInitialised = true; } // Initialize variables. $html = array(); $attr = ''; // The text field. $html[] = '<div class="wrapper">'; $html[] = '<div class="fltlft chain browseField">'; $html[] = ' <input class="input-medium" type="text" name="' . $this->name . '[' . $imgName . '][]' . '" id="' . $this->id . '_' . $imgName . $i . '"' . ' value="' . htmlspecialchars($img, ENT_COMPAT, 'UTF-8') . '"' . ' readonly="readonly" />'; $html[] = '</div>'; // The button. $html[] = '<a class="modal modalBtn hg_uikit_button" title="' . JText::_('JLIB_FORM_BUTTON_SELECT') . '" href="' . ($this->element['img']['readonly'] ? '' : ($link ? $link : 'index.php?option=com_media&view=images&tmpl=component&asset=&author=') . '&folder=&fieldid=' . $this->id . '_' . $imgName . $i) . '" rel="{handler: \'iframe\', size: {x: 800, y: 500}}">'; $html[] = JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>'; $html[] = '<a title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '" class="clearBtn hg_uikit_button" href="#" >' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '</a>'; $html[] = '</div>'; return implode("\n", $html); }
function getFields($name, $type = 'default', $values = null, $k = null) { $fieldID = str_replace(array('[', ']', 'jformparams'), '', $this->name); $itemName = $this->element['itemnname'] ? $this->element['itemnname'] : 'Item'; $dragging = $this->element['dragging']; $itemMinimized = $this->element['minimized']; // Get the field options. $options = $this->getOptions(); $output = '<td class="' . ($itemMinimized == 'yes' && $type == 'default' ? 'minimized' : '') . ' ' . ($type == 'template' ? 'fromtemplate' : '') . '" > <span class="itemcounter hg_uikit_button">' . ($k + 1) . '</span>' . ($dragging != 'no' ? '<span class="dragDynoItem' . $fieldID . ' drag-dynoitem hg_uikit_button" title="click and drag to rearrange">Drag to arrange</span>' : '') . '<span class="removeDynoItem' . $fieldID . ' remove-dynoitem hg_uikit_button" title="Remove ' . $itemName . '">Remove ' . $itemName . '</span> <span class="resizeDynoItem' . $fieldID . ' resize-dynoitem hg_uikit_button " title="Minimize Box">' . ($itemMinimized == 'yes' && $type == 'default' ? 'Maximize Box' : 'Minimize Box') . '</span> <hr class="underbuttons"> <div class="dynoitem">'; $dynotitle = isset($values['dynotitle']) ? htmlspecialchars($values['dynotitle'], ENT_COMPAT, 'UTF-8') : '» Box title (click to edit, only for backend usage)'; $output .= ' <div class="fld clearfix dynotitle"> <input type="text" name="' . $name . '[dynotitle][]" value="' . $dynotitle . '" title="Click to edit" /> </div>'; // Build the radio field output. foreach ($options as $i => $option) { switch ($option->type) { case "hidden": $output .= '<input type="hidden" name="' . $name . '[' . $option->name . '][]" value="' . $values[$option->name] . '" />'; break; case "media": $showPreview = $this->element['showpreview'] == 'no' ? false : true; $output .= ' <div class="fld clearfix mediaField"> ' . ($values[$option->name] && $showPreview ? '<div class="previewimg"><img src="' . JURI::root() . $values[$option->name] . '"/></div>' : '') . ' <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> ' . self::getMedia($option->name, $values[$option->name], $k) . ' </div>'; break; case "text": $output .= ' <div class="fld clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> <input type="text" name="' . $name . '[' . $option->name . '][]" value="' . ($values[$option->name] ? htmlspecialchars($values[$option->name], ENT_COMPAT, 'UTF-8') : htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8')) . '" class="' . $option->class . '" placeholder="' . $option->placeholder . '" /> </div>'; break; case "spacer": $output .= ' <div class="fld clearfix"> <label><strong>' . $option->label . '</strong></label> </div>'; break; case "textarea": $output .= ' <div class="fld clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> <textarea name="' . $name . '[' . $option->name . '][]" class="' . $option->class . '" rows="' . ($option->rows ? $option->rows : 3) . '" placeholder="' . $option->placeholder . '">' . ($values[$option->name] ? htmlspecialchars($values[$option->name], ENT_COMPAT, 'UTF-8') : htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8')) . '</textarea> </div>'; break; case "editor": if (!self::$editorInitialised) { $document = JFactory::getDocument(); $document->addStyleSheet(self::getPath() . 'trumbowyg/design/css/trumbowyg.css'); $document->addScript(self::getPath() . 'trumbowyg/trumbowyg.js'); $document->addScriptDeclaration(' jQuery(document).ready(function(){ txtar = jQuery(":not(.fromtemplate) .fld.editor textarea"); txtar.trumbowyg({ fixedFullWidth: true, resetCss: true, autogrow: true }); }); '); self::$editorInitialised = true; } $output .= ' <div class="fld editor clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> <div class="clearfix"></div> <textarea name="' . $name . '[' . $option->name . '][]" class=" ' . $option->class . '" placeholder="' . $option->placeholder . '" >' . ($values[$option->name] ? htmlspecialchars($values[$option->name], ENT_COMPAT, 'UTF-8') : htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8')) . '</textarea> </div>'; break; case "texturl": $target = $values[$option->name]['target'] ? $values[$option->name]['target'] : $option->target; $output .= ' <div class="fld clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> <input type="text" name="' . $name . '[' . $option->name . '][link][]" value="' . $values[$option->name]['link'] . '" class="input-medium" /> <select name="' . $name . '[' . $option->name . '][target][]" class="dropdown_target" > <option value="_self" ' . ($target == '_self' ? 'selected="selected"' : '') . '>Same Window</option> <option value="_blank" ' . ($target == '_blank' ? 'selected="selected"' : '') . '>New Window</option> <option value="lightbox_img" ' . ($target == 'lightbox_img' ? 'selected="selected"' : '') . '>Lightbox Image</option> <option value="lightbox_iframe" ' . ($target == 'lightbox_iframe' ? 'selected="selected"' : '') . '>Lightbox Iframe</option> </select> </div>'; break; case "video": include dirname(__FILE__) . '/_video.hgdyno.php'; break; case "select": $output .= ' <div class="fld clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> <select name="' . $name . '[' . $option->name . '][]" class="' . $option->class . '" >'; $lists = (array) json_decode($option->text); foreach ($lists as $list) { $selected = ''; if ($values[$option->name]) { if ($values[$option->name] == $list->value) { $selected = 'selected="selected"'; } } else { if ($option->value == $list->value) { $selected = 'selected="selected"'; } } $output .= '<option value="' . $list->value . '" ' . $selected . '>' . $list->name . '</option>'; } $output .= '</select> </div>'; break; case "fontlist": $output .= ' <div class="fld clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label> <select name="' . $name . '[' . $option->name . '][]" class="' . $option->class . '" >'; $fontlistjson = realpath(dirname(__FILE__) . '/..') . DS . 'fontlist.json'; if (JFile::exists($fontlistjson)) { $lists = (array) json_decode(file_get_contents($fontlistjson)); foreach ($lists as $list) { $selected = ''; if ($values[$option->name]) { if ($values[$option->name] == $list->value) { $selected = 'selected="selected"'; } } else { if ($option->value == $list->value) { $selected = 'selected="selected"'; } } $output .= '<option value="' . $list->value . '" ' . $selected . '>' . $list->name . '</option>'; } } $output .= '</select> </div>'; break; case "menuitem": $multiple = isset($option->multiple) ? $option->multiple : ''; $output .= ' <div class="fld clearfix menuitem"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label>' . "\n"; $selected = $values[$option->name] ? $values[$option->name] : 'mainmenu.1'; jimport('joomla.html.html.menu'); $options = JHTML::_('menu.menuitems'); $ilist = JHtml::_('select.genericlist', $options, $name . '[' . $option->name . '][' . $k . '][]', array('list.attr' => 'class="multiple_select" ' . ($multiple == 'yes' ? 'multiple="multiple" ' : ''), 'list.select' => $selected, 'list.translate' => false)); $output .= $ilist; $output .= '</div>'; break; case "sql": $output .= ' <div class="fld clearfix sqlfield"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label>' . "\n"; $selected = $values[$option->name] ? $values[$option->name] : ''; $sqloptions = array(); $key = $option->key_field ? (string) $option->key_field : 'value'; $value = $option->value_field ? (string) $option->value_field : (string) $option->name; $translate = false; $query = (string) $option->query; $db = JFactory::getDBO(); $db->setQuery($query); $items = $db->loadObjectlist(); if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); return $sqloptions; } $sqloptions[] = JHtml::_('select.option', 0, '-- No Article --'); if (!empty($items)) { foreach ($items as $item) { $sqloptions[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } $ilist = JHtml::_('select.genericlist', $sqloptions, $name . '[' . $option->name . '][]', array('list.attr' => 'class="' . $option->class . '"', 'list.select' => $selected, 'list.translate' => false)); $output .= $ilist; $output .= '</div>'; break; case "colorpicker": $class = ' class="' . trim('minicolors ' . $option->class) . '"'; // Including fallback code for HTML5 non supported browsers. JHtml::_('jquery.framework'); JHtml::_('script', 'system/html5fallback.js', false, true); JHtml::_('behavior.colorpicker'); $output .= ' <div class="fld colorpicker clearfix"> <label ' . ($option->description ? 'class="hasTip" title="' . $option->label . '::' . $option->description . '"' : '') . '>' . $option->label . '</label>'; $output .= '<input type="text" name="' . $name . '[' . $option->name . '][]" id="' . $this->id . '"' . ' value="' . ($values[$option->name] ? htmlspecialchars($values[$option->name], ENT_COMPAT, 'UTF-8') : htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8')) . '" placeholder="#rrggbb" ' . $class . ' data-position="right" data-control="hue" />'; $output .= '</div>'; break; } } $output .= ' </div> </td>'; return $output; }