summaryrefslogtreecommitdiff
path: root/liberty_plugins
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-21 19:26:26 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-21 19:26:26 +0100
commit4ba9b3906b27e3571767689d2764b67dfe007e30 (patch)
tree494f4e6a65d34a4338c14de4144595a2df8c65b5 /liberty_plugins
downloadstock-4ba9b3906b27e3571767689d2764b67dfe007e30.tar.gz
stock-4ba9b3906b27e3571767689d2764b67dfe007e30.tar.bz2
stock-4ba9b3906b27e3571767689d2764b67dfe007e30.zip
Initial stock package — forked from fisheye
StockAssembly (was FisheyeGallery), StockComponent (was FisheyeImage), StockBase (was FisheyeBase). All fisheye_ table prefixes and FISHEYE_ constants renamed to stock_/STOCK_. DB schema will need rework before install; this gives a non-clashing base to diverge from fisheye. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'liberty_plugins')
-rwxr-xr-xliberty_plugins/data.carousel.php179
-rwxr-xr-xliberty_plugins/data.gallery.php167
-rwxr-xr-xliberty_plugins/data.image.php157
3 files changed, 503 insertions, 0 deletions
diff --git a/liberty_plugins/data.carousel.php b/liberty_plugins/data.carousel.php
new file mode 100755
index 0000000..06d497c
--- /dev/null
+++ b/liberty_plugins/data.carousel.php
@@ -0,0 +1,179 @@
+<?php
+/**
+ * @version $Revision$
+ * $Header$
+ * @package liberty
+ * @subpackage plugins_storage
+ */
+
+/**
+ * required setup
+ */
+namespace Bitweaver\Liberty;
+
+use Bitweaver\Stock\StockComponent;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+
+/**
+ * definitions
+ */
+define( 'PLUGIN_GUID_DATACAROUSEL', 'datacarousel' );
+
+global $gLibertySystem;
+
+$pluginParams = [
+ 'tag' => 'carousel',
+ 'title' => 'Stock Carousel',
+ 'description' => KernelTools::tra( "Display a carousel of images in other content. This plugin only works with files that have been uploaded using stock." ),
+ 'help_page' => 'DataPluginCarousel',
+
+ 'auto_activate' => false,
+ 'requires_pair' => false,
+ 'syntax' => '{carousel id= }',
+ 'plugin_type' => DATA_PLUGIN,
+
+ // display icon in quicktags bar
+ '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 );
+
+function data_carousel( $pData, $pParams ) {
+ global $gBitSystem, $gBitSmarty;
+ $ret = ' ';
+
+ $imgStyle = '';
+
+ $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams );
+
+ $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : null;
+ foreach( $pParams as $key => $value ) {
+ if( !empty( $value ) ) {
+ switch( $key ) {
+ // rename a couple of parameters
+ case 'width':
+ case 'height':
+ if( preg_match( "/^\d+(em|px|%|pt)$/", trim( $value ) ) ) {
+ $imgStyle .= $key.':'.$value.';';
+ } elseif( preg_match( "/^\d+$/", $value ) ) {
+ $imgStyle .= $key.':'.$value.'px;';
+ }
+ // remove values from the hash that they don't get used in the div as well
+ $pParams[$key] = null;
+ break;
+ }
+ }
+ }
+
+ $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( 'stock' )) {
+
+ $gallery = new StockComponent();
+ $listHash = $pParams;
+ $listHash['size'] = 'large';
+ $listHash['gallery_id'] = $pParams['id'];
+ $listHash['max_records'] = 10;
+ $listHash['sort_mode'] = 'item_position_asc';
+ $images = $gallery->getList( $listHash );
+ $num=count($images);
+
+ $out = '<div class="carousel slide" data-ride="carousel" id="myCarousel">';
+ $out .= '<ol class="carousel-indicators">';
+ $out .= '<li class="active" data-slide-to="0" data-target="#myCarousel">&nbsp;</li>';
+ for ( $i=1; $i<$num; $i++ ) {
+ $out .= '<li data-slide-to="'.$i.'" data-target="#myCarousel">&nbsp;</li>';
+ }
+ $out .= '</ol>';
+ $out .= '<div class="carousel-inner" role="listbox">';
+
+ $i=0;
+ foreach( $images as $image ) {
+ // insert source url if we need the original file
+ if( !empty( $pParams['size'] ) && $pParams['size'] == 'original' ) {
+ $thumbUrl = $image['source_url'];
+ } elseif( $image['thumbnail_url'] ) {
+ $thumbUrl = $image['thumbnail_url'];
+ }
+
+ if( empty( $image['$description'] ) ) {
+ $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : $image['title'];
+ }
+
+ // check if we have a valid thumbnail
+ if( !empty( $thumbUrl )) {
+ $active = $i == 0 ? $active = ' active' : '';
+ $i++;
+ // set up image first
+ $ret = '<div class="item'.$active.'"><img class="img-responsive"'.
+ ' alt="'. $description.'"'.
+ ' title="'.$description.'"'.
+ ' src="' .$thumbUrl.'"'.
+ ' height="103" width="800"'.
+ ' /></div>';
+
+ if( !empty( $pParams['nolink'] ) ) {
+ } elseif( !empty( $wrapper['link'] ) ) {
+ // if this image is linking to something, wrap the image with the <a>
+ $ret = '<a href="'.trim( $wrapper['link'] ).'">'.$ret.'</a>';
+ } elseif ( empty( $pParams['size'] ) || $pParams['size'] != 'original' ) {
+ if ( $image['source_url'] ) {
+ $ret = '<a href="'.trim( $image['source_url'] ).'">'.$ret.'</a>';
+ }
+ }
+
+ if( !empty( $wrapper['style'] ) || !empty( $class ) || !empty( $wrapper['description'] ) ) {
+ $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 = KernelTools::tra( "Unknown Gallery" );
+ }
+ $out .= $ret;
+ }
+ $out .= '</div>';
+ $out .= '<a class="left carousel-control" data-slide="prev" href="#myCarousel" role="button">';
+ $out .= '<span class="sr-only">Previous</span> </a>';
+ $out .= '<a class="right carousel-control" data-slide="next" href="#myCarousel" role="button">';
+ $out .= '<span class="sr-only">Next</span> </a></div>';
+ $out .= '</div>';
+ }
+ return $out;
+}
+
+function data_carousel_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . KernelTools::tra( "Key" ) . '</th>'
+ .'<th>' . KernelTools::tra( "Type" ) . '</th>'
+ .'<th>' . KernelTools::tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>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>' . 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>' . 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>'
+ . 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
new file mode 100755
index 0000000..7eda88d
--- /dev/null
+++ b/liberty_plugins/data.gallery.php
@@ -0,0 +1,167 @@
+<?php
+/**
+ * @version $Revision$
+ * $Header$
+ * @package liberty
+ * @subpackage plugins_storage
+ */
+
+/**
+ * required setup
+ */
+namespace Bitweaver\Liberty;
+
+use Bitweaver\Stock\StockComponent;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+
+/**
+ * definitions
+ */
+define( 'PLUGIN_GUID_DATAGALLERY', 'datagallery' );
+
+global $gLibertySystem;
+
+$pluginParams = [
+ 'tag' => 'gallery',
+ 'title' => 'Stock Gallery',
+ 'description' => KernelTools::tra( "Display a list of images in other content. This plugin only works with files that have been uploaded using stock." ),
+ 'help_page' => 'DataPluginGallery',
+
+ 'auto_activate' => false,
+ 'requires_pair' => false,
+ 'syntax' => '{gallery id= }',
+ 'plugin_type' => DATA_PLUGIN,
+
+ // display icon in quicktags bar
+ '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 );
+
+function data_gallery( $pData, $pParams ) {
+ global $gBitSystem, $gBitSmarty;
+ $ret = ' ';
+
+ $imgStyle = '';
+
+ $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams );
+
+ $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : null;
+ foreach( $pParams as $key => $value ) {
+ if( !empty( $value ) ) {
+ switch( $key ) {
+ // rename a couple of parameters
+ case 'width':
+ case 'height':
+ if( preg_match( "/^\d+(em|px|%|pt)$/", trim( $value ) ) ) {
+ $imgStyle .= $key.':'.$value.';';
+ } elseif( preg_match( "/^\d+$/", $value ) ) {
+ $imgStyle .= $key.':'.$value.'px;';
+ }
+ // remove values from the hash that they don't get used in the div as well
+ $pParams[$key] = null;
+ break;
+ }
+ }
+ }
+
+ $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams );
+
+ if( !empty( $pParams['src'] ) ) {
+ $thumbUrl = $pParams['src'];
+ } elseif( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'stock' )) {
+ require_once STOCK_PKG_CLASS_PATH.'StockComponent.php';
+
+ $gallery = new StockComponent();
+ $listHash = $pParams;
+ $listHash['size'] = 'small';
+ $listHash['gallery_id'] = $pParams['id'];
+ $listHash['max_records'] = 3;
+ $listHash['sort_mode'] = 'random';
+ $images = $gallery->getList( $listHash );
+$out = '<div>';
+ foreach( $images as $image ) {
+ // insert source url if we need the original file
+ if( !empty( $pParams['size'] ) && $pParams['size'] == 'original' ) {
+ $thumbUrl = $image['source_url'];
+ } elseif( $image['thumbnail_url'] ) {
+ $thumbUrl = $image['thumbnail_url'];
+ }
+
+ if( empty( $image['$description'] ) ) {
+ $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : $image['title'];
+ }
+
+ // check if we have a valid thumbnail
+ if( !empty( $thumbUrl )) {
+ // set up image first
+ $ret = '<img class="img-responsive"'.
+ ' alt="'. $description.'"'.
+ ' title="'.$description.'"'.
+ ' src="' .$thumbUrl.'"'.
+ ' style="float:left; '.$imgStyle.'"'.
+ ' />';
+
+ if( !empty( $pParams['nolink'] ) ) {
+ } elseif( !empty( $wrapper['link'] ) ) {
+ // if this image is linking to something, wrap the image with the <a>
+ $ret = '<a href="'.trim( $wrapper['link'] ).'">'.$ret.'</a>';
+ } elseif ( empty( $pParams['size'] ) || $pParams['size'] != 'original' ) {
+ if ( $image['source_url'] ) {
+ $ret = '<a href="'.trim( $image['source_url'] ).'">'.$ret.'</a>';
+ }
+ }
+
+ if( !empty( $wrapper['style'] ) || !empty( $class ) || !empty( $wrapper['description'] ) ) {
+ $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 = KernelTools::tra( "Unknown Gallery" );
+ }
+ $out .= $ret;
+ }
+ $out .= '</div>';
+ }
+ return $out;
+}
+
+function data_gallery_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . KernelTools::tra( "Key" ) . '</th>'
+ .'<th>' . KernelTools::tra( "Type" ) . '</th>'
+ .'<th>' . KernelTools::tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>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>' . 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>' . 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>' . 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>'
+ . 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
new file mode 100755
index 0000000..6bf08fe
--- /dev/null
+++ b/liberty_plugins/data.image.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * @version $Revision$
+ * $Header$
+ * @package liberty
+ * @subpackage plugins_storage
+ */
+
+/**
+ * required setup
+ */
+namespace Bitweaver\Liberty;
+
+use Bitweaver\Stock\StockComponent;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+
+/**
+ * definitions
+ */
+define( 'PLUGIN_GUID_DATAIMAGE', 'dataimage' );
+
+global $gLibertySystem;
+
+$pluginParams = [
+ 'tag' => 'image',
+ 'title' => 'Stock Image',
+ 'description' => KernelTools::tra( "Display an image in other content. This plugin only works with files that have been uploaded using stock." ),
+ 'help_page' => 'DataPluginImage',
+
+ 'auto_activate' => false,
+ 'requires_pair' => false,
+ 'syntax' => '{image id= }',
+ 'plugin_type' => DATA_PLUGIN,
+
+ // display icon in quicktags bar
+ '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 );
+
+function data_image( $pData, $pParams ) {
+ global $gBitSystem, $gBitSmarty;
+ $ret = ' ';
+
+ $imgStyle = '';
+
+ $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams );
+
+ $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : null;
+ foreach( $pParams as $key => $value ) {
+ if( !empty( $value ) ) {
+ switch( $key ) {
+ // rename a couple of parameters
+ case 'width':
+ case 'height':
+ if( preg_match( "/^\d+(em|px|%|pt)$/", trim( $value ) ) ) {
+ $imgStyle .= $key.':'.$value.';';
+ } elseif( preg_match( "/^\d+$/", $value ) ) {
+ $imgStyle .= $key.':'.$value.'px;';
+ }
+ // remove values from the hash that they don't get used in the div as well
+ $pParams[$key] = null;
+ break;
+ }
+ }
+ }
+
+ $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams );
+
+ if( !empty( $pParams['src'] ) ) {
+ $thumbUrl = $pParams['src'];
+ } elseif( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'stock' )) {
+
+ $item = new StockComponent( $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'];
+ }
+
+ if( empty( $description ) ) {
+ $description = !isset( $wrapper['description'] ) ? $wrapper['description'] : $item->getField( 'title', KernelTools::tra( 'Image' ) );
+ }
+ }
+ }
+
+ // check if we have a valid thumbnail
+ if( !empty( $thumbUrl )) {
+ // set up image first
+ $ret = '<img'.
+ ' alt="'. $description.'"'.
+ ' title="'.$description.'"'.
+ ' src="' .$thumbUrl.'"'.
+ ' style="'.$imgStyle.'"'.
+ ' />';
+
+ if( !empty( $pParams['nolink'] ) ) {
+ } elseif( !empty( $wrapper['link'] ) ) {
+ // if this image is linking to something, wrap the image with the <a>
+ $ret = '<a href="'.trim( $wrapper['link'] ).'">'.$ret.'</a>';
+ } elseif ( empty( $pParams['size'] ) || $pParams['size'] != 'original' ) {
+ if ( $gBitSystem->isFeatureActive( 'site_fancy_zoom' ) and !empty( $item->mInfo['source_url'] ) ) {
+ $ret = '<a href="'.trim( str_replace(' ', '%20', $item->mInfo['source_url'] ) ).'">'.$ret.'</a>';
+ } else if ( $item->getDownloadUrl() ) {
+ $ret = '<a href="'.trim( $item->getDownloadUrl() ).'">'.$ret.'</a>';
+ } else if ( !empty( $item->mInfo['media_url'] ) ) {
+ $ret = '<a href="'.trim( $item->mInfo['media_url'] ).'">'.$ret.'</a>';
+ }
+ }
+
+ if( !empty( $wrapper['style'] ) || !empty( $class ) || !empty( $wrapper['description'] ) ) {
+ $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 = KernelTools::tra( "Unknown Image" );
+ }
+
+ return $ret;
+}
+
+function data_image_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . KernelTools::tra( "Key" ) . '</th>'
+ .'<th>' . KernelTools::tra( "Type" ) . '</th>'
+ .'<th>' . KernelTools::tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>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>' . 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>' . 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>'
+ . KernelTools::tra( "Example: ") . "{image id='13' size='small'}";
+ return $help;
+} \ No newline at end of file