JHTML::script('mootree.js');
JHTML::stylesheet('mootree.css');
if (isset($trees[$id]) && ($trees[$id])) {
return;
}
// Setup options object
$opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id.'_tree';
$opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders';
$opt['grid'] = (array_key_exists('grid', $params)) ? '\\'.$params['grid'] : '\\true';
$opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JURI::root(true).'/media/system/images/mootree.gif';
// Event handlers
$opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\'.$params['onExpand'] : null;
$opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\'.$params['onSelect'] : null;
$opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\'.$params['onClick'] : '\\function(node){ window.open(node.data.url, $chk(node.data.target) ? node.data.target : \'_self\'); }';
$options = JHTMLBehavior::_getJSObject($opt);
// Setup root node
$rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root';
$rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null;
$rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null;
$rt['open'] = (array_key_exists('open', $root)) ? '\\'.$root['open'] : '\\true';
$rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null;
$rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null;
$rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null;
$rootNode = JHTMLBehavior::_getJSObject($rt);
$treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : '';
$js = ' window.addEvent(\'domready\', function(){
tree'.$treeName.' = new MooTreeControl('.$options.','.$rootNode.');
tree'.$treeName.'.adopt(\''.$id.'\');})';
// Attach tooltips to document
$document =& JFactory::getDocument();
$document->addScriptDeclaration($js);
// Set static array
$trees[$id] = true;
return;
}
function calendar()
{
$document =& JFactory::getDocument();
JHTML::stylesheet('calendar-jos.css', 'media/system/css/', array(' title' => JText::_( 'green' ) ,' media' => 'all' ));
JHTML::script( 'calendar.js', 'media/system/js/' );
JHTML::script( 'calendar-setup.js', 'media/system/js/' );
$translation = JHTMLBehavior::_calendartranslation();
if($translation) {
$document->addScriptDeclaration($translation);
}
}
/**
* Keep session alive, for example, while editing or creating an article.
*/
function keepalive()
{
// Include mootools framework
JHTMLBehavior::mootools();
$config =& JFactory::getConfig();
$lifetime = ( $config->getValue('lifetime') * 60000 );
$refreshTime = ( $lifetime <= 60000 ) ? 30000 : $lifetime - 60000;
//refresh time is 1 minute less than the liftime assined in the configuration.php file
$document =& JFactory::getDocument();
$script = '';
$script .= 'function keepAlive( ) {';
$script .= ' var myAjax = new Ajax( "index.php", { method: "get" } ).request();';
$script .= '}';
$script .= ' window.addEvent("domready", function()';
$script .= '{ keepAlive.periodical('.$refreshTime.' ); }';
$script .= ');';
$document->addScriptDeclaration($script);
return;
}
/**
* Internal method to get a JavaScript object notation string from an array
*
* @param array $array The array to convert to JavaScript object notation
* @return string JavaScript object notation representation of the array
* @since 1.5
*/
function _getJSObject($array=array())
{
// Initialize variables
$object = '{';
// Iterate over array to build objects
foreach ((array)$array as $k => $v)
{
if (is_null($v)) {
continue;
}
if (!is_array($v) && !is_object($v)) {
$object .= ' '.$k.': ';
$object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'";
$object .= ',';
} else {
$object .= ' '.$k.': '.JHTMLBehavior::_getJSObject($v).',';
}
}
if (substr($object, -1) == ',') {
$object = substr($object, 0, -1);
}
$object .= '}';
return $object;
}
/**
* Internal method to translate the JavaScript Calendar
*
* @return string JavaScript that translates the object
* @since 1.5
*/
function _calendartranslation()
{
static $jsscript = 0;
if($jsscript == 0)
{
$return = 'Calendar._DN = new Array ("'.JText::_('Sunday').'", "'.JText::_('Monday').'", "'.JText::_('Tuesday').'", "'.JText::_('Wednesday').'", "'.JText::_('Thursday').'", "'.JText::_('Friday').'", "'.JText::_('Saturday').'", "'.JText::_('Sunday').'");Calendar._SDN = new Array ("'.JText::_('Sun').'", "'.JText::_('Mon').'", "'.JText::_('Tue').'", "'.JText::_('Wed').'", "'.JText::_('Thu').'", "'.JText::_('Fri').'", "'.JText::_('Sat').'", "'.JText::_('Sun').'"); Calendar._FD = 0; Calendar._MN = new Array ("'.JText::_('January').'", "'.JText::_('February').'", "'.JText::_('March').'", "'.JText::_('April').'", "'.JText::_('May').'", "'.JText::_('June').'", "'.JText::_('July').'", "'.JText::_('August').'", "'.JText::_('September').'", "'.JText::_('October').'", "'.JText::_('November').'", "'.JText::_('December').'"); Calendar._SMN = new Array ("'.JText::_('January_short').'", "'.JText::_('February_short').'", "'.JText::_('March_short').'", "'.JText::_('April_short').'", "'.JText::_('May_short').'", "'.JText::_('June_short').'", "'.JText::_('July_short').'", "'.JText::_('August_short').'", "'.JText::_('September_short').'", "'.JText::_('October_short').'", "'.JText::_('November_short').'", "'.JText::_('December_short').'");Calendar._TT = {};Calendar._TT["INFO"] = "'.JText::_('About the calendar').'";
Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" +
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";
Calendar._TT["PREV_YEAR"] = "'.JText::_('Prev. year (hold for menu)').'";Calendar._TT["PREV_MONTH"] = "'.JText::_('Prev. month (hold for menu)').'"; Calendar._TT["GO_TODAY"] = "'.JText::_('Go Today').'";Calendar._TT["NEXT_MONTH"] = "'.JText::_('Next month (hold for menu)').'";Calendar._TT["NEXT_YEAR"] = "'.JText::_('Next year (hold for menu)').'";Calendar._TT["SEL_DATE"] = "'.JText::_('Select date').'";Calendar._TT["DRAG_TO_MOVE"] = "'.JText::_('Drag to move').'";Calendar._TT["PART_TODAY"] = "'.JText::_('(Today)').'";Calendar._TT["DAY_FIRST"] = "'.JText::_('Display %s first').'";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "'.JText::_('Close').'";Calendar._TT["TODAY"] = "'.JText::_('Today').'";Calendar._TT["TIME_PART"] = "'.JText::_('(Shift-)Click or drag to change value').'";Calendar._TT["DEF_DATE_FORMAT"] = "'.JText::_('%Y-%m-%d').'"; Calendar._TT["TT_DATE_FORMAT"] = "'.JText::_('%a, %b %e').'";Calendar._TT["WK"] = "'.JText::_('wk').'";Calendar._TT["TIME"] = "'.JText::_('Time:').'";';
$jsscript = 1;
return $return;
} else {
return false;
}
}
}