liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.gallery.php

Documentation is available at data.gallery.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  *  $Header$
  5.  * @package  liberty
  6.  * @subpackage plugins_storage
  7.  */
  8.  
  9. /**
  10.  * definitions
  11.  */
  12. define'PLUGIN_GUID_DATAGALLERY''datagallery' );
  13. global $gLibertySystem;
  14. $pluginParams array (
  15.     'tag'           => 'gallery',
  16.     'title'         => 'Fisheye Gallery',
  17.     'description'   => tra"Display a list of images in other content. This plugin only works with files that have been uploaded using fisheye." ),
  18.     'help_page'     => 'DataPluginGallery',
  19.  
  20.     'auto_activate' => FALSE,
  21.     'requires_pair' => FALSE,
  22.     'syntax'        => '{gallery id= }',
  23.     'plugin_type'   => DATA_PLUGIN,
  24.  
  25.     // display icon in quicktags bar
  26.     'booticon'       => '{booticon iname="icon-picture" iexplain="Image"}',
  27.     'taginsert'     => '{gallery id= size= nolink=}',
  28.  
  29.     // functions
  30.     'help_function' => 'data_gallery_help',
  31.     'load_function' => 'data_gallery',
  32. );
  33. $gLibertySystem->registerPluginPLUGIN_GUID_DATAGALLERY$pluginParams );
  34. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAGALLERY );
  35.  
  36.  
  37. function data_gallery$pData$pParams {
  38.     global $gBitSystem$gBitSmarty;
  39.     $ret ' ';
  40.  
  41.     $imgStyle '';
  42.  
  43.     $wrapper liberty_plugins_wrapper_style$pParams );
  44.  
  45.     $description !isset$wrapper['description'$wrapper['description'NULL;
  46.     foreach$pParams as $key => $value {
  47.         if!empty$value ) ) {
  48.             switch$key {
  49.                 // rename a couple of parameters
  50.                 case 'width':
  51.                 case 'height':
  52.                     ifpreg_match"/^\d+(em|px|%|pt)$/"trim$value ) ) ) {
  53.                         $imgStyle .= $key.':'.$value.';';
  54.                     elseifpreg_match"/^\d+$/"$value ) ) {
  55.                         $imgStyle .= $key.':'.$value.'px;';
  56.                     }
  57.                     // remove values from the hash that they don't get used in the div as well
  58.                     $pParams[$keyNULL;
  59.                     break;
  60.             }
  61.         }
  62.     }
  63.  
  64.     $wrapper liberty_plugins_wrapper_style$pParams );
  65.  
  66.     if!empty$pParams['src') ) {
  67.         $thumbUrl $pParams['src'];
  68.     elseif@BitBase::verifyId$pParams['id'&& $gBitSystem->isPackageActive'fisheye' )) {
  69.         require_onceFISHEYE_PKG_PATH.'FisheyeImage.php' );
  70.         $gBitSmarty->loadPlugin'smarty_modifier_display_bytes' );
  71.  
  72.         $gallery new FisheyeImage();
  73.             $listHash $pParams;
  74.             $listHash['size''small';
  75.             $listHash['gallery_id'$pParams['id'];
  76.             $listHash['max_records'3;
  77.             $listHash['sort_mode''random';
  78.             $images $gallery->getList$listHash );
  79. $out '<div>';
  80.   foreach$images as $image {
  81.           // insert source url if we need the original file
  82.             if!empty$pParams['size'&& $pParams['size'== 'original' {
  83.                 $thumbUrl $image['source_url'];
  84.             elseif$image['thumbnail_url'{
  85.                 $thumbUrl $image['thumbnail_url'];
  86.             }
  87.  
  88.             ifempty$image['$description') ) {
  89.                 $description !isset$wrapper['description'$wrapper['description'$image['title'];
  90.             }
  91.  
  92.         // check if we have a valid thumbnail
  93.         if!empty$thumbUrl )) {
  94.             // set up image first
  95.             $ret '<img class="img-responsive"'.
  96.                 ' alt="'.  $description.'"'.
  97.                 ' title="'.$description.'"'.
  98.                 ' src="'  .$thumbUrl.'"'.
  99.                 ' style="float:left; '.$imgStyle.'"'.
  100.                 ' />';
  101.     
  102.             if!empty$pParams['nolink') ) {
  103.             elseif!empty$wrapper['link') ) {
  104.                 // if this image is linking to something, wrap the image with the <a>
  105.                 $ret '<a href="'.trim$wrapper['link').'">'.$ret.'</a>';
  106.             elseif empty$pParams['size'|| $pParams['size'!= 'original' {
  107.                 if $image['source_url'{
  108.                     $ret '<a href="'.trim$image['source_url').'">'.$ret.'</a>';
  109.                 
  110.             }
  111.     
  112.             if!empty$wrapper['style'|| !empty$class || !empty$wrapper['description') ) {
  113.                 $ret '<'.$wrapper['wrapper'].' class="'.!empty$wrapper['class'$wrapper['class'"img-responsive" ).'" style="'.$wrapper['style'].'">'.$ret.!empty$wrapper['description''<br />'.$wrapper['description''' ).'</'.$wrapper['wrapper'].'>';
  114.             }
  115.         else {
  116.             $ret tra"Unknown Gallery" );
  117.         }
  118.         $out .= $ret;
  119.     }
  120.   $out .= '</div>';
  121.     }
  122.     return $out;
  123. }
  124.  
  125. function data_gallery_help({
  126.     $help =
  127.         '<table class="data help">'
  128.             .'<tr>'
  129.                 .'<th>' tra"Key" '</th>'
  130.                 .'<th>' tra"Type" '</th>'
  131.                 .'<th>' tra"Comments" '</th>'
  132.             .'</tr>'
  133.             .'<tr class="odd">'
  134.                 .'<td>id</td>'
  135.                 .'<td>' tra"numeric"'<br />' tra("(required)"'</td>'
  136.                 .'<td>' tra"gallery id number of Images to display inline."tra"You can use either content_id or id." ).'</td>'
  137.             .'</tr>'
  138.             .'<tr class="even">'
  139.                 .'<td>size</td>'
  140.                 .'<td>' tra"key-words"'<br />' tra("(optional)"'</td>'
  141.                 .'<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> '
  142.                 . tra"(Default = " '<strong>medium</strong>)</td>'
  143.             .'</tr>'
  144.             .'<tr class="odd">'
  145.                 .'<td>nolink</td>'
  146.                 .'<td>' tra"key-words"'<br />' tra("(optional)"'</td>'
  147.                 .'<td>' tra"Remove hotlink from element. Used to display fixed copies of an image item."'</td>'
  148.             .'</tr>'
  149.             .'<tr class="even">'
  150.                 .'<td>num</td>'
  151.                 .'<td>' tra"key-words"'<br />' tra("(optional)"'</td>'
  152.                 .'<td>' tra"Number of images to display from the gallery"
  153.                 . tra"(Default = " '<strong>3</strong>)</td>'
  154.             .'</tr>'
  155.         .'</table>'
  156.         . tra"Example: ""{gallery id='13' size='small'}";
  157.     return $help;
  158. }
  159. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:19 +0000 by phpDocumentor 1.5.0-lsces