/** * Simple helper which references all important members to the request data listing * for usage within the style listing. */ private function _prepare_request_data() { $this->_request_data['article'] =& $this->_article; $this->_request_data['datamanager'] =& $this->_datamanager; // Populate the toolbar if ($this->_article->can_do('midgard:update')) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "edit/{$this->_article->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e')); } $article = $this->_article; if ($this->_article->topic !== $this->_content_topic->id) { $qb = net_nehmer_static_link_dba::new_query_builder(); $qb->add_constraint('topic', '=', $this->_content_topic->id); $qb->add_constraint('article', '=', $this->_article->id); if ($qb->count() === 1) { // Get the link $results = $qb->execute_unchecked(); $article = $results[0]; } } if ($article->can_do('midgard:delete')) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "delete/{$this->_article->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd')); } }
/** * Displays an article delete confirmation view. * * Note, that the article for non-index mode operation is automatically determined in the can_handle * phase. * * If create privileges apply, we relocate to the index creation article * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_article = new midcom_db_article($args[0]); // Relocate to delete the link instead of the article itself if ($this->_article->topic !== $this->_content_topic->id) { return new midcom_response_relocate("delete/link/{$args[0]}/"); } $this->_article->require_do('midgard:delete'); $this->_load_datamanager(); if (array_key_exists('net_nehmer_static_deleteok', $_REQUEST)) { // Deletion confirmed. if (!$this->_article->delete()) { throw new midcom_error("Failed to delete article {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string()); } // Delete all the links pointing to the article $qb = net_nehmer_static_link_dba::new_query_builder(); $qb->add_constraint('article', '=', $this->_article->id); $links = $qb->execute_unchecked(); midcom::get('auth')->request_sudo('net.nehmer.static'); foreach ($links as $link) { $link->delete(); } midcom::get('auth')->drop_sudo(); // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_article->guid); // Delete ok, relocating to welcome. return new midcom_response_relocate(''); } if (array_key_exists('net_nehmer_static_deletecancel', $_REQUEST)) { // Redirect to view page. return new midcom_response_relocate("{$this->_article->name}/"); } $this->_prepare_request_data(); $this->bind_view_to_object($this->_article, $this->_datamanager->schema->name); midcom::get('style')->append_substyle('admin'); midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid); midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}"); $this->set_active_leaf($this->_article->id); $this->_update_breadcrumb_line($handler_id); }