Commit 66c8e6f9 authored by NancyDru's avatar NancyDru

Fix branching error

parent dee820d9
......@@ -19,4 +19,13 @@ UNINSTALL:
Go to admin/settings/weight/setup/disable
and click "Remove Weights".
Disable the module.
\ No newline at end of file
Disable the module.
TO CREATE AN ORDERABLE VIEW:
Create a view as normal with a "page" display
Change the view style to "weight changer"
Include Field Weight.
Sort by Weight DESC.
Ensure only appropriate roles have access to the view.
Load up the view, reorder, and save!
......@@ -15,3 +15,11 @@ products.
Nodes will be sorted first by stickiness, then by weight, then by creation
date.
TO CREATE AN ORDERABLE VIEW (Admins can reweight nodes using drag-and-drop):
* Create a view as normal with a "page" display
* Change the view style to "weight changer"
* Include Field Weight (though not as the first field you include).
* Sort by Weight DESC.
* Ensure only appropriate roles have access to the view.
* Load up the view, reorder, and save!
......@@ -3,16 +3,17 @@
# LANGUAGE translation of Drupal (general)
# Copyright YEAR NAME <EMAIL@ADDRESS>
# Generated from files:
# weight.views.inc: n/a
# weight.module,v 1.22 2007/05/24 03:38:37 hlslaughter
# weight.info,v 1.2 2007/05/24 03:38:37 hlslaughter
# weight.install,v 1.1 2007/05/24 03:22:30 hlslaughter
# weight.views.inc,v 1.5 2008/11/14 01:41:05 nancyw
# weight.module,v 1.27 2009/01/01 23:19:08 nancyw
# weight.info,v 1.4 2008/09/27 00:05:46 nancyw
# weight.module,v 1.26 2008/11/13 17:48:14 nancyw
# weight.install,v 1.2 2008/09/27 00:05:46 nancyw
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2008-09-13 14:29-0400\n"
"POT-Creation-Date: 2009-01-01 20:19-0500\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
......@@ -21,110 +22,126 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: weight.views.inc:16
msgid "Weight: Sticky"
#: weight.views.inc:13;24;32 weight.module:50 weight.info:0
msgid "Weight"
msgstr ""
#: weight.views.inc:25
msgid "The node weight."
msgstr ""
#: weight.views.inc:17
msgid "Yes"
#: weight.views.inc:51
msgid "Weight Changer"
msgstr ""
#: weight.views.inc:17
msgid "No"
#: weight.views.inc:52
msgid "Displays rows in a table which allows weight change. Be sure to add the Weight field and Sort by Weight."
msgstr ""
#: weight.views.inc:19
msgid "Filter by whether or not the node is set sticky."
#: weight.views.inc:121
msgid "sort by @s"
msgstr ""
#: weight.views.inc:19
msgid "Use \"Weight: Sticky\" as a replacement for \"Node: Sticky\" when the weight module is enabled."
#: weight.views.inc:215
msgid "Save"
msgstr ""
#: weight.module:16;52 weight.info:0
#: weight.module:16;52 weightx.module:16 weight.info:0
msgid "Add weight-based sorting to nodes."
msgstr ""
#: weight.module:18
#: weight.module:18 weightx.module:18
msgid "<h3>Description:</h3><p>The weight module adds a weight option to enabled node types. It uses the \"sticky\" field in the database to store weights as well as sticky information (so that feature is not lost). Nodes will be sorted first by stickiness, then by weight (lightest to heaviest), then by creation date.</p>\r\n <h4>Setup:</h4><p>To enable weight sorting on existing nodes, visit the <a href=\"@setup\">weight db setup page</a> and click \"Setup Database\" to convert old sticky values to new weight-encoded values for proper sorting.</p>\r\n <h4>Permissions:</h4><p>Users with \"administer nodes\" permission will always be able to adjust weight for enabled node types. However, enabling \"assign node weight\" will allow non-node-admin users to adjust weight on their own nodes. Find these settings <a href=\"@access\">here</a>.</p>\r\n <h4>Bulk weight management</h4><p>You may easily manage the weight of multiple nodes simultaneously by using the <a href=\"@node_admin\"> node admin page</a>.</p>"
msgstr ""
#: weight.module:145
#: weight.module:143
msgid "<strong>Note:</strong> When the weight module is enabled,\r\n it is not possible to filter based on sticky status."
msgstr ""
#: weight.module:153
#: weight.module:151 weightx.module:144
msgid "<strong>Weight:</strong> To change the weight of a node, select a value from the corresponding dropdown box under <i>@operations</i>. Node weights are submitted immediately. Selectors are only available for node types configured on the <a href=\"@weight_admin\">weight admin page</a>."
msgstr ""
#: weight.module:180;187
#: weight.module:154 weightx.module:147
msgid "Operations"
msgstr ""
#: weight.module:178;186 weightx.module:180;187
msgid "Node Weight"
msgstr ""
#: weight.module:190
#: weight.module:189 weightx.module:190
msgid "In a node list context (such as the front page or term pages), list items (e.g. \"teasers\") will be ordered by \"stickiness\" then by \"node weight\" then by \"authored on\" datestamp. Items with a lower (lighter) node weight value will appear above those with a higher (heavier) value."
msgstr ""
#: weight.module:198;213
#: weight.module:193
msgid "<strong>Note</strong>: If this node is used in a menu, then this weight will be ignored."
msgstr ""
#: weight.module:201;216 weightx.module:207;222
msgid "Setup Database"
msgstr ""
#: weight.module:203
#: weight.module:206 weightx.module:212
msgid "<p>The weight module uses the node table's 'sticky' column to store weight information for each node. New and updated nodes will automatically have their sticky and weight information remapped. However if you have pre-existing nodes, you will need to update your database so that these nodes sort correctly with new nodes.</p>\r\n <p>%count nodes need to be updated.</p>"
msgstr ""
#: weight.module:219;232
#: weight.module:222;235 weightx.module:228;241
msgid "Remove weights"
msgstr ""
#: weight.module:223
#: weight.module:226 weightx.module:232
msgid "<p>Before disabling the weight module, you will want to click this button to change the database back to Drupal's conventional sticky system.</p>\r\n <p><strong>NOTE: Clicking this button will erase any node weights that have been set.</strong></p>"
msgstr ""
#: weight.module:238;279
#: weight.module:240;285 weightx.module:247;288
msgid "Update"
msgstr ""
#: weight.module:245
#: weight.module:245 weightx.module:254
msgid "Settings updated."
msgstr ""
#: weight.module:257
#: weight.module:256 weightx.module:266
msgid "Node Weight Range"
msgstr ""
#: weight.module:260
#: weight.module:259 weightx.module:269
msgid "<p>This will be the +/- range for node weight.</p>"
msgstr ""
#: weight.module:265
#: weight.module:264
msgid "Use Menu Weight"
msgstr ""
#: weight.module:266
msgid "<p>If the node has not been weighted, should we use the menu item weight?</p>"
msgstr ""
#: weight.module:271 weightx.module:274
msgid "Display On"
msgstr ""
#: weight.module:268
#: weight.module:274 weightx.module:277
msgid "<p>Add node weighting to these content types.</p>\r\n <p><i>Note:</i> Unselecting a node type after having changed weights\r\n for nodes of that type will leave these nodes with the current weight.\r\n You may want to check the <a href=\"@posts_page\">Post page</a>. Before\r\n unsetting any node types."
msgstr ""
#: weight.module:295
#: weight.module:302 weightx.module:305
msgid " nodes updated to support weight.module"
msgstr ""
#: weight.module:298
#: weight.module:305 weightx.module:308
msgid "No nodes needed to be updated."
msgstr ""
#: weight.module:310
msgid "All node weights have been removed. Please deactivate weight module now."
#: weight.module:318 weightx.module:321
msgid "All node weights have been removed. Please deactivate the Weight module now."
msgstr ""
#: weight.module:32
msgid "assign node weight"
msgstr ""
#: weight.module:50 weight.info:0
msgid "Weight"
msgstr ""
#: weight.module:58
msgid "Settings"
msgstr ""
......@@ -145,6 +162,14 @@ msgstr ""
msgid "weight"
msgstr ""
#: weightx.module:138
msgid "<strong>Note:</strong> When the weight module is enabled, it is not possible to filter based on sticky status."
msgstr ""
#: weightx.module:0
msgid "weightx"
msgstr ""
#: weight.install:14
msgid "Weight module is now enabled. You must now update your nodes using the <a href=\"!url\">Weight DB setup page</a>"
msgstr ""
......
<?php
/* $Id$
/**
* @file
* Views template for Weight module.
*/
?>
<table class="<?php print $class; ?>" id="<?php print $id; ?>">
<thead>
<tr>
<?php if (count($header)): ?>
<?php foreach ($header as $field => $label): ?>
<th class="views-field views-field-<?php print $fields[$field]; ?>">
<?php print $label; ?>
</th>
<?php endforeach; ?>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php if (count($rows)): ?>
<?php foreach ($rows as $count => $row): ?>
<tr class="<?php print ($count % 2 == 0) ? 'even' : 'odd';?> draggable">
<?php foreach ($row as $field => $content): ?>
<td class="views-field views-field-<?php print isset($fields[$field]) ? $fields[$field] : '' ?>">
<?php print $content; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php print $submit; ?>
/* $Id: */
/**
* @file style sheet for Weight module.
*/
.weight-selector {
display: inline;
position: relative;
float: left;
/* margin: 0 0 0 5px; */
}
#node-admin-nodes td a {
margin-right: 3px;
}
\ No newline at end of file
......@@ -29,4 +29,5 @@ function weight_uninstall() {
// Delete our variables.
variable_del('weight_node_types');
variable_del('weight_range');
variable_del('weight_use_menu');
}
This diff is collapsed.
<?php
function weight_views_tables() {
$tables['node_by_weight'] = array(
'name' => 'node',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'nid',
),
'right' => array(
'field' => 'nid',
// $Id$
/**
* @file
* Views2 support for Weight module.
*/
/**
* Implementation of hook_views_data()
*/
function weight_views_data() {
$data['node_weight'] = array(
'table' => array(
'group' => t('Weight'),
'join' => array(
'node' => array(
'table' => 'node',
'left_field' => 'nid',
'field' => 'nid',
),
),
),
'weight' => array(
'real field' => 'sticky',
'title' => t('Weight'), // The item it appears as on the UI,
'help' => t('The node weight.'), // The help that appears on the UI,
'field' => array(
'handler' => 'weight_handler_field_sticky',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
'label' => t('Weight'),
),
'sort' => array(
'handler' => 'weight_handler_sort',
),
),
'filters' => array(
'sticky' => array(
'name' => t('Weight: Sticky'),
'operator' => array('>' => t('Yes'), '<=' => t('No')),
'value' => array('#type' => 'value', '#value' => '0'),
'help' => t('Filter by whether or not the node is set sticky.') .' '. t('Use "Weight: Sticky" as a replacement for "Node: Sticky" when the weight module is enabled.'),
),
);
return $data;
}
/**
* Implementation of hook_views_plugins();
*/
function weight_views_plugins() {
return array(
'style' => array(
'weight' => array(
'title' => t('Weight Changer'),
'help' => t('Displays rows in a table which allows weight change. Be sure to add the Weight field and Sort by Weight.'),
'handler' => 'views_plugin_style_table',
'parent' => 'table',
'path' => drupal_get_path('module', 'weight'),
'theme' => 'weight_view_weight',
'uses row plugin' => FALSE,
'uses fields' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
),
),
);
}
/**
* Implementation of hook_views_handlers().
*/
function weight_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'weight') /*.'/handlers'*/,
),
'handlers' => array(
'weight_handler_field_sticky' => array(
'parent' => 'views_handler_field_numeric',
),
'weight_handler_sort' => array(
'parent' => 'views_handler_sort',
),
),
);
}
/**
* Display a view as a weight changing table.
*/
function theme_weight_view_weight($view, $rows, $type) {
$result = $view->result;
$rows = array();
$options = $view->style_plugin->options;
$handler = $view->style_plugin;
$fields = &$view->field;
$columns = $handler->sanitize_columns($options['columns'], $fields);
$active = !empty($handler->active) ? $handler->active : '';
$order = !empty($handler->order) ? $handler->order : 'asc';
$query = tablesort_get_querystring();
if ($query) {
$query = '&'. $query;
}
foreach ($columns as $field => $column) {
// render the header labels
if ($field == $column && empty($fields[$field]->options['exclude'])) {
$label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : '');
if (empty($options['info'][$field]['sortable'])) {
$header[$field] = $label;
}
else {
// @todo -- make this a setting
$initial = 'asc';
if ($active == $field && $order == 'asc') {
$initial = 'desc';
}
$image = theme('tablesort_indicator', $initial);
$title = t('sort by @s', array('@s' => $label));
$link_options = array(
'html' => TRUE,
'attributes' => array('title' => $title),
'query' => 'order='. urlencode($field) .'&sort='. $initial . $query,
);
$header[$field] = l($label . $image, $_GET['q'], $link_options);
}
}
// Create a second variable so we can easily find what fields we have and what the
// CSS classes should be.
$weight_fields[$field] = views_css_safe($field);
if ($active == $field) {
$weight_fields[$field] .= ' active';
}
// Render each field into its appropriate column.
foreach ($result as $num => $row) {
if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) {
$field_output = $fields[$field]->theme($row);
// Don't bother with separators and stuff if the field does not show up.
if (!isset($field_output) && isset($rows[$num][$column])) {
continue;
}
// Place the field into the column, along with an optional separator.
if (isset($rows[$num][$column])) {
if (!empty($options['info'][$column]['separator'])) {
$rows[$num][$column] .= filter_xss_admin($options['info'][$column]['separator']);
}
}
else {
$rows[$num][$column] = '';
}
$rows[$num][$column] .= $field_output;
}
}
}
$class = 'views-table-weight';
if (!empty($options['sticky'])) {
drupal_add_js('misc/tableheader.js');
$class .= " sticky-enabled";
}
// Pass along the nid.
foreach ($view->result as $count => $item) {
$rows[$count]['nid_hidden'] = $item->nid;
}
$id = $view->name .'_drag';
return drupal_get_form('weight_view_weight_form', $header, $rows, $weight_fields, $class, $id);
}
/**
* Display a view as a weight changing table.
*/
function weight_view_weight_form(&$form_state, $header, $rows, $fields, $class, $id) {
// Make this form draggable
drupal_add_tabledrag($id, 'order', 'sibling', 'weight_dragger');
$form = array('#tree' => TRUE);
$form['#variables'] = array(
'header' => $header,
'class' => $class,
'fields' => $fields,
'id' => $id,
);
foreach ($rows as $count => $row) {
if (is_numeric($count)) {
foreach ($row as $field => $content) {
$nid = $row['nid_hidden'];
if (substr($field, 0, 6) == 'weight') {
$form['rows'][$count][$field] = array(
'#default_value' => $content,
'#type' => 'weight',
'#delta' => variable_get('weight_range', 20),
);
}
elseif ($field != 'nid_hidden') {
$form['rows'][$count][$field] = array(
'#value' => $content,
);
}
else {
$form['rows'][$count][$field] = array(
'#type' => 'hidden',
'#value' => $content,
);
}
}
}
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}
return $tables;
}
\ No newline at end of file
/**
* Save the changed weights.
*/
function weight_view_weight_form_submit($form, &$form_state) {
foreach ($form_state['values']['rows'] as $count => $value) {
$weight = $value['weight'];
$nid = $value['nid_hidden'];
$node = node_load($nid);
if ($node->sticky) {
$node->sticky = (-1 * $weight) + 100;
}
// Unweighted non-sticky nodes will have a value of -100.
else {
$node->sticky = (-1 * $weight) - 100;
}
db_query("UPDATE {node} SET sticky = %d WHERE nid = %d", $node->sticky, $nid);
}
drupal_set_message('Your weight changes have been saved.');
}
<?php
// $Id$
/**
* @file
* Field handler for Weight module.
*/
class weight_handler_field_sticky extends views_handler_field_numeric {
function render($values) {
$value = $values->{$this->field_alias};
// convert sticky values to corresponding weights.
if ($value > 0) {
$value = $value == 1 ? 0 : (100 - $value);
}
else {
$value = $value == 0 ? 0 : -($value + 100);
}
if (!empty($this->options['set_precision'])) {
$value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']);
}
else {
$remainder = abs($value) - intval(abs($value));
$value = number_format($value, 0, '', $this->options['separator']);
if ($remainder) {
$value .= $this->options['decimal'] . $remainder;
}
}
return check_plain($this->options['prefix'] . $value . $this->options['suffix']);
}
}
<?php
// $Id$
/**
* @file
* Sort handler for Weight module.
*/
class weight_handler_sort extends views_handler_sort {
function query() {
$this->ensure_my_table();
// Reverse ASC and DESC for weight order so that the sticky weights are ordered like real weights.
if ($this->options['order'] == 'ASC') {
$this->options['order'] = 'DESC';
}
elseif ($this->options['order'] == 'DESC') {
$this->options['order'] = 'ASC';
}
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
}
}
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