Ejemplo n.º 1
0
 public function testHandler_tagged()
 {
     $article_properties = array('topic' => self::$_topic->id, 'title' => __CLASS__ . ' ' . __FUNCTION__ . ' ' . time());
     $page2 = $this->create_object('net_nemein_wiki_wikipage', $article_properties);
     midcom::get('auth')->request_sudo('net.nemein.wiki');
     net_nemein_tag_handler::tag_object($page2, array(self::$_page->name => ''), 'net.nemein.wiki');
     midcom::get('auth')->drop_sudo();
     $data = $this->run_handler(self::$_topic, array('tags', self::$_page->name));
     $this->assertEquals('tags', $data['handler_id']);
     $this->show_handler($data);
 }
Ejemplo n.º 2
0
 /**
  * Tags given object with the tags in the string
  *
  * Creates missing tags and tag_links, sets tag_link navorder
  * Deletes tag links from object that are not in the list provided
  *
  * @param object &$object MidCOM DBA object
  * @param array $tags List of tags and urls, tag is key, url is value
  * @return boolean indicating success/failure
  * @todo Set the link->navorder property
  */
 public static function tag_object(&$object, $tags, $component = null)
 {
     if (is_null($component)) {
         $component = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT);
     }
     $existing_tags = net_nemein_tag_handler::get_object_tags($object);
     if (!is_array($existing_tags)) {
         // Major failure when getting existing tags
         debug_add('get_object_tags() reported critical failure, aborting', MIDCOM_LOG_ERROR);
         return false;
     }
     // Determine operations
     $add_tags = array();
     $update_tags = array();
     $remove_tags = array();
     foreach ($tags as $tagname => $url) {
         if (empty($tagname)) {
             unset($tags[$tagname]);
             continue;
         }
         if (!array_key_exists($tagname, $existing_tags)) {
             $add_tags[$tagname] = $url;
         } else {
             if (!empty($url)) {
                 $update_tags[$tagname] = $url;
             }
         }
     }
     foreach ($existing_tags as $tagname => $url) {
         if (!array_key_exists($tagname, $tags)) {
             $remove_tags[$tagname] = true;
         }
     }
     // Excute
     foreach ($remove_tags as $tagname => $bool) {
         self::_remove_tag($tagname, $object->guid);
     }
     foreach ($update_tags as $tagname => $url) {
         self::_update_tag($tagname, $url, $object->guid);
     }
     foreach ($add_tags as $tagname => $url) {
         self::_create_tag($tagname, $url, $object, $component);
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
<?php

midcom::get('auth')->require_valid_user();
?>
<h1>Merge tags</h1>

<?php 
if (isset($_POST['from']) && isset($_POST['to'])) {
    if (net_nemein_tag_handler::merge_tags($_POST['from'], $_POST['to'])) {
        echo "<p>Successfully merged tag \"{$_POST['from']}\" to \"{$_POST['to']}\"</p>\n";
    } else {
        echo "<p>Failed to merge tag \"{$_POST['from']}\" to \"{$_POST['to']}\"</p>\n";
    }
}
?>

<form method="post">
    <input name="from" value="from" />
    <input name="to" value="to" />
    <input type="submit" value="Merge" />
</form>
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
    echo "Categories: \n";
    $cats_shown = 0;
    foreach ($categories as $category) {
        $cats_shown++;
        if (substr($category, 0, 5) == 'feed:') {
            continue;
        }
        $category = htmlspecialchars($category);
        echo "{$category}";
        if ($cats_shown < count($categories)) {
            echo ",";
        }
        echo " \n";
    }
}
$tags = net_nemein_tag_handler::get_object_tags($data['article']);
if (count($tags) > 0) {
    echo "<br />Tags: \n";
    $tags_shown = 0;
    foreach ($tags as $tag => $url) {
        $tags_shown++;
        $tag = htmlspecialchars($tag);
        echo "<a href=\"{$url}\" rel=\"tag\">{$tag}</a>";
        if ($tags_shown < count($tags)) {
            echo ",";
        }
        echo " \n";
    }
}
?>
        </div><!-- /tags -->
