當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Translatable::disable_locale_filter方法代碼示例

本文整理匯總了PHP中Translatable::disable_locale_filter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translatable::disable_locale_filter方法的具體用法?PHP Translatable::disable_locale_filter怎麽用?PHP Translatable::disable_locale_filter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Translatable的用法示例。


在下文中一共展示了Translatable::disable_locale_filter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     Translatable::disable_locale_filter();
     //Publish all english pages
     $pages = Page::get()->filter('Locale', 'en_US');
     foreach ($pages as $page) {
         $page->publish('Stage', 'Live');
     }
     //Rewrite the french translation groups and publish french pages
     $pagesFR = Page::get()->filter('Locale', 'fr_FR');
     foreach ($pagesFR as $index => $page) {
         $page->addTranslationGroup($pages->offsetGet($index)->ID, true);
         $page->publish('Stage', 'Live');
     }
     Translatable::enable_locale_filter();
     $this->origLocaleRoutingEnabled = Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL');
     Config::inst()->update('MultilingualRootURLController', 'UseLocaleURL', false);
     $this->origDashLocaleEnabled = Config::inst()->get('MultilingualRootURLController', 'UseDashLocale');
     Config::inst()->update('MultilingualRootURLController', 'UseDashLocale', false);
     $this->origAcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.5';
     $this->origCookieLocale = Cookie::get('language');
     Cookie::force_expiry('language');
     Cookie::set('language', 'en');
     $this->origCurrentLocale = Translatable::get_current_locale();
     Translatable::set_current_locale('en_US');
     $this->origLocale = Translatable::default_locale();
     Translatable::set_default_locale('en_US');
     $this->origi18nLocale = i18n::get_locale();
     i18n::set_locale('en_US');
     $this->origAllowedLocales = Translatable::get_allowed_locales();
     Translatable::set_allowed_locales(array('en_US', 'fr_FR'));
     MultilingualRootURLController::reset();
 }
開發者ID:helpfulrobot,項目名稱:webbuilders-group-silverstripe-translatablerouting,代碼行數:35,代碼來源:MultilingualModelAsControllerTest.php

示例2: handleBatchAction

 public function handleBatchAction($request)
 {
     // This method can't be called without ajax.
     if (!$request->isAjax()) {
         $this->parentController->redirectBack();
         return;
     }
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     $actions = $this->batchActions();
     $actionClass = $actions[$request->param('BatchAction')]['class'];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $v) {
         if (!is_numeric($v)) {
             unset($ids[$k]);
         }
     }
     if ($ids) {
         if (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
             Translatable::disable_locale_filter();
         }
         $recordClass = $this->recordClass;
         $pages = DataObject::get($recordClass)->byIDs($ids);
         if (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
             Translatable::enable_locale_filter();
         }
         $record_class = $this->recordClass;
         if ($record_class::has_extension('Versioned')) {
             // If we didn't query all the pages, then find the rest on the live site
             if (!$pages || $pages->Count() < sizeof($ids)) {
                 $idsFromLive = array();
                 foreach ($ids as $id) {
                     $idsFromLive[$id] = true;
                 }
                 if ($pages) {
                     foreach ($pages as $page) {
                         unset($idsFromLive[$page->ID]);
                     }
                 }
                 $idsFromLive = array_keys($idsFromLive);
                 $livePages = Versioned::get_by_stage($this->recordClass, 'Live')->byIDs($idsFromLive);
                 if ($pages) {
                     // Can't merge into a DataList, need to condense into an actual list first
                     // (which will retrieve all records as objects, so its an expensive operation)
                     $pages = new ArrayList($pages->toArray());
                     $pages->merge($livePages);
                 } else {
                     $pages = $livePages;
                 }
             }
         }
     } else {
         $pages = new ArrayList();
     }
     return $actionHandler->run($pages);
 }
開發者ID:congaaids,項目名稱:silverstripe-framework,代碼行數:60,代碼來源:CMSBatchActionHandler.php

