You are here

function coder_upgrade_upgrade_call_drupal_add_css_alter in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_upgrade/conversions/call.inc \coder_upgrade_upgrade_call_drupal_add_css_alter()

Implements hook_upgrade_call_drupal_add_css_alter().

File

coder_upgrade/conversions/call.inc, line 653
Provides conversion routines applied to function calls.

Code

function coder_upgrade_upgrade_call_drupal_add_css_alter(&$node, &$reader) {

  // DONE (UPDATED)
  // Create helper objects.
  $editor = PGPEditor::getInstance();

  // Get the function call object.
  $item =& $node->data;

  // Process function call.
  $name =& $item->name;

  // A similar comment to that in 'drupal_add_js' below applies here.
  cdp($item->parameters
    ->print_r());
  $count = $item->parameters
    ->count();
  if ($count == 1) {
    return;
  }
  if ($count == 2) {
    $type = trim($item
      ->printParameter(1), "'\"");
    if ($type == 'module') {
      $item
        ->deleteParameter(1);
      return;
    }
  }

  // Insert a new weight parameter.
  $type = trim($item
    ->printParameter(1), "'\"");
  $weight = coder_upgrade_css_weight($type);
  $editor
    ->insertParameter($item, 2, "{$weight}");

  // Arrayitize the parameters.
  $keys = array(
    'type',
    'weight',
    'media',
    'preprocess',
  );
  $defaults = array(
    "'module'",
    'CSS_DEFAULT',
    "'all'",
    'TRUE',
  );
  $string = $editor
    ->arrayitize($item, 1, $keys, $defaults);
  $string = preg_replace('@[\'"]theme[\'"]@', "'file'", $string);

  // Could be deleted.
  if ($string != 'array()') {
    $temp = $editor
      ->expressionToStatement($string);
    $temp
      ->getElement(0)->multiline = 0;
    cdp($temp
      ->print_r());
    $item
      ->setParameter(1, $temp);
  }
}