git-svn-id: https://192.168.0.254/svn/Proyectos.ConstruccionesCNJ_Web/trunk@5 a1d75475-e439-6a4c-b115-a3aab481e8ec
251 lines
7.7 KiB
PHP
251 lines
7.7 KiB
PHP
<?php
|
|
/*
|
|
* Gallery - a web based photo album viewer and editor
|
|
* Copyright (C) 2000-2007 Bharat Mediratta
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
* your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
/**
|
|
* CNJ.net Gallery theme
|
|
* @package Themes
|
|
* @subpackage CNJ
|
|
* @author Nico Kaiser <nico@siriux.net>
|
|
* @version $Revision: 16034 $
|
|
*/
|
|
class CNJTheme extends GalleryTheme {
|
|
|
|
function CNJTheme() {
|
|
global $gallery;
|
|
|
|
$this->setId('CNJ');
|
|
$this->setName($gallery->i18n('CNJ'));
|
|
$this->setDescription($gallery->i18n('CNJ.net Gallery theme'));
|
|
$this->setVersion('1.1.3');
|
|
$this->setRequiredCoreApi(array(7, 10));
|
|
$this->setRequiredThemeApi(array(2, 4));
|
|
$this->setStandardSettings(
|
|
array('perPage' => 9,
|
|
'contentWidth' => 930,
|
|
'albumBlocks' => serialize(array(
|
|
array('comment.ViewComments', array()))),
|
|
'photoBlocks' => serialize(array(
|
|
array('exif.ExifInfo', array()),
|
|
array('comment.ViewComments', array()))),
|
|
'contentWidth' => 930,
|
|
'groupByYear' => 0,
|
|
'enableImageMap' => 1));
|
|
}
|
|
|
|
/**
|
|
* @see GalleryTheme::showAlbumPage
|
|
*/
|
|
function showAlbumPage(&$template, $item, $params, $childIds) {
|
|
$ret = $this->loadCommonTemplateData(
|
|
$template, $item, $params,
|
|
array('owner', 'viewCount', 'childCount', 'descendentCount', 'parents',
|
|
'systemLinks', 'itemLinks', 'itemSummaries', 'permissions',
|
|
'thumbnails', 'pageNavigator', 'jumpRange'),
|
|
$childIds);
|
|
if ($ret) {
|
|
return array($ret, null);
|
|
}
|
|
|
|
/* Override some navigator settings */
|
|
$theme =& $template->getVariableByReference('theme');
|
|
if (isset($theme['navigator']['first'])) {
|
|
unset($theme['navigator']['first']);
|
|
}
|
|
if (isset($theme['navigator']['last'])) {
|
|
unset($theme['navigator']['last']);
|
|
}
|
|
|
|
/* Find the thumbnail size for this album */
|
|
$theme['params']['thumbnailSize'] = 150;
|
|
list ($ret, $preferences) =
|
|
GalleryCoreApi::fetchDerivativePreferencesForItem($item->getId());
|
|
if ($ret) {
|
|
return array($ret, null);
|
|
}
|
|
foreach ($preferences as $preference) {
|
|
if ($preference['derivativeType'] == DERIVATIVE_TYPE_IMAGE_THUMBNAIL &&
|
|
preg_match('/thumbnail\|(\d+)/', $preference['derivativeOperations'], $matches)) {
|
|
$theme['params']['thumbnailSize'] = $matches[1];
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Begin Rodax Software
|
|
/* 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;
|
|
}
|
|
$theme['children'][$key]['resizedId'] = $value['id'];
|
|
if ( $resizedIds ){
|
|
/* Find the best resized option
|
|
*
|
|
* Use width/height max=1024; */
|
|
$lboxMaxEdge = 1024;
|
|
$resizedEdge = NULL;
|
|
$resizedId = NULL;
|
|
foreach ( $resizedIds[$value['id']] as $resize )
|
|
{
|
|
$width = $resize->getWidth();
|
|
$height = $resize->getHeight();
|
|
$edge = ( $width > $height )? $width : $height;
|
|
if ( $edge <= $lboxMaxEdge ){
|
|
if ( !isset($resizedEdge) ){
|
|
$resizedId = $resize->getId();
|
|
$resizedEdge = $edge;
|
|
} else if ( $edge > $resizedEdge ){
|
|
$resizedId = $resize->getId();
|
|
$resizedEdge = $edge;
|
|
}
|
|
}
|
|
}
|
|
$theme['children'][$key]['resizedId'] = $resizedId;
|
|
}
|
|
}
|
|
}
|
|
/* end add resizedId to child values, required for Lightbox JS */
|
|
// End Rodax Software
|
|
|
|
return array(null, 'theme.tpl');
|
|
}
|
|
|
|
/**
|
|
* @see GalleryTheme::showPhotoPage
|
|
*/
|
|
function showPhotoPage(&$template, $item, $params) {
|
|
$ret = $this->loadCommonTemplateData($template, $item, $params,
|
|
array('owner', 'parents', 'systemLinks', 'itemLinks', 'permissions',
|
|
'itemLinksDetailed', 'itemNavigator', 'imageViews'));
|
|
if ($ret) {
|
|
return array($ret, null);
|
|
}
|
|
|
|
/* Override some navigator settings */
|
|
$theme =& $template->getVariableByReference('theme');
|
|
if (isset($theme['navigator']['first'])) {
|
|
unset($theme['navigator']['first']);
|
|
}
|
|
if (isset($theme['navigator']['last'])) {
|
|
unset($theme['navigator']['last']);
|
|
}
|
|
|
|
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, null);
|
|
}
|
|
|
|
/* Add in our extra stuff */
|
|
$theme =& $template->getVariableByReference('theme');
|
|
$theme['moduleTemplate'] = $templateFile;
|
|
|
|
/* Add our header and styles */
|
|
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, null);
|
|
}
|
|
|
|
/* Add in our extra stuff */
|
|
$theme =& $template->getVariableByReference('theme');
|
|
$theme['adminTemplate'] = $templateFile;
|
|
|
|
return array(null, 'theme.tpl');
|
|
}
|
|
|
|
/**
|
|
* @see GalleryTheme::showErrorPage
|
|
*/
|
|
function showErrorPage(&$template) {
|
|
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, null);
|
|
}
|
|
|
|
return array(null, 'theme.tpl');
|
|
}
|
|
|
|
/**
|
|
* @see GalleryTheme::getSettings
|
|
*/
|
|
function getSettings($itemId=null) {
|
|
list ($ret, $settings, $params) = parent::getSettings($itemId);
|
|
if ($ret) {
|
|
return array($ret, null, null);
|
|
}
|
|
|
|
/* Add in our custom settings */
|
|
$settings[] = array('key' => 'contentWidth',
|
|
'name' => $this->translate('Width of page content in pixels'),
|
|
'type' => 'text-field',
|
|
'typeParams' => array('size' => 2),
|
|
'value' => $params['contentWidth']);
|
|
$settings[] = array('key' => 'groupByYear',
|
|
'name' => $this->translate(
|
|
'Group sub-albums by year (album must be sorted by date!)'),
|
|
'type' => 'checkbox',
|
|
'value' => $params['groupByYear']);
|
|
$settings[] = array('key' => 'enableImageMap',
|
|
'name' => $this->translate(
|
|
'Enable prev/next navigation by clicking in the left/right half of the image'),
|
|
'type' => 'checkbox',
|
|
'value' => $params['enableImageMap']);
|
|
|
|
return array(null, $settings, $params);
|
|
}
|
|
|
|
/**
|
|
* @see GalleryTheme::validateSettings
|
|
*/
|
|
function validateSettings($settings) {
|
|
$error = parent::validateSettings($settings);
|
|
if (!is_numeric($settings['contentWidth'])) {
|
|
$error['contentWidth'] = $this->translate('You must enter a number');
|
|
}
|
|
return $error;
|
|
}
|
|
}
|
|
?>
|