本文整理汇总了PHP中Pages::getAvailablePages方法的典型用法代码示例。如果您正苦于以下问题:PHP Pages::getAvailablePages方法的具体用法?PHP Pages::getAvailablePages怎么用?PHP Pages::getAvailablePages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pages
的用法示例。
在下文中一共展示了Pages::getAvailablePages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSchemas
public static function getSchemas()
{
$pages = array();
$prefix = Pages::getAvailablePages();
foreach ($prefix as $p) {
$pages[$p] = Pages::getSchema($p);
}
return $pages;
}
示例2: saveAction
public function saveAction()
{
// We'll need to access the pages database
$pages = new Pages();
// Is the form correctly posted ?
if (!$this->getRequest()->isPost()) {
throw new Stuffpress_Exception("Invalid request - must be post");
}
// Get the source from the request
$id = (int) $this->_getParam('id');
$type = (string) $this->_getParam('type');
// Validate the parameters
if (!($id >= 0 && in_array($type, Pages::getAvailablePages()))) {
throw new Stuffpress_Exception("Parameters failed validation");
}
// If it is an edit; are we the owner ?
if ($id > 0) {
// Does the page exist ?
if (!($page = $pages->getPage($id))) {
throw new Stuffpress_Exception("Unknown page with id {$id}");
}
// Are we the owner ?
if ($page['user_id'] != $this->_application->user->id) {
throw new Stuffpress_AccessDeniedException("Not the owner of page {$id}");
}
}
// Get the page descriptor
$model = Pages::getModel($type);
// Validate the form
$form = $model->getForm();
if (!$form->isValid($_POST)) {
return $this->_helper->json->sendJson($form->getErrorArray());
}
// Get the form values
$values = $form->getValues();
// Proceed and save the values
$title = @$values['title'];
// There shoudl always be a title
// Create the page if it does not exist
if ($id == 0) {
$id = $pages->addPage($type, $title);
} else {
$pages->setTitle($id, $title);
}
// Save the page configuration
$model->processForm($id, $values);
// Ok
return $this->_helper->json->sendJson(false);
}