Location: PHPKode > projects > INTELIMEN - WYSIWYG HTML Browser Editor > editor/lib.editor.inc.php
<?
if(!$sys_path)$sys_path = dirname($GLOBALS[SCRIPT_FILENAME]);
$i=strlen($GLOBALS[DOCUMENT_ROOT]);
if($GLOBALS[DOCUMENT_ROOT][($i-1)]=='/') --$i;
$rel_path = substr($sys_path,$i);
$url_path = 'http://'.$GLOBALS[HTTP_HOST].$rel_path;
include("$sys_path/cfg.editor.inc.php");
include("$sys_path/lang.$lng.inc.php");
$upload_abs = $GLOBALS[DOCUMENT_ROOT].$upload_path;
$upload_url = 'http://'.$GLOBALS[HTTP_HOST].$upload_path;

$script = "<SCRIPT language='JavaScript'>\n".
          "   var cfg = new Array();\n".
          "   cfg.AvailableFontFamily = '{$cfg[AvailableFontFamily]}';\n".
          "   cfg.DefaultFontFamily   = '{$cfg[DefaultFontFamily]}';\n".
          "   cfg.AutoAddFontFamily   = {$cfg[AutoAddFontFamily]};\n".
          "   cfg.AvailableFontSize   = '{$cfg[AvailableFontSize]}';\n".
          "   cfg.DefaultFontSize     = '{$cfg[DefaultFontSize]}';\n".
          "   cfg.AutoAddFontSize     = {$cfg[AutoAddFontSize]};\n".

          "   var lng = '$lng';\n".
          "   var editable_source    = '{$editable_source}';\n".
          "   var PATH               = '{$rel_path}';\n".
          "   var EDITSOURCE         = '{$lang[edit_source]}';\n".
          "   var CLEAN_CODE         = '{$lang[clean_code]}';\n".
          "   var TOGGLE_DETAILS     = '{$lang[show_tags]}';\n".
          "   var TOGGLE_BORDERS     = '{$lang[show_borders]}';\n".
          "   var FINDTEXT           = '{$lang[search]}';\n".
          "   var ABOUT              = '{$lang[about]}';\n".
          "   var HELP               = '{$lang[help]}';\n".
          "   var EDITTABLE          = '{$lang[edit_table]}';\n".
          "   var INSERTCOL          = '{$lang[insert_col]}';\n".
          "   var DELETECOLS         = '{$lang[delete_cols]}';\n".
          "   var EDITROW            = '{$lang[edit_row]}';\n".
          "   var INSERTROW          = '{$lang[insert_row]}';\n".
          "   var DELETEROWS         = '{$lang[delete_rows]}';\n".
          "   var EDITCELL           = '{$lang[edit_cell]}';\n".
          "   var INSERTCELL         = '{$lang[insert_cell]}';\n".
          "   var DELETECELLS        = '{$lang[delete_cells]}';\n".
          "   var MERGECELLS         = '{$lang[merge_cells]}';\n".
          "   var SPLITCELL          = '{$lang[split_cell]}';\n".
          "</SCRIPT>\n".
          "<SCRIPT language='JavaScript' src='{$url_path}/lib.editor.inc.js' id='clientEventHandlersJS'></SCRIPT>\n";
