function js_library_edit in jQuery Plugin Handler (JQP) 6.2
Builds the form which is used to edit a single version of a library
1 string reference to 'js_library_edit'
- jqp_menu in ./
jqp.module - Implementation of hook_menu().
File
- ./
jqp.admin.inc, line 104 - This file includes all functionality for the libraries configuration pages
Code
function js_library_edit(&$form_state, $js_library, $version = 0, $op = NULL) {
$types = array(
'scripts',
'stylesheets',
);
// Used to create an array for form fields which needs to be rendered by the theme function
$form['files'] = array(
'#type' => 'value',
"#value" => array(),
);
$index = 0;
$form['js_library'] = array(
'#type' => 'value',
"#value" => $js_library,
);
$form['version'] = array(
'#type' => 'value',
"#value" => $version,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
// If operation is 'add' we want to display empty fields.
// We overwrite $js_library with an empty placeholder.
if ($op == 'add') {
$form['add'] = array(
'#type' => 'value',
'#value' => TRUE,
);
_jqp_form_elements($form, $index, array(
'version' => $version,
));
return $form;
}
foreach ($types as $type) {
if (!empty($js_library->info[$type][$version])) {
$added_types[] = $type;
foreach ($js_library->info[$type][$version] as $key => $path) {
if ($key !== 'changed') {
$values = array(
'name' => $key,
'path' => $path,
'version' => $version,
'type' => $type,
'operations' => array(
l(t('remove'), "admin/build/jqp/{$js_library->name}/{$version}/remove_file", array(
'query' => "type={$type}&file=" . urlencode($key),
)),
),
);
_jqp_form_elements($form, $index, $values);
$index++;
}
}
}
}
// If this is not the default version (0), and there are files types available which aren't added yet,
// we add it here and disable it.
if ($version !== 0) {
foreach ($types as $type) {
if (!in_array($type, $added_types) && isset($js_library->info[$type][0])) {
foreach ($js_library->info[$type][0] as $key => $path) {
if ($key !== 'changed') {
_jqp_form_elements($form, -$index, array(
'name' => $key,
'path' => $path,
'version' => 0,
));
$index++;
}
}
}
}
}
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset'),
);
return $form;
}