/** * Loads the comments, does any processing according to the state of the GET list. * On successful processing we relocate once to ourself. * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. * @return boolean Indicating success. */ function _handler_comments($handler_id, array $args, array &$data) { if (!mgd_is_guid($args[0])) { throw new midcom_error("The GUID '{$args[0]}' is invalid. Cannot continue."); } $this->_objectguid = $args[0]; midcom::get('cache')->content->register($this->_objectguid); if ($handler_id == 'view-comments-nonempty') { $this->_comments = net_nehmer_comments_comment::list_by_objectguid_filter_anonymous($this->_objectguid, $this->_config->get('items_to_show'), $this->_config->get('item_ordering'), $this->_config->get('paging')); } else { $this->_comments = net_nehmer_comments_comment::list_by_objectguid($this->_objectguid, $this->_config->get('items_to_show'), $this->_config->get('item_ordering'), $this->_config->get('paging')); } if ($this->_config->get('paging') !== false) { $data['qb_pager'] = $this->_comments; $this->_comments = $this->_comments->execute(); } if (midcom::get('auth')->user || $this->_config->get('allow_anonymous')) { $this->_init_post_controller(); $this->_process_post(); // This might exit. } if ($this->_comments) { $this->_init_display_datamanager(); } $this->_process_admintoolbar(); // This might exit. if ($handler_id = 'view-comments-custom' && count($args) > 1) { midcom::get()->skip_page_style = true; $this->custom_view = $args[1]; } $this->_prepare_request_data(); midcom::get('metadata')->set_request_metadata($this->_get_last_modified(), $this->_objectguid); if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { midcom::get()->skip_page_style = true; } }
<?php // This is a style element so the XML output can easily be modified to whatever is needed: DOAP, ... $mapper = new midcom_helper_xml_objectmapper(); $label = $data['datamanager']->schema->name; if ($label == 'default') { $label = 'product'; } $extradata = array(); if (midcom::get('componentloader')->is_installed('net.nehmer.comments')) { $comments_db = net_nehmer_comments_comment::list_by_objectguid_filter_anonymous($data['product']->guid); foreach ($comments_db as $i => $comment) { $extradata['comments'][] = array('guid' => $comment->guid, 'author' => $comment->author, 'title' => $comment->title, 'content' => $comment->content, 'published' => $comment->metadata->published, 'rating' => $comment->rating); } } echo $mapper->dm2data($data['datamanager'], $label, $extradata);