Esempio n. 1
0
 public function save()
 {
     parent::save();
     // save new location in tag tree / net
     if ($this->_newLocation()) {
         $position_array = $this->_getPositionArray();
         $position_old_array = $this->_getOldPositionArray();
         $new = false;
         // only tree / not net
         if (isset($position_old_array[0])) {
             $diff = array_diff($position_array[0], $position_old_array[0]);
         } else {
             $diff = $position_array[0];
             $new = true;
         }
         $father = '';
         if (!empty($diff['father'])) {
             $father = $position_array[0]['father'];
         }
         $place = '';
         if (!empty($diff['place'])) {
             $place = $position_array[0]['place'];
         }
         $tag2tag_manager = $this->_environment->getTag2TagManager();
         if (!empty($father)) {
             // delete old position
             if (!$new) {
                 $tag2tag_manager->delete($position_old_array[0]['father'], $this->getItemID());
             }
             // insert new position
             $tag2tag_manager->insert($this->getItemID(), $father, $position_array[0]['place']);
         } elseif (!empty($place)) {
             // change position
             $tag2tag_manager->change($this->getItemID(), $position_old_array[0]['father'], $place);
         }
         unset($tag2tag_manager);
     }
 }