Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 210 | Rev 259 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
// declare(encoding='UTF-8');

/**
 * Classe de gestion des liens.
 *
 * @package     ODS_saisie
 * @category    Php 5.2
 * @author      Aurélien Peronnet <aurelien@tela-botanica.org>
 * @copyright   2010 Tela-Botanica
 * @license     http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
 * @license     http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
 * @version     SVN: $Id: Fiche.php 152 2010-09-06 16:19:12Z jpm $
 */
class Liens extends aControleur {

        public static function construireUrl($tableau_params, $conserver_parametres_actuels = false) {
                
                if ($conserver_parametres_actuels) {
                        return '?'.http_build_query($tableau_params + $_GET);
                }
                return '?'.http_build_query($tableau_params);
        }
        
        public static function getUrlSquelette() {
                
        $url_base = self::getUrlBaseComplete();         
        $url_base_squelette = $url_base.Config::get('dossier_squelettes').DS;
        
        return $url_base_squelette;
    }
    
    public static function getUrlStyle() {
        $url_base_style = self::getUrlSquelette().'css'.DS;
        
        return $url_base_style;
    }
    
    public static function getUrlScript() {
        $url_base_script = self::getUrlSquelette().'js'.DS;
        
        return $url_base_script;
    }
    
    public static function getUrlImage() {
        $url_base_image = self::getUrlSquelette().'images'.DS;
        
        return $url_base_image;
    }
    
    public static function getUrlImageEspece($nom_sci, $format = 'CXS') {
        
        $nom_sci_formate = strtolower(str_replace(' ', '_', $nom_sci));
        
        if(!file_exists(Config::get('dossier_images_especes').$format.'/'.$nom_sci_formate.'.jpg')) {
                return Config::get('url_images_especes').$format.'/'.'vide.jpg';
        }
        
        return Config::get('url_images_especes').$format.'/'.$nom_sci_formate.'.jpg';
    }
    
    public static function getCreditImageEspece($nom_sci) {
        
        $nom_sci_formate = strtolower(str_replace(' ', '_', $nom_sci));
        
        if(!file_exists(Config::get('dossier_images_especes').'/'.$nom_sci_formate.'.txt')) {
                $credit = '';
        } else {
                $credit = file_get_contents(Config::get('dossier_images_especes').'/'.$nom_sci_formate.'.txt');
                $credit = htmlentities($credit);
        }
        
        if(trim($credit) != '') {
                $credit = 'Crédits : '.$credit;
        }
        
        return $credit;
    }
    
        public static function getUrlBaseReecrite() {
                
                if(isset($_SERVER['REDIRECT_URL']) && $_SERVER['REDIRECT_URL'] != '') {
                        
                }
                
                $base_url_reecrite = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REDIRECT_URL'];
                $base_url_reecrite .= '/';
                
                return $base_vrai_chemin;
        }
    
        public static function getUrlBase() {
                
                $base_vrai_chemin = str_replace(realpath($_SERVER['DOCUMENT_ROOT']),'',realpath(Application::getChemin()));
                $base_vrai_chemin .= '/';
                
                return $base_vrai_chemin;
        }
        
        public static function getUrlBaseComplete() {
                return 'http://'.$_SERVER['SERVER_NAME'].str_replace(realpath($_SERVER['DOCUMENT_ROOT']),'',realpath(Application::getChemin())).'/';
        }
        
    public static function getUrlDefaut() {     
        
        $params = array();
        return self::construireUrl($params);    
    }
    
    public static function getUrlConsultationFicheStation($id_station) {        
        
        $params = array(
                'module' => 'Station',
                'action' => 'afficherInformationsStation',
                'id_station' => $id_station
        );
        return self::construireUrl($params);    
    }
    
    public static function getUrlFormulaireSaisieStation() {
        
        $params = array(
                'module' => 'Station',
                'action' => 'afficherFormulaireSaisieStation',
                'id_station' => 'saisie'
        );
        return self::construireUrl($params);
    }
    
    public static function getUrlValidationFormulaireSaisieStation() {
        $params = array(
                'module' => 'Station',
                'action' => 'validerFormulaireSaisieStation'
        );
        return self::construireUrl($params);
    }
    
    public static function getUrlFormulaireModificationStation($id_station) {
        $params = array(
                'module' => 'Station',
                'action' => 'afficherFormulaireModificationStation',
                'id_station' => $id_station
        );
        return self::construireUrl($params);
    }
    
    public static function getUrlValidationFormulaireModificationStation($id_station) {
        $params = array(
                'module' => 'Station',
                'action' => 'validerFormulaireModificationStation',
                'id_station' => $id_station
        );
        return self::construireUrl($params);
    }
    
    public static function getUrlFormulaireSuppressionStation() {
        
                $params = array(
                'module' => 'Station',
                'action' => 'supprimerStation'
        );
        return self::construireUrl($params);
    }
    
        public static function getUrlFormulaireAjoutEspece($id_station) {  

                $params = array(
                'module' => 'Espece',
                'action' => 'afficherFormulaireSaisieEspece',
                'id_station' => $id_station,
                'id_espece' => 'saisie'
        ); 
        
        return self::construireUrl($params); 
        }
        
        public static function getUrlValidationFormulaireSaisieEspece($id_station) {  
                
                $params = array(
                'module' => 'Espece',
                'action' => 'validerFormulaireSaisieEspece',
                'id_station' => $id_station,
                'id_espece' => 'saisie'
        );      
        
        return self::construireUrl($params);    
        }
    
