redirect() public static method

Redirect to another page
public static redirect ( string $strLocation, integer $intStatus = 303 )
$strLocation string The target URL
$intStatus integer The HTTP status code (defaults to 303)
コード例 #1
0
ファイル: RegistrationExport.php プロジェクト: Jobu/core
 public function export(\Contao\DC_Table $dc)
 {
     $database = \Contao\Database::getInstance();
     $stage_id = $database->query("SELECT s.id FROM tl_beachcup_stage AS s WHERE s.start_date >= UNIX_TIMESTAMP() ORDER BY s.start_date ASC LIMIT 1")->fetchAssoc()["id"];
     $data = $database->query("select tl_beachcup_registration.id as ANMELDUNG_ID, tl_beachcup_tournament.name_de AS TURNIER, DATE_FORMAT(from_unixtime(tl_beachcup_registration.tstamp), '%d.%m.%Y') as DATUM_ANMELDUNG,\n                                    p1.surname as NACHNAME_1, p1.name as VORNAME_1, p1.tax_number as STEUER_NR_1, DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL p1.birth_date SECOND), '%d.%m.%Y') as GEB_DATUM_1, p1.birth_place as GEB_ORT_1, p1.gender as GESCHLECHT_1, p1.address as ADRESSE_1, p1.zip_code as PLZ_1, p1.city as ORT_1, p1.country as LAND_1, p1.email as EMAIL_1, p1.phone_number as TEL_1, p1.shirt_size as SHIRT_1, p1.has_shirt as SHIRT_ERHALTEN_1, p1.is_fipav as FIPAV_1, p1level.description_de as SPIELER_LEVEL_1, p1.has_medical_certificate as AERZTL_ZEUGNIS_1, p1.is_confirmed as EIGENERKLAERUNG_1,\n                                    p2.surname as NACHNAME_2, p2.name as VORNAME_2, p2.tax_number as STEUER_NR_2, DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL p2.birth_date SECOND), '%d.%m.%Y') as GEB_DATUM_2, p2.birth_place as GEB_ORT_2, p2.gender as GESCHLECHT_2, p2.address as ADRESSE_2, p2.zip_code as PLZ_2, p2.city as ORT_2, p2.country as LAND_2, p2.email as EMAIL_2, p2.phone_number as TEL_2, p2.shirt_size as SHIRT_2, p2.has_shirt as SHIRT_ERHALTEN_2, p2.is_fipav as FIPAV_2, p2level.description_de as SPIELER_LEVEL_2, p2.has_medical_certificate as AERZTL_ZEUGNIS_2, p2.is_confirmed as EIGENERKLAERUNG_2,\n                                    tl_beachcup_registration_state.code as STATUS_ANMELDUNG\n                                    from tl_beachcup_registration\n                                    join tl_beachcup_team on tl_beachcup_team.id = tl_beachcup_registration.team_id\n                                    join tl_beachcup_player p1 on p1.id =  tl_beachcup_team.player_1\n                                    join tl_beachcup_player_level p1level on p1level.id = p1.player_level\n                                    join tl_beachcup_player p2 on p2.id =  tl_beachcup_team.player_2\n                                    join tl_beachcup_player_level p2level on p2level.id = p2.player_level\n                                    join tl_beachcup_tournament on tl_beachcup_tournament.id = tl_beachcup_registration.tournament_id\n                                    join tl_beachcup_registration_state on tl_beachcup_registration_state.id = tl_beachcup_registration.state_id\n                                    join tl_beachcup_stage on tl_beachcup_stage.id = tl_beachcup_tournament.stage_id\n                                    where tl_beachcup_stage.id = {$stage_id} and tl_beachcup_registration_state.code != 'REJECTED'\n                                    order by tl_beachcup_tournament.date, tl_beachcup_tournament.name_de, tl_beachcup_registration.tstamp;")->fetchAllAssoc();
     if (count($data) > 0) {
         $headers = array();
         foreach ($data[0] as $key => $value) {
             $headers[] = $key;
         }
         $file = fopen("php://memory", "w");
         fputcsv($file, $headers, ";");
         foreach ($data as $record) {
             fputcsv($file, $record, ";");
         }
         fseek($file, 0);
         header('Content-Encoding: iso-8859-1');
         header('Content-Type: application/csv; charset=iso-8859-1');
         header('Content-Disposition: attachement; filename="Anmeldungen.csv";');
         echo "";
         fpassthru($file);
         exit;
     }
     \Contao\Controller::redirect('contao/main.php?do=registration');
 }
