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


PHP ErrorPage::response_for方法代码示例

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


在下文中一共展示了ErrorPage::response_for方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBeforeHTTPError

 public function onBeforeHTTPError($statusCode, $request)
 {
     $response = ErrorPage::response_for($statusCode);
     if ($response) {
         throw new SS_HTTPResponse_Exception($response, $statusCode);
     }
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:7,代码来源:ErrorPageControllerExtension.php

示例2: httpError

 public function httpError($code, $message = null)
 {
     if (!Permission::check("ADMIN")) {
         $response = ErrorPage::response_for($code);
     }
     if (empty($response)) {
         $response = $message;
     }
     throw new SS_HTTPResponse_Exception($response);
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:10,代码来源:SafeXSSForm.php

示例3: ipn

 /**
  * Process IPN request from ClickBank. Only process POST request
  * 
  * @param	object	$_POST
  * @return	int		HTTP code 
  */
 public function ipn(SS_HTTPRequest $request)
 {
     if ($request->isPost()) {
         if (ClickBankManager::validate_ipn_request($request->postVars())) {
             ClickBankManager::process_ipn_request($request->postVars());
             return Director::get_status_code();
         }
     }
     return ErrorPage::response_for(404);
 }
开发者ID:rixrix,项目名称:silverstripe-clickbank,代码行数:16,代码来源:ClickBankController.php

示例4: onBeforeInit

 function onBeforeInit()
 {
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(403);
             }
             $response = $response ? $response : 'The requested page could not be found.';
             return $this->owner->httpError(403, $response);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-adminlogin,代码行数:13,代码来源:LimitAdminAccessExtension.php

示例5: init

 public function init()
 {
     parent::init();
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             $reponse = '';
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(404);
             }
             return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.');
         }
     }
     // this prevents loading frontend css and javscript files
     Requirements::clear();
     Requirements::css('adminlogin/css/style.css');
 }
开发者ID:sheadawson,项目名称:silverstripe-adminlogin,代码行数:17,代码来源:AdminLogin.php

示例6: renderBox

 /**
  * Tries to find the lightbox based on the id given.
  *
  * @param $request
  * @return HTMLText
  * @throws SS_HTTPResponse_Exception
  */
 public function renderBox($request)
 {
     $url = $request->param('URLSegment');
     $id = (int) preg_replace('/lightbox\\-/', '', $url);
     $lightbox = DataObject::get_by_id('Lightbox', $id);
     if ($lightbox) {
         $callback = $request->getVar('callback');
         $content = $lightbox->renderWith(get_class($lightbox));
         if ($callback) {
             $jsonContent = array('content' => $content->getValue());
             return "{$callback}(" . json_encode($jsonContent) . ");";
         } else {
             return $content;
         }
     }
     $this->httpError(404, ErrorPage::response_for(404));
 }
开发者ID:silverstripe-terraformers,项目名称:silverstripe-lightbox,代码行数:24,代码来源:LightboxController.php

示例7: handleList

 /**
  * Displays a list of all members on the site that belong to the selected
  * groups.
  *
  * @return string
  */
 public function handleList($request)
 {
     if (!$this->parent->AllowProfileViewing) {
         return ErrorPage::response_for(404);
     }
     $sort = $request->getVar('sort');
     if ($sort && singleton('Member')->hasDatabaseField($sort)) {
         $sort = sprintf('"%s"', Convert::raw2sql($sort));
     } else {
         $sort = '"ID"';
     }
     $groups = $this->parent->Groups();
     $fields = $this->parent->Fields('"MemberListVisible" = 1');
     // List all members that are in at least one of the groups on the
     // parent page.
     if (count($groups)) {
         $groups = implode(',', array_keys($groups->map()));
         $filter = "\"Group_Members\".\"GroupID\" IN ({$groups})";
         $join = 'LEFT JOIN "Group_Members" ' . 'ON "Member"."ID" = "Group_Members"."MemberID"';
     } else {
         $filter = $join = null;
     }
     $members = DataObject::get('Member', $filter, $sort, $join, array('start' => $this->getPaginationStart(), 'limit' => 25));
     if ($members && $fields) {
         foreach ($members as $member) {
             $data = new DataObjectSet();
             $public = $member->getPublicFields();
             foreach ($fields as $field) {
                 if ($field->PublicVisibility == 'MemberChoice' && !in_array($field->MemberField, $public)) {
                     $value = null;
                 } else {
                     $value = $member->{$field->MemberField};
                 }
                 $data->push(new ArrayData(array('MemberID' => $member->ID, 'Name' => $field->MemberField, 'Title' => $field->Title, 'Value' => $value, 'Sortable' => $member->hasDatabaseField($field->MemberField))));
             }
             $member->setField('Fields', $data);
         }
     }
     $this->data()->Title = _t('MemberProfiles.MEMBERLIST', 'Member List');
     $this->data()->Parent = $this->parent;
     $controller = $this->customise(array('Members' => $members));
     return $controller->renderWith(array('MemberProfileViewer_list', 'MemberProfileViewer', 'Page'));
 }
