Filter:   InfoImg
download Smarty.addons.php
Language: PHP
LOC: 456
Project Info
HPE
Server: SourceForge
Type: cvs
[Show Code]






[Show Code]
...ceForge\h\hpe\hpe\hpe1\HPE\
   .cvsignore
   clickerr.inc
   config.inc
   Config_File.class.php
   database.inc
   database.mysql.inc
   database.pear.inc
   FormChek.js
   HPE.inc
   HPEbase.inc
   HPEUsers.default.xml
   HPEUsers.guest.xml
   layout.js
   local.inc
   modules.inc
   ...andlers.addChannel.ftsc
   navcond.js
   newsaccess.inc
   newssource.inc
   newstools.js
   overlib.js
   overlib_mini.js
   pagemaker.inc
   pages.inc
   PHPClientSniffer.inc
   phpodp.inc
   publisher.inc
   services.inc
   sitelister.inc
   Smarty.addons.php
   Smarty.class.php
   Smarty_Compiler.class.php
   sourcetools.js
   thememaker.inc
   toparser.inc
   user.edit.inc
   user.inc
   xmlrpc.inc
   xmlrpcs.inc
   xmltree.inc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
<?php
/*
 * Project:     Smarty: the PHP compiled template engine
 * File:        Smarty.addons.php
 * Author:      Monte Ohrt <monte@ispi.net>
 *              Andrei Zmievski <andrei@php.net>
 * Version:     1.4.4
 * Copyright:   2001 ispi of Lincoln, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * You may contact the authors of Smarty by e-mail at:
 * monte@ispi.net
 * andrei@php.net
 *
 * Or, write to:
 * Monte Ohrt
 * CTO, ispi
 * 237 S. 70th suite 220
 * Lincoln, NE 68510
 *
 * The latest version of Smarty can be obtained from:
 * http://www.phpinsider.com
 *
 */


/*============================================*\
  Inserts handler
\*============================================*/

function _smarty_insert_handler($args, $caching, $delimiter)
{
    if ($caching) {
        $arg_string = serialize($args);
        return "$delimiter{insert_cache $arg_string}$delimiter";
    } else {
        $function_name = 'insert_'.$args['name'];
        return $function_name($args);
    }
}


/*============================================*\
  Modifiers
\*============================================*/

function _smarty_mod_handler()
{
    $args = func_get_args();
    list($func_name, $map_array) = array_splice($args, 0, 2);
    $var = $args[0];

    if ($map_array && is_array($var)) {
        foreach ($var as $key => $val) {
            $args[0] = $val;
            $var[$key] = call_user_func_array($func_name, $args);
        }
        return $var;
    } else {
        return call_user_func_array($func_name, $args);
    }
}


/*======================================================================*\
    Function: smarty_mod_escape
    Purpose:  Escape the string according to escapement type
\*======================================================================*/
$smarty_xml_escape_trans = array(
							'<' => '&lt;',
							'>' => '&gt;'
						   );
function smarty_mod_escape($string, $esc_type = 'html')
{
	global $smarty_xml_escape_trans;
    switch ($esc_type) {
        case 'html':
            return htmlspecialchars($string, ENT_QUOTES);

        case 'url':
            return urlencode($string);

        case 'js':
		case 'quotes':
        	// escape unescaped single quotes
            return preg_replace("%(?<!\\\\)'%", "\\'", $string);

        case 'nl':
            return nl2br($string);

		case 'xml':
			return preg_replace("%&(?!([#\w\d]+);)%", "&amp;", strtr($string, $smarty_xml_escape_trans));

		case 'rss':
			return preg_replace("%&(?!(nbsp;|iexcl;|cent;|pound;|curren;|yen;|brvbar;|sect;|uml;|copy;|ordf;|laquo;|not;|shy;|reg;|macr;|deg;|plusmn;|sup2;|sup3;|acute;|micro;|para;|middot;|cedil;|sup1;|ordm;|raquo;|frac14;|frac12;|frac34;|iquest;|Agrave;|Aacute;|Acirc;|Atilde;|Auml;|Aring;|AElig;|Ccedil;|Egrave;|Eacute;|Ecirc;|Euml;|Igrave;|Iacute;|Icirc;|Iuml;|ETH;|Ntilde;|Ograve;|Oacute;|Ocirc;|Otilde;|Ouml;|times;|Oslash;|Ugrave;|Uacute;|Ucirc;|Uuml;|Yacute;|THORN;|szlig;|agrave;|aacute;|acirc;|atilde;|auml;|aring;|aelig;|ccedil;|egrave;|eacute;|ecirc;|euml;|igrave;|iacute;|icirc;|iuml;|eth;|ntilde;|ograve;|oacute;|ocirc;|otilde;|ouml;|divide;|oslash;|ugrave;|uacute;|ucirc;|uuml;|yacute;|thorn;|yuml;|lt;|gt;|amp;|quot;|apos;|#[0-9]+;|#[a-fA-F0-9]+;|#o[0-7]+;))%", "&amp;", strtr($string, $smarty_xml_escape_trans));

        default:
            return $string;
    }
}


