You are here

function contemplate_save in Content Templates (Contemplate) 7

Same name and namespace in other branches
  1. 5 contemplate.module \contemplate_save()
  2. 6 contemplate.module \contemplate_save()
1 call to contemplate_save()
contemplate_edit_type_form_submit in ./contemplate.module

File

./contemplate.module, line 565
Create templates to customize teaser and body content.

Code

function contemplate_save($edit) {
  $type = $edit['values']['type'];
  $flags = false;
  $teaserfield = !empty($edit['values']['teaserfield']) ? $edit['values']['teaserfield'] : '';
  $bodyfield = !empty($edit['values']['bodyfield']) ? $edit['values']['bodyfield'] : '';
  $rssfield = !empty($edit['values']['rssfield']) ? $edit['values']['rssfield'] : '';
  $enclosure = !empty($edit['values']['enclosure']) ? $edit['values']['enclosure'] : '';
  $flags |= !empty($edit['values']['teaser-enable']) ? CONTEMPLATE_TEASER_ENABLED : 0;
  $flags |= !empty($edit['values']['body-enable']) ? CONTEMPLATE_BODY_ENABLED : 0;
  $flags |= !empty($edit['values']['rss-enable']) ? CONTEMPLATE_RSS_ENABLED : 0;
  contemplate_delete($type);
  $id = db_insert('contemplate')
    ->fields(array(
    'type' => $type,
    'teaser' => $teaserfield,
    'body' => $bodyfield,
    'rss' => $rssfield,
    'enclosure' => $enclosure,
    'flags' => $flags,
  ))
    ->execute();
  return $id;
}