object_variables.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * CRUD -- Entity variables view
  4. *
  5. * @package Lorea
  6. * @subpackage CRUD
  7. *
  8. * Copyright 2012-2013 Lorea Faeries <federation@lorea.org>
  9. *
  10. * This program is free software: you can redistribute it and/or
  11. * modify it under the terms of the GNU Affero General Public License
  12. * as published by the Free Software Foundation, either version 3 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public
  21. * License along with this program. If not, see
  22. * <http://www.gnu.org/licenses/>.
  23. *
  24. * @uses $vars['entity'] The crud object
  25. */
  26. $entity = $vars['entity'];
  27. $object_subtype = $entity->getSubtype();
  28. $crud_object = crud_get_handler($object_subtype);
  29. $children_categories = $crud_object->children_categories;
  30. $variables = elgg_get_config($object_subtype);
  31. foreach ($variables as $name => $type) {
  32. if (is_array($type)) {
  33. $type = elgg_extract('output_view', $type, elgg_extract('type', $type));
  34. }
  35. $value = $entity->$name;
  36. if (in_array($name, array('title', 'description', 'access_id'))) {
  37. continue;
  38. }
  39. if (!$value) {
  40. continue;
  41. }
  42. if ($children_categories == $name) {
  43. continue;
  44. }
  45. ?>
  46. <div>
  47. <?php
  48. if ($name != 'tags') {
  49. ?>
  50. <label><?php echo elgg_echo("$crud_object->module:$object_subtype:$name") ?>: </label>
  51. <?php
  52. }
  53. if ($type != 'longtext') {
  54. }
  55. ?>
  56. <?php echo elgg_view("output/$type", array(
  57. 'name' => $name,
  58. 'crud' => $crud_object,
  59. 'value' => $value,
  60. ));
  61. ?>
  62. </div>
  63. <?php
  64. }