/*======================================================================*\
    Function: smarty_mod_truncate
    Purpose:  Truncate a string to a certain length if necessary,
              optionally splitting in the middle of a word, and
              appending the $etc string.
\*======================================================================*/
function smarty_mod_truncate($string, $length = 80, $etc = '...', $break_words = false)
{
    if ($length == 0)
        return '';

    if (strlen($string) > $length) {
        $length -= strlen($etc);
        $fragment = substr($string, 0, $length+1);
        if ($break_words)
            $fragment = substr($fragment, 0, -1);
        else
            $fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
        return $fragment.$etc;
    } else
        return $string;
}


/*======================================================================*\
    Function: smarty_mod_spacify
    Purpose:  add spaces between characters in a string
\*======================================================================*/
function smarty_mod_spacify($string, $spacify_char = ' ')
{
    return implode($spacify_char, preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
}

/*======================================================================*\
    Function: smarty_mod_date_format
    Purpose:  format datestamps via strftime
\*======================================================================*/
function smarty_mod_date_format($string, $format="%b %e, %Y")
{
    return strftime($format, smarty_make_timestamp($string));
}

/*======================================================================*\
    Function: smarty_make_timestamp
    Purpose:  used by other smarty functions to make a timestamp
              from a string of characters.
\*======================================================================*/
function smarty_make_timestamp($string)
{        
    $time = strtotime($string);
    if(is_numeric($time) && $time != -1)
        return $time;
    
    // is mysql timestamp format of YYYYMMDDHHMMSS?
    if(is_numeric($string) && strlen($string) == 14) {
        $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
               substr($string,4,2),substr($string,6,2),substr($string,0,4));
        
        return $time;
    }

    // can decipher, must be timestamp already?    
    return $string;
}

/*======================================================================*\
    Function: smarty_mod_string_format
    Purpose:  format strings via sprintf
\*======================================================================*/
function smarty_mod_string_format($string, $format)
{
    return sprintf($format, $string);
}

/*======================================================================*\
    Function: smarty_mod_replace
    Purpose:  simple search/replace
\*======================================================================*/
function smarty_mod_replace($string, $search, $replace)
{
    return str_replace($search, $replace, $string);
}

/*======================================================================*\
    Function: smarty_mod_regex_replace
    Purpose:  regular epxression search/replace
\*======================================================================*/
function smarty_mod_regex_replace($string, $search, $replace)
{
    return preg_replace($search, $replace, $string);
}

/*======================================================================*\
    Function: smarty_mod_strip_tags
    Purpose:  strip html tags from text
\*======================================================================*/
function smarty_mod_strip_tags($string, $replace_with_space = true)
{
    if ($replace_with_space)
        return preg_replace('!<[^>]*?>!', ' ', $string);
    else
        return strip_tags($string);
}

/*======================================================================*\
    Function: smarty_mod_default
    Purpose:  designate default text for empty variables
\*======================================================================*/
function smarty_mod_default($string, $default="")
{
    if(empty($string))
        return $default;
    else
        return $string;
}

/*======================================================================*\
    Function: smarty_func_assign
    Purpose:  assign a value to a template variable
\*======================================================================*/
function smarty_func_assign($args, &$smarty_obj)
{
	extract($args);

	if (empty($var)) {
    	$smarty_obj->_trigger_error_msg("assign: missing 'var' parameter");
    	return;
	}

	if (empty($value)) {
    	$smarty_obj->_trigger_error_msg("assign: missing 'value' parameter");
    	return;
	}

	$smarty_obj->assign($var, $value);
	return true;
}

