TemplateObject.php3
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:9k
- <?
- // TemplateObject Test Suite
- //error_reporting(63);
- $PROMETHEUS_LIBRARY_BASE='../';
- include ('../all.lib');
- AutoLoad('TemplateObject');
- function retval ($value)
- {
- if ( $value == false )
- printf("return: false<br>n");
- elseif ( $value == true )
- printf("return: true<br>n");
- elseif( is_integer($value) )
- printf("return: %d<br>n", $value);
- elseif( is_string($value) )
- printf("return: %s<br>n", $value);
- else
- echo $value . "<br>n";
- }
- ?>
- <body bgcolor=#CCCCCC>
- <pre>
- <h1>TemplateObject.object</h1>
- <h2>Boundary Conditions</h2>
- <ul>
- <li><b>Parse Template, no registrations</b>
- $template_obj = new TemplateObject();
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, with no value</b>
- $template_obj = new TemplateObject();
- $template_obj->Register('TOKEN1','');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->Register('TOKEN1','');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, change <i>start</i> tag</b>
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '%';
- $template_obj->Register('TOKEN2','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '%';
- $template_obj->Register('TOKEN2','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, change <i>end</i> tag</b>
- $template_obj = new TemplateObject();
- $template_obj->template_var_end = '%';
- $template_obj->Register('TOKEN3','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->template_var_end = '%';
- $template_obj->Register('TOKEN3','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, change both <i>end</i> and <i>start</i> tags</b>
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '%';
- $template_obj->template_var_end = '%';
- $template_obj->Register('TOKEN4','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '%';
- $template_obj->template_var_end = '%';
- $template_obj->Register('TOKEN4','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, change <i>start</i> tag to NOTHING!</b>
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '';
- $template_obj->Register('TOKEN5','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '';
- $template_obj->Register('TOKEN5','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, change <i>end</i> tag to NOTHING!</b>
- $template_obj = new TemplateObject();
- $template_obj->template_var_end = '';
- $template_obj->Register('TOKEN6','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->template_var_end = '';
- $template_obj->Register('TOKEN6','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Parse Template, register single token, change <i>end</i> and <i>start</i> tags to NOTHING!</b>
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '';
- $template_obj->template_var_end = '';
- $template_obj->Register('TOKEN7','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->template_var_start = '';
- $template_obj->template_var_end = '';
- $template_obj->Register('TOKEN7','***NEWVALUE***');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- </ul>
- <h2>Regular Conditions</h2>
- <ul>
- <pre>
- <li><b>Enable Imbedded PHP</b>
- $template_obj = new TemplateObject();
- $template_obj->with_php = true;
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->with_php = true;
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Enable Returning of Contents</b>
- $template_obj = new TemplateObject();
- $template_obj->return_contents = true;
- $returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
- echo "<ul>$returned</ul>";
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->return_contents = true;
- $returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
- echo "<ul>$returned</ul>";
- unset($template_obj);
- ?>
- <pre>
- <li><b>Enable Imbedded PHP _AND_ Returning of Contents</b>
- $template_obj = new TemplateObject();
- $template_obj->with_php = true;
- $template_obj->return_contents = true;
- $returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
- echo "<ul>$returned</ul>";
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->with_php = true;
- $template_obj->return_contents = true;
- $returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
- echo "<ul>$returned</ul>";
- unset($template_obj);
- ?>
- <pre>
- <li><b>Register Single File</b>
- $template_obj = new TemplateObject();
- $template_obj->RegisterFile('TOKEN1','TemplateObject.file');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->RegisterFile('TOKEN1','TemplateObject.file');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Register Token with File, Enable Returning of Content</b>
- $template_obj = new TemplateObject();
- $template_obj->return_contents = true;
- $template_obj->RegisterFile('TOKEN1','TemplateObject.file');
- $returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
- echo "<ul>$returned</ul>";
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->return_contents = true;
- $template_obj->RegisterFile('TOKEN1','TemplateObject.file');
- $returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
- echo "<ul>$returned</ul>";
- unset($template_obj);
- ?>
- <pre>
- <li><b>Register Token with File, Enable Imbedded PHP</b>
- $template_obj = new TemplateObject();
- $template_obj->with_php = true;
- $template_obj->RegisterFile('TOKEN1','TemplateObject.file');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- $template_obj->with_php = true;
- $template_obj->RegisterFile('TOKEN1','TemplateObject.file');
- $template_obj->ParseTemplate('TemplateObject.tmpl');
- unset($template_obj);
- ?>
- <pre>
- <li><b>Register Token with File AND THEN Register it as a normal token</b>
- $template_obj = new TemplateObject();
- retval( $template_obj->RegisterFile('TOKEN1','TemplateObject.file') );
- retval( $template_obj->Register('TOKEN1','***RE-REGISTER***') );
- retval( $template_obj->ParseTemplate('TemplateObject.tmpl'));
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- retval( $template_obj->RegisterFile('TOKEN1','TemplateObject.file') );
- retval( $template_obj->Register('TOKEN1','***RE-REGISTER***') );
- retval( $template_obj->ParseTemplate('TemplateObject.tmpl') );
- unset( $template_obj );
- ?>
- <pre>
- <li><b>Register Token with File AND Register a second as a normal token</b>
- $template_obj = new TemplateObject();
- retval( $template_obj->RegisterFile('TOKEN1','TemplateObject.file') );
- retval( $template_obj->Register('TOKEN2','**SECOND TOKEN**') );
- retval( $template_obj->ParseTemplate('TemplateObject.tmpl'));
- unset($template_obj);
- </pre>
- <?
- $template_obj = new TemplateObject();
- retval( $template_obj->RegisterFile('TOKEN1','TemplateObject.file') );
- retval( $template_obj->Register('TOKEN2','**SECOND TOKEN**') );
- retval( $template_obj->ParseTemplate('TemplateObject.tmpl'));
- unset( $template_obj );
- ?>
- </ul>
- </body>