Ejemplo n.º 7
0
 /**
  * Handle storing Flickr-style geo tags to org.routamc.positioning
  * storage should be to org_routamc_positioning_location_dba object
  * with relation ORG_ROUTAMC_POSITIONING_RELATION_IN
  *
  * @return boolean
  */
 private function _geotag()
 {
     if (!$GLOBALS['midcom_config']['positioning_enable']) {
         return false;
     }
     midcom::get('componentloader')->load_library('org.routamc.positioning');
     // Get all "geo" tags of the object
     $object = midcom::get('dbfactory')->get_object_by_guid($this->fromGuid);
     $geotags = net_nemein_tag_handler::get_object_machine_tags_in_context($object, 'geo');
     $position = array('longitude' => null, 'latitude' => null, 'altitude' => null);
     foreach ($geotags as $key => $value) {
         switch ($key) {
             case 'lon':
             case 'lng':
             case 'long':
                 $position['longitude'] = $value;
                 break;
             case 'lat':
                 $position['latitude'] = $value;
                 break;
             case 'alt':
                 $position['altitude'] = $value;
                 break;
         }
     }
     if (is_null($position['longitude']) || is_null($position['latitude'])) {
         // Not enough information for positioning, we need both lon and lat
         return false;
     }
     $object_location = new org_routamc_positioning_location_dba();
     $object_location->relation = ORG_ROUTAMC_POSITIONING_RELATION_IN;
     $object_location->parent = $this->fromGuid;
     $object_location->parentclass = $this->fromClass;
     $object_location->parentcomponent = $this->fromComponent;
     $object_location->date = $this->metadata->published;
     $object_location->longitude = $position['longitude'];
     $object_location->latitude = $position['latitude'];
     $object_location->altitude = $position['altitude'];
     return $object_location->create();
 }
Ejemplo n.º 8
0
        midcom::get('componentloader')->load_graceful($component);
    }
    // Could not get required class defined, abort
    if (!class_exists($class)) {
        $response->errstr = "Class {$class} could not be loaded";
        $reponse->send();
    }
    $qb = call_user_func(array($class, 'new_query_builder'));
    $qb->add_constraint($id_field, '=', $object_id);
    $results = $qb->execute();
    if ($results === false) {
        $response->errstr = "Error when executing QB";
        $reponse->send();
    }
    $object = $results[0];
    $tags = net_nemein_tag_handler::get_object_tags($object);
    foreach ($tags as $name => $link) {
        $data = array('id' => $name, 'name' => $name, 'color' => '8596b6');
        $items[$name] = $data;
    }
} else {
    if (!class_exists($callback)) {
        // Try auto-load.
        $path = MIDCOM_ROOT . '/' . str_replace('_', '/', $callback) . '.php';
        if (!file_exists($path)) {
            debug_add("Auto-loading of the callback class {$callback} from {$path} failed: File does not exist.", MIDCOM_LOG_ERROR);
            return false;
        }
        require_once $path;
    }
    if (!class_exists($callback)) {
Ejemplo n.º 9
0
 /**
  * Add menu items to toolbar
  *
  * @param mixed $handler_id The ID of the handler.
  */
 public function _populate_toolbar($handler_id)
 {
     if (!$this->_object) {
         return;
     } else {
         if ($this->_object->can_do('midgard:admin')) {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'suggestion/edit/' . $this->_object->guid, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('edit %s'), 'suggestion'), MIDCOM_TOOLBAR_ICON => $this->_config->get('default_edit_icon')));
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'suggestion/delete/' . $this->_object->guid, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('delete %s'), 'suggestion'), MIDCOM_TOOLBAR_ICON => $this->_config->get('default_trash_icon')));
         }
         if ($this->_object->can_do('midgard:create')) {
             $url = "create?";
             $defaults = array();
             $defaults['suggestion'] = $this->_object->guid;
             $defaults['title'] = $this->_object->title;
             $defaults['description'] = $this->_object->description;
             $defaults['organization'] = $this->_object->organization;
             $defaults['url'] = $this->_object->url;
             $defaults['tags'] = '';
             $tags = net_nemein_tag_handler::get_tags_by_guid($this->_object->guid);
             if (is_array($tags)) {
                 $defaults['tags'] = implode(" ", array_keys($tags));
             }
             foreach ($defaults as $key => $value) {
                 $url .= "defaults[{$key}]={$value}&";
             }
             $url = substr($url, 0, -1);
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $url, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), 'dataset from suggestion'), MIDCOM_TOOLBAR_ICON => $this->_config->get('default_new_icon')));
         }
     }
 }
