You are here

function _potx_find_menu_hook in Translation template extractor 6.2

Same name and namespace in other branches
  1. 5.2 potx.inc \_potx_find_menu_hook()
  2. 5 potx.inc \_potx_find_menu_hook()
  3. 6 potx.inc \_potx_find_menu_hook()

List of menu item titles. Only for Drupal 6.

Parameters

$file: Full path name of file parsed.

$filebase: Filenaname of file parsed.

$save_callback: Callback function used to save strings.

1 call to _potx_find_menu_hook()
_potx_process_file in ./potx.inc
Process a file and put extracted information to the given parameters.

File

./potx.inc, line 883
Extraction API used by the web and command line interface.

Code

function _potx_find_menu_hook($file, $filebase, $save_callback) {
  global $_potx_tokens, $_potx_lookup;
  if (isset($_potx_lookup[$filebase . '_menu']) && is_array($_potx_lookup[$filebase . '_menu'])) {

    // We have a menu hook in this file.
    foreach ($_potx_lookup[$filebase . '_menu'] as $ti) {
      $end = _potx_find_end_of_function($ti);
      $tn = $ti;
      while ($tn < $end) {

        // Look through the code until the end of the function.
        if ($_potx_tokens[$tn][0] == T_CONSTANT_ENCAPSED_STRING && in_array($_potx_tokens[$tn][1], array(
          "'title'",
          '"title"',
          "'description'",
          '"description"',
        )) && $_potx_tokens[$tn + 1][0] == T_DOUBLE_ARROW) {
          if ($_potx_tokens[$tn + 2][0] == T_CONSTANT_ENCAPSED_STRING) {
            $save_callback(_potx_format_quoted_string($_potx_tokens[$tn + 2][1]), $file, $_potx_tokens[$tn + 2][2]);
            $tn += 2;

            // Jump forward by 2.
          }
          else {
            potx_status('error', t('Invalid menu %element definition found in %hook. Title and description keys of the menu array should be literal strings.', array(
              '%element' => $_potx_tokens[$tn][1],
              '%hook' => $filebase . '_menu()',
            )), $file, $_potx_tokens[$tn][2], NULL, 'http://drupal.org/node/323101');
          }
        }
        $tn++;
      }
    }
  }
}