wrap line in header when display time-range results
[phpfspot.git] / rpc.php
1 <?php
2
3 /* *************************************************************************
4  *
5  * Copyright (c) by Andreas Unterkircher, unki@netshadow.at
6  * All rights reserved
7  *
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
11  *  any later version.
12  *
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.
17  *
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.
21  *
22  * *************************************************************************/
23
24 require_once "phpfspot.class.php";
25
26 class PHPFSPOT_RPC {
27
28    public function __construct()
29    {
30       session_start();
31
32    } // __construct()
33
34    public function process_ajax_request()
35    {
36       require_once 'HTML/AJAX/Server.php';
37
38       $server = new HTML_AJAX_Server();
39       $server->handleRequest();
40
41       $fspot = new PHPFSPOT();
42
43       /* if no action is specified, no need to further process this
44        * function here.
45        */
46       if(!isset($_GET['action']))
47          return;
48
49       switch($_GET['action']) {
50          case 'showphoto':
51             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
52                $fspot->showPhoto($_GET['id']);
53             }
54             break;
55    
56          case 'show_available_tags':
57             print $fspot->getAvailableTags();
58             break;
59
60          case 'show_selected_tags':
61             print $fspot->getSelectedTags();
62             break;
63
64          case 'addtag':
65             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
66                $fspot->addTag($_GET['id']);
67             }
68             break;
69
70          case 'deltag':
71             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
72                $fspot->delTag($_GET['id']);
73             }
74             break;
75
76          case 'reset':
77             $fspot->resetTagSearch();
78             $fspot->resetTags();
79             $fspot->resetDateSearch();
80             $fspot->resetPhotoView();
81             break;
82
83          case 'tagcondition':
84             if(isset($_GET['mode']) && in_array($_GET['mode'], Array('or', 'and'))) {
85                $fspot->setTagCondition($_GET['mode']);
86             }
87             break;
88
89          case 'show_photo_index':
90             if(isset($_GET['begin_with']) && is_numeric($_GET['begin_with'])) {
91                $_SESSION['begin_with'] = $_GET['begin_with'];
92             }
93             else {
94                unset($_SESSION['begin_with']);
95             }
96             $fspot->showPhotoIndex();
97             break;
98    
99          case 'showcredits':
100             $fspot->showCredits();
101             break;
102
103          case 'search':
104             $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to']);
105             
106             if((isset($_GET['from']) && $fspot->isValidDate($_GET['from'])) &&
107                (isset($_GET['to']) && $fspot->isValidDate($_GET['to']))) {
108             }
109             else {
110                $fspot->startSearch($_GET['for']);
111             }
112             break;
113
114          case 'update_sort_order':
115             if(isset($_POST['value']) && is_string($_POST['value'])) {
116                print $fspot->updateSortOrder($_POST['value']);
117             }
118             break;
119
120          case 'get_export':
121             /* $_GET['mode'] will be validated by getExport() */
122             $fspot->getExport($_GET['mode']);
123             break;
124
125          case 'get_photo_to_show':
126             $fspot->getCurrentPhoto();
127             break;
128
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']);
134             }
135             break;
136
137          case 'what_to_do':
138             print $fspot->whatToDo();
139             break;
140
141          case 'reset_slideshow':
142             print $fspot->resetSlideShow();
143             break;
144
145          case 'get_next_slideshow_img':
146             print $fspot->getNextSlideShowImage();
147             break;
148          
149          case 'get_prev_slideshow_img':
150             print $fspot->getPrevSlideShowImage();
151             break;
152
153       }
154
155    } // process_ajax_request();
156
157 } // class PHPFSPOT_RPC
158
159 $rpc = new PHPFSPOT_RPC();
160 $rpc->process_ajax_request();
161
162 ?>