web/client.php
changeset 1557 7c67caaafdeb
parent 1518 a3c6f244dbc1
child 1558 761ba7426984
--- a/web/client.php	Thu Dec 02 13:52:58 2021 +0100
+++ b/web/client.php	Mon Nov 20 18:10:58 2023 +0100
@@ -15,7 +15,7 @@
 /**
  * Do we already have a valid Access Token or need to go get one?
  */
-if (!isset($_SESSION['TWITTER_ACCESS_TOKEN']) && isset($_GET['CONNECT']) ) {
+if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN']) && isset($_GET['CONNECT']) ) {
     // /**
     //  * Guess we need to go get one!
     //  */
@@ -27,7 +27,8 @@
     //  * approve our access
     //  */
     // $consumer->redirect();
-    $get_twitter_request_token();
+    $socialDomain = $_GET['CONNECT'];
+    $get_social_request_token($socialDomain, $config);
 } else {
     if (isset($_SESSION['TWITTER_REDIRECT_URL'])) {
         unset($_SESSION['TWITTER_REDIRECT_URL']);
@@ -51,7 +52,7 @@
     (isset($config['islive_embed']) && $config['islive_embed']) || (isset($config['islive']) && $config['islive']);
 $videoWidth = ( $embed ? 412 : 480 );
 $videoHeight = ( $embed ? 280 : 320 );
-if ($embed && !isset($_SESSION['TWITTER_ACCESS_TOKEN']) && (isset($_REQUEST['auth_redirect']) || isset($_SERVER['HTTP_REFERER']))) {
+if ($embed && !isset($_SESSION['SOCIAL_ACCESS_TOKEN']) && (isset($_REQUEST['auth_redirect']) || isset($_SERVER['HTTP_REFERER']))) {
     $_SESSION['TWITTER_REDIRECT_URL'] = isset($_REQUEST['auth_redirect']) ? $_REQUEST['auth_redirect'] : $_SERVER['HTTP_REFERER'];
 };
 
@@ -74,7 +75,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <title>Polemic Tweet &mdash; <?php echo($translate->_('config__title')); ?></title>
     <meta http-equiv="X-UA-Compatible" content="IE=9" />
-
+    <link rel="icon" type="image/x-icon" href="<?php echo(URL_ROOT); ?>images/favico.png">
     <!-- FONT -->
     <link href='<?php echo(registry_url('PT-Sans_Narrow','font'))?>' rel='stylesheet' type='text/css'>
     <link href='<?php echo(registry_url('PT-Sans','font'))?>' rel='stylesheet' type='text/css'>
@@ -116,11 +117,11 @@
         $hVal = intval(($annot_def['colors']['h']<1.0)?floatval($annot_def['colors']['h']) * 360.0:$annot_def['colors']['h']);
         $sVal = intval(floatval($annot_def['colors']['s']) * 100.0);
 
-        $baseColor = "hsl($hVal, ${sVal}%, 90%)";
-        $borderColor = "hsl($hVal, ${sVal}%, 60%)";
+        $baseColor = "hsl($hVal, {$sVal}%, 90%)";
+        $borderColor = "hsl($hVal, {$sVal}%, 60%)";
         $selectedColor = "hsl($hVal, 15%, 70%)";
         $selectedBorderColor = "hsl($hVal, 15%, 60%)";
-        $gradientColor = "hsl($hVal, ${sVal}%, 50%)";
+        $gradientColor = "hsl($hVal, {$sVal}%, 50%)";
     ?>
     .tweetButton.<?php echo($annot_def['colors_class']) ?> {
         background: <?php echo($baseColor); ?>;
@@ -165,7 +166,7 @@
             }
         }
     </script>
-    <?php if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])) { ?>
+    <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
     <script type="text/javascript" src="<?php echo(registry_url('twcx-main','js'))?>"></script>
     <?php } ?>
 
@@ -182,6 +183,9 @@
             const TWEET_LENGTH = <?php echo(TWEET_LENGTH)?>;
             function updateCounter() {
                 var _v = $("#status").val();
+                if(!_v) {
+                    return;
+                }
                 var _tRes = twttr.txt.parseTweet(_v);
                 if(_tRes.valid) {
                     $('#tweetCounter').removeClass("tweetCounterNegative");
@@ -489,13 +493,13 @@
                 </div>
                 <div id="twwWrap">
                     <div id="tweetWriter">
-                            <?php if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])): ?>
+                            <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])): ?>
                             <div id="tweetCounter"><?php echo(TWEET_LENGTH-strlen($config['hashtag']));?></div>
                             <?php endif;?>
                         <h3 class="tweetWriterTitle"><?php print $translate->_("ClientTitle1 :"); ?></h3>
                         <form  action="tweet.php" method="post" id="statusform" >
-                            <?php if (!isset($_SESSION['TWITTER_ACCESS_TOKEN'])){
-                                echo("<div class='loginbutton'><a href='".URL_ROOT."$rep/client.php?CONNECT=true' target='_top' class='loginlink'>".$translate->_("Vous n'êtes pas connecté.")."</a></div>");
+                            <?php if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){
+                                echo("<div class='loginbutton'><a href='".URL_ROOT."$rep/client.php?CONNECT=mastodon.svc.iri-research.org' target='_top' class='loginlink'>".$translate->_("Vous n'êtes pas connecté.")."</a></div>");
                             } else {
                                 echo("<textarea name='status' id='status' rows='3' cols='50'>$config[hashtag]</textarea>");
                             }
@@ -527,7 +531,7 @@
                     </div>
                 </div>
 
-            <?php if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])) { ?>
+            <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
 
                 <div id="tweetviz">
                     <div class="barre">
@@ -555,7 +559,7 @@
 
             <?php } else {?>
 
-                <p class="connect-message"><a href="<?php echo URL_ROOT.$rep; ?>/client.php?CONNECT=true"><?php echo $translate->_('You must be connected with your Twitter account to read the conversation'); ?></a></p>
+                <p class="connect-message"><a href="<?php echo URL_ROOT.$rep; ?>/client.php?CONNECT=mastodon.svc.iri-research.org"><?php echo $translate->_('You must be connected with your Twitter account to read the conversation'); ?></a></p>
 
             <?php } ?>
 
@@ -578,7 +582,7 @@
          <?php
                 echo("<span id=\"event-partenaires\">".$translate->_('config__partenaires')."</span>");
 
-                if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])){
+                if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){
                     echo("| <a href='clear.php' class='footerLink'>".$translate->_("D&eacute;connexion")."</a>");
                 }
          ?><br>