UberBots Website Documentation

Function Documentation - skinParser.php

  • parseSkin

    Parses a skin file.

    Description

    string parseSkin ( array $replace , string $skinFile [, array $cases] )

    This function will return the contents of the skin file as declared in skinFile, and will parse it according to the first and last parameters.

    Parameters

    • replace

      This is an associative array which contains information for the skin parser to replace. For each element in the array, it will search for the key, and replace it with the value.

    • skinFile

      This is the skin file which will be parsed. When using this function, do not add the file extension. The function will append the extension .html to the argument and look for that file.

    • cases

      This argument is optional. When used, it should be an associative array. The key should the name of the case, and the value should be a boolean of the state: either true or false.

    Return Values

    This function returns the contents of the skin file, replacing parts as defined by the arguments.

    Notes

    This function should be used to call skins on the PHP end of the OmniPage system. It allows for dynamic content in the HTML skin files. Using this function will open up a lot of possibilities in the coding and making of a module.

    The function takes two arguments: things to replace and if statement information. Both of these things have a special syntax in the skin file. For something to be replaced by an element in the first parameter, it should be like: {{foo}}. On the PHP end, you want an element of the first array to have a key of "foo" and a value ($array['foo'] = "bar";).

    In order to define an IF statement in the skin, it should be declared like so:

    
    [[IF foo]]
    //statements if true go here
    [[END IF]]
    

    On the PHP end, the array passed as the second parameter should contain an element with a key: "foo" and a boolean value ($array['foo'] = TRUE;).

    Examples

    
    //usage with only first two parameters
    //construct replace array 
    $replace['one'] = 1;
    $replace['two'] = 2;
    $replace['three'] = 3;
    //call parseSkin function
    return parseSkin($replace,'numbers');
    

    Now, an example of what the 'numbers' skin file could look like.

    
    <h5>Numbers</h5>
    {{one}} <br/>
    {{two}} <br/>
    {{three}}
    

    This will render as:

    Numbers
    1
    2
    3


    
    //usage with all three parameters
    //construct replace array
    $replace['one'] = 1;
    $replace['two'] = 2;
    $replace['three'] = 3;
    //construct case array
    $case['foo'] = TRUE;
    $case['bar'] = (1<0);
    //call parseSkin
    return parseSkin($replace,'numbers',$case);
    

    What the numbers skin file would look like:

    
    <h5>Numbers</h5 >
    [[IF foo]]
    {{one}} <br/>
    {{two}} <br/>
    [[END IF]]
    {{three}} <br/>
    [[IF bar]]
    <p>paragraph</p>
    [[END IF]]
    <p>end</p>
    

    This will render as:

    Numbers
    1
    2
    3

    end


    Top of Page

Upcoming Events

Events in the next week:

No upcoming events.

Connect With Us

Follow us on Twitter! Connect with us on Facebook! Add us to your circles on Google+