/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/test/test9.php
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/test/test9.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Jan 30 03:29:41 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Branch point for: no_vendor_tag
Initial revision

1 <?php
2
3 include_once("localinc.php");
4
5 /**
6 * This function parses the input string and
7 * replaces all occurences of a \n character
8 * with a BRtag object. Then it wraps the entire
9 * new string with a DIVtag object with a
10 * class reference of $class.
11 *
12 * @param string $raw_string - the input string.
13 * @param string $class - the css class to give
14 * to the wrapper DIVtag
15 * @return DIVtag object.
16 */
17 function babw_nl2br($raw_string, $class=NULL) {
18
19 $attributes = array();
20 if ($class) {
21 $attributes = array ("class" => $class );
22 }
23 $div = new DIVtag( $attributes );
24
25 //Ok now lets walk through the string
26 //and find each \n char.
27 $lines = explode( chr(13), $raw_string);
28 $index=0;
29 while( $lines[$index] ) {
30 $div->push( $lines[$index], html_br() );
31 $index++;
32 }
33 return $div;
34 }
35
36 $page = new HTMLPageClass("test.php");
37 $page->set_text_debug( $debug );
38
39 $form = new FORMtag(array("name"=> "testform",
40 "method" => "POST",
41 "action" => $PHP_SELF));
42
43
44 $textarea = form_textarea("text", "this is a long ass test" );
45 $textarea->set_tag_attributes( array("cols" => "60",
46 "rows" => "40") );
47
48 $form->push( html_br(), $textarea, html_br() );
49
50 $form->push( form_submit("what", "Submit") );
51 $form->push( form_submit("debug", "Debug") );
52
53 $page->push( $form, html_br(), html_br() );
54
55 if ($REQUEST_METHOD == "POST") {
56 //Ok lets process the input.
57 $div = babw_nl2br( $HTTP_POST_VARS["text"] );
58 $page->push( $div );
59 }
60
61 print $page->render();
62 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed