You are here

function coder_upgrade_upgrade_call_drupal_set_title_alter in Coder 7

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

Implements hook_upgrade_call_drupal_set_title_alter().

File

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

Code

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

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

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

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

  // Find all calls to check_plain() in the parameter expression.
  while ($node2 =& $parameters
    ->search('PGPFunctionCall', 'name', 'value', 'check_plain', TRUE)) {

    // Insert the nodes in the parameter expression to check_plain()
    // into the parameter expression to drupal_set_title() right before the call
    // to check_plain().
    $parameters
      ->insertListBefore($node2, $node2->data
      ->getParameter());

    // Remove the check_plain() call as drupal_set_title() now does this.
    $parameters
      ->delete($node2);
  }

  // TODO Should check the argument keys not the text to the t().
  if ($item
    ->parameterCount() == 1 && ($call =& $parameters
    ->search('PGPFunctionCall', 'name', 'value', 't'))) {
    $temp = $call
      ->toString();
    cdp("temp = {$temp}");
    if (preg_match('#(\'|")[@|%]\\w+(\'|")\\s*=>\\s*#', $temp) && preg_match('#(\'|")!\\w+(\'|")\\s*=>\\s*#', $temp) === 0) {

      // This is a likely condition for setting 'PASS_THROUGH' but not an absolute.
      $editor
        ->setParameter($item, 1, 'PASS_THROUGH');
      cdp($item
        ->print_r(0, $item));
    }
  }
}