Adventure,PHP,framework,page controller,front controller,pattern,object orientated design,software,development,reusability,uml,tutorial,benchmark,brilliant performance,

Search:    
Downloads  |  SVN!  |  Roadmap  |  Forum!  |  Bugtracking  |  Guestbook  |  Backlinks!  |  References!  |  Sitemap  |  Impress  
 
Deutsch | English Adventure PHP Framework  Bookmark @ Technorati Bookmark @ del.icio.us Bookmark @ Mr. Wong Bookmark @ Simpy Bookmark @ Google Bookmark @ Digg.com Adventure PHP Framework Print page 046-Standard-taglibs

Standard taglibs

Rank article:
This article has not yet been ranked. Vote this article first of all!
This chapter describes the taglib tags available out-of-the-box. Within not self-closing tags all HTML tags and formatting are permitted. All tags can be equipped with the usual HTML attributes, provided that these are relevant for the issue or function.


1. Core

1.1. Addtaglib

Taglibs are only "valid" within a specific document of the object tree. That means, that the parser methode __extractTagLibTags() only parses the taglibs known in one specific node. To be able to integrate a self-implemented taglib in the present document the following tag is used. This XML tag should be placed possibly at the beginning of the document, or at least befor it is used because of tag can only be successfully integrated after the taglib is parsed.
<core:addtaglib namespace="" prefix="" class="" />
Description of the attributes:
  • namespace: Namespace path seperated with "::". (Allowed characters: [A-Za-z0-9_-:])
  • prefix: XML prefix (Allowed characters: [a-z])
  • class: XML class (Allowed characters: [a-z])
Taglib classes generated by the developer must be named like "<prefix>_taglib_<class>". Thereby, <prefix> is the prefix and <class> identifies the class of the XML tag used to inside a template. The methods to be implemented within the class are to be taken from the API documentation. In common the tag is used for the integration of the form taglib or to load user specific taglibs. Own taglibs are usualy created, when a application needs to be separated into independent parts and these want to be used in different contexts or modules of the application.


1.2. Importdesign

To include another template into a certain place in the space of a present template the tag
<core:importdesign namespace="" template="" [incparam=""] />
Description of the attributes:
  • namespace: Namespace path seperated with "::". (Allowed characters: [A-Za-z0-9_-:])
  • template: Name of the desired template. (Allowed characters: [A-Za-z0-9-_:])
  • incparam: URL parameter that is used for template inclusion.
can be used. If a so-called pagepart template is defined with the definition of this tag, a template can be integrated depending by the specified URL parameter. Standard parameter is "pagepart", nevertheless, this can be adapted with the optional attribute "incparam". Example of the integration with the pagepart parameter is:
<core:importdesign namespace="sites::testsite::pres::templates" template="[pagepart = test]" />
<core:importdesign namespace="sites::testsite::pres::templates" template="[cmsmodule = test]" \
 incparam="cmsmodule" />
The integrated template automatically inherits the qualities of the father's object. In particular context and language will be adopted.


1.3. Setproperty

To be able to set an property of the current document in a template the "core:setproperty" tag is available to the developer. Typical application case is to set the context or the language of the documents with this tag to influence the language.
<core:setproperty name="" value="" />
A detailed list of the class properties of classes that inherit from the class "Document" can be taken from the API documentation.

To use the tag it must be announced using the
<core:addtaglib namespace="core::pagecontroller" prefix="core" class="setproperty" />
directive.

Description of the attributes:
  • name: Name of the desired class property. (Allowed characters: [A-Za-z0-9_-])
  • value: Value. (Allowed characters: [A-Za-z0-9-_:.])

1.4. Setattribute

The behavior of "core:setattribute" is similar to "core:setproperty". The difference is, that "core:setattribute" manipulates the attributes array not a specific class' property.
<core:setattribute name="" value="" />
To use the tag it must be announced using the
<core:addtaglib namespace="core::pagecontroller" prefix="core" class="setattribute" />
directive.

Description of the attributes:
  • name: Name of the attribute. (Allowed characters: [A-Za-z0-9_-])
  • value: Value. (Allowed characters: [A-Za-z0-9-_:.])

2. Html

2.1. Placeholder

To be able to fill contents in a document controller dynamically the tag "html:placeholder" was introduced.
<html:placeholder name="" />
Description of the attributes:
  • name: Name of the place holder. The name is used to access this place holder within a document controller. (Allowed characters: [A-Za-z0-9-_])

