| 1 |
<?php
|
| 2 |
// $Id: ed_classified_views.inc,v 1.1.2.1.4.4 2009/08/06 10:47:37 milesgillham Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Simple text-based classified ads module.
|
| 7 |
* Autho: Michael Curry, Exodus Development, Inc. * exodusdev@gmail.com
|
| 8 |
* for more information, please visit http://exodusdev.com/drupal/modules/classified.module
|
| 9 |
*/
|
| 10 |
|
| 11 |
|
| 12 |
/* ================= views.module integration ===================== */
|
| 13 |
|
| 14 |
function ed_classified_views_handlers() {
|
| 15 |
$handlers = array(
|
| 16 |
'handlers' => array(
|
| 17 |
'ed_classified_views_time_remaining_handler_field' => array(
|
| 18 |
'parent' => 'views_handler_field_date'
|
| 19 |
)
|
| 20 |
)
|
| 21 |
);
|
| 22 |
return $handlers;
|
| 23 |
}
|
| 24 |
|
| 25 |
/*
|
| 26 |
* Implements hook_views_data()
|
| 27 |
* No need to make it a base, doesn't have sufficient first class data
|
| 28 |
* as yet, really just dependent upon Node.
|
| 29 |
*/
|
| 30 |
|
| 31 |
function ed_classified_views_data() {
|
| 32 |
module_load_include('inc', 'ed_classified', 'ed_classified_utils');
|
| 33 |
|
| 34 |
$parms = _ed_classified_displayname_parms();
|
| 35 |
$parms['!modulename'] = EDI_CLASSIFIED_MODULE_NAME;
|
| 36 |
$data = array();
|
| 37 |
// All classified ads are in a single table group
|
| 38 |
$data['edi_classified_nodes']['table']['group'] = t('Classified Ads');
|
| 39 |
// Everything else is in a Node
|
| 40 |
$data['edi_classified_nodes']['table']['join'] = array(
|
| 41 |
// Tell Views that we can join with node (on vid just to get current
|
| 42 |
// revision.)
|
| 43 |
'node' => array(
|
| 44 |
'left_field' => 'vid',
|
| 45 |
'field' => 'vid'
|
| 46 |
)
|
| 47 |
);
|
| 48 |
// 'expires_on'
|
| 49 |
$data['edi_classified_nodes']['expires_on'] = array(
|
| 50 |
'title' => t('Expires On'),
|
| 51 |
// The help that appears on the UI
|
| 52 |
'help' => t('Classified ad expiry date.'),
|
| 53 |
// Information for displaying
|
| 54 |
'field' => array(
|
| 55 |
'handler' => 'views_handler_field_date',
|
| 56 |
'click sortable' => TRUE
|
| 57 |
),
|
| 58 |
// Information for accepting as an argument
|
| 59 |
'argument' => array(
|
| 60 |
'handler' => 'views_handler_argument_date',
|
| 61 |
'name field' => 'title',
|
| 62 |
'numeric' => TRUE,
|
| 63 |
),
|
| 64 |
// Information for accepting as a filter
|
| 65 |
'filter' => array(
|
| 66 |
'handler' => 'views_handler_filter_date'
|
| 67 |
),
|
| 68 |
// Information for sorting
|
| 69 |
'sort' => array(
|
| 70 |
'handler' => 'views_handler_sort_date'
|
| 71 |
)
|
| 72 |
);
|
| 73 |
// 'expiry_remaining' time remaining is an alias of 'expires_on'
|
| 74 |
// but displayed differently
|
| 75 |
$data['edi_classified_nodes']['expiry_remaining'] = array(
|
| 76 |
'real field' => 'expires_on',
|
| 77 |
'title' => t('Expiry time remaining'),
|
| 78 |
// The help that appears on the UI
|
| 79 |
'help' => t('Time remaining until expiry.'),
|
| 80 |
// Information for displaying
|
| 81 |
'field' => array(
|
| 82 |
'handler' => 'ed_classified_views_time_remaining_handler_field',
|
| 83 |
'click sortable' => TRUE
|
| 84 |
),
|
| 85 |
// Information for accepting as an argument
|
| 86 |
'argument' => array(
|
| 87 |
'handler' => 'views_handler_argument_date',
|
| 88 |
'name field' => 'title',
|
| 89 |
'numeric' => TRUE,
|
| 90 |
),
|
| 91 |
// Information for accepting as a filter
|
| 92 |
'filter' => array(
|
| 93 |
'handler' => 'views_handler_filter_date'
|
| 94 |
),
|
| 95 |
// Information for sorting
|
| 96 |
'sort' => array(
|
| 97 |
'handler' => 'views_handler_sort_date'
|
| 98 |
)
|
| 99 |
);
|
| 100 |
return $data;
|
| 101 |
}
|
| 102 |
|
| 103 |
|
| 104 |
/* ================= views.module integration END ===================== */
|