示例3: multipleNewsHolderPages

 /**
  * If there are multiple @link NewsHolderPage available, add the field for multiples.
  * This includes translation options
  */
 private function multipleNewsHolderPages()
 {
     $enabled = false;
     // If we have translations, disable translation filter to get all pages.
     if (class_exists('Translatable')) {
         $enabled = Translatable::disable_locale_filter();
     }
     $pages = Versioned::get_by_stage('NewsHolderPage', 'Live');
     // Only add the page-selection if there are multiple. Otherwise handled by onBeforeWrite();
     if ($pages->count() > 1) {
         $pagelist = array();
         if (class_exists('Translatable')) {
             foreach ($pages as $page) {
                 $pagelist['Root.Main'][$page->ID] = $page->Title . ' ' . $page->Locale;
             }
         } else {
             $pagelist = $pages->map('ID', 'Title')->toArray();
         }
         $this->field_list['Root.Main'][1] = ListboxField::create('NewsHolderPages', $this->owner->fieldLabel('NewsHolderPages'), $pagelist);
         $this->field_list['Root.Main'][1]->setMultiple(true);
     }
     if ($enabled) {
         Translatable::enable_locale_filter();
     }
 }
開發者ID:MilesSummers,項目名稱:silverstripe-newsmodule,代碼行數:29,代碼來源:NewsCMSExtension.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     //Remap translation group for home pages
     Translatable::disable_locale_filter();
     $default = $this->objFromFixture('Page', 'home');
     $defaultFR = $this->objFromFixture('Page', 'home_fr');
     $defaultFR->addTranslationGroup($default->ID, true);
     Translatable::enable_locale_filter();
     $this->origLocaleRoutingEnabled = Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL');
     Config::inst()->update('MultilingualRootURLController', 'UseLocaleURL', false);
     $this->origDashLocaleEnabled = Config::inst()->get('MultilingualRootURLController', 'UseDashLocale');
     Config::inst()->update('MultilingualRootURLController', 'UseDashLocale', false);
     $this->origAcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.5';
     $this->origCookieLocale = Cookie::get('language');
     Cookie::force_expiry('language');
     $this->origCurrentLocale = Translatable::get_current_locale();
     Translatable::set_current_locale('en_US');
     $this->origLocale = Translatable::default_locale();
     Translatable::set_default_locale('en_US');
     $this->origi18nLocale = i18n::get_locale();
     i18n::set_locale('en_US');
     $this->origAllowedLocales = Translatable::get_allowed_locales();
     Translatable::set_allowed_locales(array('en_US', 'fr_FR'));
     MultilingualRootURLController::reset();
 }
開發者ID:helpfulrobot,項目名稱:webbuilders-group-silverstripe-translatablerouting,代碼行數:27,代碼來源:MultilingualRootURLControllerTest.php

示例5: sitemap

 /**
  * We need to disable Translatable before retreiving the DataObjects or 
  * Pages for the sitemap, because otherwise only pages in the default 
  * language are found.
  * 
  * Next we need to add the alternatives for each Translatable Object 
  * included in the sitemap: basically these are the Translations plus 
  * the current object itself
  * 
  * @return Array
  */
 public function sitemap()
 {
     Translatable::disable_locale_filter();
     $sitemap = parent::sitemap();
     Translatable::enable_locale_filter();
     $updatedItems = new ArrayList();
     foreach ($sitemap as $items) {
         foreach ($items as $item) {
             if ($item->hasExtension('Translatable')) {
                 $translations = $item->getTranslations();
                 if ($translations) {
                     $alternatives = new ArrayList();
                     foreach ($translations as $translation) {
                         $translation->GoogleLocale = $this->getGoogleLocale($translation->Locale);
                         $alternatives->push($translation);
                     }
                     $item->GoogleLocale = $this->getGoogleLocale($item->Locale);
                     $alternatives->push($item);
                     $item->Alternatives = $alternatives;
                 }
                 $updatedItems->push($item);
             }
         }
     }
     if (!empty($updatedItems)) {
         return array('Items' => $updatedItems);
     } else {
         return $sitemap;
     }
 }
