12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307 |
- <?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'),
- 'field' => array(
- 'handler' => 'modulename_handler_field_example_field',
- ),
- );
-
-
-
- $data['node']['title']['field']['handler'] = 'modulename_handler_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_field_views_data($field) {
- return array();
- }
- function hook_field_views_data_alter(&$result, $field, $module) {
- }
- function hook_field_views_data_views_data_alter(&$data, $field) {
- $field_name = $field['field_name'];
- $data_key = 'field_data_' . $field_name;
-
- }
- 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_plugin_option_definition_alter(&$options, $plugin) {
-
- $options['option_name'] = array('default' => '');
- }
- function hook_views_handler_option_definition_alter(&$options, $handler) {
-
- $options['option_name'] = array('default' => '');
- }
- 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'
- ) {
- $view->set_display('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['command'] == 'viewsScrollTop') {
- $command['command'] .= 'myScrollTop';
- }
- }
- }
- function hook_views_invalidate_cache($cid) {
- cache_clear_all('views:*', 'cache_mymodule', TRUE);
- }
- function hook_views_view_presave($view) {
-
- if (mymodule_check_view($view)) {
- mymodule_do_some_voodoo($view);
- }
- }
- function hook_views_view_save($view) {
-
- watchdog('views', 'The view @name was deleted by @user at @time', array('@name' => $view->name, '@user' => $GLOBALS['user']->name, '@time' => format_date(time())));
- }
- function hook_views_view_delete($view) {
-
- watchdog('views', 'The view @name was deleted by @user at @time', array('@name' => $view->name, '@user' => $GLOBALS['user']->name, '@time' => format_date(time())));
- }
|