web/common.php
changeset 1427 8b3d57a519eb
parent 1425 99671a4d5274
child 1435 228471fbc9fa
equal deleted inserted replaced
1426:15a1a28f609a 1427:8b3d57a519eb
     1 <?php
     1 <?php
     2 
     2 
     3 /**
     3 // composer autoload files
     4  * If you haven't edited php.ini to add the Zend Framework and the
     4 require __DIR__ . '/vendor/autoload.php';
     5  * Zend Framework Incubator to the PHP include_path, then do so here.
     5 
     6  * Don't use mine!
     6 use Abraham\TwitterOAuth\TwitterOAuth;
     7  */
       
     8 set_include_path(
       
     9     'lib'
       
    10     . PATH_SEPARATOR . get_include_path()
       
    11 );
       
    12 
     7 
    13 /**
     8 /**
    14 * Base configuration
     9 * Base configuration
    15 */
    10 */
    16 date_default_timezone_set('UTC');
    11 date_default_timezone_set('UTC');
    81     include_once dirname(__FILE__)."/$req_rep/traduction.php";
    76     include_once dirname(__FILE__)."/$req_rep/traduction.php";
    82 }
    77 }
    83 
    78 
    84 
    79 
    85 /**
    80 /**
    86  * Make sure Zend_Oauth's Consumer is loaded
       
    87  */
       
    88 require_once dirname(__FILE__).'/lib/Zend/Oauth/Consumer.php';
       
    89 
       
    90 /** Zend_Locale */
       
    91 require_once dirname(__FILE__).'/lib/Zend/Locale.php';
       
    92 
       
    93 /** Zend_Translate_Adapter */
       
    94 require_once dirname(__FILE__).'/lib/Zend/Translate/Adapter.php';
       
    95 
       
    96 /**
       
    97  * Start up the ol' session engine
    81  * Start up the ol' session engine
    98  */
    82  */
    99 session_start();
    83 session_start();
   100 
    84 
   101 /**
    85 /**
   102  * Include the configuration data for our OAuth Client (array $configuration)
    86  * Include the configuration data for our OAuth Client (array $configuration)
   103  */
    87  */
   104 include_once dirname(__FILE__).'/config.php';
    88 include_once dirname(__FILE__).'/config.php';
   105 
    89 
   106 
    90 
   107 $configuration['callbackUrl'] = URL_ROOT."$req_rep/callback.php";
    91 $get_twitter_request_token = function () use ($req_rep) {
   108 
    92 
   109 
    93     $twitterClient = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
   110 /**
    94     $token = $twitterClient->oauth('oauth/request_token', array('oauth_callback' => URL_ROOT."callback.php?rep=$req_rep"));
   111  * Setup an instance of the Consumer for use
    95 
   112  */
    96     $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);
   113 $consumer = new Zend_Oauth_Consumer($configuration);
    97 
       
    98     /**
       
    99      * Now redirect user to Twitter site so they can log in and
       
   100      * approve our access
       
   101      */
       
   102     $url = $twitterClient->url('oauth/authorize', array('oauth_token' => $token['oauth_token']));
       
   103     header("Location: ".$url);
       
   104     die();
       
   105 };
   114 
   106 
   115 /**
   107 /**
   116  * TRADUCTION
   108  * TRADUCTION
   117 **/
   109 **/
   118 function get_config_translations($config) {
   110 function get_config_translations($config) {
   162     // set the locale back
   154     // set the locale back
   163     $translate->setLocale($locale);
   155     $translate->setLocale($locale);
   164 }
   156 }
   165 
   157 
   166 
   158 
   167 Zend_Loader::loadClass('Zend_Translate');
   159 // use Translator;
   168 Zend_Loader::loadClass('Zend_Http_Cookie');
   160 include './Translator.php';
   169 
   161 $translate = new Translator();
   170 
       
   171 $client = new Zend_Http_Client();
       
   172 $translate = new Zend_Translate('array', $init, 'fr');
       
   173 
   162 
   174 
   163 
   175 $translate->addTranslation($traduction_en, 'en');
   164 $translate->addTranslation($traduction_en, 'en');
   176 $translate->addTranslation($traduction_ja, 'ja_JP');
   165 $translate->addTranslation($traduction_ja, 'ja_JP');
   177 $translate->addTranslation($traduction_fr, 'fr');
   166 $translate->addTranslation($traduction_fr, 'fr');
   178 
   167 
   179 if(isset($config)) {
   168 if(isset($config)) {
   180 
       
   181     set_config_translations($config, $translate);
   169     set_config_translations($config, $translate);
   182 //     $config_translations = get_config_translations($config);
       
   183 
       
   184 
       
   185 //     $translate->addTranslation($config_translations['en'], 'en');
       
   186 //     $translate->addTranslation($config_translations['jp'], 'ja_JP');
       
   187 //     $translate->addTranslation($config_translations['fr'], 'fr');
       
   188 }
   170 }
   189 
   171 
   190 $actual = $translate->getLocale();
   172 $actual = $translate->getLocale();
   191 
   173 
   192 //$translate->setLocale("en");
       
   193 // $acceptCookie = $this->_request->getCookie('acceptCookie',0);
       
   194 
   174 
   195 if(isset($_GET['lang'])==false and isset($_SESSION['lang'])==false){
   175 if(isset($_GET['lang'])==false and isset($_SESSION['lang'])==false){
   196 
   176 
   197     if($actual!='fr' and $actual!='en' and $actual!='ja_JP'){
   177     if($actual!='fr' and $actual!='en' and $actual!='ja_JP'){
   198         $translate->setLocale("fr");
   178         $translate->setLocale("fr");
   479 function get_archive_box($rep, $metadata, $url_root, $basepath, &$translate) {
   459 function get_archive_box($rep, $metadata, $url_root, $basepath, &$translate) {
   480 
   460 
   481     include("$basepath$rep/config.php");
   461     include("$basepath$rep/config.php");
   482 
   462 
   483     set_config_translations($config, $translate);
   463     set_config_translations($config, $translate);
   484 /* 	$config_translations = get_config_translations($config);
   464 
   485 
       
   486 // 	save the locale because it gets changed when adding translations
       
   487     $locale = $translate->getLocale();
       
   488 
       
   489     $translate->addTranslation($config_translations['en'], 'en');
       
   490     $translate->addTranslation($config_translations['jp'], 'ja_JP');
       
   491     $translate->addTranslation($config_translations['fr'], 'fr');
       
   492 
       
   493 // 	set the locale back
       
   494     $translate->setLocale($locale);
       
   495  */
       
   496     $id = "abox_$rep".(($metadata!=null)?"_$metadata":"");
   465     $id = "abox_$rep".(($metadata!=null)?"_$metadata":"");
   497     $hash = ($metadata!=null)?"#metadata=$metadata":"";
   466     $hash = ($metadata!=null)?"#metadata=$metadata":"";
   498     $tail_img = $translate->_('config__archive_img');
   467     $tail_img = $translate->_('config__archive_img');
   499     if(is_array($tail_img)) {
   468     if(is_array($tail_img)) {
   500         $tail_img = $tail_img[$metadata];
   469         $tail_img = $tail_img[$metadata];