<commit_before><?php
namespace Concrete\Block\SwitchLanguage;

use Concrete\Core\Block\BlockController;
use Concrete\Core\Multilingual\Page\Section\Section;
use Concrete\Core\Routing\Redirect;
use Cookie;
use Session;

defined('C5_EXECUTE') or die("Access Denied.");

class Controller extends BlockController
{
    protected $btInterfaceWidth = 500;
    protected $btInterfaceHeight = 150;
    protected $btTable = 'btSwitchLanguage';

    public $helpers = ['form'];

    public function getBlockTypeDescription()
    {
        return t("Adds a front-end language switcher to your website.");
    }

    public function getBlockTypeName()
    {
        return t("Switch Language");
    }

    public function action_switch_language($currentPageID, $sectionID, $bID = false)
    {
        $lang = Section::getByID(intval($sectionID));
        if (is_object($lang)) {
            $page = \Page::getByID(intval($currentPageID));
            if (!$page->isError()) {
                $relatedID = $lang->getTranslatedPageID($page);
                if ($relatedID) {
                    $pc = \Page::getByID($relatedID);
                    Redirect::page($pc)->send();
                    exit;
                }
            }
            Redirect::page($lang)->send();
            exit;
        }

        Redirect::to('/');
        exit;
    }

    public function action_set_current_language()
    {<commit_msg>Return the redirect responses from the block action<commit_after><?php
namespace Concrete\Block\SwitchLanguage;

use Concrete\Core\Block\BlockController;
use Concrete\Core\Multilingual\Page\Section\Section;
use Concrete\Core\Routing\Redirect;
use Cookie;
use Session;

defined('C5_EXECUTE') or die("Access Denied.");

class Controller extends BlockController
{
    protected $btInterfaceWidth = 500;
    protected $btInterfaceHeight = 150;
    protected $btTable = 'btSwitchLanguage';

    public $helpers = ['form'];

    public function getBlockTypeDescription()
    {
        return t("Adds a front-end language switcher to your website.");
    }

    public function getBlockTypeName()
    {
        return t("Switch Language");
    }

    public function action_switch_language($currentPageID, $sectionID, $bID = false)
    {
        $lang = Section::getByID(intval($sectionID));
        if (is_object($lang)) {
            $page = \Page::getByID(intval($currentPageID));
            if (!$page->isError()) {
                $relatedID = $lang->getTranslatedPageID($page);
                if ($relatedID) {
                    $pc = \Page::getByID($relatedID);
                    return Redirect::page($pc);
                }
            }
            return Redirect::page($lang);
        }

        return Redirect::to('/');
    }

    public function action_set_current_language()
    {
{'fraction_non_alphanumeric': 0.12299465240641712, 'fraction_numerical': 0.004991087344028521, 'mean_word_length': 2.4987531172069826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6532134', 'n_tokens_mistral': 802, 'n_tokens_neox': 765, 'n_words': 167}