Ejemplo n.º 10
0
} 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) {
        if (!$context) {
            $context = midcom::get('i18n')->get_string('tagged', 'net.nemein.tag');
        }
        echo "    <dt>{$context}</dt>\n";
        foreach ($tags as $tag => $url) {
            $link = $parser->render_link($tag);
            echo "        <dd class=\"tag\">{$link}</dd>\n";
        }
    }
    echo "</dl>\n";
}
Ejemplo n.º 11
0
 /**
  * @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_import($handler_id, array $args, array &$data)
 {
     if (!$this->_config->get('api_email_enable')) {
         throw new midcom_error('Email API is disabled');
     }
     if ($handler_id === 'api-email-basicauth') {
         midcom::get('auth')->require_valid_user('basic');
     }
     //Content-Type
     midcom::get()->skip_page_style = true;
     midcom::get('cache')->content->content_type('text/plain');
     if (!isset($this->_request_data['schemadb'][$this->_config->get('api_email_schema')])) {
         throw new midcom_error('Schema "' . $this->_config->get('api_email_schema') . '" not found in schemadb "' . $this->_config->get('schemadb') . '"');
     }
     $schema_instance =& $this->_request_data['schemadb'][$this->_config->get('api_email_schema')];
     // Parse email
     $this->_decode_email();
     $this->_parse_email_persons();
     midcom::get('auth')->request_sudo('net.nehmer.blog');
     // Create article
     $this->_create_article($this->_decoder->subject);
     // Load the article to DM2
     $this->_load_datamanager();
     // Find image and tag fields in schema
     foreach ($schema_instance->fields as $name => $field) {
         if (is_a($this->_datamanager->types[$name], 'midcom_helper_datamanager2_type_image')) {
             $this->_request_data['image_field'] = $name;
             continue;
         }
         if (is_a($this->_datamanager->types[$name], 'midcom_helper_datamanager2_type_tags')) {
             $data['tags_field'] = $name;
             continue;
         }
     }
     // Try to find tags in email content
     $content = $this->_decoder->body;
     $content_tags = '';
     midcom::get('componentloader')->load_graceful('net.nemein.tag');
     if (class_exists('net_nemein_tag_handler')) {
         // unconditionally tag
         debug_add("content before machine tag separation\n===\n{$content}\n===\n");
         $content_tags = net_nemein_tag_handler::separate_machine_tags_in_content($content);
         if (!empty($content_tags)) {
             debug_add("found machine tags string: {$content_tags}");
             net_nemein_tag_handler::tag_object($this->_article, net_nemein_tag_handler::string2tag_array($content_tags));
         }
         debug_add("content AFTER machine tag separation\n===\n{$content}\n===\n");
     }
     // Populate rest of the data
     $this->_datamanager->types['content']->value = $content;
     if (!empty($data['tags_field'])) {
         // if we have tags field put content_tags value there as well or they will get deleted!
         $this->_datamanager->types[$data['tags_field']]->value = $content_tags;
     }
     $body_switched = false;
     foreach ($this->_decoder->attachments as $att) {
         debug_add("processing attachment {$att['name']}");
         switch (true) {
             case strpos($att['mimetype'], 'image/') !== false:
                 $this->_add_image($att);
                 break;
             case strtolower($att['mimetype']) == 'text/plain':
                 if (!$body_switched) {
                     // Use first text/plain part as the content
                     $this->_datamanager->types['content']->value = $att['content'];
                     $body_switched = true;
                     break;
                 }
                 // Fall-through if not switching
             // Fall-through if not switching
             default:
                 $this->_add_attachment($att);
         }
     }
     if (!$this->_datamanager->save()) {
         // Remove the article, but get errstr first
         $errstr = midcom_connection::get_error_string();
         $this->_article->delete();
         throw new midcom_error('DM2 failed to save the article. Last Midgard error was: ' . $errstr);
     }
     // Index the article
     $indexer = midcom::get('indexer');
     net_nehmer_blog_viewer::index($this->_datamanager, $indexer, $this->_content_topic);
     if ($this->_config->get('api_email_autoapprove')) {
         $metadata = midcom_helper_metadata::retrieve($this->_article);
         if (!$metadata->force_approve()) {
             // Remove the article, but get errstr first
             $errstr = midcom_connection::get_error_string();
             $this->_article->delete();
             throw new midcom_error('Failed to force approval on article. Last Midgard error was: ' . $errstr);
         }
     }
     midcom::get('auth')->drop_sudo();
 }
Ejemplo n.º 12
0
 /**
  * Returns an array of datasets tagged with 'tags'
  * @return array all tags
  */
 public function get_all_tags()
 {
     return net_nemein_tag_handler::get_tags_by_class('fi_opengov_datacatalog_dataset_dba');
 }
