Exemple #1
0
      * Reordering of sections
      ******************************************************************************/
 } else {
     if ($_REQUEST['reorderSection']) {
         $site_id = db_get_value("slot", "FK_site", "slot_name='" . addslashes($_REQUEST['site']) . "'");
         $orderedSet = new OrderedSet(null);
         $query = "\n\t\tSELECT\n\t\t\tsection_id, section_order\n\t\tFROM\n\t\t\tsection\n\t\tWHERE\n\t\t\tFK_site = '" . addslashes($site_id) . "'\n\t\tORDER BY section_order\t\t\t\n\t";
         printpre($query);
         $r = db_query($query);
         // Populate the Set with the original page order
         while ($a = db_fetch_assoc($r)) {
             printpre($a['section_order'] . "-" . $a['section_id']);
             $orderedSet->addItem($a['section_id']);
         }
         // Move our page to its new position
         $orderedSet->moveToPosition($_REQUEST['reorderSection'], $_REQUEST['newPosition']);
         // Save the new order
         $orderedSet->reset();
         // Make sure the iterator is at the begining.
         $order = 0;
         while ($orderedSet->hasNext()) {
             $item = $orderedSet->next();
             printpre($order . "-" . $item);
             // Update the db
             $query = "\n\t\t\tUPDATE\n\t\t\t\tsection\n\t\t\tSET\n\t\t\t\tsection_order =  '" . addslashes($order) . "'\n\t\t\tWHERE\n\t\t\t\tsection_id = '" . addslashes($item) . "'\n\t\t";
             //printpre($query);
             $r = db_query($query);
             $order++;
         }
         $showorder = "section";
     }
 /**
  * Move the specified id to the specified position in the set.
  * @param object Id $id The Id of the item to move.
  * @param integer $position The new position of the specified id.
  * @access public
  * @return void
  */
 function moveToPosition($id, $position)
 {
     // Store the old order
     $oldOrder = $this->_items;
     // remove the Item
     parent::moveToPosition($id, $position);
     // update the database with the new order keys.
     $this->_updateOrders($oldOrder);
 }