From 5905f9ef83d7e5d50f1ce7c1b108a691c4e6cdfd Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 7 Oct 2011 14:14:27 -0300 Subject: Adding handlers code --- muamba.module | 16 ++---- muamba.views.inc | 110 ---------------------------------------- views/muamba.handlers.inc | 16 ++++++ views/muamba.views.inc | 125 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 123 deletions(-) delete mode 100644 muamba.views.inc create mode 100644 views/muamba.handlers.inc create mode 100644 views/muamba.views.inc diff --git a/muamba.module b/muamba.module index 0cfe977..ccaed41 100644 --- a/muamba.module +++ b/muamba.module @@ -271,21 +271,11 @@ function muamba_user_delete($account) { } /** - * Register View API information. This is required for your module to have - * its include files loaded; for example, when implementing - * hook_views_default_views(). - * - * @return - * An array with the following possible keys: - * - api: (required) The version of the Views API the module implements. - * - path: (optional) If includes are stored somewhere other than within - * the root module directory, specify its path here. - * - template path: (optional) A path where the module has stored it's views template files. - * When you have specificed this key views automatically uses the template files for the views. - * You can use the same naming conventions like for normal views template files. + * Implementes hook_views_data() */ function muamba_views_api() { return array( - 'api' => 3, + 'api' => 3, + 'path' => drupal_get_path('module', 'muamba') . '/views', ); } diff --git a/muamba.views.inc b/muamba.views.inc deleted file mode 100644 index c1f77a0..0000000 --- a/muamba.views.inc +++ /dev/null @@ -1,110 +0,0 @@ - 'mid', - 'title' => t('Muamba'), - 'help' => t("Muamba contains transaction data related to users and nodes"), - 'weight' => -10, - ); - - $data['muamba']['table']['join'] = array( - 'node' => array( - 'left_field' => 'nid', - 'field' => 'nid', - ), - ); - - // Transaction Id. - $data['muamba']['mid'] = array( - 'title' => t('Id'), - 'help' => t('Transaction Id'), - 'field' => array( - 'handler' => 'views_handler_field_numeric', - 'click sortable' => TRUE, - ), - 'filter' => array( - 'handler' => 'views_handler_filter_numeric', - ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - ); - - // Node ID field. - $data['muamba']['nid'] = array( - 'title' => t('Muamba node asset'), - 'help' => t('The node in a muamba transaction.'), - 'relationship' => array( - 'base' => 'node', - 'field' => 'nid', - 'handler' => 'views_handler_relationship', - 'label' => t('Muamba node'), - ), - ); - - // User ID field. - $data['muamba']['uid'] = array( - 'title' => t('Muamba requester user'), - 'help' => t('The user that initiated a transaction.'), - 'relationship' => array( - 'base' => 'users', - 'field' => 'uid', - 'handler' => 'views_handler_relationship', - 'label' => t('Muamba requester'), - ), - ); - - // User ID field. - $data['muamba']['owner'] = array( - 'title' => t('Muamba asset owner'), - 'help' => t('The user that owns an asset.'), - 'relationship' => array( - 'base' => 'users', - 'field' => 'uid', - 'handler' => 'views_handler_relationship', - 'label' => t('Muamba item owner'), - ), - ); - - // Thread ID field. - $data['muamba']['thread_id'] = array( - 'title' => t('Thread'), - 'help' => t('The transaction negotiation thread.'), - 'relationship' => array( - 'base' => 'pm_index', - 'field' => 'thread_id', - 'handler' => 'views_handler_relationship', - 'label' => t('Muamba thread'), - ), - ); - - // Transaction status. - $data['muamba']['status'] = array( - 'title' => t('Status'), - 'help' => t('Transaction status'), - 'field' => array( - 'handler' => 'views_handler_field_numeric', - 'click sortable' => TRUE, - ), - 'filter' => array( - 'handler' => 'views_handler_filter_numeric', - ), - 'sort' => array( - 'handler' => 'views_handler_sort', - ), - ); - - return $data; -} diff --git a/views/muamba.handlers.inc b/views/muamba.handlers.inc new file mode 100644 index 0000000..9c5c6b9 --- /dev/null +++ b/views/muamba.handlers.inc @@ -0,0 +1,16 @@ + 'mid', + 'title' => t('Muamba'), + 'help' => t("Muamba contains transaction data related to users and nodes"), + 'weight' => -10, + ); + + $data['muamba']['table']['join'] = array( + 'node' => array( + 'left_field' => 'nid', + 'field' => 'nid', + ), + ); + + // Transaction Id. + $data['muamba']['mid'] = array( + 'title' => t('Id'), + 'help' => t('Transaction Id'), + 'field' => array( + 'handler' => 'views_handler_field_numeric', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_numeric', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + // Node ID field. + $data['muamba']['nid'] = array( + 'title' => t('Muamba node asset'), + 'help' => t('The node in a muamba transaction.'), + 'relationship' => array( + 'base' => 'node', + 'field' => 'nid', + 'handler' => 'views_handler_relationship', + 'label' => t('Muamba node'), + ), + ); + + // User ID field. + $data['muamba']['uid'] = array( + 'title' => t('Muamba requester user'), + 'help' => t('The user that initiated a transaction.'), + 'relationship' => array( + 'base' => 'users', + 'field' => 'uid', + 'handler' => 'views_handler_relationship', + 'label' => t('Muamba requester'), + ), + ); + + // User ID field. + $data['muamba']['owner'] = array( + 'title' => t('Muamba asset owner'), + 'help' => t('The user that owns an asset.'), + 'relationship' => array( + 'base' => 'users', + 'field' => 'uid', + 'handler' => 'views_handler_relationship', + 'label' => t('Muamba item owner'), + ), + ); + + // Thread ID field. + $data['muamba']['thread_id'] = array( + 'title' => t('Thread'), + 'help' => t('The transaction negotiation thread.'), + 'relationship' => array( + 'base' => 'pm_index', + 'field' => 'thread_id', + 'handler' => 'views_handler_relationship', + 'label' => t('Muamba thread'), + ), + ); + + // Transaction status. + $data['muamba']['status'] = array( + 'title' => t('Status'), + 'help' => t('Transaction status'), + 'field' => array( + 'handler' => 'views_handler_field_muamba_status', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_numeric', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + return $data; +} + +/** + * Implements hook_views_handlers() + */ +function muamba_views_handlers() { + $common = array( + 'parent' => 'views_handler_field', + 'file' => 'muamba.handlers.inc', + ); + return array( + 'handlers' => array( + 'views_handler_field_muamba_status' => $common, + ), + ); +} -- cgit v1.2.3