Framework  3.9
functions.inc File Reference

Go to the source code of this file.

Namespaces

 Fakoli
 Framework.
 

Functions

 checkRole ($role, $account=null)
 Check whether the user has one of a specified set of roles. More...
 
 hasRole ($role, $account=null)
 Determine whether a user has a specific role explicitly set. More...
 
 filterByRole ($items, $field)
 Filter the given list, retaining only the objects that match the current user's role profile in the given parameter. More...
 
 formatAddress ()
 Utility function to nicely format addresses, etc. More...
 
 formatCurrency ($amount)
 Utility function to format currency using $ and , and stuff. More...
 
 formatDate ($date)
 Utility function to format date (no time component). More...
 
 formatMonthYear ($date)
 
 formatDateShort ($date)
 Utility function to format date in short form (MM/DD/YYYY), with no time component. More...
 
 formatDateLong ($date)
 
 formatTimestamp ($ts)
 Utility function to format readable date from a timestamp (no time component). More...
 
 formatTimestampShort ($ts)
 
 getMonthDays ($m, $y)
 Returns the number of days in the specified month. More...
 
 getMonthWeekDays ($month, $year)
 Get the number of week days in the specified month. More...
 
 formatTime12 ($time)
 Format a time in 12 hour clock, no seconds. More...
 
 formatDateTime12 ($time)
 Format a date and time in 12 hour clock, no seconds. More...
 
 formatDateTime12Hr ($datetime)
 
 formatStartDateToEndDate ($start, $end)
 
 format_phone ($phone)
 
 now ()
 Returns the current time and date in a database compatible format. More...
 
 today ()
 Returns today as a string. More...
 
 jsSafe ($str, $escapeEntities=false)
 Utility function to escape a string correctly for use in a Javascript client-side call. More...
 
 htmlsafe ($str)
 
 cleanHTMLTags ($str)
 
 HTMLToText ($html)
 
 cleanQuotes ($str)
 
 printMIMETypeList ($types)
 Outputs the MIME type list based on an array of MIME types. More...
 
 getDocType ($doc)
 Returns a human-readable type name for a document, based on the file extension of the supplied file name. More...
 
 getDocSize ($doc)
 Returns the file size in Kb for a document. More...
 
 getDocMimeType ($name)
 
 getDocIcon ($doc)
 
 checkNumeric ($p)
 Security helper function. More...
 
 checkNumericList ($p, $separator=",")
 Security helper function. More...
 
 checkIdentifier ($p)
 Security helper function. More...
 
 checkIdentifierList ($p)
 Security helper function. More...
 
 checkValidEmail ($e)
 Security helper function. More...
 
 checkValidDate ($d)
 Security helper function. More...
 
 checkValidDateTime ($d)
 Security helper function. More...
 
 checkPlainGUID ($guid)
 Checkes whether the provided string is an undecorated GUID (i.e. More...
 
 checkGUID ($guid)
 Checks whether the provided string is in a valid form for a GUID. More...
 
 color ($count)
 Utility function to nicely format addresses, etc. More...
 
 ellipsis ($txt, $max, $wholeWord=false)
 Truncate the supplied text at the given maximum length. More...
 
 rteSafe ($strText)
 
 firstSentence ($text)
 Returns the first sentence of the supplied text. More...
 
 stripHTML ($text)
 
 parseMultiParam ($collection, $param)
 Parse out multiple values from the provided collection that have the same root name, and return the results in an array. More...
 
 option ($value, $text, $sel="")
 Write out an option tag, marking as selected if applicable. More...
 
 str_option ($value, $text, $sel="")
 Write out an option tag to a string, marking as selected if applicable. More...
 
 registerRedirectLogCallback ($callback)
 
 redirect ($page)
 Simplified redirect. More...
 
 getCleanQueryString ()
 Returns the query string for the current page, cleaned of any Fakoli-related navigation parameters. More...
 
 trace ($msg, $lvl=3, $callStack=null)
 Send output to the trace log. More...
 
 getScaledSize ($size, $decimal_places=1)
 Get human-readable file size from raw number of bytes. More...
 
 roundFormat ($num, $abbrev=false)
 
 getIcon ($file)
 Retrieves a graphic icon appropriate for the given file. More...
 
 includeRemote ($host, $file)
 Includes the contents of the given remote file, with any relative src or href references converted to absolute references. More...
 
 getRemote ($url, $username="", $password="")
 Retrieve the contents of the remote file at the given URL. More...
 
 jsonRequest ($url, $params=array())
 Make a simple GET request to a JSON-return RESTful API, passing the supplied parameters. More...
 
 saveRemote ($url, $saveAs)
 Retreive the contents of the remote file at the given URL and save it to the specified location on the local disk. More...
 
 canonicalizeURL ($url)
 Takes a URL and converts relative URLs to absolute URLs for the current site. More...
 
 sanitizePath ($path)
 Sanitize a file path, removing relative path sections and ensuring the correct directory separator is used throughout. More...
 
 postRemote ($url, $data=null, $timeout=30)
 Make a POST request to a remote URL, returning the results. More...
 
 postRemoteXML ($url, $xml, $timeout=30)
 
 getRemoteHeaders ($url)
 Retrieve the HTTP headers for the specified remote URL (excluding the body). More...
 
 wrapURL ($url, $width=120)
 Break a URL at a given string position. More...
 
 codify ($name)
 Takes a text string and converts it into a code-compliant format, suitable for use as a variable name or identifier. More...
 
 prettify ($name)
 Takes a variable or field name and converts it into a human-readable version (assuming that the original contains human-readable words, of course). More...
 
 pluralize ($text, $count=0)
 Takes a singular string and makes it plural. More...
 
 formatAsHTML ($text)
 Takes a string and formats it for display as HTML, removing any HTML tags it contains, and converting carriage returns to br tags. More...
 
 startsWith ($text, $start)
 Tests whether a string starts with a given sub-string. More...
 
 endsWith ($text, $end)
 Tests whether a string ends with the given sub-string. More...
 
 stripHTMLTags ($text)
 Removes all HTML tags from the specified string. More...
 
 ordinalSuffix ($n, $sup=false)
 Adds the english ordinal suffix to a number. More...
 
 makeURL ($uri)
 Ensures that the http:// protocol specifier prefix is present in the supplied string. More...
 
 formatCheckListItemsforView ($options, $items)
 For dataitems that are rendered as CheckListFieldRenderer, this function converts the comma-delimited list of items for display. More...
 
 baseURI ($uri=null)
 Returns the base URI for the current script, with the query string removed. More...
 
 appendToQueryString ($qs, $params)
 Appends the specified parameters to the supplied query string. More...
 
 registerURLRewriteParameters ()
 Register any URL rewrite parameters that should be excluded from query string reformatting. More...
 
 getFullQueryString ($includePOST=true)
 Generates a query string containing the values passed to this page. More...
 
 toJSArray ($items, $field="")
 
 prettyPrintJSON ($json)
 Format the JSON in the supplied string to be more human-readable. More...
 
 makeRandomString ($len)
 Creates a randomized string of characters. More...
 
 arrayFilterKey ( $input, $callback)
 Filter an array based on applying the specified callback to the keys. More...
 
 ajaxReturn ($msg=null)
 Returns a string output and exits the script cleanly. More...
 
 getMIMEType ($filename)
 
 array_remove_keys ($array)
 Remove specified keys from the given array. More...
 
 xmlEntities ($string)
 Function to provide html to XML entity renaming. More...
 
 encode7bit ($text)
 Encode text to 7-bit clean format, suitable for mail headers. More...
 
 GUID ()
 Generates a version 4 GUID. More...
 
 plainGUID ()
 Generates a version 4 GUID with no punctutation. More...
 
 getBacktrace ($ignore=2)
 Returns a formatted backtrace suitable for debugging output. More...
 
 luhnTest ($num)
 Performs a Luhn validity test for credit card or IMEI numbers. More...
 
 countMatchingElements ($a, $b)
 Determines the number of items that two comma-separated lists have in common. More...
 
 printIncludes ($html=true, $return=false)
 Outputs a list of all included files. More...
 
 replaceValues ($substitutions, $target)
 Given an array of pairs of old and new values, replace all instances of old values with new values in the target string. More...
 
 fopen_utf8 ($filename)
 Opens a text file, detects the encoding, inteprets the BOM if present, attaches a stream filter to convert to UTF-8. More...
 
 fgetcsv_noBOM ($fp)
 
 tempdir ($dir=null, $prefix='tmp_', $mode=0700, $maxAttempts=1000)
 Creates a random unique temporary directory, with specified parameters, that does not already exist (like tempnam(), but for dirs). More...
 

Variables

 $image_types = array( "image/jpeg", "image/gif", "image/x-png", "image/pjpeg" )
 MIME types allowable for image uploads. More...
 
 $_redirectLogCallback = null
 
 $traceLevels
 
 $_icons
 
 $__urlRewriteParams = array()