/*============================================*\
  Custom tag functions
\*============================================*/

/*======================================================================*\
    Function: smarty_func_html_options
    Purpose:  Prints the list of <option> tags generated from
              the passed parameters
\*======================================================================*/
function smarty_func_html_options()
{
    $print_result = true;

    extract(func_get_arg(0));

    $html_result = "";

    settype($selected, 'array');
    if (isset($options)) {
        settype($options, 'array');
        foreach ($options as $key => $value) {
            $html_result .= "<option value=\"$key\"";
            if (in_array($key, $selected))
                $html_result .= " selected";
            $html_result .= ">$value</option>\n";
        }
    } else {
        settype($output, 'array');
        settype($values, 'array');
        for ($i = 0; $i < count($output); $i++) {
            /* By default, check value against $selected */
            $sel_check = $values[$i];
            $html_result .= "<option";
            if ($i < count($values))
                $html_result .= " value=\"".$values[$i]."\"";
            else
                $sel_check = $output[$i];       /* if more outputs than values, then
                                                   check output against $selected */        
            if (in_array($sel_check, $selected))
                $html_result .= " selected";
            $html_result .= ">".$output[$i]."</option>\n";
        }
    }

    if ($print_result)
        print $html_result;
    else
        return $html_result;
}


/*======================================================================*\
    Function: smarty_func_html_select_date
    Purpose:  Prints the dropdowns for date selection.
\*======================================================================*/
function smarty_func_html_select_date()
{
    /* Default values. */
    $prefix         = "Date_";
    $time           = time();
    $start_year     = strftime("%Y");
    $end_year       = $start_year;
    $display_days   = true;
    $display_months = true;
    $display_years  = true;
    $month_format   = "%B";
    $day_format     = "%02d";
    $year_as_text   = false;
    
    extract(func_get_arg(0));

    $time = smarty_make_timestamp($time);
        
    $html_result = "";

    if ($display_months) {
        $month_names = array();

        for ($i = 1; $i <= 12; $i++)
            $month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));

        $html_result .= '<select name="'.$prefix.'Month">'."\n";
        $html_result .= smarty_func_html_options(array('output'     => $month_names,
                                                       'values'     => range(1, 12),
                                                       'selected'   => strftime("%m", $time),
                                                       'print_result' => false));
        $html_result .= "</select>\n";
    }

    if ($display_days) {
        $days = range(1, 31);
        for ($i = 0; $i < count($days); $i++)
            $days[$i] = sprintf($day_format, $days[$i]);

        $html_result .= '<select name="'.$prefix.'Day">'."\n";
        $html_result .= smarty_func_html_options(array('output'     => $days,
                                                       'values'     => range(1, 31),
                                                       'selected'   => strftime("%d", $time),
                                                       'print_result' => false));
        $html_result .= "</select>\n";
    }

    if ($display_years) {
        if ($year_as_text) {
            $html_result .= '<input type="text" name="'.$prefix.'Year" value="'.strftime('%Y', $time).'" size="4" maxlength="4">';
        } else {
            $years = range($start_year, $end_year);

            $html_result .= '<select name="'.$prefix.'Year">'."\n";
            $html_result .= smarty_func_html_options(array('output' => $years,
                                                           'values' => $years,
                                                           'selected'   => strftime("%Y", $time),
                                                           'print_result' => false));
            $html_result .= "</select>\n";
        }
    }

    print $html_result;
}


