function theme_wikitools_create in Wikitools 7
Same name and namespace in other branches
- 6 wikitools.pages.inc \theme_wikitools_create()
@todo Please document this function.
See also
1 theme call to theme_wikitools_create()
- theme_wikitools_page_does_not_exist in ./
wikitools.pages.inc - @todo Please document this function.
File
- ./
wikitools.pages.inc, line 220 - Page callbacks for wikitools pages.
Code
function theme_wikitools_create($variables) {
$page_name = $variables['page_name'];
$node_types = wikitools_node_types();
$output = '';
if (wikitools_node_creation() && count($node_types)) {
module_load_include('inc', 'node', 'node.pages');
$output .= '<p>' . t('You can create the page as:') . '</p>';
// Collapse the forms initially if there are more than one.
$collapsed = count($node_types) > 1 ? ' collapsed' : '';
// The form_alter hooks excpects the preset title in the GET array, so we put it there.
$_GET['edit']['title'] = $page_name;
foreach ($node_types as $type) {
drupal_add_js('misc/collapse.js');
$type = node_type_get_type($type);
if (node_access('create', $type->type)) {
$output .= '<fieldset class="collapsible' . $collapsed . '"><legend>' . $type->name . '</legend>';
if ($router_item = menu_get_item('node/add/' . str_replace('_', '-', $type->type))) {
if (isset($router_item['file'])) {
require_once DRUPAL_ROOT . '/' . $router_item['file'];
}
$form = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
$output .= drupal_render($form);
}
$output .= '</fieldset>';
}
}
// Some of the callbacks could have set the page title, so we reset it.
drupal_set_title(t('Page does not exist: %page', array(
'%page' => $page_name,
)), PASS_THROUGH);
}
return $output;
}