当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::save方法代码示例

本文整理汇总了PHP中Page::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::save方法的具体用法?PHP Page::save怎么用?PHP Page::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleCreate

 public function handleCreate()
 {
     $data = Input::all();
     $rules = array('title' => 'required', 'route' => 'required|Unique:pages');
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $user_id = Auth::id();
         $page = new Page();
         $page->title = Input::get('title');
         $page->route = Input::get('route');
         $page->breadcumbs = Input::get('breadcumb');
         $page->keywords = Input::get('keywords');
         $page->description = Input::get('description');
         $page->content = Input::get('content');
         $page->tags = Input::get('tags');
         $page->layout_id = Input::get('layout');
         $page->status_id = Input::get('status');
         $page->valid_until = Input::get('valid_until');
         $page->created_by_id = $user_id;
         $page->updated_by_id = $user_id;
         if (Input::get('save')) {
             $page->save();
             return Redirect::action('AdminPageController@index')->with('flash_edit_success', 'Hurray!You have created a Page');
         } elseif (Input::get('continue')) {
             $page->save();
             return Redirect::action('AdminPageController@edit', $page->id)->with('flash_edit_success', 'Hurray!Your updated information are saved,You can continue work...');
         } else {
             return Redirect::action('AdminPageController@index')->with('flash_dlt_success', 'OH!Sorry! I can not make a Page in this time');
         }
     } else {
         return Redirect::back()->withInput()->withErrors($validator);
     }
 }
开发者ID:BDMADE,项目名称:laracms,代码行数:34,代码来源:AdminPageController.php

