'textfield',
'#title' => t('Location of YUI library'),
'#description' => t('Default location is Yahoo Server.').'
'.t('If you install YUI library locally please enter the path as follows: files/lib'),
'#default_value' => variable_get('yui_source','http://yui.yahooapis.com/2.5.0'),
'#required' => TRUE,
);
$form['yui_skin'] = array(
'#type' => 'textfield',
'#title' => t('Skin to use for YUI'),
'#description' => t('Skin to use for YUI'),
'#default_value' => variable_get('yui_skin','yui-skin-sam'),
'#required' => TRUE,
);
return system_settings_form($form);
}
/**
* Implementation of hook_menu().
*/
function yui_menu() {
$items = array();
$items['admin/settings/yui'] = array(
'title' => 'YUI Common Settings',
'description' => 'YUI Description',
'page callback' => 'drupal_get_form',
'page arguments' => array('yui_admin'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Add a YUI JS file to the current page.
*
* @param $component
* Not used.
* @param $yui_source
* Location of the YUI library.
* @param $file_and_path
* File to include.
* @param $returl
* Return only the URL to the file that should be included
*/
function yui_add_js($component = NULL, $yui_source = NULL, $file_and_path = NULL, $returl = false) {
static $js_files = array();
if (! preg_match('/^http:\/\//', $yui_source)) {
if ($returl) {
return url($yui_source . $file_and_path);
} else {
drupal_add_js($yui_source . $file_and_path);
}
}
elseif (! in_array($yui_source . $file_and_path, $js_files)) {
if ($returl) {
return $yui_source.$file_and_path;
} else {
drupal_set_html_head('');
$js_files[] = $yui_source . $file_and_path;
}
}
}
/**
* Add a YUI CSS file to the current page.
*
* @param $component
* Not used.
* @param $yui_source
* Location of the YUI library.
* @param $file_and_path
* File to include.
*/
function yui_add_css($component = NULL, $yui_source = NULL, $file_and_path = NULL, $returl = false) {
static $css_files = array();
if (! preg_match('/^http:\/\//', $yui_source)) {
if ($returl) {
return url($yui_source . $file_and_path);
} else {
drupal_add_css($yui_source . $file_and_path);
}
}
elseif (! in_array($yui_source . $file_and_path, $css_files)) {
if ($returl) {
return $yui_source.$file_and_path;
} else {
drupal_set_html_head('');
$css_files[] = $yui_source . $file_and_path;
}
}
}