| 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. |
| 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), |
| 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'], |
| 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 |
|
|
| 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()); |
| 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 |
|
|
| 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: |
| 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 |
} |
} |