web/client.php
changeset 1558 761ba7426984
parent 1557 7c67caaafdeb
child 1560 d441b50586ba
equal deleted inserted replaced
1557:7c67caaafdeb 1558:761ba7426984
    26     //  * Now redirect user to Twitter site so they can log in and
    26     //  * Now redirect user to Twitter site so they can log in and
    27     //  * approve our access
    27     //  * approve our access
    28     //  */
    28     //  */
    29     // $consumer->redirect();
    29     // $consumer->redirect();
    30     $socialDomain = $_GET['CONNECT'];
    30     $socialDomain = $_GET['CONNECT'];
       
    31     if (isset($_SESSION['SOCIAL_AUTH_STATE'])) {
       
    32         unset($_SESSION['SOCIAL_AUTH_STATE']);
       
    33     }
    31     $get_social_request_token($socialDomain, $config);
    34     $get_social_request_token($socialDomain, $config);
    32 } else {
    35 } else {
    33     if (isset($_SESSION['TWITTER_REDIRECT_URL'])) {
    36     if (isset($_SESSION['TWITTER_REDIRECT_URL'])) {
    34         unset($_SESSION['TWITTER_REDIRECT_URL']);
    37         unset($_SESSION['TWITTER_REDIRECT_URL']);
    35     }
    38     }
    74   <head>
    77   <head>
    75     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    78     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    76     <title>Polemic Tweet &mdash; <?php echo($translate->_('config__title')); ?></title>
    79     <title>Polemic Tweet &mdash; <?php echo($translate->_('config__title')); ?></title>
    77     <meta http-equiv="X-UA-Compatible" content="IE=9" />
    80     <meta http-equiv="X-UA-Compatible" content="IE=9" />
    78     <link rel="icon" type="image/x-icon" href="<?php echo(URL_ROOT); ?>images/favico.png">
    81     <link rel="icon" type="image/x-icon" href="<?php echo(URL_ROOT); ?>images/favico.png">
    79     <!-- FONT -->
       
    80     <link href='<?php echo(registry_url('PT-Sans_Narrow','font'))?>' rel='stylesheet' type='text/css'>
       
    81     <link href='<?php echo(registry_url('PT-Sans','font'))?>' rel='stylesheet' type='text/css'>
       
    82 
    82 
    83     <!-- CSS -->
    83     <!-- CSS -->
    84     <link rel="stylesheet" href="<?php echo(registry_url('fancybox','css'));?>" type="text/css" media="screen">
    84     <link href='<?php echo(URL_ROOT); ?>res/css/main.css' rel='stylesheet' type='text/css'/>
    85     <link rel="stylesheet" href="<?php echo(registry_url('tweetcast','css'));?>?v=210512" type="text/css" media="screen, projection"/>
    85     <link href='<?php echo(URL_ROOT); ?>res/css/vendors.css' rel='stylesheet' type='text/css'/>
    86     <link href="<?php echo(registry_url('videojs','css'));?>" rel="stylesheet"-->
       
    87 
       
    88     <link href='<?php echo(URL_ROOT); ?>res/css/common.css' rel='stylesheet' type='text/css'/>
    86     <link href='<?php echo(URL_ROOT); ?>res/css/common.css' rel='stylesheet' type='text/css'/>
    89 
    87 
    90     <!-- JAVASCRIPT -->
    88     <!-- JAVASCRIPT -->
    91     <script type="text/javascript" src="<?php echo(registry_url('jquery','js'))?>"></script>
       
    92     <?php if( isset($_REQUEST['highlight']) && !empty($_REQUEST['highlight'])) { ?>
       
    93     <script type="text/javascript" src="<?php echo(registry_url('jquery-ui','js'))?>"></script>
       
    94     <?php } ?>
       
    95     <script type="text/javascript" src="<?php echo(registry_url('jquery-mousewheel','js'))?>"></script>
       
    96     <script type="text/javascript" src="<?php echo(registry_url('jquery-scrollto','js'))?>"></script>
       
    97     <script type="text/javascript" src="<?php echo(registry_url('underscore','js'))?>"></script>
       
    98     <script type="text/javascript" src="<?php echo(registry_url('raphael','js'))?>"></script>
       
    99     <script type="text/javascript" src="<?php echo(registry_url('fancybox','js'))?>"></script>
       
   100     <script type="text/javascript" src="<?php echo(registry_url('twitter-text','js'))?>"></script>
       
   101     <?php if( isset($config['additional_js']) && !empty($config['additional_js'])) { 
    89     <?php if( isset($config['additional_js']) && !empty($config['additional_js'])) { 
   102         foreach ($config['additional_js'] as $jsUrl) {?>
    90         foreach ($config['additional_js'] as $jsUrl) {?>
   103     <script type="text/javascript" src="<?php echo($jsUrl)?>"></script>
    91     <script type="text/javascript" src="<?php echo($jsUrl)?>"></script>
   104         <?php }
    92         <?php }
   105     } ?>
    93     } ?>
   146     <?php } ?>
   134     <?php } ?>
   147     </style>
   135     </style>
   148 
   136 
   149     <script type="text/javascript">
   137     <script type="text/javascript">
   150         <?php
   138         <?php
       
   139         echo "var social_network = '".$config['social_network']."';";
   151         if (isset($config['tracking_keywords']) && count($config['tracking_keywords'])) {
   140         if (isset($config['tracking_keywords']) && count($config['tracking_keywords'])) {
   152             echo "var tracking_keywords = ".json_encode($config['tracking_keywords']).';';
   141             echo "var tracking_keywords = ".json_encode($config['tracking_keywords']).';';
   153         } elseif (isset($config['hashtag'])) {
   142         } elseif (isset($config['hashtag'])) {
   154             echo "var tracking_keywords = ".json_encode(array($config['hashtag'])).";";
   143             echo "var tracking_keywords = ".json_encode(array($config['hashtag'])).";";
   155         }
   144         }
   165                 }
   154                 }
   166             }
   155             }
   167         }
   156         }
   168     </script>
   157     </script>
   169     <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
   158     <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
   170     <script type="text/javascript" src="<?php echo(registry_url('twcx-main','js'))?>"></script>
   159     <script type="text/javascript" src="<?php echo(URL_ROOT); ?>res/js/live-polemic.js"></script>
   171     <?php } ?>
   160     <?php } ?>
   172 
   161 
   173     <script type="text/javascript">
   162     <script type="text/javascript">
   174 
   163 
   175     function add_grammar(value) {
   164     function add_grammar(value) {
   184             function updateCounter() {
   173             function updateCounter() {
   185                 var _v = $("#status").val();
   174                 var _v = $("#status").val();
   186                 if(!_v) {
   175                 if(!_v) {
   187                     return;
   176                     return;
   188                 }
   177                 }
   189                 var _tRes = twttr.txt.parseTweet(_v);
   178                 var _tRes = twitter.parseTweet(_v);
   190                 if(_tRes.valid) {
   179                 if(_tRes.valid) {
   191                     $('#tweetCounter').removeClass("tweetCounterNegative");
   180                     $('#tweetCounter').removeClass("tweetCounterNegative");
   192                     $('#sendTweet').prop("disabled",false);
   181                     $('#sendTweet').prop("disabled",false);
   193                     $('#sendTweet').removeClass("sendTweetDisabled");
   182                     $('#sendTweet').removeClass("sendTweetDisabled");
   194                     $('#tweetCounter').html("");
   183                     $('#tweetCounter').html("");
   218             $("#sendTweet").click(function(e){
   207             $("#sendTweet").click(function(e){
   219                 if($('#sendTweet').prop('disabled')) {
   208                 if($('#sendTweet').prop('disabled')) {
   220                     return;
   209                     return;
   221                 }
   210                 }
   222                 var MyStatus = $('#status').val();
   211                 var MyStatus = $('#status').val();
   223                 $.post('tweet_ajax.php', {status:MyStatus}
   212                 $.post('tweet_ajax.php', {
       
   213                     status:MyStatus,
       
   214                     social_network: "<?php echo($config['social_network']) ?>",
       
   215                     domain: "<?php echo(isset($_SESSION['SOCIAL_LOGIN_DOMAIN'])?$_SESSION['SOCIAL_LOGIN_DOMAIN']:'') ?>",
       
   216                     hashtag: "<?php echo($config['hashtag']) ?>",
       
   217                     group: "<?php echo($config['group'] ?? "") ?>"
       
   218                     }
   224                 ,function(data) {
   219                 ,function(data) {
   225 
   220 
   226                     if(data=="true"){
   221                     if(data=="true"){
   227                         $("#messageSuccess").show('fast');
   222                         $("#messageSuccess").show('fast');
   228                         $("#messageSuccess").delay(800).hide('slow');
   223                         $("#messageSuccess").delay(800).hide('slow');
   391 <?php
   386 <?php
   392     if (isset($config['islive']) && $config['islive']) {
   387     if (isset($config['islive']) && $config['islive']) {
   393         $videofile = $translate->_('config__video_file');
   388         $videofile = $translate->_('config__video_file');
   394         if ($videofile === 'config__video_file') $videofile = "https://media.iri.centrepompidou.fr/dash/livestream.mpd";
   389         if ($videofile === 'config__video_file') $videofile = "https://media.iri.centrepompidou.fr/dash/livestream.mpd";
   395 ?>
   390 ?>
   396 
       
   397                     <script type="text/javascript" src="<?php echo(registry_url('dashjs','js'))?>"></script>
       
   398 
   391 
   399                     <script type="text/javascript">
   392                     <script type="text/javascript">
   400                         (function(){
   393                         (function(){
   401                             var url = "<?php echo($videofile)?>";
   394                             var url = "<?php echo($videofile)?>";
   402                             var player = dashjs.MediaPlayer().create();
   395                             var player = dashjs.MediaPlayer().create();
   495                     <div id="tweetWriter">
   488                     <div id="tweetWriter">
   496                             <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])): ?>
   489                             <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])): ?>
   497                             <div id="tweetCounter"><?php echo(TWEET_LENGTH-strlen($config['hashtag']));?></div>
   490                             <div id="tweetCounter"><?php echo(TWEET_LENGTH-strlen($config['hashtag']));?></div>
   498                             <?php endif;?>
   491                             <?php endif;?>
   499                         <h3 class="tweetWriterTitle"><?php print $translate->_("ClientTitle1 :"); ?></h3>
   492                         <h3 class="tweetWriterTitle"><?php print $translate->_("ClientTitle1 :"); ?></h3>
   500                         <form  action="tweet.php" method="post" id="statusform" >
   493                         
   501                             <?php if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){
   494                             <?php if (!isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){
   502                                 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>");
   495                                 $loginform  = "<div class='loginbutton'>";
       
   496                                 $socialNetwork = isset($config['social_network'])?$config['social_network']:'Twitter';
       
   497                                 if($socialNetwork === 'Twitter') {
       
   498                                     $loginform .= "<a href='".URL_ROOT."$rep/client.php?CONNECT=true' target='_top' class='loginlink'>".$translate->_("Vous n'êtes pas connecté.")."</a>";
       
   499                                 } else {
       
   500                                     $loginform .= "<form action='".URL_ROOT."$rep/client.php' method='GET' target='_top'>";
       
   501                                     $loginform .= "<div class='loginlink'>".$translate->_("Vous n'êtes pas connecté.")."</div>";
       
   502                                     $loginform .= "<input type='text' id='social_domain' name='CONNECT' value='mastodon.svc.iri-research.org'/>";
       
   503                                     $loginform .= "<input type='submit' value='Connect'/>";
       
   504                                     $loginform .= "</form>";    
       
   505                                 }
       
   506                                 $loginform .= "</div>";
       
   507                                 echo($loginform);
   503                             } else {
   508                             } else {
       
   509                                 echo('<form  action="tweet.php" method="post" id="statusform" >');
   504                                 echo("<textarea name='status' id='status' rows='3' cols='50'>$config[hashtag]</textarea>");
   510                                 echo("<textarea name='status' id='status' rows='3' cols='50'>$config[hashtag]</textarea>");
   505                             }
   511                             }
   506                             ?>
   512                             ?>
   507                             <div id="messageSuccess" style="background-color:lightgreen; display: none;">
   513                             <div id="messageSuccess" style="background-color:lightgreen; display: none;">
   508                                 <?php print $translate->_("Envoyé"); ?><br/><br/>
   514                                 <?php print $translate->_("Envoyé"); ?><br/><br/>
   525                                     <span class="twbLabel"><?php echo $display_parts[1]; ?></span>
   531                                     <span class="twbLabel"><?php echo $display_parts[1]; ?></span>
   526                                 </a>
   532                                 </a>
   527                             <?php } ?>
   533                             <?php } ?>
   528 
   534 
   529                             <div style="clear: both;"></div>
   535                             <div style="clear: both;"></div>
       
   536                         <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])){ ?>
   530                         </form>
   537                         </form>
       
   538                         <?php } ?>
   531                     </div>
   539                     </div>
   532                 </div>
   540                 </div>
   533 
   541 
   534             <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
   542             <?php if (isset($_SESSION['SOCIAL_ACCESS_TOKEN'])) { ?>
   535 
   543