開發者ID:helpfulrobot,項目名稱:martimiz-silverstripe-translatablegooglesitemaps,代碼行數:41,代碼來源:TranslatableGoogleSitemapController.php

示例6: getExtendedResults

    public function getExtendedResults($pageLength = null, $sort = 'Relevance DESC', $filter = '', $data = null)
    {
        // legacy usage: $data was defaulting to $_REQUEST, parameter not passed in doc.silverstripe.org tutorials
        if (!isset($data) || !is_array($data)) {
            $data = $_REQUEST;
        }
        // set language (if present)
        if (class_exists('Translatable')) {
            if (singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
                if ($data['searchlocale'] == "ALL") {
                    Translatable::disable_locale_filter();
                } else {
                    $origLocale = Translatable::get_current_locale();
                    Translatable::set_current_locale($data['searchlocale']);
                }
            }
        }
        $keywords = $data['Search'];
        $andProcessor = create_function('$matches', '
	 		return " +" . $matches[2] . " +" . $matches[4] . " ";
	 	');
        $notProcessor = create_function('$matches', '
	 		return " -" . $matches[3];
	 	');
        $keywords = preg_replace_callback('/()("[^()"]+")( and )("[^"()]+")()/i', $andProcessor, $keywords);
        $keywords = preg_replace_callback('/(^| )([^() ]+)( and )([^ ()]+)( |$)/i', $andProcessor, $keywords);
        $keywords = preg_replace_callback('/(^| )(not )("[^"()]+")/i', $notProcessor, $keywords);
        $keywords = preg_replace_callback('/(^| )(not )([^() ]+)( |$)/i', $notProcessor, $keywords);
        $keywords = $this->addStarsToKeywords($keywords);
        if (!$pageLength) {
            $pageLength = $this->owner->pageLength;
        }
        $start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
        if (strpos($keywords, '"') !== false || strpos($keywords, '+') !== false || strpos($keywords, '-') !== false || strpos($keywords, '*') !== false) {
            $results = DB::getConn()->searchEngine($this->owner->classesToSearch, $keywords, $start, $pageLength, $sort, $filter, true);
        } else {
            $results = DB::getConn()->searchEngine($this->owner->classesToSearch, $keywords, $start, $pageLength);
        }
        // filter by permission
        if ($results) {
            foreach ($results as $result) {
                if (!$result->canView()) {
                    $results->remove($result);
                }
            }
        }
        // reset locale
        if (class_exists('Translatable')) {
            if (singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
                if ($data['searchlocale'] == "ALL") {
                    Translatable::enable_locale_filter();
                } else {
                    Translatable::set_current_locale($origLocale);
                }
            }
        }
        return $results;
    }
開發者ID:helpfulrobot,項目名稱:nglasl-silverstripe-extensible-search,代碼行數:58,代碼來源:SearchFormResultsExtension.php

示例7: handleAction

 function handleAction($request)
 {
     // This method can't be called without ajax.
     if (!$this->parentController->isAjax()) {
         $this->parentController->redirectBack();
         return;
     }
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     $actions = $this->batchActions();
     $actionClass = $actions[$request->param('BatchAction')]['class'];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = split(' *, *', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $v) {
         if (!is_numeric($v)) {
             unset($ids[$k]);
         }
     }
     if ($ids) {
         if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable')) {
             Translatable::disable_locale_filter();
         }
         $pages = DataObject::get($this->recordClass, sprintf('"%s"."ID" IN (%s)', ClassInfo::baseDataClass($this->recordClass), implode(", ", $ids)));
         if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable')) {
             Translatable::enable_locale_filter();
         }
         if (Object::has_extension($this->recordClass, 'Versioned')) {
             // If we didn't query all the pages, then find the rest on the live site
             if (!$pages || $pages->Count() < sizeof($ids)) {
                 foreach ($ids as $id) {
                     $idsFromLive[$id] = true;
                 }
                 if ($pages) {
                     foreach ($pages as $page) {
                         unset($idsFromLive[$page->ID]);
                     }
                 }
                 $idsFromLive = array_keys($idsFromLive);
                 $sql = sprintf('"%s"."ID" IN (%s)', $this->recordClass, implode(", ", $idsFromLive));
                 $livePages = Versioned::get_by_stage($this->recordClass, 'Live', $sql);
                 if ($pages) {
                     $pages->merge($livePages);
                 } else {
                     $pages = $livePages;
                 }
             }
         }
     } else {
         $pages = new ArrayList();
     }
     return $actionHandler->run($pages);
 }
