You are here

function pdf_to_imagefield_source_filefield in PDF to ImageField 7

Same name and namespace in other branches
  1. 6.2 pdf_to_imagefield.module \pdf_to_imagefield_source_filefield()

Given a node, returns whether that node type has any pdf filefields that this module should operate on.

Parameters

$node The node to be checked:

Return value

the field definition of the filefield that holds the pdf and the widget settings.

2 calls to pdf_to_imagefield_source_filefield()
pdf_to_imagefield_node_insert in ./pdf_to_imagefield.module
hook_node_insert() nodapi subroutine
pdf_to_imagefield_node_presave in ./pdf_to_imagefield.module
hook_node_presave() nodapi subroutine

File

./pdf_to_imagefield.module, line 414
PDF to ImageField core hooks and menu callbacks.

Code

function pdf_to_imagefield_source_filefield($node) {

  // See if this node has a pdf_to_imagefield field
  // and it's got content
  if (empty($node->type)) {

    // that's illegal. odd.
    watchdog('pdf_to_imagefield', 'Given a blank node to inspect. Something is wrong', array(), WATCHDOG_ERROR);
    return;
  }
  $type = content_types($node->type);
  if (empty($type['fields'])) {

    // No CCK, return immediately
    return NULL;
  }

  // Find any fields of type pdf_to_imagefield. Note the settings
  foreach ($type['fields'] as $field_def) {
    if ($field_def['widget']['module'] == 'pdf_to_imagefield') {
      return $field_def;
    }
  }
  return NULL;
}