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

Contents of /contributions/modules/pageroute/pageroute.page.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, 1 week 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 base type
7 */
8
9 abstract class pageroute_page {
10 var $title;
11 var $options;
12 var $route;
13 var $name;
14 var $weight;
15
16 abstract public function get_form(&$form_state, &$args);
17 abstract protected function set_up();
18
19 public function pageroute_page($page) {
20 $this->load($page);
21 }
22
23 public function load($page) {
24 $this->title = $page->title;
25 $this->options = $page->options;
26 $this->route = &$page->route;
27 $this->name = $page->name;
28 $this->type = $page->type;
29 $this->weight = $page->weight;
30 }
31
32 public function get_cancel_target() {
33 return PAGEROUTE_CURRENT;
34 }
35
36 public static function get_object($page_data) {
37 $type = $page_data->type;
38 $bases = pageroute_get_types('base');
39
40 // Include needed type!
41 include_once(drupal_get_path('module', $bases[$type]) .'/'. $bases[$type] .'.page_'. $page_data->type .'.inc');
42
43 $page_class = $bases[$type] .'_page_'. $page_data->type;
44
45 $page = new $page_class($page_data);
46
47 $page->set_up();
48
49 return $page;
50 }
51
52 /*
53 * These form fields are quite common for node forms, so page
54 * types, which are also displaying node forms can use it
55 * @param $delete Wheter the "delete checkbox" should be added
56 */
57 public static function node_ui($page, &$form, $delete = TRUE) {
58 $form['options']['preview'] = array(
59 '#type' => 'checkbox',
60 '#title' => t('Display preview button'),
61 '#default_value' => isset($page->options['preview']) ? $page->options['preview'] : 0,
62 '#weight' => 5,
63 );
64 $form['options']['submit'] = array(
65 '#type' => 'checkbox',
66 '#title' => t('Display submit button'),
67 '#default_value' => isset($page->options['submit']) ? $page->options['submit'] : 1,
68 '#weight' => 5,
69 );
70 if ($delete) {
71 $form['options']['nodelete'] = array(
72 '#type' => 'checkbox',
73 '#title' => t('Never display the delete button'),
74 '#default_value' => isset($page->options['nodelete']) ? $page->options['nodelete'] : 1,
75 '#weight' => 5,
76 );
77 }
78 }
79
80 protected function configure_form(&$form) {
81 if (isset($this->options['preview']) && !$this->options['preview']) {
82 unset($form['buttons']['preview']);
83 }
84
85 if (isset($this->options['submit']) && !$this->options['submit']) {
86 unset($form['buttons']['submit']);
87 }
88
89 if (isset($this->options['delete']) && !$this->options['delete']) {
90 unset($form['buttons']['delete']);
91 }
92 }
93
94 public static function form_submitted(&$form_state) { }
95 }

  ViewVC Help
Powered by ViewVC 1.1.2