The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

VERSION

Version 1.13091122

SYNOPSIS

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

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

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

DESCRIPTION

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

METHODS

anOrA

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.

createGUID

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.

activeToggleIcon

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.

applyLanguage

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 );

captchaHTML

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

CCTypeFromNumber

This will be moved to legacy. Do not use.

createPin

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).

createPassword

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

dialogWindow

Return a modal window link or onclick javascript.

Possible Parameters:

  • width

    defaults to 800 (only pass int)

  • height

    deafults to jquery dialog deafult

  • id

    The id of the div you wish to populate the modals content with (Can not be used with queryString)

  • queryString

    The query after the queryHead used to populate the modal (Can not be used with id)

  • linkText

    If linkText is passed the return will the a the linkText wrappered in an anchor tag with the modal onclick

  • subModal

    Set this to 1 if you are passing queryString and wish to replace the current contents of the modal with the new query. This will only work if it is called from within another modal

  • loadingContent

    HTML passed as the "now loading..." type text as HTML. This is javascript wrappered with single tics escape them if you need to use them: \'

splitDirectory

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' );
    

fieldHash

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

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

fontCSS

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

formatDate

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:

  • format

    Format type to return. This is the only required field

  • epochTime

    epoch time which could be created with time()

  • monthMod

    Modify the current month ahead or behind. (Note: If your current day is 31st, and you mod to a month that has less than 31 days it will move to the highest day of that month)

  • dayMod

    Modify the current day ahead or behind.

  • minuteMod

    Modify the current minute ahead or behind.

  • dateSeparator

    This will default to '-', but can be changed to anything. (Note: Do not use this if you are returing SQLTime format)

  • GMTOffset

    Time zone modifier. Example: CST would be -5

  • numberTime

    Use an number translated time format (It looks like SQL without sperators) YYYYMMDDHHMMSS. HHMMSS will default to 000000 if not passed.

  • SQLTime

    Use an SQL time format as the incomming date and time.

  • ISO8601

    Use GMT based ISO8601 formated time as the incomming date and time.

The following types of formats are valid:

  • date

    mm-dd-yyyy

  • time

    hh:mmAM XXX

  • shortDate

    MMM DD YYYY (MMM is the three letter acrynomn for the month in caps)

  • fancyDate

    weekdayName, monthName dd[st|nd|rd] of yyyy

  • cookie

    cookie compatible date/time

  • apache

    apache web server compatible date/time

  • number

    yyyymmddhhmmss

  • dateTime

    mm-dd-yyyy hh:mmAM XXX

  • dateTimeFull

    mm-dd-yyyy hh:mm:ss XXX

  • SQL

    yyyy-mm-dd hh:mm:ss

  • epoch

    Standard epoch number

  • yearFirstDate

    yyyy-mm-dd

  • year

    yyyy

  • month

    mm

  • day

    dd

  • ISO8601

    YYYY-MM-DDTHH:MM:SSZ (The Z and the T are literal. This format will always return GMT, but when epoch, and SQLTime are passed, they should passed as server time because they will be converted to GMT on the based on $fws->{GMTOffset} site setting)

field

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 );

formatCurrency

Return a number in USD Format.

    print $fws->formatCurrency(33.55);

formatPhone

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

FWSButton

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

FWSHint

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

FWSIcon

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:

    icon
    class
    id
    width
    alt
    onClick

justFileName

Return just the file name when given a full file path

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

jqueryEnable

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.

loadingImage

Return the web path for the default loading image spinny.

logoutOnClick

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.

removeHTML

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>' );

startElement

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.

stateDropDown

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.

SQLDate

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' );

truncateContent

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    => '...',
    );

urlEncode

Encode a string to make it browser url friendly.

    print $fws->urlEncode( $someString );

urlDecode

Decode a string to make it potentially browser url unfriendly.

    print $fws->urlEncode( $someString );

endElement

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 );

convertUnicode

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

hex2chr

Convert hex to its ascii character.

AUTHOR

Nate Lewis, <nlewis at gnetworks.com>

BUGS

Please report any bugs or feature requests to bug-fws-v2 at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FWS-V2. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

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

    perldoc FWS::V2::Format

You can also look for information at:

LICENSE AND COPYRIGHT

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 http://dev.perl.org/licenses/ for more information.