示例2: actionCreate

 /**
  * 单页添加
  */
 public function actionCreate()
 {
     $model = new Page();
     if (isset($_POST['Page'])) {
         $model->attributes = $_POST['Page'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->_thumb_width = '200';
             $upload->_thumb_height = '180';
             $upload->uploadFile($_FILES['attach'], true);
             if ($upload->_error) {
                 $upload->deleteFile($upload->_file_name);
                 $upload->deleteFile($upload->_thumb_name);
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->attach_file = $upload->_file_name;
             $model->attach_thumb = $upload->_thumb_name;
         }
         $model->create_time = time();
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:29,代码来源:PageController.php

示例3: test_belongs_to

 public function test_belongs_to()
 {
     MemoryStore::flush();
     Page::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->save();
     $page1 = new Page();
     $page1->title = "This is page 1";
     $page1->last_modified = new Date();
     $page1->body = "This is the content";
     $page1->url = "page-1";
     $page1->author = $user;
     $page1->save();
     FuzzyTest::assert_equal($page1->author_id, $user->id, "Author not set correctly");
     $user->delete();
     $page = Page::find_by_url('page-1');
     FuzzyTest::assert_true(isset($page), "Page deleted when it should have been preserved");
     FuzzyTest::assert_equal($page->author_id, 0, "Page deleted when it should have been preserved");
     $user->save();
     $page->author = $user;
     $page->save();
     $matches = $user->pages;
     FuzzyTest::assert_equal(count($matches), 1, "Page count should be 1");
 }
开发者ID:pokeb,项目名称:fuzzy-record,代码行数:32,代码来源:TestBelongsTo.php

示例4: save

function save($request)
{
    $page = new Page();
    $page->serializeArray("Page", $request['page']);
    $return = $page->save();
    echo json_encode($return);
}
开发者ID:jhmachado,项目名称:tools,代码行数:7,代码来源:page.php

示例5: createEdit

 public function createEdit()
 {
     $pageId = Input::get('pageId', null);
     $pageData = Input::get('page', array());
     try {
         if ($pageId || !empty($pageData['id'])) {
             //die(var_dump($pageId));
             $page = Page::findOrFail($pageId ? $pageId : $pageData['id']);
         } else {
             $page = new Page();
         }
     } catch (ModelNotFoundException $e) {
         return Response::json(array('error' => 1, 'message' => $e->getMessage()));
     }
     if (Request::ajax() && Request::isMethod('post')) {
         //Form submitted- Create the page
         //$keys = ['topic', 'description', 'pageContent', 'image', 'questions', 'results', 'ogImages'];
         foreach ($pageData as $key => $val) {
             $page->{$key} = is_array($pageData[$key]) ? json_encode($pageData[$key]) : $pageData[$key];
         }
         //var_dump($page);
         $page->save();
         return Response::json(array('success' => 1, 'page' => $page));
     } else {
         $pageSchema = new \Schemas\PageSchema();
         return View::make('admin/pages/create')->with(array('pageSchema' => $pageSchema->getSchema(), 'pageData' => Page::decodePageJson($page), 'editingMode' => $pageId ? true : false, 'creationMode' => $pageId ? false : true));
     }
 }
开发者ID:thunderclap560,项目名称:quizkpop,代码行数:28,代码来源:AdminPagesController.php

示例6: add

 public function add()
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => "required|unique:{$this->table}", 'content' => 'required|min:50', 'meta_description' => 'required|min:20', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = new Page();
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->content = Input::get('content');
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->published_at = Page::toDate(Input::get('published_at'));
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['name' => $this->name, 'action' => $this->action]);
 }
开发者ID:Rotron,项目名称:shop,代码行数:27,代码来源:AdminPageController.php

示例7: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Page();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Page'])) {
         //            echo "<pre>";print_r($model->attributes); echo "</pre>";
         $arr = $_POST["Page"];
         if (empty($arr["user_id"])) {
             $arr['user_id'] = Yii::app()->user->id;
         }
         if (empty($arr["date"])) {
             $arr["date"] = time();
         }
         if (empty($arr["status"])) {
             $setting = Settings::model()->findByPk(1);
             if ($setting->defaultPageStatus == 1) {
                 $arr["status"] = 0;
             } else {
                 $arr["status"] = 1;
             }
         }
         if (empty($arr["category_id"])) {
             $arr["category_id"] = 1;
         }
         $model->attributes = $arr;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:ennjamusic,项目名称:study,代码行数:36,代码来源:PageController.php

示例8: testPageUrlUnique

 public function testPageUrlUnique()
 {
     // Create page with url that exists
     $page = new Page();
     $page->setAttributes(array('category_id' => '1', 'publish_date' => '2011-12-01 18:55:06', 'status' => 'published', 'title' => 'Page Test Urls Unique', 'url' => 'page-1'));
     $this->assertTrue($page->save());
     $this->assertEquals('page-1' . '-' . date('YmdHis'), $page->url);
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:8,代码来源:PagesUnitTest.php

示例9: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return void
  *
  * @throws CDbException
  */
 public function actionCreate()
 {
     $model = new Page();
     $menuId = null;
     $menuParentId = 0;
     if (($data = Yii::app()->getRequest()->getPost('Page')) !== null) {
         $model->setAttributes($data);
         $transaction = Yii::app()->db->beginTransaction();
         try {
             if ($model->save()) {
                 // если активен модуль "Меню" - сохраним в меню
                 if (Yii::app()->hasModule('menu')) {
                     $menuId = (int) Yii::app()->getRequest()->getPost('menu_id');
                     $parentId = (int) Yii::app()->getRequest()->getPost('parent_id');
                     $menu = Menu::model()->findByPk($menuId);
                     if ($menu) {
                         if (!$menu->addItem($model->title, $model->getUrl(), $parentId, true)) {
                             throw new CDbException(Yii::t('PageModule.page', 'There is an error when connecting page to menu...'));
                         }
                     }
                 }
                 Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('PageModule.page', 'Page was created'));
                 $transaction->commit();
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
             }
         } catch (Exception $e) {
             $transaction->rollback();
             $model->addError(false, $e->getMessage());
         }
     }
     $languages = $this->yupe->getLanguagesList();
     //если добавляем перевод
     $id = (int) Yii::app()->getRequest()->getQuery('id');
     $lang = Yii::app()->getRequest()->getQuery('lang');
     if (!empty($id) && !empty($lang)) {
         $page = Page::model()->findByPk($id);
         if (null === $page) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('PageModule.page', 'Targeting page was not found!'));
             $this->redirect(['index']);
         }
         if (!array_key_exists($lang, $languages)) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('PageModule.page', 'Language was not found!'));
             $this->redirect(['index']);
         }
         Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('PageModule.page', 'You add translation for {lang}', ['{lang}' => $languages[$lang]]));
         $model->lang = $lang;
         $model->slug = $page->slug;
         $model->category_id = $page->category_id;
         $model->title = $page->title;
         $model->title_short = $page->title_short;
         $model->parent_id = $page->parent_id;
         $model->order = $page->order;
         $model->layout = $page->layout;
     } else {
         $model->lang = Yii::app()->getLanguage();
     }
     $this->render('create', ['model' => $model, 'pages' => Page::model()->getFormattedList(), 'languages' => $languages, 'menuId' => $menuId, 'menuParentId' => $menuParentId]);
 }
