本文整理汇总了PHP中FormResponse::update_status方法的典型用法代码示例。如果您正苦于以下问题:PHP FormResponse::update_status方法的具体用法?PHP FormResponse::update_status怎么用?PHP FormResponse::update_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormResponse
的用法示例。
在下文中一共展示了FormResponse::update_status方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tellBrowserAboutPublicationChange
/**
* Return a few pieces of information about a change to a page
* - Send the new status message
* - Update the action buttons
* - Update the treenote
* - Send a status message
*/
function tellBrowserAboutPublicationChange($page, $statusMessage)
{
$JS_title = Convert::raw2js($page->TreeTitle());
$JS_stageURL = $page->IsDeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = {$page->ID}");
$JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
FormResponse::add($this->getActionUpdateJS($page));
FormResponse::update_status($page->Status);
if ($JS_stageURL || $JS_liveURL) {
FormResponse::add("\$('sitetree').setNodeTitle({$page->ID}, '{$JS_title}');");
} else {
FormResponse::add("var node = \$('sitetree').getTreeNodeByIdx('{$page->ID}');");
FormResponse::add("if(node && node.parentTreeNode) node.parentTreeNode.removeTreeNode(node);");
FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$page->ID});");
}
if ($statusMessage) {
FormResponse::status_message($statusMessage, 'good');
}
FormResponse::add("\$('Form_EditForm').elements.StageURLSegment.value = '{$JS_stageURL}';");
FormResponse::add("\$('Form_EditForm').elements.LiveURLSegment.value = '{$JS_liveURL}';");
FormResponse::add("\$('Form_EditForm').notify('PagePublished', \$('Form_EditForm').elements.ID.value);");
return FormResponse::respond();
}
示例2: save
/**
* Save and Publish page handler
*/
public function save($urlParams, $form) {
$className = $this->stat('tree_class');
$result = '';
$SQL_id = Convert::raw2sql($_REQUEST['ID']);
if(substr($SQL_id,0,3) != 'new') {
$record = DataObject::get_one($className, "`$className`.ID = {$SQL_id}");
if($record && !$record->canEdit()) return Security::permissionFailure($this);
} else {
if(!singleton($this->stat('tree_class'))->canCreate()) return Security::permissionFailure($this);
$record = $this->getNewItem($SQL_id, false);
}
// We don't want to save a new version if there are no changes
$dataFields_new = $form->Fields()->dataFields();
$dataFields_old = $record->getAllFields();
$changed = false;
$hasNonRecordFields = false;
foreach($dataFields_new as $datafield) {
// if the form has fields not belonging to the record
if(!isset($dataFields_old[$datafield->Name()])) {
$hasNonRecordFields = true;
}
// if field-values have changed
if(!isset($dataFields_old[$datafield->Name()]) || $dataFields_old[$datafield->Name()] != $datafield->dataValue()) {
$changed = true;
}
}
if(!$changed && !$hasNonRecordFields) {
// Tell the user we have saved even though we haven't, as not to confuse them
if(is_a($record, "Page")) {
$record->Status = "Saved (update)";
}
FormResponse::status_message(_t('LeftAndMain.SAVEDUP',"Saved"), "good");
FormResponse::update_status($record->Status);
return FormResponse::respond();
}
$form->dataFieldByName('ID')->Value = 0;
if(isset($urlParams['Sort']) && is_numeric($urlParams['Sort'])) {
$record->Sort = $urlParams['Sort'];
}
// HACK: This should be turned into something more general
$originalClass = $record->ClassName;
$originalStatus = $record->Status;
$record->HasBrokenLink = 0;
$record->HasBrokenFile = 0;
$record->writeWithoutVersion();
// HACK: This should be turned into something more general
$originalURLSegment = $record->URLSegment;
$form->saveInto($record, true);
if(is_a($record, "Page")) {
$record->Status = ($record->Status == "New page" || $record->Status == "Saved (new)") ? "Saved (new)" : "Saved (update)";
}
// $record->write();
if(Director::is_ajax()) {
if($SQL_id != $record->ID) {
FormResponse::add("$('sitetree').setNodeIdx(\"{$SQL_id}\", \"$record->ID\");");
FormResponse::add("$('Form_EditForm').elements.ID.value = \"$record->ID\";");
}
if($added = DataObjectLog::getAdded('SiteTree')) {
foreach($added as $page) {
if($page->ID != $record->ID) $result .= $this->addTreeNodeJS($page);
}
}
if($deleted = DataObjectLog::getDeleted('SiteTree')) {
foreach($deleted as $page) {
if($page->ID != $record->ID) $result .= $this->deleteTreeNodeJS($page);
}
}
if($changed = DataObjectLog::getChanged('SiteTree')) {
foreach($changed as $page) {
if($page->ID != $record->ID) {
$title = Convert::raw2js($page->TreeTitle());
FormResponse::add("$('sitetree').setNodeTitle($page->ID, \"$title\");");
}
}
}
$message = _t('LeftAndMain.SAVEDUP');
// Update the icon if the class has changed
if($originalClass != $record->ClassName) {
//.........这里部分代码省略.........
示例3: save
/**
* Save generic data handler
*
* @return String Statusmessage
*/
function save($urlParams, $form)
{
$className = $this->stat('data_type');
$id = $_REQUEST['ID'];
if (substr($id, 0, 3) != 'new') {
$generic = DataObject::get_one($className, "`{$className}`.ID = {$id}");
$generic->Status = "Saved (Update)";
} else {
$generic = new $className();
$generic->Status = "Saved (New)";
}
$form->saveInto($generic, true);
$id = $generic->write();
if ($this->stat('data_type_extra')) {
foreach ($this->stat('data_type_extra') as $oneRelated) {
$oneExtra = $generic->{$oneRelated}();
if ($_REQUEST[$oneExtra->class]) {
foreach ($_REQUEST[$oneExtra->class] as $field => $value) {
$oneExtra->setField($field, $value);
}
$oneExtra->write();
}
}
}
$this->getActionUpdateJS($generic);
FormResponse::status_message(_t('GenericDataAdmin.SAVED', 'Saved'), 'good');
FormResponse::update_status($generic->Status);
if (method_exists($this, "saveAfterCall")) {
$this->saveAfterCall($generic, $urlParams, $form);
}
return FormResponse::respond();
}
示例4: save
/**
* Save and Publish page handler
*/
public function save($urlParams, $form)
{
$className = $this->stat('tree_class');
$SQL_id = Convert::raw2sql($_REQUEST['ID']);
if (substr($SQL_id, 0, 3) != 'new') {
$record = DataObject::get_one($className, "\"{$className}\".\"ID\" = {$SQL_id}");
if ($record && !$record->canEdit()) {
return Security::permissionFailure($this);
}
} else {
if (!singleton($this->stat('tree_class'))->canCreate()) {
return Security::permissionFailure($this);
}
$record = $this->getNewItem($SQL_id, false);
}
// We don't want to save a new version if there are no changes
$dataFields_new = $form->Fields()->dataFields();
$dataFields_old = $record->getAllFields();
$changed = false;
$hasNonRecordFields = false;
foreach ($dataFields_new as $datafield) {
// if the form has fields not belonging to the record
if (!isset($dataFields_old[$datafield->Name()])) {
$hasNonRecordFields = true;
}
// if field-values have changed
if (!isset($dataFields_old[$datafield->Name()]) || $dataFields_old[$datafield->Name()] != $datafield->dataValue()) {
$changed = true;
}
}
if (!$changed && !$hasNonRecordFields) {
// Tell the user we have saved even though we haven't, as not to confuse them
if (is_a($record, "Page")) {
$record->Status = "Saved (update)";
}
FormResponse::status_message(_t('LeftAndMain.SAVEDUP', "Saved"), "good");
FormResponse::update_status($record->Status);
return FormResponse::respond();
}
$form->dataFieldByName('ID')->Value = 0;
if (isset($urlParams['Sort']) && is_numeric($urlParams['Sort'])) {
$record->Sort = $urlParams['Sort'];
}
// HACK: This should be turned into something more general
$originalClass = $record->ClassName;
$originalStatus = $record->Status;
$originalParentID = $record->ParentID;
$originalBrokenLinkValues = $record->HasBrokenLink . $record->HasBrokenFile;
$record->HasBrokenLink = 0;
$record->HasBrokenFile = 0;
$record->writeWithoutVersion();
// HACK: This should be turned into something more general
$originalURLSegment = $record->URLSegment;
$form->saveInto($record, true);
if (is_a($record, "Page")) {
$record->Status = $record->Status == "New page" || $record->Status == "Saved (new)" ? "Saved (new)" : "Saved (update)";
}
if (Director::is_ajax()) {
if ($SQL_id != $record->ID) {
FormResponse::add("\$('sitetree').setNodeIdx(\"{$SQL_id}\", \"{$record->ID}\");");
FormResponse::add("\$('Form_EditForm').elements.ID.value = \"{$record->ID}\";");
}
if ($added = DataObjectLog::getAdded('SiteTree')) {
foreach ($added as $page) {
if ($page->ID != $record->ID) {
FormResponse::add($this->addTreeNodeJS($page));
}
}
}
if ($deleted = DataObjectLog::getDeleted('SiteTree')) {
foreach ($deleted as $page) {
if ($page->ID != $record->ID) {
FormResponse::add($this->deleteTreeNodeJS($page));
}
}
}
if ($changed = DataObjectLog::getChanged('SiteTree')) {
foreach ($changed as $page) {
if ($page->ID != $record->ID) {
$title = Convert::raw2js($page->TreeTitle());
FormResponse::add("\$('sitetree').setNodeTitle({$page->ID}, \"{$title}\");");
}
}
}
$message = _t('LeftAndMain.SAVEDUP');
// Update the class instance if necessary
if ($originalClass != $record->ClassName) {
$newClassName = $record->ClassName;
// The records originally saved attribute was overwritten by $form->saveInto($record) before.
// This is necessary for newClassInstance() to work as expected, and trigger change detection
// on the ClassName attribute
$record->setClassName($originalClass);
// Replace $record with a new instance
$record = $record->newClassInstance($newClassName);
// update the tree icon
FormResponse::add("if(\$('sitetree').setNodeIcon) \$('sitetree').setNodeIcon({$record->ID}, '{$originalClass}', '{$record->ClassName}');");
}
//.........这里部分代码省略.........
示例5: cms_publishwithcomment
public function cms_publishwithcomment($urlParams, $form)
{
$className = 'SiteTree';
$SQL_id = Convert::raw2sql($_REQUEST['ID']);
if (substr($SQL_id, 0, 3) != 'new') {
$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
$record = DataObject::get_one($className, "{$bt}{$className}{$bt}.{$bt}ID{$bt} = {$SQL_id}");
if ($record && !$record->canEdit()) {
return Security::permissionFailure($this);
}
} else {
if (!singleton($this->stat('tree_class'))->canCreate()) {
return Security::permissionFailure($this);
}
$record = $this->getNewItem($SQL_id, false);
}
// We don't want to save a new version if there are no changes
$dataFields_new = $form->Fields()->dataFields();
$dataFields_old = $record->getAllFields();
$changed = false;
$hasNonRecordFields = false;
foreach ($dataFields_new as $datafield) {
// if the form has fields not belonging to the record
if (!isset($dataFields_old[$datafield->Name()])) {
$hasNonRecordFields = true;
}
// if field-values have changed
if (!isset($dataFields_old[$datafield->Name()]) || $dataFields_old[$datafield->Name()] != $datafield->dataValue()) {
$changed = true;
}
}
if (!$changed && !$hasNonRecordFields) {
// Tell the user we have saved even though we haven't, as not to confuse them
if (is_a($record, "Page")) {
$record->Status = "Saved (update)";
}
FormResponse::status_message(_t('LeftAndMain.SAVEDUP', "Saved"), "good");
FormResponse::update_status($record->Status);
return FormResponse::respond();
}
$form->dataFieldByName('ID')->Value = 0;
if (isset($urlParams['Sort']) && is_numeric($urlParams['Sort'])) {
$record->Sort = $urlParams['Sort'];
}
// HACK: This should be turned into something more general
$originalClass = $record->ClassName;
$originalStatus = $record->Status;
$originalParentID = $record->ParentID;
$record->HasBrokenLink = 0;
$record->HasBrokenFile = 0;
$record->writeWithoutVersion();
// HACK: This should be turned into something more general
$originalURLSegment = $record->URLSegment;
$form->saveInto($record, true);
if (is_a($record, "Page")) {
$record->Status = $record->Status == "New page" || $record->Status == "Saved (new)" ? "Saved (new)" : "Saved (update)";
}
if (Director::is_ajax()) {
if ($SQL_id != $record->ID) {
FormResponse::add("\$('sitetree').setNodeIdx(\"{$SQL_id}\", \"{$record->ID}\");");
FormResponse::add("\$('Form_EditForm').elements.ID.value = \"{$record->ID}\";");
}
if ($added = DataObjectLog::getAdded('SiteTree')) {
foreach ($added as $page) {
if ($page->ID != $record->ID) {
FormResponse::add($this->addTreeNodeJS($page));
}
}
}
if ($deleted = DataObjectLog::getDeleted('SiteTree')) {
foreach ($deleted as $page) {
if ($page->ID != $record->ID) {
FormResponse::add($this->deleteTreeNodeJS($page));
}
}
}
if ($changed = DataObjectLog::getChanged('SiteTree')) {
foreach ($changed as $page) {
if ($page->ID != $record->ID) {
$title = Convert::raw2js($page->TreeTitle());
FormResponse::add("\$('sitetree').setNodeTitle({$page->ID}, \"{$title}\");");
}
}
}
$message = _t('LeftAndMain.SAVEDUP');
// Update the class instance if necessary
if ($originalClass != $record->ClassName) {
$newClassName = $record->ClassName;
// The records originally saved attribute was overwritten by $form->saveInto($record) before.
// This is necessary for newClassInstance() to work as expected, and trigger change detection
// on the ClassName attribute
$record->setClassName($originalClass);
// Replace $record with a new instance
$record = $record->newClassInstance($newClassName);
// update the tree icon
FormResponse::add("if(\$('sitetree').setNodeIcon) \$('sitetree').setNodeIcon({$record->ID}, '{$originalClass}', '{$record->ClassName}');");
}
// HACK: This should be turned into somethign more general
if ($record->class == 'VirtualPage' && $originalURLSegment != $record->URLSegment || $originalClass != $record->ClassName || LeftAndMain::$ForceReload == true) {
FormResponse::add("\$('Form_EditForm').getPageFromServer({$record->ID});");
//.........这里部分代码省略.........