You are here

function ocupload_preprocess_html in One Click Upload 7

Same name and namespace in other branches
  1. 7.2 ocupload.module \ocupload_preprocess_html()

Implements hook_preprocess_html().

File

./ocupload.module, line 83
Hooks and general functions

Code

function ocupload_preprocess_html(&$vars) {
  global $base_path;
  $scripts = drupal_add_js();
  $item = menu_get_item();
  $module_path = _ocupload_get_path();
  $module_static_path = $module_path . '/static/';
  $ocupload_use = FALSE;
  if (module_exists('bueditor') && (isset($scripts[drupal_get_path('module', 'bueditor') . '/bueditor.js']) || $item['path'] == 'admin/config/content/bueditor/%')) {
    drupal_add_js($module_static_path . 'bueditor.js', array(
      'weight' => 100,
    ));
    $ocupload_use = TRUE;
  }
  elseif (module_exists('ckeditor') && isset($scripts[ckeditor_path('url') . '/ckeditor.js'])) {
    $ocupload_use = TRUE;
  }
  elseif (module_exists('wysiwyg')) {
    foreach ($scripts['settings']['data'] as $data) {
      if (isset($data['wysiwyg']['configs']['ckeditor'])) {
        $ocupload_use = TRUE;
        break;
      }
    }
  }
  if ($ocupload_use) {
    $allowed_ext = array();
    foreach (ocupload_templates() as $template) {
      if (user_access('upload files use template ' . $template->tid)) {
        $allowed_ext = array_merge($allowed_ext, explode(',', $template->mask));
      }
    }
    drupal_add_js(array(
      'ocupload' => array(
        'allowedExt' => '*.' . implode('; *.', $allowed_ext) . ';',
      ),
    ), 'setting');
    if ($allowed_ext) {
      drupal_add_js('sites/all/libraries/swfupload/swfupload.js');
      drupal_add_js('sites/all/libraries/swfupload/plugins/swfupload.queue.js');
      drupal_add_js(array(
        'ocupload' => array(
          'phpsessid' => session_id(),
          'sizeLimit' => file_upload_max_size(),
          'modulePath' => $base_path . $module_path,
          'uploadPath' => url('ocupload/upload'),
        ),
      ), 'setting');
      drupal_add_css($module_static_path . 'styles.css');
    }
  }
}