Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
annotations.php
Go to the documentation of this file.
1 <?php
19  if (!($row instanceof \stdClass)) {
20  // @todo should throw in this case?
21  return $row;
22  }
23 
24  return new \ElggAnnotation($row);
25 }
26 
37  return _elgg_services()->annotations->get($id);
38 }
39 
47  return _elgg_services()->annotations->delete($id);
48 }
49 
62 function create_annotation($entity_guid, $name, $value, $value_type = '',
63  $owner_guid = 0, $access_id = ACCESS_PRIVATE) {
64  return _elgg_services()->annotations->create(
65  $entity_guid, $name, $value, $value_type, $owner_guid, $access_id);
66 }
67 
80 function update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id) {
81  return _elgg_services()->annotations->update($annotation_id, $name, $value, $value_type, $owner_guid, $access_id);
82 }
83 
113 function elgg_get_annotations(array $options = array()) {
114  return _elgg_services()->annotations->find($options);
115 }
116 
127  $defaults = array(
128  'limit' => 25,
129  'offset' => (int) max(get_input('annoff', 0), 0),
130  'no_results' => '',
131  );
132 
133  $options = array_merge($defaults, $options);
134 
135  return elgg_list_entities($options, 'elgg_get_annotations', 'elgg_view_annotation_list');
136 }
137 
150  return _elgg_services()->annotations->deleteAll($options);
151 }
152 
163  return _elgg_services()->annotations->disableAll($options);
164 }
165 
179  return _elgg_services()->annotations->enableAll($options);
180 }
181 
218 function elgg_get_entities_from_annotations(array $options = array()) {
219  return _elgg_services()->annotations->getEntities($options);
220 }
221 
233  return elgg_list_entities($options, 'elgg_get_entities_from_annotations');
234 }
235 
269  return _elgg_services()->annotations->getEntitiesFromCalculation($options);
270 }
271 
282  $defaults = array(
283  'calculation' => 'sum',
284  'order_by' => 'annotation_calculation desc'
285  );
286  $options = array_merge($defaults, $options);
287 
288  return elgg_list_entities($options, 'elgg_get_entities_from_annotation_calculation');
289 }
290 
301 function elgg_annotation_exists($entity_guid, $annotation_type, $owner_guid = null) {
302  return _elgg_services()->annotations->exists($entity_guid, $annotation_type, $owner_guid);
303 }
304 
316  $annotation = $params['extender'];
317  /* @var \ElggExtender $annotation */
318  if ($annotation->getSubtype() == 'generic_comment') {
319  $entity = $annotation->getEntity();
320  if ($entity) {
321  return $entity->getURL() . '#item-annotation-' . $annotation->id;
322  }
323  }
324 }
325 
335 function _elgg_annotations_test($hook, $type, $tests) {
336  global $CONFIG;
337  $tests[] = $CONFIG->path . 'engine/tests/ElggCoreAnnotationAPITest.php';
338  return $tests;
339 }
340 
346  elgg_register_plugin_hook_handler('extender:url', 'annotation', '_elgg_set_comment_url');
347  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_annotations_test');
348 }
349 
350 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
351  $events->registerHandler('init', 'system', '_elgg_annotations_init');
352 };
_elgg_annotations_init()
Initialize the annotation library private.
$annotation
Elgg default annotation view.
Definition: default.php:10
create_annotation($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=ACCESS_PRIVATE)
Create a new annotation.
Definition: annotations.php:62
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
elgg_delete_annotations(array $options)
Deletes annotations based on $options.
$defaults
elgg_get_entities_from_annotations(array $options=array())
Returns entities based upon annotations.
$value
Definition: longtext.php:26
row_to_elggannotation($row)
Convert a database row to a new .
Definition: annotations.php:18
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:715
update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id)
Update an annotation.
Definition: annotations.php:80
$url
Definition: exceptions.php:24
_elgg_annotations_test($hook, $type, $tests)
Register annotation unit tests.
_elgg_set_comment_url($hook, $type, $url, $params)
Set the URL for a comment when called from a plugin hook.
$options
Elgg admin footer.
Definition: footer.php:6
$params
Definition: login.php:72
$entity_guid
Definition: save.php:9
elgg_disable_annotations(array $options)
Disables annotations based on $options.
$owner_guid
elgg_list_annotations($options)
Returns a rendered list of annotations with pagination.
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
elgg_delete_annotation_by_id($id)
Deletes an annotation using its ID.
Definition: annotations.php:46
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
global $CONFIG
elgg_get_entities_from_annotation_calculation($options)
Get entities ordered by a mathematical calculation on annotation values.
const ACCESS_PRIVATE
Definition: elgglib.php:1988
elgg_enable_annotations(array $options)
Enables annotations based on $options.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:382
elgg_list_entities_from_annotations($options=array())
Returns a viewable list of entities from annotations.
elgg_get_annotations(array $options=array())
Returns annotations.
$entity
Definition: delete.php:7
$row
elgg_annotation_exists($entity_guid, $annotation_type, $owner_guid=null)
Check to see if a user has already created an annotation on an object.
if(!$collection_name) $id
Definition: add.php:17
elgg_list_entities_from_annotation_calculation($options)
List entities from an annotation calculation.
if(!$display_name) $type
Definition: delete.php:27