web/polemicaltimeline.php
changeset 656 635a86f25fe7
parent 654 a5977736d2b0
child 657 d563fda7b928
--- a/web/polemicaltimeline.php	Fri Jul 06 18:23:19 2012 +0200
+++ b/web/polemicaltimeline.php	Wed Jul 11 18:21:43 2012 +0200
@@ -13,11 +13,11 @@
 
 $div_height = 640;
 if($translate->_('config__div_height') != 'config__div_height') {
-	$div_height = $translate->_('config__div_height');
+    $div_height = $translate->_('config__div_height');
 }
 $tweet_explain_background = URL_ROOT.'images/tweetExplainBgd.gif';
 if(file_exists(dirname(__FILE__)."/$rep/images/tweetExplainBgd.gif")) {
-	$tweet_explain_background = URL_ROOT.$rep.'/images/tweetExplainBgd.gif';
+    $tweet_explain_background = URL_ROOT.$rep.'/images/tweetExplainBgd.gif';
 }
 
 $head_logo = URL_ROOT."$rep/images/head_logo.gif";
@@ -27,59 +27,94 @@
 
 $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
 
+$protocol_level = (
+    isset($_REQUEST['protocol_level'])
+    ? $_REQUEST['protocol_level']
+    : (
+        isset($config['protocol_level'])
+        ? $config['protocol_level']
+        : 3
+    )
+);
+
+$protocol_level = min(3,max(0, $protocol_level));
+
+$use_protocol = (isset($_REQUEST['protocol_level']) || isset($config['protocol_level']));
+
+if ($use_protocol && !isset($_SESSION['answered_events'])) {
+    $_SESSION['answered_events'] = array();
+}
+
+$show_splash = ( $use_protocol && !in_array($rep, $_SESSION['answered_events']) );
+
+if ($show_splash) {
+    array_push($_SESSION['answered_events'], $rep);
+}
+
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html lang="<?php echo($actual); ?>">
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <title>Polemic tweet - <?php echo($translate->_('config__title')); ?></title>
-	<meta name="keywords" content="<?php echo($translate->_('config__keywords')); ?>"><!-- add timestampedmetadata -->
-	<!--<meta name="description" content="PoelmicTweet.fr : debate mapping, opinion, conference, video">-->
-	<meta name="description" content="<?php echo(strip_tags($translate->_('config__description'))); ?>">
-	<meta name="robots" content="index, follow">
-	
-	<!-- ICI : <?php echo($_SERVER['DOCUMENT_ROOT']); ?> -->
-	<!-- JAVASCRIPT -->
-	<script type="text/javascript" src="<?php echo(registry_url('json-js','js'));?>"></script>
-	<script type="text/javascript" src="<?php echo(registry_url('jquery','js'));?>"></script>
-	<script type="text/javascript">
-		$.noConflict();
-	</script>
-	<script type="text/javascript" src="<?php echo(registry_url('fancybox','js'));?>"></script>
-	<script type="text/javascript" src="<?php echo(registry_url('jquery-url','js'));?>"></script>
-	<script type="text/javascript" src="<?php echo(registry_url('metadataplayer','js'));?>"></script>
-		
-	<!-- Framework CSS -->
-    <link rel="stylesheet" href="<?php echo(registry_url('tweetcast','css'));?>?v=210512" type="text/css" media="screen, projection"/>
-	<link rel="stylesheet" href="<?php echo(registry_url('fancybox','css'));?>" media="screen"/>
-	
-	<!-- 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'/>
-	
-	
-	<script type="text/javascript">
-  		// Configuration Polemical Timeline
-	if (typeof jQuery == "undefined") {
-	    jQuery = IriSP.jQuery;
-	}
-	<?php
-  		if(is_array($translate->_('config__metadata'))):
-		reset($translate->_('config__metadata'));
-	    $first_key = key($translate->_('config__metadata'));
-	?>
-	var metadatas = jQuery.parseJSON('<?php echo(json_encode($translate->_('config__metadata'))); ?>');
-	var url = jQuery.url();
-	var metadata_key = url.fparam('metadata');
-	if(typeof metadata_key === "undefined" || metadata_key.length === 0) {
-		metadata_key = "<?php echo($first_key);?>";
-	}
-	<?php else: ?>
-	var metadatas = { metadata: {url: "<?php echo($translate->_('config__metadata'));?>"} };
-	var metadata_key = "metadata";
-	<?php endif;?>
-  		
-	
+    <meta name="keywords" content="<?php echo($translate->_('config__keywords')); ?>"><!-- add timestampedmetadata -->
+    <!--<meta name="description" content="PoelmicTweet.fr : debate mapping, opinion, conference, video">-->
+    <meta name="description" content="<?php echo(strip_tags($translate->_('config__description'))); ?>">
+    <meta name="robots" content="index, follow">
+    
+    <!-- ICI : <?php echo($_SERVER['DOCUMENT_ROOT']); ?> -->
+    <!-- JAVASCRIPT -->
+    <script type="text/javascript" src="<?php echo(registry_url('json-js','js'));?>"></script>
+    <script type="text/javascript" src="<?php echo(registry_url('jquery','js'));?>"></script>
+    <script type="text/javascript">
+        $.noConflict();
+    </script>
+    <script type="text/javascript" src="<?php echo(registry_url('fancybox','js'));?>"></script>
+    <script type="text/javascript" src="<?php echo(registry_url('jquery-url','js'));?>"></script>
+    <script type="text/javascript" src="<?php echo(registry_url('metadataplayer','js'));?>"></script>
+    <script type="text/javascript" src="<?php echo(registry_url('tracemanager','js'));?>"></script>
+        
+    <!-- Framework CSS -->
+    <link rel="stylesheet" href="<?php echo(registry_url('tweetcast','css'));?>?v=11072012" type="text/css" media="screen, projection"/>
+    <link rel="stylesheet" href="<?php echo(registry_url('fancybox','css'));?>" media="screen"/>
+    
+    <!-- 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'/>
+    
+    
+    <script type="text/javascript">
+          // Configuration Polemical Timeline
+    if (typeof jQuery == "undefined") {
+        jQuery = IriSP.jQuery;
+    }
+    <?php
+          if(is_array($translate->_('config__metadata'))):
+            reset($translate->_('config__metadata'));
+            $first_key = key($translate->_('config__metadata'));
+    ?>
+    var metadatas = jQuery.parseJSON('<?php echo(json_encode($translate->_('config__metadata'))); ?>');
+    var url = jQuery.url();
+    var metadata_key = url.fparam('metadata');
+    if(typeof metadata_key === "undefined" || metadata_key.length === 0) {
+        metadata_key = "<?php echo($first_key);?>";
+    }
+    <?php else: ?>
+    var metadatas = { metadata: {url: "<?php echo($translate->_('config__metadata'));?>"} };
+    var metadata_key = "metadata";
+    <?php endif;?>
+
+    var _tracer = tracemanager.init_trace("test", {
+            url: "http://traces.advene.org:5000/",
+            requestmode: "GET",
+            syncmode: "sync",
+            default_subject: "PolemicTweet"
+        });
+    _tracer.trace("Pt_LoadPage", {
+        protocol_level: <?php echo $protocol_level; ?>,
+        url: document.location.href
+    });
+    
     IriSP.libFiles.defaultDir = "<?php echo(registry_url('libdir','js'));?>";
     IriSP.widgetsDir = "<?php echo(registry_url('ldtwidgets','js'));?>";
     IriSP.libFiles.locations.jwPlayerSWF = "<?php echo(URL_ROOT); ?>res/mediaplayer/player.swf";
