function _hosting_node_add in Hosting 7.3
Same name and namespace in other branches
- 5 hosting.module \_hosting_node_add()
- 6.2 hosting.module \_hosting_node_add()
- 7.4 hosting.module \_hosting_node_add()
Replacement node/add page.
Major kludge to remove the hidden node types from node/add page.
Copied from node.module.
1 string reference to '_hosting_node_add'
- hosting_menu_alter in ./
hosting.module - Implements hook_menu_alter().
File
- ./
hosting.module, line 796 - Hosting module.
Code
function _hosting_node_add($type = '') {
global $user;
$types = node_type_get_types();
$type = $type ? str_replace('-', '_', $type) : NULL;
// If a node type has been specified, validate its existence.
if (isset($types[$type]) && user_access('create ' . $type) && hosting_feature($type) !== HOSTING_FEATURE_DISABLED) {
// Initialize settings:
$node = array(
'uid' => $user->uid,
'name' => $user->name,
'type' => $type,
);
drupal_set_title(t('Submit @name', array(
'@name' => $types[$type]->name,
)), PASS_THROUGH);
// TODO $node needs to have $form as its first parameter.
$output = drupal_get_form($type . '_node_form', $node);
}
else {
// If no (valid) node type has been provided, display a node type overview.
foreach ($types as $type) {
if (function_exists($type->module . '_form') && user_access('create ' . $type->type) && hosting_feature($type->type) !== HOSTING_FEATURE_DISABLED) {
$type_url_str = str_replace('_', '-', $type->type);
$title = t('Add a new @s.', array(
'@s' => $type->name,
));
$out = '<dt>' . l(drupal_ucfirst($type->name), "node/add/{$type_url_str}", array(
'attributes' => array(
'title' => $title,
),
)) . '</dt>';
$out .= '<dd>' . filter_xss_admin($type->description) . '</dd>';
$item[$type->name] = $out;
}
}
if (isset($item)) {
uksort($item, 'strnatcasecmp');
$output = t('Choose the appropriate item from the list:') . '<dl>' . implode('', $item) . '</dl>';
}
else {
$output = t('No content types available.');
}
}
return $output;
}