You are here

function _blogapi_mt_extra in Blog API 7.2

Same name and namespace in other branches
  1. 7 blogapi.module \_blogapi_mt_extra()

Handles extra information sent by clients according to MovableType's spec.

1 call to _blogapi_mt_extra()
blogapi_edit_post in ./blogapi.module
Service allback for metaWeblog.editPost
1 string reference to '_blogapi_mt_extra'
blogapi_edit_post in ./blogapi.module
Service allback for metaWeblog.editPost

File

modules/blogapi_movabletype/blogapi_movabletype.module, line 338
Provides MovableType services for BlogAPI

Code

function _blogapi_mt_extra(&$node, $struct) {
  $was_array = FALSE;
  if (is_array($node)) {
    $was_array = TRUE;
    $node = (object) $node;
  }
  if (array_key_exists('mt_allow_comments', $struct)) {
    switch ($struct['mt_allow_comments']) {
      case 0:
        $node->comment = COMMENT_NODE_HIDDEN;
        break;
      case 1:
        $node->comment = COMMENT_NODE_OPEN;
        break;
      case 2:
        $node->comment = COMMENT_NODE_CLOSED;
        break;
    }
  }

  // Merge the 3 body sections (description, mt_excerpt, mt_text_more) into one body.
  global $language;
  $lang = $language->language;
  if ($lang != 'und') {
    $value = $node->body[$lang][0]['value'];
  }
  else {
    $value = $node->body[LANGUAGE_NONE][0]['value'];
  }
  if (isset($struct['mt_excerpt'])) {
    $node->body['und'][0]['value'] = $struct['mt_excerpt'] . '<!--break-->' . $value;
  }
  else {
    $node->body['und'][0]['value'] = $value;
  }
  if (isset($struct['mt_text_more'])) {
    $node->body['und'][0]['value'] = $node->body['und'][0]['value'] . '<!--extended-->' . $struct['mt_text_more'];
  }
  if (isset($struct['mt_convert_breaks'])) {
    $node->body['und'][0]['format'] = $struct['mt_convert_breaks'];
  }
  if (isset($struct['dateCreated'])) {
    $node->date = format_date(mktime($struct['dateCreated']->hour, $struct['dateCreated']->minute, $struct['dateCreated']->second, $struct['dateCreated']->month, $struct['dateCreated']->day, $struct['dateCreated']->year), 'custom', 'Y-m-d H:i:s O');
  }
  if ($was_array) {
    $node = (array) $node;
  }
}