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


// Specials actions
if($_GET['action'] == 'upload') {
	
	if($_POST['name'] != NULL && $_POST['albumId'] != NULL && $_POST['imageSmall'] != NULL && $_POST['imageLarge'] != NULL){
	
		$model_pictures = new model_pictures();
		$model_pictures->insertNewLine($_POST['name'], $_POST['albumId'], $_POST['imageSmall'], $_POST['imageLarge']);
		
		$view_pictures = new view_pictures($model_pictures);
		echo $view_pictures->getPictureById(DB::$insertId);
	}
	return;
	
}elseif($_GET['action'] == 'albumorder'){
	
	if($_POST['albumId'] != NULL && $_POST['albumOrder'] != NULL){
		
		$model_albums = new model_albums();
		$view_albums = new view_albums($model_albums);
		
		$model_albums->updateOrderById($_POST['albumId'], $_POST['albumOrder']);
		echo $view_albums->getAll($_POST['albumSelectedId']);
	
	}
	return;
	
}elseif($_GET['action'] == 'picturechangealbum'){
	
	if($_POST['albumId'] != NULL){
	
		$model_pictures = new model_pictures();
		$view_pictures = new view_pictures($model_pictures);
		
		preg_match_all('/[0-9]+/', $_POST['picturesSelectedId'], $pictures);
		preg_match_all('/[0-9]+/', $_POST['albumId'], $album);
		
		foreach($pictures[0] as $value) $model_pictures->updateAlbumLineById($value, $album[0][0]);
		$script = "<script>" . FUNCTIONS::getAjaxRequestEval('options_empty', 'panel_options') . "</script>";
		echo $view_pictures->getAllFromAlbum($album[0][0]) . $script;
	
	}
	return;
	
}

// Defaults actions handler
switch($actions[0][0]) {

	case "albums" :
		
		$model_albums = new model_albums();
		$view_albums = new view_albums($model_albums);
		
		switch($actions[0][1]){
			
			case "list" : echo $view_albums->getAll($_POST['albumSelectedId']); break;
			
			case "create" : echo $view_albums->getCreateForm(); break;
			
			case "edit" : echo $view_albums->getEditForm($values[0][0]); break;
			
			case "delete" : echo $view_albums->getPopupDelete($values[0][0]); break;
			
			case "createfinish" : 
				$model_albums->insertNewLine($_POST['title'], $_POST['locked'], $_POST['password'], $_POST['active']);
				$newLineId = DB::$insertId;
				$model_albums->updateOrderById($newLineId, 0);
				$script = '<script>panelAlbums.currentAlbumSelectedId=' . $newLineId . '; ' . FUNCTIONS::getAjaxRequestEval('pictures_listfromalbum:' . $newLineId, 'panel_pictures') . FUNCTIONS::getAjaxRequestEval('albums_edit:' . $newLineId, 'panel_options') . '</script>';
				echo $view_albums->getAll($newLineId) . $script;
			break;
			
			case "editfinish" : 
				$model_albums->updateLineById($values[0][0], $_POST['title'], $_POST['locked'], $_POST['password'], $_POST['active']);
				echo $view_albums->getAll($_POST['albumSelectedId']);
			break;
			
			case "deletefinish" : 
				$model_albums->deleteLineById($values[0][0]);
				$model_pictures = new model_pictures();
				$model_pictures->deleteAllFromAlbum($values[0][0]);
				$script = '';
				if($_POST['albumSelectedId'] == $values[0][0]) $script = "<script>" . FUNCTIONS::getAjaxRequestEval('options_empty', 'panel_options') . FUNCTIONS::getAjaxRequestEval('pictures_list', 'panel_pictures') . "</script>";
				echo $view_albums->getAll($_POST['albumSelectedId']) . $script;
			break;
			
		}
		
	break;
	case "pictures" :
		
		$model_pictures = new model_pictures();
		$view_pictures = new view_pictures($model_pictures);
		
		switch($actions[0][1]){
			
			case "list" : 
				$script = "<script>panelAlbums.setAlbumDeselectedAll(); " . FUNCTIONS::getAjaxRequestEval('options_empty', 'panel_options') . "</script>";
				echo $view_pictures->getAll() . $script;
			break;
			
			case "listfromalbum" : echo $view_pictures->getAllFromAlbum($values[0][0]); break;
			
			case "large" : echo $view_pictures->getPopupLargeImage($values[0][0]); break;
			
			case "create" : echo $view_pictures->getPopupUpload(); break;
			
			case "edit" : 
				preg_match_all('/[0-9]+/', $_POST['picturesSelectedId'], $pictures);
				if(count($pictures[0]) > 1) echo $view_pictures->getMultipleEditForm($pictures[0]); 
				else echo $view_pictures->getEditForm($values[0][0]); 
			break;
			
			case "delete" : echo $view_pictures->getPopupDelete($values[0][0]); break;
			
			case "multipledelete" : 
				echo $view_pictures->getPopupMultipleDelete(); 
			break;
			
			case "editfinish" : 
				$model_pictures->updateLineById($values[0][0], $_POST['title']);
				echo $view_pictures->getAll();
			break;
			
			case "deletefinish" : 
				$model_pictures->deleteLineById($values[0][0]);
				$script = "<script>" . FUNCTIONS::getAjaxRequestEval('options_empty', 'panel_options') . "</script>";
				if($_POST['albumSelectedId'] != 'undefined') echo $view_pictures->getAllFromAlbum($_POST['albumSelectedId']) . $script;
				else echo $view_pictures->getAll() . $script;
			break;
			
			case "multipledeletefinish" : 
				preg_match_all('/[0-9]+/', $_POST['picturesSelectedId'], $pictures);
				foreach($pictures[0] as $value) $model_pictures->deleteLineById($value);
				$script = "<script>" . FUNCTIONS::getAjaxRequestEval('options_empty', 'panel_options') . "</script>";
				if($_POST['albumSelectedId'] != 'undefined') echo $view_pictures->getAllFromAlbum($_POST['albumSelectedId']) . $script;
				else echo $view_pictures->getAll() . $script;
			break;
			
		}
		
	break;
	case "settings" :
		
		$model_settings = new model_settings();
		$view_settings = new view_settings($model_settings);
		
		switch($actions[0][1]){
			
			case "edit" : echo $view_settings->getPopupEdit(); break;
			
			case "editfinish" : echo $view_settings->getPopupEditResponse(); break;
			
			case "editpassword" : echo $view_settings->getPopupEditPassword(); break;
			
			case "editpasswordfinish" : echo $view_settings->getPopupEditPasswordResponse(); break;
			
		}
	
	break;
	case "options" :
	
		echo '<p class="empty">' . $LANG->traduc['WarningNoOptions'] . '</p>';
	
	break;
	default:
	
		$view = new view_admin();
		echo $view->buffer;
		
	break;
	
}
	
	
?>
Return current item: GalleryShuffle