protected function process() { global $core; $record = null; $oldurl = null; if ($this->record) { $record = $this->record; $pattern = $record->url_pattern; if (!Pattern::is_pattern($pattern)) { $oldurl = $pattern; } } $rc = parent::process(); $nid = $rc['key']; # # update contents # /* var $contents_model ContentModel */ $preserve = array(); $contents_model = $this->module->model('contents'); $contents = $this->request['contents']; $editor_ids = $this->request['editors']; if ($contents && $editor_ids) { foreach ($contents as $content_id => $unserialized_content) { if (!$unserialized_content) { continue; } $editor_id = $editor_ids[$content_id]; $editor = $core->editors[$editor_id]; $content = $editor->serialize($unserialized_content); if (!$content) { continue; } $preserve[$content_id] = $content_id; $values = array('content' => $content, 'editor' => $editor_id); $contents_model->insert(array('pageid' => $nid, 'contentid' => $content_id) + $values, array('on duplicate' => $values)); } } # # we delete possible remaining content for the page # $arr = $contents_model->filter_by_pageid($nid); if ($preserve) { $arr->where(array('!contentid' => $preserve)); } $arr->delete(); if ($record && $oldurl) { $record = $this->module->model[$nid]; $newurl = $record->url; if ($newurl && $newurl != $oldurl) { new Page\MoveEvent($record, $oldurl, $newurl); } } return $rc; }
protected function process() { $rc = parent::process(); $nid = $rc['key']; if ($this->request['items']) { $w = 0; foreach ($this->request['items'] as $item_properties) { // TODO-20140226: sanitize item properties $item = Item::from(array('nid' => $nid, 'weight' => ++$w) + $item_properties); $item->save(); } } return $rc; }
protected function process() { $rc = parent::process(); $photos = $this->request['photos']; $photos_model = $this->module->model('photos'); if ($photos) { $w = 0; $nid = $rc['key']; foreach ($photos as $id) { $photo = $photos_model[$id]; $photo->nid = $nid; $photo->weight = $w++; $photo->save(); } } return $rc; }