[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/yui/ -> yui.module (source)

   1  <?php
   2  // $Id: yui.module
   3  
   4  /*
   5   * Bunyamin AKYILDIZ (bakyildiz)
   6   * YUI Common module
   7   */
   8  
   9  /*
  10   * Implementation of hook_help().
  11   */
  12  function yui_help($section) {
  13      switch ($section) {
  14          case 'admin/settings/modules#description':
  15              return t('YUI Common parameters.');
  16      }
  17  }
  18  
  19  /**
  20   * implementation of hook_perm().
  21   */
  22  function yui_perm() {
  23      $array = array('Access YUI');
  24        return $array;
  25  }
  26  
  27  /**
  28   * implementation of hook_init().
  29   */
  30  function yui_init() {
  31    require_once  './includes/common.inc';
  32    $skin = variable_get('yui_skin', 'yui-skin-sam');
  33  
  34    drupal_add_js("if (Drupal.jsEnabled) { $(document).ready(function() { $('body').addClass('$skin'); } ); };", "inline");
  35  }
  36  
  37  /*
  38   * Settings form as implemented by hook_menu
  39   */
  40  function yui_admin_settings() {
  41      $form['yui_source'] = array(
  42      '#type' => 'textfield',
  43      '#title' => t('Location of YUI library'),
  44      '#description' => t('Default location is Yahoo Server. <BR>If you install YUI library locally please enter the path as follows: files/lib'),
  45      '#default_value' => variable_get('yui_source','http://yui.yahooapis.com/2.3.0'),
  46      '#required' => TRUE,
  47      );
  48      $form['yui_skin'] = array(
  49      '#type' => 'textfield',
  50      '#title' => t('Skin to use for YUI'),
  51      '#description' => t('Skin to use for YUI'),
  52      '#default_value' => variable_get('yui_skin','yui-skin-sam'),
  53      '#required' => TRUE,
  54      );
  55      return system_settings_form($form);
  56  }
  57  
  58  function yui_menu() {
  59    $items = array();
  60      $items['admin/settings/yui'] = array(
  61        'title' => t('YUI Common Settings'),
  62        'description' => t('YUI Description'),
  63        'page callback' => 'drupal_get_form',
  64        'page arguments' => array('yui_admin_settings'),
  65        'access callback' => 'user_access',
  66        'access arguments' => array('administer site configuration'),
  67        'type' => MENU_NORMAL_ITEM,
  68          );
  69      return $items;
  70  }
  71  
  72  function yui_add_js($component = NULL, $yui_source = NULL, $file_and_path = NULL) {
  73    static $js_files = array();
  74  
  75    if (! preg_match('/^http:\/\//', $yui_source)) {
  76      $yui_source = base_path() . $yui_source;
  77    }
  78  
  79    if (! in_array($yui_source . $file_and_path, $js_files)) {
  80      drupal_set_html_head('<script type="text/javascript" src="'.$yui_source.$file_and_path.'"></script>');
  81      $js_files[] = $yui_source . $file_and_path;
  82    }
  83  }
  84  
  85  function yui_add_css($component = NULL, $yui_source = NULL, $file_and_path = NULL) {
  86    static $css_files = array();
  87  
  88    if (! preg_match('/^http:\/\//', $yui_source)) {
  89      $yui_source = base_path() . $yui_source;
  90    }  
  91  
  92    if (! in_array($yui_source . $file_and_path, $css_files)) {
  93      drupal_set_html_head('<link rel="stylesheet" type="text/css" href="'.$yui_source.$file_and_path.'"/>');
  94      $css_files[] = $yui_source . $file_and_path;
  95    }
  96  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7