Ejemplo n.º 13
0
 /**
  * Parses rel-tag links in article content and tags the object based on them
  *
  * @param midgard_article $article Imported article
  * @param Array $item Feed item as provided by MagpieRSS
  * @return boolean
  */
 function parse_tags($article, $item, $field = 'content')
 {
     $html_tags = org_openpsa_httplib_helpers::get_anchor_values($article->{$field}, 'tag');
     $tags = array();
     if (count($html_tags) > 0) {
         foreach ($html_tags as $html_tag) {
             if (!$html_tag['value']) {
                 // No actual tag specified, skip
                 continue;
             }
             $tag = strtolower(strip_tags($html_tag['value']));
             $tags[$tag] = $html_tag['href'];
         }
         midcom::get('componentloader')->load_library('net.nemein.tag');
         return net_nemein_tag_handler::tag_object($article, $tags);
     }
     return true;
 }
Ejemplo n.º 14
0
 /**
  * Displays the datasets page
  *
  * @param mixed $handler_id The ID of the handler.
  * @param mixed &$data The local request data.
  */
 public function _show_read($handler_id, &$data)
 {
     if (isset($this->_datasets)) {
         if (!count($this->_datasets)) {
             midcom_show_style('no_dataset');
         } else {
             $this->_request_data['handler_id'] = $handler_id;
             if ($this->_show_list) {
                 $this->_request_data['filter'] = $this->_filter;
                 midcom_show_style('dataset_list_intro');
                 midcom_show_style('dataset_list_header');
             }
             $i = 0;
             foreach ($this->_datasets as $dataset) {
                 $this->_request_data['dataset'] = $dataset;
                 $this->_request_data['permalink'] = $_MIDCOM->permalinks->create_permalink($dataset->guid);
                 $this->_request_data['organization'] = fi_opengov_datacatalog_info_dba::get_details($dataset->organization, 'organization');
                 $this->_request_data['license'] = fi_opengov_datacatalog_info_dba::get_details($dataset->license, 'license');
                 $this->_request_data['formats'] = fi_opengov_datacatalog_dataset_dba::get_formats($dataset->id);
                 /* show different page when viewing only 1 dataset */
                 if ($handler_id == 'view' && !$this->_show_list) {
                     /* fetch and populate tags */
                     $this->_request_data['tags'] = net_nemein_tag_handler::get_tags_by_guid($dataset->guid);
                     /* gather blog posts about this dataset */
                     $this->_request_data['blogposts'] = $this->_seek_blogposts();
                     /* load the comments if enabled */
                     if ($this->_config->get('allow_comments')) {
                         $comments_node = $this->_seek_comments();
                         if ($comments_node) {
                             $this->_request_data['comments_url'] = $comments_node[MIDCOM_NAV_RELATIVEURL] . "comment/{$dataset->guid}";
                         }
                     }
                     midcom_show_style('dataset_item_detailed_view');
                 } else {
                     ++$i % 2 ? $this->_request_data['class'] = 'odd' : ($this->_request_data['class'] = 'even');
                     midcom_show_style('dataset_item_view');
                 }
             }
             if ($this->_show_list) {
                 midcom_show_style('dataset_list_footer');
             }
         }
     } else {
         midcom_show_style('no_dataset');
     }
 }
Ejemplo n.º 15
0
 public function convert_to_raw()
 {
     return net_nemein_tag_handler::string2tag_array($this->value);
 }
