本文整理汇总了PHP中CMSForm::sessionMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSForm::sessionMessage方法的具体用法?PHP CMSForm::sessionMessage怎么用?PHP CMSForm::sessionMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMSForm
的用法示例。
在下文中一共展示了CMSForm::sessionMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
public function clear($data, CMSForm $form)
{
if (isset($data['ToClear'])) {
$cleared = array();
foreach ($data['ToClear'] as $name) {
$cache = $this->getCache($name);
if ($cache) {
if (isset($data['Key']) && strlen($data['Key'])) {
$cache->delete($data['Key']);
} else {
$cache->clear();
}
$cleared[] = $name;
}
}
$cleared = implode(',', $cleared);
$form->sessionMessage("Cleared {$cleared}", 'good');
} else {
$form->sessionMessage("No caches cleared", 'good');
}
return $form->getResponseNegotiator()->respond($this->getRequest());
}
示例2: doAddMockChildren
/**
* Handles the creation of mock children with {@link MockDataBuilder}
*
* @param array $data The data passed in from the form
* @param CMSForm $form The Form object that was used
* @return SSViewer
*/
public function doAddMockChildren($data, $form)
{
$parentPage = SiteTree::get()->byID((int) $data['ID']);
if (!$parentPage) {
return false;
}
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
$builder = new MockDataBuilder($className);
$builder->setCount((int) $data['Count'])->setIncludeRelations((bool) $data['IncludeRelations'])->setDownloadImages((bool) $data['DownloadImages'])->setParentField("ParentID")->setParentObj($parentPage);
try {
$ids = $builder->generate();
} catch (Exception $e) {
$form->sessionMessage($e->getMessage(), "bad");
return $this->redirectBack();
}
$this->response->addHeader('X-Status', _t('MockData.CREATESUCCESS', 'Created {count} mock children under {title}', array('count' => $data['Count'], 'title' => $parentPage->Title)));
$this->redirect(Controller::join_links(singleton('CMSPagesController')->Link()));
return $this->getResponseNegotiator()->respond($this->request);
}