switch ($mode) {
  case "link":
    // Conguration for MODAL LINK
    if(!$width)  $width    = "640";
    if(!$height) $height   = "480";
    if(!$tag)    $tag      = "";
    $html                  = "$script".
                             "<TEXTAREA style='position:absolute; visibility:hidden;' name='{$name}'>{$value}</TEXTAREA>\n".
                             "<A onclick='editor_DialogEditor($name,$height,$width);' $tag>$title</A>";
    // ---------------------------------------------------------------
  break;
  case "modal":
    // Conguration for MODAL WINDOW
    $width                 = "100%";
    $height                = "100%";
    $arguments             = "form.$name.value=window.dialogArguments;";
    $head                  = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>\n".
                             "<HTML>\n".
                             "  <HEAD>\n".
                             "    <TITLE>Editor Intelimen 1.0</TITLE>\n".
                             "  </HEAD>\n".
                             "  <BODY class='dlg' topmargin='0' leftmargin='0' scroll='no'>\n".
                             "    <CENTER>\n".
                             "      <FORM name='form'>";
    $footer                = "      </FORM>\n".
                             "  </BODY>\n".
                             "</HTML>";
    // ---------------------------------------------------------------
  case "textarea":
    // Conguration for TEXTAREA
    if(!$width)  $width    = "100%";
    if(!$height) $height   = "100%";
    if($editable_source) $source_tab =
                             "<TD valign='top'>".
                               "<IMG src='{$url_path}/icon.spacer.gif' width='20' height='1'>".
                               "<IMG src='{$url_path}/icon.normaltabon.gif' width='49' height='11' border='0' alt='' name='normaltab' onclick='editor_EditSource(false)'>".
                               "<IMG src='{$url_path}/icon.htmltaboff.gif'  width='41' height='11' border='0' alt='' name='htmltab'   onclick='editor_EditSource(true)'>".
                             "</TD>\n";
    $html                  = "$script".
                             "<LINK rel='stylesheet' type='text/css' href='styles.editor.inc.css'>\n".
                             "<TABLE class='editor' bgcolor='buttonface' cellpadding='0' cellspacing='0' width='{$width}' height='{$height}' ondragstart='window.event.returnValue=false;' onselectstart='window.event.returnValue=false;'>\n".
                               "<TR class='editor'>\n".
                                 "<TD class='editor' valign='bottom' colspan='2'>\n".
                                   "<IFRAME src='{$url_path}/pg.blank.php' id='editor_TableFrame' style='position:absolute; visibility:hidden; width:10; height:10; z-index:2;' vspace='0' hspace='0' marginheight='0' marginwidth='0' scrolling='no'></IFRAME>\n".
                                   "<TABLE cellspacing='2' cellpadding='0' border='0'>\n".
                                     "<TR valign='middle'>\n".
                                       "<TD width='10' background='{$url_path}/icon.toolbar.gif'><IMG src='{$url_path}/icon.spacer.gif' width='9' height='20'></TD>\n".
                                       "<TD>\n".
                                         "<SPAN id='editor_ToolBars' onmouseover='editor_MouseOver(window.event.srcElement);' onmousedown='editor_MouseDown(window.event.srcElement);' onmouseup='editor_MouseUp(window.event.srcElement);' onmouseout='editor_MouseOut(window.event.srcElement);' ondragstart='window.event.returnValue=false;' onselectstart='window.event.returnValue=false;'>\n".
                                           "<NOBR>".
                                             //"<IMG\n src='{$url_path}/icon.new.gif'          alt='{$lang['new']}'                  class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.open.gif'         alt='{$lang[open]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.save.gif'         alt='{$lang[save]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.cancel.gif'       alt='{$lang[cancel]}'                 class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             //"<IMG\n src='{$url_path}/icon.print.gif'        alt='{$lang['print']}'                class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.preview.gif'      alt='{$lang[preview]}'                class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.spell_check.gif'  alt='{$lang[spell_check]}'            class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             //"<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.cut.gif'          alt='{$lang[cut]}'                    class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5003'>".
                                             "<IMG\n src='{$url_path}/icon.copy.gif'         alt='{$lang[copy]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5002'>".
                                             "<IMG\n src='{$url_path}/icon.paste.gif'        alt='{$lang[paste]}'                  class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5032'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.undo.gif'         alt='{$lang[undo]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5049'>".
                                             "<IMG\n src='{$url_path}/icon.redo.gif'         alt='{$lang[redo]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5033'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.link.gif'         alt='{$lang[insert_hyperlink]}'       class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5016'>".
                                             "<IMG\n src='{$url_path}/icon.image.gif'        alt='{$lang[insert_image]}'           class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5017'>".
                                             "<IMG\n src='{$url_path}/icon.specialchar.gif'  alt='{$lang[insert_special_chars]}'   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6008'>".
                                             //"<IMG\n src='{$url_path}/icon.horizontal_rulehorizontal_rule.gif'           alt='{$lang[insert_horizontal_rule]}' class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             "<IMG\n src='{$url_path}/icon.instable.gif'     alt='{$lang[insert_table]}'           class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5022' name='editor_tbtn'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.clean_code.gif'   alt='{$lang[clean_code]}'             class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6013'>".
                                             "<IMG\n src='{$url_path}/icon.show_borders.gif' alt='{$lang[show_borders]}'           class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6012'>".
                                             "<IMG\n src='{$url_path}/icon.tags.gif'         alt='{$lang[show_tags]}'              class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6004'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.find.gif'         alt='{$lang[search]}'                 class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5008'>".
                                             "<IMG\n src='{$url_path}/icon.help.gif'         alt='{$lang[help]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='6003'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>\n".
                                             "<SELECT size='1' id='QuickFormat' style='width:120px;font:8pt Verdana;vertical-align:middle;' onchange='editor_quickformat();'></SELECT>\n".
                                             "<SELECT size='1' id='FontFamily'  style='width:120px;font:8pt Verdana;vertical-align:middle;' onchange='editor_FontFamily();'></SELECT>\n".
                                             "<SELECT size='1' id='FontSize'    style='width:40px; font:8pt Verdana;vertical-align:middle;' onchange='editor_FontSize();'></SELECT>&nbsp;<IMG\n".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.fgcolor.gif'     alt='{$lang[font]}'                    class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5009'>".
                                             "<IMG\n src='{$url_path}/icon.highlight.gif'   alt='{$lang[highlight]}'               class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5009'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.bold.gif'        alt='{$lang[bold]}'                    class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5000'>".
                                             "<IMG\n src='{$url_path}/icon.italic.gif'      alt='{$lang[italic]}'                  class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5023'>".
                                             "<IMG\n src='{$url_path}/icon.under.gif'       alt='{$lang[underline]}'               class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5048'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.left.gif'        alt='{$lang[left]}'                    class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5025'>".
                                             "<IMG\n src='{$url_path}/icon.center.gif'      alt='{$lang[center]}'                  class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5024'>".
                                             "<IMG\n src='{$url_path}/icon.right.gif'       alt='{$lang[right]}'                   class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5026'>".
                                             "<IMG\n src='{$url_path}/icon.justify.gif'     alt='{$lang[justify]}'                 class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5026'>".
                                             "<IMG\n src='{$url_path}/icon.space.gif' class='spc'><WBR>".
                                             "<IMG\n src='{$url_path}/icon.numbers.gif'     alt='{$lang[numbers]}'                 class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5030'>".
                                             "<IMG\n src='{$url_path}/icon.bullets.gif'     alt='{$lang[bullets]}'                 class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5051'>".
                                             "<IMG\n src='{$url_path}/icon.deindent.gif'    alt='{$lang[decrease_indent]}'         class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5031'>".
                                             "<IMG\n src='{$url_path}/icon.inindent.gif'    alt='{$lang[increase_indent]}'         class='flat' type='btn' onclick='editor_onCommand(null)' CommandId='5018'>".
                                           "</NOBR>\n".
                                         "</SPAN>\n".
                                       "</TD>\n".
                                     "</TR>\n".
                                   "</TABLE>\n".
                                 "</TD>\n".
                                 "<TD class='editor'>&nbsp;</TD>\n".
                               "</TR>\n".
                               "<TR class='editor'>\n".
                                 "<TD class='editor'>&nbsp;</TD>\n".
                                 "<TD class='editor' width='100%' height='100%'>\n".
                                   "<OBJECT classid='clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A' id='DHTMLSafe' width='100%' height='100%' style='z-index:1;' CODEBASE='http://myserver/DHTMLED.CAB#Version=6,1,0,nnnn'><PARAM NAME=ScrollbarAppearance VALUE=0></OBJECT>\n".
                                   "<SCRIPT LANGUAGE='javascript' FOR='DHTMLSafe' EVENT='ShowContextMenu'>return ShowMenu();</SCRIPT>\n".
                                   "<SCRIPT LANGUAGE='javascript' FOR='DHTMLSafe' EVENT='onkeypress'>return editor_onKeypress();</SCRIPT>\n".
                                   "<SCRIPT LANGUAGE='javascript' FOR='DHTMLSafe' EVENT='onmousedown'>return editor_onMouseDown();</SCRIPT>\n".
                                   "<SCRIPT LANGUAGE='javascript' FOR='DHTMLSafe' EVENT='onclick'>return editor_onClick();</SCRIPT>\n".
                                   "<SCRIPT LANGUAGE='javascript' FOR='DHTMLSafe' EVENT='DisplayChanged'>return editor_onDisplayChange();</SCRIPT>\n".
                                   "<SCRIPT LANGUAGE='javascript' FOR='DHTMLSafe' EVENT='ContextMenuAction(itemIndex)'>return editor_onMenuAction(itemIndex);</SCRIPT>\n".
                                 "</TD>\n".
                                 "<TD class='editor'>&nbsp;</TD>\n".
                               "</TR>\n".
                               "<TR class='editor'>\n".
                                 "<TD colspan='3' class='editor'>\n".
                                   "<TABLE cellspacing=0 cellpadding=0 border=0 width='100%'>\n".
                                     "<TR>\n".
                                       "$source_tab".
                                       "<TD align='right' valign='top'>".
                                         "<A title='{$lang[about]}' onClick='javascript:editor_DialogAbout()' style='font-family:Arial;font-size:10px;text-decoration:none;color:gray;'>".
                                           "Intelimen Web Solutions &nbsp;".
                                         "</A>".
                                       "</TD>\n".
                                     "</TR>\n".
                                   "</TABLE>\n".
                                 "</TD>\n".
                               "</TR>\n".
                             "</TABLE>\n".
                             "<TEXTAREA style='position:absolute; visibility:hidden;' id='editor_Field' name='{$name}'>\n".
                               "{$value}\n".
                             "</TEXTAREA>\n".
                             "<SCRIPT language='JavaScript'>\n".
                               "{$arguments}editor_Initialize();\n".
                             "</SCRIPT>\n";
    // ---------------------------------------------------------------
  break;
}
if($mode=='modal')echo $head.$html.$footer;

?>
Return current item: INTELIMEN - WYSIWYG HTML Browser Editor