You are here

function mobile_codes_process_data in Mobile Codes 6.2

Same name and namespace in other branches
  1. 7.2 mobile_codes.module \mobile_codes_process_data()

Process the data provided to a Mobile Code.

Parameters

$data: The data provided to a Mobile Code.

1 call to mobile_codes_process_data()
mobile_codes_process_url in ./mobile_codes.module
Process Mobile Codes request URL.

File

./mobile_codes.module, line 225
Mobile Codes core functions.

Code

function mobile_codes_process_data(&$data) {
  $settings = array();
  $type = mobile_code_data_type($data);
  $defaults = variable_get('mobile_codes_settings', array(
    'url' => array(
      'alias' => 'alias',
    ),
  ));
  drupal_alter('mobile_codes_settings', $settings);
  if (is_array($settings[$type]) && count($settings[$type]) > 0) {
    foreach ($settings[$type = mobile_code_data_type($data)] as $setting => $values) {
      if ($defaults['url'][$setting]) {
        $weight = isset($values['weight']) ? $values['weight'] : 0;
        $order[$weight] = is_array($order[$weight]) ? $order[$weight] : array();
        $order[$weight][] = $setting;
      }
    }
    if ($order) {
      ksort($order);
      foreach ($order as $settings) {
        sort($settings);
        foreach ($settings as $setting) {
          if (function_exists($function = "mobile_codes_data_{$type}_{$setting}")) {
            $function($data);
          }
        }
      }
    }
  }
}