tripal_stock.views.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal stock tables. Supplementary functions can be found in
  6. * ./views/
  7. *
  8. * Documentation on views integration can be found at
  9. * http://views2.logrus.com/doc/html/index.html.
  10. */
  11. /**
  12. * @defgroup tripal_stock_views Stock Views Integration
  13. * @ingroup views
  14. * @ingroup tripal_stock
  15. */
  16. /**
  17. * Implements hook_views_data(): Describe chado/tripal tables & fields to views
  18. *
  19. * @return array
  20. * A data array which follows the structure outlined in the
  21. * views2 documentation for this hook. Essentially, it's an array of table
  22. * definitions keyed by chado/tripal table name. Each table definition
  23. * includes basic details about the table, fields in that table and
  24. * relationships between that table and others (joins)
  25. *
  26. * @ingroup tripal_stock_views
  27. */
  28. function tripal_stock_views_data() {
  29. $data = array();
  30. if (module_exists('tripal_views')) {
  31. $tablename = 'stock';
  32. $priority = 9;
  33. // check to see if the table is integrated. If it is then integrate it's
  34. // corresponding 'chado_[table]' table.
  35. if (!tripal_views_is_integrated($tablename, $priority)) {
  36. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
  37. // Add in node relationships if chado is in the same db as drupal
  38. if (tripal_core_chado_schema_exists()) {
  39. $integrations = tripal_views_add_node_relationship_to_chado_table_integration($table_integration_array);
  40. foreach ($integrations as $integration) {
  41. tripal_views_integration_add_entry($integration);
  42. }
  43. }
  44. else {
  45. tripal_views_integration_add_entry($table_integration_array);
  46. }
  47. }
  48. $tablename = 'stockcollection';
  49. $priority = 9;
  50. if (!tripal_views_is_integrated($tablename, $priority)) {
  51. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
  52. tripal_views_integration_add_entry($table_integration_array);
  53. }
  54. $tables = array(
  55. 'stock_cvterm',
  56. 'stock_dbxref',
  57. 'stock_genotype',
  58. 'stock_pub',
  59. 'stock_relationship',
  60. 'stock_relationship_pub',
  61. 'stockcollection_stock',
  62. 'stockcollectionprop',
  63. 'stockprop',
  64. 'stockprop_pub'
  65. );
  66. foreach ($tables as $tablename) {
  67. $priority = 9;
  68. if (!tripal_views_is_integrated($tablename, $priority)) {
  69. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
  70. tripal_views_integration_add_entry($table_integration_array);
  71. }
  72. }
  73. }
  74. return $data;
  75. }
  76. /**
  77. * Implements hook_views_handlers()
  78. *
  79. * Purpose: Register all custom handlers with views
  80. * where a handler describes either "the type of field",
  81. * "how a field should be filtered", "how a field should be sorted"
  82. *
  83. * @return array
  84. * An array of handler definitions
  85. *
  86. * @ingroup tripal_stock_views
  87. */
  88. function tripal_stock_views_handlers() {
  89. return array(
  90. 'info' => array(
  91. 'path' => drupal_get_path('module', 'tripal_stock') . '/views/handlers',
  92. ),
  93. 'handlers' => array(
  94. 'views_handler_field_computed_stock_nid' => array(
  95. 'parent' => 'views_handler_field_numeric',
  96. ),
  97. 'views_handler_field_stockprop_by_type' => array(
  98. 'parent' => 'views_handler_field_prerender_list',
  99. ),
  100. 'views_handler_field_stockprop_all' => array(
  101. 'parent' => 'views_handler_field_prerender_list',
  102. ),
  103. 'views_handler_field_stockrel_by_type' => array(
  104. 'parent' => 'views_handler_field_prerender_list',
  105. ),
  106. 'views_handler_field_stockrel_all' => array(
  107. 'parent' => 'views_handler_field_prerender_list',
  108. ),
  109. 'views_handler_field_stock_dbxref_by_type' => array(
  110. 'parent' => 'views_handler_field_prerender_list',
  111. ),
  112. 'views_handler_field_stock_dbxref_all' => array(
  113. 'parent' => 'views_handler_field_prerender_list',
  114. ),
  115. 'views_handler_filter_stockprop_id' => array(
  116. 'parent' => 'views_handler_filter',
  117. ),
  118. 'views_handler_filter_stock_dbxref_id' => array(
  119. 'parent' => 'views_handler_filter',
  120. ),
  121. 'views_handler_filter_stock_relationship_id' => array(
  122. 'parent' => 'views_handler_filter',
  123. ),
  124. 'views_handler_argument_stockprop_id' => array(
  125. 'parent' => 'views_handler_argument_string',
  126. ),
  127. ),
  128. );
  129. }
  130. /**
  131. * Implementation of hook_views_data_alter().
  132. */
  133. function tripal_stock_views_data_alter(&$data) {
  134. if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
  135. // Add featuer relationship to node
  136. $data['node']['stock_chado_nid'] = array(
  137. 'group' => 'Stock',
  138. 'title' => 'Stock Node',
  139. 'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
  140. 'real field' => 'nid',
  141. 'relationship' => array(
  142. 'handler' => 'views_handler_relationship',
  143. 'title' => t('Node => Chado'),
  144. 'label' => t('Node => Chado'),
  145. 'real field' => 'nid',
  146. 'base' => 'chado_stock',
  147. 'base field' => 'nid'
  148. ),
  149. );
  150. }
  151. }
  152. /**
  153. * Implements hook_views_pre_render
  154. *
  155. * Purpose: Intercepts the view after the query has been executed
  156. * All the results are stored in $view->result
  157. * Looking up the NID here ensures the query is only executed once
  158. * for all stocks in the table.
  159. *
  160. * @todo add if !<chado/drupal same db> around NID portion
  161. *
  162. * @ingroup tripal_stock_views
  163. */
  164. function tripal_stock_views_pre_render (&$view) {
  165. if (preg_match('/stock/', $view->base_table)) {
  166. //-----Node IDs---------------------------------------------
  167. // @see tripal_core.views.inc, tripal_core_add_node_ids_to_view()
  168. // retrieve the stock_id for each record in the views current page
  169. $stock_ids = array();
  170. foreach ($view->result as $row_num => $row) {
  171. $stock_ids[$row_num] = $row->stock_id;
  172. }
  173. if (sizeof($stock_ids)) {
  174. //-----Properties------------------------------------------
  175. $field_names = array_keys($view->field);
  176. //if any property fields are in the current view
  177. $property_field_names = preg_grep('/properties/', $field_names);
  178. if (!empty($property_field_names)) {
  179. $sql = "SELECT stockprop.*, cvterm.name as type_name FROM {stockprop} "
  180. ."INNER JOIN cvterm cvterm ON stockprop.type_id=cvterm.cvterm_id "
  181. ."WHERE stockprop.stock_id IN (" . implode(',', $stock_ids) . ")";
  182. $previous_db = tripal_db_set_active('chado');
  183. $resource = db_query($sql);
  184. tripal_db_set_active($previous_db);
  185. $view->result[$key]->properties = array();
  186. while ($r = db_fetch_object($resource)) {
  187. $key = array_search($r->stock_id, $stock_ids);
  188. $view->result[$key]->properties[] = $r;
  189. }
  190. }
  191. //-----Relationships----------------------------------------
  192. //if any relationship fields are in the current view
  193. $relationship_field_names = preg_grep('/relationships/', $field_names);
  194. if (!empty($relationship_field_names)) {
  195. $sql = "SELECT stock_relationship.*, cvterm.name as type_name, "
  196. ."subject_stock.name as subject_name, object_stock.name as object_name "
  197. ."FROM stock_relationship "
  198. ."LEFT JOIN stock subject_stock ON stock_relationship.subject_id=subject_stock.stock_id "
  199. ."LEFT JOIN stock object_stock ON stock_relationship.object_id=object_stock.stock_id "
  200. ."LEFT JOIN cvterm cvterm ON stock_relationship.type_id = cvterm.cvterm_id "
  201. ."WHERE stock_relationship.subject_id IN (" . implode(',', $stock_ids) . ") "
  202. ."OR stock_relationship.object_id IN (" . implode(',', $stock_ids) . ") ";
  203. $previous_db = tripal_db_set_active('chado');
  204. $resource = db_query($sql);
  205. tripal_db_set_active($previous_db);
  206. while ($r = db_fetch_object($resource)) {
  207. if (in_array($r->subject_id, $stock_ids)) {
  208. $key = array_search($r->subject_id, $stock_ids);
  209. $r->stock_id = $r->subject_id;
  210. $view->result[$key]->relationships[] = clone $r;
  211. }
  212. if (in_array($r->object_id, $stock_ids)) {
  213. $key = array_search($r->object_id, $stock_ids);
  214. $r->stock_id = $r->object_id;
  215. $view->result[$key]->relationships[] = clone $r;
  216. }
  217. }
  218. }
  219. //-----DB References--------------------------------------------
  220. //if any dbxref fields are in the current view
  221. $dbxref_field_names = preg_grep('/dbxref/', $field_names);
  222. if (!empty($dbxref_field_names)) {
  223. $sql = "SELECT stock_dbxref.*, dbxref.db_id, db.name as db_name, db.urlprefix, "
  224. ."dbxref.accession, dbxref.version, dbxref.description "
  225. ."FROM stock_dbxref "
  226. ."LEFT JOIN dbxref dbxref ON stock_dbxref.dbxref_id=dbxref.dbxref_id "
  227. ."LEFT JOIN db db ON dbxref.db_id=db.db_id "
  228. ."WHERE stock_dbxref.stock_id IN (" . implode(',', $stock_ids) . ")";
  229. $previous_db = tripal_db_set_active('chado');
  230. $resource = db_query($sql);
  231. tripal_db_set_active($previous_db);
  232. $view->result[$key]->dbxref = array();
  233. while ($r = db_fetch_object($resource)) {
  234. $key = array_search($r->stock_id, $stock_ids);
  235. $view->result[$key]->dbxref[] = $r;
  236. }
  237. }
  238. } //if there are stocks
  239. } //if we're dealing with a stock view
  240. }
  241. /**
  242. *
  243. * @ingroup tripal_stock_views
  244. */
  245. function tripal_stock_views_default_views() {
  246. $views = array();
  247. if (!module_exists('tripal_views')) {
  248. return $views;
  249. }
  250. // Main default view
  251. $view = new view;
  252. $view->name = 'stock_listing';
  253. $view->description = 'This view lists all stocks by default.';
  254. $view->tag = 'chado default';
  255. $view->base_table = 'stock';
  256. $view->core = 0;
  257. $view->api_version = '2';
  258. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  259. $handler = $view->new_display('default', 'Defaults', 'default');
  260. $handler->override_option('fields', array(
  261. 'uniquename' => array(
  262. 'label' => 'Unique Name',
  263. 'alter' => array(
  264. 'alter_text' => 0,
  265. 'text' => '',
  266. 'make_link' => 0,
  267. 'path' => '',
  268. 'link_class' => '',
  269. 'alt' => '',
  270. 'prefix' => '',
  271. 'suffix' => '',
  272. 'target' => '',
  273. 'help' => '',
  274. 'trim' => 0,
  275. 'max_length' => '',
  276. 'word_boundary' => 1,
  277. 'ellipsis' => 1,
  278. 'html' => 0,
  279. 'strip_tags' => 0,
  280. ),
  281. 'empty' => '',
  282. 'hide_empty' => 0,
  283. 'empty_zero' => 0,
  284. 'link_to_node' => 1,
  285. 'exclude' => 0,
  286. 'id' => 'uniquename',
  287. 'table' => 'stock',
  288. 'field' => 'uniquename',
  289. 'relationship' => 'none',
  290. ),
  291. 'name_2' => array(
  292. 'label' => 'Name',
  293. 'alter' => array(
  294. 'alter_text' => 0,
  295. 'text' => '',
  296. 'make_link' => 0,
  297. 'path' => '',
  298. 'link_class' => '',
  299. 'alt' => '',
  300. 'prefix' => '',
  301. 'suffix' => '',
  302. 'target' => '',
  303. 'help' => '',
  304. 'trim' => 0,
  305. 'max_length' => '',
  306. 'word_boundary' => 1,
  307. 'ellipsis' => 1,
  308. 'html' => 0,
  309. 'strip_tags' => 0,
  310. ),
  311. 'empty' => '',
  312. 'hide_empty' => 0,
  313. 'empty_zero' => 0,
  314. 'link_to_node' => 1,
  315. 'exclude' => 0,
  316. 'id' => 'name_2',
  317. 'table' => 'stock',
  318. 'field' => 'name',
  319. 'relationship' => 'none',
  320. ),
  321. 'name' => array(
  322. 'label' => 'Type',
  323. 'alter' => array(
  324. 'alter_text' => 0,
  325. 'text' => '',
  326. 'make_link' => 0,
  327. 'path' => '',
  328. 'link_class' => '',
  329. 'alt' => '',
  330. 'prefix' => '',
  331. 'suffix' => '',
  332. 'target' => '',
  333. 'help' => '',
  334. 'trim' => 0,
  335. 'max_length' => '',
  336. 'word_boundary' => 1,
  337. 'ellipsis' => 1,
  338. 'html' => 0,
  339. 'strip_tags' => 0,
  340. ),
  341. 'empty' => '',
  342. 'hide_empty' => 0,
  343. 'empty_zero' => 0,
  344. 'exclude' => 0,
  345. 'id' => 'name',
  346. 'table' => 'cvterm',
  347. 'field' => 'name',
  348. 'relationship' => 'none',
  349. ),
  350. 'common_name' => array(
  351. 'label' => 'Organism',
  352. 'alter' => array(
  353. 'alter_text' => 0,
  354. 'text' => '',
  355. 'make_link' => 0,
  356. 'path' => '',
  357. 'link_class' => '',
  358. 'alt' => '',
  359. 'prefix' => '',
  360. 'suffix' => '',
  361. 'target' => '',
  362. 'help' => '',
  363. 'trim' => 0,
  364. 'max_length' => '',
  365. 'word_boundary' => 1,
  366. 'ellipsis' => 1,
  367. 'html' => 0,
  368. 'strip_tags' => 0,
  369. ),
  370. 'empty' => '',
  371. 'hide_empty' => 0,
  372. 'empty_zero' => 0,
  373. 'link_to_node' => 1,
  374. 'exclude' => 0,
  375. 'id' => 'common_name',
  376. 'table' => 'organism',
  377. 'field' => 'common_name',
  378. 'relationship' => 'none',
  379. ),
  380. ));
  381. $handler->override_option('sorts', array(
  382. 'common_name' => array(
  383. 'order' => 'ASC',
  384. 'id' => 'common_name',
  385. 'table' => 'organism',
  386. 'field' => 'common_name',
  387. 'relationship' => 'none',
  388. ),
  389. 'uniquename' => array(
  390. 'order' => 'ASC',
  391. 'id' => 'uniquename',
  392. 'table' => 'stock',
  393. 'field' => 'uniquename',
  394. 'relationship' => 'none',
  395. ),
  396. ));
  397. $handler->override_option('filters', array(
  398. 'common_name' => array(
  399. 'operator' => '=',
  400. 'value' => array(),
  401. 'group' => '0',
  402. 'exposed' => TRUE,
  403. 'expose' => array(
  404. 'use_operator' => 0,
  405. 'operator' => 'common_name_op',
  406. 'identifier' => 'organism_common_name',
  407. 'label' => 'Organism',
  408. 'remember' => 0,
  409. ),
  410. 'case' => 1,
  411. 'id' => 'common_name',
  412. 'table' => 'organism',
  413. 'field' => 'common_name',
  414. 'relationship' => 'none',
  415. 'values_form_type' => 'select',
  416. 'multiple' => 1,
  417. 'optional' => 0,
  418. 'agg' => array(
  419. 'records_with' => 1,
  420. 'aggregates_with' => 1,
  421. ),
  422. ),
  423. 'search_results' => array(
  424. 'operator' => '=',
  425. 'value' => '',
  426. 'group' => '0',
  427. 'exposed' => FALSE,
  428. 'expose' => array(
  429. 'operator' => FALSE,
  430. 'label' => '',
  431. ),
  432. 'id' => 'search_results',
  433. 'table' => 'views',
  434. 'field' => 'search_results',
  435. 'relationship' => 'none',
  436. 'apply_button' => 'Show',
  437. 'no_results_text' => 'Click "Show" to see a list of all stocks matching the entered criteria. If you leave a any of the criteria blank then the stocks will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all stocks will be listed.',
  438. ),
  439. 'type_id' => array(
  440. 'operator' => '=',
  441. 'value' => '',
  442. 'group' => '0',
  443. 'exposed' => TRUE,
  444. 'expose' => array(
  445. 'use_operator' => 0,
  446. 'operator' => 'type_id_op',
  447. 'identifier' => 'type_id',
  448. 'label' => 'Type',
  449. 'remember' => 0,
  450. ),
  451. 'case' => 1,
  452. 'id' => 'type_id',
  453. 'table' => 'stock',
  454. 'field' => 'type_id',
  455. 'relationship' => 'none',
  456. 'values_form_type' => 'select',
  457. 'multiple' => 1,
  458. 'optional' => 0,
  459. 'show_all' => 0,
  460. 'agg' => array(
  461. 'records_with' => 1,
  462. 'aggregates_with' => 1,
  463. ),
  464. ),
  465. 'name' => array(
  466. 'operator' => 'contains',
  467. 'value' => '',
  468. 'group' => '0',
  469. 'exposed' => TRUE,
  470. 'expose' => array(
  471. 'use_operator' => 0,
  472. 'operator' => 'name_op',
  473. 'identifier' => 'name',
  474. 'label' => 'Name Contains',
  475. 'remember' => 0,
  476. ),
  477. 'case' => 0,
  478. 'id' => 'name',
  479. 'table' => 'stock',
  480. 'field' => 'name',
  481. 'relationship' => 'none',
  482. 'agg' => array(
  483. 'records_with' => 1,
  484. 'aggregates_with' => 1,
  485. ),
  486. ),
  487. ));
  488. $handler->override_option('access', array(
  489. 'type' => 'perm',
  490. 'perm' => 'access chado_stock content',
  491. ));
  492. $handler->override_option('cache', array(
  493. 'type' => 'none',
  494. ));
  495. $handler->override_option('title', 'Stocks');
  496. $handler->override_option('header', 'Click "Show" to see a list of all stocks matching the entered criteria. If you leave a any of the criteria blank then the stocks will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all stocks will be listed.');
  497. $handler->override_option('header_format', '2');
  498. $handler->override_option('header_empty', 0);
  499. $handler->override_option('empty', 'No stocks match the supplied criteria.');
  500. $handler->override_option('empty_format', '1');
  501. $handler->override_option('items_per_page', 50);
  502. $handler->override_option('use_pager', '1');
  503. $handler->override_option('style_plugin', 'table');
  504. $handler->override_option('style_options', array(
  505. 'grouping' => '',
  506. 'override' => 1,
  507. 'sticky' => 0,
  508. 'order' => 'asc',
  509. 'columns' => array(
  510. 'uniquename' => 'uniquename',
  511. 'name_2' => 'name_2',
  512. 'name' => 'name',
  513. 'common_name' => 'common_name',
  514. 'all_dbxref' => 'all_dbxref',
  515. 'all_properties' => 'all_properties',
  516. 'all_relationships' => 'all_relationships',
  517. ),
  518. 'info' => array(
  519. 'uniquename' => array(
  520. 'sortable' => 1,
  521. 'separator' => '',
  522. ),
  523. 'name_2' => array(
  524. 'sortable' => 1,
  525. 'separator' => '',
  526. ),
  527. 'name' => array(
  528. 'sortable' => 1,
  529. 'separator' => '',
  530. ),
  531. 'common_name' => array(
  532. 'sortable' => 1,
  533. 'separator' => '',
  534. ),
  535. 'all_dbxref' => array(
  536. 'separator' => '',
  537. ),
  538. 'all_properties' => array(
  539. 'separator' => '',
  540. ),
  541. 'all_relationships' => array(
  542. 'separator' => '',
  543. ),
  544. ),
  545. 'default' => '-1',
  546. ));
  547. $default_handler = $handler;
  548. $handler = $view->new_display('page', 'Page', 'page_1');
  549. $handler->override_option('path', 'chado/stocks');
  550. $handler->override_option('menu', array(
  551. 'type' => 'normal',
  552. 'title' => 'Stocks',
  553. 'description' => 'A stock is the physical entities, either living or preserved, held by collections and can be globally identified by the combination of organism, uniquename and stock type.',
  554. 'weight' => '10',
  555. 'name' => 'navigation',
  556. ));
  557. $handler->override_option('tab_options', array(
  558. 'type' => 'none',
  559. 'title' => '',
  560. 'description' => '',
  561. 'weight' => 0,
  562. 'name' => 'navigation',
  563. ));
  564. // Add code specific to a local chado installation
  565. // NOTE: Edit $handler above to $default_handler for the default display
  566. if (tripal_core_chado_schema_exists()) {
  567. // Add nid field
  568. $fields = $view->get_items('field', 'default');
  569. $new_fields = array(
  570. 'nid' => array(
  571. 'label' => 'Nid',
  572. 'alter' => array(
  573. 'alter_text' => 0,
  574. 'text' => '',
  575. 'make_link' => 0,
  576. 'path' => '',
  577. 'absolute' => 0,
  578. 'link_class' => '',
  579. 'alt' => '',
  580. 'rel' => '',
  581. 'prefix' => '',
  582. 'suffix' => '',
  583. 'target' => '',
  584. 'help' => '',
  585. 'trim' => 0,
  586. 'max_length' => '',
  587. 'word_boundary' => 1,
  588. 'ellipsis' => 1,
  589. 'html' => 0,
  590. 'strip_tags' => 0,
  591. ),
  592. 'empty' => '',
  593. 'hide_empty' => 0,
  594. 'empty_zero' => 0,
  595. 'hide_alter_empty' => 1,
  596. 'link_to_node' => 0,
  597. 'exclude' => 1,
  598. 'id' => 'nid',
  599. 'table' => 'node',
  600. 'field' => 'nid',
  601. 'relationship' => 'none',
  602. )
  603. );
  604. $fields = $new_fields + $fields;
  605. // Change analysis.name to have a link to the node
  606. $fields['name_2']['alter']['make_link'] = 1;
  607. $fields['name_2']['alter']['path'] = 'node/[nid]';
  608. $default_handler->override_option('fields', $fields);
  609. // Adds stock => Node relationship
  610. $default_handler->override_option('relationships', array(
  611. 'nid' => array(
  612. 'label' => 'Stock to Node',
  613. 'required' => 0,
  614. 'id' => 'nid',
  615. 'table' => 'chado_stock',
  616. 'field' => 'nid',
  617. 'relationship' => 'none',
  618. ),
  619. ));
  620. // Only show records with published nodes
  621. $filters = $view->get_items('filter', 'default');
  622. $filters['status'] = array(
  623. 'operator' => '=',
  624. 'value' => '1',
  625. 'group' => '0',
  626. 'exposed' => FALSE,
  627. 'expose' => array(
  628. 'operator' => FALSE,
  629. 'label' => '',
  630. ),
  631. 'id' => 'status',
  632. 'table' => 'node',
  633. 'field' => 'status',
  634. 'relationship' => 'none',
  635. );
  636. $default_handler->override_option('filters', $filters);
  637. }
  638. $views[$view->name] = $view;
  639. return $views;
  640. }