Ejemplo n.º 16
0
 /**
  * @todo Check if we already have an open task for this delivery?
  */
 function create_task($start, $end, $title, $source_task = null)
 {
     $salesproject = org_openpsa_sales_salesproject_dba::get_cached($this->_deliverable->salesproject);
     $product = org_openpsa_products_product_dba::get_cached($this->_deliverable->product);
     // Check if we already have a project for the sales project
     $project = $salesproject->get_project();
     // Create the task
     $task = new org_openpsa_projects_task_dba();
     $task->agreement = $this->_deliverable->id;
     $task->customer = $salesproject->customer;
     $task->title = $title;
     $task->description = $this->_deliverable->description;
     $task->start = $start;
     $task->end = $end;
     $task->plannedHours = $this->_deliverable->plannedUnits;
     $task->manager = $salesproject->owner;
     if ($project) {
         $task->project = $project->id;
         $task->orgOpenpsaAccesstype = $project->orgOpenpsaAccesstype;
         $task->orgOpenpsaOwnerWg = $project->orgOpenpsaOwnerWg;
     }
     if (!empty($source_task)) {
         $task->priority = $source_task->priority;
         $task->manager = $source_task->manager;
     }
     // TODO: Figure out if we really want to keep this
     $task->hoursInvoiceableDefault = true;
     if ($task->create()) {
         $task->add_members('contacts', array_keys($salesproject->contacts));
         if (!empty($source_task)) {
             $source_task->get_members();
             $task->add_members('resources', array_keys($source_task->resources));
         }
         org_openpsa_relatedto_plugin::create($task, 'org.openpsa.projects', $product, 'org.openpsa.products');
         // Copy tags from deliverable so we can seek resources
         $tagger = new net_nemein_tag_handler();
         $tagger->copy_tags($this->_deliverable, $task);
         midcom::get('uimessages')->add(midcom::get('i18n')->get_string('org.openpsa.sales', 'org.openpsa.sales'), sprintf(midcom::get('i18n')->get_string('created task "%s"', 'org.openpsa.sales'), $task->title), 'ok');
         return $task;
     } else {
         throw new midcom_error("The task for this cycle could not be created. Last Midgard error was: " . midcom_connection::get_error_string());
     }
 }
Ejemplo n.º 17
0
 private function _save_to_taglib()
 {
     if ($this->allow_other && !empty($this->others)) {
         $merged = array_merge($this->selection, $this->others);
         foreach ($merged as $k => $tag) {
             $tags[$tag] = '';
         }
     } else {
         if (count($this->selection) == 0) {
             return;
         } else {
             foreach ($this->selection as $k => $tag) {
                 $tags[$tag] = '';
             }
         }
     }
     debug_print_r('new tags to be saved to n.n.tag', $tags);
     $status = net_nemein_tag_handler::tag_object($this->storage->object, $tags);
     if (!$status) {
         debug_print_r('Tried to save the tags', $tags);
         debug_add("for field {$this->name}, but failed. Ignoring silently.", MIDCOM_LOG_WARN);
     }
     $tmp_tags = net_nemein_tag_handler::get_object_tags($this->storage->object);
     $tags = array();
     foreach ($tmp_tags as $name => $url) {
         $tags[$name] = $name;
     }
     debug_print_r("new tags:", $tags);
 }
Ejemplo n.º 18
0
}
?>
        <div class="taken photographer">
            Kuvaaja: <a href="&(user_url);"><?php 
echo $data['photographer']->name;
?>
</a>
        </div>

        <div class="description">
            &(view['description']:h);
        </div>

        <?php 
// List tags used in this wiki page
$tags_by_context = net_nemein_tag_handler::get_object_tags_by_contexts($data['photo']);
if (count($tags_by_context) > 0) {
    if (!isset($photostream_prefix)) {
        $photostream_prefix = $prefix;
    }
    echo "<dl class=\"tags\">\n";
    foreach ($tags_by_context as $context => $tags) {
        if (!$context) {
            $context = $_MIDCOM->i18n->get_string('tagged', 'net.nemein.tag');
        }
        echo "    <dt>{$context}</dt>\n";
        foreach ($tags as $tag => $url) {
            echo "        <dd class=\"tag\"><a href=\"{$photostream_prefix}tag/{$data['user_url']}/{$tag}\">{$tag}</a></dd>\n";
        }
    }
    echo "</dl>\n";
Ejemplo n.º 19
0
 private function _generate_tag_list()
 {
     $html = '';
     $tags = net_nemein_tag_handler::get_tags();
     $object_tags = explode(' ', $this->_type->value);
     if (!empty($tags)) {
         $html .= "<ul>\n";
         foreach ($tags as $tag => $data) {
             $classname = 'enabled';
             if (in_array($tag, $object_tags)) {
                 $classname = 'selected';
             }
             $html .= "<li class=\"{$classname}\"><span>{$tag}</span></li>\n";
         }
         $html .= "</ul>\n";
     }
     return $html;
 }