NAME
FWS::V2::Format - Framework Sites version 2 text and html formatting
VERSION
Version 0.004
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
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);
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
dateTime
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->dateTime(format=>'date');
#
# convert SQL formated date time to a human form
#
my $humanDate = $fws->dateTime(SQLTime=>'2012-10-12 10:09:33',format=>'date');
By passing 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->dateTime(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.
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: EST would be -5
SQLTime
Use an SQL time format as the incomming date and time.
The following types of formats are valid:
date
mm-dd-yyyy
time
hh:mmAM XXX
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
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
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.
popupWindow
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, 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=>'...');
FWS ADMIN METHODS
These methods are used only by FWS Admin maintainers. They should not be used out of the context of the FWS Admin as they could change without warning.
adminField
Return an edit field or field block for the FWS Admin. The adminField method is a very configurable tool used by the FWS administration maintainers.
#
# Create a admin edit field
#
$valueHash{'html'} .= $fws->adminField( %paramHash );
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.
Passable Keys:
fieldType
fieldName
fieldValue
fieldOptions
unilingual: [1|0]
ajaxUpdateGUID
ajaxUpdateParentId
id
class
style
onSaveComplete
updateType
guid
onKeyDown
note
afterFieldHTML
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);
adminPageHeader
Return a standard HTML admin header for admin elements that open in new pages.
#
# Header for an admin page that opens in a new window
#
$valueHash{'html'} .= $fws->adminPageHeader( name =>'Page Name in the upper right',
rightContent =>'This will show up on the right,
usually its a saving widget',
title =>'This is title on the left, it will
look just like a panel title',
icon =>'somethingInTheFWSIconDirectory.png');
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.
tabs
Return jQueryUI tab html. The tab names, tab content, tinyMCE editing field name, and any javascript for the tab onclick is passed as arrays to the method.
#
# add the data to the tabs and panels to the HTML
#
$valueHash{'html'} .= $self->tabs( id =>'theIdOfTheTabContainer',
tabs =>[@tabs],
tabContent =>[@tabContent],
tabJava =>[@tabJava],
# html and file tab support
tabType =>[@tabType], # file, html or leave empty for standard panel
# setting type will overwrite content and java provided
tabFields =>[@tabFields], # field your updating
guid =>'someGUID', # guid your updating
# optional if your talking to a non-data table
tabUpdateType =>[@tabUpdateType], # defaults to AJAXExt
table =>'data', # defaults to data
# for file type only (required)
currentFile =>[@currentFile], #
);
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. In future versions this will be replaced with a hash array style paramater to make this less cumbersome, but this will be avaiable for legacy controls.
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:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2012 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.