You are here

function comment_activeedit_elements in Javascript Tools 5

Implementation of hook_activeedit_elements().

File

activeedit/modules/comment.inc, line 41

Code

function comment_activeedit_elements($object = NULL) {
  $elements = array();

  // We only support comment editing if comments can be posted without preview.
  if (variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) {
    $elements['comment'] = array(
      '#selector' => 'div.comment',
      '#target' => 'comment/edit/*',
      '#id_field' => 'cid',
    );
    if (variable_get('comment_subject_field', 1) == 1) {
      $elements['comment']['comment_subject'] = array(
        '#title' => t('comment subject'),
        '#selector' => 'h3.title > a',
        '#submit_text' => t('Post comment'),
        '#form' => array(
          'comment_form' => array(
            array(
              'subject',
            ),
          ),
        ),
      );
    }
    $elements['comment']['comment_comment'] = array(
      '#title' => t('comment'),
      '#selector' => 'div.content > p',
      '#submit_text' => t('Post comment'),
      '#form' => array(
        'comment_form' => array(
          array(
            'comment_filter',
          ),
        ),
      ),
    );
  }

  // We generate content separately, on demand, to avoid unneeded processing.
  // Otherwise these calls would all be run on every page load.
  if (isset($_POST) && $_POST['activeedit_submit'] && ($key = $_REQUEST['activeedit_id'])) {
    $content = FALSE;
    switch ($key) {
      case 'comment_subject':
        $elements['comment'][$key]['#content'] = $object->subject;
        break;
      case 'comment_comment':
        $elements['comment'][$key]['#content'] = $object->comment;
        break;
    }
  }
  return $elements;
}