Source for file liberty_lib.php
Documentation is available at liberty_lib.php
// ================== Liberty Plugin Parsing ==================
* This crazy function will parse all the data plugin stuff found within any
* @param array $pData Data to be parsed
global $gLibertySystem, $gBitSystem;
// note: $curlyTags[0] is the complete match, $curlyTags[1] is plugin name, $curlyTags[2] is plugin arguments
preg_match_all( "/\{\/?([A-Za-z0-9]+)([^\}]*)\}/", $pData, $curlyTags, PREG_OFFSET_CAPTURE );
if( count( $curlyTags[0] ) ) {
// if TRUE, replace only CODE plugin, if false, replace all other plugins
// Process plugins in reverse order, so that nested plugins are handled from the inside out.
$i = count( $curlyTags[0] ) - 1;
$plugin_start = $curlyTags[0][$i][0];
$plugin = $curlyTags[1][$i][0];
// Work out where the plugin starts. This can not be done using the
// positional data from $curlyTags since the position might have
// changed since the last cycle. We therefore need to determine the
// position direclty. - xing - Thursday Nov 01, 2007 22:55:10 CET
//$pos = $curlyTags[0][$i][1];
$pos = strpos( $pData, $plugin_start );
// hush up the return of this in case someone uses curly braces to enclose text
$pluginInfo = $gLibertySystem->getPluginInfo( @$gLibertySystem->mDataTags[$dataTag] ) ;
// only process a standalone unpaired tag or the start tag for a paired tag
if( empty( $paired_close_tag_seen[$dataTag] ) || $paired_close_tag_seen[$dataTag] == 0 ) {
$paired_close_tag_seen[$dataTag] = 1;
$paired_close_tag_seen[$dataTag] = 0;
if(( empty( $pluginInfo['requires_pair'] ) && ( strtolower( $plugin_start ) != '{/'. $dataTag . '}' ))
|| ( strpos( $plugin_start, ' ' ) > 0 )
|| ( strtolower( $plugin_start ) == '{'. $dataTag. '}' && !$paired_close_tag_seen[$dataTag] )
// when in CODE parsing mode, replace only CODE plugins
( ( $code_first && ( $dataTag == 'code' ) )
// when NOT in CODE parsing mode, replace all other plugins
|| ( !$code_first && ( $dataTag <> 'code' ) )
&& !empty( $gLibertySystem->mDataTags[$dataTag] )
&& ( $loadFunc = $gLibertySystem->getPluginFunction( $gLibertySystem->mDataTags[$dataTag], 'load_function' ) )
if( $pluginInfo['requires_pair'] ) {
$plugin_end = '{/'. $plugin. '}';
$plugin_end2 = '{'. $plugin. '}';
if( ( $pos_end2 > 0 && $pos_end2 > 0 && $pos_end2 < $pos_end ) || $pos_end === FALSE ) {
$plugin_end = $plugin_end2;
$pos_end = $pos + strlen( $curlyTags[0][$i][0] );
// Extract the plugin data
$plugin_data_len = $pos_end - $pos - strlen( $curlyTags[0][$i][0] );
$plugin_data = substr( $pData, $pos + strlen( $plugin_start ), $plugin_data_len );
// Construct argument list array
if( preg_match( '/^\(.*=>.*\)$/', $paramString ) ) {
$paramString = preg_replace( '/[\(\)]/', '', $paramString );
//we have the old style parms like {CODE (in=>1)}
foreach( $params as $param ) {
// the following str_replace line is to decode the > char when html is turned off
// perhaps the plugin syntax should be changed in 1.8 not to use any html special chars
if( isset ( $parts[0] ) && isset ( $parts[1] ) ) {
$name = trim( $parts[0] );
$arguments[$name] = trim( $parts[1] );
$paramString = trim( $curlyTags[2][$i][0], " \t()" );
$paramString = str_replace(""", '"', $paramString);
if( $ret = $loadFunc( $plugin_data, $arguments, $pCommonObject, $pParseHash )) {
// don't modify data if $pos is FALSE
// if we are in CODE parsing mode and list is done, switch to 'parse other plugins' mode and start all over
if( ( $code_first ) && ( $i < 0 ) ) {
$i = count( $curlyTags[0] ) - 1;
* This function replaces pre- and no-parsed sections with unique keys and
* saves the section contents for later reinsertion. It is needed by
* parse_data_plugins() to extract sections that don't require parsing
* @param array $pData data that might contain ~np~ or ~pp~ strings
* @param array $preparsed array that is updated by refrerence with key and data that needs to be substituted later
* @param array $noparsed array that is updated by refrerence with key and data that needs to be substituted later
// Find all sections delimited by ~pp~ ... ~/pp~
if( count( $preparse[0] )) {
$pData = str_replace( "~pp~$pp~/pp~", $aux['key'], $pData );
// now remove <pre>...<pre> sections
preg_match_all( "!(<pre[^>]*>)(.*?)(</pre[^>]*>)!si", $pData, $preparse );
if( count( $preparse[0] )) {
foreach( $preparse[2] as $key => $pre ) {
$pData = str_replace( $preparse[1][$key]. $pre. $preparse[3][$key], $aux['key'], $pData );
// and now ~np~...~/np~ sections
if( count( $noparse[0] )) {
$pData = str_replace( "~np~$np~/np~", $aux['key'], $pData );
// ================== Liberty Plugin Helper ==================
* pass in the plugin paramaters and out comes a hash with usable styling information
* @param array $pParamHash
* @return hash full of styling goodies
$ret['style'] = $ret['description'] = '';
if( !empty( $pParamHash ) && is_array( $pParamHash )) {
// if align is right and text-align isn't set, we'll align that right as well
if( empty( $pParamHash['text-align'] ) && ( !empty( $pParamHash['align'] ) && $pParamHash['align'] == 'right' || !empty( $pParamHash['align'] ) && $pParamHash['align'] == 'right' )) {
$pParamHash['text-align'] = 'right';
// this defines what the wrapper should be - div or span
// if someone sets this value manually, they know what they are doing
if( empty( $pParamHash['wrapper'] )) {
$pParamHash['wrapper'] = 'div';
// set to 'span' if desired
$pParamHash['wrapper'] = 'span';
// force display:block to the "div" if not specified otherwise
if( empty( $pParamHash['display'] )) {
$pParamHash['display'] = "inline-block";
foreach( $pParamHash as $key => $value ) {
$ret['style'] .= "{ $key}:{ $value}; ";
$ret['style'] .= "{ $key}:{ $value}px; ";
$ret['style'] .= "{ $key}:{ $value}; ";
// align and float are special
if( $value == 'center' || $value == 'middle' ) {
$ret['style'] .= 'text-align:center;';
$ret['style'] .= "float:{$value};";
// default just gets re-assigned
// ================== Liberty Service Functions ==================
* liberty_content_load_sql
* @return content load sql
global $gBitSystem, $gBitUser;
$hasPerm = ( is_object( $pObject ) && isset ( $pObject->hasUserPermission )) ? $pObject->hasUserPermission( 'p_liberty_edit_all_status' ) : $gBitUser->hasPermission( 'p_liberty_edit_all_status' );
if( $gBitSystem->isFeatureActive( 'liberty_display_status' ) && !$hasPerm ) {
if(( is_object( $pObject ) && !empty( $pObject->mType['content_type_guid'] ) && $pObject->mType['content_type_guid'] == 'bitcomment' )
|| ( !empty( $pParamHash['include_comments'] ) && $pParamHash['include_comments'] == 'y' )) {
// if we are getting a list of comments then lets check the owner of the comment root and the owner of the content
INNER JOIN `". BIT_DB_PREFIX. "liberty_comments` lcoms ON (lc.`content_id` = lcoms.`content_id`)
INNER JOIN `". BIT_DB_PREFIX. "liberty_content` rlcs ON( rlcs.`content_id`=lcoms.`root_id` )";
$ret['where_sql'] = " AND lc.`content_status_id` < 100 AND ( ( (rlcs.`user_id` = '". $gBitUser->getUserId(). "' OR lc.`user_id` = '". $gBitUser->getUserId(). "') AND lc.`content_status_id` > -100) OR lc.`content_status_id` > 0 )";
// let owner see any of their own content with a status > -100
$ret['where_sql'] = " AND lc.`content_status_id` < 100 AND ( (lc.`user_id` = '". $gBitUser->getUserId(). "' AND lc.`content_status_id` > -100) OR lc.`content_status_id` > 0 )";
// Make sure owner comes out properly for all content
$ret['select_sql'] = " , lc.`user_id` AS owner_id";
* liberty_content_list_sql
* @param array $pParamHash
* @param array $pParamHash['enforce_status'] will add joins to status_id even if user is admin
* @param array $pParamHash['min_status_id'] one less than the minimum status a content can have to be included
* @param array $pParamHash['max_status_id'] one more than the maximum status a content can have to be included
* @param array $pParamHash['min_owner_status_id'] one less than the mimimum status a content can have to be included that is owned by the requester
* @return content list sql
global $gBitSystem, $gBitUser;
// enforce_status will require the status limit on everyone including admin and thus we can ignore permission checks
if( !isset ( $pParamHash['enforce_status'] )) {
$hasPerm = ( is_object( $pObject ) && method_exists( $pObject, 'hasUserPermission' )) ? $pObject->hasUserPermission( 'p_liberty_edit_all_status', FALSE ) : $gBitUser->hasPermission( 'p_liberty_edit_all_status' );
// default show content with status between 0 and 100;
$min_status_id = isset ( $pParamHash['min_status_id'] ) && ( @BitBase::verifyId( $pParamHash['min_status_id'] ) || $pParamHash['min_status_id'] === 0 ) ? $pParamHash['min_status_id'] : 0;
$max_status_id = isset ( $pParamHash['max_status_id'] ) && ( @BitBase::verifyId( $pParamHash['max_status_id'] ) || $pParamHash['max_status_id'] === 0 ) ? $pParamHash['max_status_id'] : 100;
// let owner see any of their own content with a status > -100
$min_owner_status_id = isset ( $pParamHash['min_owner_status_id'] ) && ( @BitBase::verifyId( $pParamHash['min_owner_status_id'] ) || $pParamHash['min_owner_status_id'] === 0 ) ? $pParamHash['min_owner_status_id'] : - 100;
if( $gBitSystem->isFeatureActive('liberty_display_status') && !$hasPerm ) {
if(( is_object( $pObject ) && !empty( $pObject->mType['content_type_guid'] ) && $pObject->mType['content_type_guid'] == 'bitcomment' )
|| ( !empty( $pParamHash['include_comments'] ) && $pParamHash['include_comments'] == 'y' )) {
// if we are getting a list of comments then lets check the owner of the comment root and the owner of the content
LEFT OUTER JOIN `". BIT_DB_PREFIX. "liberty_comments` lcoms ON (lc.`content_id` = lcoms.`content_id`)
LEFT OUTER JOIN `". BIT_DB_PREFIX. "liberty_content` rlcs ON( rlcs.`content_id`=lcoms.`root_id` )";
" AND lc.`content_status_id` < ". $max_status_id.
( (rlcs.`user_id` = '". $gBitUser->getUserId(). "' OR lc.`user_id` = '". $gBitUser->getUserId(). "') AND lc.`content_status_id` > ". $min_owner_status_id. ")
OR lc.`content_status_id` > ". $min_status_id. "
" AND lc.`content_status_id` < ". $max_status_id.
(lc.`user_id` = '". $gBitUser->getUserId(). "' AND lc.`content_status_id` > ". $min_owner_status_id. ")
OR lc.`content_status_id` > ". $min_status_id. "
* liberty_content_preview
global $gBitSystem, $gBitUser;
&& @BitBase::verifyId( $_REQUEST['content_status_id'] )) {
$pObject->mInfo['content_status_id'] = $_REQUEST['content_status_id'];
&& @BitBase::verifyId( $_REQUEST['owner_id'] )) {
$pObject->mInfo['owner_id'] = $_REQUEST['owner_id'];
* liberty_content_display
* @param array $pParamHash
if( $pObject->isValid() ) {
global $gBitUser, $gBitSystem;
// make sure user has appropriate permissions to view this content
if( !empty( $pParamHash['perm_name'] )) {
$pObject->verifyViewPermission();
* @param array $pParamHash
// ================== Liberty File Processing Functions ==================
* Process uploaded files. Will automagically generate thumbnails for images
* @param array $pFileHash Data require to process the files
* @param array $pFileHash['name'] (required) Name of the uploaded file
* @param array $pFileHash['type'] (required) Mime type of the file uploaded
* @param array $pFileHash['dest_branch'] (required) Relative path where you want to store the file (trailing slash required)
* @param array $pFileHash['tmp_name'] (required) Absolute path to file including file name
* @param boolean $pFileHash['thumbnail'] (optional) Set to FALSE if you don't want to generate thumbnails
* @param array $pFileHash['thumbnail_sizes'] (optional) Decide what sizes thumbnails you want to create: icon, avatar, small, medium, large
* @param boolean $pMoveFile (optional) specify if you want to move or copy the original file
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
// Check for evil file extensions that could be execed on the server
$pFileHash['type'] = 'text/plain';
$pFileHash['name'] = $pFileHash['name']. '.txt';
list ( $pFileHash['name'], $pFileHash['type'] ) = $gBitSystem->verifyFileExtension( $pFileHash['tmp_name'], $pFileHash['name'] );
//$pFile['type'] = $gBitSystem->verifyMimeType( $pFile['tmp_name'] );
$ext = strrpos( $pFileHash['name'], '.' );
// clean out crap that can make life difficult in server maintenance
$cleanedBaseName = preg_replace( '/[&\%:\/\\\]/', '', substr( $pFileHash['name'], 0, $ext ) );
$pFileHash['dest_base_name'] = $cleanedBaseName;
$pFileHash['source_file'] = $pFileHash['tmp_name'];
// lowercase all file extensions
$pFileHash['name'] = $cleanedBaseName. strtolower( substr( $pFileHash['name'], $ext ) );
// Thumbs.db is a windows My Photos/ folder file, and seems to really piss off imagick
if( !empty( $canThumbFunc ) && $canThumbFunc( $pFileHash['type'] ) && $pFileHash['name'] != 'Thumbs.db' ) {
* liberty_process_archive
* @param array $pFileHash
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
// sanity check: make sure tmp_name isn't empty. will scan / if it is
if( !is_array( $pFileHash ) || empty( $pFileHash['tmp_name'] ) || empty( $pFileHash['name'] ) ) {
// if the file has been uploaded using a form, we'll process the uploaded
// file directly. if it's been ftp uploaded or some other method used,
// we'll copy the file. in the case of xuploaded files, the files have been
// processed but don't have to be copied
if( empty( $pFileHash['preprocessed'] ) && !is_uploaded_file( $pFileHash['tmp_name'] ) && is_file( $pFileHash['tmp_name'] ) ) {
$copyFile = tempnam( !empty( $tmpDir ) ? $tmpDir : '/tmp', $pFileHash['name'] );
copy( $pFileHash['tmp_name'], $copyFile );
$pFileHash['tmp_name'] = $copyFile;
$dir = dirname( $pFileHash['tmp_name'] );
if( is_file( $pFileHash['tmp_name'] ) ) {
$baseDir .= $gBitUser->mUserId;
$destDir = $baseDir. '/'. basename( $pFileHash['tmp_name'] );
// this if is very important logic back so subdirs get processed properly
// Some commands don't nicely support extracting to other directories
$shellResult = shell_exec( "unrar x \"{$pFileHash['tmp_name']}\" \"$destDir\"" );
case 'tgz': $compressFlag = '-z'; break;
case 'bz2': $compressFlag = '-j'; break;
default: $compressFlag = ''; break;
$shellResult = shell_exec( "tar -x $compressFlag -f \"{$pFileHash['tmp_name']}\" -C \"$destDir\"" );
$shellResult = shell_exec( "unzip \"{$pFileHash['tmp_name']}\" -d \"$destDir\"" );
$shellResult = shell_exec( "unstuff -d=\"$destDir\" \"{$pFileHash['tmp_name']}\" " );
$shellResult = shell_exec( "unzip \"{$pFileHash['tmp_name']}\" -d \"$destDir\"" );
} elseif( $upExt == 'rar' ) {
$shellResult = shell_exec( "unrar x \"{$pFileHash['tmp_name']}\" \"$destDir\"" );
} elseif( $upExt == 'sit' || $upExt == 'sitx' ) {
print ( "unstuff -d=\"$destDir\" \"{$pFileHash['tmp_name']}\" " );
$shellResult = shell_exec( "unstuff -d=\"$destDir\" \"{$pFileHash['tmp_name']}\" " );
// if we created a copy of the original, we remove it
if( !empty( $copyFile ) ) {
// obviously something went horribly wrong
* liberty_process_generic
* @param array $pFileHash
* @param array $pMoveFile
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
if( !empty( $pFileHash['dest_file'] ) ) {
$destFile = $pFileHash['dest_file'];
if( is_file( $pFileHash['source_file']) ) {
if( $pFileHash['source_file'] == $destFile ) {
// do nothing if source and dest are the same
rename( $pFileHash['source_file'], $destFile );
copy( $pFileHash['source_file'], $destFile );
$pFileHash['size'] = filesize( $destFile );
* @param array $pFileHash
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
$pFileHash['source_file'] = $resizePath;
//set permissions if possible - necessary for some wonky shared hosting environments
if(chmod($pFileHash['source_file'], 0644)){
//does nothing, but fails elegantly
$nameHold = $pFileHash['name'];
$sizeHold = $pFileHash['size'];
$ret = $pFileHash['source_file'];
// do not thumbnail only if intentionally set to FALSE
if( !isset ( $pFileHash['thumbnail'] ) || $pFileHash['thumbnail']== TRUE ) {
$pFileHash['name'] = $nameHold;
$pFileHash['size'] = $sizeHold;
* liberty_clear_thumbnails will clear all thummbnails found in a given directory
* @param array $pFileHash['dest_branch'] should contain the path to the dir where we should remove thumbnails
* @return TRUE on success, FALSE on failure
if( !empty( $pFileHash['dest_branch'] )) {
'source_file' => $pFileHash['dest_branch'],
// get thumbnails we want to remove
foreach( $thumbs as $thumb ) {
// if this was the thumbs subdirectory, we'll remove it if it's empty
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
$ret = 'liberty_'. $gBitSystem->getConfig( 'image_processor', 'gd' ). '_'. $pType. '_image';
* liberty_generate_thumbnails
* @param array $pFileHash
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
global $gBitSystem, $gThumbSizes;
// allow custom selection of thumbnail sizes
if( empty( $pFileHash['thumbnail_sizes'] )) {
if( !empty( $gThumbSizes ) && is_array( $gThumbSizes )) {
$pFileHash['thumbnail_sizes'] = array_keys( $gThumbSizes );
$pFileHash['thumbnail_sizes'] = array( 'large', 'medium', 'small', 'avatar', 'icon' );
if( ( !preg_match( '#image/(gif|jpe?g|png)#i', $pFileHash['type'] ) && $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' )) || in_array( 'original', $pFileHash['thumbnail_sizes'] ) ) {
// jpeg version of original
if( preg_match( '/pdf/i', $pFileHash['type'] ) ) {
// has a customer pdf rasterization function been defined?
if( function_exists( 'liberty_rasterize_pdf' ) && $rasteredFile = liberty_rasterize_pdf( $pFileHash['source_file'] ) ) {
$pFileHash['source_file'] = $rasteredFile;
MagickSetImageUnits( $magickWand, MW_PixelsPerInchResolution );
MagickSetResolution( $magickWand, 300, 300 );
$pFileHash['dest_base_name'] = 'original';
$pFileHash['name'] = 'original.jpg';
if( $convertedFile = $resizeFunc( $pFileHash )) {
$pFileHash['source_file'] = $convertedFile;
$pFileHash['type'] = $gBitSystem->verifyMimeType( $pFileHash['source_file'] );
// override $mimeExt if we have a custom setting for it
$mimeExt = $gBitSystem->getConfig( 'liberty_thumbnail_format' );
$initialDestPath = $pFileHash['dest_branch'];
foreach( $pFileHash['thumbnail_sizes'] as $thumbSize ) {
if( isset ( $gThumbSizes[$thumbSize] )) {
$pFileHash['dest_base_name'] = $thumbSize;
$pFileHash['name'] = $thumbSize. $destExt;
if( !empty( $gThumbSizes[$thumbSize]['width'] )) {
$pFileHash['max_width'] = $gThumbSizes[$thumbSize]['width'];
// Have to unset since we reuse $pFileHash
unset ( $pFileHash['max_width'] );
// reset dest_branch for created thumbs
if( !empty( $pFileHash['thumb_path'] ) ) {
$pFileHash['dest_file'] = $pFileHash['thumb_path']. $pFileHash['name'];
// create a subdirectory for the thumbs
$pFileHash['dest_branch'] = $initialDestPath. 'thumbs/';
if( !empty( $gThumbSizes[$thumbSize]['height'] )) {
$pFileHash['max_height'] = $gThumbSizes[$thumbSize]['height'];
// Have to unset since we reuse $pFileHash
unset ( $pFileHash['max_height'] );
if( $pFileHash['icon_thumb_path'] = $resizeFunc( $pFileHash )) {
// use the previous thumb as the source for the next, decreasingly smaller thumb as this GREATLY increases speed
$pFileHash['source_file'] = $pFileHash['icon_thumb_path'];
// to keep everything in bitweaver working smoothly, we need to remove the thumbs/ subdir again
$pFileHash['dest_branch'] = $initialDestPath;
* fetch all available thumbnails for a given item. if no thumbnails are present, get thumbnailing image or the appropriate mime type icon
* @param array $pParamHash Hash of all settings used to fetch thumbnails, including source_file, default_image, thumbnail_sizes, and mime_image
* @return array of available thumbnails or mime icons
* TODO: individual options are only for legacy reasons - remove options and deprecated() soon - xing - Monday Jun 23, 2008 22:36:53 CEST
global $gBitSystem, $gThumbSizes;
if( !empty( $pParamHash['source_file'] )) {
if( empty( $pParamHash['thumbnail_sizes'] )) {
$pParamHash['thumbnail_sizes'] = array_keys( $gThumbSizes );
// liberty file processors automatically pick the best format for us. we can force a format though.
// using array_unique will give us the best order in which to look for the thumbnails
$exts = array_unique( array( $gBitSystem->getConfig( 'liberty_thumbnail_format', 'jpg' ), 'jpg', 'png', 'gif', 'x-jpeg' ));
$path = &$pParamHash['source_file'];
// $path might already be the absolute path or it might already contain BIT_ROOT_URL
// remove the filename if there is one (we can't just use dirname() becuase we might only have the path to the dir)
// assume thumb sizes are from largest to smallest. reverse so smaller can be used if larger don't exist
foreach( array_reverse( $pParamHash['thumbnail_sizes'] ) as $size ) {
foreach( $exts as $ext ) {
$ret[$size] = (empty( $_REQUEST['uri_mode'] ) ? STORAGE_PKG_URL : STORAGE_PKG_URI). $thumbDir. $image;
// fetch mime image unless we set this to FALSE
if(( !isset ( $pParamHash['mime_image'] ) || $pParamHash['mime_image'] === TRUE ) && empty( $ret[$size] )) {
if( $lastSize && !empty( $ret[$lastSize] ) ) {
$ret[$size] = $ret[$lastSize];
// default if nothing else is available
foreach( array_reverse( $pParamHash['thumbnail_sizes'] ) as $size ) {
if( empty( $ret[$size] ) ) {
if( !empty( $pParamHash['default_image'] )) {
$ret[$size] = $pParamHash['default_image'];
// we need to make sure we have an image name that we can look up the mime type
* fetch a single available thumbnail for a given item. if no thumbnail is present, return NULL
* @param array $pParamHash Hash of all settings used to fetch thumbnails including: size, source_file, default_image, and mime_image
* TODO: individual options are only for legacy reasons - remove options and deprecated() soon - xing - Monday Jun 23, 2008 22:36:53 CEST
if( !empty( $pParamHash['source_file'] )) {
if( empty( $pParamHash['size'] )) {
$pParamHash['size'] = 'small';
$pParamHash['thumbnail_sizes'] = array( $pParamHash['size'] );
return( !empty( $ret[$pParamHash['size']] ) ? $ret[$pParamHash['size']] : NULL );
* get a set of image size options based on $gThumbSizes
* @param string $pEmptyOption string to use as empty option - if set to FALSE no empty string is eincluded - Note that string is tra()'d
* @return array of image size options suitable for use in a form
if( !empty( $pEmptyOption )) {
$ret[''] = tra( $pEmptyOption );
foreach( $gThumbSizes as $key => $size ) {
$ret[$key] = tra( ucfirst( $key )). " ( ". ( empty( $size['width'] ) ? tra( 'unlimited' ) : $size['width'] ) . " x ". ( empty($size['height'] ) ? tra('unlimited') : $size['height'] ) . " ". tra( 'pixels' ). " )";
* get_leadtitle will fetch the string before the liberty_subtitle_delimiter
* @param string $pString string that should be checked for the delimiter
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
return( substr( $pString, 0, strpos( $pString, $gBitSystem->getConfig( 'liberty_subtitle_delimiter', ':' ))));
* get_subtitle will fetch the string after the liberty_subtitle_delimiter
* @param string $pString string that should be checked for the delimiter
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
if(( $start = strpos( $pString, $gBitSystem->getConfig( 'liberty_subtitle_delimiter', ':' ))) !== FALSE ) {
return( substr( $pString, ( $start + 1 )));
|