source: sipes/modules_contrib/diff/includes/taxonomy.inc @ 177a560

stableversion-3.0
Last change on this file since 177a560 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100644
File size: 2.0 KB
Línea 
1<?php
2
3/**
4 * @file
5 * Implementation of hook_diff() for taxonomy.
6 */
7
8/**
9 * Implementation of hook_diff() for taxonomy.
10 */
11function taxonomy_diff($old_node, $new_node) {
12  $result = array();
13  // TODO: make taxonomy by category not only by whole taxonomy?
14  $old_taxonomy = array();
15  $new_taxonomy = array();
16  if (isset($old_node->taxonomy) && $old_node->taxonomy) {
17    foreach ($old_node->taxonomy as $term) {
18      $old_taxonomy[] = $term->name;
19    }
20  }
21  if (isset($new_node->taxonomy) && $new_node->taxonomy) {
22    foreach ($new_node->taxonomy as $id => $entry) {
23      if (is_array($entry)) {
24        // During editing the taxonomy is built up as a list of vocabulary ids as keys
25        // and a list of term ids per array entry.
26        if (is_numeric($id)) {
27          foreach ($entry as $tid) {
28            $term = taxonomy_get_term($tid);
29            $new_taxonomy[] = $term->name;
30          }
31        }
32        else {
33          // If the id is not numeric than it has to be 'tags' which denotes freetagging
34          // vocabularies. These are stored as an array which map the vocabulary id to
35          // a string of terms.
36          foreach ($entry as $taglist) {
37            // The regular expression is taken from taxonomy.module.
38            preg_match_all('%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x', $taglist, $matches);
39            foreach ($matches[1] as $term) {
40              $new_taxonomy[] = $term;
41            }
42          }
43        }
44      }
45      elseif (is_numeric($entry)) {
46        // During editing, taxonomy is a single id.
47        $term = taxonomy_get_term($entry);
48        $new_taxonomy[] = $term->name;
49      }
50      else {
51        // Not during editing the taxonomy list is a list of terms.
52        $new_taxonomy[] = $entry->name;
53      }
54    }
55  }
56  $result['taxonomy'] = array(
57    '#name' => t('Taxonomy'),
58    '#old' => $old_taxonomy,
59    '#new' => $new_taxonomy,
60    '#weight' => -3,
61    '#format' => array(
62      'show_header' => FALSE,
63    )
64  );
65  return $result;
66}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.