To fill a place holder with contents you can insert the following instruction in a document controller:
  $this->setPlaceHolder('NameOfThePlaceHolder','ContentOfThePlaceHolder'); 

2.2. Getstring:

The tag "<html:getstring />" gives the opportunity to read a configuration string from a language-dependent configuration file and so create multi-language GUIs. The behavior is identical to the "<template:getstring />" tag described in chapter 2.2.3.
<html:getstring namespace="" config="" entry="" />
To use the tag it must be announced using the
<core:addtaglib namespace="tools::html::taglib" prefix="html" class="getstring" />
directive.

Description of the attributes:
  • namespace: Namespace of the configuration file. (Allowed characters: [A-Za-z0-9_-:])
  • config: Name of the configuration. (Allowed characters: [A-Za-z0-9-_])
  • value: Name of the configuration key. (Allowed characters: [A-Za-z0-9-_.])

The language dependent configuration file must contain one section per language (two-letter ISO country code) and the configuration keys used in the tag within each of the language sections. If the tag
  <html:getstring namespace="modules::mymodule" config="language" entry="title" />
should display a multilangual title within a template, the configuration file
  /config/modules/mymodule/{APPS__CONTEXT}/{APPS__ENVIRONMENT}_language.ini
must be filled with the content
[de]
title = "Mein Modul"

[en]
title = "My module"
This description of this tag can also be applied to the tags <form:getstring /> (chapter 2.4.19.) and <template:getstring /> (chapter 2.3.3.).


2.3. Template

2.3.1. Basic functions

To be able to define further reusable elements the so-called templates are introduces. These can be manipulated and be processed within a document controllers. Each template again has place holders than can be filled dynamically.
<html:template name="">
  [<template:placeholder name="" />]
  [<template:addtaglib namespace="" prefix="" class="" />]
</html:template>
Description of the attributes:
  • name: Name of the templates of name of the place holder within a templates. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
Access to a template grants the private method "__getTemplate()" of a document controller. With the help of this function a reference on a template object can be gathered. A typical application case looks like this:

Template:
<@controller namespace="" file="" class="" @>
<html:placeholder name="Content" />

<html:template name="MyTemplate">
  <template:placeholder name="MyPlaceHolder">
</html:template>
Controller:
class myDocumentController extends baseController
{
   function 
myDocumentController(){
   }

