Index: draggableviews_handler_flag_weights.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flag_weights/Attic/draggableviews_handler_flag_weights.inc,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 draggableviews_handler_flag_weights.inc --- draggableviews_handler_flag_weights.inc 10 Jan 2009 02:48:58 -0000 1.1.2.1 +++ draggableviews_handler_flag_weights.inc 23 Feb 2009 10:30:32 -0000 @@ -3,7 +3,7 @@ /** * @file -* The default implementation for draggableviews. +* Flag weights implementation for draggableviews. */ /* @@ -21,6 +21,9 @@ class draggableviews_handler_flag_weight $this->field = $view->field[$field_name]; $this->flag_id = $view->relationship['flag_content_rel']->definition['extra'][0]['value']; + + $this->view = $view; + $this->pager = $view->pager; } function save($nid, $value) { @@ -31,29 +34,28 @@ class draggableviews_handler_flag_weight } function get_form_element($value, $attributes = array()) { - $display = 'select'; // TODO: get from somewhere else - switch ($display) { - - case 'hidden': - return array( - '#type' => 'hidden', - '#name' => $attributes['field_name'], - '#value' => $value, - '#attributes' => array('class' => $attributes['class']), - ); - - default: - return array( - '#type' => 'select', - '#name' => $attributes['field_name'], - '#value' => $value, - // slice out the first and the last element, so we make it possible - // that new nodes may appear on the very top or the very bottom - '#options' => array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20), - '#attributes' => array('class' => $attributes['class']), - ); - + $options = array(); + // if items per page are limitated show only the limited set of values. + // This makes nodes from a certain page independent from other pages (assumed that + // there's no hidden node with an order value that refers to the current page). + if ($this->pager['items_per_page'] > 0) { + $start = $this->pager['items_per_page'] * $this->pager['current_page']; + $end = $start + $this->pager['items_per_page']; } + else { + $start = 0; + $end = count($this->view->result); + } + for ($i = $start; $i < $end; $i++) $options[$i] = $i; + + return array( + '#type' => 'select', + '#name' => $attributes['field_name'], + '#value' => $value, + '#options' => $options, + '#attributes' => array('class' => $attributes['class']), + ); + break; }