You are here

function epub_views_data in Epub 6

@file Tell the views module about the new epub table.

Database definition:


CREATE TABLE IF NOT EXISTS epub (
  nid int(10) unsigned NOT NULL DEFAULT '0',
  vid int(10) unsigned NOT NULL DEFAULT '0',
  bid int(10) unsigned NOT NULL DEFAULT '0',
  author_name varchar(127) DEFAULT NULL,
  language_code varchar(2) DEFAULT NULL,
  identifier text,
  identifier_type text,
  publisher_name text,
  publisher_site text,
  creation_date datetime NOT NULL,
  rights text,
  source_url text,
  PRIMARY KEY (nid,vid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

File

./epub.views.inc, line 27
Tell the views module about the new epub table.

Code

function epub_views_data() {
  $data = array();
  $data['epub']['table']['group'] = t('ePub');
  $data['epub']['table']['join'] = array(
    'node' => array(
      'left_field' => 'vid',
      'field' => 'vid',
    ),
    'book' => array(
      'left_field' => 'bid',
      'field' => 'bid',
    ),
  );

  // Relationship to the 'Node' table
  $data['epub']['nid'] = array(
    'title' => t('Node'),
    'help' => t('The particular node the ePub is attached to'),
    'relationship' => array(
      'label' => t('Node'),
      'base' => 'node',
      'base field' => 'vid',
      'skip base' => array(
        'node',
        'book',
      ),
    ),
  );

  // Relationship to the 'Book' table
  $data['epub']['bid'] = array(
    'title' => t('Book'),
    'help' => t('The particular book the ePub is attached to'),
    'relationship' => array(
      'label' => t('Book'),
      'base' => 'book',
      'base field' => 'bid',
      'skip base' => array(
        'node',
        'book',
      ),
    ),
  );

  // Author
  $data['epub']['author_name'] = array(
    'title' => t('Author'),
    'help' => t('Name of the person who has written the book.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Language code
  $data['epub']['language_code'] = array(
    'title' => t('Language'),
    'help' => t('RFC3066 Language codes, such as "en", "da", "fr", ...'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Identifier
  $data['epub']['identifier'] = array(
    'title' => t('Identifier'),
    'help' => t("The ePub' s ISBN number, preferred for published books, or a UUID."),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Identifier Type
  $data['epub']['identifier_type'] = array(
    'title' => t('Identifier type'),
    'help' => t("The ePub' s identifier type, ie: ISBN, ISSN, UUID, ..."),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Publisher' s name
  $data['epub']['publisher_name'] = array(
    'title' => t("Publisher' s name"),
    'help' => t('Name of the person or the company who is publishing the book.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Publisher' s site
  $data['epub']['publisher_site'] = array(
    'title' => t("Publisher' s site"),
    'help' => t('Site of the person or the company who is publishing the book.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Creation date
  $data['epub']['creation_date'] = array(
    'title' => t('Creation Date'),
    'help' => t('Date in which the epub has been created.'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Rights
  $data['epub']['rights'] = array(
    'title' => t('Rights'),
    'help' => t('Copyright and license information specific for the ePub.'),
    'field' => array(
      'handler' => 'views_handler_field_string',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Source URL
  $data['epub']['source_url'] = array(
    'title' => t('Source URL'),
    'help' => t('URL where you will find the ePub'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  return $data;
}