source: branches/unified_backend/ddt/ddt.php @ 546

Last change on this file since 546 was 172, checked in by yermol, 15 years ago

htmlarea.js

. added workaround fix for NASTY FIREFOX BUG resulting in the infamous

uneditable area problem (exception on designMode="on" issue -
refer to bug:


https://bugzilla.mozilla.org/show_bug.cgi?id=207842


and this thread:


http://xinha.gogo.co.nz/punbb/viewtopic.php?id=229


. trailing <BR>'s are no longer stripped out of the document. This

was wreaking havoc on EnterParagraphs?. It's not clear whether or not
this is going to have unanticipated side-effects.

plugins/EnterParagraphs/enter-paragraphs.js

NOT FULLY FUNCTIONAL YET - DOESN'T HANDLE ALL CASES CORRECTLY,
but it's much better than it was I think.

. largely reworked.
. changed obfuscated variables names to make it more readable.
. expanded out nested (x ? y : z) constructs to make it more readable.
. added alot of comments.
. fixed a serious bug in findEachNodeUnder() that was not correctly

handling beginning and end node conditions.

. fixed design flaw that selected a non-existent insertion point for

placing the cursor.

. fixed several exceptions.
. now correctly handles lists by passing the back back to the Gecko

engine if we are in a list with the exception of being at the
first position in the first element in which case we insert
a paragraph before the list and move the cursor back to the first
item on the list.

File size: 5.5 KB
Line 
1<?php
2
3// [NOSTRIP
4// -----------------------------------------------------------------
5// Copyright (C) DTLink, LLC.
6// http://www.dtlink.com and http://www.formvista.com
7// -----------------------------------------------------------------
8// This code is distributed under the the sames terms as Xinha
9// itself. (HTMLArea license based on the BSD license)
10//
11// Please read license.txt in this package for details.
12//
13// All software distributed under the Licenses is provided strictly on
14// an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
15// IMPLIED, AND DTLINK LLC HEREBY DISCLAIMS ALL SUCH
16// WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
17// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT,
18// OR NON-INFRINGEMENT.
19// ------------------------------------------------------------------
20// NOSTRIP]
21
22/**
23* Debug and Error Message functions.
24*
25* These functions implement a procedural version of the formVista DDT debug
26* message system.
27*
28* @package formVista
29* @subpackage lib
30* @copyright DTLink, LLC 2005
31* @author Yermo Lamers
32* @see http://www.formvista.com/contact.html
33*/
34
35// REVISION HISTORY:
36//
37// 26 Jan 2001 YmL:
38//              . initial revision
39//
40// 2002-06-19 YmL:
41//              . added logging debug and error messages to a file.
42//
43// 2004-02-06 YmL:
44//      .       added a newline to generated messages.
45//
46// 2005-01-09 YmL:
47//      .       now checks global $fvDEBUG[ "logfile" ] setting for
48//              logfile to output to.
49//      .       dumping to file has not been combined into a dumpmsg
50//              method.
51//
52// 2005-02-25 YmL:
53//      .       added _error() support for cmdLine programs.
54//
55// 2005-03-20 YmL:
56//      .       changed license for this file to HTMLArea from RPL.
57//      .       quick hack to repurpose for Xinha.
58//
59// -------------------------------------------------------
60
61/**
62* dumps message to stdout or log file depending upon global.
63*
64* checks $fvDEBUG["logfile"] global for name of file to dump
65* messages to. Opens the file once.
66*/
67
68function dumpmsg( $msgline )
69{
70
71global $fvDEBUG;
72
73if ( @$fvDEBUG[ "logfile" ] != NULL )
74        {
75
76        // only open the file once and store the handle in the global
77        // fvDEBUG array .. for now.
78
79        if ( @$fvDEBUG[ "logfile_fp" ] == NULL )
80                {
81
82                // we clear out the debug file on each run.
83
84                if (( $fvDEBUG[ "logfile_fp" ] = fopen( $fvDEBUG[ "logfile" ], "a" )) == NULL )
85                        {
86                        die( "ddt(): unable to open debug log" );
87                        return  false ;
88                        }
89                }
90
91        fwrite( $fvDEBUG[ "logfile_fp" ], $msgline );
92        fflush( $fvDEBUG[ "logfile_fp" ] );
93
94        }
95else
96        {
97        echo $msgline;
98        }
99
100}       // end of dumpmsg.
101
102/**
103* displays a formatted debugging message.
104*
105* If ddtOn() was called, outputs a formatted debugging message.
106*
107* @param string $file filename, usually __FILE__
108* @param string $line line number in file, usually __LINE__
109* @param string $msg debugging message to display
110*/
111
112function _ddt( $file, $line, $msg )
113{
114
115global $_DDT;
116global $_DDT_DEBUG_LOG;
117global $_DDT_CMDLINE;
118
119$basename = basename( $file );
120
121if ( @$_DDT == "yes" )
122        {
123
124        if ( @$_DDT_CMDLINE == "yes" )
125                {
126                dumpmsg( basename( $file ) . ":$line: $msg \n" );
127                flush();
128
129                }
130        else
131                {
132                dumpmsg( "<p>$basename:$line: $msg</p>\n" );
133                }
134        }
135
136}       // end of _ddt
137
138/**
139* displays a formatted dump of an associative array.
140*
141* If ddtOn() was called, outputs a formatted debugging message showing
142* contents of array.
143*
144* @param string $file filename, usually __FILE__
145* @param string $line line number in file, usually __LINE__
146* @param string $msg debugging message to display
147* @param array $array_var array to dump.
148*/
149
150function _ddtArray( $file, $line, $msg, $array_var )
151{
152
153global $_DDT;
154
155if ( $_DDT == "yes" )
156        {
157
158        dumpmsg( "<h2>$file:$line: $msg</h2>" );
159       
160        foreach ( $array_var as $name => $value )
161                {
162                dumpmsg( "<p><b>$name</b> => <b>$value</b>\n" );
163                }
164        }
165
166}       // end of _ddtArray
167
168// -----------------------------------------------------------------
169
170/**
171* Central Error Function.
172*
173* Displays a formatted error message to the user.
174* If the global _DDT_ERROR_LOG is set the error message is dumped
175* to that file  instead of being displayed to the user.
176*/
177
178function _error( $file, $line, $msg )
179{
180
181global $_DDT_ERROR_LOG;
182global $_DDT_CMDLINE;
183
184if ( @$_DDT_ERROR_LOG == NULL )
185        {
186
187        if ( @$_DDT_CMDLINE == "yes" )
188                {
189                echo basename($file) . ":$line: $msg\n";
190                }
191        else
192                {
193                echo "<h2>$file:$line: $msg</h2>";
194                }
195        }
196else
197        {
198         
199        if (( $fp = fopen( $_DDT_ERROR_LOG, "a" )) != NULL )
200                {
201                fputs( $fp, date("D M j G:i:s T Y") . " - $file:$line: $msg\n" );
202                fclose( $fp );
203                }
204               
205        }
206       
207}       // end of _error
208
209// ----------------------------------------------------------------------
210
211function errorEcho( $title, $field )
212{
213
214global $error_msg;
215
216if ( $error_msg[ $field ] != "" )
217        {
218       
219        echo "<FONT SIZE=\"+2\" COLOR=\"RED\">$title</FONT>";
220       
221        }
222else
223        {
224       
225        echo $title;
226       
227        }
228       
229}       // end of errorEcho
230
231/**
232* turns on procedural debugging.
233*
234* Causes _ddt() calls to display debugging messages.
235*/
236
237function _ddtOn()
238{
239
240global $_DDT;
241
242$_DDT = "yes";
243
244}
245
246/**
247* set error message destination.
248*
249* sets the destination for error messages.
250*
251* @param string $file full path to errorlog.
252*/
253
254function _setErrorLog( $errorLog )
255{
256
257global $_DDT_ERROR_LOG;
258
259$_DDT_ERROR_LOG = $errorLog;
260
261}
262
263/**
264* set output file for debugging messages.
265*
266* sets the destination file for debugging messages.
267*
268* @param string $file full path to debuglog.
269*/
270
271function _setDebugLog( $debugLog )
272{
273
274global $fvDEBUG;
275
276$fvDEBUG[ "logfile" ] = $debugLog;
277
278}
279
280/**
281* set debugging output style to command line.
282*
283* tells ddt to format debugging messages for a
284* command line program.
285*/
286
287function _ddtSetCmdLine()
288{
289
290global $_DDT_CMDLINE;
291
292$_DDT_CMDLINE = "yes";
293
294}
295
296// END
297
298?>
Note: See TracBrowser for help on using the repository browser.