/[drupal]/contributions/modules/location/location_node.module
ViewVC logotype

Diff of /contributions/modules/location/location_node.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5, Fri Apr 3 20:17:53 2009 UTC revision 1.6, Mon Aug 31 22:09:35 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: location_node.module,v 1.4 2009/04/03 15:51:10 bdragon Exp $  // $Id: location_node.module,v 1.5 2009/04/03 20:17:53 bdragon Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 10  Line 10 
10   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
11   */   */
12  function location_node_form_alter(&$form, &$form_state, $form_id) {  function location_node_form_alter(&$form, &$form_state, $form_id) {
13    if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {    if (!empty($form['#node_edit_form'])) {
14      // Add the Location fields on the Node edit form      // Add the Location fields on the Node edit form
15      $node = $form['#node'];      $node = $form['#node'];
16      $settings = variable_get('location_settings_node_'. $node->type, array());      $settings = variable_get('location_settings_node_'. $node->type, array());
# Line 22  function location_node_form_alter(&$form Line 22  function location_node_form_alter(&$form
22  }  }
23    
24  /**  /**
25   * Implementation of hook_nodeapi().   * Implementation of hook_node_delete_revision().
26   */   */
27  function location_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {  function location_node_node_delete_revision($node) {
28    switch ($op) {    $locations = array();
29      case 'delete revision':    location_save_locations($locations, array('vid' => $node->vid));
30        $locations = array();  }
31        location_save_locations($locations, array('vid' => $node->vid));  
32        break;  /**
33      case 'delete':   * Implementation of hook_node_delete().
34        $locations = array();   */
35        location_save_locations($locations, array('nid' => $node->nid));  function location_node_node_delete($node) {
36        break;    $locations = array();
37      case 'load':    location_save_locations($locations, array('nid' => $node->nid));
38        $locations = location_load_locations($node->vid);  }
39        $location = count($locations) ? $locations[0] : array();  
40        return array('locations' => $locations, 'location' => $location);  /**
41     * Implementation of hook_node_load().
42      case 'insert':   */
43      case 'update':  function location_node_node_load($nodes, $types) {
44        if (!empty($node->locations)) {    // @@@ Resurrect the behavior from way back (1.x/2.x) that disabled existing
45          location_save_locations($node->locations, array('nid' => $node->nid, 'vid' => $node->vid));    // locations when the content type wasn't enabled for locations?
46        }    // @@@TODO 7.x -- multiload version!
47        break;    foreach (array_keys($nodes) as $nid) {
48        $nodes[$nid]->locations = location_load_locations($nodes[$nid]->vid);
49        // @@@TODO 7.x -- Either reimplement or cut $node->location.
50      }
51    }
52    
53    /**
54     * Implementation of hook_node_insert().
55     */
56    function location_node_node_insert($node) {
57      if (!empty($node->locations)) {
58        location_save_locations($node->locations, array('nid' => $node->nid, 'vid' => $node->vid));
59      }
60    }
61    
62      case 'view':  /**
63        if (variable_get('location_display_location', 1)) {   * Implementation of hook_node_update().
64          $settings = variable_get('location_settings_node_'. $node->type, array());   */
65          if (isset($settings['display']['teaser']) && isset($settings['display']['full'])) {  function location_node_node_update($node) {
66            if (($a3 && $settings['display']['teaser']) || (!$a3 && $settings['display']['full'])) {    return location_node_node_insert($node);
67              $node->content['locations'] = location_display($settings, $node->locations);  }
68            }  
69    /**
70     * Implementation of hook_node_view().
71     */
72    function location_node_node_view($node, $build_mode) {
73      // @@@TODO 7.x Switch to a pure "fields" approach?
74      if (empty($node->locations)) {
75        return;
76      }
77    
78      // @@@TODO 7.x -- TEST THIS!
79      if ($build_mode == 'rss') {
80        $settings = variable_get('location_settings_node_'. $node->type, array());
81        $mode = isset($settings['rss']['mode']) ? $settings['rss']['mode'] : 'simple';
82        if ($mode == 'none') {
83          return;
84        }
85        if (is_array($node->locations) && !empty($node->locations)) {
86          require_once(drupal_get_path('module', 'location') .'/location.georss.inc');
87          $node->rss_namespaces += location_rss_namespaces($mode);
88          foreach ($node->locations as $location) {
89            if (($item = location_rss_item($location, $mode))) {
90                $node->rss_elements[] = $item;
91          }          }
92        }        }
93        break;      }
94      }
95      case 'rss item':    else {
96        $items = array();      // @@@TODO 7.x -- location_display_location is idiotic. KILL IT.
97        if (variable_get('location_display_location', 1)) {
98        $settings = variable_get('location_settings_node_'. $node->type, array());        $settings = variable_get('location_settings_node_'. $node->type, array());
99        $mode = isset($settings['rss']['mode']) ? $settings['rss']['mode'] : 'simple';        if (isset($settings['display']['teaser']) && isset($settings['display']['full'])) {
100        if ($mode == 'none') {          if (($a3 && $settings['display']['teaser']) || (!$a3 && $settings['display']['full'])) {
101          return;            $node->content['locations'] = location_display($settings, $node->locations);
       }  
       if (is_array($node->locations)) {  
         foreach ($node->locations as $location) {  
           if (($item = location_rss_item($location, $mode))) {  
             $items[] = $item;  
           }  
102          }          }
103        }        }
104        return $items;      }
105    }    }
106    
107  }  }
108    
109  /**  /**
# Line 106  function location_node_form_node_type_fo Line 137  function location_node_form_node_type_fo
137    
138    $settings = variable_get('location_settings_node_'. $type, array());    $settings = variable_get('location_settings_node_'. $type, array());
139    $form['location_settings'] = location_settings($settings);    $form['location_settings'] = location_settings($settings);
140      $form['location_settings']['#group'] = 'additional_settings';
141    
142    // Tack on customizations for node settings.    // Tack on customizations for node settings.
143    $form['location_settings']['display']['teaser'] = array(    $form['location_settings']['display']['teaser'] = array(

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.2