_blogapi_mt_extra

Versions
4.6 – 6
_blogapi_mt_extra(&$node, $struct)

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

▾ 2 functions call _blogapi_mt_extra()

blogapi_blogger_edit_post in modules/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_new_post in modules/blogapi.module
Blogging API callback. Inserts a new blog post as a node.

Code

modules/blogapi.module, line 619

<?php
function _blogapi_mt_extra(&$node, $struct) {
  if (is_array($node)) {
    $was_array = true;
    $node = array2object($node);
  }

  // mt_allow_comments
  if (array_key_exists('mt_allow_comments', $struct)) {
    switch ($struct['mt_allow_comments']) {
      case 0:
        $node->comment = 0;
        break;
      case 1:
        $node->comment = 2;
        break;
      case 2:
        $node->comment = 1;
        break;
    }
  }

  // merge the 3 body sections (description, mt_excerpt, mt_text_more) into
  // one body
  if ($struct['mt_excerpt']) {
    $node->body = $struct['mt_excerpt'] .'<!--break-->'.$node->body;
  }
  if ($struct['mt_text_more']) {
    $node->body = $node->body . '<!--extended-->' . $struct['mt_text_more'];
  }

  // mt_tb_ping_urls
  if (function_exists('trackback_send')) {
    if (is_array($struct['mt_tb_ping_urls'])) {
      foreach ($struct['mt_tb_ping_urls'] as $tb_ping_url) {
        $node->tb_url = $tb_ping_url->getVal();
        trackback_send($node);
        unset($node->tb_url); // make sure we don't ping twice
      }
    }
    else {
      $node->tb_url = $struct['mt_tb_ping_urls'];
    }
  }

  // mt_convert_breaks
  if ($struct['mt_convert_breaks']) {
    $node->format = $struct['mt_convert_breaks'];
  }

  // dateCreated
  if ($struct['dateCreated']) {
    $node->created = mktime($struct['dateCreated']->hour, $struct['dateCreated']->minute, $struct['dateCreated']->second, $struct['dateCreated']->month, $struct['dateCreated']->day, $struct['dateCreated']->year);
  }

  if ($was_array) {
    $node = object2array($node);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.