diff --git a/sites/all/modules/contrib/nodeformcols/nodeformcols-configuration.tpl.php b/sites/all/modules/contrib/nodeformcols/nodeformcols-configuration.tpl.php index bb259b3..f598723 100644 --- a/sites/all/modules/contrib/nodeformcols/nodeformcols-configuration.tpl.php +++ b/sites/all/modules/contrib/nodeformcols/nodeformcols-configuration.tpl.php @@ -1,12 +1,8 @@ diff --git a/sites/all/modules/contrib/nodeformcols/nodeformcols.admin.inc b/sites/all/modules/contrib/nodeformcols/nodeformcols.admin.inc index b4b969e..11e1d4f 100644 --- a/sites/all/modules/contrib/nodeformcols/nodeformcols.admin.inc +++ b/sites/all/modules/contrib/nodeformcols/nodeformcols.admin.inc @@ -1,5 +1,4 @@ 'value', @@ -202,7 +201,7 @@ function _nodeformcols_configuration_form_after_build($form) { drupal_add_js(drupal_get_path('module', 'nodeformcols') . '/js/nodeformcols.js'); drupal_add_css(drupal_get_path('module', 'nodeformcols') . '/css/nodeformcols.admin.css'); - $regions = nodeformcols_form_regions(); + $regions = nodeformcols_form_regions($form['type']['#value']); foreach ($regions as $region => $title) { if (is_array($form['conf'][$region])) { uasort($form['conf'][$region], "element_sort"); diff --git a/sites/all/modules/contrib/nodeformcols/nodeformcols.module b/sites/all/modules/contrib/nodeformcols/nodeformcols.module index a215f37..473f901 100644 --- a/sites/all/modules/contrib/nodeformcols/nodeformcols.module +++ b/sites/all/modules/contrib/nodeformcols/nodeformcols.module @@ -1,5 +1,4 @@ array( 'template' => 'nodeformcols-configuration', - 'arguments' => array('element' => array()), + 'arguments' => array('element' => array(), 'type' => ''), ), ); } @@ -53,35 +52,59 @@ function nodeformcols_ctools_plugin_directory($module, $plugin) { } } -function nodeformcols_form_regions() { - return array( - 'main' => t('Main column'), - 'right' => t('Right'), - 'footer' => t('Footer'), - ); +/** + * Returns a set of regions. + * + * @param string $type + * Machine readable name of a content type + * @param boolean $reset + * Optional boolean to force the list to reset. + * @return array + * An array of regions. + */ +function nodeformcols_form_regions($type = '', $reset = FALSE) { + static $regions; + if (!isset($regions) || $reset) { + $regions = array( + 'main' => t('Main column'), + 'right' => t('Right'), + 'footer' => t('Footer'), + ); + drupal_alter('nodeformcols_form_regions', $regions, $type); + } + return $regions; } /** * Gets default placements for standard fields * + * @param string $type + * Machine readable name of a content type + * @param boolean $reset + * Optional boolean to force the list to reset. * @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_default_field_placements($type = '', $reset = FALSE) { + static $placements; + if(!isset($placements) || $reset) { + $placements = 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), + ); + drupal_alter('nodeformcols_default_field_placements', $placements, $type); + } + return $placements; } function nodeformscols_field_placements($content_type, $variant) { - $default = _nodeformscols_default_field_placements(); + $default = _nodeformscols_default_field_placements($content_type); if ($variant != 'default') { $default = variable_get('nodeformscols_field_placements_' . $content_type . '_default', $default); @@ -138,7 +161,8 @@ function template_preprocess_node_form(&$aVars) { $regions = array(); $has_elements = array(); $weight = 0; - foreach (nodeformcols_form_regions() as $name => $title) { + $form_regions = nodeformcols_form_regions($form['#node']->type); + foreach ($form_regions as $name => $title) { $regions[$name] = array( '#prefix' => '
', '#suffix' => '
', @@ -234,3 +258,12 @@ function nodeformcols_node_type($op, $info) { break; } } + +/** + * Preprocess function for the admin page, to get the type and put in the + * correct list of regions. + */ +function template_preprocess_nodeformcols_configuration(&$vars){ + $type = str_replace('-', '_', arg(3)); + $vars['regions'] = nodeformcols_form_regions($type); +} diff --git a/sites/all/modules/contrib/nodeformcols/nodeformcols.api.php b/sites/all/modules/contrib/nodeformcols/nodeformcols.api.php new file mode 100644 index 0000000..d3a6856 --- /dev/null +++ b/sites/all/modules/contrib/nodeformcols/nodeformcols.api.php @@ -0,0 +1,60 @@ + 'custom'); + } +} + +/** + * Alter the form data before being placed by nodeformcols_form_alter(). + * + * @param array $form + */ +function hook_nodeformcols_pre_form_alter(&$form){ +} + +/** + * Alter the form data after being placed by nodeformcols_form_alter(). + * + * @param array $form + */ +function hook_nodeformcols_post_form_alter(&$form){ +} + +/** + * Perform alterations on a form before being placed on the node form. + * + * This hook is invoked by template_preprocess_node_form(). + * + * @param array $form + */ +function hook_nodeformcols_pre_placement_alter(&$form){ +}