当前位置: 首页>>代码示例>>PHP>>正文


PHP Page_Controller::setModel方法代码示例

本文整理汇总了PHP中Page_Controller::setModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Page_Controller::setModel方法的具体用法?PHP Page_Controller::setModel怎么用?PHP Page_Controller::setModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page_Controller的用法示例。


在下文中一共展示了Page_Controller::setModel方法的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 (Director::redirected_to()) {
         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->setModel($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) {
         Requirements::css(SAPPHIRE_DIR . "/css/Form.css");
         // Needed because the <base href=".."> in the template makes problems
         // with the tabstrip library otherwise
         $link_base = Director::absoluteURL($this->Link("login"));
         Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
         Requirements::javascript(SAPPHIRE_DIR . "/javascript/jquery_improvements.js");
         Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
         Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
         Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
         Requirements::css(SAPPHIRE_DIR . '/css/Security_login.css');
         Requirements::javascript(SAPPHIRE_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'));
 }
开发者ID:,项目名称:,代码行数:84,代码来源:


注:本文中的Page_Controller::setModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。