blueshoes php application framework and cms            core_html
[ class tree: core_html ] [ index: core_html ] [ all elements ]

Class: Bs_FormTemplateParser

Source Location: /core/html/form/Bs_FormTemplateParser.class.php

Class Overview

Bs_Object
   |
   --Bs_XmlParser
      |
      --Bs_FormTemplateParser

Template Parser Class


Author(s):

Version:

  • 4.3.$Revision: 1.4 $ $Date: 2003/10/29 17:48:39 $

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods

Class: Bs_XmlParser

Bs_XmlParser::Bs_XmlParser()
Constructor.
Bs_XmlParser::getTagName()
returns the name of the tag.
Bs_XmlParser::isCommentedOut()
tells if the tag is commented out.
Bs_XmlParser::parseProperties()
same as parseTag() but takes a tag string instead of a full tag.
Bs_XmlParser::parseTag()
takes a tag (something like <bs_form name="name" what="element"/>) and parses its properties into a hash.

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 104]
Template Parser Class

dependencies: Bs_XmlParser, Bs_String, Bs_ContentBlock, Bs_Dir, Bs_FormHandler (which starts the require of all the form stuff), Bs_TemplateParser, //Bs_NavigationSite

the following tags are defined:

 o) bs_navigation
     - used to build the site navigation
     - is closed directly.
     - properties:
        - function= the function name to call.
     - example:
       
 o) bs_content
     - used for content blocks.
     - is closed directly.
     - properties:
        - name= the internally used form name. has to be set.
        - type= not sure if this is of any use or just a hint for the webmaster.
     - example:
       
 o) bs_form
     - used for forms.
     - has to be closed using .
     - can 'hold' bs_input tags.
     - properties:
        - name= the internally used form name. has to be set.
        - mode= one of 'add', 'edit', 'delete'. should be set.
     - example:
        ... 
 o) bs_input
     - used for forms.
     - is closed directly.
     - properties:
        - name= the internally used element name. has to be set.
        - type= one of 'element', 'caption', 'text', 'error', 'help'. default is 'element'.
        - elementlist= list of elements you want to have in the returned output. useful for
                       radio buttons if you don't want all of them, or just one.
                       give the keys of the elements you want.
     - example:
       
       
 o) bs_formbuttons
     - used for forms.
     - is closed directly.
     - example:
       
 o) bs_forminfo
     maybe you better use that only in 'done' templates. i think that they can also be
     used else, but ... dunno.
     - used for forms.
     - is closed directly.
     - properties:
        - type= one of 'recordId', 'usedTime', 'viewCount'.
     - example:
       
 o) bs_formerrors
    - used in forms.
    - is closed directly.
     - properties:
        - caption= the internally used element name. has to be set.
        - //type=
     - example:
       
 o) bs_include
     - used to include source code that gets parsed from bs. is done
       in an extra loop to have everything together before we start.
       can be recursive.
     - is closed directly.
     - properties:
        - src= can be a file (relative or absolute) on the current
                  machine or in the network, or can be an url.
     - examples:
       
       
 o) bs_require
     - same as bs_include but it won't be parsed from bs. not done
       in an extra loop either. so it's faster but less fun.
 




Tags:

copyright:  blueshoes.org
pattern:  singleton: (pseudostatic)
access:  public
version:  4.3.$Revision: 1.4 $ $Date: 2003/10/29 17:48:39 $
author:  andrej arn <at blueshoes dot org>


[ Top ]


Class Variables

$Bs_String =

[line 110]

reference to the globally used pseudostatic class.


Type:   object


[ Top ]

$caseFolding =  FALSE

[line 173]

OVERWRITES PARENT CLASS! should this class do case folding? (make all tags and attributes upper case) default is FALSE. (parent uses TRUE!!) i don't want to use XML_OPTION_CASE_FOLDING here.



Tags:

access:  public

Type:   bool
Overrides:   Array


[ Top ]

$pageID =

[line 117]

the page id for which this instance of templateparser is used.

set in the constructor.



Type:   int


[ Top ]

$tags =

[line 145]

has this structure:

 $tags[0]['tag']        = 'bs_form';
 $tags[0]['properties'] = hash output from Bs_Html->parseTag();
 $tags[0]['subTags'][]  = other tags (hashes) like this one.
 $tags[0]['posStart']   = 105;
 $tags[0]['posEnd']     = 123;
 



Type:   array


[ Top ]

$templatePath =

[line 163]

the absolute path to the template directory. if not set than this class will try to find them using getAbsolutePath() . '../templates/' which kinda sucks. so you better set that...



Tags:

access:  public

Type:   string


[ Top ]

$templateString =

[line 131]

the content of the template file as one string.



Tags:

var:  templateString

Type:   string


[ Top ]

$_offset =  0

[line 152]

used in applyTag(). everytime we add something, the tags below move more down.

that's what the offset is for.



Type:   int


[ Top ]



Class Methods


constructor Bs_FormTemplateParser [line 181]

Bs_FormTemplateParser Bs_FormTemplateParser( [int $pageID = 0], [object $page = NULL])

Constructor.



Parameters:

int   $pageID   default is 0
object   $page   the page object that uses this template parser. PASS IT BY REFERENCE.

[ Top ]

method apply [line 494]

bool apply( [string $language = NULL], [mixed $form = NULL], [bool $editable = FALSE], object &$form)

has to be called after parse(). means $this->tags must be set already, somehow.

of course also $this->templateString has to be set, which can be done using loadTemplate().




Tags:

return:  TRUE
todo:  not satisfied with the params, how the information is passed.
throws:  bs_exception (at least at the moment)


Parameters:

string   $language   if set it will be applied where appropriate.
object   &$form   the form to use for the forms where no name is set in the xml code or where the name equals to the one of the form. pass it byref.
bool   $editable   default is FALSE. if content blocks should be editable or not.

[ Top ]

method applyTag [line 675]

bool applyTag( int $tagKey, string $tagString)

applies a tag to $this->templateString.



Tags:

return:  TRUE if the tag was inserted successfully, FALSE if not (key out of bounds or something).
access:  public


Parameters:

int   $tagKey   the key of $this->tags for which we insert the tag.
string   $tagString   the new string to insert into $this->templateString.

[ Top ]

method loadTemplateFromFullpath [line 322]

bool loadTemplateFromFullpath( string $fullPath)

loads the template from the given absolute fullpath.



Tags:

return:  TRUE on success
todo:  finish this code. it works fine but only if everything's right the first time.
see:  loadTemplate(), Bs_FormTemplateParser::loadTemplateFromString()
throws:  bs_exception on failure
access:  public


Parameters:

string   $fullPath   (absolute fullpath to template)

[ Top ]

method loadTemplateFromString [line 342]

bool loadTemplateFromString( string $str)

"loads" the template given in the string.



Tags:

return:  TRUE
since:  bs4.5
see:  loadTemplate(), Bs_FormTemplateParser::loadTemplateFromFullpath()
access:  public


Parameters:

string   $str   (the template)

[ Top ]

method parse [line 378]

void parse( [bool $debug = FALSE])

it's not a real parser, it just searches for <bs ...> tags. fills $this->tags.

you cannot comment out a whole block using <!-- -->. but you can comment out tags using <!tag>.

of course $this->templateString has to be set already, which can be done using loadTemplate().




Tags:

see:  var $this->tags
access:  public


Parameters:

bool   $debug   (default is FALSE). prints out debug information directly to the screen.

[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:10:38 +0100 by phpDocumentor 1.2.3