/[drupal]/contributions/modules/simplelist/SimpleListDisplayCascade.php
ViewVC logotype

Contents of /contributions/modules/simplelist/SimpleListDisplayCascade.php

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


Revision 1.4 - (show annotations) (download) (as text)
Mon May 19 14:43:49 2008 UTC (18 months, 1 week ago) by jcfiala
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -4 lines
File MIME type: text/x-php
#260172 by jcfiala: Forgot to include changes to translated strings that go along with the new simplelist.pot.
1 <?php
2 // $Id$
3
4 require_once(drupal_get_path('module', 'simplelist') .'/SimpleListDisplayParent.php');
5
6 /**
7 * This display class takes a list of nodes, and presents them to the user in series.
8 *
9 */
10 class SimpleListDisplayCascade extends SimpleListDisplayParent {
11
12 /**
13 * The render function takes an array of nodes and presents them in series based on the simplelist data.
14 *
15 * @param stdClass $simple_list
16 * Simplelist
17 * @param array $node_array
18 * Array of node objects
19 * @return string
20 * HTML to present
21 */
22 public function render($simple_list, $node_array) {
23 $items = array();
24
25 foreach($node_array as $node) {
26 if ($simple_list->display->display_format == SIMPLELIST_FORMAT_TITLE_LINK) {
27 $items[] = l($node->title, 'node/'. $node->nid);
28 }
29 else if ($simple_list->display->display_format == SIMPLELIST_FORMAT_THEME) {
30 $items[] = theme(array("simplelist__$simple_list->name", "simplelist"), $node, $simple_list);
31 }
32 else if ($simple_list->display->display_format == SIMPLELIST_FORMAT_TEASER) {
33 if (isset($node->teaser) && isset($node->body)) {
34 $items[] = node_view($node, TRUE, FALSE, TRUE);
35 }
36 else {
37 $items[] = theme('node', $node, TRUE, FALSE);
38 }
39 }
40 else if ($simple_list->display->display_format == SIMPLELIST_FORMAT_FULL) {
41 if (isset($node->teaser) || isset($node->body)) {
42 $items[] = node_view($node, FALSE, FALSE, TRUE);
43 }
44 else {
45 $items[] = theme('node', $node, FALSE, FALSE);
46 }
47 }
48 }
49 $result_nodes = implode("\n", $items);
50 if ($simple_list->display->display_pager == 1) {
51 $result_nodes .= theme('pager', array(), $simple_list->display->display_count);
52 }
53 if ($simple_list->display->display_more_path != '') {
54 $result_nodes .= l('More', $simple_list->display->display_more_path);
55 }
56 return $result_nodes;
57 }
58
59 public static function get_display_form($simplelist, $format='block') {
60 $form = array();
61 if ($format == 'block') {
62 $form['block_display_title'] = array(
63 '#type' => 'textfield',
64 '#title' => t('Block Title'),
65 '#default_value' => $simplelist->displays['block']->display_title,
66 '#size' => 80,
67 '#maxlength' => 255,
68 '#weight' => -5,
69 );
70
71 $form['block_display_count'] = array(
72 '#type' => 'textfield',
73 '#title' => t('Block Item Count'),
74 '#default_value' => $simplelist->displays['block']->display_count,
75 '#size' => 6,
76 '#maxlength' => 3,
77 '#weight' => -3,
78 );
79
80 $form['block_display_more'] = array(
81 '#type' => 'checkbox',
82 '#title' => t('Display \'More\' link - requires page view.'),
83 '#default_value' => $simplelist->displays['block']->display_more,
84 '#weight' => -1,
85 );
86
87 $form['block_display_format'] = array(
88 '#type' => 'select',
89 '#title' => t('Node Format'),
90 '#default_value' => $simplelist->displays['block']->display_format,
91 '#options' => array(
92 SIMPLELIST_FORMAT_TEASER => t('As Teaser'),
93 SIMPLELIST_FORMAT_FULL => t('As Full Node'),
94 SIMPLELIST_FORMAT_THEME => t('As Themed'),
95 SIMPLELIST_FORMAT_TITLE_LINK => t('As Titles, linking to node'),
96 ),
97 '#multiple' => FALSE,
98 '#required' => TRUE,
99 '#description' => t('Choose how to display the nodes. If you use \'As Themed\', you should define a theme_simplelist__$name($node, $simplelist) function, where $name is the name of this simplelist.'),
100 '#weight' => 1,
101 );
102
103 $form['block_display_path'] = array(
104 '#type' => 'hidden',
105 '#title' => t('Argument Path'),
106 '#default_value' => $simplelist->displays['block']->display_path,
107 '#size' => 80,
108 '#maxlength' => 255,
109 '#weight' => 3,
110 );
111 }
112 else if ($format == 'page') {
113 $form['page_display_title'] = array(
114 '#type' => 'textfield',
115 '#title' => t('Page Title'),
116 '#default_value' => $simplelist->displays['page']->display_title,
117 '#size' => 80,
118 '#maxlength' => 255,
119 '#weight' => -7,
120 );
121
122 $form['page_display_count'] = array(
123 '#type' => 'textfield',
124 '#title' => t('Page Item Count'),
125 '#default_value' => $simplelist->displays['page']->display_count,
126 '#size' => 6,
127 '#maxlength' => 3,
128 '#weight' => -5,
129 );
130
131 $form['page_display_pager'] = array(
132 '#type' => 'checkbox',
133 '#title' => t('Display pager at bottom of page?'),
134 '#default_value' => $simplelist->displays['page']->display_pager,
135 '#weight' => -3,
136 );
137
138 $form['page_display_format'] = array(
139 '#type' => 'select',
140 '#title' => t('Node Format'),
141 '#default_value' => $simplelist->displays['page']->display_format,
142 '#options' => array(
143 SIMPLELIST_FORMAT_TEASER => t('As Teaser'),
144 SIMPLELIST_FORMAT_FULL => t('As Full Node'),
145 SIMPLELIST_FORMAT_THEME => t('As Themed'),
146 SIMPLELIST_FORMAT_TITLE_LINK => t('As Titles, linking to node'),
147 ),
148 '#multiple' => FALSE,
149 '#required' => TRUE,
150 '#description' => t('Choose how to display the nodes. If you use \'As Themed\', you should define a theme_simplelist__$name($node, $simplelist) function, where $name is the name of this simplelist.'),
151 '#weight' => -1,
152 );
153
154 $form['page_display_path'] = array(
155 '#type' => 'textfield',
156 '#title' => t('Page Path'),
157 '#default_value' => $simplelist->displays['page']->display_path,
158 '#size' => 80,
159 '#maxlength' => 255,
160 '#weight' => 1,
161 '#description' => t('Enter the path to display this page at. For arguments you can include %tid to include the termid, or %node_type to include the node type. If these are included, they\'ll override whatever term or type were assigned as a parameter. I don\'t recommend using a parameter for the first part of the path.'),
162 );
163 }
164 return $form;
165 }
166
167 public static function clear_existing_settings($slid, $form_id='', &$form_state=NULL, $format='block') {
168 // There's no existing settings that won't be overritten anyway.
169
170 }
171 }

  ViewVC Help
Powered by ViewVC 1.1.2