helpers.rst 2.6 KB

  1. Helper functions
  2. ================
  3. Input and output
  4. ----------------
  5. - ``get_input($name)`` Grabs information from a form field (or any variable passed using GET or POST). Also sanitises input, stripping Javascript etc.
  6. - ``set_input($name, $value)`` Forces a value to a particular variable for subsequent retrieval by ``get_input()``
  7. Entity methods
  8. --------------
  9. - ``$entity->getURL()`` Returns the URL of any entity in the system
  10. - ``$entity->getGUID()`` Returns the GUID of any entity in the system
  11. - ``$entity->canEdit()`` Returns whether or not the current user can edit the entity
  12. - ``$entity->getOwnerEntity()`` Returns the ElggUser owner of a particular entity
  13. Entity and context retrieval
  14. ----------------------------
  15. - ``elgg_get_logged_in_user_entity()`` Returns the ElggUser for the current user
  16. - ``elgg_get_logged_in_user_guid()`` Returns the GUID of the current user
  17. - ``elgg_is_logged_in()`` Is the viewer logged in
  18. - ``elgg_is_admin_logged_in()`` Is the view an admin and logged in
  19. - ``elgg_gatekeeper()`` Shorthand for checking if a user is logged in. Forwards user to front page if not
  20. - ``elgg_admin_gatekeeper()`` Shorthand for checking the user is logged in and is an admin. Forwards user to front page if not
  21. - ``get_user($user_guid)`` Given a GUID, returns a full ElggUser entity
  22. - ``elgg_get_page_owner_guid()`` Returns the GUID of the current page owner, if there is one
  23. - ``elgg_get_page_owner_entity()`` Like elgg_get_page_owner_guid() but returns the full entity
  24. - ``get_context()`` Returns the current page's context - eg "blog" for the blog plugin, "thewire" for the wire, etc. Returns "main" as default
  25. - ``set_context($context)`` Forces the context to be a particular value
  26. - ``elgg_push_context($context)`` Adds a context to the stack
  27. - ``elgg_pop_context()`` Removes the top context from the stack
  28. - ``elgg_in_context($context)`` Checks if you're in a context (this checks the complete stack, eg. 'widget' in 'groups')
  29. Plugins
  30. -------
  31. - ``elgg_is_active_plugin($plugin_id)`` Check if a plugin is installed and enabled
  32. Interface and annotations
  33. -------------------------
  34. - ``elgg_view_image_block($icon, $info)`` Return the result in a formatted list
  35. - ``elgg_view_comments($entity)`` Returns any comments associated with the given entity
  36. - ``elgg_get_friendly_time($unix_timestamp)`` Returns a date formatted in a friendlier way - "18 minutes ago", "2 days ago", etc.
  37. - You can pass ``'use_hover' => false`` to the user icon view if you don't want the avatar drop down menu to appear e.g.
  38. .. code:: php
  39. elgg_view_entity_icon($user, 'small', array('use_hover' => false));