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

Source for file data.attachment.php

Documentation is available at data.attachment.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2004, bitweaver.org
  9. // +----------------------------------------------------------------------+
  10. // | All Rights Reserved. See below for details and a complete list of authors.
  11. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  12. // |
  13. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  14. // | -> see http://phpdocu.sourceforge.net/
  15. // +----------------------------------------------------------------------+
  16. // | Authors: drewslater <andrew@andrewslater.com>
  17. // +----------------------------------------------------------------------+
  18. // $Id$
  19.  
  20. /**
  21.  * definitions
  22.  */
  23. global $gBitSystem;
  24.  
  25. define'PLUGIN_GUID_DATAATTACHMENT''dataattachment' );
  26. global $gLibertySystem;
  27. $pluginParams array (
  28.     'tag'           => 'attachment',
  29.     'auto_activate' => TRUE,
  30.     'requires_pair' => FALSE,
  31.     'load_function' => 'data_attachment',
  32.     'title'         => 'Attachment',
  33.     'help_page'     => 'DataPluginAttachment',
  34.     'description'   => tra("Display attachment in content"),
  35.     'help_function' => 'data_attachment_help',
  36.     'syntax'        => '{attachment id= size= align= }',
  37.     'plugin_type'   => DATA_PLUGIN,
  38.     'booticon'       => '{booticon iname="icon-paper-clip" iexplain="Attachment"}',
  39.     'taginsert'     => '{attachment id= align= size= description= alt=}',
  40. );
  41. $gLibertySystem->registerPluginPLUGIN_GUID_DATAATTACHMENT$pluginParams );
  42. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAATTACHMENT );
  43.  
  44.  
  45. function data_attachment_help({
  46.     $help =
  47.         '<table class="data help">'
  48.             .'<tr>'
  49.                 .'<th>' tra"Key" '</th>'
  50.                 .'<th>' tra"Type" '</th>'
  51.                 .'<th>' tra"Comments" '</th>'
  52.             .'</tr>'
  53.             .'<tr class="odd">'
  54.                 .'<td>id</td>'
  55.                 .'<td>' tra"numeric"'<br />' tra("(required)"'</td>'
  56.                 .'<td>' tra"Id number of Attachment to display inline."'</td>'
  57.             .'</tr>'
  58.             .'<tr class="even">'
  59.                 .'<td>size</td>'
  60.                 .'<td>' tra"key-words"'<br />' tra("(optional)"'</td>'
  61.                 .'<td>' tra"If the Attachment is an image, you can specify the size of the thumbnail displayed. Possible values are:"' <strong>avatar, small, medium, large, original</strong> '
  62.                 . tra"(Default = " '<strong>medium</strong>)</td>'
  63.             .'</tr>'
  64.             .'<tr class="odd">'
  65.                 .'<td>description</td>'
  66.                 .'<td>' tra"string"'<br />' tra"(optional)" '</td>'
  67.                 .'<td>' tra"The text to use in the title attribute or as the link text if output=desc. Will also be used for the alt attribute if no alt is specified. This text is parsed." )
  68.                 .tra"(Default = " '<strong>'.tra'Image' ).'</strong>)</td>'
  69.             .'</tr>'
  70.             .'<tr class="even">'
  71.                 .'<td>alt</td>'
  72.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  73.                 .'<td>' tra"The text to use in the alt tag. Will also be used for the title attribute if no description is specified.")
  74.                 . tra("(Default = "'<strong>'.tra'Image' ).'</strong>)</td>'
  75.             .'</tr>'
  76.             .'<tr class="odd">'
  77.                 .'<td>link</td>'
  78.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  79.                 .'<td>' tra"Allows you to specify a relative or absolute URL the image will link to if clicked. You can also link to one of the sizes of the image: icon, avatar, small, medium, large, original and download (insert download link, which will activate the download counter). If set to false, no link is inserted.")
  80.                 . tra("(Default = "'<strong>'.tra'link to image details page' ).'</strong>)</td>'
  81.             .'</tr>'
  82.             .'<tr class="even">
  83.                 <td>page_id</td>
  84.                 <td>'.tra'numeric (optional)' ).'</td>
  85.                 <td>'.tra"To include any wiki page you can use it's page_id number." ).'</td>
  86.             </tr>
  87.             <tr class="odd">
  88.                 <td>content_id</td>
  89.                 <td>'.tra'numeric (optional)' ).'</td>
  90.                 <td>'.tra'To include any content from bitweaver insert the appropriate numeric content id. This can include blog posts, images, wiki texts...<br />
  91.                     Available content can be viewed <a href="'.LIBERTY_PKG_URL.'list_content.php">here</a>' ).'</td>
  92.             </tr>
  93.             <tr class="even">
  94.                 <td>output</td>
  95.                 <td>'.tra'keyword (optional)' ).'</td>
  96.                 <td>'.tra"If you are attaching a file and you only want to display the description and not the image that goes with it, use: output=desc. If you want to force the use of a thumbnail, use output=thumbnail." ).'</td>
  97.             </tr>'
  98.             .'<tr class="odd">'
  99.                 .'<td>'.tra"styling" ).'</td>'
  100.                 .'<td>'.tra"string").'<br />'.tra("(optional)").'</td>'
  101.                 .'<td>'.tra"Multiple styling options available: width, height, background, background-color, border, color, display, float, font, font-family, font-size, font-weight, margin, overflow, padding, text-align, align. Please view <a href='http://www.w3.org/TR/CSS21/indexlist.html'>CSS guidelines</a> on what values these settings take.").'</td>'
  102.             .'</tr>'
  103.         .'</table>'
  104.         . tra("Example: "' ' "{ATTACHMENT id='13' size='small' text-align='center' link='http://www.google.com'}"
  105.         . '<br />'
  106.         . tra("Example: "' ' "{ATTACHMENT id='11' description='Text, the link will be wrapped around' output=desc}";
  107.     return $help;
  108. }
  109.  
  110. function data_attachment$pData$pParams$pCommonObject$pParseHash {
  111.     require_onceLIBERTY_PKG_PATH.'LibertyMime.php' );
  112.  
  113.     // at a minimum, return blank string (not empty) so we still replace the tag
  114.     $ret ' ';
  115.  
  116.     // The Manditory Parameter is missing. we are not gonna trow an error, and
  117.     // just return empty since many sites use the old style required second
  118.     // "closing" empty tag
  119.     ifempty$pParams['id')) {
  120.         return $ret;
  121.     }
  122.  
  123.     if!$att $pCommonObject->getAttachment$pParams['id']$pParams )) {
  124.         $ret tra"The attachment id given is not valid." );
  125.         return $ret;
  126.     }
  127.  
  128.     global $gBitSmarty$gLibertySystem$gContent;
  129.     // convert parameters into display properties
  130.     $wrapper liberty_plugins_wrapper_style$pParams );
  131.     // work out custom display_url if there is one
  132.     if@BitBase::verifyId$pParams['page_id')) {
  133.         // link to page by page_id
  134.         // avoid endless loops
  135.  
  136.         require_onceWIKI_PKG_PATH.'BitPage.php');
  137.         $wp new BitPage$pParams['page_id');
  138.         if$wp->load() ) {
  139.                 $wrapper['display_url'$wp->getDisplayUrl();
  140.         }
  141.     elseif@BitBase::verifyId$pParams['content_id')) {
  142.         // link to any content by content_id
  143.         if$obj LibertyBase::getLibertyObject$pParams['content_id')) {
  144.                 $wrapper['display_url'$obj->getDisplayUrl();
  145.         }
  146.     elseif!empty$pParams['page_name')) {
  147.         // link to page by page_name
  148.         require_onceWIKI_PKG_PATH.'BitPage.php');
  149.         $wp new BitPage();
  150.             $wrapper['display_url'$wp->getDisplayUrl$pParams['page_name');
  151.     elseif!empty$pParams['link'&& $pParams['link'== 'false' {
  152.         // no link
  153.     elseif!empty$pParams['link')) {
  154.         // Allow the use of icon, avatar, small, medium and large to link to certain size of image directly
  155.         if!empty$att['thumnail_url'][$pParams['link']] )) {
  156.             $pParams['link'$att['thumnail_url'][$pParams['link']];
  157.  
  158.         // Allow the use of 'original' to link to original file directly
  159.         elseif$pParams['link'== 'original' && !empty$att['source_url')) {
  160.             $pParams['link'$att['source_url'];
  161.  
  162.         // Allow the use of 'download' to link to download link. this will allow us to count downloads
  163.         elseif$pParams['link'== 'download' && !empty$att['download_url')) {
  164.             $pParams['link'$att['download_url'];
  165.  
  166.         // Adjust class name if we are leaving this server
  167.         elseif!strstr$pParams['link']$_SERVER["SERVER_NAME"&& strstr$pParams['link']'//' )) {
  168.             $wrapper['href_class''class="external"';
  169.         }
  170.         $wrapper['display_url'$pParams['link'];
  171.     elseif!empty$att['display_url') )  {
  172.             $wrapper['display_url'$att['display_url'];
  173.         }
  174.  
  175.     if!empty$wrapper['description')) {
  176.         $parseHash['content_id'$pParseHash['content_id'];
  177.         $parseHash['user_id']    $pParseHash['user_id'];
  178.         $parseHash['no_cache']   TRUE;
  179.         $parseHash['data']       $wrapper['description'];
  180.         $wrapper['description_parsed'$pCommonObject->parseData$parseHash );
  181.     }
  182.  
  183.     // pass stuff to the template
  184.     $gBitSmarty->assign'attachment'$att );
  185.     $gBitSmarty->assign'wrapper'$wrapper );
  186.     $gBitSmarty->assign'thumbsize'(( !empty$pParams['size'&& $pParams['size'== 'original' || !empty$att['thumbnail_url'][$pParams['size']] ))) $pParams['size''medium' ));
  187.  
  188.     //Carry only these attributes to the image tags
  189.     $width !empty$pParams['width'$pParams['width''';
  190.     $gBitSmarty->assign'width'$width );
  191.  
  192.     $height !empty$pParams['height'$pParams['height''';
  193.     $gBitSmarty->assign'height'$height );
  194.  
  195.     $mimehandler (( !empty$wrapper['output'&& $wrapper['output'== 'thumbnail' LIBERTY_DEFAULT_MIME_HANDLER $att['attachment_plugin_guid');
  196.     $ret $gBitSmarty->fetch$gLibertySystem->getMimeTemplate'attachment'$mimehandler ));
  197.     return $ret;
  198. }
  199. ?>

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