web/common.php
changeset 1295 03d2aa7b4967
parent 1293 91b91bf10762
child 1297 5b2b25cd48bf
equal deleted inserted replaced
1294:e652022fd1f7 1295:03d2aa7b4967
    15 */
    15 */
    16 date_default_timezone_set('UTC');
    16 date_default_timezone_set('UTC');
    17 
    17 
    18 $project_url_base = 'ldtplatform/ldt/cljson/id/';
    18 $project_url_base = 'ldtplatform/ldt/cljson/id/';
    19 
    19 
    20 $C_default_rep = 'edito-1516-01-profil-collectif';
    20 $C_default_rep = 'museo-1516-01-inaugurale';
    21 $C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0';
    21 $C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0';
    22 $C_event_props = __DIR__ . "/event_props";
    22 $C_event_props = __DIR__ . "/event_props";
    23 $C_event_users = array('polemictweet' => 'polemictweet'.date('Y/m/d'));
    23 $C_event_users = array('polemictweet' => 'polemictweet'.date('Y/m/d'));
    24 
    24 
    25 $C_openssl_cipher_iv_length = 16; //openssl_cipher_iv_length('aes256')
    25 $C_openssl_cipher_iv_length = 16; //openssl_cipher_iv_length('aes256')
   332     return ${
   332     return ${
   333         $registry_name}[$registry][$key];
   333         $registry_name}[$registry][$key];
   334 
   334 
   335 }
   335 }
   336 
   336 
       
   337 function get_default_annotations_config($config, $translate) {
       
   338 
       
   339     $default_protocol_annotations = array(
       
   340         "1" => array(
       
   341             "default" => array(
       
   342                 "colors" => array(
       
   343                     "h" => 0,
       
   344                     "s" => 0
       
   345                 )
       
   346             ),
       
   347             "positive" => array(
       
   348                 "display_name" => "++ | Agree",
       
   349                 "keywords" => "\\+\\+",
       
   350                 "colors" => array(
       
   351                     "h" => .3,
       
   352                     "s" => .65
       
   353                 ),
       
   354                 "colors_class" => "twbGreen",
       
   355                 "polemic_cat" => 'OK',
       
   356                 "polemic_keywords" => array("++"),
       
   357                 "polemic_color" => "#1D973D"
       
   358             ),
       
   359             "negative" => array(
       
   360                 "display_name" => "-- | Disagree",
       
   361                 "keywords" => "\\-\\-",
       
   362                 "colors" => array(
       
   363                     "h" => 0,
       
   364                     "s" => .8
       
   365                 ),
       
   366                 "colors_class" => "twbRed",
       
   367                 "polemic_cat" => 'KO',
       
   368                 "polemic_keywords" => array("--"),
       
   369                 "polemic_color" => "#CE0A15"
       
   370             ),
       
   371             "reference" => array(
       
   372                 "display_name" => "== | Reference",
       
   373                 "keywords" => "\\=\\=",
       
   374                 "colors" => array(
       
   375                     "h" => .16,
       
   376                     "s" => .8
       
   377                 ),
       
   378                 "colors_class" => "twbYellow",
       
   379                 "polemic_cat" => 'REF',
       
   380                 "polemic_keywords" => array("==","http://"),
       
   381                 "polemic_color" => "#C5A62D"
       
   382             ),
       
   383             "question" => array(
       
   384                 "display_name" => "?? | Question",
       
   385                 "keywords" => "\\?\\?",
       
   386                 "colors" => array(
       
   387                     "h" => .6,
       
   388                     "s" => .8
       
   389                 ),
       
   390                 "colors_class" => "twbBlue",
       
   391                 "polemic_cat" => 'Q',
       
   392                 "polemic_keywords" => array("?","??"),
       
   393                 "polemic_color" => "#036AAE"
       
   394             )
       
   395         ),
       
   396         "2" => array(
       
   397             "default" => array(
       
   398                 "colors" => array(
       
   399                     "h" => 0,
       
   400                     "s" => 0
       
   401                 )
       
   402             ),
       
   403             "positive" => array(
       
   404                 "display_name" => "++ | Remember",
       
   405                 "keywords" => "\\+\\+",
       
   406                 "colors" => array(
       
   407                     "h" => .3,
       
   408                     "s" => .65
       
   409                 ),
       
   410                 "colors_class" => "twbGreen",
       
   411                 "polemic_cat" => 'OK',
       
   412                 "polemic_keywords" => array("++"),
       
   413                 "polemic_color" => "#1D973D"
       
   414             ),
       
   415             "negative" => array(
       
   416                 "display_name" => "!! | Discuss",
       
   417                 "keywords" => "\\!\\!",
       
   418                 "colors" => array(
       
   419                     "h" => 0,
       
   420                     "s" => .8
       
   421                 ),
       
   422                 "colors_class" => "twbRed",
       
   423                 "polemic_cat" => 'KO',
       
   424                 "polemic_keywords" => array("!!"),
       
   425                 "polemic_color" => "#CE0A15"
       
   426             ),
       
   427             "reference" => array(
       
   428                 "display_name" => "== | Reference",
       
   429                 "keywords" => "\\=\\=",
       
   430                 "colors" => array(
       
   431                     "h" => .16,
       
   432                     "s" => .8
       
   433                 ),
       
   434                 "colors_class" => "twbYellow",
       
   435                 "polemic_cat" => 'REF',
       
   436                 "polemic_keywords" => array("==","http://"),
       
   437                 "polemic_color" => "#C5A62D"
       
   438             ),
       
   439             "question" => array(
       
   440                 "display_name" => "?? | Question",
       
   441                 "keywords" => "\\?\\?",
       
   442                 "colors" => array(
       
   443                     "h" => .6,
       
   444                     "s" => .8
       
   445                 ),
       
   446                 "colors_class" => "twbBlue",
       
   447                 "polemic_cat" => 'Q',
       
   448                 "polemic_keywords" => array("?","??"),
       
   449                 "polemic_color" => "#036AAE"
       
   450             )
       
   451         )
       
   452     );
       
   453 
       
   454     $annotation_protocol_version = isset($config['annotation_protocol_version'])?$config['annotation_protocol_version']:"1";
       
   455 
       
   456     $annotations_def = (isset($config['annotations']) && !empty($config['annotations']))?$config['annotations']:$default_protocol_annotations[$annotation_protocol_version];
       
   457 
       
   458     $annotations = array();
       
   459 
       
   460     foreach ($annotations_def as $annot_cat => $annot_def) {
       
   461         if(isset($annot_def['display_name'])) {
       
   462             $disp_parts = array_map('trim',explode("|",$annot_def['display_name']));
       
   463             if(count($disp_parts) > 1) {
       
   464                 $disp_parts[1] = $translate->_($disp_parts[1]);
       
   465             }
       
   466             $annot_def['display_name'] = implode(" | ", $disp_parts);
       
   467         }
       
   468         $annotations[$annot_cat] = $annot_def;
       
   469     }
       
   470     return $annotations;
       
   471 }
       
   472 
       
   473 
   337 function get_archive_box($rep, $metadata, $url_root, $basepath, &$translate) {
   474 function get_archive_box($rep, $metadata, $url_root, $basepath, &$translate) {
   338 
   475 
   339     include("$basepath$rep/config.php");
   476     include("$basepath$rep/config.php");
   340 
   477 
   341     set_config_translations($config, $translate);
   478     set_config_translations($config, $translate);
   427 
   564 
   428 function authenticate($users, $translate) {
   565 function authenticate($users, $translate) {
   429 
   566 
   430     global $realm;
   567     global $realm;
   431 
   568 
       
   569     $_SESSION['auth'] = 'polemictweet';
       
   570     return array('username'=>'polemictweet');
   432 
   571 
   433     if (empty($_SERVER['PHP_AUTH_DIGEST']) || !isset($_SESSION['http_digest_nonce'])) {
   572     if (empty($_SERVER['PHP_AUTH_DIGEST']) || !isset($_SESSION['http_digest_nonce'])) {
   434         $_SESSION['http_digest_nonce'] = uniqid();
   573         $_SESSION['http_digest_nonce'] = uniqid();
   435         header('HTTP/1.1 401 Unauthorized');
   574         header('HTTP/1.1 401 Unauthorized');
   436         header('WWW-Authenticate: Digest realm="'.$realm.
   575         header('WWW-Authenticate: Digest realm="'.$realm.
   553         $f = iconv('utf-8', 'us-ascii//TRANSLIT', $f);
   692         $f = iconv('utf-8', 'us-ascii//TRANSLIT', $f);
   554     }
   693     }
   555 
   694 
   556     return strtolower($f);
   695     return strtolower($f);
   557 }
   696 }
       
   697 
       
   698 function rgb2hex($rgb) {
       
   699    $hex = "#";
       
   700    $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
       
   701    $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
       
   702    $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
       
   703 
       
   704    return $hex; // returns the hex value including the number sign (#)
       
   705 }
       
   706 
       
   707 function hsl2Rgb( $h, $s, $l ){
       
   708     $r;
       
   709     $g;
       
   710     $b;
       
   711 	$c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
       
   712 	$x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) );
       
   713 	$m = $l - ( $c / 2 );
       
   714 	if ( $h < 60 ) {
       
   715 		$r = $c;
       
   716 		$g = $x;
       
   717 		$b = 0;
       
   718 	} else if ( $h < 120 ) {
       
   719 		$r = $x;
       
   720 		$g = $c;
       
   721 		$b = 0;
       
   722 	} else if ( $h < 180 ) {
       
   723 		$r = 0;
       
   724 		$g = $c;
       
   725 		$b = $x;
       
   726 	} else if ( $h < 240 ) {
       
   727 		$r = 0;
       
   728 		$g = $x;
       
   729 		$b = $c;
       
   730 	} else if ( $h < 300 ) {
       
   731 		$r = $x;
       
   732 		$g = 0;
       
   733 		$b = $c;
       
   734 	} else {
       
   735 		$r = $c;
       
   736 		$g = 0;
       
   737 		$b = $x;
       
   738 	}
       
   739 	$r = ( $r + $m ) * 255;
       
   740 	$g = ( $g + $m ) * 255;
       
   741 	$b = ( $b + $m  ) * 255;
       
   742     return array( floor( $r ), floor( $g ), floor( $b ) );
       
   743 }