Project

General

Profile

« Previous | Next » 

Revision f2c82d01

Added by Andreas Kohlbecker over 15 years ago

relaxing module dependency, cdm_taxontree_cache fixes

View differences:

.gitattributes
51 51
modules/cdm_dataportal/cdm_taxontree/LICENSE.txt -text
52 52
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.css -text
53 53
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.info -text
54
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.install -text
54 55
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module -text
55 56
modules/cdm_dataportal/cdm_taxontree/concept_switch.gif -text
56 57
modules/cdm_dataportal/cdm_taxontree/images/btn_expand.gif -text
modules/cdm_dataportal/cdm_api/cdm_api.install
22 22
 * Implementation of hook_uninstall().
23 23
 */
24 24
function cdm_api_uninstall(){
25
    db_query("DROP TABLE {cache_cdm_ws}");
25
    db_query("DROP TABLE {cache_cdm_ws};");
26 26
}
27 27
 ?>
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.install
1
<?php
2
// $Id: cdm_taxontree.install 2857 2008-06-26 16:48:16Z a.kohlbecker $
3

  
4
/**
5
 * Implementation of hook_install().
6
 */
7
function cdm_taxontree_install(){
8
  
9
  db_query(" CREATE TABLE  {cache_cdm_taxontree} (
10
      `cid` varchar(333) NOT NULL default '',
11
      `data` longblob,
12
      `expire` int(11) NOT NULL default '0',
13
      `created` int(11) NOT NULL default '0',
14
      `headers` text,
15
      PRIMARY KEY  (`cid`),
16
      KEY `expire` (`expire`)
17
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8; ");
18
  
19
}
20

  
21
/**
22
 * Implementation of hook_uninstall().
23
 */
24
function cdm_taxontree_uninstall(){
25
    db_query("DROP TABLE {cache_cdm_taxontree};");
26
}
27
 ?>
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module
60 60
          'type' => MENU_CALLBACK,
61 61
        );
62 62
  
63
		$items[] = array('path' => 'admin/settings/cdm_dataportal/clear_cache',
64
      'title' => t('Empty CDM Taxontree Cache'),
65
      'callback' => 'cdm_taxontree_cache_clear',
66
      'access' => user_access('administer cdm_dataportal'),
67
      'weight' => 2,
68
      'type' => MENU_NORMAL_ITEM,
69
		);
63
    } else {
70 64

  
65
      if(variable_get('cdm_taxontree_cache', 0)){
66
    		$items[] = array('path' => 'admin/settings/cdm_dataportal/clear_cache',
67
          'title' => t('Empty CDM Taxontree Cache'),
68
          'callback' => 'cdm_taxontree_cache_clear',
69
          'access' => user_access('administer cdm_dataportal'),
70
          'weight' => 2,
71
          'type' => MENU_NORMAL_ITEM,
72
    		);
73
      }
74
      
71 75
    }
72 76
    return $items;
73 77
}
74 78

  
79
function cdm_taxontree_cache_get($term){
80
  if(variable_get('cdm_taxontree_cache', 0)){
81
    return cache_get($term,'cache_cdm_taxontree');
82
  }
83
}
84

  
85
function cdm_taxontree_cache_set($term, $child_terms){
86
  if(variable_get('cdm_taxontree_cache', 0)){
87
    return cache_set($term,'cache_cdm_taxontree', serialize($child_terms));
88
  }
89
}
90

  
75 91
/**
76
 * function to empty the cdm_taxontree cache table in case of changes in taxa
92
 * function to empty the cdm_taxontree cache table
77 93
 *
78 94
 */
79 95
function cdm_taxontree_cache_clear() {
......
550 566
					$term_collection = array();
551 567
					// get child terms from cache
552 568
					foreach($child_terms as $key => $term){
553
						if(!$children = cache_get($term,'cache_cdm_taxontree')){
569
						if(!$children = cdm_taxontree_cache_get($term,'cache_cdm_taxontree')){
554 570
							// no data in cache? add some!
555 571
							$child_terms = _cdm_taxontree_get_all_children($child_terms,TRUE);
556 572
							// add parent term
......
559 575
								$child_terms[$key] = $key;
560 576
							}
561 577

  
562
							cache_set($term,'cache_cdm_taxontree',serialize($child_terms));
578
							cdm_taxontree_cache_set($term,'cache_cdm_taxontree',serialize($child_terms));
563 579
							$children = $child_terms;
564 580
						}
565 581
						else{
......
1363 1379
    // disable filterswitch
1364 1380
    $show_filter_switch = false;
1365 1381
    
1382
  } else if(module_exists('cdm_dataportal')){
1383
      $node_name = cdm_dataportal_shortname_of($node);
1384
      $path = cdm_dataportal_taxon_path($node->uuid);
1366 1385
  } else {
1367
    $node_name = cdm_dataportal_shortname_of($node);
1368
    $path = cdm_dataportal_taxon_path($node->uuid);
1386
      $node_name = "module cdm_dataportal missing";
1387
      $path = "";
1369 1388
  }
1370 1389

  
1371 1390
  if($filterIncludes){
......
1389 1408
  if(!$is_leaf && !$is_expanded && $filter_class != 'filter_excluded'){
1390 1409
    if($node->tid){
1391 1410
      $ahah_url = url('cdm_taxontree/taxonomy/children/'.$node->tid.'/'.$node->vid.'/cdm_taxontree/'.($nextLevelIncluded ? 1 : 0).'/'.($show_filter_switch ? 1 : 0).'/'.$tree_node_callback);
1392
    } else {
1411
    } else if(module_exists('cdm_dataportal')) {
1393 1412
      $ws_url = cdm_compose_url(CDM_WS_TREENODE_CHILDREN, array($node->uuid));
1394 1413
      $ahah_url = url('cdm_api/proxy/'.urlencode($ws_url).'/cdm_taxontree/'.($nextLevelIncluded ? 1 : 0).'/'.($show_filter_switch ? 1 : 0).'/'.$tree_node_callback);
1395 1414
    }
......
1425 1444
}
1426 1445

  
1427 1446
function theme_cdm_taxontree_node_filter_switch(&$node, $filter_class){
1447
  if(!module_exists('cdm_dataportal')) {
1448
    return '';
1449
  }
1450
  
1428 1451
  $out = '';
1429

  
1430 1452
  switch($filter_class){
1431 1453
    case 'filter_included':
1432 1454
      $filter_icon = 'visible_implicit_small.gif';

Also available in: Unified diff