Build-in utility classes
  1. Application class (tool/Application.php):
    This is static class. It is used to implement emulated Application variable. There are several static methods in this class:

    • start() – Start Application to use. When you want to use application variable(s), it must use this static method first.

    • set( $key , $value ) – Defines the application variable name and its value.

    • get( $key ) – Get the application variable which is defined before.

    • remove( $key ) – Remove application variable which is defined before.

    • end() – After using application variable(s), you must run this static method to save all application variable(s).

    Here is an example:

    A.php :

    Include_once("tool/Application.php");

    Application::start();
    Application::set( "test", "This is testing…" );
    Application::end();
    ……

    B.php :
    Include_once("tool/Application.php");

    Application::start();
    echo Application::get( "test" );
    Application::end();

    When A.php is called by user A, "test" application variable is set. Afterwards, B.php is called by User B and B.php can get "test" application variable and have following output result:
    This is testing…

  2. Calendar class (tool/Calendar.php):
    This is static class. It provides common "Date" static methods.

    • getDatesOfWeekdayInMonth( $weekdayName , $timestamp="" ) – It return timestamps of all dates of indicated weekday in that month. The return value is in PHP Array. Input value of weekday name of this method must be " SUNDAY ", " MONDAY ", " TUESDAY ", " WEDNESDAY ", " THURSDAY ", " FRIDAY " or " SATURDAY ". Input value of timestamp of this method is timestamp of date. By default, the input value is timestamp of current time.


    • getNextDay( $timestamp="" ) – It returns timestamp of next day of input value. Input value of this method is timestamp of date. By default, the input value is timestamp of current time.


    • getTotalDaysInMonth( $timestamp="" ) – It returns the total days of that month. Input value of this method is timestamp of date. By default, the input value is timestamp of current time.


    • getPreviousDay( $timestamp="" ) - It returns timestamp of previous day of input value. Input value of this method is timestamp of date. By default, the input value is timestamp of current time.

  3. ComponentManager class (tool/ComponentManager.php):
    This is static class. This class is used to get component object or get information of component object. The following static methods are provided in this class:

    • getComponent( $enabler ) – return related component object which has same enabler name as the input value.

    • getComponentClassName( $enabler ) – return the class name of component object which has same enabler name as the input value.

    • getComponentScope( $enabler ) – return the scope value of component object which has same enabler name as the input value.

  4. PropertiesReader class (tool/PropertiesReader.php) :
    This is static class. It provides static method to read propterties file.
    • parse( $propertyFile ) – parse content of properties file and return result into PHP Array. The format of Array is $param[" <property name> "] = " <property value> " . If symbol " # " locates at beginning of the line, this line will be ignored to parse. That means that line is comment line.

    Here is an example:

    test.properties :
    # This is comment line.

    propertyName1 = this is value of property name 1.
    propertyName2 = this is value of property name 2.

    A.php :
    Include_once("tool/PropertiesReader.php");

    $parseResult = PropertiesReader::parse("test.properties");

    Foreach ($parseResult as $propertyName => $value)
          echo "The value of ‘$propertyName' is ‘$value' <br/>";

    The output result:
    The value of 'propertyName 1' is 'this is value of property name 1.'
    The value of 'propertyName 2' is 'this is value of property name 2.'

  5. StringUtil class (tool/StringUtil.php):
    This is static class. This class provides static method to process string.

    • addEscapeSlashes( $string ) – It returns string that " \ " are replaced to " \\ " and ' " ' are replaced to ' \" '.

    • shorten( $string , $numberOfCharacters , $shortenSymbol ) – It returns string which is shortened. By default, the number of character is 30 and symbol which is used to replace exceeding string is "…".

  6. Validator class (tool/Validator.php) :
    This is static class. This class is use for validation. It provides several static methods:

    • notEmpty( $parameters ) – Check the input string is empty or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> ") )

    • requiredString( $parameters ) - Check input string is "String" type (i.e. it does not contain number) or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> ") )

    • requiredNumber( $parameters ) - Check the input string is number (i.e. 0-9) or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> ") )

    • email( $parameters ) - Check the input string is correct email format or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> ") )

    • strLen( $parameters ) - Check the length of input string is in range of number (between minimum value and maximum value) or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> " , "min" => "<min length>" , "max" => "<max length>") ) Either "min" value or "max" value can be omitted. That means you can set "min" value only or "max" value only or both of them.

    • numRange( $parameters ) - Check the length of input number is in range of number (between minimum value and maximum value) or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> " , "min" => "<min length>" , "max" => "<max length>") ) Either "min" value or "max" value can be omitted. That means you can set "min" value only or "max" value only or both of them.

    • dateRange( $parameters ) - Check the length of input date is in range of dates (between start date and end date) or not. It returns true or false. The input parameter is in PHP Array format. (i.e. array("string" => " <input string> " , "min" => "<min length>" , "max" => "<max length>") ) Either "min" value or "max" value can be omitted. That means you can set "min" value only or "max" value only or both of them.

  7. XMLParser class (objectTool/XMLParser.php) :
    This is not static class. You should define new object to use it. This class is used to parse XML file into PHP Array. There are several methods in this class:

    • parse( $xml_file ) – parse XML file. In constructor of "XMLParser" class, it contains this method. As a result, we do not run this method after new this object. However, if you want to parse another XML file, you should run it again.

    • getData() – return PHP Array which is contained result of parsed XML file.

    Here is an example:

    testXMLParser.php
    <?php
    include_once("objectTool/XMLParser.php");

    /* Create new XMLParser object and parse "test.xml" */

    $parser = new XMLParser("test.xml");
    $resultInArray = $parser->getData();

    /* parse another xml file (another.xml) with same XMLParser object */

    $parser->parse("another.xml");
    $anotherResultInArray = $parser->getData();
    ?>