3 /* *************************************************************************
5 * Copyright (c) by Andreas Unterkircher, unki@netshadow.at
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * *************************************************************************/
24 require_once "phpfspot.class.php";
28 public function __construct()
34 public function process_ajax_request()
36 require_once 'HTML/AJAX/Server.php';
38 $server = new HTML_AJAX_Server();
39 $server->handleRequest();
41 $fspot = new PHPFSPOT();
43 /* if no action is specified, no need to further process this
46 if(!isset($_GET['action']))
49 switch($_GET['action']) {
51 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
52 $fspot->showPhoto($_GET['id']);
56 case 'show_available_tags':
57 print $fspot->getAvailableTags();
60 case 'show_selected_tags':
61 print $fspot->getSelectedTags();
65 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
66 $fspot->addTag($_GET['id']);
71 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
72 $fspot->delTag($_GET['id']);
77 $fspot->resetTagSearch();
79 $fspot->resetDateSearch();
80 $fspot->resetPhotoView();
84 if(isset($_GET['mode']) && in_array($_GET['mode'], Array('or', 'and'))) {
85 $fspot->setTagCondition($_GET['mode']);
89 case 'show_photo_index':
90 if(isset($_GET['begin_with']) && is_numeric($_GET['begin_with'])) {
91 $_SESSION['begin_with'] = $_GET['begin_with'];
94 unset($_SESSION['begin_with']);
96 $fspot->showPhotoIndex();
100 $fspot->showCredits();
104 $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to']);
106 if((isset($_GET['from']) && $fspot->isValidDate($_GET['from'])) &&
107 (isset($_GET['to']) && $fspot->isValidDate($_GET['to']))) {
110 $fspot->startSearch($_GET['for']);
114 case 'update_sort_order':
115 if(isset($_POST['value']) && is_string($_POST['value'])) {
116 print $fspot->updateSortOrder($_POST['value']);
121 /* $_GET['mode'] will be validated by getExport() */
122 $fspot->getExport($_GET['mode']);
125 case 'get_photo_to_show':
126 $fspot->getCurrentPhoto();
129 case 'get_calendar_matrix':
130 if((is_numeric($_GET['year']) || !isset($_GET['year'])) &&
131 (is_numeric($_GET['month']) || !isset($_GET['month'])) &&
132 (is_numeric($_GET['day']) || !isset($_GET['day']))) {
133 $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
138 print $fspot->whatToDo();
141 case 'reset_slideshow':
142 print $fspot->resetSlideShow();
145 case 'get_next_slideshow_img':
146 print $fspot->getNextSlideShowImage();
149 case 'get_prev_slideshow_img':
150 print $fspot->getPrevSlideShowImage();
155 } // process_ajax_request();
157 } // class PHPFSPOT_RPC
159 $rpc = new PHPFSPOT_RPC();
160 $rpc->process_ajax_request();