开发者ID:newsplash,项目名称:silverstripe-memberprofiles,代码行数:49,代码来源:MemberProfileViewer.php

示例8: init

 public function init()
 {
     parent::init();
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             $reponse = '';
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(404);
             }
             return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.');
         }
     }
     if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) {
         // this prevents loading frontend css and javscript files
         Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller');
         Requirements::css('adminlogin/css/style.css');
     }
     Object::useCustomClass('MemberLoginForm', 'AdminLoginForm');
 }
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-adminlogin,代码行数:20,代码来源:AdminLogin.php

示例9: postRequest

 /**
  *	Attempt to redirect towards the highest priority link mapping that may have been defined.
  *
  *	@URLparameter direct <{BYPASS_LINK_MAPPINGS}> boolean
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     // Bypass the request filter when requesting specific director rules such as "/admin" or "/dev".
     $requestURL = $request->getURL();
     $configuration = Config::inst();
     foreach ($configuration->get('Director', 'rules') as $segment => $controller) {
         // Retrieve the specific director rules.
         if (($position = strpos($segment, '$')) !== false) {
             $segment = rtrim(substr($segment, 0, $position), '/');
         }
         // Determine if the current request matches a specific director rule.
         if ($segment && strpos($requestURL, $segment) === 0) {
             // Continue processing the response.
             return true;
         }
     }
     // Bypass the request filter when using the direct GET parameter.
     if ($request->getVar('direct')) {
         // Continue processing the response.
         return true;
     }
     // Determine the default automated URL handling response status.
     $status = $response->getStatusCode();
     $success = $status >= 200 && $status < 300;
     $error = $status === 404;
     // Either hook into a page not found, or when enforced, replace the default automated URL handling.
     $enforce = $configuration->get('MisdirectionRequestFilter', 'enforce_misdirection');
     $replace = $configuration->get('MisdirectionRequestFilter', 'replace_default');
     if (($error || $enforce || $replace) && ($map = $this->service->getMappingByRequest($request))) {
         // Update the response code where appropriate.
         $responseCode = $map->ResponseCode;
         if ($responseCode == 0) {
             $responseCode = 303;
         } else {
             if ($responseCode == 301 && $map->ForwardPOSTRequest) {
                 $responseCode = 308;
             } else {
                 if ($responseCode == 303 && $map->ForwardPOSTRequest) {
                     $responseCode = 307;
                 }
             }
         }
         // Update the response using the link mapping redirection.
         $response->redirect($map->getLink(), $responseCode);
     } else {
         if ($error && ($fallback = $this->service->determineFallback($requestURL))) {
             // Update the response code where appropriate.
             $responseCode = $fallback['code'];
             if ($responseCode === 0) {
                 $responseCode = 303;
             }
             // Update the response using the fallback, enforcing no further redirection.
             $response->redirect(HTTP::setGetVar('direct', true, Controller::join_links(Director::absoluteBaseURL(), $fallback['link'])), $responseCode);
         } else {
             if (!$error && !$success && $replace) {
                 $response->setStatusCode(404);
                 // Retrieve the appropriate page not found response.
                 ClassInfo::exists('SiteTree') && ($page = ErrorPage::response_for(404)) ? $response->setBody($page->getBody()) : $response->setBody('No URL was matched!');
             }
         }
     }
     // Continue processing the response.
     return true;
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-misdirection,代码行数:69,代码来源:MisdirectionRequestFilter.php

示例10: getNestedController

 /**
  * @return ContentController
  */
 public function getNestedController()
 {
     $request = $this->request;
     if (!($URLSegment = $request->param('URLSegment'))) {
         throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.');
     }
     // Find page by link, regardless of current locale settings
     if (class_exists('Translatable')) {
         Translatable::disable_locale_filter();
     }
     $sitetree = DataObject::get_one('SiteTree', sprintf('"URLSegment" = \'%s\' %s', Convert::raw2sql(rawurlencode($URLSegment)), SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null));
     if (class_exists('Translatable')) {
         Translatable::enable_locale_filter();
     }
     if (!$sitetree) {
         // If a root page has been renamed, redirect to the new location.
         // See ContentController->handleRequest() for similiar logic.
         $redirect = self::find_old_page($URLSegment);
         if ($redirect) {
             $params = $request->getVars();
             if (isset($params['url'])) {
                 unset($params['url']);
             }
             $this->response = new SS_HTTPResponse();
             $this->response->redirect(Controller::join_links($redirect->Link(Controller::join_links($request->param('Action'), $request->param('ID'), $request->param('OtherID'))), $params ? '?' . http_build_query($params) : null), 301);
             return $this->response;
         }
         if ($response = ErrorPage::response_for(404)) {
             return $response;
         } else {
             $this->httpError(404, 'The requested page could not be found.');
         }
     }
     // Enforce current locale setting to the loaded SiteTree object
     if (class_exists('Translatable') && $sitetree->Locale) {
         Translatable::set_current_locale($sitetree->Locale);
     }
     if (isset($_REQUEST['debug'])) {
         Debug::message("Using record #{$sitetree->ID} of type {$sitetree->class} with link {$sitetree->Link()}");
     }
     return self::controller_for($sitetree, $this->request->param('Action'));
 }
