public function redirect($code, $nb_site_target, $nb_language = null, $params = null)
    {
        global $NABU_HTTP_CODES;

        if (is_string($nb_site_target)) {
            $url = new CNabuURL($nb_site_target);
            if (!$url->isValid()) {
                $nb_site_target = CNabuSiteTarget::findByKey($this, $nb_site_target);
                unset($url);
            }
        } elseif (is_numeric($nb_site_target)) {
            $nb_site_target = new CNabuSiteTarget($nb_site_target);
            if ($nb_site_target->isNew()) {
                $nb_site_target = null;
            }
        } elseif ($nb_site_target instanceof CNabuDataObject) {
            if (!($nb_site_target instanceof CNabuSiteTarget)) {
                $nb_site_target = new CNabuSiteTarget($nb_site_target);
                if ($nb_site_target->isNew()) {
                    $nb_site_target = null;
                }
            }
        } else {
            $nb_site_target = null;
        }

        if ($nb_site_target != null) {
            $encoded = '';
            if ($params != null && count($params) > 0) {
                foreach ($params as $field => $value) {
                    $encoded .= (strlen($encoded) > 0 ? "&" : "").urlencode($field)."=".urlencode($value);
                }
                $encoded = '?'.$encoded;
            }

            $nb_language_id = nb_getMixedValue($nb_language, 'nb_language_id');
            $nb_site = $this->nb_request->getSite();
            if ($nb_language_id == null) {
                $nb_language_id = $nb_site->getDefaultLanguageId();
            }

            $url = ($nb_site_target instanceof CNabuSiteTarget
                   ? $nb_site_target->getFullyQualifiedURL($nb_language_id) . $encoded
                   : $nb_site_target);
            throw new ENabuRedirectionException($code, $url);
        } elseif (isset($url)) {
            throw new ENabuRedirectionException($code, $url->getURL());
        } else {
            $this->http_response_code = 500;
            throw new ENabuCoreException(ENabuCoreException::ERROR_REDIRECTION_TARGET_NOT_VALID);
        }
    }
public function redirect($code, $nb_site_target, $nb_language = null, $params = null)
    {
        global $NABU_HTTP_CODES;

        if (is_string($nb_site_target)) {
            $url = new CNabuURL($nb_site_target);
            if (!$url->isValid()) {
                $nb_site_target = CNabuSiteTarget::findByKey($this, $nb_site_target);
                unset($url);
            }
        } elseif (is_numeric($nb_site_target)) {
            $nb_site_target = new CNabuSiteTarget($nb_site_target);
            if ($nb_site_target->isNew()) {
                $nb_site_target = null;
            }
        } elseif ($nb_site_target instanceof CNabuDataObject) {
            if (!($nb_site_target instanceof CNabuSiteTarget)) {
                $nb_site_target = new CNabuSiteTarget($nb_site_target);
                if ($nb_site_target->isNew()) {
                    $nb_site_target = null;
                }
            }
        } else {
            $nb_site_target = null;
        }

        if ($nb_site_target != null) {
            $encoded = '';
            if ($params != null && count($params) > 0) {
                foreach ($params as $field => $value) {
                    $encoded .= (strlen($encoded) > 0 ? "&" : "").urlencode($field)."=".urlencode($value);
                }
                $encoded = '?'.$encoded;
            }

            $nb_language_id = nb_getMixedValue($nb_language, 'nb_language_id');
            $nb_site = $this->nb_request->getSite();
            if ($nb_language_id == null) {
                $nb_language_id = $nb_site->getDefaultLanguageId();
            }

            $url = ($nb_site_target instanceof CNabuSiteTarget
                   ? $nb_site_target->getFullyQualifiedURL($nb_language_id) . $encoded
                   : $nb_site_target);
            throw new ENabuRedirectionException($code, $url);
        } elseif (isset($url)) {
            throw new ENabuRedirectionException($code, $url->getURL());
        } else {
            $this->http_response_code = 500;
            throw new ENabuCoreException(ENabuCoreException::ERROR_REDIRECTION_TARGET_NOT_VALID);
        }
    }
public function redirect ( $ code , $ nb_site_target , $ nb_language = null , $ params = null ) { global $ NABU_HTTP_CODES ; if ( is_string ( $ nb_site_target ) ) { $ url = new CNabuURL ( $ nb_site_target ) ; if ( ! $ url -> isValid ( ) ) { $ nb_site_target = CNabuSiteTarget :: findByKey ( $ this , $ nb_site_target ) ; unset ( $ url ) ; } } elseif ( is_numeric ( $ nb_site_target ) ) { $ nb_site_target = new CNabuSiteTarget ( $ nb_site_target ) ; if ( $ nb_site_target -> isNew ( ) ) { $ nb_site_target = null ; } } elseif ( $ nb_site_target instanceof CNabuDataObject ) { if ( ! ( $ nb_site_target instanceof CNabuSiteTarget ) ) { $ nb_site_target = new CNabuSiteTarget ( $ nb_site_target ) ; if ( $ nb_site_target -> isNew ( ) ) { $ nb_site_target = null ; } } } else { $ nb_site_target = null ; } if ( $ nb_site_target != null ) { $ encoded = '' ; if ( $ params != null && count ( $ params ) > 0 ) { foreach ( $ params as $ field => $ value ) { $ encoded .= ( strlen ( $ encoded ) > 0 ? "&" : "" ) . urlencode ( $ field ) . "=" . urlencode ( $ value ) ; } $ encoded = '?' . $ encoded ; } $ nb_language_id = nb_getMixedValue ( $ nb_language , 'nb_language_id' ) ; $ nb_site = $ this -> nb_request -> getSite ( ) ; if ( $ nb_language_id == null ) { $ nb_language_id = $ nb_site -> getDefaultLanguageId ( ) ; } $ url = ( $ nb_site_target instanceof CNabuSiteTarget ? $ nb_site_target -> getFullyQualifiedURL ( $ nb_language_id ) . $ encoded : $ nb_site_target ) ; throw new ENabuRedirectionException ( $ code , $ url ) ; } elseif ( isset ( $ url ) ) { throw new ENabuRedirectionException ( $ code , $ url -> getURL ( ) ) ; } else { $ this -> http_response_code = 500 ; throw new ENabuCoreException ( ENabuCoreException :: ERROR_REDIRECTION_TARGET_NOT_VALID ) ; } }
This function makes the redirection to another page. Parameters permits a wide range of options.
@param int $code result code for HTTP protocol message
@param mixed $nb_site_target target to redirect. It can be a string with a URL or a Site Target key,
an integer with a Site Target ID or a CNabuDataObject containing a field named nb_site_target_id
@param mixed $nb_language language to use in redirection. It can be a Language ID,
a CNabuLanguage object or a CNabuDataObject containing a field named nb_language_id
@param array $params aditional params for URL as an associative array
@return bool If redirection is not allowed, then returns false.
In another case, the function makes exit internally and breaks the program flow.
This function makes the redirection to another page . Parameters permits a wide range of options .