You are here

function _jqp_ajax_check_file in jQuery Plugin Handler (JQP) 6.2

AJAX callback function for Drupal.behaviors.libraryCheckInput().

Validates the path suggested in the input form field from js_library_edit().

See also

jqp.admin.js

js_library_edit()

1 string reference to '_jqp_ajax_check_file'
jqp_menu in ./jqp.module
Implementation of hook_menu().

File

./jqp.admin.inc, line 381
This file includes all functionality for the libraries configuration pages

Code

function _jqp_ajax_check_file() {
  $p = (object) $_POST;
  if (isset($p->path) && user_access('administer javascript libraries')) {
    $result['result'] = isset($p->path) && file_exists($p->path) && is_file($p->path);
    if ($result['result'] && isset($p->type)) {
      $type = $p->type == t('Javascript') ? '.js' : ($p->type == t('Stylesheet') ? '.css' : FALSE);
      if ($type) {
        $result['result'] = strrpos($p->path, "{$type}") == drupal_strlen($p->path) - drupal_strlen($type);
      }
    }
    print drupal_to_js($result);
  }
}