Commit bbc213ca authored by Ben Davis's avatar Ben Davis

Reverting last commit

parent 3dc29658
......@@ -53,7 +53,7 @@ function weight_settings_form() {
$form['weight_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Display On'),
'#default_value' => weight_get_node_types(),
'#default_value' => variable_get('weight_node_types', $types),
'#options' => $types,
'#description' => '<p>' . t('Select the content types to be weighted.
The selected content types will be mass updated to the default weight</p>
......@@ -88,25 +88,21 @@ function weight_settings_form_submit($form, &$form_state) {
variable_set('weight_label', $form_state['values']['weight_label']);
// Check for changes in the list.
$before = array_filter(weight_get_node_types());
$before = array_filter(variable_get('weight_node_types', array()));
$after = array_filter($form_state['values']['weight_node_types']);
$del = array_diff($before, $after);
$add = array_diff($after, $before);
// Add weighting to new types.
if ($add) {
weight_old_nodes($add);
foreach ($add as $type) {
variable_set('weight_node_type_' . $type, TRUE);
}
}
// Remove weighting from types taken out of the list.
if ($del) {
weight_disable($del);
foreach ($del as $type) {
variable_del('weight_node_type_' . $type);
}
}
variable_set('weight_node_types', $after);
drupal_set_message(t('Settings updated.'));
}
......
......@@ -85,7 +85,7 @@ function weight_theme_registry_alter(&$theme_registry) {
* Implements hook_node_presave().
*/
function weight_node_presave($node) {
$weight_node_types = weight_get_node_types();
$weight_node_types = variable_get('weight_node_types', array_flip(node_type_get_names()));
if (in_array($node->type, $weight_node_types)) {
// Non-weighted nodes have a weight of zero.
if (is_null($node->node_weight)) {
......@@ -106,7 +106,7 @@ function weight_node_presave($node) {
* Implements hook_node_load().
*/
function weight_node_load($nodes, $types) {
$weight_node_types = weight_get_node_types();
$weight_node_types = variable_get('weight_node_types', array_flip(node_type_get_names()));
foreach ($nodes as $node) {
if (in_array($node->type, $weight_node_types)) {
_weight_decode($node);
......@@ -121,7 +121,7 @@ function weight_node_load($nodes, $types) {
* @ingroup themeable
*/
function theme_weight_node_admin_nodes($form) {
$weight_node_types = weight_get_node_types();
$weight_node_types = variable_get('weight_node_types', array_flip(node_type_get_names()));
$weight_node_type_names = array();
foreach ($weight_node_types as $type) {
......@@ -234,7 +234,7 @@ function weight_node_selector($nid) {
* and add some help text to the form.
*/
function weight_form_alter(&$form, &$form_state, $form_id) {
$weight_node_types = weight_get_node_types();
$weight_node_types = variable_get('weight_node_types', array_flip(node_type_get_names()));
// Node edit page weight selector.
if (!empty($form['#node_edit_form'])) {
......@@ -395,16 +395,3 @@ function template_preprocess_weight_view_weight_form(&$vars) {
$vars['submit'] = drupal_render_children($form);
}
/**
* Returns a list of types where weight is enabled
*/
function weight_get_node_types() {
$types = node_type_get_names();
$enabled_types = array();
foreach (array_keys($types) as $key) {
if (variable_get('weight_node_type_' . $key, FALSE)) {
$enabled_types[] = $key;
}
}
return $enabled_types;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment