Changeset 64682 in spip-zone


Ignore:
Timestamp:
Aug 10, 2012, 1:41:48 PM (9 years ago)
Author:
bruno.caillard@…
Message:
  • Test si le plugin est configuré
  • qq modif mineures
File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/tradauto/tradauto.php

    r63740 r64682  
    1010function tradauto_ajout_bouton($flux)
    1111{
     12        $clientID = lire_config('tradauto/clientID');
     13        if (empty($clientID))
     14        {
     15                echo "ERREUR Tradauto : Le plugin n'est pas encore configuré.";
     16                return $flux;
     17        }
     18
    1219        $translator = new Translator();
    1320
     
    1623
    1724        include_spip('inc/cfg_config');
    18         $flux['args']['contexte']['tradauto_exclus'] = str_replace('"', '\"', lire_config('tradauto/mt_exclus'));
     25        $f = array("\\", "\"");
     26        $r =  array("\\\\", "\\\"");
     27        $flux['args']['contexte']['tradauto_exclus'] = trim(str_replace($f , $r, lire_config('tradauto/mt_exclus')));
    1928        $flux['args']['contexte']['tradauto_lang'] = (array)$translator->GetLanguages($flux['args']['contexte']['lang']); //$translator->GetLanguagesForTranslate();
    2029
     
    3140
    3241
    33 
    34 
    35 
    36 
    37 
    38 
    39 
    40 
    41 /*
    42 
    43 
    44 
    45             //Create the authorization Header string.
    46             $authHeader = "Authorization: Bearer ". $accessToken;
    47 
    48             //Create the Translator Object.
    49             $translatorObj = new HTTPTranslator();
    50 
    51             //Input String.
    52             $inputStr = 'This is the sample string.';
    53             //HTTP Detect Method URL.
    54             $detectMethodUrl = "http://api.microsofttranslator.com/V2/Http.svc/Detect?text=".urlencode($inputStr);
    55             //Call the curlRequest.
    56             $strResponse = $translatorObj->curlRequest($detectMethodUrl, $authHeader);
    57             //Interprets a string of XML into an object.
    58             $xmlObj = simplexml_load_string($strResponse);
    59             foreach((array)$xmlObj[0] as $val){
    60                 $languageCode = $val;
    61             }
    62 
    63             /*
    64              * Get the language Names from languageCodes.
    65              */
    66 /*
    67             $locale = 'en';
    68             $getLanguageNamesurl = "http://api.microsofttranslator.com/V2/Http.svc/GetLanguageNames?locale=$locale";
    69             //Create the Request XML format.
    70             $requestXml = $translatorObj->createReqXML($languageCode);
    71             //Call the curlRequest.
    72             $curlResponse = $translatorObj->curlRequest($getLanguageNamesurl, $authHeader, $requestXml);
    73 
    74             //Interprets a string of XML into an object.
    75             $xmlObj = simplexml_load_string($curlResponse);
    76             echo "<table border=2px>";
    77             echo "<tr>";
    78             echo "<td><b>LanguageCodes</b></td><td><b>Language Names</b></td>";
    79             echo "</tr>";
    80             foreach($xmlObj->string as $language){
    81                 echo "<tr><td>".$inputStr."</td><td>". $languageCode."(".$language.")"."</td></tr>";
    82             }
    83             echo "</table>";
    84         } catch (Exception $e) {
    85             echo "Exception: " . $e->getMessage() . PHP_EOL;
    86         }
    87 
    88 */
    89 
    90 
    91 
    92 
    93 
    94 
    9542?>
Note: See TracChangeset for help on using the changeset viewer.