   function 
transformContent(){
      
$Template__MyTemplate = &$this->__getTemplate('MyTemplate');
      
$Template__MyTemplate->setPlaceHolder('MyPlaceHolder','MyContent');
      
$this->setPlaceHolder('Content',$Template__MyTemplate->transformTemplate());
   }
Here a document controller, a HTML place holder and a template with accompanying place holder is defined in the template file. Now in the controller you can get a reference on the template by using the __getTemplate() methode and fill it with setPlaceHolder(). Afterwards the template is transformed and the output is used to fill the HTML place holder by means of setPlaceHolder(). It is possible to define several templates inside a template file. Often this is used for the issue of displaying different announcements with different events.


2.3.2. Template enhancement:

If the standard functionality of HTML templates must be extended, the tag "<template:addtaglib />" can be used to achieve this goal. The behavour of the is similar to "<core:addtaglib />" that can be used in context of template files to add tag libs there.
<template:addtaglib namespace="" prefix="" class="" />
Description of the attributes:
  • namespace: Namespace path seperated with "::". (Allowed characters: [A-Za-z0-9_-:])
  • prefix: XML prefix (Allowed characters: [a-z])
  • class: XML class (Allowed characters: [a-z])
An example of the use of the XML tag is the taglib tag <[html|template]:getstring / > to read a string from a configuration file and display it. See chapter 2.2.3 or 2.4 for more details.


2.3.3. Getstring:

The tag "template:getstring" gives the opportunity to read a configuration string from a language-dependent configuration file and so create multi-language GUIs.
<template:getstring namespace="" config="" entry="" />
To use the tag it must be announced using the
<template:addtaglib namespace="tools::html::taglib" prefix="template" class="getstring" />
directive.

Description of the attributes:
  • namespace: Namespace of the configuration file. (Allowed characters: [A-Za-z0-9_-:])
  • config: Name of the configuration file. (Allowed characters: [A-Za-z0-9-_])
  • value: Name of the configuration key. (Allowed characters: [A-Za-z0-9-_.])

2.4. Form

To the dynamic generation and use of forms the html:form tag was created. With this forms within a document can be described like templates and are available fot use in the document controller of the present DOM node like templates.
<html:form name="" [method=""]>
  ...
</html:form>
Description of the attributes:
  • name: Name of the formular. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • method: Dispatching methode. Default is "post". (Allowed characters: [get|post])
Within a form the following tags are available. These can appear in different combinations. For an application example please refer to the contact form tutorial or the API documentation.

Besides the following attributes are available for the activation and configuration of the validation feature of input fields (e.g. with text areas):
<form:area name="" [validate="" button="" [validator=""]]/>
Description of the attributes:
  • validate: If this value is set tu "true", the field will be validated when the form is submitted. Whether the attribute is not present or set to "false" validation will be turned off. Setting the value to true, requires that the attribute "button" must be specified. (Allowed characters: [true|false])
  • button: Name of the form's button that indicates the validation. (Allowed characters: [A-Za-z0-9-_])
  • validator: Name of the validator. The standard validator is "Text" which tests the user input of containing more that three characters. The attribute can be filled by any validation method known the class "myValidator". The keyword given here must contain the name of the validator's validation method without the string "validate". An example: if someone wants to validate a field to contain a valid e-mail address, the method "validateEMail" must be used. Thus the field "validator" must be filled with the string "EMail". To allow other validation methods the class "myValidator" must be extended. (Allowed characters: [A-Za-z])

2.4.1. Textarea

<form:area name="" [id=""] [class=""] [style=""] />
Description of the attributes:
  • name: Name of the textarea. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.2. Textarea with content

<form:area name="" [id=""] [class=""] [style=""]>
  [..]
</form:area>
Description of the attributes:
  • name: Name of the textarea. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.3. Button

<form:button name="" [id=""] [class=""] [style=""] />
Description of the attributes:
  • name: Name of zje button. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.4. Checkbox

<form:checkbox name="" [id=""] [class=""] [style=""] [checked=""] />
Description of the attributes:
  • name: Name of the checkbox. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.
  • checked: Indicates whether a radio button is pre selected.

2.4.5. Date control

<form:date name="" [id=""] [class=""] [style=""] [yearrange=""] [offsetnames=""]/>
Description of the attributes:
  • name: Name of the datum controll. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.
  • yearrange: Range of the field "year". Example: 1990-2007. (Allowed characters: [0-9-])
  • offsetnames: Names of the fields for day, month year. Each field must be seperated by a semicolon (";"). Example: DAY;MONTH;YEAR. (Allowed characters: [A-Za-z])

2.4.6. File upload field

<form:file name="" [id=""] [class=""] [style=""] />
Description of the attributes:
  • name: Name des Dateiupload-Felds. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.7. Hidden field

<form:hidden name="" value="" />
Description of the attributes:
  • name: Name des Hidden-Felds. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • value: Wert des Hidden-Feldes.

2.4.8. Multic select field

<form:multiselect name="" [id=""] [class=""] [style=""] />
Description of the attributes:
  • name: Name of the multiselect field. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.9. Multic select field with options

<form:multiselect name="" [id=""] [class=""] [style=""]>
  <select:option value="" [selected="selected"]></select:option>
</form:multiselect>
Description of the attributes:
  • name: Name of the multiselect field. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.
  • value: Value of the currend option.
  • selected: Indicates if the current option is pre selected. (Allowed characters: [selected|<empty>])

2.4.10. Password field

<form:password name="" [id=""] [class=""] [style=""] />
Description of the attributes:
  • name: Name of the passwors field. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.11. Placeholder

<form:placeholder name="" />
Description of the attributes:
  • name: Name of the place holder. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])

2.4.12. Radio button

<form:radio name="" id="" [class=""] [style=""] [checked=""]/>
Description of the attributes:
  • name: Name of the radio button. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.
  • value: Wert der Option.
  • checked: Indicates if the option is pre selected. (Allowed characters: [checked|<empty>])

2.4.13. Select field

<form:select name="" [id=""] [class=""] [style=""] />
Description of the attributes:
  • name: Name of the select field. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.14. Select field with options

