*
* @return string The HTML image code.
*/
- protected function _emoticonReplace($icon)
+ public function getIcon($icon)
{
return Horde::img(Horde_Themes::img('emoticons/' . $this->getIcons($icon) . '.png'), $icon, array('align' => 'middle', 'title' => $icon));
}
if ($var->type->hasHelper() && $browser->hasFeature('javascript')) {
$html .= '<br /><table cellspacing="0"><tr><td>';
- Horde::addScriptFile('open_html_helper.js', 'horde', array('direct' => false));
$imgId = $this->_genID($var->getVarName(), false) . 'ehelper';
+
+ Horde::addScriptFile('open_html_helper.js', 'horde');
+
if ($var->type->hasHelper('emoticons')) {
- $html .= Horde::link('#', _("Emoticons"), '', '', 'openHtmlHelper(\'emoticons\', \'' . $var->getVarName() . '\'); return false;') . Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '"') . '</a>';
+ $filter = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->getFilter('emoticons');
+ $icon_list = array();
+
+ foreach (array_flip($filter->getIcons()) as $icon => $string) {
+ $icon_list[] = array(
+ $filter->getIcon($icon),
+ $string
+ );
+ }
+
+ Horde::addInlineScript(array(
+ 'Horde_Html_Helper.iconlist = ' . Horde_Serialize::serialize($icon_list, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset())
+ ));
+
+ $html .= Horde::link('#', _("Emoticons"), '', '', 'Horde_Html_Helper.open(\'emoticons\', \'' . $var->getVarName() . '\'); return false;') . Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '"') . '</a>';
}
$html .= '</td></tr><tr><td><div ' . $this->_genID('htmlhelper_' . $var->getVarName()) . ' class="control"></div></td></tr></table>' . "\n";
}
if ($var->type->hasHelper() && $browser->hasFeature('javascript')) {
$html .= '<div class="form-html-helper">';
- Horde::addScriptFile('open_html_helper.js', 'horde', array('direct' => false));
+ Horde::addScriptFile('open_html_helper.js', 'horde');
$imgId = $var->getVarName() . 'ehelper';
if ($var->type->hasHelper('emoticons')) {
- $html .= Horde::link('#', _("Emoticons"), '', '', 'openHtmlHelper(\'emoticons\', \'' . $var->getVarName() . '\'); return false;')
+ $filter = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->getFilter('emoticons');
+ $icon_list = array();
+
+ foreach (array_flip($filter->getIcons()) as $icon => $string) {
+ $icon_list[] = array(
+ $filter->getIcon($icon),
+ $string
+ );
+ }
+
+ Horde::addInlineScript(array(
+ 'Horde_Html_Helper.iconlist = ' . Horde_Serialize::serialize($icon_list, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset())
+ ));
+
+ $html .= Horde::link('#', _("Emoticons"), '', '', 'Horde_Html_Helper.open(\'emoticons\', \'' . $var->getVarName() . '\'); return false;')
. Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '" align="middle"')
. '</a>'."\n";
}
*/
public function emoticonReplace($matches)
{
- return $matches[1] . $this->_emoticonReplace($matches[2]) . (empty($matches[3]) ? '' : $matches[3]);
+ return $matches[1] . $this->getIcon($matches[2]) . (empty($matches[3]) ? '' : $matches[3]);
}
/**
*
* @return string The replacement text.
*/
- protected function _emoticonReplace($icon)
+ public function getIcon($icon)
{
return $icon;
}
--- /dev/null
+/**
+ * Horde Html Helper Javascript Class
+ *
+ * Provides the javascript class insert html tags by clicking on icons.
+ *
+ * The helpers available:
+ * emoticons - for inserting emoticons strings
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Marko Djukic <marko@oblo.com>
+ * @package Horde
+ * @todo Add handling for font tags, tables, etc.
+ */
+
+var Horde_Html_Helper = {
+
+ iconlist: [],
+ targetElement: null,
+
+ open: function(type, target)
+ {
+ var cell, row, table, tbody,
+ lay = $('htmlhelper_' + target);
+ this.targetElement = $(target);
+
+ if (lay.getStyle('display') == 'block') {
+ lay.hide();
+ return false;
+ }
+
+ if (lay.firstChild) {
+ lay.removeChild(lay.firstChild);
+ }
+
+ tbody = new Element('TBODY');
+ table = new Element('TABLE', { border: 0, cellSpacing: 0 }).insert(tbody);
+
+ if (type == 'emoticons') {
+ row = new Element('TR');
+ cell = new Element('TD');
+
+ iconlist.each(function(i) {
+ var link =
+ new Element('A', { href: '#' }).insert(
+ new Element('IMG', { align: 'middle', border: 0, src: i[0] })
+ );
+ cell.appendChild(link);
+
+ link.observe('click', function(e) {
+ this.targetElement.setValue($F(this.targetElement) + i[1] + ' ');
+ e.stop();
+ }.bindAsEventListener(this));
+ });
+
+ row.insert(cell);
+ tbody.insert(row);
+ table.insert(tbody);
+ }
+
+ lay.insert(table).setStyle({ display: 'block' });
+ }
+};
+++ /dev/null
-/**
- * Horde Html Helper Javascript Class
- *
- * Provides the javascript class insert html tags by clicking on icons.
- *
- * The helpers available:
- * emoticons - for inserting emoticons strings
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Marko Djukic <marko@oblo.com>
- * @package Horde
- * @todo Add handling for font tags, tables, etc.
- */
-
-var targetElement;
-
-function openHtmlHelper(type, target)
-{
- var lay = document.getElementById('htmlhelper_' + target);
- targetElement = document.getElementById(target);
-
- if (lay.style.display == 'block') {
- lay.style.display = 'none';
- return false;
- }
-
- if (lay.firstChild) {
- lay.removeChild(lay.firstChild);
- }
-
- var table = document.createElement('TABLE');
- var tbody = document.createElement('TBODY');
- table.appendChild(tbody);
- table.cellSpacing = 0;
- table.border = 0;
-
- if (type == 'emoticons') {
- row = document.createElement('TR');
- cell = document.createElement('TD');
- <?php $filter = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->getFilter('emoticons'); $icons = array_flip($filter->getIcons()); foreach ($icons as $icon => $string): ?>
- link = document.createElement('A');
- link.href = '#';
- link.onclick = function() {
- targetElement.value = targetElement.value + '<?php echo $string ?>' + ' ';
- return false;
- }
- cell.appendChild(link);
- img = document.createElement('IMG')
- img.src = '<?php echo Horde_Themes::img('emoticons/' . $icon . '.png') ?>';
- img.align = 'middle';
- img.border = 0;
- link.appendChild(img);
- <?php endforeach; ?>
- row.appendChild(cell);
- tbody.appendChild(row);
- table.appendChild(tbody);
- }
-
- lay.appendChild(table);
- lay.style.display = 'block';
-}