You are here

function _js_injector_load_rule in JS injector 6.2

Same name and namespace in other branches
  1. 6 js_injector.module \_js_injector_load_rule()
  2. 7 js_injector.module \_js_injector_load_rule()

Helper function to load all js injection rules.

6 calls to _js_injector_load_rule()
js_injector_admin_form in ./js_injector.admin.inc
Page callback for js Injector's main admin page.
js_injector_delete_confirm in ./js_injector.admin.inc
Menu callback -- ask for confirmation of rule deletion.
js_injector_edit in ./js_injector.admin.inc
Constructor for the js rule edit form.
js_injector_edit_save in ./js_injector.admin.inc
Submit button callback for the js rule edit form.
js_injector_init in ./js_injector.module
Implementation of hook_init(). Checks to see whether any js files should be added to the current page, based on rules configured by the site administrator.

... See full list

File

./js_injector.module, line 123
Allows administrators to inject js into the page output based on configurable rules. Useful for adding simple js tweaks without modifying a site's official theme.

Code

function _js_injector_load_rule($crid = NULL, $reset = FALSE) {
  static $rules;
  if (!isset($rules) || $reset) {
    if (!$reset && ($cache = cache_get('js_injector:rules')) && !empty($cache->data)) {
      $rules = $cache->data;
    }
    else {
      $rules = array();
      $results = db_query("SELECT * FROM {js_injector_rule}");
      while ($rule = db_fetch_array($results)) {
        $rules[$rule['crid']] = $rule;
      }
      cache_set('js_injector:rules', $rules);
    }
  }
  if (is_numeric($crid)) {
    return $rules[$crid];
  }
  else {
    return $rules;
  }
}