Returns localization properties, inner html and placeholder contents.

@return SupraJsonResponse
543373
public function getAction()
	{
		$localization = $this->getPageLocalization();

		$pageRequest = $this->createPageRequest();

		$pageController = $this->getPageController();

		$templateException = $response
				= $internalHtml
				= null;

		try {
			$response = $pageController->execute($pageRequest);
		} catch (\Twig_Error_Loader $e) {
			$templateException = $e;
		} catch (LayoutNotFound $e) {
			$templateException = $e;
		} catch (\Exception $e) {
			throw $e;
		}

		$localizationData = $this->getLocalizationData($localization);

		if ($templateException) {
			$internalHtml = '<h1>Page template or layout not found.</h1>
				<p>Please make sure the template is assigned and the template is published in this locale and it has layout assigned.</p>';
		} elseif ($response instanceof Response) {
			$internalHtml = $response->getContent();
		}

		$localizationData['internal_html'] = $internalHtml;

		$placeHolders = $pageRequest->getPlaceHolderSet()
				->getFinalPlaceHolders();

		$blocks = $pageRequest->getBlockSet();

		$placeHoldersData = &$localizationData['contents'];

		foreach ($placeHolders as $placeHolder) {

			$blocksData = array();

			foreach ($blocks->getPlaceHolderBlockSet($placeHolder) as $block) {
				/* @var $block Block */
				$blocksData[] = $this->getBlockData($block);
			}

			$placeHolderData = array(
				'id'		=> $placeHolder->getName(),
				'title'		=> $placeHolder->getTitle(),
				'locked'	=> $placeHolder->isLocked(),
				'closed'	=> ! $localization->isPlaceHolderEditable($placeHolder),
				'contents'	=> $blocksData,
				// @TODO: if this one is hardcoded, why not to hardcode in UI?
				'type'		=> 'list',
				// @TODO: list of blocks that are allowed to be insterted
//				'allow' => array(
//						0 => 'Project_Text_TextController',
//				),
			);

			$placeHoldersData[] = $placeHolderData;
		}

		$jsonResponse = new SupraJsonResponse($localizationData);

		// @FIXME: dummy. when needed, move to prefilter.
		$jsonResponse->setPermissions(array(array(
			'edit_page' => true,
			'supervise_page' => true
		)));

		return $jsonResponse;
	}
1035065
protected function lockPage()
	{
		$this->isPostRequest();

		$currentUser = $this->getCurrentUser();

		if (! $currentUser) {
			return null;
		}

		$localization = $this->getPageLocalization();

		$force = $this->getRequestInput()
				->filter('force', false, false, FILTER_VALIDATE_BOOLEAN);

		try {
			if ($this->checkLock(false) === null) {
				$this->createLock();
			}
		} catch (ObjectLockedException $e) {
			if (! $force) {
				return new SupraJsonResponse($this->getLocalizationEditLockData($localization));
			}
		}

		return new SupraJsonResponse();
	}
1077042
public function getAcceptedEncodings()
    {
        if (null === $this->encodings) {
            if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
                $this->encodings = strtolower(trim($_SERVER['HTTP_ACCEPT_ENCODING']));
            } else {
                $this->encodings = '';
            }
        }

        return $this->encodings;
    }
1364990
protected function getInlineJavaScriptTranslations()
    {
        $close_text =
            $this->close_text === null ? Swat::_('Close') : $this->close_text;

        return sprintf(
            "SwatImagePreviewDisplay.close_text = '%s';\n",
            $close_text
        );
    }
538121
protected function getLocales()
    {
        return \localizer\locales()->reduce(function ($ids, $locale) {
            $ids[] = $locale->id();

            return $ids;
        }, []);
    }
1254332
public function getLocalesExtraData()
    {
        $host = $this->getHost();

        if (!isset($this->hosts[$host]['locales_extra'])) {
            return parent::getLocalesExtraData();
        }

        return $this->hosts[$host]['locales_extra'];
    }
427712
public function placeholder()
    {
        if ($this->placeholder === null) {
            $metadata = $this->metadata();

            if (isset($metadata['data']['placeholder'])) {
                $this->setPlaceholder($metadata['data']['placeholder']);
            } else {
                $this->placeholder = '';
            }
        }

        if ($this->placeholder instanceof Translation) {
            if (isset($this->placeholder->isRendered) && $this->placeholder->isRendered === false) {
                $this->placeholder = $this->renderTranslatableTemplate($this->placeholder);
            }

            if ($this->lang()) {
                return $this->placeholder[$this->lang()];
            }
        }

        return $this->placeholder;
    }
141105
private function retrieve_translation_details() {
		$api_url = $this->get_api_url();

		$resp = wp_remote_get( $api_url );
		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) !== 200 ) {
			return null;
		}
		$body = wp_remote_retrieve_body( $resp );
		unset( $resp );

		if ( $body ) {
			$body = json_decode( $body );
			if ( empty( $body->translation_sets ) ) {
				return null;
			}
			foreach ( $body->translation_sets as $set ) {
				if ( ! property_exists( $set, 'wp_locale' ) ) {
					continue;
				}

				// For informal and formal locales, we have to complete the locale code by concatenating the slug ('formal' or 'informal') to the xx_XX part.
				if ( $set->slug !== 'default' && strtolower( $this->locale ) === strtolower( $set->wp_locale . '_' . $set->slug ) ) {
					return $set;
				}

				if ( $this->locale === $set->wp_locale ) {
					return $set;
				}
			}
		}

		return null;
	}
