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

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

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

revision 1.1.2.11 by q0rban, Wed Aug 26 19:24:44 2009 UTC revision 1.1.2.12 by q0rban, Fri Nov 20 21:55:47 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: region_manager.pages.inc,v 1.1.2.10 2009/05/21 21:56:34 q0rban Exp $  // $Id: region_manager.pages.inc,v 1.1.2.11 2009/08/26 19:24:44 q0rban Exp $
3    
4  /**  /**
5   * Define our states.   * Define our states.
# Line 113  function region_manager_manage_form(&$fo Line 113  function region_manager_manage_form(&$fo
113        '#value' => $block['delta'],        '#value' => $block['delta'],
114      );      );
115    
116      // Block name.      // Block administration name.
     // Remove (nodeblock) if it's in there.  
     $block['info'] = preg_replace('/\(nodeblock\)$/', t('(Content @block)', array('@block' => _region_manager_block_name())), $block['info']);  
117      $form[$key]['info'] = array(      $form[$key]['info'] = array(
118        '#value' => check_plain($block['info']),        '#value' => $block['info'],
119      );      );
120    
121        // Block operations
122      $form[$key]['operations'] = array(      $form[$key]['operations'] = array(
123        '#type' => 'markup',        '#type' => 'markup',
124        '#value' => _region_manager_block_operations($block, $key),        '#value' => _region_manager_block_operations($block, $key),
# Line 133  function region_manager_manage_form(&$fo Line 132  function region_manager_manage_form(&$fo
132        '#options' => array(t('Use Default Title'), t('Disable Title'), t('Use Custom Title')),        '#options' => array(t('Use Default Title'), t('Disable Title'), t('Use Custom Title')),
133      );      );
134    
135        // Block title
136      $form[$key]['title'] = array(      $form[$key]['title'] = array(
137        '#attributes' => array('class' => 'region-manager-manage-form-title'),        '#attributes' => array('class' => 'region-manager-manage-form-title'),
138        '#type' => 'textfield',        '#type' => 'textfield',
139        '#size' => 40,        '#size' => 40,
140        '#default_value' => $block['title'],        '#default_value' => $block['title'],
141      );      );
142    
143        // Block weight
144      $form[$key]['weight'] = array(      $form[$key]['weight'] = array(
145        '#type' => 'weight',        '#type' => 'weight',
146        '#default_value' => $block['weight'],        '#default_value' => $block['weight'],
# Line 316  function _region_manager_manage_form_sta Line 318  function _region_manager_manage_form_sta
318    
319    switch($state) {    switch($state) {
320      case RM_BLOCK_ACTIVE_PATH:      case RM_BLOCK_ACTIVE_PATH:
321        $vars['state_prefix'][$state] = '<div id="region-manager-active-path-nodeblock-wrapper">';        $vars['state_prefix'][$state] = '<div id="region-manager-active-path-wrapper">';
322        // Output the available content blocks to be added, if nodeblock is enabled.        // Output the create links, if there are any.
323        if (function_exists('nodeblock_block') && _region_manager_nodeblock_status($theme_key, $region) && ($links = _region_manager_nodeblock_links($theme_key, $region))) {        if ($links = region_manager_create_links($theme_key, $region)) {
324          $vars['state_prefix'][$state] .= theme('region_manager_nodeblock_menu', $links);          $vars['state_prefix'][$state] .= theme('region_manager_create_menu', $links);
325        }        }
326        break;        break;
327    
# Line 392  function _region_manager_block_state($bl Line 394  function _region_manager_block_state($bl
394   * @return   * @return
395   *   The HTML list of links.   *   The HTML list of links.
396   */   */
397  function theme_region_manager_nodeblock_menu($links) {  function theme_region_manager_create_menu($links) {
398    $output = '<div class="region-manager-nodeblock-menu">';    $output = '<div class="region-manager-create-menu">';
399    
400    // The arguments array for the t() func.    // The arguments array for the t() func.
401    $t_args = array('@block' => _region_manager_block_name());    $t_args = array('@block' => _region_manager_block_name());
# Line 402  function theme_region_manager_nodeblock_ Line 404  function theme_region_manager_nodeblock_
404    // a fancy button.    // a fancy button.
405    $options = array('attributes' => array(    $options = array('attributes' => array(
406      'title' => t('Create and add a new content @block', $t_args),      'title' => t('Create and add a new content @block', $t_args),
407      'class' => 'region-manager-nodeblock-menu-link',      'class' => 'region-manager-create-menu-link',
408    ));    ));
409    $output .= '<h4>'. l(t('Create content @block', $t_args), 'node/add', $options) .'</h4>';    $output .= '<h4>'. l(t('Create content @block', $t_args), 'node/add', $options) .'</h4>';
410    
# Line 414  function theme_region_manager_nodeblock_ Line 416  function theme_region_manager_nodeblock_
416  }  }
417    
418  /**  /**
  * Loads a list of links to add new nodeblock content types.  
  *  
  * @param $theme_key  
  *   A string containing the key of the active theme.  
  * @param $region  
  *   A string containing the region to be managed.  
  * @return  
  *   An array containing the available content types to add.  
  */  
 function _region_manager_nodeblock_links($theme_key, $region) {  
   $types = node_get_types();  
   
   foreach ($types as $type) {  
     if (nodeblock_type_enabled($type)) {  
       if (node_access('create', $type)) {  
         $options = array();  
         if ($path = $_REQUEST['destination']) {  
           $options['query'] = array('destination' => $path);  
         }  
         $type_url_str = str_replace('_', '-', $type->type);  
         $links[] = l(t('@type @block', array('@type' => $type->name, '@block' => _region_manager_block_name())), "node/add/$type_url_str/$theme_key/$region", $options);  
       }  
     }  
   }  
   
   return $links;  
 }  
   
 /**  
419   * Helper function to determine the status of a title.   * Helper function to determine the status of a title.
420   *   *
421   * Title states:   * Title states:
# Line 466  function _region_manager_block_title_sta Line 439  function _region_manager_block_title_sta
439    }    }
440    
441    return $title_status;    return $title_status;
 }  
   
 /**  
  * Checks to see if nodeblock is disabled for a specific region.  
  *  
  * @param $theme_key  
  *   A string containing the key of the active theme.  
  * @param $region  
  *   A string containing the region to be managed.  
  * @return  
  *   Boolean TRUE if nodeblocks are available for the region  
  */  
 function _region_manager_nodeblock_status($theme_key, $region) {  
   $records = region_manager_regions_load($theme_key);  
   
   return !($records[$region]['modules']['nodeblock'] == REGION_MANAGER_ALL_DISABLED);  
442  }  }

Legend:
Removed from v.1.1.2.11  
changed lines
  Added in v.1.1.2.12

  ViewVC Help
Powered by ViewVC 1.1.3