本文整理汇总了PHP中PageLayout::save方法的典型用法代码示例。如果您正苦于以下问题:PHP PageLayout::save方法的具体用法?PHP PageLayout::save怎么用?PHP PageLayout::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageLayout
的用法示例。
在下文中一共展示了PageLayout::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function app_model_settings($request, $app_label = false, $model = false)
{
$templateArr = array('current_admin_menu' => $app_label, 'current_admin_submenu' => $model, 'current_admin_submenu2' => 'Settings', 'title' => __(sprintf('%s %s Settings', $app_label, $model)));
$coreApps = array('Post');
$app_label0 = $app_label;
if (in_array($app_label, $coreApps)) {
$app_label = sprintf('Pjango\\Contrib\\%s', $app_label);
}
$contentType = ContentType::get_for_model($model, $app_label);
$formClass = sprintf('%s\\Forms\\%sSettingsForm', $app_label, $model);
$formData = array();
$ignoredSettings = array('is_active', 'title', 'show_title', 'category_id', 'content');
$settings = Doctrine_Query::create()->from('Settings o')->where('o.category = ? AND o.site_id = ? ', array($app_label, SITE_ID))->fetchArray();
foreach ($settings as $settingsValue) {
$formData[$settingsValue['name']] = $settingsValue['value'];
}
if (class_exists('PageLayout')) {
$pageLayout = Doctrine_Query::create()->from('PageLayout o')->where('o.site_id = ? AND o.content_type_id = ?', array(SITE_ID, $contentType->id))->fetchOne();
if ($pageLayout) {
$formData = array_merge($formData, $pageLayout->toArray());
}
}
if ($request->POST) {
$form = new $formClass($request->POST);
try {
if (!$form->is_valid()) {
throw new Exception(pjango_gettext('There are some errors, please correct them below.'));
}
$formData = $form->cleaned_data();
if (class_exists('PageLayout')) {
if (!$pageLayout) {
$pageLayout = new PageLayout();
}
$pageLayout->fromArray($formData);
$pageLayout->content_type_id = $contentType->id;
$pageLayout->site_id = SITE_ID;
$pageLayout->save();
}
foreach ($formData as $key => $value) {
if (in_array($key, $ignoredSettings)) {
unset($formData[$key]);
}
}
Settings::saveFromArray($app_label, $formData);
Messages::Info('The operation completed successfully');
HttpResponseRedirect(sprintf('/admin/%s/%s/settings/', $app_label0, $model));
} catch (Exception $e) {
Messages::Error($e->getMessage());
}
}
if (!$form) {
$form = new $formClass($formData);
}
$templateArr['addchange_form'] = $form;
render_to_response('admin/addchange.html', $templateArr);
}