Location: PHPKode > scripts > GalleryShuffle > v1.0/php/Views/settings.php
<?php

/**
* SETTINGS
**/

class view_settings extends view_classicView
{
	
	
	public function getPopupEdit() 
	{
		
		$uid = uniqid();
		
		$text = '
		<p id="settings_state_' . $uid . '" class="state"></p>
		<div id="settings_form_' . $uid . '">
			
			<div  class="separator">
				<label for="settings_title_' . $uid . '">' . $this->LANG->traduc['galleryTitle'] . ' :</label>
				<input name="title" id="settings_title_' . $uid . '" size="15" value="' . CONFIG::galleryTitle . '"/>
				
				<br /><label for="settings_subtitle_' . $uid . '">' . $this->LANG->traduc['gallerySubtitle'] . ' :</label>
				<input name="subtitle" id="settings_subtitle_' . $uid . '" size="15" value="' . CONFIG::gallerySubtitle . '"/>
				
				<div class="littlSeparator"></div>
				<input name="locked" onclick="javascript: var object = document.getElementById(' . "'settings_islocked_" . $uid . "'" . '); if(object.style.opacity < 1){ object.setOpacity(1); }else{ object.setOpacity(0.3); };" id="settings_locked_' . $uid . '" type="checkbox" ';
				if(CONFIG::galleryIsLocked == 1) $text .= 'checked="checked"';
				$text .= '/><label for="settings_locked_' . $uid . '">' . $this->LANG->traduc['galleryLocked'] . '</label>
				
				<br /><div id="settings_islocked_' . $uid . '" style="opacity: ';
				if(CONFIG::galleryIsLocked == 0) $text .= '0.3';
				else $text .= '1';
				$text .= ';">
					<label for="settings_password_' . $uid . '">' . $this->LANG->traduc['password'] . ' :</label>
					<input name="password" id="settings_password_' . $uid . '" size="8" value="' . CONFIG::galleryPassword . '"/>
				</div>
				
				<div class="littlSeparator"></div>
				<input name="shuffled"  id="settings_shuffled_' . $uid . '" type="checkbox" ';
				if(CONFIG::galleryIsShuffled == 1) $text .= 'checked="checked"';
				$text .= '/><label for="settings_shuffled_' . $uid . '">' . $this->LANG->traduc['galleryShuffled'] . '</label>
				
			</div>
			
			<div  class="separator">
				<label for="settings_mail_' . $uid . '">' . $this->LANG->traduc['adminMail'] . ' :</label>
				<input name="mail" id="settings_mail_' . $uid . '" size="25" value="' . CONFIG::userLogin . '"/>
				<br /><a href="' . FUNCTIONS::getAjaxRequest('settings_editpassword', 'popup') . '" class="littleLink">' . $this->LANG->traduc['changeAdminPassword'] . '</a>
			</div>
			
			<div  class="separator">
				<label for="settings_upsizemax_' . $uid . '">' . $this->LANG->traduc['uploadPictureMaxSize'] . ' :</label>
				<input name="upsizemax" id="settings_upsizemax_' . $uid . '" size="4" value="' . CONFIG::uploadPictureLargeMaxSize . '"/>px
			</div>
			
			<a href="' . "javascript: var object = document.getElementById('settings_state_" . $uid . "'); 
				object.innerHTML = '" . $this->LANG->traduc['settingsWaitRespond'] . "'; 
				object.setVisible(); 
				" . FUNCTIONS::getAjaxRequestEval('settings_editfinish', 'settings_state_' . $uid, 'settings_form_' . $uid) . '">
				' . $this->LANG->traduc['save'] . '</a>
			
			<div class="littlSeparator"></div>
			<a href="http://ingwe.fr" target="_blank" class="littleLink">' . $this->LANG->traduc['developer'] . '</a><!-- - 
			<a href="javascript: ;" class="littleLink">' . $this->LANG->traduc['donate'] . '</a-->
		</div>
		<script>document.getElementById("settings_state_' . $uid . '").setHide();</script>
		';
		
		return $this->getPopup($this->LANG->traduc['settings'], NULL, $text);
	
	}
	
