You are here

function flashnode_load in Flash Node 6.3

Same name and namespace in other branches
  1. 5.6 flashnode.module \flashnode_load()
  2. 5.2 flashnode.module \flashnode_load()
  3. 5.3 flashnode.module \flashnode_load()
  4. 6.2 flashnode.module \flashnode_load()

Implementation of hook_load

File

./flashnode.module, line 375

Code

function flashnode_load(&$node) {
  if ($node->vid) {

    // Retrieve data for this node from combination of {flash} and {files}
    $result = db_query("SELECT filepath, filename, {flashnode}.* FROM {files} INNER JOIN {flashnode} ON {files}.fid = {flashnode}.fid WHERE {flashnode}.vid = %d", $node->vid);
    $data = db_fetch_object($result);

    // If no object was retrieved then make $data array empty and output a message
    if ($data === FALSE) {
      $data = array();
      drupal_set_message(t('Unable to load flash node data for node @node.', array(
        '@node' => $node->nid,
      )), 'error');
    }

    // Store all the settings in to the $node->flashnode object
    foreach ($data as $parameter => $value) {
      $node->flashnode[$parameter] = $value;
    }

    // The current Drupal database cannot handle NULL in an integer field,
    // so if NULL was intended then zero got stored. Assume for now that
    // zero means NULL, and that no-one would intend a zero width or height.
    // This isn't necessarily true, but will have to do for now!
    if (!$node->flashnode['height']) {
      $node->flashnode['height'] = null;
    }
    if (!$node->flashnode['width']) {
      $node->flashnode['width'] = null;
    }
  }
}