/** * Shows the autoindex list. Nothing to do in the handle phase except setting last modified * dates. * * @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_feed($handler_id, array $args, array &$data) { midcom::get('componentloader')->load_library('de.bitfolge.feedcreator'); midcom::get('cache')->content->content_type("text/xml; charset=UTF-8"); midcom::get()->header("Content-type: text/xml; charset=UTF-8"); midcom::get()->skip_page_style = true; // Prepare control structures $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb']); // Get the articles, $qb = midcom_db_article::new_query_builder(); net_nehmer_blog_viewer::article_qb_constraints($qb, $data, $handler_id); $qb->add_order('metadata.published', 'DESC'); if ($handler_id == 'feed-category-rss2') { if (!in_array($args[0], $this->_request_data['categories'])) { // This is not a predefined category from configuration, check if site maintainer allows us to show it if (!$this->_config->get('categories_custom_enable')) { throw new midcom_error('Custom category support is disabled'); } } // TODO: Check for ".xml" suffix $this->_request_data['category'] = trim(strip_tags($args[0])); $multiple_categories = true; // TODO: check schema storage to get fieldname if (isset($this->_request_data['schemadb']['default']->fields['categories']) && array_key_exists('allow_multiple', $this->_request_data['schemadb']['default']->fields['categories']['type_config']) && !$this->_request_data['schemadb']['default']->fields['categories']['type_config']['allow_multiple']) { $multiple_categories = false; } debug_add("multiple_categories={$multiple_categories}"); if ($multiple_categories) { $qb->add_constraint('extra1', 'LIKE', "%|{$this->_request_data['category']}|%"); } else { $qb->add_constraint('extra1', '=', (string) $this->_request_data['category']); } } $qb->set_limit($this->_config->get('rss_count')); $this->_articles = $qb->execute(); // Prepare the feed (this will also validate the handler_id) $this->_create_feed($handler_id); midcom::get('metadata')->set_request_metadata(net_nehmer_blog_viewer::get_last_modified($this->_topic, $this->_content_topic), $this->_topic->guid); }
/** * Shows the archive. Depending on the selected handler various constraints are added to * the QB. See the add_*_constraint methods for details. * * @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_list($handler_id, array $args, array &$data) { // Get Articles, distinguish by handler. $qb = midcom_db_article::new_query_builder(); net_nehmer_blog_viewer::article_qb_constraints($qb, $data, $handler_id); // Use helper functions to determine start/end switch ($handler_id) { case 'archive-year-category': if (!$this->_config->get('archive_years_enable')) { throw new midcom_error_notfound('Year archive not allowed'); } $data['category'] = trim(strip_tags($args[1])); $multiple_categories = true; if (isset($data['schemadb']['default']->fields['categories']) && array_key_exists('allow_multiple', $data['schemadb']['default']->fields['categories']['type_config']) && !$data['schemadb']['default']->fields['categories']['type_config']['allow_multiple']) { $multiple_categories = false; } if ($multiple_categories) { $qb->add_constraint('extra1', 'LIKE', "%|{$this->_request_data['category']}|%"); } else { $qb->add_constraint('extra1', '=', (string) $data['category']); } case 'archive-year': if (!$this->_config->get('archive_years_enable')) { throw new midcom_error_notfound('Year archive not allowed'); } $this->_set_startend_from_year($args[0]); break; case 'archive-month': $this->_set_startend_from_month($args[0], $args[1]); break; default: throw new midcom_error("The request handler {$handler_id} is not supported."); } $qb->add_constraint('metadata.published', '>=', $this->_start->format('Y-m-d H:i:s')); $qb->add_constraint('metadata.published', '<', $this->_end->format('Y-m-d H:i:s')); $qb->add_order('metadata.published', $this->_config->get('archive_item_order')); $this->_articles = $qb->execute(); $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb']); // Move end date one day backwards for display purposes. $now = new DateTime(); if ($now < $this->_end) { $this->_end = $now; } else { $this->_end->modify('-1 day'); } $start = $this->_start->format($this->_l10n_midcom->get('short date')); $end = $this->_end->format($this->_l10n_midcom->get('short date')); $this->add_breadcrumb("archive/year/{$args[0]}/", "{$start} - {$end}"); $this->_prepare_request_data(); if ($this->_config->get('archive_in_navigation')) { $this->set_active_leaf($this->_topic->id . '_ARCHIVE'); } else { $this->set_active_leaf($this->_topic->id . '_ARCHIVE_' . $args[0]); } midcom::get('metadata')->set_request_metadata(net_nehmer_blog_viewer::get_last_modified($this->_topic, $this->_content_topic), $this->_topic->guid); midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$start} - {$end}"); }
/** * Shows the autoindex list. Nothing to do in the handle phase except setting last modified * dates. * * @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_index($handler_id, array $args, array &$data) { if ($handler_id == 'ajax-latest') { midcom::get()->skip_page_style = true; } $this->_datamanager = new midcom_helper_datamanager2_datamanager($data['schemadb']); $qb = new org_openpsa_qbpager('midcom_db_article', 'net_nehmer_blog_index'); $data['qb'] =& $qb; net_nehmer_blog_viewer::article_qb_constraints($qb, $data, $handler_id); // Set default page title $data['page_title'] = $this->_topic->extra; // Filter by categories if ($handler_id == 'index-category' || $handler_id == 'latest-category') { $data['category'] = trim(strip_tags($args[0])); if (!($constraint = $this->_process_category_constraint($qb))) { throw new midcom_error('Failed to process category constraint'); } } $qb->add_order('metadata.published', 'DESC'); switch ($handler_id) { case 'index': case 'index-category': $qb->results_per_page = $this->_config->get('index_entries'); break; case 'latest': case 'ajax-latest': $qb->results_per_page = $args[0]; break; case 'latest-category': $qb->results_per_page = $args[1]; break; default: $qb->results_per_page = $this->_config->get('index_entries'); break; } $this->_articles = $qb->execute(); $this->_prepare_request_data(); midcom::get('metadata')->set_request_metadata(net_nehmer_blog_viewer::get_last_modified($this->_topic, $this->_content_topic), $this->_topic->guid); if ($qb->get_current_page() > 1) { $this->add_breadcrumb(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX), sprintf(midcom::get('i18n')->get_string('page %s', 'org.openpsa.qbpager'), $qb->get_current_page())); } }