media.variables.inc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * @file
  4. * Contains the variables used by media and their defaults.
  5. */
  6. /* ***************************************** */
  7. /* CONSTANTS */
  8. /* ***************************************** */
  9. /**
  10. * @TODO: iz_cruft?
  11. * @var unknown_type
  12. */
  13. define('MEDIA_RESOURCE_URI_DEFAULT', 'public://');
  14. define('MEDIA_TYPES_DEFAULT', '*');
  15. /**
  16. * Define constants.
  17. */
  18. define('MEDIA_VARIABLE_NAMESPACE', 'media__');
  19. /**
  20. * Wrapper for variable_get() that uses the Media variable registry.
  21. *
  22. * @param string $name
  23. * The variable name to retrieve. Note that it will be namespaced by
  24. * pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
  25. * other modules.
  26. * @param unknown $default
  27. * An optional default variable to return if the variable hasn't been set
  28. * yet. Note that within this module, all variables should already be set
  29. * in the media_variable_default() function.
  30. * @return unknown
  31. * Returns the stored variable or its default.
  32. *
  33. * @see media_variable_set()
  34. * @see media_variable_del()
  35. * @see media_variable_default()
  36. */
  37. function media_variable_get($name, $default = NULL) {
  38. // Allow for an override of the default.
  39. // Useful when a variable is required (like $path), but namespacing still desired.
  40. if (!isset($default)) {
  41. $default = media_variable_default($name);
  42. }
  43. // Namespace all variables
  44. $variable_name = MEDIA_VARIABLE_NAMESPACE . $name;
  45. return variable_get($variable_name, $default);
  46. }
  47. /**
  48. * Wrapper for variable_set() that uses the Media variable registry.
  49. *
  50. * @param string $name
  51. * The variable name to set. Note that it will be namespaced by
  52. * pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
  53. * other modules.
  54. * @param unknown $value
  55. * The value for which to set the variable.
  56. * @return unknown
  57. * Returns the stored variable after setting.
  58. *
  59. * @see media_variable_get()
  60. * @see media_variable_del()
  61. * @see media_variable_default()
  62. */
  63. function media_variable_set($name, $value) {
  64. $variable_name = MEDIA_VARIABLE_NAMESPACE . $name;
  65. return variable_set($variable_name, $value);
  66. }
  67. /**
  68. * Wrapper for variable_del() that uses the Media variable registry.
  69. *
  70. * @param string $name
  71. * The variable name to delete. Note that it will be namespaced by
  72. * pre-pending MEDIA_VARIABLE_NAMESPACE, as to avoid variable collisions with
  73. * other modules.
  74. *
  75. * @see media_variable_get()
  76. * @see media_variable_set()
  77. * @see media_variable_default()
  78. */
  79. function media_variable_del($name) {
  80. $variable_name = MEDIA_VARIABLE_NAMESPACE . $name;
  81. variable_del($variable_name);
  82. }
  83. /**
  84. * Returns the final machine name of a Media namespaced variable.
  85. */
  86. function media_variable_name($name) {
  87. return MEDIA_VARIABLE_NAMESPACE . $name;
  88. }
  89. /**
  90. * The default variables within the Media namespace.
  91. *
  92. * @param string $name
  93. * Optional variable name to retrieve the default. Note that it has not yet
  94. * been pre-pended with the MEDIA_VARIABLE_NAMESPACE namespace at this time.
  95. * @return unknown
  96. * The default value of this variable, if it's been set, or NULL, unless
  97. * $name is NULL, in which case we return an array of all default values.
  98. *
  99. * @see media_variable_get()
  100. * @see media_variable_set()
  101. * @see media_variable_del()
  102. */
  103. function media_variable_default($name = NULL) {
  104. static $defaults;
  105. if (!isset($defaults)) {
  106. $defaults = array(
  107. 'wysiwyg_title' => 'Media browser',
  108. 'wysiwyg_icon_title' => 'Add media',
  109. //@todo: We should do this per type actually. For "other" it should be a link.
  110. 'wysiwyg_default_view_mode' => 'media_large',
  111. // Types which can be selected when embedding media vs wysiwyg.
  112. 'wysiwyg_allowed_types' => array('audio', 'image', 'video'),
  113. // Attributes which can be modified via the wysiwyg and persist.
  114. 'wysiwyg_allowed_attributes' => array('height', 'width', 'hspace', 'vspace', 'border', 'align', 'style', 'alt', 'title', 'class', 'id'),
  115. 'field_select_media_text' => 'Select media',
  116. 'field_remove_media_text' => 'Remove media',
  117. // Name of the theme to use in media popup dialogs, defaults to admin_theme
  118. 'dialog_theme' => '',
  119. // @TODO: Make a configuration form with this.
  120. 'file_extensions' => 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp mp3 mov m4v mp4 mpeg avi ogg oga ogv wmv ico',
  121. 'max_filesize' => '',
  122. 'debug' => FALSE,
  123. 'file_list_size' => 10,
  124. // Used in media.xml.inc: how long to cache retrieved remote data.
  125. 'xml_cache_expire' => 3600,
  126. // Browser defaults in media.browser.inc.
  127. 'browser_viewtype_default' => 'thumbnails',
  128. 'browser_pager_limit' => 40,
  129. 'browser_library_empty_message' => 'There are currently no media in this library to select.',
  130. 'import_batch_size' => 20,
  131. 'fromurl_supported_schemes' => array('http', 'https', 'ftp', 'smb', 'ftps'),
  132. 'type_icon_directory' => drupal_get_path('module', 'media') . '/images/types',
  133. 'icon_base_directory' => drupal_get_path('module', 'media') . '/images/icons',
  134. 'icon_set' => 'default',
  135. // This is set in media_enable(). It will show a persistant dsm on every page
  136. // until the user runs the batch operation provided by media_admin_rebuild_types_form().
  137. 'show_file_type_rebuild_nag' => FALSE,
  138. );
  139. }
  140. if (!isset($name)) {
  141. return $defaults;
  142. }
  143. if (isset($defaults[$name])) {
  144. return $defaults[$name];
  145. }
  146. }