comparison modules/taxonomy/taxonomy.module @ 7:fff6d4c8c043 6.3

Drupal 6.3
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:30:28 +0100
parents 2427550111ae
children 589fb7c02327
comparison
equal deleted inserted replaced
6:2cfdc3c92142 7:fff6d4c8c043
1 <?php 1 <?php
2 // $Id: taxonomy.module,v 1.414.2.1 2008/04/09 21:11:51 goba Exp $ 2 // $Id: taxonomy.module,v 1.414.2.4 2008/06/25 08:00:57 goba Exp $
3 3
4 /** 4 /**
5 * @file 5 * @file
6 * Enables the organization of content into categories. 6 * Enables the organization of content into categories.
7 */ 7 */
47 */ 47 */
48 function taxonomy_link($type, $node = NULL) { 48 function taxonomy_link($type, $node = NULL) {
49 if ($type == 'taxonomy terms' && $node != NULL) { 49 if ($type == 'taxonomy terms' && $node != NULL) {
50 $links = array(); 50 $links = array();
51 // If previewing, the terms must be converted to objects first. 51 // If previewing, the terms must be converted to objects first.
52 if ($node->build_mode == NODE_BUILD_PREVIEW) { 52 if (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW) {
53 $node->taxonomy = taxonomy_preview_terms($node); 53 $node->taxonomy = taxonomy_preview_terms($node);
54 } 54 }
55 if (!empty($node->taxonomy)) { 55 if (!empty($node->taxonomy)) {
56 foreach ($node->taxonomy as $term) { 56 foreach ($node->taxonomy as $term) {
57 // During preview the free tagging terms are in an array unlike the 57 // During preview the free tagging terms are in an array unlike the
906 $result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid')); 906 $result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
907 } 907 }
908 else { 908 else {
909 $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type); 909 $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
910 } 910 }
911 $count[$type] = array();
911 while ($term = db_fetch_object($result)) { 912 while ($term = db_fetch_object($result)) {
912 $count[$type][$term->tid] = $term->c; 913 $count[$type][$term->tid] = $term->c;
913 } 914 }
914 } 915 }
915 $children_count = 0; 916 $children_count = 0;
954 * 955 *
955 * @return 956 * @return
956 * An array of matching term objects. 957 * An array of matching term objects.
957 */ 958 */
958 function taxonomy_get_term_by_name($name) { 959 function taxonomy_get_term_by_name($name) {
959 $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER(t.name) LIKE LOWER('%s')", 't', 'tid'), trim($name)); 960 $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s')", 't', 'tid'), trim($name));
960 $result = array(); 961 $result = array();
961 while ($term = db_fetch_object($db_result)) { 962 while ($term = db_fetch_object($db_result)) {
962 $result[] = $term; 963 $result[] = $term;
963 } 964 }
964 965