system.info.inc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * @file
  4. * Provides info about system-wide entities.
  5. */
  6. /**
  7. * Implements hook_entity_property_info() on top of system module.
  8. *
  9. * @see entity_entity_property_info()
  10. * @see entity_metadata_site_wrapper()
  11. */
  12. function entity_metadata_system_entity_property_info() {
  13. $info = array();
  14. // There is no site entity, but still add metadata for global site properties
  15. // here. That way modules can alter and add further properties at this place.
  16. // In order to make use of this metadata modules may use the wrapper returned
  17. // by entity_metadata_site_wrapper().
  18. $properties = &$info['site']['properties'];
  19. $properties['name'] = array(
  20. 'label' => t("Name"),
  21. 'description' => t("The name of the site."),
  22. 'getter callback' => 'entity_metadata_system_get_properties',
  23. 'sanitize' => 'check_plain',
  24. );
  25. $properties['slogan'] = array(
  26. 'label' => t("Slogan"),
  27. 'description' => t("The slogan of the site."),
  28. 'getter callback' => 'entity_metadata_system_get_properties',
  29. 'sanitize' => 'check_plain',
  30. );
  31. $properties['mail'] = array(
  32. 'label' => t("Email"),
  33. 'description' => t("The administrative email address for the site."),
  34. 'getter callback' => 'entity_metadata_system_get_properties',
  35. );
  36. $properties['url'] = array(
  37. 'label' => t("URL"),
  38. 'description' => t("The URL of the site's front page."),
  39. 'getter callback' => 'entity_metadata_system_get_properties',
  40. 'type' => 'uri',
  41. );
  42. $properties['login_url'] = array(
  43. 'label' => t("Login page"),
  44. 'description' => t("The URL of the site's login page."),
  45. 'getter callback' => 'entity_metadata_system_get_properties',
  46. 'type' => 'uri',
  47. );
  48. $properties['current_user'] = array(
  49. 'label' => t("Logged in user"),
  50. 'description' => t("The currently logged in user."),
  51. 'getter callback' => 'entity_metadata_system_get_properties',
  52. 'type' => 'user',
  53. );
  54. $properties['current_date'] = array(
  55. 'label' => t("Current date"),
  56. 'description' => t("The current date and time."),
  57. 'getter callback' => 'entity_metadata_system_get_properties',
  58. 'type' => 'date',
  59. );
  60. $properties['current_page'] = array(
  61. 'label' => t("Current page"),
  62. 'description' => t("Information related to the current page request."),
  63. 'getter callback' => 'entity_metadata_system_get_properties',
  64. 'type' => 'struct',
  65. 'property info' => array(
  66. 'path' => array(
  67. 'label' => t("Path"),
  68. 'description' => t("The internal Drupal path of the current page request."),
  69. 'getter callback' => 'current_path',
  70. 'type' => 'text',
  71. ),
  72. 'url' => array(
  73. 'label' => t("URL"),
  74. 'description' => t("The full URL of the current page request."),
  75. 'getter callback' => 'entity_metadata_system_get_page_properties',
  76. 'type' => 'uri',
  77. ),
  78. ),
  79. );
  80. // Files.
  81. $properties = &$info['file']['properties'];
  82. $properties['fid'] = array(
  83. 'label' => t("File ID"),
  84. 'description' => t("The unique ID of the uploaded file."),
  85. 'type' => 'integer',
  86. 'validation callback' => 'entity_metadata_validate_integer_positive',
  87. 'schema field' => 'fid',
  88. );
  89. $properties['name'] = array(
  90. 'label' => t("File name"),
  91. 'description' => t("The name of the file on disk."),
  92. 'getter callback' => 'entity_metadata_system_get_file_properties',
  93. 'schema field' => 'filename',
  94. );
  95. $properties['mime'] = array(
  96. 'label' => t("MIME type"),
  97. 'description' => t("The MIME type of the file."),
  98. 'getter callback' => 'entity_metadata_system_get_file_properties',
  99. 'sanitize' => 'filter_xss',
  100. 'schema field' => 'filemime',
  101. );
  102. $properties['size'] = array(
  103. 'label' => t("File size"),
  104. 'description' => t("The size of the file, in kilobytes."),
  105. 'getter callback' => 'entity_metadata_system_get_file_properties',
  106. 'type' => 'integer',
  107. 'schema field' => 'filesize',
  108. );
  109. $properties['url'] = array(
  110. 'label' => t("URL"),
  111. 'description' => t("The web-accessible URL for the file."),
  112. 'getter callback' => 'entity_metadata_system_get_file_properties',
  113. );
  114. $properties['timestamp'] = array(
  115. 'label' => t("Timestamp"),
  116. 'description' => t("The date the file was most recently changed."),
  117. 'type' => 'date',
  118. 'schema field' => 'timestamp',
  119. );
  120. $properties['owner'] = array(
  121. 'label' => t("Owner"),
  122. 'description' => t("The user who originally uploaded the file."),
  123. 'type' => 'user',
  124. 'getter callback' => 'entity_metadata_system_get_file_properties',
  125. 'schema field' => 'uid',
  126. );
  127. return $info;
  128. }