/** * Does a local search for persons that match the task constraints * * @param org_openpsa_projects_task_dba &$task Task object to search prospect resources for * @return array of prospect persons (or false on critical failure) */ function find_task_prospects(&$task) { midcom::get('componentloader')->load_graceful('net.nemein.tag'); if (!class_exists('net_nemein_tag_handler')) { return false; } $return = array(); $classes = array('midgard_person', 'midcom_db_person', 'org_openpsa_contacts_person_dba'); $tag_map = net_nemein_tag_handler::get_object_tags($task); if (!is_array($tag_map)) { // Critical failure when fetching tags, aborting return false; } $tags = array(); // Resolve tasks tags (with contexts) into single array of tags without contexts foreach ($tag_map as $tagname => $url) { $tag = net_nemein_tag_handler::resolve_tagname($tagname); $tags[$tag] = $tag; } $persons = net_nemein_tag_handler::get_objects_with_tags($tags, $classes, 'AND'); if (!is_array($persons)) { return false; } // Normalize to contacts person class if necessary foreach ($persons as $obj) { switch (true) { case is_a($obj, 'org_openpsa_contacts_person_dba'): $return[] = $obj; break; default: try { $tmpobj = new org_openpsa_contacts_person_dba($obj->id); } catch (midcom_error $e) { break; } $return[] = $tmpobj; break; } } // TODO: Check other constraints (available time, country, time zone) $this->_find_task_prospects_filter_by_minimum_time_slot($task, $return); return $return; }
$view = $data['wikipage_view']; $nap = new midcom_helper_nav(); $node = $nap->get_node($nap->get_current_node()); ?> <div class="net_nemein_wiki_wikipage"> <h1>&(view['title']:h);</h1> <?php if ($view['content'] != '') { echo $view['content']; } else { echo "<p class=\"stub\">" . $data['l10n']->get('this page is stub') . "</p>"; } // List possible wiki pages tagged with name of this page $tagged_pages = net_nemein_tag_handler::get_objects_with_tags(array($data['wikipage']->title), array('net_nemein_wiki_wikipage')); if (count($tagged_pages) > 0) { usort($tagged_pages, array('net_nemein_wiki_handler_view', 'sort_by_title')); echo "<dl class=\"tagged\">\n"; echo " <dt>" . sprintf($data['l10n']->get('%s for %s'), midcom::get('i18n')->get_string('tagged', 'net.nemein.tag'), $data['wikipage']->title) . "</dt>\n"; foreach ($tagged_pages as $page) { echo " <dd><a href=\"{$node[MIDCOM_NAV_FULLURL]}{$page->name}/\">{$page->title}</a></dd>\n"; } echo "</dl>\n"; } // List tags used in this wiki page $tags_by_context = net_nemein_tag_handler::get_object_tags_by_contexts($data['wikipage']); if (count($tags_by_context) > 0) { $parser = new net_nemein_wiki_parser($data['wikipage']); echo "<dl class=\"tags\">\n"; foreach ($tags_by_context as $context => $tags) {
/** * 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; }
/** * Returns an array of datasets tagged with 'tags' * @param tags string * @return array all matching dataset objects */ public function get_dataset_by_tags($tags) { $_tags = explode(' ', $tags); $_classes[] = 'fi_opengov_datacatalog_dataset_dba'; return net_nemein_tag_handler::get_objects_with_tags($_tags, $_classes); }