@@ -89,6 +124,7 @@
         url: metadatas[metadata_key].url + '?callback=?',
         format: 'ldt'
     };
+    var _protocol_level = <?php echo $protocol_level; ?>;
     var _config = {            
         gui: {
             width: 600,
@@ -99,20 +135,21 @@
             },
             css:'<?php echo(registry_url('metadataplayer','css'));?>',
             widgets: [
-<?php
-    if (!isset($config['protocol_level']) || $config['protocol_level'] > 1) {
-        echo '{ type: "Polemic"';
-        if (isset($config['protocol_level']) && $config['protocol_level'] < 3) {
-            echo ', polemics: []';
-        }
-        echo '},';
-    }
-?>
+<?php if ($protocol_level > 1): ?>
+                {
+                    type: "Polemic"
+<?php if ($protocol_level < 3): ?>
+                    ,
+                    polemics: []
+<?php endif; ?>
+                },
+<?php endif; ?>
                 { type: "Slider" },
                 {
                     type: "Controller",
                     disable_annotate_btn: true
                 },
+<?php if ($protocol_level > 1): ?>
                 {
                     type: "Segments",
                     annotation_type: [ "chap", "découpage" ]
@@ -134,11 +171,16 @@
                     //ajax_url : "http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=?", 
                     //foreign_url : "http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}",
                     container: "AnnotationsListContainer"
+<?php if ($protocol_level < 3): ?>
+                    ,
+                    polemics: []
+<?php endif; ?>
                 },
+<?php endif; ?>
                 { type: "Mediafragment"},
                 {
                     type: "Trace",
-                    default_subject: "Polemic"
+                    tracer: _tracer
                 }
             ]
         },
@@ -148,61 +190,111 @@
             height: 360, 
             width: 600, 
             provider: "rtmp",
