/[drupal]/contributions/modules/movino/standalone.inc
ViewVC logotype

Contents of /contributions/modules/movino/standalone.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Fri Jul 13 07:28:27 2007 UTC (2 years, 4 months ago) by tomsun
Branch: MAIN
CVS Tags: DRUPAL-5--1-0-1, DRUPAL-5--1-1, DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +1 -1 lines
File MIME type: text/x-php
Added info on the movino_admin.module
1 <?php // $Id$
2 /*
3 Movino-web
4 Copyright 2006, 2007 Tom Sundström
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 define('MOVINO_STANDALONE', TRUE);
21 include_once('movino.module');
22 include_once('optional/movino_lists.module');
23
24 if (is_file('../movino_player_cortado/movino_player_cortado.module')) {
25 include_once('../movino_player_cortado/movino_player_cortado.module');
26 define('PATH_CORTADO', '../movino_player_cortado');
27 } elseif (is_file('./movino_player_cortado.module')) {
28 include_once('./movino_player_cortado.module');
29 define('PATH_CORTADO', '.');
30 } elseif (is_file('./movino_player_cortado/movino_player_cortado.module')) {
31 include_once('./movino_player_cortado/movino_player_cortado.module');
32 define('PATH_CORTADO', './movino_player_cortado');
33 }
34
35 class movinoController {
36
37 function movinoController() {
38 if (!isset($_REQUEST['q'])) {
39 $_REQUEST['q'] = 'movino';
40 }
41 }
42
43 function page() {
44
45 // Fetch info on all pages the movino module and the movino list module implements.
46 $paths = array_merge(movino_menu(0), movino_menu(1));
47 $paths = array_merge($paths, movino_lists_menu(0));
48 $paths = array_merge($paths, movino_lists_menu(1));
49
50 foreach ($paths as $path) {
51 if ($path['path'] == substr($_REQUEST['q'], 0, strlen($path['path'])) &&
52 ereg("movino", $path['path'])) {
53
54 // Call the callback function implementing the page.
55 return call_user_func($path['callback']);
56 }
57 }
58 }
59 }
60
61
62 /**************************** Handle Drupal API calls ****************************/
63
64
65 function module_implements($hook) {
66 return FALSE;
67 }
68
69 function module_exists() {
70 return FALSE;
71 }
72
73 function module_invoke_all($hook) {
74 switch ($hook) {
75 case 'movino_player_supports':
76 if (defined('PATH_CORTADO')) {
77 return movino_player_cortado_movino_player_supports();
78 }
79 case 'movino_player':
80 if (defined('PATH_CORTADO')) {
81 return movino_player_cortado_movino_player();
82 }
83 }
84
85 return;
86 }
87
88 function arg($index) {
89 static $arguments, $q;
90
91 if (empty($arguments) || $q != $_GET['q']) {
92 $arguments = explode('/', $_GET['q']);
93 $q = $_GET['q'];
94 }
95
96 if (isset($arguments[$index])) {
97 return $arguments[$index];
98 }
99 }
100
101
102 function t($string, $args = 0) {
103 return $string;
104 }
105
106
107 function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
108 return '<a href="'. url($path, $query, $fragment, $absolute) . '">'. $text .'</a>';
109 }
110
111
112 function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
113 return $_SERVER['SCRIPT_NAME'] . '?q=' . $path . '&' . $query;
114 }
115
116
117 function drupal_get_path($type, $id) {
118 if ($id == 'movino_player_cortado') {
119 return PATH_CORTADO;
120 }
121 return '.';
122 }
123
124
125 function base_path() {
126 }
127
128
129 function drupal_add_css() {
130 }
131
132
133 function user_access() {
134 return TRUE;
135 }
136
137
138 function drupal_set_title() {
139 }
140
141
142 function variable_get($id, $alt) {
143 global $conf;
144
145 if (!isset($conf)) {
146 $conf = parse_ini_file('standalone.ini');
147 }
148
149 if (!isset($conf[$id])) {
150 return $alt;
151 }
152 return $conf[$id];
153
154 }
155
156
157 function theme() {
158 $args = func_get_args();
159 $function = 'theme_' . array_shift($args);
160
161 return call_user_func_array($function, $args);
162 }
163
164
165 function drupal_set_message($message = NULL, $type = 'status') {
166 echo '<div class="message">' . $message . '</div>';
167 }
168
169
170 function theme_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {
171 global $pager_total;
172 $output = '';
173
174 if ($pager_total[$element] > 1) {
175 $output .= '<div class="pager">';
176 $output .= theme('pager_first', ($tags[0] ? $tags[0] : t('first')), $limit, $element, $parameters);
177 $output .= theme('pager_previous', ($tags[1] ? $tags[1] : t('previous')), $limit, $element, 1, $parameters);
178 $output .= theme('pager_list', $limit, $element, ($tags[2] ? $tags[2] : 9 ), '', $parameters);
179 $output .= theme('pager_next', ($tags[3] ? $tags[3] : t('next')), $limit, $element, 1, $parameters);
180 $output .= theme('pager_last', ($tags[4] ? $tags[4] : t('last')), $limit, $element, $parameters);
181 $output .= '</div>';
182
183 return $output;
184 }
185 }
186
187
188 function theme_pager_list($limit, $element = 0, $quantity = 5, $text = '', $parameters = array()) {
189 global $pager_page_array, $pager_total;
190
191 $output = '<span class="pager-list">';
192 // Calculate various markers within this pager piece:
193 // Middle is used to "center" pages around the current page.
194 $pager_middle = ceil($quantity / 2);
195 // current is the page we are currently paged to
196 $pager_current = $pager_page_array[$element] + 1;
197 // first is the first page listed by this pager piece (re quantity)
198 $pager_first = $pager_current - $pager_middle + 1;
199 // last is the last page listed by this pager piece (re quantity)
200 $pager_last = $pager_current + $quantity - $pager_middle;
201 // max is the maximum page number
202 $pager_max = $pager_total[$element];
203 // End of marker calculations.
204
205 // Prepare for generation loop.
206 $i = $pager_first;
207 if ($pager_last > $pager_max) {
208 // Adjust "center" if at end of query.
209 $i = $i + ($pager_max - $pager_last);
210 $pager_last = $pager_max;
211 }
212 if ($i <= 0) {
213 // Adjust "center" if at start of query.
214 $pager_last = $pager_last + (1 - $i);
215 $i = 1;
216 }
217 // End of generation loop preparation.
218
219 // When there is more than one page, create the pager list.
220 if ($i != $pager_max) {
221 $output .= $text;
222 if ($i > 1) {
223 $output .= '<span class="pager-ellipsis">...</span>';
224 }
225
226 // Now generate the actual pager piece.
227 for (; $i <= $pager_last && $i <= $pager_max; $i++) {
228 if ($i < $pager_current) {
229 $output .= theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters);
230 }
231 if ($i == $pager_current) {
232 $output .= '<strong class="pager-current">'. $i .'</strong>';
233 }
234 if ($i > $pager_current) {
235 $output .= theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters);
236 }
237 }
238
239 if ($i < $pager_max) {
240 $output .= '<span class="pager-ellipsis"> - </span>';
241 }
242 }
243 $output .= '</span>';
244
245 return $output;
246 }
247
248
249 function theme_pager_first($text, $limit, $element = 0, $parameters = array()) {
250 global $pager_page_array;
251 $output = '';
252
253 // If we are anywhere but the first page
254 if ($pager_page_array[$element] > 0) {
255 $output = theme('pager_link', $text, pager_load_array(0, $element, $pager_page_array), $element, $parameters, array('class' => 'pager-first'));
256 }
257
258 return $output;
259 }
260
261
262 function theme_pager_next($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
263 global $pager_page_array, $pager_total;
264 $output = '';
265
266 // If we are anywhere but the last page
267 if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
268 $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
269 // If the next page is the last page, mark the link as such.
270 if ($page_new[$element] == ($pager_total[$element] - 1)) {
271 $output = theme('pager_last', $text, $limit, $element, $parameters);
272 }
273 // The next page is not the last page.
274 else {
275 $output = theme('pager_link', $text, $page_new, $element, $parameters, array('class' => 'pager-next'));
276 }
277 }
278
279 return $output;
280 }
281
282
283 function theme_pager_previous($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
284 global $pager_page_array;
285 $output = '';
286
287 // If we are anywhere but the first page
288 if ($pager_page_array[$element] > 0) {
289 $page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
290
291 // If the previous page is the first page, mark the link as such.
292 if ($page_new[$element] == 0) {
293 $output = theme('pager_first', $text, $limit, $element, $parameters);
294 }
295 // The previous page is not the first page.
296 else {
297 $output = theme('pager_link', $text, $page_new, $element, $parameters, array('class' => 'pager-previous'));
298 }
299 }
300
301 return $output;
302 }
303
304
305 function pager_load_array($value, $element, $old_array) {
306 $new_array = $old_array;
307 // Look for empty elements.
308 for ($i = 0; $i < $element; $i++) {
309 if (!$new_array[$i]) {
310 // Load found empty element with 0.
311 $new_array[$i] = 0;
312 }
313 }
314 // Update the changed element.
315 $new_array[$element] = (int)$value;
316 return $new_array;
317 }
318
319
320 function theme_pager_last($text, $limit, $element = 0, $parameters = array()) {
321 global $pager_page_array, $pager_total;
322 $output = '';
323
324 // If we are anywhere but the last page
325 if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
326 $output = theme('pager_link', $text, pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), $element, $parameters, array('class' => 'pager-last'));
327 }
328
329 return $output;
330 }
331
332
333 function theme_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
334 $page = isset($_GET['page']) ? $_GET['page'] : '';
335 if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
336 $parameters['page'] = $new_page;
337 }
338
339 $query = array();
340 if (count($parameters)) {
341 $query[] = drupal_query_string_encode($parameters, array());
342 }
343 $querystring = pager_get_querystring();
344 if ($querystring != '') {
345 $query[] = $querystring;
346 }
347
348 // Set each pager link title
349 if (!isset($attributes['title'])) {
350 static $titles = NULL;
351 if (!isset($titles)) {
352 $titles = array(
353 t('first') => t('Go to first page'),
354 t('previous') => t('Go to previous page'),
355 t('next') => t('Go to next page'),
356 t('last') => t('Go to last page'),
357 );
358 }
359 if (isset($titles[$text])) {
360 $attributes['title'] = $titles[$text];
361 }
362 else if (is_numeric($text)) {
363 $attributes['title'] = t('Go to page @number', array('@number' => $text));
364 }
365 }
366
367 return l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL);
368 }
369
370
371 function pager_get_querystring() {
372 static $string = NULL;
373 if (!isset($string)) {
374 $string = drupal_query_string_encode($_REQUEST, array_merge(array('q', 'page'), array_keys($_COOKIE)));
375 }
376 return $string;
377 }
378
379
380 function drupal_query_string_encode($query, $exclude = array(), $parent = '') {
381 $params = array();
382
383 foreach ($query as $key => $value) {
384 $key = drupal_urlencode($key);
385 if ($parent) {
386 $key = $parent .'['. $key .']';
387 }
388
389 if (in_array($key, $exclude)) {
390 continue;
391 }
392
393 if (is_array($value)) {
394 $params[] = drupal_query_string_encode($value, $exclude, $key);
395 }
396 else {
397 $params[] = $key .'='. drupal_urlencode($value);
398 }
399 }
400
401 return implode('&', $params);
402 }
403
404
405 function drupal_urlencode($text) {
406 if (variable_get('clean_url', '0')) {
407 return str_replace(array('%2F', '%26', '%23'),
408 array('/', '%2526', '%2523'),
409 urlencode($text));
410 }
411 else {
412 return str_replace('%2F', '/', urlencode($text));
413 }
414 }
415
416
417 function format_date($timestamp) {
418 return date('Y.m.d H:i:s', $timestamp);
419 }
420
421 ?>

  ViewVC Help
Powered by ViewVC 1.1.2