View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Nate Lewis > FWS-V2 > FWS::V2::Format



Annotate this POD


New  1
Open  0
View/Report Bugs
Module Version: 1.13091122   Source  


FWS::V2::Format - Framework Sites version 2 text and html formatting


Version 1.13091122


    use FWS::V2;
    my $fws = FWS::V2->new();

    my $tempPassword = $fws->createPassword( lowLength => 6, highLength => 8);

    my $newGUID = $fws->createGUID();


Framework Sites version 2 methods that use or manipulate text either for rendering or default population.



Return an 'a' or an 'an' based on what the next word is.

    # retrieve a guid
    print "This is " . $fws->anOrA( 'antalope' ) . " antalope or " . $fws->anOrA( 'cantalope' ) . " cantalope.\n':

    # return: This is an antalope or a cantalope.


Return a non repeatable Globally Unique Identifier to be used to populate the guid field that is default on all FWS tables.

    # retrieve a guid to use with a new record
    my $guid = $fws->createGUID();

In version 2 all GUID's have a prefix, if not specified it will be set to 'd'. There should be no reason to use another prefix, but if you wish you can add it as the only parameter it will be used. In newer versions of FWS the prefix will eventually be deprecated and is only still present for compatibility.


Create a on off admin lightbulb for an item that will work if you are logged in as an edit mode editor role. Pass a data hash, and append ajaxUpdateTable if it is not updating the standard data table.


Apply the langague to a hash, so it will return as if the current sessions language is returned as the default keys.

    # retrieve a guid to use with a new record
    %dataHash = $fws->applyLanguage( %dataHash );


Return the default captcha html to be used with isCaptchaValid on its return.


This will be moved to legacy. Do not use.


Return a short pin for common data structures.

    # retrieve a guid to use with a new record
    my $pin = $fws->createPin();

This pin will be checked against the directory, and profile tables to make sure it is not repeated and by default be 6 characters long with only easy to read character composition (23456789QWERTYUPASDFGHJKLZXCVBNM).


Return a random password or text key that can be used for temp password or unique configurable small strings.

    # retrieve a password that is 6-8 characters long and does not contain commonly mistaken letters
    my $tempPassword = $fws->createPassword(
                    composition     => "abcedef1234567890",
                    lowLength       => 6,
                    highLength      => 8);

If no composition is given, a vocal friendly list will be used: qwertyupasdfghjkzxcvbnmQWERTYUPASDFGHJKZXCVBNM23456789


Return a modal window link or onclick javascript.

Possible Parameters:


Return directory with the last part of the directory split into two parts. If a directory passed into it ends with a slash, then it will be removed.

    # this will return /first/part/su/supertsplitter
    print $fws->splitDirectory( directory => '/first/part/supersplitter' );


Return a hash of formValues passed to the current post that are not used for the FWS core.

    my %formFieldsPopulated = $fws->fieldHash();


Return css that will set the default FWS font for inline use before CSS is capable of being applied.


Return the date time in a given format. By passing epochTime, SQLTime you can do a time conversion from that date/time to what ever format is set to. If you do not pass epoch or SQL time the server time will be used.

    # get the current Date in SQL format
    my $currentDate = $fws->formatDate( format => 'date' );
    # convert SQL formated date time to a human form
    my $humanDate = $fws->formatDate( SQLTime => '2012-10-12 10:09:33', format => 'date' );

By passing minuteMod, monthMod or dayMod you can adjust the month forward or backwards by the given number of months or days

    # 3 months from today (negative numbers are ok)
    my $threeMonths = $fws->formatDate( format => 'date', monthMod => 3 );

Multilingual support: French date formats will be used for 'fancyDate' and 'date' if the language() is set to FR.

Possible Parameters:

The following types of formats are valid:


Return a field based on dynamic language and falling back to the default if the language specific value isn't available.

    print $fws->field( 'title', %dataHash );


Return a number in USD Format.

    print $fws->formatCurrency(33.55);


Return a phone number in a specific format.

    print $fws->formatPhone( format => 'full', phone => '555-367-5309' );

Valid formats:

number: 1234567890

full: (123) 456-7890

dots: 123.456.7890


Create a button that is default to JQuery UI class structure. You can pass style, class, name, id, value and onClick keys.


Return a FWS Hint HTML for roll over hint icons or links.


Return just the file name when given a full file path

       $valueHash{html} .= $fws->FWSIcon( icon => 'blank_16.png' );

You can pass the following keys:



Return just the file name when given a full file path

    my $fileName = $fws->justFileName( '/this/is/not/going/to/be/here/justTheFileName.jpg' );


Add FWS core distribution jQuery modules and corresponding CSS files to the CSS and JS cached files. These are located in the /fws/jquery directory. The naming convention for jQuery files are normalized and only the module name and version is required.

    # if the module you were loadings file name is:
    # jquery-WHATEVERTHEMODULEIS-1.1.1.min.js
    # it would be loaded via jqueryEnable as follows:
    $fws->jqueryEnable( 'WHATEVERTHEMODULEIS-1.1.1' );

This method ensures jQuery files are only loaded once, and the act of any jQuery module being enabled will auto-activate the core jQuery library. They will be loaded in the order they were called from any element in the rendering process.


Return the web path for the default loading image spinny.


Return the on click javascript for a logout button. You can pass landingPage key if you want it to land somewhere besides the current page. This is also trigger the facebook logout.


Return a wrapped link of data hash that can be linked to. This supports friendlies, forced or not, and url linking.


Create a link to a popup window or just the onclick. Passing queryString is requried and pass linkHTML if you would like it to be a link.

    $valueHash{html} .= $fws->popupWindow(queryString=>'p=somePage',$linkHTML=>'Click Here to go to some page');

NOTE: This should only be used in the context of the FWS Administration, and is only here as a reference for modifiers of the admin.


Return a string minus anything that is in < >.

    $safeForText = $fws->removeHTML( '<a href="somelink.html">This is the text that will return without the anchor</a>' );


Return a the complement to endElement having the default title control and class labeling.

    $valueHash{html} .= $fws->startElement( %dataHash );
    $valueHash{html} .= $fws->endElement( %dataHash );

If there is no dataHash to pass, you can set its the keys elementClass, title, and disableTitle to control its appearence.


Return a dropdown for all US States, passining it (current, class, id, name, style, topOption) TopOption if passed will be the text that is displayed for the option, but the value will be blank.


Return a date string in SQL format if it was passed ass SQL format already, or convert it if it was sent as mm-dd-yyyy.

    my $SQLDate = $fws->SQLDate( '2012-02-03' );


Return content based on nearest ended word to the length parameter.

    print $fws->truncateContent(
        content     => 'this is some long content I want just a preview of.',
        length      => 10, 
        postText    => '...',


Encode a string to make it browser url friendly.

    print $fws->urlEncode( $someString );


Decode a string to make it potentially browser url unfriendly.

    print $fws->urlEncode( $someString );


Return the complement to startElement() having the default by placing the appropriate close divs created in startElement().

    $valueHash{html} .= $fws->startElement( %dataHash );
    $valueHash{html} .= $fws->endElement( %dataHash );


Convert from unicode charcters from web services to a standard character.


Convert hex to its ascii character.


Nate Lewis, <nlewis at>


Please report any bugs or feature requests to bug-fws-v2 at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc FWS::V2::Format

You can also look for information at:


Copyright 2013 Nate Lewis.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: