You are here

function scald_atom_defaults in Scald: Media Management made easy 7

Get the defaults options for a specific Atom type.

10 calls to scald_atom_defaults()
hook_scald_add_form in ./scald.api.php
Provides a form using to add an atom.
ScaldAtomController::save in includes/ScaldAtomController.inc
Save changes to a Scald Atom, or create a new one.
ScaldBaseTestCase::testScaldBaseAtomType in tests/scald.test
Test Scald type defaults.
scald_admin_type_form in includes/scald.admin.inc
Form for admin settings for Scald Types.
scald_audio_scald_add_form in modules/providers/scald_audio/scald_audio.module
Implements hook_scald_add_form().

... See full list

5 string references to 'scald_atom_defaults'
scald_admin_type_form_submit in includes/scald.admin.inc
Submit function for admin settings for Scald Types.
scald_flash_install in modules/providers/scald_flash/scald_flash.install
Implements hook_install().
scald_flash_uninstall in modules/providers/scald_flash/scald_flash.install
Implements hook_uninstall().
scald_uninstall in ./scald.install
Implements hook_uninstall().
scald_update_7000 in ./scald.install
Updates the schema from the 6.x version.

File

./scald.module, line 389
The Scald Core, which handles all Scald Registries and dispatch.

Code

function scald_atom_defaults($type) {
  $defaults =& drupal_static(__FUNCTION__);
  if (!isset($defaults)) {
    $defaults = array();
  }
  if (isset($defaults[$type])) {
    return $defaults[$type];
  }
  $all = variable_get('scald_atom_defaults', array());
  if (isset($all[$type])) {
    $default = $all[$type];
  }
  else {
    $actions = scald_actions();
    $default = new stdClass();
    $default->actions = $actions['view']['bitmask'] + $actions['fetch']['bitmask'];
    $default->description = '';
    $thumbnail = in_array($type, array(
      'image',
      'audio',
      'video',
    )) ? $type . '.png' : 'thumbnail_default.png';
    $default->thumbnail_source = 'public://atoms/' . $thumbnail;
    if (!file_exists($default->thumbnail_source)) {

      // file_unmanaged_copy() does not create new directory, so it is necessary
      // to create it before.
      $directory = dirname($default->thumbnail_source);
      file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
      file_unmanaged_copy(drupal_get_path('module', 'scald') . '/assets/' . $thumbnail, $default->thumbnail_source);
    }
  }

  // In old versions, this option did not exist and results in a PHP notice
  // when the default is not update. Fix it.
  if (!isset($default->upload_type)) {
    $default->upload_type = 'managed_file';
  }

  // If plupload upload type is in use but the module is no longer enabled, do
  // not die silently.
  if ($default->upload_type == 'plupload' && !function_exists('plupload_element_info')) {
    $default->upload_type = 'managed_file';
  }
  return $defaults[$type] = $default;
}