preparations for sef
[eventlist:eventlist.git] / router.php
1 <?php 
2 /**
3 * @version 0.9 $Id$
4 * @package Joomla 
5 * @subpackage EventList
6 * @copyright (C) 2005 - 2007 Christoph Lukes
7 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
8 */
9 /*
10 function EventListBuildURL(&$ARRAY, &$params)
11 {
12         $resolveNames = $params->get('realnames',0);
13
14         // TODO: Resolve category names
15         $parts = array();
16         if(isset($ARRAY['view'])) {
17                 $parts[] = $ARRAY['view'];
18         };
19
20         if(isset($ARRAY['layout'])) {
21                 $parts[] = $ARRAY['layout'];
22         };
23
24         if(isset($ARRAY['id'])) {
25                 $parts[] = $ARRAY['id'];
26         };
27         
28         if(isset($ARRAY['did'])) {
29                 $parts[] = $ARRAY['did'];
30         };
31         
32         if(isset($ARRAY['locatid'])) {
33                 $parts[] = $ARRAY['locatid'];
34         };
35         
36         if(isset($ARRAY['categid'])) {
37                 $parts[] = $ARRAY['categid'];
38         };
39
40         if (isset( $ARRAY['limit'] ))
41         {
42                 // Do all pages if limit = 0
43                 if ($ARRAY['limit'] == 0) {
44                         $parts[] = 'all';
45                 } else {
46                         $limit          = (int) $ARRAY['limit'];
47                         $limitstart     = (int) @$ARRAY['limitstart'];
48                         $page           = floor( $limitstart / $limit ) + 1;
49                         $parts[]        = 'page'.$page.':'.$limit;
50                 }
51         }
52
53         //unset the whole array
54         $ARRAY = array();
55
56         return $parts;
57 }
58
59 function EventListParseURL($ARRAY, &$params)
60 {
61         // view is always the first element of the array
62         $view   = array_shift($ARRAY);
63         $nArray = count($ARRAY);
64
65         JRequest::setVar('view', $view, 'get');
66
67         switch ($view)
68         {
69                 case 'venuesview':
70                 case 'categoriesdetailed':
71                 case 'categoriesview':
72                 case 'eventlist':
73                 {
74                         if (count($ARRAY))
75                         {
76                                 $variable = array_shift($ARRAY);
77
78                                 if(is_numeric($variable))
79                                 {
80                                         JRequest::setVar('id', $variable, 'get');
81                                 }
82                                 else
83                                 {
84                                         JRequest::setVar('layout', $variable, 'get');
85                                         $variable = array_shift($ARRAY);
86                                         JRequest::setVar('id', $variable, 'get');
87                                 }
88                         }                       
89                         
90                 } break;
91
92                 case 'details':
93                 {
94                                 $variable = array_shift($ARRAY);
95                                 JRequest::setVar('did', $variable, 'get');
96
97                 } break;
98                 
99                 case 'categoryevents':
100                 {
101                                 $variable = array_shift($ARRAY);
102                                 JRequest::setVar('categid', $variable, 'get');
103                         
104                 } break;
105                 
106                 case 'venueevents':
107                 {
108                                 $variable = array_shift($ARRAY);
109                                 JRequest::setVar('locatid', $variable, 'get');
110                 } break;
111         
112         
113                 // Handle Pagination
114                 $last = array_shift($ARRAY);
115                 if ($last == 'all')
116                 {
117                         array_pop( $ARRAY );
118                         JRequest::setVar('limitstart', 0, 'get');
119                         JRequest::setVar('limit', 0, 'get');
120                         // if you want more than 1e6 on your page then you are nuts!
121                 }
122                 elseif (strpos( $last, 'page' ) === 0)
123                 {
124                         array_pop( $ARRAY );
125                         $pts            = explode( ':', $last );
126                         $limit          = @$pts[1];
127                         $limitstart     = (max( 1, intval( str_replace( 'page', '', $pts[0] ) ) ) - 1)  * $limit;
128                         JRequest::setVar('limit',$limit, 'get');
129                         JRequest::setVar('limitstart', $limitstart, 'get');
130                 }
131         
132                 default: break;
133         }
134 }
135 */
136
137 function EventListBuildRoute(&$query)
138 {
139         $segments = array();
140
141         if(isset($query['did']))
142         {
143                 $segments[] = $query['did'];
144                 unset($query['did']);
145         };
146
147         if(isset($query['locatid']))
148         {
149                 $segments[] = $query['locatid'];
150                 unset($query['locatid']);
151         };
152
153         unset($query['view']);
154
155         return $segments;
156 }
157
158 function EventListParseRoute($segments)
159 {
160         //Get the active menu item
161         $menu =& JMenu::getInstance();
162         $item =& $menu->getActive();
163
164         // Count route segments
165         $count = count($segments);
166
167         //Handle View and Identifier
168         switch($item->query['view'])
169         {
170                 case 'categoryevents':
171                 {
172                         JRequest::setVar('categid'  , $segments[1], 'get');
173                         $view = 'categoryevents';
174
175                 } break;
176
177                 case 'details':
178                 {
179                         JRequest::setVar('did'          , $segments[1], 'get');
180                         $view = 'details';
181
182                 } break;
183                 
184                 case 'eventlist':
185                 {
186                         $view = 'eventlist';
187
188                 } break;
189                 
190                 case 'categoriesdetailed':
191                 {
192                         $view = 'categoriesdetailed';
193
194                 } break;
195                 
196                 case 'categoriesview':
197                 {
198                         $view = 'categoriesview';
199
200                 } break;
201                 
202                 case 'venuesview':
203                 {
204                         $view = 'venuesview';
205
206                 } break;
207                 
208                 case 'editevent':
209                 {
210                         JRequest::setVar('id'           , $segments[1], 'get');
211                         $view = 'editevent';
212
213                 } break;
214                 
215                 case 'editvenue':
216                 {
217                         JRequest::setVar('id'           , $segments[1], 'get');
218                         $view = 'editvenue';
219
220                 } break;
221         }
222
223         JRequest::setVar('view'         , $view, 'get');
224 }
225 ?>