public function _update_breadcrumb($handler_id) { // Get common breadcrumb for the product $breadcrumb = org_openpsa_products_viewer::update_breadcrumb_line($this->_object); // Handler-based additions switch ($handler_id) { case 'edit_product': $breadcrumb[] = array(MIDCOM_NAV_URL => '', MIDCOM_NAV_NAME => sprintf($this->_l10n_midcom->get('edit %s'), $this->_l10n->get('product'))); break; case 'delete_product': $breadcrumb[] = array(MIDCOM_NAV_URL => '', MIDCOM_NAV_NAME => sprintf($this->_l10n_midcom->get('delete %s'), $this->_l10n->get('product'))); break; } midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $breadcrumb); }
/** * Looks up a product to display. * * @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_view($handler_id, array $args, array &$data) { if (preg_match('/_raw$/', $handler_id)) { midcom::get()->skip_page_style = true; } $this->_productlink = new org_openpsa_products_product_link_dba($args[0]); $data['controller'] = null; $data['datamanager'] = new midcom_helper_datamanager2_datamanager($data['schemadb_productlink']); if (!$data['datamanager']->autoset_storage($this->_productlink)) { throw new midcom_error("Failed to create a DM2 instance for productlink {$this->_productlink->guid}."); } $this->_prepare_request_data(); $this->bind_view_to_object($this->_productlink, $data['datamanager']->schema->name); $breadcrumb = org_openpsa_products_viewer::update_breadcrumb_line($this->_productlink); midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $breadcrumb); midcom::get('metadata')->set_request_metadata($this->_productlink->metadata->revised, $this->_productlink->guid); // midcom::get('head')->set_pagetitle($this->_request_data['view_title']); }
/** * Looks up a product to display. * * @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_view($handler_id, array $args, array &$data) { if (preg_match('/_raw$/', $handler_id)) { midcom::get()->skip_page_style = true; } $qb = org_openpsa_products_product_dba::new_query_builder(); if (preg_match('/^view_product_intree/', $handler_id)) { $group_qb = org_openpsa_products_product_group_dba::new_query_builder(); if (mgd_is_guid($args[0])) { $group_qb->add_constraint('guid', '=', $args[0]); } else { $group_qb->add_constraint('code', '=', $args[0]); } $groups = $group_qb->execute(); if (empty($groups)) { throw new midcom_error_notfound("Product group {$args[0]} not found"); } $categories_mc = org_openpsa_products_product_group_dba::new_collector('up', $groups[0]->id); $categories_in = $categories_mc->get_values('id'); if (count($categories_in) == 0) { /* No matching categories belonging to this group * So we can search for the application using only * this group id */ $qb->add_constraint('productGroup', 'INTREE', $groups[0]->id); } else { $categories_in[] = $groups[0]->id; $qb->add_constraint('productGroup', 'IN', $categories_in); } if (mgd_is_guid($args[1])) { $qb->add_constraint('guid', '=', $args[1]); } else { $qb->add_constraint('code', '=', $args[1]); } } else { if (mgd_is_guid($args[0])) { $qb->add_constraint('guid', '=', $args[0]); } else { $qb->add_constraint('code', '=', $args[0]); } } if ($this->_config->get('enable_scheduling')) { $qb->add_constraint('start', '<=', time()); $qb->begin_group('OR'); /* * List products that either have no defined end-of-market dates * or are still in market */ $qb->add_constraint('end', '=', 0); $qb->add_constraint('end', '>=', time()); $qb->end_group(); } $results = $qb->execute(); $this->_request_data['is_linked_from'] = ''; if (!empty($results)) { $this->_product = $results[0]; if ($this->_config->get('enable_productlinks') && $this->_product->productGroup != 0) { $root_group_guid = $this->_config->get('root_group'); if ($root_group_guid != '') { $root_group = org_openpsa_products_product_group_dba::get_cached($root_group_guid); } if ($root_group->id != $this->_product->productGroup) { $product_group = new org_openpsa_products_product_group_dba($this->_product->productGroup); $mc_intree = org_openpsa_products_product_group_dba::new_collector('id', $product_group->id); $mc_intree->add_constraint('up', 'INTREE', $root_group->id); $count = $mc_intree->count(); if ($count == 0) { $mc_intree = org_openpsa_products_product_link_dba::new_collector('product', $this->_product->id); $mc_intree->add_constraint('productGroup', 'INTREE', $root_group->id); $mc_intree->execute(); $results = $mc_intree->list_keys(); if (count($results) > 0) { foreach ($results as $guid => $array) { $this->_request_data['is_linked_from'] = $guid; } } } } } } else { if (preg_match('/^view_product_intree/', $handler_id)) { $this->_product = new org_openpsa_products_product_dba($args[1]); } else { $this->_product = new org_openpsa_products_product_dba($args[0]); } } if ($GLOBALS['midcom_config']['enable_ajax_editing']) { $data['controller'] = midcom_helper_datamanager2_controller::create('ajax'); $data['controller']->schemadb =& $data['schemadb_product']; $data['controller']->set_storage($this->_product); $data['controller']->process_ajax(); $data['datamanager'] =& $data['controller']->datamanager; } else { $data['controller'] = null; $data['datamanager'] = new midcom_helper_datamanager2_datamanager($data['schemadb_product']); if (!$data['datamanager']->autoset_storage($this->_product)) { throw new midcom_error("Failed to create a DM2 instance for product {$this->_product->guid}."); } } $this->_prepare_request_data(); $this->bind_view_to_object($this->_product, $data['datamanager']->schema->name); if (isset($product_group)) { unset($product_group); } $product_group = null; if ($this->_request_data['is_linked_from'] != '') { $linked_product = new org_openpsa_products_product_link_dba($data['is_linked_from']); if ($linked_product->productGroup != 0) { $product_group = new org_openpsa_products_product_group_dba($linked_product->productGroup); } } $breadcrumb = org_openpsa_products_viewer::update_breadcrumb_line($this->_product, $product_group); midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $breadcrumb); midcom::get('metadata')->set_request_metadata($this->_product->metadata->revised, $this->_product->guid); $title = $this->_config->get('product_page_title'); if (strstr($title, '<PRODUCTGROUP')) { try { $productgroup = new org_openpsa_products_product_group_dba($this->_product->productGroup); $title = str_replace('<PRODUCTGROUP_TITLE>', $productgroup->title, $title); $title = str_replace('<PRODUCTGROUP_CODE>', $productgroup->code, $title); } catch (midcom_error $e) { $title = str_replace('<PRODUCTGROUP_TITLE>', '', $title); $title = str_replace('<PRODUCTGROUP_CODE>', '', $title); } } $title = str_replace('<PRODUCT_CODE>', $this->_product->code, $title); $title = str_replace('<PRODUCT_TITLE>', $this->_product->title, $title); $title = str_replace('<TOPIC_TITLE>', $this->_topic->extra, $title); midcom::get('head')->set_pagetitle($title); }