/[drupal]/contributions/modules/pageroute/pageroute.page_add.inc
ViewVC logotype

Contents of /contributions/modules/pageroute/pageroute.page_add.inc

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


Revision 1.1 - (show annotations) (download) (as text)
Sat Sep 13 13:45:09 2008 UTC (14 months, 2 weeks ago) by tauran
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
Initial commit of pageroute d6 dev version.
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Page add type
7 */
8
9 include_once(drupal_get_path('module', 'pageroute') .'/pageroute.page.inc');
10
11 class pageroute_page_add extends pageroute_page {
12 /*
13 * Returns the node adding form for the configured node type
14 */
15 function get_form(&$form_state, &$args) {
16
17 $form = array();
18
19 $args['hide_pageroute_buttons'] = FALSE;
20 $args['submit_action'] = PAGEROUTE_FORWARD;
21
22 return pageroute_page_add::get_node_add_form(&$form_state, $this);
23 }
24
25 public static function get_node_add_form(&$form_state, &$page) {
26 $type = $page->options['content-type'];
27
28 // If a node type has been specified, validate its existence.
29 if (node_access('create', $type)) {
30 $account = user_load(array('uid' => pageroute_page_get_uid($this, 'administer nodes')));
31
32 // Initialize settings:
33 $node = array('uid' => $account->uid, 'name' => $account->name, 'type' => $type);
34
35 unset($form_state['node']);
36 $form = drupal_retrieve_form($type .'_node_form', $form_state, $node);
37 drupal_prepare_form($type .'_node_form', $form, $form_state);
38
39 $page->configure_form(&$form);
40
41 return $form;
42 }
43 else {
44 drupal_access_denied();
45 pageroute_exit_now();
46 }
47 }
48
49 public static function ui($page, &$form) {
50 $form['options']['content-type'] = array(
51 '#type' => 'select',
52 '#title' => t('Content type'),
53 '#options' => node_get_types('names'),
54 '#required' => TRUE,
55 '#default_value' => $page->options['content-type'],
56 '#weight' => 2,
57 );
58 if (!isset($page->options['cancel'])) {
59 //we default to show the cancel button on add node forms
60 $form['options']['cancel']['#default_value'] = t('Cancel');
61 }
62 pageroute_page::node_ui($page, $form, FALSE);
63 }
64
65 public static function help() {
66 return t('A page of this type will present a common node adding form '.
67 'of a configurable content-type. The id of the new node will be '.
68 'added as new argument to the current path, so that other pages '.
69 'like a node view page can make use of it.');
70 }
71
72 public static function info() {
73 return array('name' => t('Node adding form'));
74 }
75
76 public function get_cancel_target() {
77 return PAGEROUTE_FORWARD;
78 }
79
80 public static function form_submitted(&$form_state) {
81
82 switch ($form_state['clicked_button']['#value']) {
83 case t('Preview'):
84 $form_state['storage']['args']['submit_action'] = PAGEROUTE_CURRENT;
85 break;
86 }
87 }
88
89 protected function set_up() {
90 include_once(drupal_get_path('module', 'node') .'/node.pages.inc');
91 }
92 }

  ViewVC Help
Powered by ViewVC 1.1.2