    public static function getUrlConsultationFicheIndividu($id_station, $id_espece, $id_individu) { 

        $params = array(
                'module' => 'Individu',
                'action' => 'afficherInformationsIndividu',
                'id_station' => $id_station,
                'id_espece' => $id_espece,
                'id_individu' => $id_individu
        );
        return self::construireUrl($params);
        
    }
    
        public static function getUrlFormulaireSaisieIndividu($id_station, $id_espece) {        
                
                $params = array(
                'module' => 'Individu',
                'action' => 'afficherFormulaireSaisieIndividu',
                'id_station' => $id_station,
                'id_espece' => $id_espece
        );
        return self::construireUrl($params);    
    }
    
        public static function getUrlValidationFormulaireSaisieIndividu($id_station, $id_espece) { 

                $params = array(
                'module' => 'Individu',
                'action' => 'validerFormulaireSaisieIndividu',
                'id_station' => $id_station,
                'id_espece' => $id_espece
        );
        return self::construireUrl($params); 
    }
    
        public static function getUrlFormulaireModificationIndividu($id_station, $id_espece, $id_individu) {    
                
                $params = array(
                'module' => 'Individu',
                'action' => 'afficherFormulaireModificationIndividu',
                'id_station' => $id_station,
                'id_espece' => $id_espece,
                        'id_individu' => $id_individu
        );
        return self::construireUrl($params);    
    }
    
        public static function getUrlValidationFormulaireModificationIndividu($id_station, $id_espece, $id_individu) { 

                $params = array(
                'module' => 'Individu',
                'action' => 'validerFormulaireModificationIndividu',
                'id_station' => $id_station,
                'id_espece' => $id_espece,
                        'id_individu' => $id_individu
        );
        return self::construireUrl($params); 
    }
    
        public static function getUrlSuppressionIndividu($id_station, $id_espece, $id_individu) { 

                $params = array(
                'module' => 'Individu',
                'action' => 'supprimerIndividu',
                'id_station' => $id_station
        );
        return self::construireUrl($params); 
    }
  
    public static function getUrlConsultationEspeceStation($id_station, $id_espece, $annee = null) { 
        
        if($annee == null) {
                $annee = date('Y');
        }
        
        $params = array(
                'module' => 'Individu',
                'action' => 'afficherListeIndividu',
                'id_station' => $id_station,
                'id_espece' => $id_espece,
                'annee' => $annee
        );      
        
        return self::construireUrl($params); 
    }
        
    public static function getUrlFormulaireModificationObservation($id_station,$id_espece, $id_individu, $annee = null) {
        
        if($annee == null) {
                $annee = date('Y');
        }
        
        $params = array(
                'module' => 'Observation',
                'action' => 'afficherFormulaireModificationObservation',
                'id_station' => $id_station,
                'id_espece' => $id_espece,
                'id_individu' => $id_individu,
                'annee' => $annee
        );      
        
        return self::construireUrl($params);    
    }
    
        public static function getUrlValidationFormulaireModificationObservation($id_station,$id_espece, $id_individu, $annee = null) {
                
                if($annee == null) {
                $annee = date('Y');
        }
        
        $params = array(
                'module' => 'Observation',
                'action' => 'validerFormulaireModificationObservation',
                'id_station' => $id_station,
                'id_espece' => $id_espece,
                'id_individu' => $id_individu,
                'annee' => $annee
        ); 
        
                return self::construireUrl($params); 
    }
    
        public static function getUrlExportDonneesObservations() {
                
                return Config::get('url_jrest').'OdsExport/FichierExportObservationCSV/'; 
    }
    
        public static function getUrlExportDonneesObservationsPourUtilisateur() {
                
                $params = array(
                'module' => 'Export',
                'action' => 'envoyerFichierCSVExportObservation'
        ); 
        
                return self::construireUrl($params); 
    }
    
    public static function renvoyerStylesInclus() {
        
        $styles = '';
        $styles .= '<link href="'.self::getUrlStyle().'saisie.css" rel="stylesheet" type="text/css"/>';         
                $styles .= '<link href="'.self::getUrlStyle().'jquery_ui/jquery-ui-1.8.6.custom.css" rel="stylesheet" type="text/css"/>';
                $styles .= '<link href="'.self::getUrlStyle().'jquery_ui/jquery.ui.datepicker.css" rel="stylesheet" type="text/css"/>';
        
        return $styles;
        
    }
    
        public static function renvoyerScriptsInclus() {
                
        $scripts = '<script type="text/javascript">'.
                                        ' var urlBaseJrest = "'.Config::get('url_jrest').'"; '.
                                '</script>';
        $scripts .= '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>';
        $scripts .= '<script type="text/javascript" src="'.self::getUrlScript().'jquery-1.4.4.min.js"></script>';
        $scripts .= '<script type="text/javascript" src="'.self::getUrlScript().'jquery_ui/jquery-ui-1.8.6.custom.min.js"></script>';
                $scripts .= '<script type="text/javascript" src="'.self::getUrlScript().'saisie.js"></script>';
                
                if(AppControleur::getUtilisateur()->estAdmin()) {
                        $scripts .= '<script type="text/javascript" src="'.self::getUrlScript().'saisie_admin.js"></script>';
                }
                
        $scripts .= '<script type="text/javascript" src="'.self::getUrlScript().'jquery_ui/jquery.ui.datepicker.js"></script>';
        $scripts .= '<script type="text/javascript" src="'.self::getUrlScript().'jquery_ui/jquery.ui.datepicker-fr.js"></script>';
        
        return $scripts;
        
    }
    
    
}
?>