see http://phpdocu.sourceforge.net/ // +----------------------------------------------------------------------+ // | Authors: drewslater // +----------------------------------------------------------------------+ // $Id$ /** * definitions */ global $gBitSystem; define( 'PLUGIN_GUID_DATAATTACHMENT', 'dataattachment' ); global $gLibertySystem; $pluginParams = array ( 'tag' => 'attachment', 'auto_activate' => TRUE, 'requires_pair' => FALSE, 'load_function' => 'data_attachment', 'title' => 'Attachment', 'help_page' => 'DataPluginAttachment', 'description' => tra("Display attachment in content"), 'help_function' => 'data_attachment_help', 'syntax' => '{attachment id= size= align= }', 'plugin_type' => DATA_PLUGIN, 'booticon' => '{booticon iname="icon-paper-clip" iexplain="Attachment"}', 'taginsert' => '{attachment id= align= size= description= alt=}', ); $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAATTACHMENT, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAATTACHMENT ); function data_attachment_help() { $help = '' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'
' . tra( "Key" ) . '' . tra( "Type" ) . '' . tra( "Comments" ) . '
id' . tra( "numeric") . '
' . tra("(required)") . '
' . tra( "Id number of Attachment to display inline.") . '
size' . tra( "key-words") . '
' . tra("(optional)") . '
' . tra( "If the Attachment is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' avatar, small, medium, large, original ' . tra( "(Default = " ) . 'medium)
description' . tra( "string") . '
' . tra( "(optional)" ) . '
' . 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." ) .tra( "(Default = " ) . ''.tra( 'Image' ).')
alt' . tra( "string") . '
' . tra("(optional)") . '
' . tra( "The text to use in the alt tag. Will also be used for the title attribute if no description is specified.") . tra("(Default = ") . ''.tra( 'Image' ).')
link' . tra( "string") . '
' . tra("(optional)") . '
' . 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.") . tra("(Default = ") . ''.tra( 'link to image details page' ).')
page_id '.tra( 'numeric (optional)' ).' '.tra( "To include any wiki page you can use it's page_id number." ).'
content_id '.tra( 'numeric (optional)' ).' '.tra( 'To include any content from bitweaver insert the appropriate numeric content id. This can include blog posts, images, wiki texts...
Available content can be viewed here' ).'
output '.tra( 'keyword (optional)' ).' '.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." ).'
'.tra( "styling" ).''.tra( "string").'
'.tra("(optional)").'
'.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 CSS guidelines on what values these settings take.").'
' . tra("Example: ") . ' ' . "{ATTACHMENT id='13' size='small' text-align='center' link='http://www.google.com'}" . '
' . tra("Example: ") . ' ' . "{ATTACHMENT id='11' description='Text, the link will be wrapped around' output=desc}"; return $help; } function data_attachment( $pData, $pParams, $pCommonObject, $pParseHash ) { require_once( LIBERTY_PKG_PATH.'LibertyMime.php' ); // at a minimum, return blank string (not empty) so we still replace the tag $ret = ' '; // The Manditory Parameter is missing. we are not gonna trow an error, and // just return empty since many sites use the old style required second // "closing" empty tag if( empty( $pParams['id'] )) { return $ret; } if( !$att = $pCommonObject->getAttachment( $pParams['id'], $pParams )) { $ret = tra( "The attachment id given is not valid." ); return $ret; } global $gBitSmarty, $gLibertySystem, $gContent; // convert parameters into display properties $wrapper = liberty_plugins_wrapper_style( $pParams ); // work out custom display_url if there is one if( @BitBase::verifyId( $pParams['page_id'] )) { // link to page by page_id // avoid endless loops require_once( WIKI_PKG_PATH.'BitPage.php'); $wp = new BitPage( $pParams['page_id'] ); if( $wp->load() ) { $wrapper['display_url'] = $wp->getDisplayUrl(); } } elseif( @BitBase::verifyId( $pParams['content_id'] )) { // link to any content by content_id if( $obj = LibertyBase::getLibertyObject( $pParams['content_id'] )) { $wrapper['display_url'] = $obj->getDisplayUrl(); } } elseif( !empty( $pParams['page_name'] )) { // link to page by page_name require_once( WIKI_PKG_PATH.'BitPage.php'); $wp = new BitPage(); $wrapper['display_url'] = $wp->getDisplayUrl( $pParams['page_name'] ); } elseif( !empty( $pParams['link'] ) && $pParams['link'] == 'false' ) { // no link } elseif( !empty( $pParams['link'] )) { // Allow the use of icon, avatar, small, medium and large to link to certain size of image directly if( !empty( $att['thumnail_url'][$pParams['link']] )) { $pParams['link'] = $att['thumnail_url'][$pParams['link']]; // Allow the use of 'original' to link to original file directly } elseif( $pParams['link'] == 'original' && !empty( $att['source_url'] )) { $pParams['link'] = $att['source_url']; // Allow the use of 'download' to link to download link. this will allow us to count downloads } elseif( $pParams['link'] == 'download' && !empty( $att['download_url'] )) { $pParams['link'] = $att['download_url']; // Adjust class name if we are leaving this server } elseif( !strstr( $pParams['link'], $_SERVER["SERVER_NAME"] ) && strstr( $pParams['link'], '//' )) { $wrapper['href_class'] = 'class="external"'; } $wrapper['display_url'] = $pParams['link']; } elseif( !empty( $att['display_url'] ) ) { $wrapper['display_url'] = $att['display_url']; } if( !empty( $wrapper['description'] )) { $parseHash['content_id'] = $pParseHash['content_id']; $parseHash['user_id'] = $pParseHash['user_id']; $parseHash['no_cache'] = TRUE; $parseHash['data'] = $wrapper['description']; $wrapper['description_parsed'] = $pCommonObject->parseData( $parseHash ); } // pass stuff to the template $gBitSmarty->assign( 'attachment', $att ); $gBitSmarty->assign( 'wrapper', $wrapper ); $gBitSmarty->assign( 'thumbsize', (( !empty( $pParams['size'] ) && ( $pParams['size'] == 'original' || !empty( $att['thumbnail_url'][$pParams['size']] ))) ? $pParams['size'] : 'medium' )); //Carry only these attributes to the image tags $width = !empty( $pParams['width'] ) ? $pParams['width'] : ''; $gBitSmarty->assign( 'width', $width ); $height = !empty( $pParams['height'] ) ? $pParams['height'] : ''; $gBitSmarty->assign( 'height', $height ); $mimehandler = (( !empty( $wrapper['output'] ) && $wrapper['output'] == 'thumbnail' ) ? LIBERTY_DEFAULT_MIME_HANDLER : $att['attachment_plugin_guid'] ); $ret = $gBitSmarty->fetch( $gLibertySystem->getMimeTemplate( 'attachment', $mimehandler )); return $ret; } ?>