function data_file($pData, $pParams) { global $gBitSystem, $gBitSmarty; $ret = ' '; if (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('treasury')) { require_once TREASURY_PKG_PATH . 'TreasuryItem.php'; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); $item = new TreasuryItem(); $item->mContentId = $item->getContentIdFromAttachmentId($pParams['id']); if ($item->load()) { // insert source url if we need the original file if (!empty($pParams['size']) && $pParams['size'] == 'original') { $thumburl = $item->getField('source_url'); } elseif ($item->getField('thumbnail_url')) { $thumburl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium']; } // check if we have a valid thumbnail if (!empty($thumburl)) { $wrapper = liberty_plugins_wrapper_style($pParams); $description = !empty($wrapper['description']) ? $wrapper['description'] : $item->getField('data', tra('Image')); // set up image first $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumburl . '"' . ' />'; if ($item->getField('file_size')) { $ret .= '<br />' . $item->getField('title') . "<br /><small>(" . $item->getField('mime_type') . " " . smarty_modifier_display_bytes($item->getField('file_size')) . ")</small>"; } if (!empty($description) && !empty($pParams['output']) && ($pParams['output'] == 'desc' || $pParams['output'] == 'description')) { $ret = $description; $nowrapper = TRUE; } else { $ret .= !empty($wrapper['description']) ? '<br />' . $wrapper['description'] : ''; } // use specified link as href. insert default link to source only when // source not already displayed if (!empty($pParams['link']) && $pParams['link'] == 'false') { } elseif (!empty($pParams['link'])) { if (strstr($pParams['link'], $_SERVER["SERVER_NAME"]) || !strstr($pParams['link'], '//')) { $class = ''; } else { $class = 'class="external"'; } $ret = '<a ' . $class . ' href="' . trim($pParams['link']) . '">' . $ret . '</a>'; } elseif (empty($pParams['download']) && $item->getField('display_url')) { $ret = '<a href="' . trim($item->getField('display_url')) . '">' . $ret . '</a>'; } elseif (!empty($pParams['download']) && ($pParams['download'] = 'direct')) { $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>'; } elseif (!empty($pParams['download']) && $item->getField('download_url')) { $ret = '<a href="' . trim($item->getField('download_url')) . '">' . $ret . '</a>'; } elseif (empty($pParams['size']) || $pParams['size'] != 'original') { $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>'; } // finally, wrap the output. if (empty($nowrapper)) { $ret = '<!-- ~np~ --><' . $wrapper['wrapper'] . ' class="' . (isset($wrapper) && !empty($wrapper['class']) ? $wrapper['class'] : "att-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . '</' . $wrapper['wrapper'] . '><!-- ~/np~ -->'; } } else { $ret = tra("There was a problem getting an image for the file."); } } else { $ret = tra("The attachment id given is not valid."); } } else { $ret = tra("The attachment id given is not valid."); } return $ret; }
$rss->link = TREASURY_PKG_URI; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); // get all the data ready for the feed creator foreach ($feeds as $feed) { $item = new FeedItem(); $item->title = $feed->getTitle(); $item->link = $feed->getField('display_url'); $item->date = (int) $feed->getField('last_modified'); $item->source = BIT_ROOT_URI; if (!empty($feed->mInfo['thumbnail_url']['medium'])) { $item->description = '<a href="' . $feed->getField('display_url') . '"><img src="' . $feed->mInfo['thumbnail_url']['medium'] . '" /></a>'; } $item->description .= "<ul>"; if ($feed->getField('parsed_data')) { $item->description .= "<li>" . tra('Description') . ": {$feed->getField('parsed_data')}</li>"; } $item->description .= "<li>" . tra('Filename') . ": {$feed->getField('filename')} [" . smarty_modifier_display_bytes($feed->getField('file_size')) . "]</li>"; $item->description .= "</ul>"; $userHash = array('user_id' => $feed->getField('user_id')); $user = $gBitUser->getUserInfo($userHash); if (isset($user['email'])) { $item->author = $user['email'] . " (" . $gBitUser->getDisplayName(FALSE, $feed->mInfo) . ")"; } $item->descriptionTruncSize = $gBitSystem->getConfig('rssfeed_truncate', 5000); $item->descriptionHtmlSyndicated = FALSE; // pass the item on to the rss feed creator $rss->addItem($item); } // finally we are ready to serve the data echo $rss->saveFeed($rss_version_name, $cacheFile); }