開發者ID:rixrix,項目名稱:sapphire,代碼行數:55,代碼來源:CMSBatchActionHandler.php

示例8: sitemap

 /**
  * Specific controller action for displaying a particular list of links
  * for a class
  *
  * @return mixed
  */
 public function sitemap()
 {
     if ($this->request->param('ID') == 'SiteTree') {
         //Disable the locale filter
         Translatable::disable_locale_filter();
         $items = parent::sitemap();
         //Re-enable the locale filter
         Translatable::enable_locale_filter();
         return $items;
     } else {
         return parent::sitemap();
     }
 }
開發者ID:helpfulrobot,項目名稱:webbuilders-group-silverstripe-translatablerouting,代碼行數:19,代碼來源:MultilingualGoogleSitemap.php

示例9: start

 /**
  * Returns the state of other modules before compatibility mode is started.
  *
  * @return array
  */
 public static function start()
 {
     $compatibility = array(self::SUBSITES => null, self::TRANSLATABLE => null);
     if (ClassInfo::exists("Subsite")) {
         $compatibility[self::SUBSITES] = Subsite::$disable_subsite_filter;
         Subsite::disable_subsite_filter(true);
     }
     if (ClassInfo::exists("Translatable")) {
         $compatibility[self::TRANSLATABLE] = Translatable::locale_filter_enabled();
         Translatable::disable_locale_filter();
     }
     return $compatibility;
 }