	public function getPopupEditResponse(){
	
		$stateBuffer = '';
		if($_POST['title'] == '') $stateBuffer .= '<i>' . $this->LANG->traduc['galleryTitle'] . '</i>' . $this->LANG->traduc['WarningCannotBeNull'] . '<br />';
		
		if($_POST['mail'] == '') $stateBuffer .= '<i>' . $this->LANG->traduc['adminMail'] . '</i>' . $this->LANG->traduc['WarningCannotBeNull'] . '<br />';
		elseif(!FUNCTIONS::isMailAddress($_POST['mail'])) $stateBuffer .= '<i>' . $this->LANG->traduc['adminMail'] . '</i>' . $this->LANG->traduc['WarningShouldBeMail'] . '<br />';
		
		if($_POST['upsizemax'] == '') $stateBuffer .= '<i>' . $this->LANG->traduc['uploadPictureMaxSize'] . '</i>' . $this->LANG->traduc['WarningCannotBeNull'] . '<br />';
		elseif(!FUNCTIONS::isInt($_POST['upsizemax'])) $stateBuffer .= '<i>' . $this->LANG->traduc['uploadPictureMaxSize'] . '</i>' . $this->LANG->traduc['WarningShouldBeInt'] . '<br />';
		
		if($stateBuffer == ''){
		
			$this->model->saveBasicsSettings($_POST['title'], $_POST['subtitle'], $_POST['shuffled'], $_POST['locked'], $_POST['password'], $_POST['mail'], $_POST['upsizemax']);
			return $this->LANG->traduc['settingsSucces'] . "
			<script> 
			
			PHPCONST.uploadPictureLargeMaxSize = " . $_POST['upsizemax'] . ";
			
			var timer = setInterval( function() { 
				clearInterval(timer); document.getElementById('popupTable').show(false); 
			}, 1000); 
			
			</script>";
		
		}else return $stateBuffer;
		
	}
	
	
	public function getPopupEditPassword() 
	{
		
		$uid = uniqid();
		
		$text = '
		<p id="settings_state_' . $uid . '" class="state"></p>
		<div id="settings_form_' . $uid . '">
			
			<div class="separator">
				<label for="settings_password1_' . $uid . '">' . $this->LANG->traduc['enterNewPassword'] . ' :</label>
				<input name="password1"  type="password" id="settings_password1_' . $uid . '" size="10"/>
				
				<br /><label for="settings_password2_' . $uid . '">' . $this->LANG->traduc['confirmNewPassword'] . ' :</label>
				<input name="password2" type="password" id="settings_password2_' . $uid . '" size="10"/>
				
			</div>
			<a href="' . "javascript: var object = document.getElementById('settings_state_" . $uid . "'); 
				object.innerHTML = '" . $this->LANG->traduc['settingsWaitRespond'] . "'; 
				object.setVisible(); 
				" . FUNCTIONS::getAjaxRequestEval('settings_editpasswordfinish', 'settings_state_' . $uid, 'settings_form_' . $uid) . '">
				' . $this->LANG->traduc['save'] . '</a>
			<a href="' . FUNCTIONS::getAjaxRequest('settings_edit', 'popup') . '">' . $this->LANG->traduc['back'] . '</a>
			
		</div>
		<script>document.getElementById("settings_state_' . $uid . '").setHide();</script>
		';
		
		return $this->getPopup($this->LANG->traduc['settings'], NULL, $text);
	
	}
	
	public function getPopupEditPasswordResponse() 
	{
		
		$stateBuffer = '';
		
		$passwordLength = mb_strlen(html_entity_decode($_POST['password1'], ENT_QUOTES, "UTF-8"));
		
		if($passwordLength < 6 || $passwordLength > 10) $stateBuffer .= $this->LANG->traduc['passwordTooShort'];
		elseif($_POST['password1'] != $_POST['password2']) $stateBuffer .= $this->LANG->traduc['passwordsNotMatch'];
		
		if($stateBuffer == ''){
		
			$this->model->savePasswordSettings($_POST['password1']);
			return $this->LANG->traduc['settingsSucces'] . "
			<script> 
			var timer = setInterval( function() { 
				clearInterval(timer);
				" . FUNCTIONS::getAjaxRequestEval('settings_edit', 'popup') . "
			}, 1000); 
			</script>";
		
		}else return $stateBuffer;
	
	}
	
	public function getJsPHPCONST() 
	{
		
		$buffer = "
	PHPCONST = {
		uploadPictureLargeMaxSize: " . CONFIG::uploadPictureLargeMaxSize . ",
		uploadPictureSmallMaxSize: " . CONFIG::uploadPictureSmallMaxSize . ",
		picturesFolder: '" . CONFIG::picturesFolder . "',
		picturesSmallFolder: '" . CONFIG::picturesSmallFolder . "',
		picturesLargeFolder: '" . CONFIG::picturesLargeFolder . "',
		galleryIsShuffled: " . CONFIG::galleryIsShuffled . "
	};";
		
		return $buffer;
		
	}
	
	
}

?>
Return current item: GalleryShuffle