/** * POST Form for save the specified resource. * * @param int $id * @return Response */ public function doSave() { $validator = Validator::make(Input::all(), StaticPage::$rules); if ($validator->passes()) { $id = Input::get('id'); if (isset($id) && $id > 0) { $page = StaticPage::find($id); } else { $page = new StaticPage(); } $page->user_id = Auth::user()->id; $page->title = Input::get('title'); $page->meta_keywords = Input::get('meta_keywords'); $page->meta_description = Input::get('meta_description'); $page->url = Input::get('url'); $page->description = Input::get('description'); $page->save(); return Redirect::route('page-list')->with('message', 'Static Page was changed successfully.'); } else { return Redirect::route('page-edit')->with('message', 'The following errors occurred')->withErrors($validator)->withInput(); } }
} if (empty($_REQUEST['do'])) { if (!empty($_POST['preferred_caption'])) { $caption_taken = StaticPage::get(array('caption' => $_POST['caption'])); if (!empty($caption_taken)) { $error = TRUE; $msg[] = __('Caption has already been taken, please enter a different caption'); } } } $static_page->caption = $form_data['caption'] = $_POST['caption']; $static_page->page_text = $form_data['page_text'] = $_POST['page_text']; $static_page->url = $form_data['preferred_caption'] = $_POST['preferred_caption']; if (!$error) { try { $url = $static_page->save(); $form_data = array(); header("location: cncontent_static_pages.php?msg_id={$msg_id}"); exit; } catch (CNException $e) { $msg[] = $e->message; } } } else { if (!empty($_GET['do']) && $_GET['do'] == 'edit' && !empty($_GET['id'])) { $edit = TRUE; $res = StaticPage::get(array('id' => (int) $_GET['id'])); if (!empty($res)) { $form_data['id'] = $res[0]->id; $form_data['caption'] = $res[0]->caption; $form_data['url'] = $res[0]->url;
private function save(StaticPage $page, $updateMenu = true) { $request = $this->getRequest(); $page->getSpecification(); $page->loadRequestData($request); if ($updateMenu) { $menu = array('INFORMATION' => !!$request->get('menuInformation'), 'ROOT_CATEGORIES' => !!$request->get('menuRootCategories')); if ($menu['INFORMATION'] == false && $menu['ROOT_CATEGORIES'] == false) { $menu = null; } $page->menu->set($menu); } $page->save(); $arr = $page->toArray(); return new JSONResponse(array('id' => $page->getID(), 'title' => $arr['title_lang']), 'success', $this->translate('_page_has_been_successfully_saved')); }
if ($guid) { $ia = elgg_set_ignore_access(true); $entity = get_entity($guid); elgg_set_ignore_access($ia); if (!elgg_instanceof($entity, 'object', 'static') || !$entity->canEdit()) { forward(REFERER); } } $new_entity = false; if (!$entity) { $entity = new \StaticPage(); $entity->owner_guid = $owner->getGUID(); $entity->container_guid = $parent_guid; $entity->access_id = $access_id; $ia = elgg_set_ignore_access(true); if (!$entity->save()) { elgg_set_ignore_access($ia); register_error(elgg_echo('actionunauthorized')); forward(REFERER); } elgg_set_ignore_access($ia); $new_entity = true; } if ($parent_guid !== $entity->getContainerGUID()) { // reset order if moved to another parent unset($entity->order); } // place in the correct tree $subpage_relationship_guid = false; if ($parent_guid !== $owner->getGUID()) { $ia = elgg_set_ignore_access(true);