<form:select name="" [id=""] [class=""] [style=""]>
  <select:option value="" [selected="selected"]></select:option>
</form:select>
Description of the attributes:
  • name: Name of the select field. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.
  • value: Wert der Option.
  • selected: Indicates if the current option is pre selected. (Allowed characters: [selected|<empty>])

2.4.15. Text field

<form:text name="" [id=""] [class=""] [style=""]/>
Description of the attributes:
  • name: Name of the text field. The name is used to access this object within a document controller. (Allowed characters: [A-Za-z0-9-_])
  • id: Unique ID within the form. (Allowed characters: [A-Za-z0-9-_])
  • class: CSS class.
  • style: CSS style.

2.4.16. Validator

<form:validate validator="" button="" field="" [type=""] [msginputreq=""] [msginputwrg=""] />
Description of the attributes:
  • validator: Name of the validator, that should be used to validate the user input. For details please refer to chapter 2.3. (Allowed characters: [A-Za-z])
  • button: Name of the button of the form.
  • field: Name of the field, that should be validated.
  • type: Output / display type of the validator tag. Filled with the keyword "text" you need to create a language dependent configuration file ("{APPS__ENVIRONMENT}__formconfig.ini") under the namespace "tools::form::taglib" and the current context folder. Please see configuration for more details. If set to "css" a CSS formating string is presented. (Allowed characters: text|css).
  • msginputreq: This attribute specifies the configuration key that should be used for text ouput if the field described throuh the attribute "field" was not filled. If not presend a default text will be displayed. (Allowed characters: [A-Za-z0-9_-]).
  • msginputwrg: This attribute can be used to declare the config key that contains the text that should be displayed whether the field specified by the "field" attribute was not filled correctly. It the parameter is not present default values will be displayed. (Allowed characters: [A-Za-z0-9_-]).

2.4.17. Validator group

<form:valgroup name="">
  <valgroup:validate validator="" button="" field="" [type=""] [msginputreq=""] [msginputwrg=""] />
  [<valgroup:placeholder name="" />]
</form:valgroup>
Description of the attributes:
  • name: Name of the validator group. Severak groups can be defined.
  • validator: Name of the validator, that should be used to validate the user input. For details please refer to chapter 2.3. (Allowed characters: [A-Za-z])
  • button: Name of the button of the form.
  • field: Name of the field, that should be validated.
  • type: Output / display type of the validator tag. Filled with the keyword "text" you need to create a language dependent configuration file ("{APPS__ENVIRONMENT}__formconfig.ini") under the namespace "tools::form::taglib" and the current context folder. Please see configuration for more details. If set to "css" a CSS formating string is presented. (Allowed characters: text|css).
  • msginputreq: This attribute specifies the configuration key that should be used for text ouput if the field described throuh the attribute "field" was not filled. If not presend a default text will be displayed. (Allowed characters: [A-Za-z0-9_-]).
  • msginputwrg: This attribute can be used to declare the config key that contains the text that should be displayed whether the field specified by the "field" attribute was not filled correctly. It the parameter is not present default values will be displayed. (Allowed characters: [A-Za-z0-9_-]).
As shown in the example code place holders can be included in a validator group. To fill this place holders the setPlaceHolder() method can be used on an validator group object. Attribute relevant to the tag can be seen in the html:placeholder specification.


2.4.18. Generic validator

The generic validator was introduced in release 1.4. It can be used to influence standard HTML or CSS code with dynamic contens generated by the generic validator tag. This tag prints out the content specified in the tag's content if the validation condition was not fulfilled.

If the validation methods of the myValidator class don't fit the currend application, a regular expression can be used to perform the validation. To do so, the attribute validator must be filled with the value RegExp and the attribute regexp must provide a legal regular expression.
<form:genericval button="" field="" [validator="" ]>[text]</form:genericval>
Description of the attributes:
  • button: Name of the form's buttons.
  • field: Name of the field, that should be validated.
  • validator: Name of the validator, that should be used. For details please refer to chapter 2.3. (Allowed characters: [A-Za-z])
  • regexp: Regular expression. This attribute must be present, if the validator attribute contains the value "RegExp". This means, that the validation of the desired field is done by a regular expression.
  • text: Text that should be displayed whether the condition is not fulfilled. The content can contain contain any kind of HTML or XML fragments.

2.4.19. Getstring:

