/**
  * @return void
  * @desc Re-build from data posted by this control the data object this control is editing
  */
 function BuildPostedDataObject()
 {
     /* @var $o_category Category */
     $o_category = new Category();
     if (isset($_POST['item'])) {
         $o_category->SetId($_POST['item']);
     }
     $o_category->SetName($_POST['displayName']);
     $o_category->SetParentId($_POST['parent_id']);
     $o_category->SetUrl($_POST['name']);
     $o_category->SetSortOverride($_POST['sort']);
     $this->SetDataObject($o_category);
 }
 /**
  * Updates the derived hierarchy data stored in the database
  *
  * @param Object which can generate the category URLs $url_manager
  * @param Name of method to generate the category URLs $url_method
  */
 public function UpdateHierarchyData($url_manager, $url_method)
 {
     # Fresh start
     $this->Clear();
     $categories = array();
     $o_sorted_categories = new CategoryCollection();
     $category_table = $this->GetSettings()->GetTable('Category');
     # First, get all the categories from the db
     $s_sql = "SELECT id, parent, code FROM {$category_table} ORDER BY sort_override, name";
     $result = $this->GetDataConnection()->query($s_sql);
     while ($o_row = $result->fetch()) {
         $o_category = new Category();
         $o_category->SetId($o_row->id);
         $o_category->SetParentId($o_row->parent);
         $o_category->SetUrl($o_row->code);
         $categories[] = $o_category;
     }
     $result->closeCursor();
     # Sort the categories, generating hierarchy data including a URL
     $a_stack = array();
     $this->GatherChildCategories($a_stack, $categories, $o_sorted_categories, $url_manager, $url_method);
     # Now write that hierarchy data back to the db
     $i = 0;
     foreach ($o_sorted_categories as $category) {
         /* @var $category Category */
         $s_sql = "UPDATE {$category_table} SET " . "navigate_url = " . Sql::ProtectString($this->GetDataConnection(), $category->GetNavigateUrl(), false) . ", " . "hierarchy_level = " . Sql::ProtectNumeric($category->GetHierarchyLevel()) . ", " . "hierarchy_sort = {$i} " . "WHERE id = " . Sql::ProtectNumeric($category->GetId());
         $i++;
         $this->GetDataConnection()->query($s_sql);
     }
 }