bookmarks.php 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Bookmarks helper functions
  4. *
  5. * @package Bookmarks
  6. */
  7. /**
  8. * Prepare the add/edit form variables
  9. *
  10. * @param ElggObject $bookmark A bookmark object.
  11. * @return array
  12. */
  13. function bookmarks_prepare_form_vars($bookmark = null) {
  14. // input names => defaults
  15. $values = array(
  16. 'title' => get_input('title', ''), // bookmarklet support
  17. 'address' => get_input('address', ''),
  18. 'description' => '',
  19. 'access_id' => ACCESS_DEFAULT,
  20. 'tags' => '',
  21. 'shares' => array(),
  22. 'container_guid' => elgg_get_page_owner_guid(),
  23. 'guid' => null,
  24. 'entity' => $bookmark,
  25. );
  26. if ($bookmark) {
  27. foreach (array_keys($values) as $field) {
  28. if (isset($bookmark->$field)) {
  29. $values[$field] = $bookmark->$field;
  30. }
  31. }
  32. }
  33. if (elgg_is_sticky_form('bookmarks')) {
  34. $sticky_values = elgg_get_sticky_values('bookmarks');
  35. foreach ($sticky_values as $key => $value) {
  36. $values[$key] = $value;
  37. }
  38. }
  39. elgg_clear_sticky_form('bookmarks');
  40. return $values;
  41. }