/[drupal]/contributions/modules/family/views.inc
ViewVC logotype

Contents of /contributions/modules/family/views.inc

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


Revision 1.4 - (show annotations) (download) (as text)
Sat Dec 6 03:18:15 2008 UTC (11 months, 2 weeks ago) by pyutaros
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
File MIME type: text/x-php
#322607 by Microbe:  Ascendants and Descendants tabs appear on every node type
#326432 by Microbe:  New 6.x-1.0-beta2 instalation - warning: mysql_fetch_array()
#339263 by Microbe:  Misspelling of word "Birth" in table
#339265 by Microbe:  Marriage type fields requested, in addition to "Religious"
#331459 by Microbe:  GEDCOM data confused on import
1 <?php
2 // implementation attempt of hook_views_tables
3 function family_views_tables() {
4 $tables['family_individual'] = array(
5 'name' => 'family_individual',
6 'join' => array(
7 'left' => array(
8 'table' => 'node',
9 'field' => 'nid',
10 ),
11 'right' => array(
12 'field' => 'nid',
13 ),
14 ),
15 'fields' => array(
16 'firstname' => array(
17 'name' => t('Family Indiv: Forename'),
18 'sortable'=>TRUE,
19 'help' => t('Family individuals Forename'),
20 'handler'=>'views_handler_field_nodelink',
21 'option' => array(
22 '#type' => 'select',
23 '#options' => array(
24 'link' => 'As link',
25 'nolink' => 'Without link'
26 ),
27 ),
28 ),
29 'middlename' => array(
30 'name' => t('Family Indiv: Middlename'),
31 'sortable'=>TRUE,
32 'help' => t('Family individuals Middlename'),
33 'handler'=>'views_handler_field_nodelink',
34 'option' => array(
35 '#type' => 'select',
36 '#options' => array(
37 'link' => 'As link',
38 'nolink' => 'Without link'
39 ),
40 ),
41 ),
42 'lastname' => array(
43 'name' => t('Family Indiv: Lastname'),
44 'sortable'=>TRUE,
45 'help' => t('Family individuals Surname'),
46 'handler'=>'views_handler_field_nodelink',
47 'option' => array(
48 '#type' => 'select',
49 '#options' => array(
50 'link' => 'As link',
51 'nolink' => 'Without link'
52 ),
53 ),
54 ),
55 'gender' => array(
56 'name' => t('Family Indiv: Gender'),
57 'help' => t('Family individuals Gender'),
58 'handler'=>'views_handler_field_nodelink',
59 'option' => array(
60 '#type' => 'select',
61 '#options' => array(
62 'link' => 'As link',
63 'nolink' => 'Without link'
64 ),
65 ),
66 ),
67 'birthdate' => array(
68 'name' => t('Family Indiv: Birth date'),
69 'sortable'=>TRUE,
70 'help' => t('Family individuals Birth Date'),
71 'handler'=>'family_views_date',
72 'option' => array(
73 '#type' => 'select',
74 '#options' => array(
75 'link' => 'As link',
76 'nolink' => 'Without link'
77 ),
78 ),
79 ),
80 'deathdate' => array(
81 'name' => t('Family: Deathdate'),
82 'sortable'=>TRUE,
83 'help' => t('Family individuals Death Date'),
84 'handler'=>'family_views_date',
85 'option' => array(
86 '#type' => 'select',
87 '#options' => array(
88 'link' => 'As link',
89 'nolink' => 'Without link'
90 ),
91 ),
92 ),
93 ),
94 'filters'=>array(
95
96
97 ),
98 );
99 $tables['family_group'] = array(
100 'name' => 'family_group',
101 'join' => array(
102 'left' => array(
103 'table' => 'node',
104 'field' => 'nid',
105 ),
106 'right' => array(
107 'field' => 'nid',
108 ),
109 ),
110 'fields' => array(
111 'marr_type' => array(
112 'name' => t('Family Group: Type'),
113 'sortable'=>TRUE,
114 'help' => t('Family Group marriage type'),
115 'handler'=>'views_handler_field_nodelink',
116 'option' => array(
117 '#type' => 'select',
118 '#options' => array(
119 'link' => 'As link',
120 'nolink' => 'Without link'
121 ),
122 ),
123 ),
124 'marr_date' => array(
125 'name' => t('Family Group: Marriage Date'),
126 'sortable'=>TRUE,
127 'help' => t('Family Group marriage date'),
128 'handler'=>'views_handler_field_nodelink',
129 'option' => array(
130 '#type' => 'select',
131 '#options' => array(
132 'link' => 'As link',
133 'nolink' => 'Without link'
134 ),
135 ),
136 ),
137 'marr_plac' => array(
138 'name' => t('Family Group: Marriage Place'),
139 'sortable'=>TRUE,
140 'help' => t('Family Group marriage place'),
141 'handler'=>'family_views_location',
142 'option' => array(
143 '#type' => 'select',
144 '#options' => array(
145 'link' => 'As link',
146 'nolink' => 'Without link'
147 ),
148 ),
149 ),
150 'div_date' => array(
151 'name' => t('Family Group: Divorce date'),
152 'help' => t('Family Group divorce date'),
153 'handler'=>'views_handler_field_nodelink',
154 'option' => array(
155 '#type' => 'select',
156 '#options' => array(
157 'link' => 'As link',
158 'nolink' => 'Without link'
159 ),
160 ),
161 ),
162 'div_plac' => array(
163 'name' => t('Family Group: Divorce place'),
164 'sortable'=>TRUE,
165 'help' => t('Family Group divorce place'),
166 'handler'=>'family_views_location',
167 'option' => array(
168 '#type' => 'select',
169 '#options' => array(
170 'link' => 'As link',
171 'nolink' => 'Without link'
172 ),
173 ),
174 ),
175 'parent1' => array(
176 'name' => t('Family Group: Parent 1'),
177 'sortable'=>TRUE,
178 'help' => t('Family Group parent 1'),
179 'option' => array(
180 '#type' => 'select',
181 '#options' => array(
182 'link' => 'As link',
183 'nolink' => 'Without link'
184 ),
185 ),
186 'handler'=> 'family_views_parent',
187 ),
188 'parent2' => array(
189 'name' => t('Family Group: Parent 2'),
190 'sortable'=>TRUE,
191 'help' => t('Family Group parent 2'),
192 'option' => array(
193 '#type' => 'select',
194 '#options' => array(
195 'link' => 'As link',
196 'nolink' => 'Without link'
197 ),
198 ),
199 'handler'=> 'family_views_parent',
200 ),
201 ),
202 );
203 $tables['family_location'] = array(
204 'name' => 'family_location',
205 'join' => array(
206 'left' => array(
207 'table' => 'node',
208 'field' => 'nid',
209 ),
210 'right' => array(
211 'field' => 'nid',
212 ),
213 ),
214 'fields' => array(
215 'building' => array(
216 'name' => t('Family Location: Building'),
217 'help' => t('Family Location building'),
218 'handler'=>'views_handler_field_nodelink',
219 'option' => array(
220 '#type' => 'select',
221 '#options' => array(
222 'link' => 'As link',
223 'nolink' => 'Without link'
224 ),
225 ),
226 ),
227 'street' => array(
228 'name' => t('Family Location: Street'),
229 'help' => t('Family Location street'),
230 'handler'=>'views_handler_field_nodelink',
231 'option' => array(
232 '#type' => 'select',
233 '#options' => array(
234 'link' => 'As link',
235 'nolink' => 'Without link'
236 ),
237 ),
238 ),
239 'city' => array(
240 'name' => t('Family Location: City'),
241 'sortable'=>TRUE,
242 'help' => t('Family Location city'),
243 'handler'=>'views_handler_field_nodelink',
244 'option' => array(
245 '#type' => 'select',
246 '#options' => array(
247 'link' => 'As link',
248 'nolink' => 'Without link'
249 ),
250 ),
251 ),
252 'county' => array(
253 'name' => t('Family Location: County'),
254 'help' => t('Family Location county'),
255 'sortable'=>TRUE,
256 'handler'=>'views_handler_field_nodelink',
257 'option' => array(
258 '#type' => 'select',
259 '#options' => array(
260 'link' => 'As link',
261 'nolink' => 'Without link'
262 ),
263 ),
264 ),
265 'state_province' => array(
266 'name' => t('Family Location: State/Province'),
267 'sortable'=>TRUE,
268 'handler'=>'views_handler_field_nodelink',
269
270 'help' => t('Family Location state or province'),
271 'option' => array(
272 '#type' => 'select',
273 '#options' => array(
274 'link' => 'As link',
275 'nolink' => 'Without link'
276 ),
277 ),
278 ),
279 'country' => array(
280 'name' => t('Family Location: Country'),
281 'sortable'=>TRUE,
282 'handler'=>'views_handler_field_nodelink',
283 'help' => t('Family Location country'),
284 'option' => array(
285 '#type' => 'select',
286 '#options' => array(
287 'link' => 'As link',
288 'nolink' => 'Without link'
289 ),
290 ),
291 ),
292 ),
293 );
294 return $tables;
295 }
296 function family_views_location($fieldinfo, $fielddata, $value, $data){
297 $value = family_make_location($value, FALSE);
298 if ($fielddata['options'] == 'nolink') {
299 return check_plain($value);
300 }
301 return l($value, "node/$data->nid");
302 }
303 function family_views_parent($fieldinfo, $fielddata, $value, $data){
304
305 $value= family_make_name($value, FALSE, FALSE);
306 if ($fielddata['options'] == 'nolink') {
307 return check_plain($value);
308 }
309 return l($value, "node/$data->nid");
310 }
311 function family_views_date($fieldinfo, $fielddata, $value, $data){
312
313 $value= family_check_date($value,$data->nid);
314 if ($fielddata['options'] == 'nolink') {
315 return check_plain($value);
316 }
317 return l($value, "node/$data->nid");
318 }
319 function family_views_default_views() {
320
321 // list individuals
322 $view = new stdClass();
323 $view->name = 'list_indi';
324 $view->description = 'List of all individuals';
325 $view->access = array ('' );
326 $view->view_args_php = '';
327 $view->page = TRUE;
328 $view->page_title = 'Individuals List';
329 $view->page_header = '';
330 $view->page_header_format = '2';
331 $view->page_footer = '';
332 $view->page_footer_format = '2';
333 $view->page_empty = '';
334 $view->page_empty_format = '2';
335 $view->page_type = 'table';
336 $view->url = 'family/list/indi';
337 $view->use_pager = TRUE;
338 $view->nodes_per_page = '40';
339 $view->menu = TRUE;
340 $view->menu_title = 'Family Members Index';
341 $view->menu_tab = FALSE;
342 $view->menu_tab_weight = '0';
343 $view->menu_tab_default = FALSE;
344 $view->menu_tab_default_parent = NULL;
345 $view->menu_tab_default_parent_type = 'existing';
346 $view->menu_parent_tab_weight = '0';
347 $view->menu_parent_title = 'Family';
348 $view->sort = array ( );
349 $view->argument = array ( );
350 $view->field = array (
351 array (
352 'tablename' => 'family_individual',
353 'field' => 'lastname',
354 'label' => 'Surname',
355 'sortable' => '1',
356 'defaultsort' => 'ASC',
357 'options' => 'link',
358 ),
359 array (
360 'tablename' => 'family_individual',
361 'field' => 'firstname',
362 'label' => 'Forename',
363 'sortable' => '1',
364 'options' => 'link',
365 ),
366 array (
367 'tablename' => 'family_individual',
368 'field' => 'middlename',
369 'label' => 'Middlename(s)',
370 'options' => 'link',
371 ),
372 array (
373 'tablename' => 'family_individual',
374 'field' => 'gender',
375 'label' => 'Gender',
376 'options' => 'link',
377 ),
378 array (
379 'tablename' => 'family_individual',
380 'field' => 'birthdate',
381 'label' => 'Birth Date',
382 'sortable' => '1',
383 'options' => 'link',
384 ),
385 array (
386 'tablename' => 'family_individual',
387 'field' => 'deathdate',
388 'label' => 'Death Date',
389 'sortable' => '1',
390 'options' =>
391 'link',
392 ),
393 );
394 $view->filter = array (
395 array (
396 'tablename' => 'node',
397 'field' => 'type',
398 'operator' => 'OR',
399 'options' => '',
400 'value' => array (
401 0 => 'family_individual',
402 ),
403 ),
404 );
405 $view->exposed_filter = array ( );
406 $view->requires = array(family_individual, node);
407 $views[$view->name] = $view;
408
409 //list group
410
411 $view = new stdClass(); $view->name = 'list_group'; $view->description = 'List of all groups'; $view->access = array ( ); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = 'Groups List'; $view->page_header = ''; $view->page_header_format = '2'; $view->page_footer = ''; $view->page_footer_format = '2'; $view->page_empty = ''; $view->page_empty_format = '2'; $view->page_type = 'table'; $view->url = 'family/list/group'; $view->use_pager = TRUE; $view->nodes_per_page = '40'; $view->menu = TRUE; $view->menu_title = 'Family Groups Index'; $view->menu_tab = FALSE; $view->menu_tab_weight = '0'; $view->menu_tab_default = FALSE; $view->menu_tab_default_parent = NULL; $view->menu_tab_default_parent_type = 'existing'; $view->menu_parent_tab_weight = '0'; $view->menu_parent_title = 'Family'; $view->sort = array ( ); $view->argument = array ( ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => 'Title', 'handler' => 'views_handler_field_nodelink_with_mark', 'options' => 'link', ), array ( 'tablename' => 'family_group', 'field' => 'marr_type', 'label' => 'Marriage Type', 'sortable' => '1', 'options' => 'link', ), array ( 'tablename' => 'family_group', 'field' => 'parent1', 'label' => 'Parent 1', 'sortable' => '1', 'options' => 'link', ), array ( 'tablename' => 'family_group', 'field' => 'parent2', 'label' => 'Parent 2', 'sortable' => '1', 'options' => 'link', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'family_group', ), ), ); $view->exposed_filter = array ( ); $view->requires = array(node, family_group); $views[$view->name] = $view;
412
413 //list locations
414
415 $view = new stdClass(); $view->name = 'list_loca'; $view->description = 'List of all locations'; $view->access = array ( ); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = 'Locations List'; $view->page_header = ''; $view->page_header_format = '1'; $view->page_footer = ''; $view->page_footer_format = '1'; $view->page_empty = ''; $view->page_empty_format = '1'; $view->page_type = 'table'; $view->url = 'family/list/location'; $view->use_pager = TRUE; $view->nodes_per_page = '40'; $view->menu = TRUE; $view->menu_title = 'Family Locations Index'; $view->menu_tab = FALSE; $view->menu_tab_weight = '0'; $view->menu_tab_default = FALSE; $view->menu_tab_default_parent = NULL; $view->menu_tab_default_parent_type = 'existing'; $view->menu_parent_tab_weight = '0'; $view->menu_parent_title = 'Family'; $view->sort = array ( ); $view->argument = array ( ); $view->field = array ( array ( 'tablename' => 'family_location', 'field' => 'building', 'label' => 'Builing', 'options' => 'link', ), array ( 'tablename' => 'family_location', 'field' => 'street', 'label' => 'Street', 'options' => 'link', ), array ( 'tablename' => 'family_location', 'field' => 'city', 'label' => 'City', 'sortable' => '1', 'defaultsort' => 'ASC', 'options' => 'link', ), array ( 'tablename' => 'family_location', 'field' => 'county', 'label' => 'County', 'sortable' => '1', 'options' => 'link', ), array ( 'tablename' => 'family_location', 'field' => 'state_province', 'label' => 'State/Province', 'sortable' => '1', 'options' => 'link', ), array ( 'tablename' => 'family_location', 'field' => 'country', 'label' => 'Country', 'sortable' => '1', 'options' => 'link', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'family_location', ), ), ); $view->exposed_filter = array ( ); $view->requires = array(family_location, node); $views[$view->name] = $view;
416
417
418 $view = new stdClass();
419 $view->name = 'family_latest';
420 $view->description = 'Family Content';
421 $view->access = array (
422 0 => '3',
423 1 => '1',
424 2 => '2',
425 );
426 $view->view_args_php = '';
427 $view->page = TRUE;
428 $view->page_title = 'Family Content';
429 $view->page_header = "
430 <p>
431 Welcome to the family area. Here you can view all the data on the website. In the left menu you can choose to view all individuals, groups and locations. To view a family tree, ascendancy or descendancy go to the page of the family member you want to view and click the associated tab along the top menu. If you have more information to add to this family tree you can add it by clicking 'create content' on the side menu or commenting on the page you have information to add to. If you are not sure how to do this please contact the webmaster by clicking the contact link in the menu.
432 </p>
433 <p>
434 &nbsp;
435 </p>
436 <h2>
437 Latest Updates:
438 </h2>
439 ";
440 $view->page_header_format = '1';
441 $view->page_footer = '';
442 $view->page_footer_format = '1';
443 $view->page_empty = '';
444 $view->page_empty_format = '1';
445 $view->page_type = 'table';
446 $view->url = 'family';
447 $view->use_pager = FALSE;
448 $view->nodes_per_page = '10';
449 $view->menu = TRUE;
450 $view->menu_title = 'Family';
451 $view->menu_tab = FALSE;
452 $view->menu_tab_weight = '0';
453 $view->menu_tab_default = FALSE;
454 $view->menu_tab_default_parent = NULL;
455 $view->menu_tab_default_parent_type = 'normal';
456 $view->menu_parent_tab_weight = '0';
457 $view->menu_parent_title = '';
458 $view->sort = array (
459 array (
460 'tablename' => 'node',
461 'field' => 'changed',
462 'sortorder' => 'DESC',
463 'options' => 'normal',
464 ),
465 );
466 $view->argument = array (
467 );
468 $view->field = array (
469 array (
470 'tablename' => 'node',
471 'field' => 'title',
472 'label' => 'Title',
473 'handler' => 'views_handler_field_nodelink_with_mark',
474 'options' => 'link',
475 ),
476 array (
477 'tablename' => 'node',
478 'field' => 'changed',
479 'label' => 'Last Updated',
480 'handler' => 'views_handler_field_since',
481 ),
482 array (
483 'tablename' => 'node',
484 'field' => 'type',
485 'label' => 'Type',
486 ),
487 );
488 $view->filter = array (
489 array (
490 'tablename' => 'node',
491 'field' => 'type',
492 'operator' => 'OR',
493 'options' => '',
494 'value' => array (
495 0 => 'family_individual',
496 1 => 'family_group',
497 2 => 'family_location',
498 ),
499 ),
500 array (
501 'tablename' => 'node',
502 'field' => 'status',
503 'operator' => '=',
504 'options' => '',
505 'value' => '1',
506 ),
507 );
508 $view->exposed_filter = array (
509 );
510 $view->requires = array(node);
511 $views[$view->name] = $view;
512
513 return $views;
514 }

  ViewVC Help
Powered by ViewVC 1.1.2