コード例 #2
0
 /**
  * @inheritdoc
  *
  * @throws \InvalidArgumentException
  */
 protected function doSwitchView($id)
 {
     list($table, $id) = explode('.', $id);
     $url = Url::removeQueryString(['switchLanguage']);
     switch ($table) {
         case 'tl_article':
             $url = Url::addQueryString('id=' . $id, $url);
             break;
         case 'tl_page':
             Session::getInstance()->set('tl_page_node', (int) $id);
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Table "%s" is not supported', $table));
     }
     Controller::redirect($url);
 }
コード例 #3
0
 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     $GLOBALS['TL_CSS'][] = 'system/modules/vimeo_api/assets/backend.min.css';
     $elementsData = $this->getContentElements();
     $template = new BackendTemplate('be_vimeo_rebuilder');
     $template->action = ampersand(Environment::get('request'));
     $template->isActive = $this->isActive();
     $template->elementsCount = count($elementsData);
     $template->canRun = true;
     // Add the stats data
     if (($stats = static::generateStats()) !== null) {
         foreach ($stats as $k => $v) {
             $template->{$k} = $v;
         }
     }
     // Generate the elements
     if ($this->isActive()) {
         // Redirect to the maintenance module if the rebuilder cannot be run
         if (!$template->canRun) {
             Controller::redirect('contao/main.php?do=maintenance');
         }
         $elements = [];
         foreach ($elementsData as $data) {
             switch ($data['ptable']) {
                 case 'tl_article':
                     $source = $GLOBALS['TL_LANG']['tl_maintenance']['vimeo.tableSourceRef']['article'];
                     $path = [$data['_page'], $data['_article']];
                     break;
                 case 'tl_news':
                     $source = $GLOBALS['TL_LANG']['tl_maintenance']['vimeo.tableSourceRef']['news'];
                     $path = [$data['_archive'], $data['_news']];
                     break;
                 case 'tl_calendar_events':
                     $source = $GLOBALS['TL_LANG']['tl_maintenance']['vimeo.tableSourceRef']['event'];
                     $path = [$data['_calendar'], $data['_event']];
                     break;
                 default:
                     $source = '';
                     $path = [];
             }
             $elements[] = ['type' => $data['type'], 'ref' => $data['type'] === 'vimeo_album' ? $data['vimeo_albumId'] : $data['vimeo_videoId'], 'id' => $data['id'], 'source' => $source, 'path' => $path];
         }
         $template->elements = $elements;
         $template->ajaxAction = $this->ajaxAction;
     }
     return $template->parse();
 }
コード例 #4
0
 /**
  * Initialize the tests handler
  *
  * @param DataContainer|null $dc
  */
 public function initialize(DataContainer $dc = null)
 {
     if ($dc === null) {
         return;
     }
     $this->table = $this->getTableName();
     $this->dc = $dc;
     // Enable or disable the analyzer
     if (isset($_GET[self::$serpParamName])) {
         Input::get(self::$serpParamName) ? static::enable() : static::disable();
         Controller::redirect(str_replace(['&' . self::$serpParamName . '=' . Input::get(self::$serpParamName), '&' . self::$serpTemporaryParamName . '=' . Input::get(self::$serpTemporaryParamName)], '', Environment::get('request')));
     }
     $this->addGlobalOperations();
     if ($this->isEnabled()) {
         $this->initializeEnabled();
     }
 }