/*======================================================================*\
    Function: smarty_func_html_select_time
    Purpose:  Prints the dropdowns for time selection
\*======================================================================*/
function smarty_func_html_select_time()
{
    /* Default values. */
    $prefix             = "Time_";
    $time               = time();
    $display_hours        = true;
    $display_minutes    = true;
    $display_seconds    = true;
    $display_meridian   = true;
    $use_24_hours        = true;
    $minute_interval    = 1;
    $second_interval    = 1;
    
    extract(func_get_arg(0));
    
    $time = smarty_make_timestamp($time);

    $html_result = '';
    
    if ($display_hours) {
        $hours       = $use_24_hours ? range(0, 23) : range(1, 12);
        $hour_fmt = $use_24_hours ? '%H' : '%I';
        for ($i = 0; $i < count($hours); $i++)
            $hours[$i] = sprintf('%02d', $hours[$i]);
        $html_result .= '<select name="'.$prefix.'Hour">'."\n";
        $html_result .= smarty_func_html_options(array('output'          => $hours,
                                                       'values'          => $hours,
                                                       'selected'      => strftime($hour_fmt, $time),
                                                       'print_result' => false));
        $html_result .= "</select>\n";
    }
    
    if ($display_minutes) {
        $all_minutes = range(0, 59);
        for ($i = 0; $i < count($all_minutes); $i+= $minute_interval)
            $minutes[] = sprintf('%02d', $all_minutes[$i]);
        $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
        $html_result .= '<select name="'.$prefix.'Minute">'."\n";
        $html_result .= smarty_func_html_options(array('output'          => $minutes,
                                                       'values'          => $minutes,
                                                       'selected'      => $selected,
                                                       'print_result' => false));
        $html_result .= "</select>\n";
    }
    
    if ($display_seconds) {
        $all_seconds = range(0, 59);
        for ($i = 0; $i < count($all_seconds); $i+= $second_interval)
            $seconds[] = sprintf('%02d', $all_seconds[$i]);
        $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
        $html_result .= '<select name="'.$prefix.'Second">'."\n";
        $html_result .= smarty_func_html_options(array('output'          => $seconds,
                                                       'values'          => $seconds,
                                                       'selected'      => $selected,
                                                       'print_result' => false));
        $html_result .= "</select>\n";
    }
    
    if ($display_meridian && !$use_24_hours) {
        $html_result .= '<select name="'.$prefix.'Meridian">'."\n";
        $html_result .= smarty_func_html_options(array('output'          => array('AM', 'PM'),
                                                       'values'          => array('am', 'pm'),
                                                       'selected'      => strtolower(strftime('%p', $time)),
                                                       'print_result' => false));
        $html_result .= "</select>\n";
    }
    
    print $html_result;
}


/*======================================================================*\
    Function: smarty_func_math
    Purpose:  allow math computations in template
\*======================================================================*/
function smarty_func_math($args, $smarty_obj) {
        // be sure equation parameter is present
        if(empty($args["equation"])) {
            $smarty_obj->_trigger_error_msg("math: missing equation parameter");
            return;
        }
                
        $equation = $args["equation"];
        
        // make sure parenthesis are balanced    
        if(substr_count($equation,"(") != substr_count($equation,")")) {
            $smarty_obj->_trigger_error_msg("math: unbalanced parenthesis");
            return;
        }
                        
        // match all vars in equation, make sure all are passed
        preg_match_all("![a-zA-Z][a-zA-Z0-9]*!",$equation,$match);
        
        foreach($match[0] as $curr_var) {
            if(!in_array($curr_var,array_keys($args)) &&
                    !in_array($curr_var,
                              array('int','abs','ceil','cos','exp','floor','log','log10',
                                    'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'))) {
                $smarty_obj->_trigger_error_msg("math: parameter $curr_var not passed as argument");
                return;
            }       
        }
       
        foreach($args as $key => $val) {
            if($key != "equation" && $key != "format") {
                // make sure value is not empty
                if(strlen($val)==0) {
                    $smarty_obj->_trigger_error_msg("math: parameter $key is empty");
                    return;                                        
                }
                if(!is_numeric($val)) {
                    $smarty_obj->_trigger_error_msg("math: parameter $key: is not numeric");
                    return;                    
                }
                $equation = preg_replace("/\b$key\b/",$val,$equation);       
            }
        }
               
    eval("\$smarty_math_result = ".$equation.";");

    if(empty($args["format"]))
        echo $smarty_math_result;
    else
        printf($args["format"],$smarty_math_result);
}

/*======================================================================*\
    Function: smarty_func_fetch
    Purpose:  fetch file, web or ftp data and display results
\*======================================================================*/
function smarty_func_fetch($args, &$smarty_obj) {
    extract($args);
	
    if (empty($file)) {
        $smarty_obj->_trigger_error_msg("parameter 'file' cannot be empty");
        return;                    
    }

	if ($smarty_obj->security && !preg_match('!^(http|ftp)://!', $file)) {
		// make sure fetched file comes from secure directory
		foreach ($smarty_obj->secure_dir as $curr_dir) {
			if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) {
				$resource_is_secure = true;
				break;
			}
		}
		if (!$resource_is_secure) {
        	$smarty_obj->_trigger_error_msg("(secure mode) fetching '$file' is not allowed");
        	return;
		}				
	}

    readfile($file);
}

