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

Source for file data.image.php

Documentation is available at data.image.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_DATAIMAGE''dataimage' );
  13. global $gLibertySystem;
  14. $pluginParams array (
  15.     'tag'           => 'image',
  16.     'title'         => 'Fisheye Image',
  17.     'description'   => tra"Display an image in other content. This plugin only works with files that have been uploaded using fisheye." ),
  18.     'help_page'     => 'DataPluginImage',
  19.  
  20.     'auto_activate' => FALSE,
  21.     'requires_pair' => FALSE,
  22.     'syntax'        => '{image id= }',
  23.     'plugin_type'   => DATA_PLUGIN,
  24.  
  25.     // display icon in quicktags bar
  26.     'booticon'       => '{booticon iname="icon-picture" iexplain="Image"}',
  27.     'taginsert'     => '{image id= size= nolink=}',
  28.  
  29.     // functions
  30.     'help_function' => 'data_image_help',
  31.     'load_function' => 'data_image',
  32. );
  33. $gLibertySystem->registerPluginPLUGIN_GUID_DATAIMAGE$pluginParams );
  34. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAIMAGE );
  35.  
  36.  
  37. function data_image$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.         $item new FisheyeImage$pParams['id']NULL );
  73.  
  74.         if$item->load() ) {
  75.             // insert source url if we need the original file
  76.             if!empty$pParams['size'&& $pParams['size'== 'original' {
  77.                 $thumbUrl $item->getDownloadUrl();
  78.             elseif$item->mInfo['thumbnail_url'{
  79.                 $thumbUrl !empty$pParams['size'&& !empty$item->mInfo['thumbnail_url'][$pParams['size']] $item->mInfo['thumbnail_url'][$pParams['size']] $item->mInfo['thumbnail_url']['medium');
  80.             }
  81.  
  82.             ifempty$description ) ) {
  83.                 $description !isset$wrapper['description'$wrapper['description'$item->getField'title'tra'Image' ) );
  84.             }
  85.         }
  86.     }
  87.  
  88.     // check if we have a valid thumbnail
  89.     if!empty$thumbUrl )) {
  90.         // set up image first
  91.         $ret '<img'.
  92.             ' alt="'.  $description.'"'.
  93.             ' title="'.$description.'"'.
  94.             ' src="'  .$thumbUrl.'"'.
  95.             ' style="'.$imgStyle.'"'.
  96.             ' />';
  97.  
  98.         if!empty$pParams['nolink') ) {
  99.         elseif!empty$wrapper['link') ) {
  100.             // if this image is linking to something, wrap the image with the <a>
  101.             $ret '<a href="'.trim$wrapper['link').'">'.$ret.'</a>';
  102.         elseif empty$pParams['size'|| $pParams['size'!= 'original' {
  103.             if $gBitSystem->isFeatureActive'site_fancy_zoom' and !empty$item->mInfo['source_url') ) {
  104.                 $ret '<a href="'.trimstr_replace(' ''%20'$item->mInfo['source_url') ).'">'.$ret.'</a>';
  105.             else if $item->getDownloadUrl() ) {
  106.                 $ret '<a href="'.trim$item->getDownloadUrl() ).'">'.$ret.'</a>';
  107.             else if !empty$item->mInfo['media_url') ) {
  108.                 $ret '<a href="'.trim$item->mInfo['media_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-plugin" ).'" style="'.$wrapper['style'].'">'.$ret.!empty$wrapper['description''<br />'.$wrapper['description''' ).'</'.$wrapper['wrapper'].'>';
  114.         }
  115.     else {
  116.         $ret tra"Unknown Image" );
  117.     }
  118.  
  119.     return $ret;
  120. }
  121.  
  122. function data_image_help({
  123.     $help =
  124.         '<table class="data help">'
  125.             .'<tr>'
  126.                 .'<th>' tra"Key" '</th>'
  127.                 .'<th>' tra"Type" '</th>'
  128.                 .'<th>' tra"Comments" '</th>'
  129.             .'</tr>'
  130.             .'<tr class="odd">'
  131.                 .'<td>id</td>'
  132.                 .'<td>' tra"numeric"'<br />' tra("(required)"'</td>'
  133.                 .'<td>' tra"Image id number of Image to display inline."tra"You can use either content_id or id." ).'</td>'
  134.             .'</tr>'
  135.             .'<tr class="even">'
  136.                 .'<td>size</td>'
  137.                 .'<td>' tra"key-words"'<br />' tra("(optional)"'</td>'
  138.                 .'<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> '
  139.                 . tra"(Default = " '<strong>medium</strong>)</td>'
  140.             .'</tr>'
  141.             .'<tr class="odd">'
  142.                 .'<td>nolink</td>'
  143.                 .'<td>' tra"key-words"'<br />' tra("(optional)"'</td>'
  144.                 .'<td>' tra"Remove hotlink from element. Used to display fixed copies of an image item."'</td>'
  145.             .'</tr>'
  146.         .'</table>'
  147.         . tra"Example: ""{image id='13' size='small'}";
  148.     return $help;
  149. }
  150. ?>

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