本文整理汇总了PHP中Page_Controller::setDataModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Page_Controller::setDataModel方法的具体用法?PHP Page_Controller::setDataModel怎么用?PHP Page_Controller::setDataModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page_Controller
的用法示例。
在下文中一共展示了Page_Controller::setDataModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Show the "login" page
*
* @return string Returns the "login" page as HTML code.
*/
public function login()
{
// Event handler for pre-login, with an option to let it break you out of the login form
$eventResults = $this->extend('onBeforeSecurityLogin');
// If there was a redirection, return
if ($this->redirectedTo()) {
return;
} else {
if ($eventResults) {
foreach ($eventResults as $result) {
if ($result instanceof SS_HTTPResponse) {
return $result;
}
}
}
}
$customCSS = project() . '/css/tabs.css';
if (Director::fileExists($customCSS)) {
Requirements::css($customCSS);
}
if (class_exists('SiteTree')) {
$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOGIN', 'Log in');
$tmpPage->URLSegment = "Security";
// Disable ID-based caching of the log-in page by making it a random number
$tmpPage->ID = -1 * rand(1, 10000000);
$controller = new Page_Controller($tmpPage);
$controller->setDataModel($this->model);
$controller->init();
//Controller::$currentController = $controller;
} else {
$controller = $this;
}
$content = '';
$forms = $this->GetLoginForms();
if (!count($forms)) {
user_error('No login-forms found, please use Authenticator::register_authenticator() to add one', E_USER_ERROR);
}
// only display tabs when more than one authenticator is provided
// to save bandwidth and reduce the amount of custom styling needed
if (count($forms) > 1) {
// Needed because the <base href=".."> in the template makes problems
// with the tabstrip library otherwise
$link_base = Director::absoluteURL($this->Link("login"));
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
Requirements::css(FRAMEWORK_DIR . '/css/Security_login.css');
Requirements::javascript(FRAMEWORK_DIR . '/javascript/TabSet.js');
$content = '<div id="Form_EditForm">';
$content .= '<div class="ss-tabset">';
$content .= '<ul>';
$content_forms = '';
foreach ($forms as $form) {
$content .= "<li><a href=\"#{$form->FormName()}_tab\">" . $form->getAuthenticator()->get_name() . "</a></li>\n";
$content_forms .= '<div class="tab" id="' . $form->FormName() . '_tab">' . $form->forTemplate() . "</div>\n";
}
$content .= "</ul>\n" . $content_forms . "\n</div>\n</div>\n";
} else {
$content .= $forms[0]->forTemplate();
}
if (strlen($message = Session::get('Security.Message.message')) > 0) {
$message_type = Session::get('Security.Message.type');
if ($message_type == 'bad') {
$message = "<p class=\"message {$message_type}\">{$message}</p>";
} else {
$message = "<p>{$message}</p>";
}
$customisedController = $controller->customise(array("Content" => $message, "Form" => $content));
} else {
$customisedController = $controller->customise(array("Form" => $content));
}
Session::clear('Security.Message');
// custom processing
return $customisedController->renderWith(array('Security_login', 'Security', $this->stat('template_main'), 'BlankPage'));
}