123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999 |
- <?php
- require('api/tripal_featuremap.api.inc');
- function tripal_featuremap_help($path, $arg) {
- $output = '';
- switch ($path) {
- case "admin/help#tripal_featuremap":
- $output = '<p>'.
- t("Displays links to nodes created on this date") .
- '</p>';
- break;
- }
- return $output;
- }
- function tripal_featuremap_node_info() {
- $nodes = array();
- $nodes['chado_featuremap'] = array(
- 'name' => t('Map'),
- 'module' => 'chado_featuremap',
- 'description' => t('A feature map from the chado database (e.g. genetic map)'),
- 'has_title' => FALSE,
- 'title_label' => t('Feature Map'),
- 'has_body' => FALSE,
- 'body_label' => t('Feature Map Description'),
- 'locked' => TRUE
- );
- return $nodes;
- }
- function tripal_featuremap_perm() {
- return array(
- 'access chado_featuremap content',
- 'create chado_featuremap content',
- 'delete chado_featuremap content',
- 'edit chado_featuremap content',
- );
- }
- function chado_featuremap_access($op, $node, $account) {
- if ($op == 'create') {
- if (!user_access('create chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'update') {
- if (!user_access('edit chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'delete') {
- if (!user_access('delete chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'view') {
- if (!user_access('access chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- return NULL;
- }
- function tripal_featuremap_menu() {
- $items = array();
-
- $items['admin/tripal/tripal_featuremap'] = array(
- 'title' => 'Maps',
- 'description' => 'Basic Description of Tripal Map Module Functionality',
- 'page callback' => 'tripal_featuremap_module_description_page',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/tripal_featuremap/configuration'] = array(
- 'title' => 'Configuration',
- 'description' => 'Manage integration of Chado maps including associated features.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_featuremap_admin'),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
-
- $items['chado_sync_featuremaps'] = array(
- 'title' => 'Sync Data',
- 'page callback' => 'tripal_featuremap_sync_featuremaps',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_CALLBACK
- );
-
-
- $items['featuremaps'] = array(
- 'menu_name' => ('primary-links'),
- 'title' => 'Feature Maps',
- 'page callback' => 'tripal_featuremap_show_maps',
- 'access arguments' => array('access chado_featuremap content'),
- 'type' => MENU_NORMAL_ITEM
- );
- return $items;
- }
- function tripal_featuremap_views_api() {
- return array(
- 'api' => 2.0,
- );
- }
- function tripal_featuremap_module_description_page() {
- $text = '';
- $text .= '<h3>Tripal Feature Map Administrative Tools Quick Links:</h3>';
- $text .= "<ul>
- <li><a href=\"" . url("admin/tripal/tripal_featuremap/configuration") . "\">Map Configuration</a></li>
- </ul>";
- $text .= '<h3>Module Description:</h3>';
- $text .= '<p>The Tripal Map module is an interface for the Chado Map module which groups features (sequences) into genetic maps.
- This module provides support for visualization of "map" pages, editing and updating.</p>';
- $text .= '<h3>Setup Instructions:</h3>';
- $text .= '<ol>';
- $text .= '<li><p><b>Set Permissions</b>: The map module supports the Drupal user permissions interface for
- controlling access to map content and functions. These permissions include viewing,
- creating, editing or administering of
- map content. The default is that only the original site administrator has these
- permissions. You can <a href="' . url('admin/user/roles') . '">add roles</a> for classifying users,
- <a href="' . url('admin/user/user') . '">assign users to roles</a> and
- <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the map content to
- those roles. For a simple setup, allow anonymous users access to view organism content and
- allow the site administrator all other permissions.</p></li>';
- $text .= '<li><p><b>Sync any Existing Maps</b>: Near the top of the ' . l('Map Configuration page', 'admin/tripal/tripal_featuremap/configuration') . ' there is
- a Sync Maps section which provides list of maps currently in chado which can be sync\'d.
- Simply select the maps you would like to create Drupal/Tripal pages for and click Sync Maps.</p></li>';
- $text .= '</ol>';
- $text .= '<h3>Features of this Module:</h3>';
- $text .= '<ul>';
- $text .= '<li><b>Add/Edit/Delete Maps</b>: Maps with no associated features can be created ' . l('here', 'node/add/chado-map') . ' but it is
- recommended to create the map using the feature loader. For example, when you load FASTA files using the Tripal loader you are
- given the option of specifying a map for all created features. Existing Maps (regardless of the method used to create them) can be
- edited or deleted by clicking the Edit tab at the top of the Map Page.</li>';
- $text .= '<li><p><b>Integration with Drupal Views</b>: <a href="http://drupal.org/project/views">Drupal Views</a> is
- a powerful tool that allows the site administrator to create lists or basic searching forms of Chado content.
- It provides a graphical interface within Drupal to allow the site admin to directly query the Chado database
- and create custom lists without PHP programming or customization of Tripal source code. Views can also
- be created to filter content that has not yet been synced with Druapl in order to protect access to non
- published data (only works if Chado was installed using Tripal). You can see a list of available pre-existing
- Views <a href="' . url('admin/build/views/') . '">here</a>, as well as create your own. </p></li>';
- $text .= '<li><b>Basic Listing</b>: This module provides a basic <a href="' . url('maps') . '">map display
- tool</a> for finding or listing maps in Chado. It does not require indexing for Drupal searching but relies
- on Drupal Views. <a href="http://drupal.org/project/views">Drupal Views</a> must be installed.</li>';
- $text .= '</ul>';
- $text .= '<h3>Page Customizations</h3>';
- $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
- Below is a description of several methods. These methods may be used in conjunction with one another to
- provide fine-grained control.
- <ul>
- <li><p><b>Integration with Drupal Panels</b>: <a href="http://drupal.org/project/views">Drupal Panels</a>
- allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming. Tripal comes with pre-set layouts for map pages. However,
- Panels become useful if you prefer a layout that is different from the pre-set layouts. Chado content
- is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
- Panel\'s GUI.</p></li>
- <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
- <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
- to any page without need to edit template files or knowing PHP. You must first download and install CCK.
- With CCK, the site administartor can create a new field to appear on the page. For example, currently,
- the Chado publication module is not yet supported by Tripal. Therefore, the site administrator can add a text
- field to the map pages. This content is not stored in Chado, but will appear on the map page. A field
- added by CCK will also appear in the form when editing a map to allow users to manually enter the appropriate
- text. If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
- indicate that it is not to be shown (using the CCK interface), then manually add the new content type
- where desired by editing the templates (as described below). If using Panels, the CCK field can be added to the
- location desired using the Panels interface.</p></li>
- <li><p><b>Drupal Node Templates</b>: The Tripal packages comes with a "theme_tripal" directory that contains the
- themeing for Chado content. The map module has a template file for map "nodes" (Tripal map pages). This file
- is named "node-chado_featuremap.tpl.php", and provides javascript, HTML and PHP code for display of the map
- pages. You can edit this file to control which types of information (or which map "blocks") are displayed for maps. Be sure to
- copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
- future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
- for instructions on how to access variables and other Chado content within the template file.</p></li>
- <li><p><b>Map "Block" Templates</b>: In the "theme_tripal" directory is a subdirectory named "tripal_featuremap".
- Inside this directory is a set of templates that control distinct types of information for maps. For example,
- there is a "base" template for displaying of data directly from the Chado map table. These templates are used both by Drupal blocks
- for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
- provides (also desribed above). You can customize this template as you desire. Be sure to copy the
- template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
- future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
- for instructions on how to access variables and other Chado content within the template files.</p></li>
- </li>
- <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
- will see a "Resources" sidebar on each page. The links that appear on the sidebar are automatically generated
- using Javascript for all of the map "Blocks" that appear on the page. If you want to add additional links
- (e.g. a link to a views table showing all features of the current map) and you want that link to appear in the
- "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
- section at the bottom of the template file where the resources section is found.</p></li>
- </ul>
- </p>';
- return $text;
- }
- function tripal_featuremap_admin() {
- $form = array();
-
-
-
- $active_jobs = FALSE;
- if (tripal_get_module_active_jobs('tripal_featuremap')) {
- $active_jobs = TRUE;
- }
-
- if (!$active_jobs) {
- get_tripal_featuremap_admin_form_sync_set($form);
- get_tripal_featuremap_admin_form_cleanup_set($form);
- get_tripal_featuremap_admin_form_reindex_set($form);
- get_tripal_featuremap_admin_form_taxonomy_set($form);
- get_tripal_featuremap_admin_form_cleanup_set($form);
- }
- else {
- $form['notice'] = array(
- '#type' => 'fieldset',
- '#title' => t('Feature Map Management Temporarily Unavailable')
- );
- $form['notice']['message'] = array(
- '#value' => t('Currently, feature map management jobs are waiting or are running. Managemment features have been hidden until these jobs complete. Please check back later once these jobs have finished. You can view the status of pending jobs in the Tripal jobs page.'),
- );
- }
- return system_settings_form($form);
- }
- function tripal_featuremap_nodeapi(&$node, $op, $teaser, $page) {
- switch ($op) {
-
-
- case 'view':
-
- if ($node->build_mode == NODE_BUILD_SEARCH_INDEX) {
- $node->content['tripal_featuremap_index_version'] = array(
- '#value' => theme('tripal_featuremap_search_index', $node),
- );
- }
- elseif ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
- $node->content['tripal_featuremap_index_version'] = array(
- '#value' => theme('tripal_featuremap_search_result', $node),
- );
- }
- }
- }
- function tripal_featuremap_theme() {
- return array(
- 'tripal_featuremap_search_index' => array(
- 'arguments' => array('node'),
- ),
- 'tripal_featuremap_search_result' => array(
- 'arguments' => array('node'),
- ),
- 'tripal_featuremap_base' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_featuremap_base',
- ),
- 'tripal_featuremap_properties' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_featuremap_properties',
- ),
- );
- }
- function theme_tripal_featuremap_search_index($node) {
- }
- function get_tripal_featuremap_admin_form_cleanup_set(&$form) {
- $form['cleanup'] = array(
- '#type' => 'fieldset',
- '#title' => t('Clean Up')
- );
- $form['cleanup']['description'] = array(
- '#type' => 'item',
- '#value' => t("With Drupal and chado residing in different databases ".
- "it is possible that nodes in Drupal and maps in Chado become ".
- "\"orphaned\". This can occur if an map node in Drupal is ".
- "deleted but the corresponding chado map is not and/or vice ".
- "versa. Click the button below to resolve these discrepancies."),
- '#weight' => 1,
- );
- $form['cleanup']['button'] = array(
- '#type' => 'submit',
- '#value' => t('Clean up orphaned maps'),
- '#weight' => 2,
- );
- }
- function get_tripal_featuremap_admin_form_taxonomy_set(&$form) {
- $form['taxonify'] = array(
- '#type' => 'fieldset',
- '#title' => t('Assign Drupal Taxonomy to Map Features')
- );
-
- $sql = "SELECT * FROM {featuremap} ORDER BY name";
- $previous_db = tripal_db_set_active('chado');
- $lib_rset = db_query($sql);
- tripal_db_set_active($previous_db);
-
- $lib_boxes = array();
- while ($featuremap = db_fetch_object($lib_rset)) {
- $lib_boxes[$featuremap->featuremap_id] = "$featuremap->name";
- }
- $form['taxonify']['description'] = array(
- '#type' => 'item',
- '#value' => t("Drupal allows for assignment of \"taxonomy\" or catagorical terms to " .
- "nodes. These terms allow for advanced filtering during searching. This option allows ".
- "for setting taxonomy only for features that belong to the selected maps below. All other features will be unaffected. To set taxonomy for all features in the site see the Feature Administration page."),
- '#weight' => 1,
- );
- $form['taxonify']['tx-maps'] = array(
- '#title' => t('Maps'),
- '#type' => t('checkboxes'),
- '#description' => t("Check the maps whose features you want to reset taxonomy. Note: this list contains all maps, even those that may not be synced."),
- '#required' => FALSE,
- '#prefix' => '<div id="lib_boxes">',
- '#suffix' => '</div>',
- '#options' => $lib_boxes,
- '#weight' => 2
- );
- $form['taxonify']['tx-button'] = array(
- '#type' => 'submit',
- '#value' => t('Set Feature Taxonomy'),
- '#weight' => 3
- );
- }
- function get_tripal_featuremap_admin_form_reindex_set(&$form) {
-
- $form['reindex'] = array(
- '#type' => 'fieldset',
- '#title' => t('Reindex Map Features')
- );
-
- $sql = "SELECT * FROM {featuremap} ORDER BY name";
- $previous_db = tripal_db_set_active('chado');
- $lib_rset = db_query($sql);
- tripal_db_set_active($previous_db);
-
- $lib_boxes = array();
- while ($featuremap = db_fetch_object($lib_rset)) {
- $lib_boxes[$featuremap->featuremap_id] = "$featuremap->name";
- }
- $form['reindex']['description'] = array(
- '#type' => 'item',
- '#value' => t("This option allows for reindexing of only those features that belong to the selected maps below. All other features will be unaffected. To reindex all features in the site see the Feature Administration page."),
- '#weight' => 1,
- );
- $form['reindex']['re-maps'] = array(
- '#title' => t('Maps'),
- '#type' => t('checkboxes'),
- '#description' => t("Check the maps whoee features you want to reindex. Note: this list contains all maps, even those that may not be synced."),
- '#required' => FALSE,
- '#prefix' => '<div id="lib_boxes">',
- '#suffix' => '</div>',
- '#options' => $lib_boxes,
- '#weight' => 2,
- );
- $form['reindex']['re-button'] = array(
- '#type' => 'submit',
- '#value' => t('Reindex Features'),
- '#weight' => 3,
- );
- }
- function get_tripal_featuremap_admin_form_sync_set(&$form) {
-
- $form['sync'] = array(
- '#type' => 'fieldset',
- '#title' => t('Sync Maps')
- );
-
- $sql = "SELECT * FROM {featuremap} ORDER BY name";
- $previous_db = tripal_db_set_active('chado');
- $lib_rset = db_query($sql);
- tripal_db_set_active($previous_db);
-
-
-
-
- $lib_boxes = array();
- $added = 0;
- while ($featuremap = db_fetch_object($lib_rset)) {
-
-
- $sql = "SELECT * FROM {chado_featuremap} WHERE featuremap_id = %d";
- if (!db_fetch_object(db_query($sql, $featuremap->featuremap_id))) {
- $lib_boxes[$featuremap->featuremap_id] = "$featuremap->name";
- $added++;
- }
- }
-
-
- if ($added > 0) {
- $lib_boxes['all'] = "All Maps";
- $form['reindex']['description'] = array(
- '#type' => 'item',
- '#value' => t("This option allows for the creation of Drupal content for maps in chado. Only the selected maps will be synced."),
- '#weight' => 1,
- );
- $form['sync']['featuremaps'] = array(
- '#title' => t('Available Maps'),
- '#type' => t('checkboxes'),
- '#description' => t("Check the maps you want to sync. Drupal content will be created for each of the maps listed above. Select 'All Maps' to sync all of them."),
- '#required' => FALSE,
- '#prefix' => '<div id="lib_boxes">',
- '#suffix' => '</div>',
- '#options' => $lib_boxes,
- '#weight' => 2,
- );
- $form['sync']['button'] = array(
- '#type' => 'submit',
- '#value' => t('Sync Maps'),
- '#weight' => 3,
- );
- }
-
- else {
- $form['sync']['value'] = array(
- '#value' => t('All maps in Chado are currently synced with Drupal.')
- );
- }
- }
- function tripal_featuremap_admin_validate($form, &$form_state) {
- global $user;
- $job_args = array();
-
- if ($form_state['values']['op'] == t('Sync Maps')) {
-
-
- $featuremaps = $form_state['values']['featuremaps'];
- $do_all = FALSE;
- $to_sync = array();
- foreach ($featuremaps as $featuremap_id) {
- if (preg_match("/^all$/i", $featuremap_id)) {
- $do_all = TRUE;
- }
- if ($featuremap_id and preg_match("/^\d+$/i", $featuremap_id)) {
-
- $sql = "SELECT * FROM {featuremap} WHERE featuremap_id = %d";
- $previous_db = tripal_db_set_active('chado');
- $featuremap = db_fetch_object(db_query($sql, $featuremap_id));
- tripal_db_set_active($previous_db);
- $to_sync[$featuremap_id] = $featuremap->name;
- }
- }
-
- if ($do_all) {
- tripal_add_job('Sync all maps', 'tripal_featuremap', 'tripal_featuremap_sync_featuremaps', $job_args, $user->uid);
- }
- else{
- foreach ($to_sync as $featuremap_id => $name) {
- $job_args[0] = $featuremap_id;
- tripal_add_job("Sync map: $name", 'tripal_featuremap', 'tripal_featuremap_sync_featuremaps', $job_args, $user->uid);
- }
- }
- }
-
-
- if ($form_state['values']['op'] == t('Reindex Features')) {
- $featuremaps = $form_state['values']['re-maps'];
- foreach ($featuremaps as $featuremap_id) {
- if ($featuremap_id and preg_match("/^\d+$/i", $featuremap_id)) {
-
- $sql = "SELECT * FROM {featuremap} WHERE featuremap_id = %d";
- $previous_db = tripal_db_set_active('chado');
- $featuremap = db_fetch_object(db_query($sql, $featuremap_id));
- tripal_db_set_active($previous_db);
- $job_args[0] = $featuremap_id;
- tripal_add_job("Reindex features for map: $featuremap->name", 'tripal_featuremap',
- 'tripal_featuremap_reindex_features', $job_args, $user->uid);
- }
- }
- }
-
-
- if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
- $featuremaps = $form_state['values']['tx-maps'];
- foreach ($featuremaps as $featuremap_id) {
- if ($featuremap_id and preg_match("/^\d+$/i", $featuremap_id)) {
-
- $sql = "SELECT * FROM {featuremap} WHERE featuremap_id = %d";
- $previous_db = tripal_db_set_active('chado');
- $featuremap = db_fetch_object(db_query($sql, $featuremap_id));
- tripal_db_set_active($previous_db);
- $job_args[0] = $featuremap_id;
- tripal_add_job("Set taxonomy for features in map: $featuremap->name", 'tripal_featuremap',
- 'tripal_featuremap_taxonify_features', $job_args, $user->uid);
- }
- }
- }
-
-
- if ($form_state['values']['op'] == t('Clean up orphaned maps')) {
- tripal_add_job('Cleanup orphaned maps', 'tripal_featuremap',
- 'tripal_featuremap_cleanup', $job_args, $user->uid);
- }
- }
- function tripal_featuremap_cron() {
- }
- function tripal_featuremap_map_access($op, $node, $account) {
- if ($op == 'create') {
- if (!user_access('create chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'update') {
- if (!user_access('edit any chado_featuremap content', $account) &&
- !user_access('edit own chado_featuremap content', $account)) {
- return FALSE;
- }
- if (user_access('edit own chado_featuremap content', $account) &&
- $account->uid != $node->uid) {
- return FALSE;
- }
- }
- if ($op == 'delete') {
- if (!user_access('delete any chado_featuremap content', $account) &&
- !user_access('delete own chado_featuremap content', $account)) {
- return FALSE;
- }
- if (user_access('delete own chado_featuremap content', $account) &&
- $account->uid != $node->uid) {
- return FALSE;
- }
- }
- return NULL;
- }
- function chado_featuremap_validate($node) {
- $lib = 0;
-
-
- if ($node->featuremap_id) {
- $sql = "SELECT * FROM ".
- "{featuremap} WHERE ".
- "name = '%s' ".
- "AND NOT featuremap_id = %d";
- $previous_db = tripal_db_set_active('chado');
- $lib = db_fetch_object(db_query($sql, $node->name,
- $node->featuremap_id));
- tripal_db_set_active($previous_db);
- }
- else {
- $sql = "SELECT * FROM ".
- "{featuremap} ".
- "WHERE name = '%s'";
- $previous_db = tripal_db_set_active('chado');
- $lib = db_fetch_object(db_query($sql, $node->name));
- tripal_db_set_active($previous_db);
- }
- if ($lib) {
- form_set_error('name', t('The unique map name already exists. '.
- 'Please choose another'));
- }
- }
- function chado_featuremap_insert($node) {
- if ($node->featuremap_id) {
- $featuremap['featuremap_id'] = $node->featuremap_id;
- }
- else {
- $values = array(
- 'name' => $node->title,
- 'description' => $node->description,
- );
- $featuremap = tripal_core_chado_insert('featuremap', $values);
- }
- if ($featuremap) {
-
-
- $featuremap_id = chado_get_id_for_node('featuremap', $node) ;
- if (!$featuremap_id) {
-
- $sql = "INSERT INTO {chado_featuremap} (nid, vid, featuremap_id) ".
- "VALUES (%d, %d, %d)";
- db_query($sql, $node->nid, $node->vid, $featuremap['featuremap_id']);
- }
- }
- else {
- drupal_set_message(t('Unable to add featuremap.', 'warning'));
- watchdog('tripal_featuremap',
- 'Insert feature: Unable to create featuremap where values: %values',
- array('%values' => print_r($values, TRUE)),
- WATCHDOG_WARNING
- );
- }
- }
- function chado_featuremap_update($node) {
- if ($node->revision) {
-
- }
- else {
- $featuremap_id = chado_get_id_for_node('featuremap', $node) ;
-
- $match = array(
- 'featuremap_id' => $featuremap_id,
- );
- $values = array(
- 'name' => $node->title,
- );
- $status = tripal_core_chado_update('featuremap', $match, $values);
- }
- }
- function tripal_featuremap_add_taxonomy($node, $featuremap_id) {
- }
- function chado_featuremap_form($node) {
- $form = array();
- $featuremap = $node->featuremap;
-
- $name = $node->name;
- if (!$name) {
- $name = $featuremap->name;
- }
-
-
- $form['featuremap_id'] = array(
- '#type' => 'value',
- '#value' => $featuremap->featuremap_id,
- );
- $form['title']= array(
- '#type' => 'textfield',
- '#title' => t('Map Title'),
- '#description' => t('Please enter the title for this map. '.
- 'This appears at the top of the map page.'),
- '#required' => TRUE,
- '#default_value' => $node->title,
- '#weight' => 1
- );
- $form['name']= array(
- '#type' => 'textfield',
- '#title' => t('Map Name'),
- '#description' => t('Please enter a name for this map'),
- '#required' => TRUE,
- '#default_value' => $name,
- '#weight' => 2
- );
- $form['description']= array(
- '#type' => 'textarea',
- '#title' => t('Map Description'),
- '#description' => t('A brief description of the map'),
- '#required' => TRUE,
- '#default_value' => $description,
- '#weight' => 5
- );
- return $form;
- }
- function tripal_featuremap_sync_featuremaps($featuremap_id = NULL, $job_id = NULL) {
- global $user;
- $page_content = '';
-
- if (!$featuremap_id) {
- $sql = "SELECT * FROM {featuremap} L";
- $previous_db = tripal_db_set_active('chado');
- $results = db_query($sql);
- tripal_db_set_active($previous_db);
- }
- else {
- $sql = "SELECT * FROM {featuremap} L WHERE featuremap_id = %d";
- $previous_db = tripal_db_set_active('chado');
- $results = db_query($sql, $featuremap_id);
- tripal_db_set_active($previous_db);
- }
-
-
- $sql = "SELECT * FROM {chado_featuremap} ".
- "WHERE featuremap_id = %d";
- while ($featuremap = db_fetch_object($results)) {
-
-
- if (!db_fetch_object(db_query($sql, $featuremap->featuremap_id))) {
- $new_node = new stdClass();
- $new_node->type = 'chado_featuremap';
- $new_node->uid = $user->uid;
- $new_node->title = "$featuremap->name";
- $new_node->featuremap_id = $featuremap->featuremap_id;
- node_validate($new_node);
- $errors = form_get_errors();
- if (!$errors) {
- $node = node_submit($new_node);
- node_save($node);
- if ($node->nid) {
- print "Added " . $featuremap->name . "\n";
- }
- else {
- print "ERROR: Unable to create " . $featuremap->name . "\n";
- }
- }
- else {
- print "ERROR: Unable to create " . $featuremap->name . "\n" . print_r($errors, TRUE) . "\n";
- }
- }
- else {
- print "Skipped " . $featuremap->name . "\n";
- }
- }
- return $page_content;
- }
- function chado_featuremap_load($node) {
-
- $featuremap_id = chado_get_id_for_node('featuremap', $node);
- $values = array('featuremap_id' => $featuremap_id);
- $featuremap = tripal_core_generate_chado_var('featuremap', $values);
- $additions = new stdClass();
- $additions->featuremap = $featuremap;
- return $additions;
- }
- function chado_featuremap_view($node, $teaser = FALSE, $page = FALSE) {
-
- if (!$teaser) {
- $node = node_prepare($node, $teaser);
- }
- return $node;
- }
- function chado_featuremap_delete(&$node) {
- $featuremap_id = chado_get_id_for_node('featuremap', $node);
-
-
-
- if (!$featuremap_id) {
- return;
- }
-
-
-
- $sql_del = "DELETE FROM {chado_featuremap} ".
- "WHERE nid = %d ".
- "AND vid = %d";
- db_query($sql_del, $node->nid, $node->vid);
- $sql_del = "DELETE FROM {node} ".
- "WHERE nid = %d ".
- "AND vid = %d";
- db_query($sql_del, $node->nid, $node->vid);
- $sql_del = "DELETE FROM {node_revisions} ".
- "WHERE nid = %d ".
- "AND vid = %d";
- db_query($sql_del, $node->nid, $node->vid);
-
- $previous_db = tripal_db_set_active('chado');
- db_query("DELETE FROM {featuremap} WHERE featuremap_id = %d", $featuremap_id);
- db_query("DELETE FROM {featuremapprop} WHERE featuremap_id = %d", $featuremap_id);
- tripal_db_set_active($previous_db);
- }
- function tripal_featuremap_cleanup($dummy = NULL, $job_id = NULL) {
- return tripal_core_clean_orphaned_nodes('featuremap', $job_id);
-
- }
- function theme_tripal_featuremap_search_result($node) {
- }
|