123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- $pub = $variables['node']->pub;
- $stocks = array();
- $element = 5;
- $num_per_page = 25;
- $options = array(
- 'return_array' => 1,
- 'pager' => array(
- 'limit' => $num_per_page,
- 'element' => $element
- ),
- );
- $pub = chado_expand_var($pub, 'table', 'stock_pub', $options);
- $stock_pubs = $pub->stock_pub;
- if (count($stock_pubs) > 0 ) {
- foreach ($stock_pubs as $stock_pub) {
- $stocks[] = $stock_pub->stock_id;
- }
- }
- $total_records = chado_pager_get_count($element);
- if(count($stocks) > 0){ ?>
- <div class="tripal_pub-data-block-desc tripal-data-block-desc">This publication contains information about <?php print number_format($total_records) ?> stocks:</div> <?php
- // the $headers array is an array of fields to use as the colum headers.
- // additional documentation can be found here
- // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
- $headers = array('Stock Name', 'Uniquenaem', 'Type');
- // the $rows array contains an array of rows where each row is an array
- // of values for each column of the table in that row. Additional documentation
- // can be found here:
- // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
- $rows = array();
- foreach ($stocks as $stock){
- $stock_name = $stock->name;
- if (property_exists($stock, 'nid')) {
- $stock_name = l($stock_name, 'node/' . $stock->nid, array('attributes' => array('target' => '_blank')));
- }
- $rows[] = array(
- $stock_name,
- $stock->uniquename,
- $stock->type_id->name,
- );
- }
-
-
-
-
- $table = array(
- 'header' => $headers,
- 'rows' => $rows,
- 'attributes' => array(
- 'id' => 'tripal_pub-table-stocks',
- 'class' => 'tripal-data-table'
- ),
- 'sticky' => FALSE,
- 'caption' => '',
- 'colgroups' => array(),
- 'empty' => '',
- );
-
-
- print theme_table($table);
-
-
-
-
-
-
- $pager = array(
- 'tags' => array(),
- 'element' => $element,
- 'parameters' => array(
- 'block' => 'stocks'
- ),
- 'quantity' => $num_per_page,
- );
- print theme_pager($pager);
- }
|