/[drupal]/contributions/modules/region_manager/region_manager.nodeblock.inc
ViewVC logotype

Diff of /contributions/modules/region_manager/region_manager.nodeblock.inc

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

revision 1.1 by q0rban, Fri Nov 20 21:55:47 2009 UTC revision 1.1.2.1 by q0rban, Fri Nov 20 21:55:47 2009 UTC
# Line 0  Line 1 
1    <?php
2    // $Id$
3    
4    /**
5     * @file
6     *
7     * Holds functions for the nodeblock implementation of Region Manager's block
8     * creation API.
9     */
10    
11    /**
12     * Implementation of hook_form_alter() on behalf of nodeblock. We need to use
13     * the region_manager namespace since nodeblock already implements this hook.
14     */
15    function region_manager_form_alter(&$form, $form_state, $form_id) {
16      if (function_exists('nodeblock_block') && $form['#id'] == 'node-form' && variable_get('nodeblock_'. $form['type']['#value'], 0) && !$form['nid']['#value']) {
17        if (($theme_key = $_GET['theme_key']) && ($region = $_GET['region']) && ($path = $_REQUEST['destination'])) {
18          $frontpage = variable_get('site_frontpage', 'node');
19          $path = ($path == $frontpage) ? '<front>' : $path;
20    
21          $form['region_manager'] = array(
22            '#tree' => TRUE,
23          );
24          $form['region_manager']['theme_key'] = array(
25            '#type' => 'hidden',
26            '#value' => $theme_key,
27          );
28          $form['region_manager']['region'] = array(
29            '#type' => 'hidden',
30            '#value' => $region,
31          );
32          $form['region_manager']['module'] = array(
33            '#type' => 'hidden',
34            '#value' => 'nodeblock',
35          );
36          $form['region_manager']['path'] = array(
37            '#type' => 'hidden',
38            '#value' => $path,
39          );
40        }
41      }
42    }
43    
44    /**
45     * Implementation of hook_region_manager_create_links() on behalf of nodeblock.
46     *
47     * @param $theme_key
48     *   A string containing the key of the theme that is being managed.
49     * @param $region
50     *   A string containing the region being managed.
51     */
52    function nodeblock_region_manager_create_links($theme_key, $region) {
53      $links = array();
54      $records = region_manager_regions_load($theme_key);
55    
56      if ($records[$region]['modules']['nodeblock'] != REGION_MANAGER_ALL_DISABLED) {
57        $types = node_get_types();
58        foreach ($types as $type) {
59          if (nodeblock_type_enabled($type)) {
60            if (node_access('create', $type)) {
61              $type_url_str = str_replace('_', '-', $type->type);
62              $path = "node/add/$type_url_str";
63              $links[$path] = array(
64                'title' => t('@type @block', array('@type' => $type->name, '@block' => _region_manager_block_name())),
65                'path' => $path,
66              );
67            }
68          }
69        }
70      }
71    
72      return $links;
73    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.3