/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/PageWidget.inc
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/widgets/PageWidget.inc

Parent Directory Parent Directory | Revision Log Revision Log


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

1 jonen 1.1 <?php
2     /**
3     * This file contains the PageWidget class
4     *
5     * $Id: PageWidget.inc,v 1.3 2002/09/25 01:36:00 hemna Exp $
6     *
7     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
8     * @package phpHtmlLib
9     */
10    
11     /**
12     * Make sure we have the required parent class
13     */
14     require_once($phphtmllib."/widgets/HTMLPageClass.inc");
15    
16     /**
17     * This class is used to build content
18     * for an entire page. It uses the
19     * HTMLPageClass widget from phphtmllib
20     * to render the final output.
21     *
22     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
23     * @package phpHtmlLib
24     */
25     class PageWidget extends HTMLPageClass {
26    
27     /** CLASS VARS **/
28    
29     /**
30     * This enables the ability to view the
31     * source of a page bu setting debug=1
32     * in the query string.
33     *
34     */
35     var $_enable_debug = FALSE;
36    
37    
38     /**
39     * holds the page title text for
40     * a page
41     *
42     */
43     var $_title_text = NULL;
44    
45    
46     /**
47     * Constructor:
48     *
49     * @param mixed - $title Title string or TITLEtag object for the page.
50     * @param string - one of 3 types of html to render. Setting this will
51     * make the object declare the gobal define which tells
52     * all of the tag objects what type of html tags to render.
53     * some tags support special features. such as the <IMG>
54     * tag. If xhtml is selected, the the IMGtag object and all
55     * utility functions will not render "border=0" as a default
56     * attribute, since this is not proper xhtml.
57     * "html" - HTML 4.0 (default)
58     * "xhtml_transitional" - render xhtml instead of html
59     * - doctype is XHTML transitional.
60     * "xhtml_strict" - render xhtml instead of html 4.0.
61     * - doctype is XHTML strict.
62     * @param int - one of 2 types. INDENT_NICE or INDENT_LEFT_JUSTIFY
63     * This tells the page how to render the indenting of the
64     * output. By default it is set to INDENT_NICE, which nicely
65     * indents each nested tag. You can have all tags rendered
66     * left justified (smaller size in output) by using
67     * INDENT_LEFT_JUSTIFY
68     *
69     */
70     function PageWidget( $title, $render_type = HTML, $indent_style=INDENT_NICE ) {
71    
72     if ( defined("DEBUG") &&
73     (isset($_GET["debug"]) ||
74     isset($_POST["debug"]) ) ) {
75     $this->enable_debug( TRUE );
76     }
77     //save the title for later.
78     $this->_title_text = $title;
79    
80     //call the parent's constructor
81     $this->HTMLPageClass( $title, $render_type, $indent_style );
82     }
83    
84     /**
85     * gets the current title of the page.
86     *
87     * @return string
88     */
89     function get_title() {
90     return $this->_title_text;
91     }
92    
93     /**
94     * This function is used to build
95     * addition head content that isn't
96     * built by the HTMLPageClass parent
97     * class by default.
98     * NOTE: you can add addition content
99     * to the head in 1 of 2 ways.
100     * 1) inside the call return the
101     * addition content in the
102     * return $foo;
103     * 2) or use the HTMLPageClass'
104     * $this->add_head_content()
105     * from within the head_content()
106     * call.
107     *
108     * @return mixed.
109     */
110     function head_content() {
111     return NULL;
112     }
113    
114    
115     /**
116     * This function is meant to be overridden
117     * by the child class.
118     * This provides all of the content
119     * for the page.
120     * NOTE: You add the content to the
121     * body in 1 of 2 ways.
122     * 1) return the content from this
123     * call.
124     * 2) inside the call, you can
125     * just call $this->add();
126     * and then return NULL;
127     *
128     * @return mixed.
129     */
130     function body_content() {
131     return NULL;
132     }
133    
134    
135     /**
136     * This function is used to save
137     * a frameset to the page. This will
138     * automatically output a properly
139     * formatted
140     */
141     function frameset() {
142     return NULL;
143     }
144    
145     /**
146     * This function is called to build
147     * any JavaScript that is needed in the
148     * <HEAD> portion of a document.
149     *
150     * @return string - the raw JS code to be
151     * put inside the <head>
152     */
153     function head_javascript() {
154     return NULL;
155     }
156    
157    
158     /**
159     * This sets the debug option for
160     * the HTMLPageClass
161     *
162     * @param boolean TRUE for on, FALSE for off
163     */
164     function enable_debug( $flag = TRUE ) {
165     $this->_enable_debug = $flag;
166     }
167    
168    
169     /**
170     * This is the function that renders the HTML
171     * for this widget.
172     *
173     * @return string - the HTML
174     */
175     function render() {
176    
177     //test to see if they want debugging of
178     //output enabled.
179     if ( $this->_enable_debug ) {
180     if ( isset($_GET["debug"]) ) {
181     $this->set_text_debug( TRUE );
182     }
183     }
184    
185     //check to see if they want to render a frameset
186     $frameset = $this->frameset();
187     if ( $frameset != NULL ) {
188     //add and set the page output
189     //to be a frameset.
190     $this->set_frameset( $frameset );
191     } else {
192    
193     //Try and get some more head content
194     $content = "";
195     $content = $this->head_content();
196     if ( $content != "" ) {
197     $this->add_head_content( $content );
198     }
199    
200     //try and get the body content.
201     //the user could just have added
202     //the data manually.
203     $content = "";
204     $content = $this->body_content();
205     if ( $content != "" ) {
206     $this->add( $content );
207     }
208     }
209    
210     //Lets see if they have any javascript
211     //for the head
212     $js = $this->head_javascript();
213     if ( $js != NULL ) {
214     $this->add_head_js( $js );
215     }
216    
217    
218     return HTMLPageClass::render();
219     }
220     }
221     ?>

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