The tag "form:getstring" gives the opportunity to read a configuration string from a language-dependent configuration file and so create multi-language GUIs.
<form:getstring namespace="" config="" entry="" />
Description of the attributes:
  • namespace: Namespace of the configuration file. (Allowed characters: [A-Za-z0-9_-:])
  • config: Name of the configuration file. (Allowed characters: [A-Za-z0-9-_])
  • value: Name of the configuration key. (Allowed characters: [A-Za-z0-9-_.])

2.4.20. Addtaglib

The "form:addtaglib" taglib behaviour is equal to the "core:addtaglib" taglib. It enables the developer to extend the existing functionality of the form tags. The implementation makes ist possible to include and use various form tags.
<form:addtaglib namespace="" prefix="" class="" />
Description of the attributes:
  • namespace: Namespace path seperated with "::". (Allowed characters: [A-Za-z0-9_-:])
  • prefix: XML prefix (Allowed characters: [a-z])
  • class: XML class (Allowed characters: [a-z])

2.4.21. Marker

As decribed in chapter dynamic forms the <form:marker /> tag is used to position dynamic form elements. The does not generates any output.
<form:marker name="" />
Description of the attributes:
  • name: Name of the markers. The name is used to address it. (Allowed characters: [A-Za-z0-9-_])

3. Document

3.1. createobject

This tag enables the developer to create a website with language-dependent content view based on html files, that contain the content and functionality of the content pages. Content files are expected to reside in a folder ./frontend/content/ in parallel to the current bootstrap file (index.php). As an example this documentation page is based on this concept. Content diles must be named like
c_{LANGCODE}_{NAME}.html
whereas
  • LANGCODE is a 2 letter ISO language code (de, en, it, es, ...) and
  • NAME is the URL name of the current page.
<doc:createobject requestparam="" defaultvalue="" />
Description of the attributes:
  • requestparam: URL parameter, that describes, which content fil has to be loaded. (Allowed characters: [A-Za-z0-9])
  • defaultvalue: Default value of the parameter defined through requestparam.
To use the tag it must be announced using the
<core:addtaglib namespace="tools::html::taglib" prefix="doc" class="createobject" />
directive.

Note: If the tag could not find an appropriate file according to the requestparam, it expects a file with the name
c_{LANGCODE}_404.htm
to indicate, that the desired page cannot be displayed. In case the error file is not present a php error will be displayed.


4. DocumentController

As already described under controller a document controller must be declared via
<@controller namespace="" file="" class="" @>
Description of the attributes:
  • namespace: Namespace path to the controller. (Allowed characters: [A-Za-z0-9:])
  • file: Name of the file, the controller resides in. (Allowed characters: [A-Za-z0-9_])
  • class: Class name of the controllers. (Allowed characters: [A-Za-z0-9_])
Any implementation must inherit from the abstract document controller baseController. This class is defined in the pagecontroller.php file under apps/core/pagecontroller and must not be included separately.


5. FrontController

Since release 1.4-18.11.2007 the tag "<fcon:importdesign />" was added. It aids the implementation of front controller based applications and makes it possible to include views by the use of application model information according to the MVC pattern. Therefore a separate model class that provides the information must be created for the entire application or a single module. The control of the view integration is regulated typically by an own front controller actions that is executed in "prepagecreate" mode (see FrontController, chapter 1.6). This action then can assign parameters to the model object that are contained in the URL.
  <fcon:importdesign
      templatenamespace=""
      modelnamespace=""
      modelfile=""
      modelclass=""
      modelparam=""
  />
Description of the attributes:
  • templatenamespace: Namespace path to the desired template folder. (Allowed characters: [A-Za-z0-9:])
  • modelnamespace: Namespace path to the model class. (Allowed characters: [A-Za-z0-9:])
  • modelfile: Class file of the model. (Allowed characters: [A-Za-z0-9_])
  • modelclass: Class name of the model. (Allowed characters: [A-Za-z0-9_])
  • modelparam: Model attribute that indicates the inclusion if the template file. (Allowed characters: [A-Za-z0-9_])
  • sessionsingleton: Defines, if the model object is created in SINGLETON or SESSIONSINGLETON mode. If the attribute is not present or contains any other value than true, the SINGLETON mode will be used. (Allowed values: true|false)

Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.


There are no comments belonging to this article.


Powered by WebRing.