function _jeditable_ajax_load in jEditable inline content editing 7
Same name and namespace in other branches
- 6.2 jeditable.module \_jeditable_ajax_load()
- 6 jeditable.module \_jeditable_ajax_load()
Helper function to load a list of select values
1 string reference to '_jeditable_ajax_load'
- jeditable_menu in ./
jeditable.module - Implements hook_menu().
File
- ./
jeditable.module, line 638 - jeditable.module TODO: Provides integration between Drupal and the jEditable jquery plugin @todo: Datepicker support @todo: Ajax upload support @todo: Radioboxes/checkboxes support @todo: add required handler for date @todo: add compatibility for…
Code
function _jeditable_ajax_load() {
// Retrieve the values needed from the post to this page
$array = explode('-', $_GET['id']);
// Assign variables as if they were an array
list($type, $id, $field_name, $field_type) = $array;
switch ($type) {
case 'node':
/** Not Implemented yet. This is a test case scenario for editing things such as a Node title **/
$node = node_load($id);
$value = $node->{$field};
$value = 'Y';
$defaults = array(
'E' => 'Letter E',
'M' => 'Letter M',
'Y' => 'Letter Y',
);
$defaults['selected'] = $value;
break;
case 'cck':
/** Right now this supports nodereference only. The same handler should support optionwidget cck types
* in a dropdown, but that needs to be sorted out still.
**/
$node = node_load($id);
$current_value = $node->{$field_name}[0]['nid'];
$field = content_fields($field_name, $node->type);
$values = _nodereference_potential_references($field);
$defaults = array();
foreach ($values as $key => $value) {
$defaults[$key] = $value['rendered'];
}
$defaults['selected'] = $current_value;
break;
case 'field':
$node = node_load($id);
if (!node_access('update', $node)) {
// check to see that current user has update permissions on the node
$value = 'access denied';
// this is the value that will be returned, but no updates made
}
else {
$field = field_info_field($field_name);
$field_info = field_info_instance($entity_type = 'node', $field_name, $node->type);
switch ($field_type) {
// jEditable select
case 'select':
//select load values works for both nodes & field_collections
$defaults = $field['settings']['allowed_values'];
$defaults = $field_info['required'] != 1 ? array(
'_none' => t('- None -'),
) + $defaults : $defaults;
break;
// jEditable radio
case 'radio':
break;
case 'datetime':
break;
}
}
break;
case 'workflow':
/** Load the workflow states available to the current user **/
$node = node_load($id);
$defaults = _jeditable_workflow_load($node, $field_name);
}
print json_encode($defaults);
exit;
}