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


PHP FormResponse::get_page方法代码示例

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


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

示例1: restore

 /**
  * Restore a completely deleted page from the SiteTree_versions table.
  */
 function restore($data, $form)
 {
     if (($id = $_REQUEST['ID']) && is_numeric($id)) {
         $restoredPage = Versioned::get_latest_version("SiteTree", $id);
         if ($restoredPage) {
             $restoredPage = $restoredPage->doRestoreToStage();
             FormResponse::get_page($id);
             $title = Convert::raw2js($restoredPage->TreeTitle());
             FormResponse::add("\$('sitetree').setNodeTitle({$id}, '{$title}');");
             FormResponse::status_message(sprintf(_t('CMSMain.RESTORED', "Restored '%s' successfully", PR_MEDIUM, 'Param %s is a title'), $title), 'good');
             return FormResponse::respond();
         } else {
             return new SS_HTTPResponse("SiteTree #{$id} not found", 400);
         }
     } else {
         return new SS_HTTPResponse("Please pass an ID in the form content", 400);
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:21,代码来源:CMSMain.php

示例2: delete

	/**
	 * Delete the current page from draft stage.
	 * @see deletefromlive()
	 */
	public function delete($urlParams, $form) {
		$id = $_REQUEST['ID'];
		$record = DataObject::get_one("SiteTree", "SiteTree.ID = $id");
		if($record && !$record->canDelete()) return Security::permissionFailure();
		
		// save ID and delete record
		$recordID = $record->ID;
		$record->delete();
		
		if(Director::is_ajax()) {
			// need a valid ID value even if the record doesn't have one in the database
			// (its still present in the live tables)
			$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "SiteTree_Live.ID = $recordID");
			// if the page has never been published to live, we need to act the same way as in deletefromlive()
			if($liveRecord) {
				// the form is readonly now, so we need to refresh the representation
				FormResponse::get_page($recordID);
				return $this->tellBrowserAboutPublicationChange($liveRecord, sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title));
			} else {
				FormResponse::add($this->deleteTreeNodeJS($record));
				FormResponse::status_message(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),$record->Title), 'good');
				return FormResponse::respond();
			}			
		} else {
			Director::redirectBack();
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:31,代码来源:CMSMain.php

示例3: revert

 public function revert($urlParams, $form)
 {
     $id = $_REQUEST['ID'];
     Versioned::reading_stage('Live');
     $obj = DataObject::get_by_id("SiteTree", $id);
     Versioned::reading_stage('Stage');
     $obj->publish("Live", "Stage");
     $title = Convert::raw2js($obj->Title);
     FormResponse::get_page($id);
     FormResponse::add("\$('sitetree').setNodeTitle({$id}, '{$title}');");
     FormResponse::status_message(sprintf(_t('CMSMain.RESTORED', "Restored '%s' successfully", PR_MEDIUM, 'Param %s is a title'), $title), 'good');
     return FormResponse::respond();
 }
开发者ID:ramziammar,项目名称:websites,代码行数:13,代码来源:CMSMain.php

示例4: workflowAction

 /**
  * Process a workflow action.
  * @param string $workflowClass The sub-class of WorkflowRequest that is expected.
  * @param string $actionName The action method to call on the given WorkflowRequest objec.t
  * @param int $id The ID# of the page.
  * @param string $comment The comment to attach.
  * @param string $successMessage The message to show on success.
  */
 function workflowAction($workflowClass, $actionName, $id, $comment)
 {
     if (is_numeric($id)) {
         // For 2.3 and 2.4 compatibility
         $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
         $page = DataObject::get_by_id("SiteTree", $id);
         if (!$page) {
             $page = Versioned::get_one_by_stage("SiteTree", "Live", "{$bt}SiteTree{$bt}.{$bt}ID{$bt} = {$id}");
         }
         if (!$page) {
             return new HTTPResponse("Can't find Page #{$id}", 400);
         }
     } else {
         return new HTTPResponse("Bad ID", 400);
     }
     // If we are creating and approving a workflow in one step, then don't bother emailing
     $notify = !($actionName == 'action' && !$page->openWorkflowRequest($workflowClass));
     if ($request = $page->openOrNewWorkflowRequest($workflowClass, $notify)) {
         $request->clearMembersEmailed();
         if ($successMessage = $request->{$actionName}($comment, null, $notify)) {
             FormResponse::get_page($id);
             $title = Convert::raw2js($page->TreeTitle());
             FormResponse::add("\$('sitetree').setNodeTitle({$id}, \"{$title}\");");
             // gather members for status output
             if ($notify) {
                 $peeps = $request->getMembersEmailed();
                 if ($peeps && $peeps->Count()) {
                     $emails = '';
                     foreach ($peeps as $peep) {
                         if ($peep->Email) {
                             $emails .= $peep->Email . ', ';
                         }
                     }
                     $emails = trim($emails, ', ');
                 } else {
                     $emails = 'no-one';
                 }
             } else {
                 $emails = "no-one";
             }
             if ($successMessage) {
                 FormResponse::status_message(sprintf($successMessage, $emails), 'good');
                 return FormResponse::respond();
             } else {
                 return;
             }
         }
     }
     // Failure
     FormResponse::status_message(_t('SiteTreeCMSWorkflow.WORKFLOW_ACTION_FAILED', "There was an error when processing your workflow request."), 'bad');
     return FormResponse::respond();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:60,代码来源:LeftAndMainCMSWorkflow.php


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