function display($tpl = null) { require_once JPATH_COMPONENT . '/helpers/jcomments.php'; $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->liveSmiliesPath = str_replace('\\', '/', JCommentsHelper::getSmiliesPath()); $filter_state = $this->state->get('filter.state'); // Filter by published state $filter_state_options = array(); $filter_state_options[] = JHTML::_('select.option', '1', JText::_('A_FILTER_STATE_PUBLISHED')); $filter_state_options[] = JHTML::_('select.option', '0', JText::_('A_FILTER_STATE_UNPUBLISHED')); JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('jcomments.stylesheet'); if (version_compare(JVERSION, '3.0', 'ge')) { JHtml::_('bootstrap.tooltip'); JHtml::_('formbehavior.chosen', 'select'); JCommentsHelper::addSubmenu('smilies'); JHtmlSidebar::setAction('index.php?option=com_jcomments&view=smilies'); JHtmlSidebar::addFilter(JText::_('A_FILTER_STATE'), 'filter_state', JHtml::_('select.options', $filter_state_options, 'value', 'text', $filter_state, true)); $this->bootstrap = true; $this->sidebar = JHtmlSidebar::render(); } else { JCommentsHelper::addSubmenu('smilies'); array_unshift($filter_state_options, JHTML::_('select.option', '', JText::_('A_FILTER_STATE'))); $filter = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', 'onchange="Joomla.submitform();"', 'value', 'text', $filter_state); $this->assignRef('filter', $filter); } $this->addToolbar(); // Include the component HTML helpers. JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); parent::display($tpl); }
protected function getInput() { require_once JPATH_COMPONENT . '/helpers/jcomments.php'; $smiliesPath = JCommentsHelper::getSmiliesPath(); $livePath = str_replace('\\', '/', $smiliesPath); if (!self::$initialised) { $script = array(); $script[] = ' function JCommentsSmileyRefreshPreview(id) {'; $script[] = ' var value = document.id(id).value;'; $script[] = ' var img = document.id(id + "_preview");'; $script[] = ' if (img) {'; $script[] = ' if (value) {'; $script[] = ' img.src = "' . JURI::root() . $livePath . '" + value;'; $script[] = ' document.id(id + "_preview_empty").setStyle("display", "none");'; $script[] = ' document.id(id + "_preview_img").setStyle("display", "");'; $script[] = ' } else { '; $script[] = ' img.src = ""'; $script[] = ' document.id(id + "_preview_empty").setStyle("display", "");'; $script[] = ' document.id(id + "_preview_img").setStyle("display", "none");'; $script[] = ' } '; $script[] = ' } '; $script[] = ' }'; JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); self::$initialised = true; } $html = array(); $html[] = '<div class="input-prepend input-append">'; // Images list $listAttr = ''; $listAttr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $listAttr .= ' onchange="JCommentsSmileyRefreshPreview(this.getAttribute(\'id\'))"'; $html[] = JHtml::_('select.genericlist', (array) $this->getOptions($smiliesPath), $this->name, trim($listAttr), 'value', 'text', $this->value, $this->id); // Preview if ($this->value && file_exists(JPATH_ROOT . '/' . $smiliesPath . $this->value)) { $src = JURI::root() . $livePath . $this->value; } else { $src = ''; } $width = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 48; $height = isset($this->element['preview_height']) ? (int) $this->element['preview_height'] : 48; $style = ''; $style .= $width > 0 ? 'max-width:' . $width . 'px;' : ''; $style .= $height > 0 ? 'max-height:' . $height . 'px;' : ''; $imgAttr = array('id' => $this->id . '_preview', 'class' => 'media-preview', 'style' => $style); $img = JHtml::image($src, JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $imgAttr); $previewImg = '<div id="' . $this->id . '_preview_img"' . ($src ? '' : ' style="display:none"') . '>' . $img . '</div>'; $previewImgEmpty = '<div id="' . $this->id . '_preview_empty"' . ($src ? ' style="display:none"' : '') . '>' . JText::_('JLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>'; $html[] = '<div class="media-preview add-on">'; $html[] = ' ' . $previewImgEmpty; $html[] = ' ' . $previewImg; $html[] = '</div>'; $html[] = '</div>'; return implode("\n", $html); }