array( 'template' => 'node-form', ), 'nodeformcols_configuration' => array( 'template' => 'nodeformcols-configuration', 'arguments' => array('element' => array()), ), ); } /** * Implementation of hook_menu(). */ function nodeformcols_menu() { $items = array(); if (!defined('MAINTENANCE_MODE')) { foreach (node_get_types() as $type) { $type_name = $type->type; $type_url_str = str_replace('_', '-', $type_name); $items['admin/content/node-type/'. $type_url_str .'/form'] = array( 'title' => 'Manage form', 'page callback' => 'drupal_get_form', 'page arguments' => array('nodeformcols_configuration_form', $type_name, 5), 'access arguments' => array('administer content types'), 'file' => 'nodeformcols.admin.inc', 'type' => MENU_LOCAL_TASK, 'weight' => 3 ); } } return $items; } /** * Implementation of hook_ctools_plugin_directory(). */ function nodeformcols_ctools_plugin_directory($module, $plugin) { if ($module == 'ctools') { return 'plugins/' . $plugin; } } function nodeformcols_form_regions() { return array( 'main' => t('Main column'), 'right' => t('Right'), 'footer' => t('Footer'), ); } /** * Gets default placements for standard fields * * @return array */ function _nodeformscols_default_field_placements() { return array( 'title' => array('region' => 'main'), 'body_field' => array('region' => 'main'), 'menu' => array('region' => 'right'), 'revision_information' => array('region' => 'right'), 'comment_settings' => array('region' => 'right'), 'path' => array('region' => 'right'), 'options' => array('region' => 'right'), 'author' => array('region' => 'right'), 'buttons' => array('region' => NODEFORMCOLS_DEFAULT_REGION, 'weight' => 100), ); } function nodeformscols_field_placements($content_type, $variant) { $default = _nodeformscols_default_field_placements(); if ($variant != 'default') { $default = variable_get('nodeformscols_field_placements_' . $content_type . '_default', $default); } $placements = variable_get('nodeformscols_field_placements_' . $content_type . '_' . $variant, $default); return $placements; } function nodeformscols_content_extra_fields($type_name, $variant) { return array( 'buttons' => array( '#title' => t('Buttons'), '#description' => t('Save, preview and delete buttons.'), '#weight' => 50, ), 'options' => array( '#title' => t('Workflow options'), '#description' => t('Options for publishing, sticky and publish on front page.'), '#weight' => 0, ), ); } /** * Implementation of hook_form_alter(). */ function nodeformcols_form_alter(&$form, $form_state, $form_id) { if ('node-form' == $form['#id']) { drupal_alter('nodeformcols_pre_form', $form); $variant = isset($form['#nodeformcols_variant']) ? $form['#nodeformcols_variant'] : 'default'; $placements = nodeformscols_field_placements($form['#node']->type, $variant); foreach ($placements as $key => $p) { if (isset($p['hidden']) && $p['hidden']) { $form[$key]['#access'] = FALSE; } } drupal_alter('nodeformcols_post_form', $form); } } /** * Preprocess function to run ahead of other modules. */ function template_preprocess_node_form(&$aVars) { drupal_add_css(drupal_get_path('module', 'nodeformcols') . '/css/nodeformcols.css'); $default_region = variable_get('nodeformcols_default_region', NODEFORMCOLS_DEFAULT_REGION); $form = &$aVars['form']; $class = array('node-form'); $regions = array(); $has_elements = array(); $weight = 0; foreach (nodeformcols_form_regions() as $name => $title) { $regions[$name] = array( '#prefix' => '