123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107 |
- <?php
- function hook_views_data() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $data['example_table']['table']['group'] = t('Example table');
-
-
-
-
- $data['example_table']['table']['base'] = array(
- 'field' => 'nid',
- 'title' => t('Example table'),
- 'help' => t('Example table contains example content and can be related to nodes.'),
- 'weight' => -10,
- );
-
-
-
- $data['example_table']['table']['join'] = array(
-
-
-
- 'node' => array(
- 'left_field' => 'nid',
- 'field' => 'nid',
- ),
- );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $data['example_table']['nid'] = array(
- 'title' => t('Example content'),
- 'help' => t('Some example content that references a node.'),
-
-
-
-
- 'relationship' => array(
- 'base' => 'node',
- 'base field' => 'nid',
-
- 'handler' => 'views_handler_relationship',
- 'label' => t('Default label for the relationship'),
- 'title' => t('Title shown when adding the relationship'),
- 'help' => t('More information on this relationship'),
- ),
- );
-
- $data['example_table']['plain_text_field'] = array(
- 'title' => t('Plain text field'),
- 'help' => t('Just a plain text field.'),
- 'field' => array(
- 'handler' => 'views_handler_field',
- 'click sortable' => TRUE,
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_string',
- ),
- 'argument' => array(
- 'handler' => 'views_handler_argument_string',
- ),
- );
-
- $data['example_table']['numeric_field'] = array(
- 'title' => t('Numeric field'),
- 'help' => t('Just a numeric field.'),
- 'field' => array(
- 'handler' => 'views_handler_field_numeric',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_numeric',
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
-
- $data['example_table']['boolean_field'] = array(
- 'title' => t('Boolean field'),
- 'help' => t('Just an on/off field.'),
- 'field' => array(
- 'handler' => 'views_handler_field_boolean',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_boolean_operator',
-
- 'label' => t('Published'),
-
- 'type' => 'yes-no',
-
- 'use equal' => TRUE,
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
-
- $data['example_table']['timestamp_field'] = array(
- 'title' => t('Timestamp field'),
- 'help' => t('Just a timestamp field.'),
- 'field' => array(
- 'handler' => 'views_handler_field_date',
- 'click sortable' => TRUE,
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort_date',
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_date',
- ),
- );
- return $data;
- }
- function hook_views_data_alter(&$data) {
-
- $data['node']['nid']['title'] = t('Node-Nid');
-
- $data['users']['example_field'] = array(
- 'title' => t('Example field'),
- 'help' => t('Some example content that references a user'),
- 'handler' => 'hook_handlers_field_example_field',
- );
-
-
-
- $data['node']['title']['handler'] = 'modulename_handlers_field_node_title';
-
-
-
-
- $data['foo']['dummy_name'] = array(
- 'title' => t('Example relationship'),
- 'help' => t('Example help'),
- 'relationship' => array(
- 'base' => 'example_table',
- 'base field' => 'eid',
- 'field' => 'fid',
- 'handler' => 'views_handler_relationship',
- 'label' => t('Default label for relationship'),
- 'title' => t('Title seen when adding relationship'),
- 'help' => t('More information about relationship.'),
- ),
- );
-
- }
- function hook_views_plugins() {
- $plugins = array();
- $plugins['argument validator'] = array(
- 'taxonomy_term' => array(
- 'title' => t('Taxonomy term'),
- 'handler' => 'views_plugin_argument_validate_taxonomy_term',
-
- 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
- ),
- );
- return array(
- 'module' => 'views',
- 'argument validator' => array(
- 'taxonomy_term' => array(
- 'title' => t('Taxonomy term'),
- 'handler' => 'views_plugin_argument_validate_taxonomy_term',
- 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
- ),
- ),
- 'argument default' => array(
- 'taxonomy_tid' => array(
- 'title' => t('Taxonomy term ID from URL'),
- 'handler' => 'views_plugin_argument_default_taxonomy_tid',
- 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
- 'parent' => 'fixed',
- ),
- ),
- );
- }
- function hook_views_plugins_alter(&$plugins) {
-
- $plugins['row']['node']['base'][] = 'apachesolr';
- }
- function hook_views_api() {
- return array(
- 'api' => 3,
- 'path' => drupal_get_path('module', 'example') . '/includes/views',
- 'template path' => drupal_get_path('module', 'example') . '/themes',
- );
- }
- function hook_views_default_views() {
-
- $view = new view;
- $view->name = 'frontpage';
- $view->description = 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.';
- $view->tag = 'default';
- $view->base_table = 'node';
- $view->human_name = 'Front page';
- $view->core = 0;
- $view->api_version = '3.0';
- $view->disabled = FALSE;
-
- $handler = $view->new_display('default', 'Master', 'default');
- $handler->display->display_options['access']['type'] = 'none';
- $handler->display->display_options['cache']['type'] = 'none';
- $handler->display->display_options['query']['type'] = 'views_query';
- $handler->display->display_options['query']['options']['query_comment'] = FALSE;
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'default';
- $handler->display->display_options['row_plugin'] = 'node';
-
- $handler->display->display_options['sorts']['sticky']['id'] = 'sticky';
- $handler->display->display_options['sorts']['sticky']['table'] = 'node';
- $handler->display->display_options['sorts']['sticky']['field'] = 'sticky';
- $handler->display->display_options['sorts']['sticky']['order'] = 'DESC';
-
- $handler->display->display_options['sorts']['created']['id'] = 'created';
- $handler->display->display_options['sorts']['created']['table'] = 'node';
- $handler->display->display_options['sorts']['created']['field'] = 'created';
- $handler->display->display_options['sorts']['created']['order'] = 'DESC';
-
- $handler->display->display_options['filters']['promote']['id'] = 'promote';
- $handler->display->display_options['filters']['promote']['table'] = 'node';
- $handler->display->display_options['filters']['promote']['field'] = 'promote';
- $handler->display->display_options['filters']['promote']['value'] = '1';
- $handler->display->display_options['filters']['promote']['group'] = 0;
- $handler->display->display_options['filters']['promote']['expose']['operator'] = FALSE;
-
- $handler->display->display_options['filters']['status']['id'] = 'status';
- $handler->display->display_options['filters']['status']['table'] = 'node';
- $handler->display->display_options['filters']['status']['field'] = 'status';
- $handler->display->display_options['filters']['status']['value'] = '1';
- $handler->display->display_options['filters']['status']['group'] = 0;
- $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-
- $handler = $view->new_display('page', 'Page', 'page');
- $handler->display->display_options['path'] = 'frontpage';
-
- $handler = $view->new_display('feed', 'Feed', 'feed');
- $handler->display->display_options['defaults']['title'] = FALSE;
- $handler->display->display_options['title'] = 'Front page feed';
- $handler->display->display_options['pager']['type'] = 'some';
- $handler->display->display_options['style_plugin'] = 'rss';
- $handler->display->display_options['row_plugin'] = 'node_rss';
- $handler->display->display_options['path'] = 'rss.xml';
- $handler->display->display_options['displays'] = array(
- 'default' => 'default',
- 'page' => 'page',
- );
- $handler->display->display_options['sitename_title'] = '1';
-
-
- $views[$view->name] = $view;
-
-
- return $views;
- }
- function hook_views_default_views_alter(&$views) {
- if (isset($views['taxonomy_term'])) {
- $views['taxonomy_term']->display['default']->display_options['title'] = 'Categories';
- }
- }
- function hook_views_query_substitutions($view) {
-
- global $language_content;
- return array(
- '***CURRENT_VERSION***' => VERSION,
- '***CURRENT_TIME***' => REQUEST_TIME,
- '***CURRENT_LANGUAGE***' => $language_content->language,
- '***DEFAULT_LANGUAGE***' => language_default('language'),
- );
- }
- function hook_views_form_substitutions() {
- return array(
- '<!--views-form-example-substitutions-->' => 'Example Substitution',
- );
- }
- function hook_views_pre_view(&$view, &$display_id, &$args) {
-
-
-
-
- if (
- $view->name == 'my_special_view' &&
- user_access('administer site configuration') &&
- $display_id == 'public_display'
- ) {
- $display_id = 'private_display';
- }
- }
- function hook_views_pre_build(&$view) {
-
-
-
- if (date('D') == 'Mon') {
- unset($view->attachment_before);
- unset($view->attachment_after);
- }
- }
- function hook_views_post_build(&$view) {
-
-
-
-
-
- if ($view->name == 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] != 'All') {
-
- if (isset($view->field['type'])) {
- $view->field['type']->options['exclude'] = TRUE;
- }
- }
- }
- function hook_views_pre_execute(&$view) {
-
-
-
-
- if (count($view->query->tables) > 2 && user_access('administer views')) {
- drupal_set_message(t('The view %view may be heavy to execute.', array('%view' => $view->name)), 'warning');
- }
- }
- function hook_views_post_execute(&$view) {
-
-
-
-
- if ($view->total_rows > 100) {
- drupal_set_message(t('You have more than 100 hits. Use the filter settings to narrow down your list.'));
- }
- }
- function hook_views_pre_render(&$view) {
-
-
-
- shuffle($view->result);
- }
- function hook_views_post_render(&$view, &$output, &$cache) {
-
-
- if ($view->query->pager instanceof views_plugin_pager_full && $cache->options['type'] == 'time' && count($view->result) < 10) {
- $cache['options']['results_lifespan'] = 0;
- $cache['options']['output_lifespan'] = 0;
- }
- }
- function hook_views_query_alter(&$view, &$query) {
-
-
-
- if ($view->name == 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) {
-
- foreach ($query->where as &$condition_group) {
- foreach ($condition_group['conditions'] as &$condition) {
-
-
- if ($condition['field'] == 'node.title') {
- $condition = array(
- 'field' => 'node.nid',
- 'value' => $view->exposed_raw_input['title'],
- 'operator' => '=',
- );
- }
- }
- }
- }
- }
- function hook_views_preview_info_alter(&$rows, $view) {
-
-
- $rows['query'][] = array(
- t('<strong>Table queue</strong>'),
- count($view->query->table_queue) . ': (' . implode(', ', array_keys($view->query->table_queue)) . ')',
- );
- }
- function hook_views_ui_display_top_links_alter(&$links, $view, $display_id) {
-
- if (isset($links['export'])) {
- $links = array('export' => $links['export']) + $links;
- }
- }
- function hook_views_ajax_data_alter(&$commands, $view) {
-
-
- foreach ($commands as &$command) {
- if ($command['method'] == 'viewsScrollTop') {
- $command['method'] .= 'myScrollTop';
- }
- }
- }
- function hook_views_invalidate_cache() {
- cache_clear_all('views:*', 'cache_mymodule', TRUE);
- }
|