diff options
| author | lsces <lester@lsces.co.uk> | 2025-08-28 16:14:49 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2025-08-28 16:14:49 +0100 |
| commit | 1d5acb912c32b33ae04d7e6794be73e4030f2643 (patch) | |
| tree | 0da283d1b24fdae96581fb5adf5da9edab0c8be4 | |
| parent | e255ca158815cb4c9f6f1b0f4f7a63a6ab3e37e3 (diff) | |
| download | fisheye-1d5acb912c32b33ae04d7e6794be73e4030f2643.tar.gz fisheye-1d5acb912c32b33ae04d7e6794be73e4030f2643.tar.bz2 fisheye-1d5acb912c32b33ae04d7e6794be73e4030f2643.zip | |
plugin code updated to PHP8.4 and namespace ... work in progress on updating some third party code
| -rwxr-xr-x[-rw-r--r--] | liberty_plugins/data.carousel.php | 69 | ||||
| -rwxr-xr-x[-rw-r--r--] | liberty_plugins/data.gallery.php | 68 | ||||
| -rwxr-xr-x[-rw-r--r--] | liberty_plugins/data.image.php | 67 |
3 files changed, 111 insertions, 93 deletions
diff --git a/liberty_plugins/data.carousel.php b/liberty_plugins/data.carousel.php index 1e23c51..0d0d833 100644..100755 --- a/liberty_plugins/data.carousel.php +++ b/liberty_plugins/data.carousel.php @@ -7,29 +7,39 @@ */ /** + * required setup + */ +namespace Bitweaver\Liberty; +use Bitweaver\Fisheye\FisheyeImage; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; + +/** * definitions */ define( 'PLUGIN_GUID_DATACAROUSEL', 'datacarousel' ); + global $gLibertySystem; -$pluginParams = array ( + +$pluginParams = [ 'tag' => 'carousel', 'title' => 'Fisheye Carousel', - 'description' => tra( "Display a carousel of images in other content. This plugin only works with files that have been uploaded using fisheye." ), + 'description' => KernelTools::tra( "Display a carousel of images in other content. This plugin only works with files that have been uploaded using fisheye." ), 'help_page' => 'DataPluginCarousel', - 'auto_activate' => FALSE, - 'requires_pair' => FALSE, + 'auto_activate' => false, + 'requires_pair' => false, 'syntax' => '{carousel id= }', 'plugin_type' => DATA_PLUGIN, // display icon in quicktags bar - 'booticon' => '{booticon iname="fa-image-landscape" iexplain="Image"}', + 'booticon' => '{booticon iname="icon-picture" iexplain="Image"}', 'taginsert' => '{carousel id= size= nolink=}', // functions 'help_function' => 'data_carousel_help', 'load_function' => 'data_carousel', -); +]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATACAROUSEL, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACAROUSEL ); @@ -40,9 +50,9 @@ function data_carousel( $pData, $pParams ) { $imgStyle = ''; - $wrapper = liberty_plugins_wrapper_style( $pParams ); + $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); - $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : NULL; + $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : null; foreach( $pParams as $key => $value ) { if( !empty( $value ) ) { switch( $key ) { @@ -55,19 +65,17 @@ function data_carousel( $pData, $pParams ) { $imgStyle .= $key.':'.$value.'px;'; } // remove values from the hash that they don't get used in the div as well - $pParams[$key] = NULL; + $pParams[$key] = null; break; } } } - $wrapper = liberty_plugins_wrapper_style( $pParams ); + $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); $pParams['nolink'] = 'yes'; if( !empty( $pParams['src'] ) ) { $thumbUrl = $pParams['src']; - } elseif( @BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'fisheye' )) { - require_once( FISHEYE_PKG_CLASS_PATH.'FisheyeImage.php' ); - $gBitSmarty->loadPlugin( 'smarty_modifier_display_bytes' ); + } elseif( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'fisheye' )) { $gallery = new FisheyeImage(); $listHash = $pParams; @@ -102,11 +110,7 @@ function data_carousel( $pData, $pParams ) { // check if we have a valid thumbnail if( !empty( $thumbUrl )) { - if ( $i == 0 ) { - $active = ' active'; - } else { - $active = ''; - } + $active = $i == 0 ? $active = ' active' : ''; $i++; // set up image first $ret = '<div class="item'.$active.'"><img class="img-responsive"'. @@ -130,7 +134,7 @@ function data_carousel( $pData, $pParams ) { $ret = '<'.$wrapper['wrapper'].' class="'.( !empty( $wrapper['class'] ) ? $wrapper['class'] : "img-responsive" ).'" style="'.$wrapper['style'].'">'.$ret.( !empty( $wrapper['description'] ) ? '<br />'.$wrapper['description'] : '' ).'</'.$wrapper['wrapper'].'>'; } } else { - $ret = tra( "Unknown Gallery" ); + $ret = KernelTools::tra( "Unknown Gallery" ); } $out .= $ret; } @@ -148,29 +152,28 @@ function data_carousel_help() { $help = '<table class="data help">' .'<tr>' - .'<th>' . tra( "Key" ) . '</th>' - .'<th>' . tra( "Type" ) . '</th>' - .'<th>' . tra( "Comments" ) . '</th>' + .'<th>' . KernelTools::tra( "Key" ) . '</th>' + .'<th>' . KernelTools::tra( "Type" ) . '</th>' + .'<th>' . KernelTools::tra( "Comments" ) . '</th>' .'</tr>' .'<tr class="odd">' .'<td>id</td>' - .'<td>' . tra( "numeric") . '<br />' . tra("(required)") . '</td>' - .'<td>' . tra( "gallery id number of Images to display inline.") . tra( "You can use either content_id or id." ).'</td>' + .'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(required)") . '</td>' + .'<td>' . KernelTools::tra( "gallery id number of Images to display inline.") . KernelTools::tra( "You can use either content_id or id." ).'</td>' .'</tr>' .'<tr class="even">' .'<td>size</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "If the File is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> ' - . tra( "(Default = " ) . '<strong>medium</strong>)</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "If the File is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> ' + . KernelTools::tra( "(Default = " ) . '<strong>medium</strong>)</td>' .'</tr>' .'<tr class="odd">' .'<td>num</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "Number of images to display from the gallery") - . tra( "(Default = " ) . '<strong>10</strong>)</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "Number of images to display from the gallery") + . KernelTools::tra( "(Default = " ) . '<strong>10</strong>)</td>' .'</tr>' .'</table>' - . tra( "Example: ") . "{carousel id='13' size='small'}"; + . KernelTools::tra( "Example: ") . "{carousel id='13' size='small'}"; return $help; -} -?> +}
\ No newline at end of file diff --git a/liberty_plugins/data.gallery.php b/liberty_plugins/data.gallery.php index 92b270c..5560a5e 100644..100755 --- a/liberty_plugins/data.gallery.php +++ b/liberty_plugins/data.gallery.php @@ -7,29 +7,39 @@ */ /** + * required setup + */ +namespace Bitweaver\Liberty; +use Bitweaver\Fisheye\FisheyeImage; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; + +/** * definitions */ define( 'PLUGIN_GUID_DATAGALLERY', 'datagallery' ); + global $gLibertySystem; -$pluginParams = array ( + +$pluginParams = [ 'tag' => 'gallery', 'title' => 'Fisheye Gallery', - 'description' => tra( "Display a list of images in other content. This plugin only works with files that have been uploaded using fisheye." ), + 'description' => KernelTools::tra( "Display a list of images in other content. This plugin only works with files that have been uploaded using fisheye." ), 'help_page' => 'DataPluginGallery', - 'auto_activate' => FALSE, - 'requires_pair' => FALSE, + 'auto_activate' => false, + 'requires_pair' => false, 'syntax' => '{gallery id= }', 'plugin_type' => DATA_PLUGIN, // display icon in quicktags bar - 'booticon' => '{booticon iname="fa-image-landscape" iexplain="Image"}', + 'booticon' => '{booticon iname="icon-picture" iexplain="Image"}', 'taginsert' => '{gallery id= size= nolink=}', // functions 'help_function' => 'data_gallery_help', 'load_function' => 'data_gallery', -); +]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAGALLERY, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAGALLERY ); @@ -40,9 +50,9 @@ function data_gallery( $pData, $pParams ) { $imgStyle = ''; - $wrapper = liberty_plugins_wrapper_style( $pParams ); + $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); - $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : NULL; + $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : null; foreach( $pParams as $key => $value ) { if( !empty( $value ) ) { switch( $key ) { @@ -55,19 +65,18 @@ function data_gallery( $pData, $pParams ) { $imgStyle .= $key.':'.$value.'px;'; } // remove values from the hash that they don't get used in the div as well - $pParams[$key] = NULL; + $pParams[$key] = null; break; } } } - $wrapper = liberty_plugins_wrapper_style( $pParams ); + $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); if( !empty( $pParams['src'] ) ) { $thumbUrl = $pParams['src']; - } elseif( @BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'fisheye' )) { - require_once( FISHEYE_PKG_CLASS_PATH.'FisheyeImage.php' ); - $gBitSmarty->loadPlugin( 'smarty_modifier_display_bytes' ); + } elseif( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'fisheye' )) { + require_once FISHEYE_PKG_CLASS_PATH.'FisheyeImage.php'; $gallery = new FisheyeImage(); $listHash = $pParams; @@ -113,7 +122,7 @@ $out = '<div>'; $ret = '<'.$wrapper['wrapper'].' class="'.( !empty( $wrapper['class'] ) ? $wrapper['class'] : "img-responsive" ).'" style="'.$wrapper['style'].'">'.$ret.( !empty( $wrapper['description'] ) ? '<br />'.$wrapper['description'] : '' ).'</'.$wrapper['wrapper'].'>'; } } else { - $ret = tra( "Unknown Gallery" ); + $ret = KernelTools::tra( "Unknown Gallery" ); } $out .= $ret; } @@ -126,34 +135,33 @@ function data_gallery_help() { $help = '<table class="data help">' .'<tr>' - .'<th>' . tra( "Key" ) . '</th>' - .'<th>' . tra( "Type" ) . '</th>' - .'<th>' . tra( "Comments" ) . '</th>' + .'<th>' . KernelTools::tra( "Key" ) . '</th>' + .'<th>' . KernelTools::tra( "Type" ) . '</th>' + .'<th>' . KernelTools::tra( "Comments" ) . '</th>' .'</tr>' .'<tr class="odd">' .'<td>id</td>' - .'<td>' . tra( "numeric") . '<br />' . tra("(required)") . '</td>' - .'<td>' . tra( "gallery id number of Images to display inline.") . tra( "You can use either content_id or id." ).'</td>' + .'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(required)") . '</td>' + .'<td>' . KernelTools::tra( "gallery id number of Images to display inline.") . KernelTools::tra( "You can use either content_id or id." ).'</td>' .'</tr>' .'<tr class="even">' .'<td>size</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "If the File is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> ' - . tra( "(Default = " ) . '<strong>medium</strong>)</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "If the File is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> ' + . KernelTools::tra( "(Default = " ) . '<strong>medium</strong>)</td>' .'</tr>' .'<tr class="odd">' .'<td>nolink</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "Remove hotlink from element. Used to display fixed copies of an image item.") . '</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "Remove hotlink from element. Used to display fixed copies of an image item.") . '</td>' .'</tr>' .'<tr class="even">' .'<td>num</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "Number of images to display from the gallery") - . tra( "(Default = " ) . '<strong>3</strong>)</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "Number of images to display from the gallery") + . KernelTools::tra( "(Default = " ) . '<strong>3</strong>)</td>' .'</tr>' .'</table>' - . tra( "Example: ") . "{gallery id='13' size='small'}"; + . KernelTools::tra( "Example: ") . "{gallery id='13' size='small'}"; return $help; -} -?> +}
\ No newline at end of file diff --git a/liberty_plugins/data.image.php b/liberty_plugins/data.image.php index 736bc77..80f917e 100644..100755 --- a/liberty_plugins/data.image.php +++ b/liberty_plugins/data.image.php @@ -7,29 +7,39 @@ */ /** + * required setup + */ +namespace Bitweaver\Liberty; +use Bitweaver\Fisheye\FisheyeImage; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; + +/** * definitions */ define( 'PLUGIN_GUID_DATAIMAGE', 'dataimage' ); + global $gLibertySystem; -$pluginParams = array ( + +$pluginParams = [ 'tag' => 'image', 'title' => 'Fisheye Image', - 'description' => tra( "Display an image in other content. This plugin only works with files that have been uploaded using fisheye." ), + 'description' => KernelTools::tra( "Display an image in other content. This plugin only works with files that have been uploaded using fisheye." ), 'help_page' => 'DataPluginImage', - 'auto_activate' => FALSE, - 'requires_pair' => FALSE, + 'auto_activate' => false, + 'requires_pair' => false, 'syntax' => '{image id= }', 'plugin_type' => DATA_PLUGIN, // display icon in quicktags bar - 'booticon' => '{booticon iname="fa-image-landscape" iexplain="Image"}', + 'booticon' => '{booticon iname="icon-picture" iexplain="Image"}', 'taginsert' => '{image id= size= nolink=}', // functions 'help_function' => 'data_image_help', 'load_function' => 'data_image', -); +]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAIMAGE, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAIMAGE ); @@ -40,9 +50,9 @@ function data_image( $pData, $pParams ) { $imgStyle = ''; - $wrapper = liberty_plugins_wrapper_style( $pParams ); + $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); - $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : NULL; + $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : null; foreach( $pParams as $key => $value ) { if( !empty( $value ) ) { switch( $key ) { @@ -55,32 +65,30 @@ function data_image( $pData, $pParams ) { $imgStyle .= $key.':'.$value.'px;'; } // remove values from the hash that they don't get used in the div as well - $pParams[$key] = NULL; + $pParams[$key] = null; break; } } } - $wrapper = liberty_plugins_wrapper_style( $pParams ); + $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); if( !empty( $pParams['src'] ) ) { $thumbUrl = $pParams['src']; - } elseif( @BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'fisheye' )) { - require_once( FISHEYE_PKG_CLASS_PATH.'FisheyeImage.php' ); - $gBitSmarty->loadPlugin( 'smarty_modifier_display_bytes' ); + } elseif( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'fisheye' )) { - $item = new FisheyeImage( $pParams['id'], NULL ); + $item = new FisheyeImage( $pParams['id'], null ); if( $item->load() ) { // insert source url if we need the original file if( !empty( $pParams['size'] ) && $pParams['size'] == 'original' ) { $thumbUrl = $item->getDownloadUrl(); } elseif( $item->mInfo['thumbnail_url'] ) { - $thumbUrl = ( !empty( $pParams['size'] ) && !empty( $item->mInfo['thumbnail_url'][$pParams['size']] ) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium'] ); + $thumbUrl = !empty( $pParams['size'] ) && !empty( $item->mInfo['thumbnail_url'][$pParams['size']] ) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium']; } if( empty( $description ) ) { - $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : $item->getField( 'title', tra( 'Image' ) ); + $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : $item->getField( 'title', KernelTools::tra( 'Image' ) ); } } } @@ -113,7 +121,7 @@ function data_image( $pData, $pParams ) { $ret = '<'.$wrapper['wrapper'].' class="'.( !empty( $wrapper['class'] ) ? $wrapper['class'] : "img-plugin" ).'" style="'.$wrapper['style'].'">'.$ret.( !empty( $wrapper['description'] ) ? '<br />'.$wrapper['description'] : '' ).'</'.$wrapper['wrapper'].'>'; } } else { - $ret = tra( "Unknown Image" ); + $ret = KernelTools::tra( "Unknown Image" ); } return $ret; @@ -123,28 +131,27 @@ function data_image_help() { $help = '<table class="data help">' .'<tr>' - .'<th>' . tra( "Key" ) . '</th>' - .'<th>' . tra( "Type" ) . '</th>' - .'<th>' . tra( "Comments" ) . '</th>' + .'<th>' . KernelTools::tra( "Key" ) . '</th>' + .'<th>' . KernelTools::tra( "Type" ) . '</th>' + .'<th>' . KernelTools::tra( "Comments" ) . '</th>' .'</tr>' .'<tr class="odd">' .'<td>id</td>' - .'<td>' . tra( "numeric") . '<br />' . tra("(required)") . '</td>' - .'<td>' . tra( "Image id number of Image to display inline.") . tra( "You can use either content_id or id." ).'</td>' + .'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(required)") . '</td>' + .'<td>' . KernelTools::tra( "Image id number of Image to display inline.") . KernelTools::tra( "You can use either content_id or id." ).'</td>' .'</tr>' .'<tr class="even">' .'<td>size</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "If the File is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> ' - . tra( "(Default = " ) . '<strong>medium</strong>)</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "If the File is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> ' + . KernelTools::tra( "(Default = " ) . '<strong>medium</strong>)</td>' .'</tr>' .'<tr class="odd">' .'<td>nolink</td>' - .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>' - .'<td>' . tra( "Remove hotlink from element. Used to display fixed copies of an image item.") . '</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "Remove hotlink from element. Used to display fixed copies of an image item.") . '</td>' .'</tr>' .'</table>' - . tra( "Example: ") . "{image id='13' size='small'}"; + . KernelTools::tra( "Example: ") . "{image id='13' size='small'}"; return $help; -} -?> +}
\ No newline at end of file |
