/[drupal]/contributions/modules/pageroute/pageroute_ui.module
ViewVC logotype

Contents of /contributions/modules/pageroute/pageroute_ui.module

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


Revision 1.36 - (show annotations) (download) (as text)
Thu Oct 11 12:35:33 2007 UTC (2 years, 1 month ago) by fago
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.35: +2 -2 lines
File MIME type: text/x-php
#176586: UI fix: fixed checking for existing page names on page creation
1 <?php
2 // $Id: pageroute_ui.module,v 1.35 2007/05/03 13:34:29 fago Exp $
3
4 /**
5 * @file
6 * Adminstration pages allowing you to create and edit pageroutes.
7 */
8
9
10 /**
11 * Implementation of hook_help().
12 */
13 function pageroute_ui_help($section) {
14
15 switch ($section) {
16 case 'admin/help#pageroute_ui':
17 return _pageroute_ui_get_help();
18 case 'admin/build/pageroute/route/'. arg(4) .'/add':
19 if (module_exists('help')) {
20 return t('Have a look at the pageroute !link for some explanation of '.
21 'the pageroute page types.',
22 array(
23 '!link' => l(t('Documentation'), 'admin/help/pageroute_ui')
24 ));
25 }
26 else {
27 return t('Activate the help module if you need some '.
28 'explanation of the pageroute page types.');
29 }
30
31 }
32 }
33
34
35
36 /**
37 * Implementation of hook_menu().
38 */
39 function pageroute_ui_menu($may_cache) {
40
41 if ($may_cache) {
42 $access = user_access('administer pageroutes');
43
44 $items[] = array(
45 'path' => 'admin/build/pageroute',
46 'title' => t('Pageroute'),
47 'description' => t('Manage your pageroutes.'),
48 'callback' => 'pageroute_ui_admin',
49 'access' => $access
50 );
51 $items[] = array(
52 'path' => 'admin/build/pageroute/list',
53 'title' => t('List routes'),
54 'type' => MENU_DEFAULT_LOCAL_TASK,
55 'weight' => -10
56 );
57 $items[] = array(
58 'path' => 'admin/build/pageroute/add',
59 'title' => t('Add route'),
60 'callback' => 'drupal_get_form',
61 'callback arguments' => array('pageroute_ui_route_edit', 'add'),
62 'access' => $access,
63 'type' => MENU_LOCAL_TASK
64 );
65 $items[] = array(
66 'path' => 'admin/build/pageroute/delete',
67 'callback' => 'drupal_get_form',
68 'callback arguments' => array('pageroute_ui_route_delete_confirm'),
69 'access' => $access,
70 'type' => MENU_CALLBACK
71 );
72 }
73 else if (is_numeric(arg(4))) {
74 $items[] = array(
75 'path' => 'admin/build/pageroute/route/'. arg(4) .'/edit',
76 'title' => t('Edit route'),
77 'callback' => 'drupal_get_form',
78 'callback arguments' => array('pageroute_ui_route_edit', 'edit', arg(4)),
79 'access' => $access,
80 'type' => MENU_LOCAL_TASK,
81 'weight' => -20,
82 );
83 $items[] = array(
84 'path' => 'admin/build/pageroute/route/'. arg(4),
85 'callback' => 'pageroute_ui_page_edit_page',
86 'type' => MENU_CALLBACK,
87 'access' => $access
88 );
89 $items[] = array(
90 'path' => 'admin/build/pageroute/route/'. arg(4) .'/list',
91 'title' => t('List pages'),
92 'type' => MENU_DEFAULT_LOCAL_TASK,
93 'weight' => -10
94 );
95 $items[] = array(
96 'path' => 'admin/build/pageroute/route/'. arg(4) .'/add',
97 'title' => t('Add page'),
98 'callback' => 'pageroute_ui_page_edit_page',
99 'access' => $access,
100 'type' => MENU_LOCAL_TASK
101 );
102 $items[] = array(
103 'path' => 'admin/build/pageroute/route/'. arg(4) .'/edit/'. arg(6),
104 'callback' => 'pageroute_ui_page_edit_page',
105 'access' => $access,
106 'type' => MENU_CALLBACK
107 );
108 $items[] = array(
109 'path' => 'admin/build/pageroute/route/'. arg(4) .'/delete',
110 'callback' => 'drupal_get_form',
111 'callback arguments' => array('pageroute_ui_page_delete_confirm', arg(4), arg(6)),
112 'access' => $access,
113 'type' => MENU_CALLBACK
114 );
115 }
116 return $items;
117 }
118
119 /**
120 * Implementation of hook_perm().
121 */
122 function pageroute_ui_perm() {
123 return array('administer pageroutes');
124 }
125
126
127 function pageroute_ui_admin() {
128
129 $result = db_query("SELECT * FROM {pageroute_routes} ORDER BY path");
130
131 $header = array(t('Path'), array('data' => t('Operations'), 'colspan' => '3'));
132
133 while ($route = db_fetch_object($result)) {
134 $row = array();
135 $row[] = check_plain($route->path);
136 $row[] = l(t('Edit route'), "admin/build/pageroute/route/$route->prid/edit");
137 $row[] = l(t('Edit pages'), "admin/build/pageroute/route/$route->prid/list");
138 $row[] = l(t('Add page'), "admin/build/pageroute/route/$route->prid/add");
139 $rows[] = $row;
140 }
141
142 if (empty($rows)) {
143 $rows[] = array(array('data' => t('No routes available.'), 'colspan' => '4', 'class' => 'message'));
144 }
145
146 return theme('table', $header, $rows, array('id' => 'pageroute'));
147 }
148
149
150 function pageroute_ui_route_edit($op = 'add', $prid = NULL) {
151 if ($op != 'add' && is_numeric($prid)) {
152 $route = db_fetch_object(db_query("SELECT * FROM {pageroute_routes} WHERE prid = %d", $prid));
153 $route->options = unserialize($route->options);
154 drupal_set_title(t('Edit route'));
155 }
156
157 $form['path'] = array('#type' => 'textfield',
158 '#title' => t('Path'),
159 '#maxlength' => 127,
160 '#default_value' => $route ? $route->path : '',
161 '#required' => TRUE,
162 '#weight' => -5,
163 );
164 $form['options']['#tree'] = TRUE;
165 $form['options']['tabs'] = array(
166 '#type' => 'radios',
167 '#title' => t('Tabs'),
168 '#options' => array(
169 0 => t('Don\'t show any tabs'),
170 PAGEROUTE_MENU_TABS => t('Use the common drupal menu tabs'),
171 PAGEROUTE_BUTTON_TABS => t('Show tab-like submit buttons above the page content.'),
172 ),
173 '#default_value' => isset($route->options['tabs']) ? $route->options['tabs'] : 0,
174 '#description' => t('Note that the commom drupal menu tabs won\'t save the actual form, if they are used. Also any arguments appended to the URL will be lost. They are in particular useful for pageroutes, which focus on displaying content.'),
175 '#weight' => -1,
176 );
177 $form['options']['access'] = array(
178 '#type' => 'fieldset',
179 '#title' => t('Access control'),
180 '#collapsible' => TRUE,
181 );
182 $form['options']['access']['allowed_roles'] = array(
183 '#type' => 'checkboxes',
184 '#title' => t('Permit access to the pageroute for only this roles'),
185 '#options' => user_roles(),
186 '#default_value' => isset($route->options['access']['allowed_roles']) ? $route->options['access']['allowed_roles'] : array(2),
187 );
188 $form['options']['access']['#weight'] = 5;
189
190 $form['advanced'] = array(
191 '#type' => 'fieldset',
192 '#title' => t('Advanced settings'),
193 '#collapsible' => TRUE,
194 '#collapsed' => TRUE,
195 '#tree' => FALSE,
196 '#weight' => 10,
197 );
198 $form['advanced']['options']['#tree'] = TRUE;
199 $form['advanced']['options']['redirect_path'] = array(
200 '#type' => 'textfield',
201 '#title' => t('Customized redirect path'),
202 '#default_value' => $route->options['redirect_path'],
203 '#maxlength' => 64,
204 '#size' => 45,
205 '#description' => t('If entered, a user will be redirected to this path after he has completed the pageroute. Specify an existing path. For example: node/28, user, taxonomy/term/1+2.'). ' '.
206 t('You may also use the following replacement variables: !uid (User ID), !nid (Node ID). For example use: node/!nid to redirect to the node with the id taken from the pageroute arguments.'),
207 '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
208 );
209 $form['advanced']['options']['no_messages'] = array(
210 '#type' => 'checkbox',
211 '#title' => t('Don\'t show drupal messages during this route.'),
212 '#default_value' => isset($route->options['no_messages']) ? $route->options['no_messages'] : 1,
213 );
214 $form['advanced']['options']['destination'] = array(
215 '#type' => 'checkbox',
216 '#title' => t('Preserve destination parameter during this route.'),
217 '#default_value' => isset($route->options['destination']) ? $route->options['destination'] : 1,
218 );
219 if (module_exists('states')) {
220 $form['advanced']['options']['track_user'] = array(
221 '#type' => 'checkbox',
222 '#title' => t('Verify that a user goes through each page of the route.'),
223 '#default_value' => $route->options['track_user'],
224 '#description' => t('If checked, pageroute verifies that a user can only reach the next page. '.
225 'To achieve this, it will track how far a user has ever gone through the route by using the states module.'),
226 );
227 }
228
229 $form['submit'] = array('#type' => 'submit',
230 '#value' => t('Submit'),
231 '#weight' => 15,
232 );
233 if ($route) {
234 $form['delete'] = array('#type' => 'submit',
235 '#value' => t('Delete'),
236 '#weight' => 16,
237 );
238 }
239 else {
240 $route = (object) array('new' => TRUE);
241 }
242
243 $form['route'] = array('#type' => 'value', '#value' => &$route);
244
245 $form['#validate'] = array('pageroute_ui_route_edit_validate' => array());
246 $form['#submit'] = array('pageroute_ui_route_edit_submit' => array());
247
248 return $form;
249 }
250
251 function pageroute_ui_route_edit_validate($form_id, &$form_values, &$form) {
252
253 $path = rtrim(ltrim($form_values['path'], '/'), '/');
254 form_set_value($form['path'], $path);
255
256 if (!valid_url($path)) {
257 form_set_error('path', t('The path has to be a valid URL.'));
258 }
259 if ($form_values['route']->path != $path && menu_get_item(NULL, $path)) {
260 form_set_error('path', t('This drupal path is already in use. Choose another path.'));
261 }
262 }
263
264 function pageroute_ui_route_edit_submit($form_id, &$form_values) {
265 $form_values['options']['arg_offset'] = substr_count($form_values['path'], '/') + 1;
266
267 if (!$form_values['route']->new) {
268 if ($form_values['op'] == t('Delete')) {
269 return 'admin/build/pageroute/delete/' . $form_values['route']->prid;
270 }
271 db_query("UPDATE {pageroute_routes} SET path = '%s', options = '%s' WHERE prid = %d",
272 $form_values['path'], serialize($form_values['options']), $form_values['route']->prid);
273 }
274 else {
275 $form_values['route']->prid = db_next_id('{pageroute}_rid');
276 db_query("INSERT INTO {pageroute_routes} (prid, path, options) VALUES(%d, '%s', '%s')",
277 $form_values['route']->prid, $form_values['path'], serialize($form_values['options']));
278 }
279 if (module_exists('states')) {
280 states_clear_machine_cache();
281 }
282 cache_clear_all('*', 'cache_menu', TRUE);
283 return 'admin/build/pageroute';
284 }
285
286 function pageroute_ui_route_delete_confirm($route) {
287
288 if (is_numeric(arg(4))) {
289 $route = db_fetch_object(db_query("SELECT * FROM {pageroute_routes} WHERE prid = %d", arg(4)));
290 $route->options = unserialize($route->options);
291 }
292 if (!$route) {
293 drupal_not_found();
294 exit;
295 }
296
297 $form['route'] = array('#type' => 'value', '#value' => $route);
298
299 return confirm_form($form,
300 t('Are you sure you want to delete the route %path?', array('%path' => $route->path)),
301 'admin/build/pageroute',
302 t('Deleting a route will delete all the pages you created in it. This action cannot be undone.'),
303 t('Delete'), t('Cancel')
304 );
305 }
306
307 function pageroute_ui_route_delete_confirm_submit($form_id, &$form_values) {
308 db_query("DELETE FROM {pageroute_pages} WHERE prid = %d", $form_values['route']->prid);
309 db_query("DELETE FROM {pageroute_routes} WHERE prid = %d", $form_values['route']->prid);
310 cache_clear_all('*', 'cache_menu', TRUE);
311 drupal_set_message('Your route has been deleted.');
312 return 'admin/build/pageroute';
313 }
314
315
316
317 function pageroute_ui_page_edit_page() {
318 if (is_numeric(arg(4))) {
319 $route = db_fetch_object(db_query("SELECT * FROM {pageroute_routes} WHERE prid = %d", arg(4)));
320 $route->options = unserialize($route->options);
321 }
322 if (!$route) {
323 drupal_not_found();
324 exit;
325 }
326
327 if (arg(5) == 'add') {
328 drupal_set_title(check_plain($route->path));
329 if (in_array(arg(6), array_keys(pageroute_get_types()))) {
330 $type = arg(6);
331 }
332 else {
333 return drupal_get_form('pageroute_ui_page_add_type');
334 }
335 }
336 else if (arg(5) != 'edit') {
337 return pageroute_ui_route_overview($route);
338 }
339 else if (arg(6)) {
340 $page = pageroute_load_page(arg(6), $route);
341 if (!$page) {
342 drupal_not_found();
343 exit;
344 }
345 drupal_set_title(check_plain($page->name));
346 $type = $page->type;
347 }
348
349 return drupal_get_form('pageroute_ui_page_edit', $route, $page, $type);
350 }
351
352 function pageroute_ui_page_edit($route, $page, $type) {
353
354 if ($help = pageroute_invoke($type, 'help')) {
355 $form['help'] = array(
356 '#type' => 'fieldset',
357 '#title' => t('Help'),
358 '#collapsible' => TRUE,
359 '#description' => $help,
360 );
361 }
362
363 $form['name'] = array(
364 '#type' => 'textfield',
365 '#title' => t('Name'),
366 '#maxlength' => 63,
367 '#default_value' => $page->name,
368 '#required' => TRUE,
369 '#description' => t('Last part of the page\'s URL. Used for identifing the page.'),
370 );
371 $form['title'] = array(
372 '#type' => 'textfield',
373 '#title' => t('Title'),
374 '#maxlength' => 255,
375 '#default_value' => $page->title,
376 '#description' => t('An optional title which will be set when the page is viewed.'),
377 '#weight' => 1,
378 );
379 $form['options']['activated'] = array(
380 '#type' => 'checkbox',
381 '#title' => t('Activated'),
382 '#default_value' => isset($page->options['activated']) ? $page->options['activated'] : 1,
383 '#description' => t('When the pageroute is generated, deactivated pages will be ignored.'),
384 '#weight' => 0,
385 );
386 if ($page->route->options['tabs']) {
387 $form['options']['no_tab'] = array(
388 '#type' => 'checkbox',
389 '#title' => t('Don\'t show a tab for this page'),
390 '#default_value' => $page->options['no_tab'],
391 '#weight' => 1,
392 );
393 }
394 $form['options']['forward'] = array(
395 '#type' => 'textfield',
396 '#title' => t('Forward button label'),
397 '#maxlength' => 32,
398 '#default_value' => isset($page->options['forward']) ? $page->options['forward'] : t('Forward'),
399 '#description' => t('The label of the forward button. Leave it empty to hide the button.'),
400 '#weight' => 3,
401 );
402 $form['options']['back'] = array(
403 '#type' => 'textfield',
404 '#title' => t('Back button label'),
405 '#maxlength' => 32,
406 '#default_value' => isset($page->options['back']) ? $page->options['back'] : t('Back'),
407 '#description' => t('The label of the back button. Leave it empty to hide the button.'),
408 '#weight' => 4,
409 );
410 $form['options']['cancel'] = array(
411 '#type' => 'textfield',
412 '#title' => t('Cancel link label'),
413 '#maxlength' => 32,
414 '#default_value' => $page->options['cancel'],
415 '#description' => t('The label of the cancel link. Leave it empty to hide the link, but note that the link is the only possibility for the user to not save the form while staying in the route.'),
416 '#weight' => 3,
417 );
418 $form['options']['#tree'] = TRUE;
419 $form['options']['#weight'] = 3;
420
421 $form['weight'] = array(
422 '#type' => 'weight',
423 '#title' => t('Weight'),
424 '#default_value' => $page->weight,
425 '#description' => t('Used for ordering the pages. Pages with lower weights are used first.'),
426 '#weight' => 7,
427 );
428
429 $form['submit'] = array(
430 '#type' => 'submit',
431 '#value' => t('Submit'),
432 '#weight' => 9,
433 );
434
435 if ($page) {
436 $form['delete'] = array(
437 '#type' => 'submit',
438 '#value' => t('Delete'),
439 '#weight' => 10,
440 );
441 }
442
443 $form['page_type'] = array('#type' => 'value', '#value' => $type);
444 $form['page'] = array('#type' => 'value', '#value' => $page);
445 $form['route'] = array('#type' => 'value', '#value' => $route);
446
447 //let the page type add further form items
448 $bases = pageroute_get_types('base');
449 $function = $bases[$type] .'_page_'. $type. '_ui';
450 if (function_exists($function)) {
451 $function($route, $page, $form, $type);
452 }
453
454 return $form;
455 }
456
457 function pageroute_ui_page_edit_validate($form_id, &$form_values, &$form) {
458 $name = rtrim(ltrim($form_values['name'], '/'), '/');
459 form_set_value($form['name'], $name);
460
461 if (strpos($name, '/') !== FALSE) {
462 form_set_error('name', t('The page name must not contain a slash "/".'));
463 }
464 if (!valid_url($name)) {
465 form_set_error('name', t('The page name has to be a valid URL.'));
466 }
467 if ((!$form_values['page'] || $form_values['page']->name != $name) &&
468 db_result(db_query("SELECT * FROM {pageroute_pages} WHERE prid = %d AND name = '%s'", $form_values['route']->prid, $name))) {
469 form_set_error('name', t('A page with this name already exists. Choose another name.'));
470 }
471 if (menu_get_item(NULL, $form_values['route']->path .'/'. $name)) {
472 form_set_error('name', t('This drupal path is already in use. Choose another name.'));
473 }
474 }
475
476 function pageroute_ui_page_edit_submit($form_id, &$form_values) {
477 if ($form_values['page']) {
478 if ($form_values['op'] == t('Delete')) {
479 return 'admin/build/pageroute/route/'. $form_values['route']->prid .'/delete/' . $form_values['page']->name;
480 }
481 $edit_page = (object)$form_values;
482 pageroute_ui_update_page($form_values['route'], $edit_page, $form_values['page']->name);
483 pageroute_ui_update_neighbours($form_values['route']);
484 }
485 else {
486 //add a new page
487 $edit_page = (object)$form_values;
488 db_query("INSERT INTO {pageroute_pages} (prid, name, title, weight, type, options) VALUES(%d, '%s', '%s', %d, '%s', '%s')",
489 $form_values['route']->prid, $form_values['name'], $form_values['title'], $form_values['weight'], $form_values['page_type'], serialize($edit_page->options));
490 pageroute_ui_update_neighbours($form_values['route']);
491 }
492 cache_clear_all('*', 'cache_menu', TRUE);
493 return 'admin/build/pageroute/route/'. $form_values['route']->prid;
494 }
495
496
497
498 function pageroute_ui_route_overview(&$route) {
499
500 drupal_set_title(check_plain($route->path));
501 $result = db_query("SELECT * FROM {pageroute_pages} WHERE prid = %d ORDER BY weight, name", $route->prid);
502
503 $header = array(t('Name'), t('Title'), t('Type'), t('Weight'), array('data' => t('Operations'), 'colspan' => '2'));
504 $types = pageroute_get_types();
505
506 $rows = array();
507 while ($page = db_fetch_object($result)) {
508 $page->options = unserialize($page->options);
509 $row = array();
510 $row[] = l($page->name, $route->path .'/'. $page->name);
511 $row[] = check_plain($page->title);
512 $row[] = ($page->type == 'view' && $page->options['nid'] != 0)
513 ? l($types[$page->type], 'node/'. $page->options['nid'])
514 : $types[$page->type];
515 $row[] = $page->weight;
516 $row[] = l(t('Edit'), "admin/build/pageroute/route/$route->prid/edit/$page->name");
517 $row[] = l(t('Delete'), "admin/build/pageroute/route/$route->prid/delete/$page->name");
518 $rows[] = $row;
519 }
520
521 if (empty($rows)) {
522 $rows[] = array(array('data' => t('No pages available.'), 'colspan' => '5', 'class' => 'message'));
523 }
524
525 return theme('table', $header, $rows, array('id' => 'pageroute_ui_pages'));
526 }
527
528 /*
529 * Shows a form for choosing the inital type of the page
530 */
531 function pageroute_ui_page_add_type() {
532
533 $form['type'] = array(
534 '#type' => 'radios',
535 '#title' => t('Choose a page type'),
536 '#options' => pageroute_get_types(),
537 '#required' => TRUE,
538 );
539 $form['submit'] = array(
540 '#type' => submit,
541 '#value' => t('Forward'),
542 );
543 return $form;
544 }
545
546 function pageroute_ui_page_add_type_submit($form_id, &$form_values) {
547 return "admin/build/pageroute/route/". arg(4) ."/add/". $form_values['type'];
548 }
549
550
551 function pageroute_ui_page_delete_confirm($prid, $page_name) {
552 $route = db_fetch_object(db_query("SELECT * FROM {pageroute_routes} WHERE prid = %d", $prid));
553 $route->options = unserialize($route->options);
554
555 if ($page_name) {
556 $page = pageroute_load_page($page_name, $route);
557 }
558 if (!$page) {
559 drupal_not_found();
560 exit;
561 }
562
563 $form['page'] = array('#type' => 'value', '#value' => $page);
564 $form['route'] = array('#type' => 'value', '#value' => $route);
565
566 return confirm_form($form,
567 t('Are you sure you want to delete the page %name?', array('%name' => $page->name)),
568 'admin/build/pageroute/route/'. $route->prid,
569 t('This action cannot be undone.'), t('Delete'), t('Cancel')
570 );
571 }
572
573 function pageroute_ui_page_delete_confirm_submit($form_id, &$form_values) {
574 db_query("DELETE FROM {pageroute_pages} WHERE prid = %d AND name ='%s'",
575 $form_values['page']->prid, $form_values['page']->name);
576 pageroute_ui_update_neighbours($route = (object)array('prid' => $form_values['page']->prid));
577 cache_clear_all('*', 'cache_menu', TRUE);
578 drupal_set_message('Your page has been deleted.');
579 return 'admin/build/pageroute/route/'. $form_values['page']->prid;
580 }
581
582 /*
583 * Determines the neighbours for all pages and writes their names
584 * into $page->options['neighbours'] with the keys 'back' and 'forward'
585 * so that they can be accessed easily on runtime.
586 *
587 * All changfes are stored in the database.
588 *
589 * @param $route The route, for which the page neighbours should be updated
590 */
591 function pageroute_ui_update_neighbours(&$route) {
592 $result = db_query("SELECT * FROM {pageroute_pages} WHERE prid = %d ORDER BY weight, name", $route->prid);
593
594 $pages = array();
595 $updated = array();
596 $back = (object)array('name' => '');
597
598 while ($the_page = db_fetch_object($result)) {
599 $the_page->options = unserialize($the_page->options);
600
601 if (isset($the_page->options['activated']) && !$the_page->options['activated']) {
602 continue;
603 }
604
605 if ($back->name != $the_page->options['neighbours']['back']) {
606 $the_page->options['neighbours']['back'] = $back->name;
607 $updated[$the_page->name] = $the_page;
608 }
609 if ($back->name && $back->options['neighbours']['forward'] != $the_page->name) {
610 $back->options['neighbours']['forward'] = $the_page->name;
611 $updated[$back->name] = $back;
612 }
613 $back = $the_page;
614 }
615 if ($back->options['neighbours']['forward'] != '') {
616 $back->options['neighbours']['forward'] = '';
617 $updated[$back->name] = $back;
618 }
619
620 //now store all updates in the db
621 foreach ($updated as $the_page) {
622 pageroute_ui_update_page($route, $the_page, $the_page->name);
623 }
624 }
625
626 /*
627 * Stores the updated $page in the database
628 */
629 function pageroute_ui_update_page(&$route, &$page, $old_name) {
630 db_query("UPDATE {pageroute_pages} SET name = '%s', title='%s', ".
631 "weight = %d, options = '%s' WHERE prid = %d AND name = '%s'",
632 $page->name, $page->title, $page->weight,
633 serialize($page->options), $route->prid, $old_name);
634 }
635
636 /**
637 * Get the help for all page types and show it
638 *
639 * Modules that contribute a page type should implement hook_pageroute_help().
640 */
641 function _pageroute_ui_get_help() {
642 $output = '<p>'. t('The module can be used to provide an userfriendly '.
643 'wizard for creating and editing several nodes. It will provide '.
644 'new URLs for all pages and optionally create customizable '.
645 'back/forward buttons at the bottom of a page, so that users are '.
646 'being lead through the route.') .'</p>';
647
648 $output .= '<h2>Pageroute Arguments</h2>';
649 $output .= '<p>'. t('Each pageroute takes further arguments to its path. '.
650 'Each page type can make use of these arguments, but they need not. '.
651 'Have a look at the page type description to see how it handles the arguments.'). '<br />'.
652 t('Page types will interprete the first additional argument as node id, '.
653 'which is used by most node page types, e.g. by the node editing page. '.
654 'The second argument will be interpreted as id of the user for which '.
655 'the route will be gone through. E.g. this will affect the author of new nodes. '.
656 'Furthermore if you pass an id of 0 pageroute will ignore that argument. '.
657 'E.g. you can link to your pageroute by using the path '.
658 '"%path" to go through the route as the currently logged in '.
659 'user (id 0) and with the node id 4 as first argument.',
660 array('%path' => 'pageroutepath/4/0')) .'</p>';
661
662 $output .= '<h2>Page types</h2>';
663 $output .= '<p>'. t('Each page has a page type which sets the behaviour of '.
664 'the page. All modules can contribute further page types.') .'</p>';
665
666 $type_names = pageroute_get_types();
667 foreach (pageroute_get_types('base') as $type => $base) {
668 $output .= '<h3>'. $type_names[$type] .'</h3>';
669
670 $function = $base .'_page_'. $type .'_help';
671 if (function_exists($function)) {
672 $output .= '<p>'. $function() .'</p>';
673 }
674 else {
675 $output .= '<p>'. t('There is no help available for this page type.') .'</p>';
676 }
677 }
678
679 return $output;
680 }

  ViewVC Help
Powered by ViewVC 1.1.2