function getThumbnailImage($pContentId = NULL, $pThumbnailContentId = NULL, $pThumbnailContentType = NULL) { global $gLibertySystem, $gBitUser; $ret = NULL; if (!@$this->verifyId($pContentId) && !empty($this->mContentId)) { $pContentId = $this->mContentId; } if (!@$this->verifyId($pThumbnailContentId)) { if (@$this->verifyId($this->mInfo['preview_content_id'])) { $pThumbnailContentId = $this->mInfo['preview_content_id']; } else { if ($this->mDb->isAdvancedPostgresEnabled()) { $whereSql = ''; $bindVars = array($pContentId); if (!$gBitUser->isAdmin()) { $whereSql = " AND (cgm.`security_id` IS NULL OR lc.`user_id`=?) "; $bindVars[] = $gBitUser->mUserId; } $query = "SELECT COALESCE( fg.`preview_content_id`, lc.`content_id` ) AS `content_id`, lc.`content_type_guid`\n\t\t\t\t\t\t\t\tFROM connectby('`" . BIT_DB_PREFIX . "fisheye_gallery_image_map`', '`item_content_id`', '`gallery_content_id`', ?, 0, '/') AS t(`cb_item_content_id` int, `cb_parent_content_id` int, `level` int, `branch` text)\n\t\t\t\t\t\t\t\tINNER JOIN liberty_content lc ON(content_id=cb_item_content_id)\n\t\t\t\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "gatekeeper_security_map` cgm ON (cgm.`content_id`=lc.`content_id`), `" . BIT_DB_PREFIX . "fisheye_gallery` fg\n\t\t\t\t\t\t\t\tWHERE `cb_parent_content_id`=fg.`content_id` {$whereSql} "; // ORDER BY RANDOM() is DOG slow (seq scans) if ($row = $this->mDb->getRow($query, $bindVars)) { $pThumbnailContentType = $row['content_type_guid']; $pThumbnailContentId = $row['content_id']; } } else { $query = "SELECT fgim.`item_content_id`, lc.`content_type_guid`\n\t\t\t\t\t\t\tFROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( fgim.`item_content_id`=lc.`content_id` )\n\t\t\t\t\t\t\tWHERE fgim.`gallery_content_id` = ?\n\t\t\t\t\t\t\tORDER BY " . $this->mDb->convertSortmode('random'); $rs = $this->mDb->query($query, array($pContentId), 1); $pThumbnailContentId = $rs->fields['item_content_id']; $pThumbnailContentType = $rs->fields['content_type_guid']; } } } if (@$this->verifyId($pThumbnailContentId)) { $ret = parent::getLibertyObject($pThumbnailContentId, $pThumbnailContentType, $this->isCacheableObject()); if (is_a($ret, 'FisheyeGallery')) { //recurse down in to find the first image if ($ret = $ret->getThumbnailImage()) { $this->mInfo['thumbnail_content_id'] = $ret->getField('content_id'); } } else { $this->mInfo['thumbnail_content_id'] = $pThumbnailContentId; } } return $ret; }
public static function getTitleFromHash(&$pHash, $pDefault = TRUE) { $ret = trim(parent::getTitleFromHash($pHash, $pDefault)); if (empty($ret) && $pDefault) { $storage = !empty($this) && !empty($this->mStorage) ? current($this->mStorage) : NULL; if (!empty($storage['file_name'])) { $ret = $storage['file_name']; } else { global $gLibertySystem; $ret = $gLibertySystem->getContentTypeName($pHash['content_type_guid']); if (!empty($pHash['image_id'])) { $ret .= " " . $pHash['image_id']; } } } return $ret; }