<?php global $gQueryUser, $moduleParams; extract($moduleParams); $gFisheyeImage = new FisheyeImage(); if (!empty($module_rows)) { $_REQUEST['max_records'] = $module_rows; } elseif (!empty($_REQUEST['offset']) && is_numeric($_REQUEST['offset'])) { $gBitSmarty->assignByRef('iMaxRows', $iMaxRows); } if (empty($_REQUEST['sort_mode'])) { $_REQUEST['sort_mode'] = 'random'; } if (!empty($_REQUEST['search'])) { $gBitSmarty->assignByRef('iSearchString', $iSearchtring); } $gBitSmarty->assignByRef('iSortMode', $_REQUEST['sort_mode']); /* Get a list of galleries which matches the imput paramters (default is to list every gallery in the system) */ if (!empty($gQueryUser) && $gQueryUser->mUserId) { $_REQUEST['user_id'] = $gQueryUser->mUserId; } $_REQUEST['root_only'] = TRUE; $_REQUEST['get_thumbnails'] = TRUE; $thumbnailList = $gFisheyeImage->getList($_REQUEST); $gBitSmarty->assignByRef('thumbnailList', $thumbnailList); /* Process the input parameters this page accepts */ if (!empty($gQueryUser) && $gQueryUser->isRegistered()) { $gBitSmarty->assignByRef('gQuerUserId', $gQueryUser->mUserId); $template = 'user_galleries.tpl'; } else { $template = 'list_galleries.tpl';
<?php /** * @version $Header$ * @package itags * @subpackage functions */ global $gContent, $gGallery; if ($gContent = FisheyeImage::lookup($_REQUEST)) { // nothing to do. ::lookup will do a full load } else { $gContent = new FisheyeImage(); $imageId = NULL; } // This user does not own this image and they have not been granted the permission to edit this image $gContent->verifyViewPermission(); $gBitSmarty->assign_by_ref('gContent', $gContent); $gBitSmarty->assign_by_ref('imageId', $gContent->mImageId);
function data_gallery($pData, $pParams) { global $gBitSystem, $gBitSmarty; $ret = ' '; $imgStyle = ''; $wrapper = liberty_plugins_wrapper_style($pParams); $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL; foreach ($pParams as $key => $value) { if (!empty($value)) { switch ($key) { // rename a couple of parameters case 'width': case 'height': if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) { $imgStyle .= $key . ':' . $value . ';'; } elseif (preg_match("/^\\d+\$/", $value)) { $imgStyle .= $key . ':' . $value . 'px;'; } // remove values from the hash that they don't get used in the div as well $pParams[$key] = NULL; break; } } } $wrapper = liberty_plugins_wrapper_style($pParams); if (!empty($pParams['src'])) { $thumbUrl = $pParams['src']; } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) { require_once FISHEYE_PKG_PATH . 'FisheyeImage.php'; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); $gallery = new FisheyeImage(); $listHash = $pParams; $listHash['size'] = 'small'; $listHash['gallery_id'] = $pParams['id']; $listHash['max_records'] = 3; $listHash['sort_mode'] = 'random'; $images = $gallery->getList($listHash); $out = '<div>'; foreach ($images as $image) { // insert source url if we need the original file if (!empty($pParams['size']) && $pParams['size'] == 'original') { $thumbUrl = $image['source_url']; } elseif ($image['thumbnail_url']) { $thumbUrl = $image['thumbnail_url']; } if (empty($image['$description'])) { $description = !isset($wrapper['description']) ? $wrapper['description'] : $image['title']; } // check if we have a valid thumbnail if (!empty($thumbUrl)) { // set up image first $ret = '<img class="img-responsive"' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' style="float:left; ' . $imgStyle . '"' . ' />'; if (!empty($pParams['nolink'])) { } elseif (!empty($wrapper['link'])) { // if this image is linking to something, wrap the image with the <a> $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>'; } elseif (empty($pParams['size']) || $pParams['size'] != 'original') { if ($image['source_url']) { $ret = '<a href="' . trim($image['source_url']) . '">' . $ret . '</a>'; } } if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) { $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-responsive") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>'; } } else { $ret = tra("Unknown Gallery"); } $out .= $ret; } $out .= '</div>'; } return $out; }
<?php /** * @version $Header$ * @package fisheye * @subpackage modules */ global $gQueryUserId, $gContent, $moduleParams; // makes things in older modules easier extract($moduleParams); /** * required setup */ require_once FISHEYE_PKG_PATH . 'FisheyeGallery.php'; $image = new FisheyeImage(); $display = TRUE; $listHash = $module_params; $listHash['size'] = 'extra-large'; $listHash['gallery_id'] = $module_rows; $listHash['max_records'] = 5; $listHash['sort_mode'] = 'random'; $images = $image->getList($listHash); $moduleTitle = 'Banner Image'; $_template->tpl_vars['moduleTitle'] = new Smarty_variable($title); $_template->tpl_vars['modImages'] = new Smarty_variable($images); $_template->tpl_vars['module_params'] = new Smarty_variable($module_params);
$rss->description = $gBitSystem->getConfig('fisheye_rss_description', $gBitSystem->getConfig('site_title') . ' - ' . tra('RSS Feed')); // check permission to view fisheye images if (!$gBitUser->hasPermission('p_fisheye_view')) { require_once RSS_PKG_PATH . "rss_error.php"; } else { $listHash = array('max_records' => $gBitSystem->getConfig('fisheye_rss_max_records', 10), 'sort_mode' => 'last_modified_desc', 'gallery_id' => !empty($_REQUEST['gallery_id']) ? $_REQUEST['gallery_id'] : NULL, 'user_id' => !empty($_REQUEST['user_id']) ? $_REQUEST['user_id'] : NULL); // check if we want to use the cache file $cacheFile = TEMP_PKG_PATH . RSS_PKG_NAME . '/' . FISHEYE_PKG_NAME . '/' . "g{$listHash['gallery_id']}u{$listHash['user_id']}" . $cacheFileTail; $rss->useCached($rss_version_name, $cacheFile, $gBitSystem->getConfig('rssfeed_cache_time')); // if we have a gallery we can work with - load it if (@BitBase::verifyId($_REQUEST['gallery_id'])) { $gallery = new FisheyeGallery($_REQUEST['gallery_id']); $gallery->load(); $rss->title .= " - {$gallery->getTitle()}"; } $fisheye = new FisheyeImage(); $feeds = $fisheye->getList($listHash); // set the rss link $rss->link = 'http://' . $_SERVER['HTTP_HOST'] . FISHEYE_PKG_URL; global $gBitSystem; // get all the data ready for the feed creator foreach ($feeds as $feed) { $item = new FeedItem(); $item->title = $feed['title']; $item->link = $feed['display_url']; $item->description = '<a href="' . $feed['display_url'] . '"><img src="' . $feed['thumbnail_url'] . '" /></a>'; $item->description .= '<p>' . $feed['data'] . '</p>'; $item->date = (int) $feed['last_modified']; $item->source = 'http://' . $_SERVER['HTTP_HOST'] . BIT_ROOT_URL; $item->author = $gBitUser->getDisplayName(FALSE, $feed); $item->descriptionTruncSize = $gBitSystem->getConfig('rssfeed_truncate', 5000);
<?php /** * @version $Header$ * @package fisheye * @subpackage functions */ global $gContent, $gGallery; if ($gContent = FisheyeImage::lookup($_REQUEST)) { // nothing to do. ::lookup will do a full load } else { $gContent = new FisheyeImage(); $imageId = NULL; } if (!empty($_REQUEST['gallery_path'])) { $_REQUEST['gallery_path'] = rtrim($_REQUEST['gallery_path'], '/'); $gContent->setGalleryPath($_REQUEST['gallery_path']); $matches = array(); $tail = strrpos($_REQUEST['gallery_path'], '/'); $_REQUEST['gallery_id'] = substr($_REQUEST['gallery_path'], $tail + 1); } if (empty($_REQUEST['gallery_id'])) { if ($parents = $gContent->getParentGalleries()) { $gal = current($parents); $gContent->setGalleryPath('/' . $gal['gallery_id']); $_REQUEST['gallery_id'] = $gal['gallery_id']; } } // the image is considered the primary content, however the gallery is useful if (!empty($_REQUEST['gallery_id']) && is_numeric($_REQUEST['gallery_id'])) { $gGallery = FisheyeGallery::lookup($_REQUEST);
function data_image($pData, $pParams) { global $gBitSystem, $gBitSmarty; $ret = ' '; $imgStyle = ''; $wrapper = liberty_plugins_wrapper_style($pParams); $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL; foreach ($pParams as $key => $value) { if (!empty($value)) { switch ($key) { // rename a couple of parameters case 'width': case 'height': if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) { $imgStyle .= $key . ':' . $value . ';'; } elseif (preg_match("/^\\d+\$/", $value)) { $imgStyle .= $key . ':' . $value . 'px;'; } // remove values from the hash that they don't get used in the div as well $pParams[$key] = NULL; break; } } } $wrapper = liberty_plugins_wrapper_style($pParams); if (!empty($pParams['src'])) { $thumbUrl = $pParams['src']; } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) { require_once FISHEYE_PKG_PATH . 'FisheyeImage.php'; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); $item = new FisheyeImage($pParams['id'], NULL); if ($item->load()) { // insert source url if we need the original file if (!empty($pParams['size']) && $pParams['size'] == 'original') { $thumbUrl = $item->getDownloadUrl(); } elseif ($item->mInfo['thumbnail_url']) { $thumbUrl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium']; } if (empty($description)) { $description = !isset($wrapper['description']) ? $wrapper['description'] : $item->getField('title', tra('Image')); } } } // check if we have a valid thumbnail if (!empty($thumbUrl)) { // set up image first $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' style="' . $imgStyle . '"' . ' />'; if (!empty($pParams['nolink'])) { } elseif (!empty($wrapper['link'])) { // if this image is linking to something, wrap the image with the <a> $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>'; } elseif (empty($pParams['size']) || $pParams['size'] != 'original') { if ($gBitSystem->isFeatureActive('site_fancy_zoom') and !empty($item->mInfo['source_url'])) { $ret = '<a href="' . trim(str_replace(' ', '%20', $item->mInfo['source_url'])) . '">' . $ret . '</a>'; } else { if ($item->getDownloadUrl()) { $ret = '<a href="' . trim($item->getDownloadUrl()) . '">' . $ret . '</a>'; } else { if (!empty($item->mInfo['media_url'])) { $ret = '<a href="' . trim($item->mInfo['media_url']) . '">' . $ret . '</a>'; } } } } if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) { $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>'; } } else { $ret = tra("Unknown Image"); } return $ret; }
function loadCurrentImage($pCurrentImageId) { if ($this->isValid() && @$this->verifyId($pCurrentImageId)) { // this code sucks but works - XOXO spiderr $query = "SELECT fgim.*, fi.`image_id`, lf.`file_name`, lf.`user_id`, lf.`mime_type`, la.`attachment_id`\n\t\t\t\t\tFROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "fisheye_image` fi ON ( fi.`content_id`=fgim.`item_content_id` )\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON ( fi.`content_id`=la.`content_id` )\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf ON ( lf.`file_id`=la.`foreign_id` )\n\t\t\t\t\tWHERE fgim.`gallery_content_id` = ?\n\t\t\t\t\tORDER BY fgim.`item_position`, fi.`content_id` "; if ($rs = $this->mDb->query($query, array($this->mContentId))) { $tempImage = new FisheyeImage(); $rows = $rs->getRows(); for ($i = 0; $i < count($rows); $i++) { if ($rows[$i]['image_id'] == $pCurrentImageId) { if ($i > 0) { $this->mInfo['previous_image_id'] = $rows[$i - 1]['image_id']; $this->mInfo['previous_image_avatar'] = liberty_fetch_thumbnail_url(array('file_name' => $rows[$i - 1]['file_name'], 'source_file' => $tempImage->getSourceFile($rows[$i - 1]), 'mime_image' => TRUE, 'size' => 'avatar')); } if ($i + 1 < count($rows)) { $this->mInfo['next_image_id'] = $rows[$i + 1]['image_id']; $this->mInfo['next_image_avatar'] = liberty_fetch_thumbnail_url(array('file_name' => $rows[$i + 1]['file_name'], 'source_file' => $tempImage->getSourceFile($rows[$i + 1]), 'mime_image' => TRUE, 'size' => 'avatar')); } } } } } }
$gBitDb->StartTrans(); $sql = "SELECT pq.content_id AS hash_key, pq.*\n\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_process_queue` pq\n\t\t\tWHERE pq.begin_date IS NULL\n\t\t\tORDER BY pq.queue_date"; $rs = $gBitSystem->mDb->query($sql, FALSE, $thumbCount); $processContent = array(); while (!$rs->EOF) { $processContent[$rs->fields['content_id']] = $rs->fields; $processContent[$rs->fields['content_id']]['parameters'] = unserialize($rs->fields['processor_parameters']); $sql2 = "UPDATE `" . BIT_DB_PREFIX . "liberty_process_queue` SET `begin_date`=? WHERE `content_id`=?"; $rs2 = $gBitSystem->mDb->query($sql2, array(date('U'), $rs->fields['content_id'])); $rs->MoveNext(); } $gBitDb->CompleteTrans(); $log = array(); $total = date('U'); foreach (array_keys($processContent) as $contentId) { $image = new FisheyeImage(NULL, $contentId); $begin = date('U'); if (!empty($processContent[$contentId]['parameters']['resize_original'])) { $image->resizeOriginal($processContent[$contentId]['parameters']['resize_original']); } if ($image->renderThumbnails()) { $log[$contentId]['message'] = 'SUCCESS: Thumbnails created'; $sql3 = "UPDATE `" . BIT_DB_PREFIX . "liberty_process_queue` SET `begin_date`=?, `end_date`=? WHERE `content_id`=?"; $rs3 = $gBitSystem->mDb->query($sql3, array($begin, $gBitSystem->getUTCTime(), $contentId)); } else { $log[$contentId]['message'] = ' ERROR: ' . $image->mErrors['thumbnail']; } $log[$contentId]['time'] = date('d/M/Y:H:i:s O'); $log[$contentId]['duration'] = date('U') - $begin; $log[$contentId]['delay'] = date('U') - $total; }
function fisheye_process_ftp_directory($pProcessDir) { global $gBitSystem, $gBitUser; if (empty($_REQUEST['gallery_additions'])) { $_REQUEST['gallery_additions'] = array(); } $errors = array(); if ($archiveDir = opendir($pProcessDir)) { $order = 100; while ($fileName = readdir($archiveDir)) { $sortedNames[] = $fileName; } sort($sortedNames); $order = 100; foreach ($sortedNames as $fileName) { if (!preg_match('/^\\./', $fileName) && $fileName != 'Thumbs.db') { $scanFile = array('type' => $gBitSystem->lookupMimeType(substr($fileName, strrpos($fileName, '.') + 1)), 'name' => $fileName, 'size' => filesize("{$pProcessDir}/{$fileName}"), 'tmp_name' => "{$pProcessDir}/{$fileName}"); if (is_dir($pProcessDir . '/' . $fileName)) { // create a new gallery from directory $dirGallery = new FisheyeGallery(); $galleryHash = array('title' => str_replace('_', ' ', $fileName)); if ($dirGallery->store($galleryHash)) { $dirGallery->addToGalleries($_REQUEST['gallery_additions']); $errors = array_merge($errors, fisheye_process_directory($pProcessDir . '/' . $fileName, $dirGallery)); } else { $errors = array_merge($errors, array_values($dirGallery->mErrors)); } unset($dirGallery); } else { if (preg_match('/(^image|pdf)/i', $scanFile['type'])) { // process image $newImage = new FisheyeImage(); $imageHash = array('upload' => $scanFile); if ($newImage->store($imageHash)) { $newImage->addToGalleries($_REQUEST['gallery_additions']); // if we have a gallery to add these images to, load one of them if (!empty($_REQUEST['gallery_additions'][0]) && @(!is_object($imageGallery))) { $imageGallery = new FisheyeGallery(); $imageGallery->mGalleryId = $_REQUEST['gallery_additions'][0]; $imageGallery->load(); } if (@(!is_object($imageGallery))) { global $gBitUser; $galleryHash = array('title' => $gBitUser->getDisplayName() . "'s Gallery"); $imageGallery = new FisheyeGallery(); if ($imageGallery->store($galleryHash)) { $imageGallery->load(); } else { $errors = array_merge($errors, array_values($imageGallery->mErrors)); } } $imageGallery->addItem($newImage->mContentId); } else { $errors = array_merge($errors, array_values($newImage->mErrors)); } } else { // create a new gallery from archive $archiveGallery = new FisheyeGallery(); $galleryHash = array('title' => substr($fileName, 0, str_replace('_', ' ', strrpos($fileName, '.')))); if (!$archiveGallery->store($galleryHash)) { $errors = array_merge($errors, array_values($archiveGallery->mErrors)); } $errors = fisheye_process_archive($scanFile, $archiveGallery, TRUE); unset($archiveGallery); } } $order += 10; } } } return $errors; }
/** * Generate a valid display link for the Blog * * @param object PostId of the item to use * @param array Not used * @return object Fully formatted html link for use by Liberty */ function getDisplayLink($pTitle = NULL, $pMixed = NULL, $pAnchor = NULL) { global $gBitSystem; $pTitle = trim($pTitle); if (empty($pMixed) && !empty($this)) { $pMixed = $this->mInfo; } if (empty($pTitle)) { $pTitle = FisheyeImage::getTitleFromHash($pMixed); } $ret = $pTitle; if ($gBitSystem->isPackageActive('fisheye')) { $ret = '<a title="' . $pTitle . '" href="' . FisheyeImage::getDisplayUrlFromHash($pMixed) . '">' . $pTitle . '</a>'; } return $ret; }
function data_carousel($pData, $pParams) { global $gBitSystem, $gBitSmarty; $ret = ' '; $imgStyle = ''; $wrapper = liberty_plugins_wrapper_style($pParams); $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL; foreach ($pParams as $key => $value) { if (!empty($value)) { switch ($key) { // rename a couple of parameters case 'width': case 'height': if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) { $imgStyle .= $key . ':' . $value . ';'; } elseif (preg_match("/^\\d+\$/", $value)) { $imgStyle .= $key . ':' . $value . 'px;'; } // remove values from the hash that they don't get used in the div as well $pParams[$key] = NULL; break; } } } $wrapper = liberty_plugins_wrapper_style($pParams); $pParams['nolink'] = 'yes'; if (!empty($pParams['src'])) { $thumbUrl = $pParams['src']; } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) { require_once FISHEYE_PKG_PATH . 'FisheyeImage.php'; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); $gallery = new FisheyeImage(); $listHash = $pParams; $listHash['size'] = 'large'; $listHash['gallery_id'] = $pParams['id']; $listHash['max_records'] = 10; $listHash['sort_mode'] = 'item_position_asc'; $images = $gallery->getList($listHash); $num = count($images); $out = '<div class="carousel slide" data-ride="carousel" id="myCarousel">'; $out .= '<ol class="carousel-indicators">'; $out .= '<li class="active" data-slide-to="0" data-target="#myCarousel"> </li>'; for ($i = 1; $i < $num; $i++) { $out .= '<li data-slide-to="' . $i . '" data-target="#myCarousel"> </li>'; } $out .= '</ol>'; $out .= '<div class="carousel-inner" role="listbox">'; $i = 0; foreach ($images as $image) { // insert source url if we need the original file if (!empty($pParams['size']) && $pParams['size'] == 'original') { $thumbUrl = $image['source_url']; } elseif ($image['thumbnail_url']) { $thumbUrl = $image['thumbnail_url']; } if (empty($image['$description'])) { $description = !isset($wrapper['description']) ? $wrapper['description'] : $image['title']; } // check if we have a valid thumbnail if (!empty($thumbUrl)) { if ($i == 0) { $active = ' active'; } else { $active = ''; } $i++; // set up image first $ret = '<div class="item' . $active . '"><img class="img-responsive"' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' height="103" width="800"' . ' /></div>'; if (!empty($pParams['nolink'])) { } elseif (!empty($wrapper['link'])) { // if this image is linking to something, wrap the image with the <a> $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>'; } elseif (empty($pParams['size']) || $pParams['size'] != 'original') { if ($image['source_url']) { $ret = '<a href="' . trim($image['source_url']) . '">' . $ret . '</a>'; } } if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) { $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-responsive") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>'; } } else { $ret = tra("Unknown Gallery"); } $out .= $ret; } $out .= '</div>'; $out .= '<a class="left carousel-control" data-slide="prev" href="#myCarousel" role="button">'; $out .= '<span class="sr-only">Previous</span> </a>'; $out .= '<a class="right carousel-control" data-slide="next" href="#myCarousel" role="button">'; $out .= '<span class="sr-only">Next</span> </a></div>'; $out .= '</div>'; } return $out; }