<?php

/* Plug-in for theme option handling
 * The Admin Options page tests for the presence of this file in a theme folder
 * If it is present it is linked to with a require_once call.
 * If it is not present, no theme options are displayed.
 *
 */

class ThemeOptions {

	function __construct() {
		setThemeOptionDefault('thumb_size', 180);
		setOptionDefault('full_image_size', 800);
		setOptionDefault('zenpage_zp_index_news', false);
		/*setOptionDefault('Allow_comments', true);
		setOptionDefault('Allow_search', true);
		setOptionDefault('Display_number', true);
		setOptionDefault('Display', 'Normal');
		setOptionDefault('sweetTitles', true);*/
		setOptionDefault('Language', true);
		setOptionDefault('Rating', true);
		setOptionDefault('GoogleMap', true);
		setOptionDefault('Paypal', true);

		/*	Taille image: 595	Taille vignette: 180
			Appliquer image pleine grandeur	2008-09-05_BecasseauVariable_9542_FULL_watermark.jpg
 			Appliquer 40_cw40_ch40_thumb
			Appliquer 80_cw80_ch80_thumb
			Appliquer 85_cw180_ch180_thumb
			Appliquer 610_watermark			2008-09-05_BecasseauVariable_9542_610_watermark.jpg (wordpress, taille article 610px)
			
		  	2008-09-05_BecasseauVariable_9542_595_watermark.jpg	image zenphoto est crée à la 1ere lecture
		  
		  
			addThemeCacheSize( $theme, $size, $width, $height, $cw, $ch, $cx, $cy, $thumb (false/true), $watermark, $effects, $maxspace  )
		*/
		if (class_exists('cacheManager')) {
			$me = basename(dirname(__FILE__));
			cacheManager::deleteThemeCacheSizes($me);
			//addThemeCacheSize( $theme, $size, $width, $height, $cw, $ch, $cx, $cy, $thumb, $watermark, $effects, $maxspace  )
			// wordpress
			//cacheManager::addThemeCacheSize($me, 610, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL, NULL);
			// image.php
			cacheManager::addThemeCacheSize($me, 610, NULL, NULL, NULL, NULL, NULL, NULL, false, getOption('fullimage_watermark'), NULL, NULL);
			// FULL
			cacheManager::addThemeCacheSize($me, 800, NULL, NULL, NULL, NULL, NULL, NULL, false, getOption('fullimage_watermark'), NULL, NULL);
			// thumb SD
			cacheManager::addThemeCacheSize($me, 180, NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, NULL, NULL);
			// thumb HD
			cacheManager::addThemeCacheSize($me, 360, NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, NULL, NULL);
			//cacheManager::addThemeCacheSize($me, 85, NULL, NULL, getThemeOption('thumb_crop_width'), getThemeOption('thumb_crop_height'), NULL, NULL, true, getOption('Image_watermark'), NULL, NULL);
		}

		if (function_exists('createMenuIfNotExists')) {
			$menuitems = array(
							array('type' => 'menulabel', 'title' => gettext('News Articles'), 'link' => '', 'show' => 1, 'nesting' => 0),
							array('type' => 'menufunction', 'title' => gettext('All news'), 'link' => 'printAllNewsCategories("All news",TRUE,"","menu-active",false);', 'show' => 1, 'include_li' => 0, 'nesting' => 1),
							array('type' => 'menulabel', 'title' => gettext('Gallery'), 'link' => '', 'show' => 1, 'nesting' => 0),
							array('type' => 'custompage', 'title' => gettext('Gallery index'), 'link' => 'gallery', 'show' => 1, 'nesting' => 1),
							array('type' => 'menufunction', 'title' => gettext('All Albums'), 'link' => 'printAlbumMenuList("list",NULL,"","menu-active","submenu","menu-active","",false,false,false,false);', 'show' => 1, 'include_li' => 0, 'nesting' => 1),
							array('type' => 'menulabel', 'title' => gettext('Pages'), 'link' => '', 'show' => 1, 'nesting' => 0),
							array('type' => 'menufunction', 'title' => gettext('All pages'), 'link' => 'printPageMenu("list","","menu-active","submenu","menu-active","",0,false);', 'show' => 1, 'include_li' => 0, 'nesting' => 1),
			);
			createMenuIfNotExists($menuitems, 'zenpage');
		}
	}

	function getOptionsSupported() {
		return array(	gettext('Allow comments') => array('key' => 'Allow_comments', 'type' => 1, 'desc' => gettext('Check to enable comment section.')),
			/*gettext('News on index page') => array('key' => 'zenpage_zp_index_news', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext("Enable this if you want to show the news section's first page on the <code>index.php</code> page.")),
			gettext('Allow search') => array('key' => 'Allow_search', 'type' => 1, 'desc' => gettext('Check to enable search form.')),
			gettext('Display number') => array('key' => 'Display_number', 'type' => 1, 'desc' => gettext('Display the pictures numbers from an album')),
			gettext('Display album') => array('key' => 'Display', 'type' => 5, 'selections' => array(gettext('Normal') => 'Normal', gettext('Simpleviewer') => 'Simpleviewer', gettext('Shadowbox') => 'Shadowbox'),
					'desc' => gettext('Select display of images')),
			gettext('sweetTitles') => array('key' => 'sweetTitles', 'type' => 1, 'desc' => gettext('Nice title')),*/
			gettext('Language') => array('key' => 'Language', 'type' => 1, 'desc' => gettext('Display the language selector.')),
			gettext('Rating') => array('key' => 'Rating', 'type' => 1, 'desc' => gettext('Display rating option')),
			gettext('GoogleMap') => array('key' => 'GoogleMap', 'type' => 1, 'desc' => gettext('Display GoogleMap option')),
			gettext('Paypal') => array('key' => 'Paypal', 'type' => 1, 'desc' => gettext('Display Paypal option'))
			);
	}

	function handleOption($option, $currentValue) {
		/*
		if ($option == "zenpage_homepage") {
			$unpublishedpages = query_full_array("SELECT titlelink FROM " . prefix('pages') . " WHERE `show` != 1 ORDER by `sort_order`");
			if (empty($unpublishedpages)) {
				echo gettext("No unpublished pages available");
				// clear option if no unpublished pages are available or have been published meanwhile
				// so that the normal gallery index appears and no page is accidentally set if set to unpublished again.
				setThemeOption('zenpage_homepage', 'none', NULL, 'zpEnlighten');
			} else {
				echo '<input type="hidden" name="' . CUSTOM_OPTION_PREFIX . 'selector-zenpage_homepage" value="0" />' . "\n";
				echo '<select id="' . $option . '" name="zenpage_homepage">' . "\n";
				if ($currentValue === "none") {
					$selected = " selected = 'selected'";
				} else {
					$selected = "";
				}
				echo "<option$selected>" . gettext("none") . "</option>";
				foreach ($unpublishedpages as $page) {
					if ($currentValue === $page["titlelink"]) {
						$selected = " selected = 'selected'";
					} else {
						$selected = "";
					}
					echo "<option$selected>" . $page["titlelink"] . "</option>";
				}
				echo "</select>\n";
			}
			
		}*/
	}

}

?>