开发者ID:nzjoel,项目名称:silverstripe-cms,代码行数:45,代码来源:ModelAsController.php

示例11: getInfo

 /**
  * Get information about the current movie to display.
  * Uses the OMDb API indirectly through the {@link MovieInformation->getInfo} function which
  * returns the XML body.
  *
  * Gets the rotten tomato information as well as the IMDb information. Also obtains both the
  * short and long version of the plot (at the expense of another query). In future this could
  * become configurable.
  *
  * @return ArrayData The information about the current pages movie
  */
 public function getInfo()
 {
     // This will get us XML body to play with as well as testing validity
     $body = $this->isValid();
     if ($body === false) {
         throw new SS_HTTPResponse_Exception(ErrorPage::response_for(404), 404);
     }
     $api = new RestfulService('http://www.omdbapi.com/');
     $results = $api->getAttributes($body, 'movie');
     $return = $results[0];
     // Get short plot as well
     $api->setQueryString(array('r' => 'xml', 'type' => 'movie', 't' => $this->Title, 'plot' => 'short', 'v' => 1));
     $results = $api->request();
     $results = $api->getAttributes($results->getBody(), 'movie');
     if ($results && !empty($results)) {
         $results = $results[0];
         $return->setField('shortPlot', $results->getField('plot'));
     }
     return $return;
 }
开发者ID:hughdavenport,项目名称:silverstripe-movieinformation,代码行数:31,代码来源:MovieInformation.php