コード例 #5
0
ファイル: BackendUser.php プロジェクト: Mozan/core-bundle
 /**
  * Generate the navigation menu and return it as array
  *
  * @param boolean $blnShowAll
  *
  * @return array
  */
 public function navigation($blnShowAll = false)
 {
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     $arrModules = array();
     $session = $objSessionBag->all();
     // Toggle nodes
     if (\Input::get('mtg')) {
         $session['backend_modules'][\Input::get('mtg')] = isset($session['backend_modules'][\Input::get('mtg')]) && $session['backend_modules'][\Input::get('mtg')] == 0 ? 1 : 0;
         $objSessionBag->replace($session);
         \Controller::redirect(preg_replace('/(&(amp;)?|\\?)mtg=[^& ]*/i', '', \Environment::get('request')));
     }
     foreach ($GLOBALS['BE_MOD'] as $strGroupName => $arrGroupModules) {
         if (!empty($arrGroupModules) && ($strGroupName == 'system' || $this->hasAccess(array_keys($arrGroupModules), 'modules'))) {
             $arrModules[$strGroupName]['icon'] = 'modMinus.gif';
             $arrModules[$strGroupName]['title'] = specialchars($GLOBALS['TL_LANG']['MSC']['collapseNode']);
             $arrModules[$strGroupName]['label'] = ($label = is_array($GLOBALS['TL_LANG']['MOD'][$strGroupName]) ? $GLOBALS['TL_LANG']['MOD'][$strGroupName][0] : $GLOBALS['TL_LANG']['MOD'][$strGroupName]) != false ? $label : $strGroupName;
             $arrModules[$strGroupName]['href'] = \Controller::addToUrl('mtg=' . $strGroupName);
             // Do not show the modules if the group is closed
             if (!$blnShowAll && isset($session['backend_modules'][$strGroupName]) && $session['backend_modules'][$strGroupName] < 1) {
                 $arrModules[$strGroupName]['modules'] = false;
                 $arrModules[$strGroupName]['icon'] = 'modPlus.gif';
                 $arrModules[$strGroupName]['title'] = specialchars($GLOBALS['TL_LANG']['MSC']['expandNode']);
             } else {
                 foreach ($arrGroupModules as $strModuleName => $arrModuleConfig) {
                     // Check access
                     if ($strModuleName == 'undo' || $this->hasAccess($strModuleName, 'modules')) {
                         $arrModules[$strGroupName]['modules'][$strModuleName] = $arrModuleConfig;
                         $arrModules[$strGroupName]['modules'][$strModuleName]['title'] = specialchars($GLOBALS['TL_LANG']['MOD'][$strModuleName][1]);
                         $arrModules[$strGroupName]['modules'][$strModuleName]['label'] = ($label = is_array($GLOBALS['TL_LANG']['MOD'][$strModuleName]) ? $GLOBALS['TL_LANG']['MOD'][$strModuleName][0] : $GLOBALS['TL_LANG']['MOD'][$strModuleName]) != false ? $label : $strModuleName;
                         $arrModules[$strGroupName]['modules'][$strModuleName]['icon'] = !empty($arrModuleConfig['icon']) ? sprintf(' style="background-image:url(\'%s%s\')"', TL_ASSETS_URL, $arrModuleConfig['icon']) : '';
                         $arrModules[$strGroupName]['modules'][$strModuleName]['class'] = 'navigation ' . $strModuleName;
                         $arrModules[$strGroupName]['modules'][$strModuleName]['href'] = TL_SCRIPT . '?do=' . $strModuleName . '&amp;ref=' . TL_REFERER_ID;
                         // Mark the active module and its group
                         if (\Input::get('do') == $strModuleName) {
                             $arrModules[$strGroupName]['class'] = ' trail';
                             $arrModules[$strGroupName]['modules'][$strModuleName]['class'] .= ' active';
                         }
                     }
                 }
             }
         }
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getUserNavigation']) && is_array($GLOBALS['TL_HOOKS']['getUserNavigation'])) {
         foreach ($GLOBALS['TL_HOOKS']['getUserNavigation'] as $callback) {
             $this->import($callback[0]);
             $arrModules = $this->{$callback[0]}->{$callback[1]}($arrModules, $blnShowAll);
         }
     }
     return $arrModules;
 }
