*/ /** * This implements the standard gallery theme * * @package GalleryTheme * @subpackage Theme */ class WordpressEmbeddedTheme extends GalleryTheme { /* * Constructor */ function WordpressEmbeddedTheme() { global $gallery; $this->setId('wordpressembedded'); $this->setName($gallery->i18n('WordpressEmbedded')); $this->setDescription($gallery->i18n('Standard Wordpress Gallery2 Embedded look and feel')); $this->setVersion('1.0.0'); $this->setRequiredCoreApi(array(7, 10)); $this->setRequiredThemeApi(array(2, 4)); $this->setStandardSettings( array('rows' => 3, 'columns' => 3, 'showImageOwner' => 0, 'showAlbumOwner' => 1, 'albumFrame' => '', 'itemFrame' => '', 'photoFrame' => '', 'colorpack' => '', 'showMicroThumbs' => 0, 'dynamicLinks' => 'browse', 'sidebarBlocks' => serialize(array( array('search.SearchBlock', array('showAdvancedLink' => true)), array('core.ItemLinks', array('useDropdown' => false)), array('core.PeerList', array()), array('imageblock.ImageBlock', array()))), 'albumBlocks' => serialize(array( array('comment.ViewComments', array()))), 'photoBlocks' => serialize(array( array('exif.ExifInfo', array()), array('comment.ViewComments', array()))))); } /* * @see GalleryTheme::showAlbumPage */ function showAlbumPage(&$template, $item, $params, $childIds) { global $gallery; $ret = $this->loadCommonTemplateData( $template, $item, $params, array('owner', 'viewCount', 'childCount', 'descendentCount', 'parents', 'systemLinks', 'itemLinks', 'itemSummaries', 'permissions', 'thumbnails', 'pageNavigator', 'jumpRange', 'childItemLinksDetailed' ), $childIds); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } /* Add in our extra stuff */ $theme =& $template->getVariableByReference('theme'); $theme['columnWidthPct'] = floor(100 / $params['columns']); list ($lightboxMode, $lightboxSize, $returnName, $returnUrl ) = GalleryUtilities::getRequestVariables('wpg2_lightbox', 'wpg2_lightboxsize', 'wpg2_returnname', 'wpg2_returnurl'); /* Get the External Variables */ if ($returnName != null) $theme['returnName'] = $returnName; else $theme['returnName'] = "Home"; if ($returnUrl != null) $theme['returnUrl'] = $returnUrl; else $theme['returnUrl'] = '/'; if ($lightboxMode != null) { $theme['lightboxMode'] = $lightboxMode; /* Add resizedId to child values, required for Lightbox JS */ if ( $theme['children'] ){ foreach ( $theme['children'] as $key => $value ){ if ( $value['id'] ){ list($ret, $resizedIds) = GalleryCoreApi::fetchResizesByItemIds(array($value['id'])); if ($ret) return $ret; } if (!$value['canContainChildren']) { list ($ret, $itemId) = GalleryCoreApi::loadEntitiesById($value['id']); if (!$ret) { if (isset($value['thumbnail'])) { $isViewable = $itemId->getMimeType(); $isViewable = strpos($isViewable, 'image'); if ($isViewable !== FALSE) { $theme['children'][$key]['resizedId'] = $value['id']; } } } } if ( $resizedIds ){ if ($lightboxSize == null) { /* Pick the largest version */ $lightboxSize = 99999; } /* Search the closest match in size */ $target = null; $targetdiff = 99999; $resizedId = null; foreach ( $resizedIds[$value['id']] as $resize ){ $isViewable = $resize->getMimeType(); $isViewable = strpos($isViewable, 'image'); if ($isViewable !== FALSE) { $diff = $resize->getHeight() - $lightboxSize; if ($diff >= 0 && $diff < $targetdiff ) { $target = $resize->getId(); $targetdiff = $diff; } } } if (!$target == null) { $theme['children'][$key]['resizedId'] = $target; } } } } } $session =& $gallery->getSession(); list ($detailMode, $return) = GalleryUtilities::getRequestVariables('detailMode', 'return'); if ($detailMode != null) { $session->put('theme.detailMode', $detailMode); return array(null, array('redirectUrl' => $return)); } $theme['detailMode'] = $session->get('theme.detailMode'); /* Add our header and styles */ return array(null, 'theme.tpl'); } /** * @see GalleryTheme::showPhotoPage */ function showPhotoPage(&$template, $item, $params) { global $gallery; $dataTypes = array('owner', 'parents', 'systemLinks', 'itemLinks', 'permissions', 'itemLinksDetailed', 'itemNavigator', 'imageViews'); if (!empty($params['showMicroThumbs'])) { $dataTypes[] = 'navThumbnails'; } $ret = $this->loadCommonTemplateData($template, $item, $params, $dataTypes); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $theme =& $template->getVariableByReference('theme'); list ($returnName, $returnUrl ) = GalleryUtilities::getRequestVariables('wpg2_returnname', 'wpg2_returnurl'); if ($returnName != null) $theme['returnName'] = $returnName; else $theme['returnName'] = "Home"; if ($returnUrl != null) $theme['returnUrl'] = $returnUrl; else $theme['returnUrl'] = '/'; $session =& $gallery->getSession(); list ($detailMode, $return) = GalleryUtilities::getRequestVariables('detailMode', 'return'); if ($detailMode != null) { $session->put('theme.detailMode', $detailMode); return array(null, array('redirectUrl' => $return)); } $theme['detailMode'] = $session->get('theme.detailMode'); return array(null, 'theme.tpl'); } /** * @see GalleryTheme::showModulePage */ function showModulePage(&$template, $item, $params, $templateFile) { $ret = $this->loadCommonTemplateData( $template, $item, $params, array('parents', 'systemLinks')); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $theme =& $template->getVariableByReference('theme'); list ($returnName, $returnUrl ) = GalleryUtilities::getRequestVariables('wpg2_returnname', 'wpg2_returnurl'); if ($returnName != null) $theme['returnName'] = $returnName; else $theme['returnName'] = "Home"; if ($returnUrl != null) $theme['returnUrl'] = $returnUrl; else $theme['returnUrl'] = '/'; return array(null, 'theme.tpl'); } /** * @see GalleryTheme::showAdminPage */ function showAdminPage(&$template, $item, $params, $templateFile) { $ret = $this->loadCommonTemplateData( $template, $item, $params, array('parents', 'systemLinks')); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $theme =& $template->getVariableByReference('theme'); list ($returnName, $returnUrl ) = GalleryUtilities::getRequestVariables('wpg2_returnname', 'wpg2_returnurl'); if ($returnName != null) $theme['returnName'] = $returnName; else $theme['returnName'] = "Home"; if ($returnUrl != null) $theme['returnUrl'] = $returnUrl; else $theme['returnUrl'] = '/'; return array(null, 'theme.tpl'); } /** * @see GalleryTheme::showErrorPage */ function showErrorPage(&$template) { $theme =& $template->getVariableByReference('theme'); list ($returnName, $returnUrl ) = GalleryUtilities::getRequestVariables('wpg2_returnname', 'wpg2_returnurl'); if ($returnName != null) $theme['returnName'] = $returnName; else $theme['returnName'] = "Home"; if ($returnUrl != null) $theme['returnUrl'] = $returnUrl; else $theme['returnUrl'] = '/'; return array(null, 'error.tpl'); } /** * @see GalleryTheme::showProgressBarPage */ function showProgressBarPage(&$template, $item, $params) { $ret = $this->loadCommonTemplateData( $template, $item, $params, array('parents', 'systemLinks')); if ($ret) { return array($ret->wrap(__FILE__, __LINE__), null); } $theme =& $template->getVariableByReference('theme'); list ($returnName, $returnUrl ) = GalleryUtilities::getRequestVariables('wpg2_returnname', 'wpg2_returnurl'); if ($returnName != null) $theme['returnName'] = $returnName; else $theme['returnName'] = "Home"; if ($returnUrl != null) $theme['returnUrl'] = $returnUrl; else $theme['returnUrl'] = '/'; return array(null, 'theme.tpl'); } } ?>