-            autostart: true,
             metadata: _metadata
         }
     };
+    
+    
+    jQuery(document).ready(function() {
 
-		jQuery(document).ready(function() {
-			
-			jQuery("#mdselect_"+metadata_key).attr("selected","selected");
-			jQuery("#mdselect").change(function() {
-				var metadata_key = this.options[this.selectedIndex].value;
-				window.location.hash = "#metadata="+metadata_key;
-				window.location.href = window.location.href;
-				window.location.reload(true);
-				jQuery(".embedbutton").attr('href','<?php echo(URL_ROOT.$rep);?>/embed_form.php?metadata='+metadata_key);
-			});
-			if(metadata_key !== "metadata") {
-				jQuery(".embedbutton").attr('href','<?php echo(URL_ROOT.$rep);?>/embed_form.php?metadata='+metadata_key);
-			}
-			jQuery(".embedbutton").fancybox({
-				'width'				: 360,
-				'height'			: 360,
-				'autoDimensions'	: false,
-				'transitionIn'		: 'none',
-				'transitionOut'		: 'none',
-				'type'				: 'iframe'
-			});
-			jQuery(".acctitre").click(function() {
-			    var _nx = jQuery(this).next();
-			    if (_nx.is(":hidden")) {
-    			    jQuery(".acctexte").slideUp();
-    			    _nx.slideDown();
-			    }
-			})
-			
-		});
-	</script>
-	<script type="text/javascript">
-		var _gaq = _gaq || [];
-		_gaq.push(['_setAccount', 'UA-23581291-1']);
-		_gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);
-		_gaq.push(['_setAllowAnchor', true]);
-	  
-		(function() {
-		    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-		    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-		    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-		})();
-	</script>
+<?php if ($show_splash): ?>
+        var _fancybox = jQuery.fancybox;
+        jQuery.fancybox(
+            jQuery("#splash").html(),
+            {
+                width: 500,
+                modal: true,
+                closeBtn: false
+            });
+        
+        jQuery("#fancybox-content form").submit(function() {
+            _fancybox.close();
+            var _checkboxes = jQuery("#fancybox-content .checkbox:checked").map(function() { return this.value }),
+                _data = {
+                    eventLink: _checkboxes,
+                    eMail: jQuery("#fancybox-content .eMail").val(),
+                    twitterHandle: jQuery("#fancybox-content .twitterHandle").val(),
+                    protocolLevel: _protocol_level
+                }
+            _tracer.trace("Pt_SendForm", _data);
+            return false;
+        });
+<?php endif; ?>
+
+        jQuery("#mdselect_"+metadata_key).attr("selected","selected");
+        jQuery("#mdselect").change(function() {
+            var metadata_key = this.options[this.selectedIndex].value;
+            window.location.hash = "#metadata="+metadata_key;
+            window.location.href = window.location.href;
+            window.location.reload(true);
+            jQuery(".embedbutton").attr('href','<?php echo(URL_ROOT.$rep);?>/embed_form.php?metadata='+metadata_key);
+        });
+        if(metadata_key !== "metadata") {
+            jQuery(".embedbutton").attr('href','<?php echo(URL_ROOT.$rep);?>/embed_form.php?metadata='+metadata_key);
+        }
+        jQuery(".embedbutton").fancybox({
+            'width'                : 360,
+            'height'            : 360,
+            'autoDimensions'    : false,
+            'transitionIn'        : 'none',
+            'transitionOut'        : 'none',
+            'type'                : 'iframe'
+        });
+        jQuery(".embedbutton").click(function() {
+            _tracer.trace("Pt_EmbedButtonClicked");
+        });
+        jQuery(".acctitre").click(function() {
+            var _nx = jQuery(this).next();
+            if (_nx.is(":hidden")) {
+                jQuery(".acctexte").slideUp();
+                _nx.slideDown();
+            }
+        })
+        
+    });
+    </script>
+    <script type="text/javascript">
+        var _gaq = _gaq || [];
+        _gaq.push(['_setAccount', 'UA-23581291-1']);
+        _gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);
+        _gaq.push(['_setAllowAnchor', true]);
+      
+        (function() {
+            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+        })();
+    </script>
   </head>
   <body>
   <div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
 
   <!-- tooltip -->
   </div>