示例12: index

 /**
  * Handle index requests
  */
 public function index()
 {
     if ($cart = $this->Cart()) {
         $this->redirect($cart->CartLink);
         return;
     } elseif ($response = ErrorPage::response_for(404)) {
         return $response;
     }
     return $this->httpError(404, _t("ShoppingCart.NOCARTINITIALISED", "no cart initialised"));
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:13,代码来源:ShoppingCart.php

示例13: httpError

 /**
  * @uses ErrorPage::response_for()
  */
 public function httpError($code, $message = null)
 {
     if ($this->request->isMedia() || !($response = ErrorPage::response_for($code))) {
         parent::httpError($code, $message);
     } else {
         throw new SS_HTTPResponse_Exception($response);
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:11,代码来源:ContentController.php

示例14: handleRequest

 public function handleRequest(SS_HTTPRequest $request, DataModel $model = null)
 {
     self::$is_at_root = true;
     $this->setDataModel($model);
     $this->pushCurrent();
     $this->init();
     if ($language = $request->param('Language')) {
         if (Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL')) {
             if (Config::inst()->get('MultilingualRootURLController', 'UseDashLocale')) {
                 //Language is missing a dash 404
                 if (strpos($language, '-') === false) {
                     //Locale not found 404
                     if ($response = ErrorPage::response_for(404)) {
                         return $response;
                     } else {
                         $this->httpError(404, 'The requested page could not be found.');
                     }
                     return $this->response;
                 }
                 $locale = explode('-', $language);
                 $locale[1] = strtoupper($locale[1]);
                 //Make sure that the language is all lowercase
                 if ($language == implode('-', $locale)) {
                     //Locale not found 404
                     if ($response = ErrorPage::response_for(404)) {
                         return $response;
                     } else {
                         $this->httpError(404, 'The requested page could not be found.');
                     }
                     return $this->response;
                 }
                 $locale = implode('_', $locale);
             } else {
                 $locale = $language;
             }
         } else {
             if (strpos($request->param('Language'), '_') !== false) {
                 //Locale not found 404
                 if ($response = ErrorPage::response_for(404)) {
                     return $response;
                 } else {
                     $this->httpError(404, 'The requested page could not be found.');
                 }
                 return $this->response;
             } else {
                 $locale = i18n::get_locale_from_lang($language);
             }
         }
         if (in_array($locale, Translatable::get_allowed_locales())) {
             Cookie::set('language', $language);
             Translatable::set_current_locale($locale);
             i18n::set_locale($locale);
             if (!DB::isActive() || !ClassInfo::hasTable('SiteTree')) {
                 $this->response = new SS_HTTPResponse();
                 $this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
                 return $this->response;
             }
             $request->setUrl($language . '/' . self::get_homepage_link() . '/');
             $request->match('$Language/$URLSegment//$Action', true);
             $controller = new MultilingualModelAsController();
             $result = $controller->handleRequest($request, $model);
             $this->popCurrent();
             return $result;
         } else {
             //URL Param Locale is not allowed so redirect to default
             $this->redirect(Controller::join_links(Director::baseURL(), Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL') ? Translatable::default_locale() : Translatable::default_lang()) . '/', 301);
             $this->popCurrent();
             return $this->response;
         }
     }
     //No Locale Param so detect browser language and redirect
     if ($locale = self::detect_browser_locale()) {
         if (Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL')) {
             if (Config::inst()->get('MultilingualRootURLController', 'UseDashLocale')) {
                 $language = str_replace('_', '-', strtolower($locale));
             } else {
                 $language = $locale;
             }
         } else {
             $language = i18n::get_lang_from_locale($locale);
         }
         Cookie::set('language', $language);
         $this->redirect(Controller::join_links(Director::baseURL(), $language) . '/', 301);
         $this->popCurrent();
         return $this->response;
     }
     if (Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL')) {
         if (Config::inst()->get('MultilingualRootURLController', 'UseDashLocale')) {
             $language = str_replace('_', '-', strtolower(Translatable::default_locale()));
         } else {
             $language = Translatable::default_locale();
         }
     } else {
         $language = Translatable::default_lang();
     }
     $this->redirect(Controller::join_links(Director::baseURL(), $language . '/'), 301);
     $this->popCurrent();
     return $this->response;
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-translatablerouting,代码行数:99,代码来源:MultilingualRootURLController.php

示例15: testGeneratedFile

 /**
  * Test fallback to file generation API with enable_static_file disabled
  */
 public function testGeneratedFile()
 {
     Config::inst()->update('ErrorPage', 'enable_static_file', false);
     $this->logInWithPermission('ADMIN');
     $page = new ErrorPage();
     $page->ErrorCode = 405;
     $page->Title = 'Method Not Allowed';
     $page->write();
     $page->doPublish();
     // Dynamic content is available
     $response = ErrorPage::response_for('405');
     $this->assertNotEmpty($response);
     $this->assertNotEmpty($response->getBody());
     $this->assertEquals(405, (int) $response->getStatusCode());
     // Static content is not available
     $this->assertEmpty(ErrorPage::get_content_for_errorcode('405'));
     $expectedErrorPagePath = AssetStoreTest_SpyStore::base_path() . '/error-405.html';
     $this->assertFileNotExists($expectedErrorPagePath, 'Error page is not cached in static location');
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:22,代码来源:ErrorPageTest.php


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