You are here

function extlink_admin_settings_submit in External Links 7

Submit handler for admin settings form.

1 string reference to 'extlink_admin_settings_submit'
extlink_admin_settings in ./extlink.module
Administrative settings.

File

./extlink.module, line 299
External Link module.

Code

function extlink_admin_settings_submit($form, &$form_state) {

  // Append internal paths & aliases to exclude/include patterns.
  foreach (array(
    'exclude',
    'include',
  ) as $type) {
    $internal = $form_state['values']['extlink_' . $type . '_internal'];
    if ($internal && $internal != variable_get('extlink_' . $type . '_internal')) {

      // Get lines.
      $internal = array_filter(preg_split("/\r\n|\n|\r/", $internal));

      // Add aliases.
      $internal = array_map(function ($v) {
        $v = trim($v, '/ ');
        $ret = array(
          $v,
          drupal_lookup_path('alias', $v),
        );
        return implode('|', array_filter($ret));
      }, $internal);
      if (!empty($internal)) {

        // Implode, add base url & escape slashes.
        global $base_url;
        $internal = $base_url . '/(' . implode('|', array_filter($internal)) . ')';
      }
      else {
        $internal = NULL;
      }
      variable_set('extlink_' . $type . '_internal_pattern', $internal);
    }
  }
}