开发者ID:alextravin,项目名称:yupe,代码行数:66,代码来源:PageBackendController.php

示例10: ___import

 public function ___import($page, $data = null)
 {
     if (is_null($data)) {
         $data = $page;
         $page = new Page();
     }
     if (empty($data['core_version'])) {
         throw new WireException("Invalid import data");
     }
     $page->of(false);
     $page->resetTrackChanges(true);
     if (!is_array($data)) {
         throw new WireException("Data passed to import() must be an array");
     }
     if (!$page->parent_id) {
         $parent = $this->wire('pages')->get($data['parent']);
         if (!$parent->id) {
             throw new WireException("Unknown parent: {$data['parent']}");
         }
         $page->parent = $parent;
     }
     if (!$page->templates_id) {
         $template = $this->wire('templates')->get($data['template']);
         if (!$template) {
             throw new WireException("Unknown template: {$data['template']}");
         }
         $page->template = $template;
     }
     $page->name = $data['name'];
     $page->sort = $data['sort'];
     $page->sortfield = $data['sortfield'];
     $page->status = $data['status'];
     $page->guid = $data['id'];
     if (!$page->id) {
         $page->save();
     }
     foreach ($data['data'] as $name => $value) {
         $field = $this->wire('fields')->get($name);
         if (!$field) {
             $this->error("Unknown field: {$name}");
             continue;
         }
         if ($data['types'][$name] != $field->type->className()) {
             $this->error("Import data for field '{$field->name}' has different fieldtype '" . $data['types'][$name] . "' != '" . $field->type->className() . "', skipping...");
             continue;
         }
         $newStr = var_export($value, true);
         $oldStr = var_export($this->exportValue($page, $field, $page->get($field->name)), true);
         if ($newStr === $oldStr) {
             continue;
         }
         // value has not changed, so abort
         $value = $this->importValue($page, $field, $value);
         $page->set($field->name, $value);
     }
     return $page;
 }
开发者ID:posixpascal,项目名称:TrooperCMS,代码行数:57,代码来源:PageExport.php

