本文整理汇总了PHP中AjaxResponseObject::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponseObject::setData方法的具体用法?PHP AjaxResponseObject::setData怎么用?PHP AjaxResponseObject::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponseObject
的用法示例。
在下文中一共展示了AjaxResponseObject::setData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
if (isset($this->params["categoryIndex"]) && isset($this->params["value"])) {
$data = array();
$oldValue = $this->getEntryField($this->object, $this->categoryIndex, $this->entryIndex, $this->field);
try {
$this->setEntryField($this->object, $this->categoryIndex, $this->entryIndex, $this->field, $this->value);
} catch (steam_exception $e) {
$data["oldValue"] = $oldValue;
$data["error"] = $e->get_message();
$data["undo"] = false;
$ajaxResponseObject->setStatus("ok");
$ajaxResponseObject->setData($data);
return $ajaxResponseObject;
}
$ajaxResponseObject->setStatus("ok");
$newValue = $this->getEntryField($this->object, $this->categoryIndex, $this->entryIndex, $this->field);
if ($newValue === $this->params["value"]) {
$data["oldValue"] = $oldValue;
$data["newValue"] = $newValue;
$data["error"] = "none";
$data["undo"] = true;
} else {
$data["oldValue"] = $oldValue;
$data["error"] = "Data could not be saved.";
$data["undo"] = false;
}
$ajaxResponseObject->setData($data);
} else {
$ajaxResponseObject->setStatus("error");
}
return $ajaxResponseObject;
}
示例2: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
$sanctions_result = array();
$sanctions = $this->object->get_sanction();
foreach ($sanctions as $id => $sanction) {
if ($sanction | SANCTION_READ) {
$sanctions_result[] = "read_{$id}";
}
if ($sanction | SANCTION_WRITE) {
$sanctions_result[] = "write_{$id}";
}
if ($sanction | SANCTION_SANCTION) {
$sanctions_result[] = "sanction_{$id}";
}
}
$ajaxResponseObject->setStatus("ok");
$ajaxResponseObject->setData(array("acquire" => $this->object->get_acquire(), "sanctions" => $sanctions_result));
return $ajaxResponseObject;
}
示例3: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
$data = array();
if (isset($this->params["attribute"]) && isset($this->params["value"])) {
$oldValue = self::getAttributeValue($this->object, $this->params["attribute"]);
try {
self::setAttributeValue($this->object, $this->params["attribute"], $this->params["value"]);
} catch (steam_exception $e) {
$data["oldValue"] = $oldValue;
$data["error"] = $e->get_message();
$data["undo"] = false;
$ajaxResponseObject->setStatus("ok");
$ajaxResponseObject->setData($data);
return $ajaxResponseObject;
}
$ajaxResponseObject->setStatus("ok");
$newValue = self::getAttributeValue($this->object, $this->params["attribute"]);
if ($newValue === $this->params["value"]) {
$data["oldValue"] = $oldValue;
$data["newValue"] = $newValue;
$data["error"] = "none";
$data["undo"] = true;
} else {
$data["oldValue"] = $oldValue;
$data["error"] = "Data could not be saved.";
$data["undo"] = false;
}
$ajaxResponseObject->setData($data);
} else {
if (isset($this->params["value"]) && !isset($this->params["attribute"]) && $this->object instanceof steam_document) {
$oldValue = $this->object->get_content();
try {
$this->object->set_content(cleanHTML($this->params["value"]));
} catch (steam_exception $e) {
$data["oldValue"] = $oldValue;
$data["error"] = $e->get_message();
$data["undo"] = false;
$ajaxResponseObject->setStatus("ok");
$ajaxResponseObject->setData($data);
return $ajaxResponseObject;
}
$ajaxResponseObject->setStatus("ok");
$newValue = $this->object->get_content();
//if ($newValue === $this->params["value"]) {
$data["oldValue"] = $oldValue;
$data["newValue"] = $newValue;
$data["error"] = "none";
$data["undo"] = true;
// } else {
// $data["oldValue"] = $oldValue;
// $data["error"] = "Data could not be saved.";
// $data["undo"] = false;
// }
$ajaxResponseObject->setData($data);
} else {
if (isset($this->params["annotate"])) {
$newValue = $this->params["annotate"];
$oldValue = "";
try {
$annotation = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "Annotation", $newValue, "text/plain");
$this->object->add_annotation($annotation);
$data["oldValue"] = "";
$data["newValue"] = "";
$data["error"] = "none";
$data["undo"] = false;
} catch (steam_exception $e) {
$data["oldValue"] = "";
$data["error"] = $e->get_message();
$data["undo"] = false;
}
$ajaxResponseObject->setStatus("ok");
$ajaxResponseObject->setData($data);
return $ajaxResponseObject;
} else {
$ajaxResponseObject->setStatus("error");
}
}
}
return $ajaxResponseObject;
}