開發者ID:GOVTNZ,項目名稱:silverstripe-contentreview,代碼行數:18,代碼來源:ContentReviewCompatability.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
     Translatable::disable_locale_filter();
     $sitetree = DataObject::get_one('SiteTree', sprintf('"URLSegment" = \'%s\' %s', Convert::raw2sql($URLSegment), SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null));
     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 = self::find_old_page($URLSegment)) {
             $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;
         }
         $ctrl = new Paste_Controller();
         $ctrl->request = $request;
         $paste = $ctrl->getCurrentPaste();
         if ($paste) {
             if (is_string($paste) || is_object($paste) && is_a($paste, 'SS_HTTPResponse')) {
                 return $paste;
             }
             $ctrl->init($paste);
             $response = $ctrl->handleRequest($request);
             return $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 ($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:jemmy655,項目名稱:Deployable-PHP-Codepad,代碼行數:52,代碼來源:ModelAsController.php

示例11: handleRequest

 /**
  * Check catalogue URL's before we get to the CMS (if it exists)
  * 
  * @param SS_HTTPRequest $request
  * @param DataModel|null $model
  * @return SS_HTTPResponse
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->request = $request;
     $this->setDataModel($model);
     $catalogue_enabled = Catalogue::config()->enable_frontend;
     $this->pushCurrent();
     // Create a response just in case init() decides to redirect
     $this->response = new SS_HTTPResponse();
     $this->init();
     // If we had a redirection or something, halt processing.
     if ($this->response->isFinished()) {
         $this->popCurrent();
         return $this->response;
     }
     // If DB is not present, build
     if (!DB::isActive() || !ClassInfo::hasTable('CatalogueProduct') || !ClassInfo::hasTable('CatalogueCategory')) {
         return $this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
     }
     $urlsegment = $request->param('URLSegment');
     $this->extend('onBeforeInit');
     $this->init();
     $this->extend('onAfterInit');
     // Find link, regardless of current locale settings
     if (class_exists('Translatable')) {
         Translatable::disable_locale_filter();
     }
     $filter = array('URLSegment' => $urlsegment, 'Disabled' => 0);
     if ($catalogue_enabled && ($object = CatalogueProduct::get()->filter($filter)->first())) {
         $controller = $this->controller_for($object);
     } elseif ($catalogue_enabled && ($object = CatalogueCategory::get()->filter($filter)->first())) {
         $controller = $this->controller_for($object);
     } elseif (class_exists('ModelAsController')) {
         // If CMS installed
         $controller = ModelAsController::create();
     } else {
         $controller = Controller::create();
     }
     if (class_exists('Translatable')) {
         Translatable::enable_locale_filter();
     }
     $result = $controller->handleRequest($request, $model);
     $this->popCurrent();
     return $result;
 }
開發者ID:i-lateral,項目名稱:silverstripe-catalogue,代碼行數:51,代碼來源:CatalogueURLController.php

示例12: Fetch

 public static function Fetch($echo = false)
 {
     $since_id = (int) SocialMediaSettings::getValue('TwitterIndex');
     if ($since_id == 0) {
         $since_id = 1;
     }
     //Twitter gives an error message if since_id is zero. This happens when tweets are fetched the first time.
     $tweets = self::Connection()->get('statuses/user_timeline', array('since_id' => $since_id, 'count' => 200, 'include_rts' => true, 'exclude_replies' => true, 'screen_name' => self::config()->username));
     if (self::Error()) {
         user_error("Twitter error: " . self::ErrorMessage($tweets));
         return false;
     }
     $updates = array();
     $max_id = (int) SocialMediaSettings::getValue('TwitterIndex');
     $skipped = 0;
     $translatable_locale_filter = Translatable::disable_locale_filter();
     //ID filtering does not work well if locale filtering is on.
     foreach ($tweets as $tweet) {
         if (!DataObject::get('BlogPost')->filter('TwitterID', $tweet->id)->exists()) {
             //Do not supply the tweet if a DataObject with the same Twitter ID already exists.
             //However, $max_id can still be updated with the already existing ID number. This will
             //Ensure we do not have to loop over this tweet again.
             $updates[] = self::tweet_to_array($tweet);
         } else {
             $skipped++;
         }
         $max_id = max($max_id, (int) $tweet->id);
     }
     Translatable::enable_locale_filter($translatable_locale_filter);
     if ($echo and $skipped > 0) {
         echo "Twitter: Skipped {$skipped} existing records. This is normal if its only a few records occasionally, but if it happens every time and the number is constant or raises, then the Twitter's 'since_id' parameter is not working correctly. If the count reaches 200, it might be that you won't get any new records at all, because Twitter's maximum count for returned records per query is 200 at the moment when writing this (January 2016). Also constant skipping might affect performance.<br />";
     }
     if ($echo) {
         echo "Twitter: since_id was {$since_id} and is now {$max_id}.<br />";
     }
     SocialMediaSettings::setValue('TwitterIndex', $max_id);
     //Keep track of where we left, so we don't get the same tweets next time.
     return $updates;
 }
開發者ID:Taitava,項目名稱:silverstripe-socialmedia,代碼行數:39,代碼來源:SocialMediaTwitter.php

示例13: get_items

 /**
  * Constructs the list of data to include in the rendered feed. Links
  * can include pages from the website, dataobjects (such as forum posts)
  * as well as custom registered paths.
  *
  * @param string
  * @param int
  *
  * @return ArrayList
  */
 public static function get_items()
 {
     $output = new ArrayList();
     $search_filter = Config::inst()->get('GoogleShoppingFeed', 'use_show_in_search');
     $disabled_filter = Config::inst()->get('GoogleShoppingFeed', 'use_disabled');
     $filter = array();
     // todo migrate to extension hook or DI point for other modules to
     // modify state filters
     if (class_exists('Translatable')) {
         Translatable::disable_locale_filter();
     }
     foreach (self::$dataobjects as $class) {
         if ($class == "SiteTree") {
             $search_filter = $search_filter ? "\"ShowInSearch\" = 1" : "";
             $instances = Versioned::get_by_stage('SiteTree', 'Live', $search_filter);
         } elseif ($class == "Product") {
             $instances = $class::get();
             if ($disabled_filter) {
                 $instances->filter("Disabled", 0);
             }
         } else {
             $instances = new DataList($class);
         }
         if ($instances) {
             foreach ($instances as $obj) {
                 if ($obj->canIncludeInGoogleShoppingFeed()) {
                     $output->push($obj);
                 }
             }
         }
     }
     return $output;
 }
開發者ID:spekulatius,項目名稱:silverstripe-googleshoppingfeed,代碼行數:43,代碼來源:GoogleShoppingFeed.php

示例14: getNestedController

 /**
  * Overrides ModelAsController->getNestedController to find the nested controller
  * on a per-site basis
  **/
 public function getNestedController()
 {
     $request = $this->request;
     $segment = $request->param('URLSegment');
     $site = Multisites::inst()->getCurrentSiteId();
     if (!$site) {
         return $this->httpError(404);
     }
     if (class_exists('Translatable')) {
         Translatable::disable_locale_filter();
     }
     $page = SiteTree::get()->filter(array('ParentID' => $site, 'URLSegment' => rawurlencode($segment)));
     $page = $page->first();
     if (class_exists('Translatable')) {
         Translatable::enable_locale_filter();
     }
     if (!$page) {
         // Check to see if linkmapping module is installed and if so, if there a map for this request.
         if (class_exists('LinkMapping')) {
             if ($request->requestVars()) {
                 $queryString = '?';
                 foreach ($request->requestVars() as $key => $value) {
                     if ($key != 'url') {
                         $queryString .= $key . '=' . $value . '&';
                     }
                 }
                 $queryString = rtrim($queryString, '&');
             }
             $link = $queryString != '?' ? $request->getURL() . $queryString : $request->getURL();
             $link = trim(Director::makeRelative($link));
             $map = LinkMapping::get()->filter('MappedLink', $link)->first();
             if ($map) {
                 $this->response = new SS_HTTPResponse();
                 $this->response->redirect($map->getLink(), 301);
                 return $this->response;
             }
         }
         // use OldPageRedirector if it exists, to find old page
         if (class_exists('OldPageRedirector')) {
             if ($redirect = OldPageRedirector::find_old_page(array($segment), Multisites::inst()->getCurrentSite())) {
                 $redirect = SiteTree::get_by_link($redirect);
             }
         } else {
             $redirect = self::find_old_page($segment, $site);
         }
         if ($redirect) {
             $getVars = $request->getVars();
             //remove the url var as it confuses the routing
             unset($getVars['url']);
             $url = Controller::join_links($redirect->Link(Controller::join_links($request->param('Action'), $request->param('ID'), $request->param('OtherID'))));
             if (!empty($getVars)) {
                 $url .= '?' . http_build_query($getVars);
             }
             $this->response->redirect($url, 301);
             return $this->response;
         }
         return $this->httpError(404);
     }
     if (class_exists('Translatable') && $page->Locale) {
         Translatable::set_current_locale($page->Locale);
     }
     return self::controller_for($page, $request->param('Action'));
 }
開發者ID:helpfulrobot,項目名稱:sheadawson-silverstripe-multisites,代碼行數:67,代碼來源:MultisitesFrontController.php

示例15: getLocaleForObject

 /**
  * Get the locale for an object that has the Translatable extension.
  * 
  * @return locale
  */
 public function getLocaleForObject()
 {
     $id = (int) $this->getRequest()->requestVar('id');
     $class = Convert::raw2sql($this->getRequest()->requestVar('class'));
     $locale = Translatable::get_current_locale();
     if ($id && $class && class_exists($class) && $class::has_extension('Translatable')) {
         // temporarily disable locale filter so that we won't filter out the object
         Translatable::disable_locale_filter();
         $object = DataObject::get_by_id($class, $id);
         Translatable::enable_locale_filter();
         if ($object) {
             $locale = $object->Locale;
         }
     }
     return $locale;
 }
開發者ID:camfindlay,項目名稱:silverstripe-translatable,代碼行數:21,代碼來源:LanguageDropdownField.php


注:本文中的Translatable::disable_locale_filter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。