本文整理汇总了PHP中WebRequest::getPostKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP WebRequest::getPostKeys方法的具体用法?PHP WebRequest::getPostKeys怎么用?PHP WebRequest::getPostKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebRequest
的用法示例。
在下文中一共展示了WebRequest::getPostKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runPage
protected function runPage()
{
try {
self::checkAccess('edit-access-levels');
$this->mSmarty->assign("readonly", '');
} catch (AccessDeniedException $ex) {
// caution: if you're copying this, this is a hack to make sure
// users know they don't have the access to do this, not
// to actually stop them from doing it, though it will have
// that effect to the non-tech-savvy.
$this->mSmarty->assign("readonly", 'disabled="disabled"');
}
if (WebRequest::wasPosted()) {
// make SURE we have the right access level for this operation
self::checkAccess('edit-access-levels');
foreach (WebRequest::getPostKeys() as $k) {
$entry = StaffAccess::getById($k);
if ($entry == null) {
continue;
}
if ($entry->getLevel() != WebRequest::postInt($k)) {
$entry->setLevel(WebRequest::postInt($k));
$entry->save();
}
}
global $cWebPath;
$this->mHeaders[] = "HTTP/1.1 303 See Other";
$this->mHeaders[] = "Location: " . $cWebPath . "/management.php/Access";
return;
}
$this->mBasePage = "mgmt/access.tpl";
$accesslist = array();
$accessKeys = StaffAccess::getKnownActions();
foreach ($accessKeys as $k) {
$accessEntry = StaffAccess::getByAction($k);
global $gLogger;
$gLogger->log("Access entry {$accessEntry->getAction()}({$accessEntry->getLevel()}) found!");
$accesslist[] = array(id => $accessEntry->getId(), name => $accessEntry->getAction(), value => $accessEntry->getLevel());
}
$this->mSmarty->assign("accesslist", $accesslist);
}
示例2: save
private function save()
{
$keys = WebRequest::getPostKeys();
foreach ($keys as $k) {
// extract id from POST request
$id = str_replace("lang", "", $k);
$id = str_replace("msg", "", $id);
if (!is_numeric($id)) {
throw new ArgumentException("{$k}: [{$id}] is not an integer", 0);
}
// retrieve message object
$message = Message::getById($id);
if ($message == null) {
throw new ArgumentException("Message ID {$id} could not be found");
}
$value = WebRequest::post($k);
if ($message->getContent != $value) {
// write content
$message->setContent($value);
// save object
$message->save();
}
}
}