You are here

function skinr_ui_skinr_skins_alter in Skinr 6.2

Implementation of hook_skinr_alter().

File

./skinr_ui.module, line 682

Code

function skinr_ui_skinr_skins_alter(&$skins, $module, $sids, $settings) {
  static $once = FALSE;
  if (arg(4) != 'ajax' && user_access('access skinr') && isset($settings['form']['skinr_ui_form']) && skinr_ui_overlay_enabled()) {

    // Add classes for ajax, and set skinr variable.
    $skinr_id = _skinr_ui_ajax_id();
    $skins += array(
      '_skinr' => 'skinr-region',
      '_skinr_id' => 'skinr-id-' . $skinr_id,
    );

    // Only need to add these scripts and css files once.
    if (!$once) {

      // Load the dialog javascript.
      dialog_add_js();

      // Add drupal's form js files.
      drupal_add_js('misc/collapse.js');
      drupal_add_js('misc/form.js');

      // Add ajax editor js files and css file.
      drupal_add_css(drupal_get_path('module', 'skinr') . '/css/skinr.css');
      drupal_add_js(drupal_get_path('module', 'skinr') . '/js/skinr.js');
      drupal_add_js(array(
        'skinr' => array(
          'css_js_query_string' => substr(variable_get('css_js_query_string', '0'), 0, 1),
        ),
      ), 'setting');
      $once = TRUE;
    }

    // Set js variables.
    $js_settings = array(
      'skinr' => array(
        'areas' => array(
          'id-' . $skinr_id => array(
            'id' => $skinr_id,
            'module' => $module,
            'sids' => $sids,
          ),
        ),
      ),
    );
    drupal_add_js($js_settings, 'setting');
  }
}