/*======================================================================*\
    Function: smarty_mod_count_characters
    Purpose:  count the number of characters in a text
\*======================================================================*/
function smarty_mod_count_characters($string,$include_spaces=false) {
    
    if($include_spaces)
       return(strlen($string));
            
    return preg_match_all("/[^\s]/",$string,$match);
}

/*======================================================================*\
    Function: smarty_mod_count_words
    Purpose:  count the number of words in a text
\*======================================================================*/
function smarty_mod_count_words($string) {
    
    // split text by ' ',\r,\n,\f,\t
    $split_array = preg_split("/\s+/",$string);
    // count matches that contain alphanumerics
    $word_count = preg_grep("/[a-zA-Z0-9]/",$split_array);
    
    return count($word_count);
}

/*======================================================================*\
    Function: smarty_mod_count_sentences
    Purpose:  count the number of sentences in a text
\*======================================================================*/
function smarty_mod_count_sentences($string,$include_spaces=false) {
    
    // find periods with a word before but not after.    
    return preg_match_all("/[^\s]\.(?!\w)/",$string,$match);
    
}

/*======================================================================*\
    Function: smarty_mod_count_paragraphs
    Purpose:  count the number of sentences in a text
\*======================================================================*/
function smarty_mod_count_paragraphs($string,$include_spaces=false) {
    
    // count \r or \n characters
    return count( preg_split("/[\r\n]+/",$string) );
}

/*======================================================================*\
    Function: smarty_func_counter
    Purpose:  print out a counter value
\*======================================================================*/
function smarty_func_counter() {
    
	static $count = array();
	static $skipval = array();
	static $dir = array();
	static $id = "default";
	static $printval = array();
	
    extract(func_get_arg(0));

	if(!isset($id))
		$id = "default";
	
	if(isset($start))
		$count[$id] = $start;	
	elseif(!isset($count[$id]))
		$count[$id]=1;

	if(!isset($print))
		$printval[$id]=true;
	else
		$printval[$id]=$print;

	if($printval[$id])
		echo $count[$id];
	
	if(isset($skip))
		$skipval[$id] = $skip;
	elseif(!isset($skipval))
		$skipval[$id] = 1;
	
	if(isset($direction))
		$dir[$id] = $direction;
	elseif(!isset($dir[$id]))
		$dir[$id] = "up";
	
	if($dir[$id] == "down")
		$count[$id] -= $skipval[$id];
	else
		$count[$id] += $skipval[$id];

    return true;
}

/*======================================================================*\
    Function: smarty_func_assign_debug_info
    Purpose:  assign debug info to the template
\*======================================================================*/
function smarty_func_assign_debug_info($args, &$smarty_obj) {
	$assigned_vars = $smarty_obj->_tpl_vars;
	ksort($assigned_vars);
	$config_vars = $smarty_obj->_config[0];
	ksort($config_vars);
	$included_templates = $smarty_obj->_included_tpls;
	$smarty_obj->assign("_debug_keys",array_keys($assigned_vars));
	$smarty_obj->assign("_debug_vals",array_values($assigned_vars));
	$smarty_obj->assign("_debug_config_keys",array_keys($config_vars));
	$smarty_obj->assign("_debug_config_vals",array_values($config_vars));
	$smarty_obj->assign("_debug_tpls",$included_templates);
	return true;
}

/*======================================================================*\
    Function: smarty_func_overlib_init
    Purpose:  initialize use of overlib
\*======================================================================*/
function smarty_func_overlib_init($args, &$smarty_obj) {
	// be sure to place overlib.js where Smarty can locate it.
	// overlib.js came with the distribution of Smarty.
	readfile(SMARTY_DIR."overlib.js",1);	
	return;
}

