本文整理汇总了PHP中FormResponse::error方法的典型用法代码示例。如果您正苦于以下问题:PHP FormResponse::error方法的具体用法?PHP FormResponse::error怎么用?PHP FormResponse::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormResponse
的用法示例。
在下文中一共展示了FormResponse::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxupdatesort
/**
* Ajax handler for updating the order of a number of tree nodes
* $_GET[ID]: An array of node ids in the correct order
* $_GET[MovedNodeID]: The node that actually got moved
*/
public function ajaxupdatesort() {
$className = $this->stat('tree_class');
$counter = 0;
$js = '';
$_REQUEST['ajax'] = 1;
if(is_array($_REQUEST['ID'])) {
if($_REQUEST['MovedNodeID']==0){ //Sorting root
$movedNode = DataObject::get($className, "`ParentID`=0");
}else{
$movedNode = DataObject::get_by_id($className, $_REQUEST['MovedNodeID']);
}
foreach($_REQUEST['ID'] as $id) {
if($id == $movedNode->ID) {
$movedNode->Sort = ++$counter;
$movedNode->Status = "Saved (update)";
$movedNode->write();
$title = Convert::raw2js($movedNode->TreeTitle());
$js .="$('sitetree').setNodeTitle($movedNode->ID, \"$title\");\n";
// Nodes that weren't "actually moved" shouldn't be registered as having been edited; do a direct SQL update instead
} else if(is_numeric($id)) {
++$counter;
DB::query("UPDATE `$className` SET `Sort` = $counter WHERE `ID` = '$id'");
}
}
// Virtual pages require selected to be null if the page is the same.
FormResponse::add(
"if( $('sitetree').selected && $('sitetree').selected[0]){
var idx = $('sitetree').selected[0].getIdx();
if(idx){
$('Form_EditForm').getPageFromServer(idx);
}
}\n" . $js
);
FormResponse::status_message(_t('LeftAndMain.SAVED'), 'good');
} else {
FormResponse::error(_t('LeftAndMain.REQUESTERROR',"Error in request"));
}
return FormResponse::respond();
}
示例2: ajaxupdatesort
/**
* Ajax handler for updating the order of a number of tree nodes
* $_GET[ID]: An array of node ids in the correct order
* $_GET[MovedNodeID]: The node that actually got moved
*/
public function ajaxupdatesort()
{
$className = $this->stat('tree_class');
$counter = 0;
$js = '';
$_REQUEST['ajax'] = 1;
if (!Permission::check('SITETREE_REORGANISE') && !Permission::check('ADMIN')) {
FormResponse::status_message(_t('LeftAndMain.CANT_REORGANISE', "You do not have permission to rearange the site tree. Your change was not saved."), "bad");
return FormResponse::respond();
}
if (is_array($_REQUEST['ID'])) {
if ($_REQUEST['MovedNodeID'] == 0) {
//Sorting root
$movedNode = DataObject::get($className, "\"ParentID\"=0");
} else {
$movedNode = DataObject::get_by_id($className, $_REQUEST['MovedNodeID']);
}
foreach ($_REQUEST['ID'] as $id) {
if ($id == $movedNode->ID) {
$movedNode->Sort = ++$counter;
$movedNode->Status = "Saved (update)";
$movedNode->write();
$title = Convert::raw2js($movedNode->TreeTitle());
$js .= "\$('sitetree').setNodeTitle({$movedNode->ID}, \"{$title}\");\n";
// Nodes that weren't "actually moved" shouldn't be registered as having been edited; do a direct SQL update instead
} else {
if (is_numeric($id)) {
++$counter;
DB::query("UPDATE \"{$className}\" SET \"Sort\" = {$counter} WHERE \"ID\" = '{$id}'");
}
}
}
FormResponse::status_message(_t('LeftAndMain.SAVED'), 'good');
} else {
FormResponse::error(_t('LeftAndMain.REQUESTERROR', "Error in request"));
}
return FormResponse::respond();
}