/** * delete a plugin item * * @param array whith id [fieldname => value] * @param string name of the tag that is being deleted * @param integer id of the tree * @return void */ public function deletePlugin($values, $plugin_type) { $ref = $this->getObject($plugin_type); switch ($plugin_type) { case self::TYPE_DEFAULT: require_once 'GalleryTreeRef.php'; $treeref = new GalleryTreeRef(); $key = array('ref_tree_id' => $values['tree_id']); $treeref->delete($key); $key = array('tree_id' => $values['tree_id'], 'tag' => $values['tag']); // delete settings $settings = $this->getObject(self::TYPE_SETTINGS); $settings->delete($key); $list = $ref->getList($key); foreach ($list['data'] as $item) { $key = $ref->getKey($item); $ref->delete($key); } break; default: $key = $ref->getKey($values); $ref->delete($key); } }
private function handleTreeEditPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); if ($this->exists($key)) { $this->update($key, $values); } else { $this->insert($values); } $treeRef = new GalleryTreeRef(); $treeRef->delete($key); foreach ($values['ref_tree_id'] as $ref_tree_id) { $key['ref_tree_id'] = $ref_tree_id; $treeRef->insert($key); } viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->plugin->getReferer()->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleTreeEditGet(false); } }