You are here

function ueditor_entity_presave in UEditor - 百度编辑器 7.2

Same name and namespace in other branches
  1. 7.3 ueditor.module \ueditor_entity_presave()

Implements hook_entity_presave().

File

./ueditor.module, line 632
Integration ueditor for wysiwyg.

Code

function ueditor_entity_presave($entity, $type) {
  if ($type != 'file') {
    $info = entity_get_info($type);
    list($id) = entity_extract_ids($type, $entity);
    $editor_profiles = _ueditor_get_wysiwyg();
    $fields = _ueditor_get_editor_fields($entity, $type, $editor_profiles);
    if (variable_get('ueditor_enable_paging') == 1 && module_exists('paging')) {
      $words = variable_get('paging_separator', '<!--pagebreak-->');
      if ($words) {
        if (!empty($words) && $fields) {
          foreach ($fields as $key => $field) {
            if (!empty($field[0]['value'])) {
              $language = field_language($type, $entity, $key);
              $entity->{$key}[$language][0]['value'] = ueditor_replace_pagebeaketag($entity->{$key}[$language][0]['value'], $words);
            }
          }
        }
      }
    }
  }
}