コード例 #6
0
ファイル: Backend.php プロジェクト: contao/core-bundle
    /**
     * Add a breadcrumb menu to the file tree
     *
     * @param string $strKey
     *
     * @throws AccessDeniedException
     * @throws \RuntimeException
     */
    public static function addFilesBreadcrumb($strKey = 'tl_files_node')
    {
        /** @var AttributeBagInterface $objSession */
        $objSession = \System::getContainer()->get('session')->getBag('contao_backend');
        // Set a new node
        if (isset($_GET['fn'])) {
            // Check the path (thanks to Arnaud Buchoux)
            if (\Validator::isInsecurePath(\Input::get('fn', true))) {
                throw new \RuntimeException('Insecure path ' . \Input::get('fn', true));
            }
            $objSession->set($strKey, \Input::get('fn', true));
            \Controller::redirect(preg_replace('/(&|\\?)fn=[^&]*/', '', \Environment::get('request')));
        }
        $strNode = $objSession->get($strKey);
        if ($strNode == '') {
            return;
        }
        // Check the path (thanks to Arnaud Buchoux)
        if (\Validator::isInsecurePath($strNode)) {
            throw new \RuntimeException('Insecure path ' . $strNode);
        }
        // Currently selected folder does not exist
        if (!is_dir(TL_ROOT . '/' . $strNode)) {
            $objSession->set($strKey, '');
            return;
        }
        $objUser = \BackendUser::getInstance();
        $strPath = \Config::get('uploadPath');
        $arrNodes = explode('/', preg_replace('/^' . preg_quote(\Config::get('uploadPath'), '/') . '\\//', '', $strNode));
        $arrLinks = array();
        // Add root link
        $arrLinks[] = \Image::getHtml('filemounts.svg') . ' <a href="' . \Backend::addToUrl('fn=') . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectAllNodes']) . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>';
        // Generate breadcrumb trail
        foreach ($arrNodes as $strFolder) {
            $strPath .= '/' . $strFolder;
            // Do not show pages which are not mounted
            if (!$objUser->hasAccess($strPath, 'filemounts')) {
                continue;
            }
            // No link for the active folder
            if ($strPath == $strNode) {
                $arrLinks[] = \Image::getHtml('folderC.svg') . ' ' . $strFolder;
            } else {
                $arrLinks[] = \Image::getHtml('folderC.svg') . ' <a href="' . \Backend::addToUrl('fn=' . $strPath) . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $strFolder . '</a>';
            }
        }
        // Check whether the node is mounted
        if (!$objUser->hasAccess($strNode, 'filemounts')) {
            $objSession->set($strKey, '');
            throw new AccessDeniedException('Folder ID "' . $strNode . '" is not mounted');
        }
        // Limit tree
        $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['root'] = array($strNode);
        // Insert breadcrumb menu
        $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['breadcrumb'] .= '

<ul id="tl_breadcrumb">
  <li>' . implode(' &gt; </li><li>', $arrLinks) . '</li>
</ul>';
    }
