You are here

function dfp_tag_load in Doubleclick for Publishers (DFP) 7

Same name and namespace in other branches
  1. 7.2 dfp.module \dfp_tag_load()

Load function.

Parameters

string $machinename:

Return value

object

5 calls to dfp_tag_load()
dfpBaseTest::createTag in tests/dfp_base.test
Creates a basic dfp ad tag.
dfpBaseTest::editTag in tests/dfp_base.test
Edit a given tag specified by $machinename with the given values.
dfp_block_view in ./dfp.module
Implements hook_block_view().
dfp_page_build in ./dfp.module
Implements of hook_page_build().
dfp_tag in ./dfp.module
Return a render array for the tag specified by machinename.
1 string reference to 'dfp_tag_load'
dfp_schema in ./dfp.install
Implements hook_schema().

File

./dfp.module, line 431

Code

function dfp_tag_load($machinename) {
  ctools_include('export');
  $tags =& drupal_static(__FUNCTION__, array());
  if (!isset($tags[$machinename])) {

    // Load the tag.
    $result = ctools_export_load_object('dfp_tags', 'names', array(
      $machinename,
    ));
    if (isset($result[$machinename])) {
      $tag = $result[$machinename];
    }
    else {
      return NULL;
    }

    // Store the original tag. This is used by the tag edit form.
    $tag->raw = clone $tag;

    // Allow modules to alter the raw tag object.
    drupal_alter('dfp_tag_load', $tag);

    // Move the settings out of the settings array.
    foreach ($tag->settings as $key => $val) {
      $tag->{$key} = $val;
    }

    // Configure this tag based on the defined settings.
    $tag->wrapper_id = 'dfp-ad-' . $tag->machinename . '-wrapper';
    $tag->placeholder_id = 'dfp-ad-' . $tag->machinename;

    // Allow modules to alter the fully-loaded tag object.
    drupal_alter('dfp_tag', $tag);

    // Statically cache the fully loaded tag.
    $tags[$machinename] = $tag;
  }
  else {

    // Use the statically cached tag object.
    $tag = $tags[$machinename];
  }
  return $tag;
}