/*======================================================================*\
    Function: smarty_func_overlib
    Purpose:  make text pop up in windows via overlib
\*======================================================================*/
function smarty_func_overlib($args, &$smarty_obj) {
	extract($args);
	if (empty($text)) {
        $smarty_obj->_trigger_error_msg("overlib: attribute 'text' required");
		return false;
	}
	
	if(empty($trigger)) { $trigger = "onMouseOver"; }
	
	echo $trigger.'="return overlib(\''.str_replace("'","\'",$text).'\'';
	if($sticky) { echo ",STICKY"; }
	if(!empty($caption)) { echo ",CAPTION,'".str_replace("'","\'",$caption)."'"; }
	if(!empty($fgcolor)) { echo ",FGCOLOR,'$fgcolor'"; }
	if(!empty($bgcolor)) { echo ",BGCOLOR,'$bgcolor'"; }
	if(!empty($textcolor)) { echo ",TEXTCOLOR,'$textcolor'"; }
	if(!empty($capcolor)) { echo ",CAPCOLOR,'$capcolor'"; }
	if(!empty($closecolor)) { echo ",CLOSECOLOR,'$closecolor'"; }
	if(!empty($textfont)) { echo ",TEXTFONT,'$textfont'"; }
	if(!empty($captionfont)) { echo ",CAPTIONFONT,'$captionfont'"; }
	if(!empty($closefont)) { echo ",CLOSEFONT,'$closefont'"; }
	if(!empty($textsize)) { echo ",TEXTSIZE,'$textsize'"; }
	if(!empty($captionsize)) { echo ",CAPTIONSIZE,'$captionsize'"; }
	if(!empty($closesize)) { echo ",CLOSESIZE,'$closesize'"; }
	if(!empty($width)) { echo ",WIDTH,'$width'"; }
	if(!empty($height)) { echo ",HEIGHT,'$height'"; }
	if(!empty($left)) { echo ",LEFT"; }
	if(!empty($right)) { echo ",RIGHT"; }
	if(!empty($center)) { echo ",CENTER"; }
	if(!empty($above)) { echo ",ABOVE"; }
	if(!empty($below)) { echo ",BELOW"; }
	if(!empty($border)) { echo ",BORDER,'$border'"; }
	if(!empty($offsetx)) { echo ",OFFSETX,'$offsetx'"; }
	if(!empty($offsety)) { echo ",OFFSETY,'$offsetxy'"; }
	if(!empty($fgbackground)) { echo ",FGBACKGROUND,'$fgbackground'"; }
	if(!empty($bgbackground)) { echo ",BGBACKGROUND,'$bgbackground'"; }
	if(!empty($closetext)) { echo ",CLOSETEXT,'".str_replace("'","\'",$closetext)."'"; }
	if(!empty($noclose)) { echo ",NOCLOSE"; }
	if(!empty($status)) { echo ",STATUS,'".str_replace("'","\'",$status)."'"; }
	if(!empty($autostatus)) { echo ",AUTOSTATUS"; }
	if(!empty($autostatuscap)) { echo ",AUTOSTATUSCAP"; }
	if(!empty($inarray)) { echo ",INARRAY,'$inarray'"; }
	if(!empty($caparray)) { echo ",CAPARRAY,'$caparray'"; }
	if(!empty($capicaon)) { echo ",CAPICON,'$capicon'"; }
	if(!empty($snapx)) { echo ",SNAPX,'$snapx'"; }
	if(!empty($snapy)) { echo ",SNAPY,'$snapy'"; }
	if(!empty($fixx)) { echo ",FIXX,'$fixx'"; }
	if(!empty($fixy)) { echo ",FIXY,'$fixy'"; }
	if(!empty($background)) { echo ",BACKGROUND,'$background'"; }
	if(!empty($padx)) { echo ",PADX,'$padx'"; }
	if(!empty($pady)) { echo ",PADY,'$pady'"; }
	if(!empty($fullhtml)) { echo ",FULLHTML"; }
	if(!empty($frame)) { echo ",FRAME,'$frame'"; }
	if(!empty($timeout)) { echo ",TIMEOUT,'$timeout'"; }
	if(!empty($function)) { echo ",FUNCTION,'$function'"; }
	if(!empty($delay)) { echo ",DELAY,'$delay'"; }
	if(!empty($hauto)) { echo ",HAUTO"; }
	if(!empty($vauto)) { echo ",VAUTO"; }
	echo ');" onMouseOut="nd();"';	
	return;
}

/* vim: set expandtab: */

?>