示例11: add

 public function add()
 {
     if (Page::already($_POST['baseUrl'], $_POST['uri'], $_POST['language'])) {
         throw new Exception('PAGE ALREADY EXISTS', 409);
     }
     $page = new Page();
     $page->setBaseUrl($_POST['baseUrl']);
     $page->setUri($_POST['uri']);
     $page->setLanguage($_POST['language']);
     if (array_key_exists('content', $_POST) && !empty($_POST['content'])) {
         $page->setContent($_POST['content']);
     }
     $page->setModele($_POST['modele']);
     $page->setTitle($_POST['title']);
     if (array_key_exists('languageParentId', $_POST)) {
         $page->setLanguageParentId($_POST['languageParentId']);
     }
     if (array_key_exists('ajax', $_POST)) {
         $page->setAjax($_POST['ajax']);
     }
     if (array_key_exists('published', $_POST)) {
         $page->setPublished($_POST['published']);
     }
     if (array_key_exists('metas', $_POST)) {
         $page->setMetas($_POST['metas']);
     }
     if (array_key_exists('css', $_POST)) {
         $page->setCss($_POST['css']);
     }
     if (array_key_exists('js', $_POST)) {
         $page->setJs($_POST['js']);
     }
     if (array_key_exists('action', $_POST)) {
         $page->setAction($_POST['action']);
     }
     if (array_key_exists('method', $_POST)) {
         $page->setMethod($_POST['method']);
     }
     if (array_key_exists('priority', $_POST)) {
         $page->setPriority($_POST['priority']);
     }
     if (array_key_exists('datas', $_POST)) {
         $page->setDatas($_POST['datas']);
     }
     if (!array_key_exists('blockIds', $_POST)) {
         $blkIds = array();
         foreach ($_POST['blockIds'] as $blk) {
             if (array_key_exists('id', $blk) && MongoId::isValid($blk['id'])) {
                 $blkIds[] = $blk['id'];
             }
         }
         $this->page->setBlockIds($blkIds);
     }
     $page->save();
     return array('pageId' => $page->getId());
 }
开发者ID:monkeytie,项目名称:korona,代码行数:56,代码来源:page.ctrl.php

示例12: getPage

 public function getPage($slug)
 {
     $page = Page::where('slug', $slug)->first();
     if (empty($page)) {
         $page = new Page();
         $page->slug = $slug;
         $page->content = "Empty Page -> Please Edit in Admin Section";
         $page->save();
     }
     return View::make('site.pages.index', compact('page'));
 }
开发者ID:EricBui0512,项目名称:FYP,代码行数:11,代码来源:SiteController.php

示例13: actionCreate

 public function actionCreate()
 {
     $model = new Page(Page::SCENARIO_CREATE);
     $model->type = Page::TYPE_QA;
     $form = new Form('content.PageCForm', $model);
     if ($form->submitted() && $model->validate()) {
         $model->save();
         $this->redirect(['index']);
     }
     $this->render('create', ['form' => $form]);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:11,代码来源:QaController.php

示例14: save

	public function save($title, $language, $content, $originalID = null, $originalLanguage = null, $preview = null)
	{
		$this->_adminTab = 'CreatePageAdminTab';
		$page = new Page;
		$page->title = $title;
		$page->language = $language;
		$page->content = $content;
		$page->author = UserSession::get();
		
		if ($originalID)
		{
			$page->originalID = $originalID;
			$page->originalLanguage = $originalLanguage;
		}
		
		try
		{
			if (!$preview)
			{
				$page->save();
				if (!$originalID)
				{
					$this->notice(t('New page created'));
					$this->redirect('page', 'show', $page->ID);
				}
				else
				{
					$opage = Page::get($originalID, $originalLanguage);
					$this->notice(t('Saved translation of "%o"', array('o'=>$opage->title)));
					if ($language != CoOrg::getLanguage())
					{
						$this->redirect('page', 'show', $page->ID, $language);
					}
					else
					{
						$this->redirect('page', 'show', $page->ID);
					}
				}
			}
			else
			{
				if ($originalID) $this->originalPage = Page::get($originalID, $originalLanguage);
				$this->newPage = $page;
				$this->render('admin/create');
			}
		}
		catch (ValidationException $e)
		{
			if ($originalID) $this->originalPage = Page::get($originalID, $originalLanguage);
			$this->newPage = $page;
			$this->error(t('Creating page failed'));
			$this->render('admin/create');
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:54,代码来源:admin.page.controller.php

示例15: store

 public function store()
 {
     $page = new Page();
     $page->title = Input::get('title');
     $page->slug = Str::slug(Input::get('title'));
     $page->body = Input::get('body');
     $page->user_id = Sentry::getUser()->id;
     $page->save();
     Notification::success('The page was saved.');
     return Redirect::route('admin.pages.edit', $page->id);
 }
开发者ID:brucewu16899,项目名称:laravel-admin-panel,代码行数:11,代码来源:PlayerController.php


注:本文中的Page::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。