855623
public function localesNavbar()
    {
        /** @var  \Illuminate\Contracts\View\Factory  $view */
        $view = $this->app[ViewFactoryContract::class];

        return $view->make('localization::navbar', ['supportedLocales' => $this->getSupportedLocales()])
                    ->render();
    }
214524
public function getTranslationsAttribute()
    {
        if (!settings('is_multilanguage') || !ContentType::find($this->type_id)->translatable)
            return null;

        $parent = $this->translation_id !== null ? Content::where('id', $this->translation_id)->first() : Content::where('id', $this->id)->first();
        $translations = Content::where('translation_id', $parent->id)->get();

        return $translations->merge([$parent]);
    }
91610
public function getRespondentLanguage()
    {
        if (! isset($this->_respTrackData['grs_iso_lang'])) {
            $this->_ensureRespondentData();

            if (! isset($this->_respTrackData['grs_iso_lang'])) {
                // Still not set in a project? The it is single language
                $this->_respTrackData['grs_iso_lang'] = $this->locale->getLanguage();
            }
        }

        return $this->_respTrackData['grs_iso_lang'];
    }
273188
protected function getInitialPageLocalization()
	{
		$localization = null;

		$cookieBag = $this->container->getRequest()->cookies;

		if ($cookieBag->has(self::INITIAL_PAGE_ID_COOKIE)) {
			$localization = $this->getEntityManager()->find(
					Localization::CN(),
					$cookieBag->get(self::INITIAL_PAGE_ID_COOKIE)
			);
		}

		// Root page otherwise
		if ($localization === null) {
			$pageRepository = $this->getEntityManager()
				->getRepository(Page::CN());
			/* @var $pageRepository PageRepository */

			$pages = $pageRepository->getRootNodes();

			if (! empty($pages)) {
				/* @var $pages AbstractPage[] */
				return $pages[0]->getLocalization($this->getCurrentLocale()->getId());
			}
		}

		return null;
	}
1370984
public function getLocales()
    {
        $locales = $this->serviceManager->get('playgroundcore_locale_service')->getLocaleMapper()->findAll();
        $localesForm = array();
        foreach ($locales as $key => $locale) {
            $localesForm[$locale->getLocale()] = $locale->getName(). " (".$locale->getLocale().")";
        }
        return $localesForm;
    }
388192
public function getUrlRegex(): string
    {
        $aSupportedLocales = $this->getSupportedLocales();
        $aUrlLocales       = [];

        foreach ($aSupportedLocales as $oLocale) {
            $sVanity       = $this->getUrlSegment($oLocale);
            $aUrlLocales[] = $sVanity;
        }

        return '/^(' . implode('|', array_filter($aUrlLocales)) . ')?(\/)?(.*)$/';
    }
983976
public function getResults()
    {
        // Get request data from request handler
        $request = $this->getRequestHandler()->getRequest();

        // set language (if present)
        $locale = null;
        $origLocale = null;
        if (class_exists('Translatable')) {
            $locale = $request->requestVar('searchlocale');
            if (SiteTree::singleton()->hasExtension('Translatable') && $locale) {
                if ($locale === "ALL") {
                    Translatable::disable_locale_filter();
                } else {
                    $origLocale = Translatable::get_current_locale();

                    Translatable::set_current_locale($locale);
                }
            }
        }

        $keywords = $request->requestVar('Search');

        $andProcessor = function ($matches) {
            return ' +' . $matches[2] . ' +' . $matches[4] . ' ';
        };
        $notProcessor = 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);

        $pageLength = $this->getPageLength();
        $start = $request->requestVar('start') ?: 0;

        $booleanSearch =
            strpos($keywords, '"') !== false ||
            strpos($keywords, '+') !== false ||
            strpos($keywords, '-') !== false ||
            strpos($keywords, '*') !== false;
        $results = DB::get_conn()->searchEngine($this->classesToSearch, $keywords, $start, $pageLength, "\"Relevance\" DESC", "", $booleanSearch);

        // filter by permission
        if ($results) {
            foreach ($results as $result) {
                if (!$result->canView()) {
                    $results->remove($result);
                }
            }
        }

        // reset locale
        if (class_exists('Translatable')) {
            if (SiteTree::singleton()->hasExtension('Translatable') && $locale) {
                if ($locale == "ALL") {
                    Translatable::enable_locale_filter();
                } else {
                    Translatable::set_current_locale($origLocale);
                }
            }
        }

        return $results;
    }
567871
public function fetchHTTPPersistentVariables()
    {
        $translations = $this->allTranslations();

        $http = eZHTTPTool::instance();
        eZHTTPPersistence::fetch( 'ContentObjectState' , eZContentObjectState::definition(), $this, $http, false );
        eZHTTPPersistence::fetch( 'ContentObjectState' , eZContentObjectStateLanguage::definition(), $translations, $http, true );
    }
645798
protected function _getPossibleLocales() {
        $bootstrap = $this->getBootstrap();
        $bootstrap->bootstrap('FrontController');
        $frontController = $bootstrap->getContainer()->frontcontroller;
        $locales = $frontController->getParam('locales');
        return $locales;
    }