コード例 #7
0
 public function generateStandardGroup(ActionEvent $event)
 {
     $action = $event->getAction();
     $environment = $event->getEnvironment();
     $dataDefinition = $environment->getDataDefinition();
     if ($dataDefinition->getName() !== 'orm_avisota_salutation_group' || $action->getName() !== 'generate') {
         return;
     }
     global $AVISOTA_SALUTATION;
     $eventDispatcher = $environment->getEventDispatcher();
     $translator = $environment->getTranslator();
     $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('avisota_salutation'));
     $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('orm_avisota_salutation_group'));
     $predefinedSalutations = $AVISOTA_SALUTATION;
     $entityDataProvider = new EntityDataProvider();
     $entityDataProvider->setBaseConfig(array('source' => 'orm_avisota_salutation_group'));
     $entityManager = $entityDataProvider->getEntityManager();
     $entityAccessor = $entityDataProvider->getEntityAccessor();
     $salutationGroup = new \Avisota\Contao\Entity\SalutationGroup();
     $salutationGroup->setTitle('Default group generated at ' . date(Config::get('datimFormat')));
     $salutationGroup->setAlias(null);
     $sorting = 64;
     foreach ($predefinedSalutations as $index => $predefinedSalutation) {
         $salutation = new \Avisota\Contao\Entity\Salutation();
         $entityAccessor->setProperties($salutation, $predefinedSalutation);
         $salutation->setSalutation($translator->translate($index, 'avisota_salutation'));
         $salutation->setSalutationGroup($salutationGroup);
         $salutation->setSorting($sorting);
         $salutationGroup->addSalutation($salutation);
         $sorting *= 2;
     }
     $entityManager->persist($salutationGroup);
     $entityManager->flush($salutationGroup);
     $sessionConfirm = Session::getInstance()->get('TL_CONFIRM');
     if (!is_array($sessionConfirm)) {
         $sessionConfirm = (array) $sessionConfirm;
     }
     $sessionConfirm[] = $translator->translate('group_generated', 'orm_avisota_salutation_group');
     Session::getInstance()->set('TL_CONFIRM', $sessionConfirm);
     Controller::redirect('contao/main.php?do=avisota_salutation');
 }
コード例 #8
0
ファイル: System.php プロジェクト: contao/core-bundle
 /**
  * Redirect to another page
  *
  * @param string  $strLocation The target URL
  * @param integer $intStatus   The HTTP status code (defaults to 303)
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use Controller::redirect() instead.
  */
 public static function redirect($strLocation, $intStatus = 303)
 {
     @trigger_error('Using System::redirect() has been deprecated and will no longer work in Contao 5.0. Use Controller::redirect() instead.', E_USER_DEPRECATED);
     \Controller::redirect($strLocation, $intStatus);
 }
コード例 #9
0
 /**
  * Redirect the user to given module
  *
  * @param string $target
  */
 protected function redirectToModule($target)
 {
     list($module, $params) = trimsplit('|', $target);
     $modules = $this->getModules();
     if (!isset($modules[$module])) {
         return;
     }
     $session = Session::getInstance()->getData();
     // Set the filters of all module tables to show all message types
     foreach ($modules[$module]['tables'] as $table) {
         $session['filter'][$table][AbstractHandler::$filterName] = AbstractHandler::getAvailableFilters()[0];
     }
     // Decode the params
     if ($params) {
         $params = '&' . base64_decode($params);
     }
     Session::getInstance()->setData($session);
     Controller::redirect('contao/main.php?do=' . $module . $params . '&' . AbstractHandler::$serpTemporaryParamName . '=1');
 }
コード例 #10
0
 /**
  * @inheritdoc
  */
 protected function doSwitchView($id)
 {
     Session::getInstance()->set('tl_page_node', (int) $id);
     Controller::redirect(Url::removeQueryString(['switchLanguage']));
 }
 /**
  * Handle a redirect event.
  *
  * @param RedirectEvent $event The event.
  *
  * @return void
  */
 public static function handleRedirect(RedirectEvent $event)
 {
     Controller::redirect($event->getNewLocation(), $event->getStatusCode());
 }
コード例 #12
0
 /**
  * @inheritdoc
  *
  * @throws \InvalidArgumentException
  */
 protected function doSwitchView($id)
 {
     $url = Url::removeQueryString(['switchLanguage']);
     $url = Url::addQueryString('id=' . $id, $url);
     Controller::redirect($url);
 }