<?php function Smarty_function_fck ($params, & $smarty) { if (!isset ($params [' InstanceName ']) | | empty ($params [' InstanceName ']) { $smarty->trigger_error (' fckeditor:required parameter ' instancename ' missing '); } static $base _arguments = Array (); static $config _arguments = Array (); if (!count ($base _arguments)) $init = TRUE; Else $init = FALSE; if (Isset ($params [' BasePath ']) { $base _arguments[' basepath '] = $params [' BasePath ']; } else if (empty ($base _arguments[' BasePath ')) { This sets the default FCK directory, relative to the directory of the program to use FCK $base _arguments[' basepath '] = '. /plugins/fckeditor/'; } $base _arguments[' instancename '] = $params [' InstanceName ']; if (Isset ($params [' value ']) $base _arguments[' value ' = $params [' value ']; if (Isset ($params [' width ']) $base _arguments[' width ' = $params [' width ']; if (Isset ($params [' height ']) $base _arguments[' height ' = $params [' height ']; if (Isset ($params [' ToolbarSet ']) $base _arguments[' toolbarset '] = $params [' ToolbarSet ']; if (Isset ($params [' Checkbrowser ']) $base _arguments[' checkbrowser '] = $params [' Checkbrowser ']; if (Isset ($params [' displayerrors ']) $base _arguments[' displayerrors '] = $params [' displayerrors ']; Use all other parameters for the config array (replace if needed) $other _arguments = Array_diff_assoc ($params, $base _arguments); $config _arguments = Array_merge ($config _arguments, $other _arguments); $out = "; if ($init) { $out. = ' <script type= ' text/javascript ' src= '. $base _arguments[' BasePath ']. ' Fckeditor.js ' ></script> '; } $out. = "N<script type=" Text/javascript ">n"; $out. = "var ofckeditor = new FCKeditor ('". $base _arguments[' InstanceName ']. "'); n"; foreach ($base _arguments as $key => $value) { if (!is_bool ($value)) { Fix newlines, JavaScript cannot handle multiple line strings very. $value = ' "'. Preg_replace ("/[rn]+/", ' "+ $0″ ', addslashes ($value)). '" } $out. = "Ofckeditor. $key = $value;"; } foreach ($config _arguments as $key => $value) { if (!is_bool ($value)) { $value = ' "'. Preg_replace ("/[rn]+/", ' "+ $0″ ', addslashes ($value)). '" } $out. = "ofckeditor.config[" $key "] = $value;"; } $out. = "Nofckeditor.create (); n"; $out. = "</script>n"; return $out; } ?> |