/** * Constructor * * @param midcom_db_topic $topic The current topic * @param midcom_service_indexer $indexer The indexer service */ public function __construct($topic, midcom_services_indexer $indexer = null) { $this->_topic = $topic; $this->_l10n = midcom::get('i18n')->get_l10n($topic->component); if (null === $indexer) { $indexer = midcom::get('indexer'); } $this->_indexer = $indexer; $nav = new midcom_helper_nav(); $this->_node = $nav->get_node($this->_topic->id); }
/** * Tries to determine the topic GUID and component using NAPs reverse-lookup capabilities. * * If this fails, you have to set the members $topic_guid, $topic_url and * $component manually. */ function _process_topic() { $nav = new midcom_helper_nav(); $object = $nav->resolve_guid($this->source); if (!$object) { debug_add("Failed to resolve the topic, skipping autodetection."); return; } if ($object[MIDCOM_NAV_TYPE] == 'leaf') { $object = $nav->get_node($object[MIDCOM_NAV_NODEID]); } $this->topic_guid = $object[MIDCOM_NAV_GUID]; $this->topic_url = $object[MIDCOM_NAV_FULLURL]; $this->component = $object[MIDCOM_NAV_COMPONENT]; }
/** * Indexes a wiki page. * * This function is usually called statically from various handlers. * * @param midcom_helper_datamanager2_datamanager &$dm The Datamanager encapsulating the event. * @param midcom_services_indexer &$indexer The indexer instance to use. * @param midcom_db_topic The topic which we are bound to. If this is not an object, the code * tries to load a new topic instance from the database identified by this parameter. */ function index(&$dm, &$indexer, $topic) { if (!is_object($topic)) { $topic = new midcom_db_topic($topic); } // Don't index directly, that would lose a reference due to limitations // of the index() method. Needs fixes there. $nav = new midcom_helper_nav(); $node = $nav->get_node($topic->id); $document = $indexer->new_document($dm); $document->topic_guid = $topic->guid; $document->topic_url = $node[MIDCOM_NAV_FULLURL]; $document->read_metadata_from_object($dm->storage->object); $document->component = $topic->component; $indexer->index($document); }
/** * @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_search($handler_id, array $args, array &$data) { $this->_request_data['results'] = array(); if (array_key_exists('query', $_GET)) { // Figure out where we are $nap = new midcom_helper_nav(); $node = $nap->get_node($nap->get_current_node()); // Instantiate indexer $indexer = midcom::get('indexer'); // Add the search parameters $query = $_GET['query']; $query .= " AND __TOPIC_URL:\"{$node[MIDCOM_NAV_FULLURL]}*\""; $query .= " AND __COMPONENT:org.openpsa.documents"; // TODO: Metadata support // Run the search $this->_request_data['results'] = $indexer->query($query, null); } $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.documents/layout.css"); $this->_populate_toolbar(); }
/** * Try to find a comments node (cache results) * * @access private */ function seek_comments(&$data) { if ($data['config']->get('comments_topic')) { // We have a specified photostream here $comments_topic = new midcom_db_topic($data['config']->get('comments_topic')); if (!is_object($comments_topic) || !isset($comments_topic->guid) || empty($comments_topic->guid)) { return false; } // We got a topic. Make it a NAP node $nap = new midcom_helper_nav(); $comments_node = $nap->get_node($comments_topic->id); return $comments_node; } // No comments topic specified, autoprobe $comments_node = midcom_helper_find_node_by_component('net.nehmer.comments'); // Cache the data if ($_MIDCOM->auth->request_sudo($data['topic']->component)) { $data['topic']->set_parameter($data['topic']->component, 'comments_topic', $comments_node[MIDCOM_NAV_GUID]); $_MIDCOM->auth->drop_sudo(); } return $comments_node; }
/** * Indexes an article. * * This function is usually called statically from various handlers. * * @param midcom_helper_datamanager2_datamanager &$dm The Datamanager encapsulating the event. * @param midcom_services_indexer &$indexer The indexer instance to use. * @param midcom_db_topic The topic which we are bound to. If this is not an object, the code * tries to load a new topic instance from the database identified by this parameter. */ function index(&$dm, &$indexer, $topic) { if (!is_object($topic)) { $tmp = new midcom_db_topic($topic); if (!$tmp || !$tmp->guid) { $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to load the topic referenced by {$topic} for indexing, this is fatal."); // This will exit. } $topic = $tmp; } // Don't index directly, that would loose a reference due to limitations // of the index() method. Needs fixes there. $nav = new midcom_helper_nav(); $node = $nav->get_node($topic->id); $author = $_MIDCOM->auth->get_user($dm->storage->object->creator); $document = $indexer->new_document($dm); $document->topic_guid = $topic->guid; $document->component = $topic->component; $document->topic_url = $node[MIDCOM_NAV_FULLURL]; $document->read_metadata_from_object($dm->storage->object); $indexer->index($document); }
/** * Method for drawing the navigation. */ public function draw() { if (!$this->root_id) { $this->root_id = $this->_nap->get_root_node(); } if ($this->skip_levels !== 0) { if (!array_key_exists($this->skip_levels, $this->node_path)) { return; } $this->root_id = $this->node_path[$this->skip_levels]; } if ($this->show_only_current) { $this->root_id = $this->_nap->get_current_node(); } $this->_list_child_elements($this->root_id); }
/** * Handle a request. * * The URL of the component that is used to handle the request is obtained automatically. * If the handler hook returns false (i.e. handling failed), it will produce an error page. * * @param midcom_baseclasses_components_interface $handler The component's main handler class */ public function run(midcom_baseclasses_components_interface $handler) { $result = $handler->handle(); if (false === $result) { throw new midcom_error("Component " . $this->get_key(MIDCOM_CONTEXT_COMPONENT) . " failed to handle the request"); } else { if (is_object($result) && $result instanceof midcom_response) { $result->send(); //this will exit } } // Retrieve Metadata $nav = new midcom_helper_nav(); if ($nav->get_current_leaf() === false) { $meta = $nav->get_node($nav->get_current_node()); } else { $meta = $nav->get_leaf($nav->get_current_leaf()); } if ($this->get_key(MIDCOM_CONTEXT_PERMALINKGUID) === null) { $this->set_key(MIDCOM_CONTEXT_PERMALINKGUID, $meta[MIDCOM_NAV_GUID]); } if ($this->get_key(MIDCOM_CONTEXT_PAGETITLE) == '') { $this->set_key(MIDCOM_CONTEXT_PAGETITLE, $meta[MIDCOM_NAV_NAME]); } }
} //check if language is passed - if not take the current-one $language = midcom::get('i18n')->get_current_language(); if (isset($_REQUEST['language'])) { $language = $_REQUEST['language']; } if (!class_exists('org_openpsa_httplib')) { $singlep_uri = str_replace('midcom-exec-midcom/reindex.php', 'midcom-exec-midcom/reindex_singleprocess.php', $current_uri); throw new midcom_error("We need org.openpsa.httplib installed to use the granular reindex, use {$singlep_uri} to get the old way."); } debug_add('Disabling script abort through client.'); ignore_user_abort(true); debug_add("Setting memory limit to configured value of {$GLOBALS['midcom_config']['midcom_max_memory']}"); ini_set('memory_limit', $GLOBALS['midcom_config']['midcom_max_memory']); $start = microtime(true); $nap = new midcom_helper_nav(); $nodes = array(); $nodeid = $nap->get_root_node(); $loader = midcom::get('componentloader'); $indexer = midcom::get('indexer'); // Use this to check that indexer is online (and hope the root topic isn't a gigantic wiki) $root_node = $nap->get_node($nodeid); $existing_documents = $indexer->query("__TOPIC_GUID:{$root_node[MIDCOM_NAV_OBJECT]->guid}"); if ($existing_documents === false) { $msg = "Query '__TOPIC_GUID:{$root_node[MIDCOM_NAV_OBJECT]->guid}' returned false, indicating problem with indexer"; throw new midcom_error($msg); } unset($existing_documents, $root_node); // Disable ob while (@ob_end_flush()) { }
private function _resolve_permalink_in_topic($topic, $guid) { // get the interface class // if we have a next-generation-one, use it to look up the required information // otherwise settle with a NAP scan // in any way, return in the same way as resolve_permalink itself. $component = $topic->component; if (!midcom::get('componentloader')->is_installed($component)) { return null; } $interface = midcom::get('componentloader')->get_interface_class($component); if ($interface === null) { debug_add("Failed to load the interface class for the component {$component} of the topic #{$topic->id}, cannot attempt to resolve the permalink here.", MIDCOM_LOG_WARN); debug_print_r('Passed topic was:', $topic); return null; } $result = $interface->resolve_permalink($topic, $guid); if ($result === null) { return null; } $nav = new midcom_helper_nav(); $node = $nav->get_node($topic->id); if (!$node) { debug_add("Failed to load the NAP information of the topic #{$topic->id}, cannot attempt to resolve the permalink here.", MIDCOM_LOG_WARN); debug_print_r('Passed topic was:', $topic); return null; } return "{$node[MIDCOM_NAV_FULLURL]}{$result}"; }
<div class="breadcrumb"> <?php if (strpos($_MIDCOM->metadata->get_page_class(), 'frontpage') === false) { $nap = new midcom_helper_nav(); echo $nap->get_breadcrumb_line(); } ?> </div>
static function common_node_toolbar_buttons_sanitycheck(&$data, &$button_component, &$bind_object, &$calling_component) { if (!midcom::get('componentloader')->load_graceful($button_component)) { //For some reason the component is and can not (be) loaded debug_add("component {$button_component} could not be loaded", MIDCOM_LOG_ERROR); return false; } if (!array_key_exists('node', $data) || empty($data['node'])) { debug_add("data['node'] not given, trying with siteconfig", MIDCOM_LOG_DEBUG); $siteconfig = org_openpsa_core_siteconfig::get_instance(); $node_guid = $siteconfig->get_node_guid($button_component); if (!$node_guid) { debug_add("data['node'] not given, and {$button_component} could not be found in siteconfig", MIDCOM_LOG_INFO); return false; } $nap = new midcom_helper_nav(); $data['node'] = $nap->resolve_guid($node_guid); } if (empty($data['node'])) { //Invalid node given/found debug_add("data['node'] is invalid", MIDCOM_LOG_ERROR); return false; } $related_to = new org_openpsa_relatedto_dba(); $related_to->toGuid = $bind_object->guid; $related_to->toClass = get_class($bind_object); $related_to->toComponent = $calling_component; $related_to->fromComponent = $button_component; $related_to->status = org_openpsa_relatedto_dba::CONFIRMED; return $related_to; }
private function _get_navigation_data() { $ret = array(); // Initialize the midcom_helper_nav or navigation access point $nap = new midcom_helper_nav(); switch ((int) $this->_topic->get_parameter('midcom.helper.nav', 'navorder')) { case MIDCOM_NAVORDER_DEFAULT: $ret['nodes'] = array(); $nodes = $nap->list_nodes($nap->get_current_node()); foreach ($nodes as $id => $node_id) { $node = $nap->get_node($node_id); $node[MIDCOM_NAV_TYPE] = 'node'; $ret['nodes'][$id] = $node; } break; case MIDCOM_NAVORDER_TOPICSFIRST: // Sort the array to have the nodes first $ret = array('nodes' => array(), 'leaves' => array()); // Fall through // Fall through case MIDCOM_NAVORDER_ARTICLESFIRST: // Sort the array to have the leaves first if (!isset($ret['leaves'])) { $ret = array('leaves' => array(), 'nodes' => array()); } // Get the nodes $nodes = $nap->list_nodes($nap->get_current_node()); foreach ($nodes as $id => $node_id) { $node = $nap->get_node($node_id); $node[MIDCOM_NAV_TYPE] = 'node'; $ret['nodes'][$id] = $node; } // Get the leafs $leaves = $nap->list_leaves($nap->get_current_node()); foreach ($leaves as $id => $leaf_id) { $leaf = $nap->get_leaf($leaf_id); $leaf[MIDCOM_NAV_TYPE] = 'leaf'; $ret['leaves'][$id] = $leaf; } break; case MIDCOM_NAVORDER_SCORE: default: $ret['mixed'] = array(); // Get the navigation items $items = $nap->list_child_elements($nap->get_current_node()); foreach ($items as $id => $item) { if ($item[MIDCOM_NAV_TYPE] === 'node') { $element = $nap->get_node($item[MIDCOM_NAV_ID]); } else { $element = $nap->get_leaf($item[MIDCOM_NAV_ID]); } // Store the type information $element[MIDCOM_NAV_TYPE] = $item[MIDCOM_NAV_TYPE]; $ret['mixed'][] = $element; } break; } return $ret; }
<div id="breadcrumb"> <?php $nap = new midcom_helper_nav(); echo $nap->get_breadcrumb_line(' » ', 'breadcrumb_link', 0, 'pagetitle'); ?> </div>
/** * Day view * * @param String $handler_id Name of the request handler * @param array $args Variable arguments * @param array &$data Public request data, passed by reference */ public function _handler_day($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); $this->_generate_date($args); // Instantiate calendar widget $this->_calendar = new org_openpsa_widgets_calendar(date('Y', $this->_selected_time), date('m', $this->_selected_time), date('d', $this->_selected_time)); $this->_calendar->type = org_openpsa_widgets_calendar::DAY; // Slots are 2 hours long $this->_calendar->calendar_slot_length = $this->_config->get('day_slot_length') * 60; $this->_calendar->start_hour = $this->_config->get('day_start_time'); $this->_calendar->end_hour = $this->_config->get('day_end_time'); $this->_calendar->column_width = 60; $this->_populate_toolbar('day'); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'month/' . $this->_get_datestring() . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('month view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'week/' . $this->_get_datestring() . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/properties.png')); // Clicking a free slot should bring up 'new event' dialogue $nap = new midcom_helper_nav(); $this_node = $nap->get_node($nap->get_current_node()); if ($this->_root_event->can_do('midgard:create')) { $this->_calendar->reservation_div_options = array('onclick' => org_openpsa_calendar_interface::calendar_editevent_js('__GUID__', $this_node)); } $this->_calendar->free_div_options = array('onclick' => org_openpsa_calendar_interface::calendar_newevent_js($this_node, '__START__', '__RESOURCE__')); // Populate contacts $this->_populate_calendar_contacts($this->_calendar->get_day_start(), $this->_calendar->get_day_end()); $this->_request_data['calendar'] =& $this->_calendar; // Set the breadcrumb $this->add_breadcrumb('year/' . date('Y-01-01', $this->_selected_time) . '/', strftime('%Y', $this->_selected_time)); $this->add_breadcrumb('month/' . date('Y-m-01', $this->_selected_time) . '/', strftime('%B', $this->_selected_time)); $this->add_breadcrumb('day/' . date('Y-m-d', $this->_selected_time) . '/', strftime('%x', $this->_selected_time)); midcom::get('head')->set_pagetitle(strftime("%x", $this->_selected_time)); }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo midcom_core_context::get()->get_key(MIDCOM_CONTEXT_PAGETITLE); ?> </title> <link rel="stylesheet" type="text/css" href="<?php echo MIDCOM_STATIC_URL; ?> /midcom.admin.help/help.css" media="screen,projector" /> <link rel="shortcut icon" href="<?php echo MIDCOM_STATIC_URL; ?> /stock-icons/logos/favicon.ico" /> <?php midcom::get('head')->print_head_elements(); ?> </head> <body> <div id="mainmenu"> </div> <div id="breadcrumb"> <?php $nap = new midcom_helper_nav(); echo $nap->get_breadcrumb_line(" > ", null, 1); ?> </div>
/** * Links to other wiki pages tagged with arbitrary tags */ private function _run_macro_tagged($macro_content, $fulltag, $after) { if (!midcom::get('componentloader')->load_library('net.nemein.tag')) { // TODO: do something to explain that we can't load n.n.tag... return $fulltag; } $tags_exploded = explode(',', $macro_content); $tags = array(); foreach ($tags_exploded as $tagname) { if (empty($tagname)) { continue; } $tag = net_nemein_tag_handler::resolve_tagname(trim($tagname)); $tags[$tag] = $tag; } $classes = array('net_nemein_wiki_wikipage', 'midcom_db_article', 'midgard_article'); $pages = net_nemein_tag_handler::get_objects_with_tags($tags, $classes, 'OR'); if (!is_array($pages)) { // Failure in tag library return $fulltag; } $nap = new midcom_helper_nav(); static $node_cache = array(); $ret = "\n<ul class=\"tagged\">\n"; usort($pages, array($this, '_code_sort_by_title')); foreach ($pages as $page) { if (!isset($node_cache[$page->topic])) { $node_cache[$page->topic] = $nap->get_node($page->topic); } $node =& $node_cache[$page->topic]; if ($node[MIDCOM_NAV_COMPONENT] !== 'net.nemein.wiki') { // We only wish to link to wiki pages continue; } $url = $node[MIDCOM_NAV_FULLURL] . "{$page->name}/"; $ret .= " <li class=\"page\"><a href=\"{$url}\">{$page->title}</a></li>\n"; } $ret .= "</ul>\n"; return $ret . $after; }
/** * Indexes an article. * * @param midcom_helper_datamanager2_datamanager &$dm The Datamanager encapsulating the event. * @param midcom_services_indexer &$indexer The indexer instance to use. * @param midcom_db_topic The topic which we are bound to. If this is not an object, the code * tries to load a new topic instance from the database identified by this parameter. */ public static function index(&$dm, &$indexer, $topic) { $config = new midcom_helper_configuration($topic, 'net.nehmer.blog'); if ($config->get('disable_indexing')) { return; } if (!is_object($topic)) { $topic = new midcom_db_topic($topic); } // Don't index directly, that would lose a reference due to limitations // of the index() method. Needs fixes there. $nav = new midcom_helper_nav(); $node = $nav->get_node($topic->id); $document = $indexer->new_document($dm); $document->topic_guid = $topic->guid; $document->component = $topic->component; $document->topic_url = $node[MIDCOM_NAV_FULLURL]; $document->read_metadata_from_object($dm->storage->object); $indexer->index($document); }
/** * Indexes a product * * This function is usually called statically from various handlers. * * @param midcom_helper_datamanager2_datamanager &$dm The Datamanager encapsulating the event. * @param midcom_services_indexer &$indexer The indexer instance to use. * @param midcom_db_topic The topic which we are bound to. If this is not an object, the code * tries to load a new topic instance from the database identified by this parameter. */ public static function index(&$dm, &$indexer, $topic, $config = null) { if ($config == null) { $config = midcom_baseclasses_components_configuration::get('org.openpsa.products', 'config'); } $object =& $dm->storage->object; if (!is_object($topic)) { $topic = new midcom_db_topic($topic); } // Don't index directly, that would lose a reference due to limitations // of the index() method. Needs fixes there. $document = $indexer->new_document($dm); if (midcom::get('dbfactory')->is_a($object, 'org_openpsa_products_product_dba')) { if ($config->get('enable_scheduling')) { // Check start/end for products if ($object->start != 0 && $object->start > time() || $object->end != 0 && $object->end < time()) { // Not in market, remove from index $indexer->delete($document->RI); return; } // FIXME: add midcom at job or somesuch to reindex products after their end time (and start time if in the future) } } $document->topic_guid = $topic->guid; $document->component = $topic->component; $nav = new midcom_helper_nav(); $node = $nav->get_node($topic->id); $document->topic_url = $node[MIDCOM_NAV_FULLURL]; $document->read_metadata_from_object($object); $document->content = "{$dm->schema->name} {$dm->schema->description} {$document->content}"; $indexer->index($document); }
/** * * @param mixed $handler_id The ID of the handler. * @param array &$data The local request data. */ public function _show_delete($handler_id, array &$data) { $data['article'] =& $this->_article; $nap = new midcom_helper_nav(); $node = $nap->get_node($this->_article->topic); $data['topic_url'] = $node[MIDCOM_NAV_FULLURL]; $data['topic_name'] = $node[MIDCOM_NAV_NAME]; $data['delete_url'] = "{$node[MIDCOM_NAV_FULLURL]}delete/{$this->_article->guid}/"; midcom_show_style('admin-delete-link'); }
function getUsersBlogs($message) { $args = $this->_params_to_args($message); if (count($args) != 3) { return new XML_RPC_Response(0, midcom_connection::get_error(), 'Invalid arguments.'); } if (!midcom::get('auth')->login($args[1], $args[2])) { return new XML_RPC_Response(0, midcom_connection::get_error(), 'Authentication failed.'); } midcom::get('auth')->initialize(); $response = array(); $topic = $this->_topic; if (!$topic->can_do('midgard:create')) { // Skip this blog, user cannot edit continue; } $nap = new midcom_helper_nav(); $node = $nap->get_node($topic->id); if (!$node) { // This topic isn't on site continue; } $response_array = array('url' => new XML_RPC_Value($node[MIDCOM_NAV_FULLURL], 'string'), 'blogid' => new XML_RPC_Value($topic->guid, 'string'), 'blogName' => new XML_RPC_Value($node[MIDCOM_NAV_NAME], 'string')); $response[] = new XML_RPC_Value($response_array, 'struct'); return new XML_RPC_Response(new XML_RPC_Value($response, 'array')); }
/** * @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_create($handler_id, array $args, array &$data) { $data['directory']->require_do('midgard:create'); $this->_defaults = array('topic' => $this->_request_data['directory']->id, 'author' => midcom_connection::get_user(), 'orgOpenpsaAccesstype' => $this->_topic->get_parameter('org.openpsa.core', 'orgOpenpsaAccesstype'), 'orgOpenpsaOwnerWg' => $this->_topic->get_parameter('org.openpsa.core', 'orgOpenpsaOwnerWg')); $this->_load_create_controller(); switch ($this->_controller->process_form()) { case 'save': /* Index the document */ $indexer = new org_openpsa_documents_midcom_indexer($this->_topic); $indexer->index($this->_controller->datamanager); // Relocate to document view $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); if ($this->_document->topic != $this->_topic->id) { $nap = new midcom_helper_nav(); $node = $nap->get_node($this->_document->topic); $prefix = $node[MIDCOM_NAV_ABSOLUTEURL]; } return new midcom_response_relocate($prefix . "document/" . $this->_document->guid . "/"); case 'cancel': return new midcom_response_relocate(''); } $this->_request_data['controller'] =& $this->_controller; // Add toolbar items org_openpsa_helpers::dm2_savecancel($this); $this->add_breadcrumb("", $this->_l10n->get('create document')); }
/** * Displays the archive. * * @param mixed $handler_id The ID of the handler. * @param array &$data The local request data. */ public function _show_list($handler_id, array &$data) { // FIXME: For some reason the config topic is lost between _handle and _show phases $this->_config->store_from_object($this->_topic, $this->_component); midcom_show_style('archive-list-start'); if ($this->_articles) { $data['index_fulltext'] = $this->_config->get('index_fulltext'); if ($this->_config->get('comments_enable')) { midcom::get('componentloader')->load_graceful('net.nehmer.comments'); $data['comments_enable'] = true; } $total_count = count($this->_articles); $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); foreach ($this->_articles as $article_counter => $article) { if (!$this->_datamanager->autoset_storage($article)) { debug_add("The datamanager for article {$article->id} could not be initialized, skipping it."); debug_print_r('Object was:', $article); continue; } $data['article'] =& $article; $data['article_counter'] = $article_counter; $data['article_count'] = $total_count; $arg = $article->name ? $article->name : $article->guid; if ($this->_config->get('view_in_url')) { $data['local_view_url'] = "{$prefix}view/{$arg}/"; } else { $data['local_view_url'] = "{$prefix}{$arg}/"; } if ($this->_config->get('link_to_external_url') && !empty($article->url)) { $data['view_url'] = $article->url; } else { $data['view_url'] = $data['local_view_url']; } if ($article->topic === $this->_content_topic->id) { $data['linked'] = false; } else { $data['linked'] = true; $nap = new midcom_helper_nav(); $data['node'] = $nap->get_node($article->topic); } midcom_show_style('archive-list-item'); } } else { midcom_show_style('archive-list-empty'); } midcom_show_style('archive-list-end'); }
/** * Adds a simple single-line text form element and place holder for tags. */ function add_elements_to_form($attributes) { $attributes = array_merge($attributes, array('class' => "shorttext", 'id' => $this->_input_element_id)); $this->widget_elements[] = HTML_QuickForm::createElement('text', "{$this->name}_input", $this->_translate($this->_field['title']), $attributes); // Get url to search handler $nav = new midcom_helper_nav(); $root_node = $nav->get_node($nav->get_root_node()); $this->_handler_url = $root_node[MIDCOM_NAV_FULLURL] . 'midcom-exec-midcom.helper.datamanager2/tags_handler.php'; $this->_jscript .= '<script type="text/javascript">'; $this->_jscript .= 'jQuery().ready(function(){'; $script = "jQuery('#{$this->_input_element_id}').midcom_helper_datamanager2_widget_tags_widget('{$this->_handler_url}', {\n"; foreach ($this->_js_widget_options as $key => $value) { $script .= "{$key}: {$value},\n"; } $script .= "});"; $this->_jscript .= $script; // Add existing selection $existing_elements = $this->_type->selection; $ee_script = ''; foreach ($existing_elements as $key) { $data = $this->_get_key_data($key); $ee_script .= "jQuery('#{$this->_input_element_id}').midcom_helper_datamanager2_widget_tags_add_selection_item({$data});\n"; } $this->_jscript .= $ee_script; $this->_jscript .= '});'; $this->_jscript .= '</script>'; $this->widget_elements[] = HTML_QuickForm::createElement('static', "{$this->name}_initscripts", '', $this->_jscript); $this->_form->addGroup($this->widget_elements, $this->name, $this->_translate($this->_field['title']), '', array('class' => 'midcom_helper_datamanager2_widget_tags')); }
/** * Creates the tab view for all enabled positioning methods * Also adds static options to results. */ function add_elements_to_form($attributes) { // Get url to geocode handler $nav = new midcom_helper_nav(); $root_node = $nav->get_node($nav->get_root_node()); $this->_handler_url = $root_node[MIDCOM_NAV_FULLURL] . 'midcom-exec-org.routamc.positioning/geocode.php'; $html = "<div id=\"{$this->_element_id}\" class=\"midcom_helper_datamanager2_widget_position\"><!-- widget starts -->\n"; $html .= "<input class=\"position_widget_id\" id=\"{$this->_element_id}_id\" name=\"{$this->_element_id}_id\" type=\"hidden\" value=\"{$this->_element_id}\" />"; $html .= "<input class=\"position_widget_backend_url\" id=\"{$this->_element_id}_backend_url\" name=\"{$this->_element_id}_backend_url\" type=\"hidden\" value=\"{$this->_handler_url}\" />"; $html .= "<input class=\"position_widget_backend_service\" id=\"{$this->_element_id}_backend_service\" name=\"{$this->_element_id}_backend_service\" type=\"hidden\" value=\"{$this->service}\" />"; $html .= " <ul>\n"; foreach ($this->enabled_methods as $method) { $html .= " <li><a href=\"#{$this->_element_id}_tab_content_{$method}\"><span>" . midcom::get('i18n')->get_string($method, 'org.routamc.positioning') . "</span></a></li>\n"; } $html .= " </ul>\n"; $this->_widget_elements[] = HTML_QuickForm::createElement('static', "{$this->_element_id}_static_widget_start", '', $html); foreach ($this->enabled_methods as $method) { $function = "_add_{$method}_method_elements"; $this->{$function}(); } $html = "</div><!-- widget ends -->\n"; $this->_widget_elements[] = HTML_QuickForm::createElement('static', "{$this->_element_id}_static_widget_end", '', $html); $this->_main_group = $this->_form->addGroup($this->_widget_elements, $this->name, $this->_translate($this->_field['title']), ''); }
/** * Adds a simple search form and place holder for results. * Also adds static options to results. */ function add_elements_to_form($attributes) { // Get url to search handler $nav = new midcom_helper_nav(); $root_node = $nav->get_node($nav->get_root_node()); if (!$root_node || empty($root_node)) { return; } $handler_url = $root_node[MIDCOM_NAV_FULLURL] . 'midcom-exec-midcom.helper.datamanager2/autocomplete_handler.php'; $selection = $this->_get_selection(); $this->_widget_elements[] = HTML_QuickForm::createElement('hidden', "{$this->_element_id}_selection", json_encode($selection), array('id' => "{$this->_element_id}_selection")); $preset = ''; if (!empty($selection)) { $identifier = $selection[0]; if ($this->id_field == 'id') { $identifier = (int) $identifier; } try { $object = new $this->class($identifier); $preset = self::create_item_label($object, $this->result_headers, $this->get_label_for); } catch (midcom_error $e) { $e->log(); } } // Text input for the search box $this->_widget_elements[] = HTML_QuickForm::createElement('text', "{$this->_element_id}_search_input", $this->_translate($this->_field['title']), array_merge($attributes, array('class' => 'shorttext autocomplete_input', 'id' => "{$this->_element_id}_search_input", 'value' => $preset))); $handler_options = json_encode(array('handler_url' => $handler_url, 'class' => $this->class, 'component' => $this->component, 'id_field' => $this->id_field, 'constraints' => $this->constraints, 'result_headers' => $this->result_headers, 'searchfields' => $this->searchfields, 'orders' => $this->orders, 'auto_wildcards' => $this->auto_wildcards)); $script = <<<EOT var {$this->_element_id}_handler_options = {$handler_options} jQuery(document).ready( function() { jQuery('#{$this->_element_id}_search_input').autocomplete( { minLength: {$this->min_chars}, source: midcom_helper_datamanager2_autocomplete.query, select: midcom_helper_datamanager2_autocomplete.select }) }); EOT; if ($this->creation_mode_enabled) { $script .= <<<EOT jQuery(document).ready( function() { midcom_helper_datamanager2_autocomplete.enable_creation_mode('{$this->_element_id}', '{$this->creation_handler}'); }); EOT; } $script = '<script type="text/javascript">' . $script . '</script>'; $this->_widget_elements[] = HTML_QuickForm::createElement('static', "{$this->_element_id}_initscript", '', $script); $this->_form->addGroup($this->_widget_elements, $this->name, $this->_translate($this->_field['title']), '', array('class' => 'midcom_helper_datamanager2_widget_autocomplete')); if ($this->_field['required']) { $errmsg = sprintf($this->_l10n->get('field %s is required'), $this->_translate($this->_field['title'])); $this->_form->addGroupRule($this->name, array("{$this->_element_id}_selection" => array(array($errmsg, 'required'), array($errmsg, 'regex', '/\\[.+?\\]/')))); } }
<?php $nap = new midcom_helper_nav(); $node = $nap->get_node($nap->get_current_node()); ?> <div class="sidebar"> <div class="area org_openpsa_helper_box"> <h3><?php echo $data['l10n']->get('groups'); ?> </h3> <?php $data['tree']->render(); ?> </div> </div> <div class="main"> <?php midcom::get()->dynamic_load($node[MIDCOM_NAV_RELATIVEURL] . "mycontacts"); ?> </div>
/** * This interface function is used to check whether a component can handle a given GUID * or not. A topic is provided which limits the "scope" of the search * accordingly. It can be safely assumed that the topic given is a valid topic in the * MidCOM content tree (it is checked through NAP). * * If the guid could be successfully resolved, a URL local to the given topic without a * leading slash must be returned (f.x. 'article/'), empty strings ('') are allowed * indicating root page access. If the GUID is invalid, null will be returned. * * This call is relayed to the component using the event handler _on_resolve_permalink(). * Before that it will deduce the active configuration for the given topic. * * The information you return with this call (if no-null) will be considered cacheable by * the content caching engine. Therefore you have to ensure that either the resolution * is stable or that you configure the content cache accordingly if you have a match. * The hard way is setting the no_cache flag in cases where you need full flexibility, but * this should be avoided for the sake of performance if somehow possible. The more * sophisticated alternative is therefore to selectively invalidate all GUIDs that have * their Permalink lookup affected. * * <b>Important Note:</b> * * Be aware that this is the only event handler at this time which has a real default * implementation: If you do not override the base class implementation, it will iterate * through all NAP leaves applicable to the node associated with the topic. If a match * is found, its local URL will be returned. This will not be terribly efficient, so * you are strongly encouraged to have some more efficient solution instead. Obviously, * if you override the function, you shouldn't call the base class implementation unless * you really need it. * * @param string $guid The permalink GUID that should be looked up. * @param midcom_db_topic $topic the Topic to look up. * @param midcom_helper_configuration $config The configuration used for the given topic. * @return string The local URL (without leading slashes) or null on failure. */ public function _on_resolve_permalink($topic, $config, $guid) { $nav = new midcom_helper_nav(); $leaves = $nav->list_leaves($topic->id); if (!$leaves) { return null; } foreach ($leaves as $leafid) { $leaf = $nav->get_leaf($leafid); if ($leaf[MIDCOM_NAV_GUID] == $guid) { return $leaf[MIDCOM_NAV_URL]; } } return null; }
/** * This helper function returns the first instance of a given component on * the MidCOM site. * * @return array NAP array of the first component instance found */ public static function find_node_by_component($component, $node_id = null, $nap = null) { static $cache = array(); $cache_node = $node_id; if (is_null($cache_node)) { $cache_node = 0; } if (!isset($cache[$cache_node])) { $cache[$cache_node] = array(); } if (array_key_exists($component, $cache[$cache_node])) { return $cache[$cache_node][$component]; } if (is_null($nap)) { $nap = new midcom_helper_nav(); } if (is_null($node_id)) { $node_id = $nap->get_root_node(); $root_node = $nap->get_node($node_id); if ($root_node[MIDCOM_NAV_COMPONENT] == $component) { $cache[$cache_node][$component] = $root_node; return $root_node; } } // Otherwise, go with QB $qb = midcom_db_topic::new_query_builder(); $qb->add_constraint('component', '=', $component); $qb->add_constraint('name', '<>', ''); $qb->add_constraint('up', 'INTREE', $node_id); $qb->set_limit(1); $topics = $qb->execute(); if (count($topics) == 0) { $cache[$cache_node][$component] = null; return null; } $node = $nap->get_node($topics[0]->id); $cache[$cache_node][$component] = $node; return $node; }
// Now just Q'n'D topic/article support function render_breadcrumb(&$crumbs) { while (current($crumbs) !== false) { $crumb = current($crumbs); if (next($crumbs) === false) { // last item echo "<a href='{$crumb['napobject'][MIDCOM_NAV_FULLURL]}'>{$crumb[MIDCOM_NAV_NAME]}</a>"; } else { echo "{$crumb[MIDCOM_NAV_NAME]} > "; } } } $site_root = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ROOTTOPIC); $host_prefix = midcom::get()->get_host_prefix(); $nap = new midcom_helper_nav(); $qb = midcom_db_topic::new_query_builder(); $qb->add_constraint('up', 'INTREE', $site_root->id); $qb->begin_group('OR'); $qb->add_constraint('metadata.hidden', '=', 1); $qb->add_constraint('metadata.navnoentry', '=', 1); $qb->end_group(); $qb->add_order('name'); $topics = $qb->execute(); unset($qb); echo "<h2>Topics</h2>\n"; foreach ($topics as $topic) { $node =& $nap->get_node($topic->id); $crumbs =& $nap->get_breadcrumb_data($node[MIDCOM_NAV_ID]); $n_crumbs = count($crumbs); $i = 0;