function theme_editablefields_formatter_editable in Editable Fields 6.2
Same name and namespace in other branches
- 6.3 editablefields.module \theme_editablefields_formatter_editable()
- 6 editablefields.module \theme_editablefields_formatter_editable()
Theme the editable field.
1 string reference to 'theme_editablefields_formatter_editable'
- editablefields_theme in ./
editablefields.module - Implementation of hook_theme().
File
- ./
editablefields.module, line 81 - Editable fields module.
Code
function theme_editablefields_formatter_editable($element) {
static $js_ready;
$field_name = $element['#field_name'];
$field = content_fields($field_name);
// $node = $element['#node'];
$revision = !empty($element['#node']->vid) ? $element['#node']->vid : NULL;
$node = node_load($element['#node']->nid, $revision);
$delta = $element['#item']['#delta'];
if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
}
// See if access to this form element is restricted,
// if so, skip widget processing and just set the value.
if (!node_access('update', $node) || !content_access('edit', $field)) {
// can't edit
$formatter_name = 'default';
if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
$theme = $formatter['module'] . '_formatter_' . $formatter_name;
return theme($theme, $element);
}
}
else {
$formatter_name = 'default';
if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
if (!isset($js_ready)) {
$js_ready = TRUE;
drupal_add_js('misc/jquery.form.js');
drupal_add_js(drupal_get_path('module', 'editablefields') . '/editablefields.js');
drupal_add_css(drupal_get_path('module', 'editablefields') . '/editablefields.css');
$settings = array(
'url_html' => url('editablefields_html', array(
'absolute' => TRUE,
)),
'url_submit' => url('editablefields_submit', array(
'absolute' => TRUE,
)),
'url_view' => url('editablefields_view', array(
'absolute' => TRUE,
)),
'clicktoedit_message' => '<div class="editablefields_clicktoedit_message">' . t('[edit]') . '</div>',
);
drupal_add_js(array(
'editablefields' => $settings,
), 'setting');
}
$theme = $formatter['module'] . '_formatter_' . $formatter_name;
$class = "editablefields";
if ($element['#formatter'] == 'clicktoedit') {
$class .= " clicktoedit";
}
elseif ($element['#formatter'] == 'editable_html') {
$class .= " editablefields-html-load";
}
// CORE handling shoudl have a div on each,
// MODULE handling should have a div surounding all elements (treat it as
// one field) (So, we'll arrainge for the JS to remove the rest!)
if (content_handle('widget', 'multiple values', $field) != CONTENT_HANDLE_CORE) {
if ($delta != 0) {
$class = "editablefields editablefields_REMOVE";
}
}
$pre = '<div class="' . $class . '" nid="' . $node->nid . '" field="' . $field_name . '" delta="' . $delta . '">';
$post = '</div>';
if ($element['#formatter'] != 'editable_html') {
return $pre . theme($theme, $element) . $post;
}
else {
// $node seems to be incomplete, so we reload it
$node = node_load($node->nid, $revision);
return $pre . drupal_get_form('editablefields_form', $node, $field_name, $delta) . $post;
}
}
}
}