/** * Re-order the *raw_task* list based on a jQuery Sortable list of IDs. * * Used when user does a drag n drop sort on the task list. * Sorting is done in-place, nothing is returned. * * see: http://stackoverflow.com/questions/348410/sort-an-array-based-on-another-array * for details of how this works * * @param array $order New sorting order (array of IDs) * @param string $project Specific Project that should be sorted */ function reorder($order, $project = null) { $order = array_flip($order); //$sorted_items = array_intersect_key($this->parsed_items, $order); $sorted_items = array_merge($order, $this->parsed_items); //$sorted_items = array_merge($this->parsed_items, $sorted_items); // deal with sorting one project by itself if ($project !== null) { $pos = array_search($project, $this->project_index); $this->parsed_items = \tpp\array_insert($this->parsed_items, $pos, $sorted_items, 1, true); } else { $this->parsed_items = $sorted_items; } }
function replace($key, $text) { $new_item = array('new' => $text); self::$_content->raw_items = \tpp\array_insert(self::$_content->raw_items, $key, $new_item); self::update(UPDATE_RAWITEM); }