public function getAction() { $image_id = $_POST["image_id"]; $anns = get_annotations($image_id); $arrayAnns = []; foreach ($anns as $ann) { $arrayAnns[] = $ann->toArray(); } echo json_encode($arrayAnns); }
function annotate($result) { $annotations = get_annotations(); if (array_key_exists($result['name'], $annotations)) { $annotation = $annotations[$result['name']]; $result['sdesc'] = $annotation['sdesc']; $result['desc'] = $annotation['desc']; } else { $result['sdesc'] = $result['name']; $result['desc'] = ''; } return $result; }
/** * Get the download trends * * @param int $guid Plugin project guid or 0 for all plugins * @param int $days Number of days starting from today or 0 for dawn of time * @return array */ function plugins_get_downloads_histogram($guid = 0, $days = 30) { $start_date = time() - $days * 3600 * 24; if ($days == 0) { $start_date = 0; } $downloads = get_annotations($guid, 'object', 'plugin_project', 'download', '', 0, 9999999, 0, 'asc', $start_date); // if queried for all downloads, need to set epoch based on first download $first_time = $downloads[0]->time_created; $num_actual_days = (int) (time() - $first_time) / (3600 * 24) + 1; if ($start_date == 0) { $start_date = $first_time; $days = max($days, $num_actual_days); } // compute histogram of downloads $histogram = array_fill(0, $days, 0); foreach ($downloads as $download) { $day = (int) floor(($download->time_created - $start_date) / (3600 * 24)); $histogram[$day]++; } return $histogram; }
//get the right annotation type //*todo - use the same for comments, everywhere e.g. comment switch ($vars['item']->subtype) { case 'thewire': $annotation_comment = 'wire_reply'; break; default: $annotation_comment = 'generic_comment'; break; } //count comment annotations $comment_count = count_annotations($vars['item']->object_guid, $vars['item']->type, $vars['item']->subtype, $annotation_comment); //count like annotations $likes = count_annotations($vars['item']->object_guid, $vars['item']->type, $vars['item']->subtype, "likes"); //get last two comments display $get_comments = get_annotations($vars['item']->object_guid, "", "", $annotation_comment, "", "", 3, 0, "desc"); if ($get_comments) { //reverse the array so we can display comments in the right order $get_comments = array_reverse($get_comments); } //minus two off the comment total as we display two by default if ($comment_count < 3) { $num_comments = 0; } else { $num_comments = $comment_count - 3; } ?> <div class="river_item"> <span class="river_item_useravatar"> <?php echo elgg_view("profile/icon", array('entity' => $user, 'size' => 'small'));
<?php /** * Elgg Message board history page * * @package ElggMessageBoard * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd <*****@*****.**> * @copyright Curverider Ltd 2008-2010 * @link http://elgg.com/ */ // Load Elgg engine require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php"; // Get the user who is the owner of the message board $current_user = $_SESSION['user']->getGUID(); //history is only available for your own wall $history_user = get_input('user'); // this is the user how has posted on your messageboard that you want to display your history with // Get any annotations for their message board // $contents = $entity->getAnnotations('messageboard', 50, 0, 'desc'); $users_array = array($current_user, $history_user); $contents = get_annotations($users_array, "user", "", "messageboard", $value = "", $users_array, $limit = 10, $offset = 0, $order_by = "desc"); // Get the content to display $area2 = elgg_view_title(elgg_echo('messageboard:history:title')); $area2 .= elgg_view("messageboard/messageboard", array('annotation' => $contents)); //$area1 = "<h2>Profile owner: " . $current_user . "</h2>"; //$area1 .= "<h2>User guid: " . $history_user . "</h2>"; //select the correct canvas area $body = elgg_view_layout("two_column_left_sidebar", '', $area2); // Display page page_draw(elgg_echo('messageboard:history:title'), $body);
/** * Elgg Entity export. * Displays an entity using the current view. * * @package Elgg * @subpackage Core * @author Curverider Ltd * @link http://elgg.org/ */ $entity = $vars['entity']; if (!$entity) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:NoEntityFound')); } $metadata = get_metadata_for_entity($entity->guid); $annotations = get_annotations($entity->guid); $relationships = get_entity_relationships($entity->guid); $exportable_values = $entity->getExportableValues(); ?> <div> <h2><?php echo elgg_echo('Entity'); ?> </h2> <?php foreach ($entity as $k => $v) { if (in_array($k, $exportable_values) || isadminloggedin()) { ?> <p class="margin_none"><b><?php echo $k; ?>
* @package Blog * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd * @copyright Curverider Ltd 2008-2010 * @link http://elgg.org/ */ // a few cases to consider: // 1. looking at all posts // 2. looking at a user's post // 3. looking at your posts /* Logged in or not doesn't matter unless you're looking at your blog. Does it matter then on the side bar? All blogs: Archives Owned blogs; Archives */ $loggedin_user = get_loggedin_user(); $page_owner = page_owner_entity(); // include a view for plugins to extend echo elgg_view("blogs/sidebar", array("object_type" => 'blog')); // fetch & display latest comments on all blog posts $comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc"); echo elgg_view('annotation/latest_comments', array('comments' => $comments)); // temporarily force tag-cloud display echo "<h3>Tagcloud</h3>"; echo "<div class='tagcloud sidebar'>" . display_tagcloud(0, 100, 'tags') . "</div>"; echo "<a href=\"{$vars['url']}mod/tagcloud/tagcloud.php\">All site tags</a>";
/** * Get the annotations for an entity. * * @param string $name * @param int $limit * @param int $offset * @param string $order */ function getAnnotations($name, $limit = 50, $offset = 0, $order = "asc") { if ((int) $this->guid > 0) { return get_annotations($this->getGUID(), "", "", $name, "", 0, $limit, $offset, $order); } else { return $this->temp_annotations[$name]; } }
<?php /** * Convert river entries for tags to be tagger-tagee-annotation from * image-tagee */ $album_subtype_id = get_subtype_id('object', 'album'); global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG; $query = "SELECT * FROM {$CONFIG->dbprefix}river WHERE view = 'river/object/image/tag'"; $river_items = mysql_query($query); while ($item = mysql_fetch_object($river_items)) { $DB_QUERY_CACHE = $DB_PROFILE = array(); // find the annotation for this river item $annotations = get_annotations($item->subject_guid, '', '', 'phototag', '', 0, 999); foreach ($annotations as $annotation) { $tag = unserialize($annotation->value); if ($tag->type === 'user') { if ($tag->value == $item->object_guid) { $update = "UPDATE {$CONFIG->dbprefix}river SET subject_guid = {$annotation->owner_guid}, annotation_id = {$annotation->id} where id = {$item->id}"; mysql_query($update); } } } }
function form_recommend($form_data_id) { if (isloggedin()) { $user_guid = $_SESSION['user']->getGUID(); $number_of_my_recommendations = form_count(get_annotations($form_data_id, 'object', 'form_data', 'form:recommendation', 1, $user_guid)); if ($number_of_my_recommendations == 0) { create_annotation($form_data_id, 'form:recommendation', 1, 'integer', $user_guid, ACCESS_PUBLIC); return true; } else { return false; } } return false; }
function event_calendar_remove_personal_event($event_guid, $user_guid) { remove_entity_relationship($user_guid, 'personal_event', $event_guid); // also use old method for now $annotations = get_annotations($event_guid, "object", "event_calendar", "personal_event", (int) $user_guid, $user_guid); if ($annotations) { foreach ($annotations as $annotation) { $annotation->delete(); } } }
if (sizeof($urls) == 0) { $annotated = curl_get("http://spotlight.dbpedia.org/rest/annotate?text=" . urlencode($description) . "&confidence=0.2&support=20"); $dom = new DOMDocument(); $dom->loadXML($annotated); $xpath = new DOMXPath($dom); $tags = $xpath->query('//Resource'); $urls = array(); foreach ($tags as $tag) { array_push($urls, $tag->getAttribute("URI")); } } return $urls; } $parser = ARC2::getRDFParser(); $parser->parse("data/ccc.rdf"); $triples = $parser->getTriples(); $annotations = array(); foreach ($triples as $key => $triple) { print_r($triple); if ($triple['p'] == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && $triple['o'] == "http://fahrplan.u0d.de/schedule.owl#Event") { $annotations[$triple['s']] = get_annotations($triple['s']); } } foreach ($annotations as $subject => $annotation) { foreach ($annotation as $url) { array_push($triples, array('s' => $subject, 'p' => 'http://fahrplan.u0d.de/schema.owl#hasTopic', 'o' => $url, 'type' => 'triple', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'uri')); } } $rdfstring = $parser->toNTriples($triples); $ohandle = fopen('data/ccc2.nt', 'w'); fwrite($ohandle, $rdfstring);
/** * Clear a personal watch annotation * * @param ElggObject $watch The watch entity * @param int $user_guid The guid for the user * */ function mediawiki_clear_personal_watchlist($watch, $user_guid) { $watched = get_annotations($watch->getGUID(), "object", "mediawiki_watch", "personal", "", $user_guid); if ($watched) { foreach ($watched as $watch_item) { $watch_item->delete(); } } }
* TODO: File icons, download & mime types */ require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php"; if (is_callable('group_gatekeeper')) { group_gatekeeper(); } //set the title if (page_owner() == get_loggedin_userid()) { $title = elgg_echo('file:yours'); $area1 = elgg_view('page_elements/content_header', array('context' => "mine", 'type' => 'file')); } else { $title = sprintf(elgg_echo("file:user"), page_owner_entity()->name); $area1 = elgg_view('page_elements/content_header', array('context' => "friends", 'type' => 'file')); } // Get objects set_context('search'); $offset = (int) get_input('offset', 0); $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => page_owner(), 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE)); set_context('file'); $get_filter = get_filetype_cloud(page_owner()); if ($get_filter) { $area1 .= $get_filter; } else { $area2 .= "<p class='margin_top'>" . elgg_echo("file:none") . "</p>"; } //get the latest comments on the current users files $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc", 0, 0, page_owner()); $area3 = elgg_view('annotation/latest_comments', array('comments' => $comments)); $content = "<div class='files'>" . $area1 . $area2 . "</div>"; $body = elgg_view_layout('one_column_with_sidebar', $content, $area3); page_draw($title, $body);
/** * Checks to see if the current user has already voted on the entity * * @param guid The entity guid * @return bool Returns true/false */ function fivestar_hasVoted($guid) { $entity = get_entity($guid); $annotation = get_annotations($entity->guid, $entity->type, $entity->subtype, 'fivestar', '', $_SESSION['user']->guid, 1); if (is_object($annotation[0])) { return true; } return false; }
/** * Handler called by trigger_plugin_hook on the "export" event. */ function export_annotation_plugin_hook($hook, $entity_type, $returnvalue, $params) { // Sanity check values if (!is_array($params) && !isset($params['guid'])) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport')); } if (!is_array($returnvalue)) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue')); } $guid = (int) $params['guid']; $name = $params['name']; $result = get_annotations($guid); if ($result) { foreach ($result as $r) { $returnvalue[] = $r->export(); } } return $returnvalue; }
$downloads = plugins_get_downloads_histogram($guid, 0); $mean = array_sum($downloads) / count($downloads); $std_dev = 0; foreach ($downloads as $count) { $std_dev += ($count - $mean) * ($count - $mean); } $std_dev /= count($downloads); $std_dev = sqrt($std_dev); // calculate cutoff - 95% assuming Gaussian distribution $cutoff = $mean + 2 * $std_dev; // calculate median sort($downloads); $median = $downloads[(int) round(0.5 * count($downloads))]; // delete annotations beyond the daily cutoff - there must be a better way to do this // This does not process the last day $downloads = get_annotations($guid, 'object', 'plugin_project', 'download', '', 0, 9999999, 0, 'asc', 0); $start_date = $downloads[0]->time_created; $current_day = 0; $count = 0; $annotations_removed = 0; $annotations_stack = array(); foreach ($downloads as $download) { $day = (int) floor(($download->time_created - $start_date) / (3600 * 24)); if ($current_day == $day) { $count++; $annotation_stack[] = $download; } else { // if this day is out of the ordinary, reduce to median if ($count > $cutoff) { if (!$preview) { while (count($annotation_stack) > $median) {
<?php $images = $_GET['images']; //print_r($images);//<link rel='stylesheet' type='text/css' media='screen' href='openseadragon.css'/> $Annotations = []; foreach ($images as $image_id => $dimensions) { $anns = get_annotations($image_id); $arrayAnns = []; foreach ($anns as $ann) { $arrayAnns[] = $ann->toArray(); } $Annotations[] = $arrayAnns; } ?> <html> <head></head> <body> <script src="openseadragon.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js"></script> <style> .navigator .highlight{ opacity: 0.4; filter: alpha(opacity=40); border: 2px solid #900; outline: none; background-color: #900; } .highlight{ filter: alpha(opacity=70); opacity: 0.7;