-
+    <div id="splash" style="display:none;">
+        <div class="splash">
+            <h1><?php echo $translate->_("Protocol_Head").$translate->_('config__title'); ?></h1>
+            <p><?php echo $translate->_("Protocol_Subtitle"); ?></p>
+            <?php echo $translate->_("Protocol_Explain_Level_".$protocol_level); ?>
+            <hr />
+            <h2><?php echo $translate->_("Protocol_Questions_Head"); ?></h2>
+            <form>
+                <h3><?php echo $translate->_("Protocol_Questions_Part_1_prefix").$translate->_('config__title').$translate->_("Protocol_Questions_Part_1_suffix"); ?></h3>
+                <ul>
+                    <li><input class="checkbox" type="checkbox" value="wasThere"/><?php echo $translate->_("Protocol_Answer_WasThere"); ?></li>
+                    <li><input class="checkbox" type="checkbox" value="watchedStream"/><?php echo $translate->_("Protocol_Answer_WatchedStream"); ?></li>
+                    <li><input class="checkbox" type="checkbox" value="liveTweeted"/><?php echo $translate->_("Protocol_Answer_liveTweeted"); ?></li>
+                    <li><input class="checkbox" type="checkbox" value="none"/><?php echo $translate->_("Protocol_Answer_none"); ?></li>
+                </ul>
+                <h3><?php echo $translate->_("Protocol_Questions_Part_2"); ?></h3>
+                <ul>
+                    <li><label><?php echo $translate->_("Protocol_Answer_Mail"); ?></label><input class="eMail" name="eMail" /></li>
+                    <li><label><?php echo $translate->_("Protocol_Answer_Twitter"); ?></label><input class="twitterHandle" name="twitterHandle" /></li>
+                </ul>
+                <input type="submit" value="<?php echo $translate->_("Protocol_Submit_Label"); ?>" class="submit" />
+            </form>
+        </div>
+    </div>
     <div id="container">
         <div class="barre">
             <img id="headlogo" src="<?php echo($head_logo); ?>" width="171" height="63" />
@@ -226,18 +318,18 @@
             </ul>
             <ul class="menu">
                 <li>
-                    <a href="<?php URL_ROOT ?>client.php?lang=ja_JP" class="menuLink" >
+                    <a href="<?php URL_ROOT ?>polemicaltimeline.php?lang=ja_JP" class="menuLink" >
                         <img src='<?php echo(URL_ROOT); ?>images/flag_jp.gif'<?php if($actual!="ja_JP"){echo("style='opacity: .5;'"); } ?> />
                         <?php print $translate->_("Japonais"); ?>
                     </a></li>
                 <li>
-                    <a href="<?php URL_ROOT ?>client.php?lang=fr" class="menuLink">
+                    <a href="<?php URL_ROOT ?>polemicaltimeline.php?lang=fr" class="menuLink">
                         <img src='<?php echo(URL_ROOT); ?>images/flag_fr.gif' <?php if($actual!="fr"){echo("style='opacity: .5;'"); } ?> />
                         <?php print $translate->_("Français"); ?>
                     </a>
                 </li>
                 <li>
-                    <a href="<?php URL_ROOT ?>client.php?lang=en" class="menuLink">
+                    <a href="<?php URL_ROOT ?>polemicaltimeline.php?lang=en" class="menuLink">
                         <img src='<?php echo(URL_ROOT); ?>images/flag_en.gif' <?php if($actual!="en"){echo("style='opacity: .5;'"); } ?> />
                         <?php print $translate->_("Anglais"); ?>
                     </a>
@@ -268,8 +360,8 @@
             </div>
         </div>
 
-	<!-- EXPLICATION  -->
-	<div id="mdpgauche">
+    <!-- EXPLICATION  -->
+    <div id="mdpgauche">
         <ul class="accordeon">
             <li class="acctitre">
                 <h3><?php echo($translate->_('config__title')); ?></h3>
@@ -277,6 +369,8 @@
             <li class="acctexte mdpacclimited">
                 <p><?php echo($translate->_('config__description')); ?></p>
             </li>
+
+<?php if ($protocol_level > 1): ?>
             <li class="acctitre">
                 <h3>Liste des Annotations</h3>
             </li>
@@ -289,16 +383,17 @@
             <li class="acctexte mdpacclimited" style="display: none;">
                 <div id="TagcloudContainer"></div>
             </li>
+<?php endif; ?>
         </ul>
-		
-	  </div>
+        
+      </div>
 
 
 
 
-	  <div id="mdpdroite" >
-		<div id="LdtPlayer"></div>
-	  </div>
+      <div id="mdpdroite" >
+        <div id="LdtPlayer"></div>
+      </div>
 <script type="text/javascript">
     var _myPlayer = new IriSP.Metadataplayer(_config);
 </script>
@@ -306,10 +401,10 @@
  
       <div class="footer">
           
-		<hr>
-			<?php echo($translate->_('config__partenaires')); ?>
-	  </div>
-	
+        <hr>
+            <?php echo($translate->_('config__partenaires')); ?>
+      </div>
+
     </div>
 
   </body>