diff -r e652022fd1f7 -r 03d2aa7b4967 web/common.php --- a/web/common.php Tue Nov 17 12:15:00 2015 +0100 +++ b/web/common.php Wed Nov 18 15:39:05 2015 +0100 @@ -17,7 +17,7 @@ $project_url_base = 'ldtplatform/ldt/cljson/id/'; -$C_default_rep = 'edito-1516-01-profil-collectif'; +$C_default_rep = 'museo-1516-01-inaugurale'; $C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0'; $C_event_props = __DIR__ . "/event_props"; $C_event_users = array('polemictweet' => 'polemictweet'.date('Y/m/d')); @@ -334,6 +334,143 @@ } +function get_default_annotations_config($config, $translate) { + + $default_protocol_annotations = array( + "1" => array( + "default" => array( + "colors" => array( + "h" => 0, + "s" => 0 + ) + ), + "positive" => array( + "display_name" => "++ | Agree", + "keywords" => "\\+\\+", + "colors" => array( + "h" => .3, + "s" => .65 + ), + "colors_class" => "twbGreen", + "polemic_cat" => 'OK', + "polemic_keywords" => array("++"), + "polemic_color" => "#1D973D" + ), + "negative" => array( + "display_name" => "-- | Disagree", + "keywords" => "\\-\\-", + "colors" => array( + "h" => 0, + "s" => .8 + ), + "colors_class" => "twbRed", + "polemic_cat" => 'KO', + "polemic_keywords" => array("--"), + "polemic_color" => "#CE0A15" + ), + "reference" => array( + "display_name" => "== | Reference", + "keywords" => "\\=\\=", + "colors" => array( + "h" => .16, + "s" => .8 + ), + "colors_class" => "twbYellow", + "polemic_cat" => 'REF', + "polemic_keywords" => array("==","http://"), + "polemic_color" => "#C5A62D" + ), + "question" => array( + "display_name" => "?? | Question", + "keywords" => "\\?\\?", + "colors" => array( + "h" => .6, + "s" => .8 + ), + "colors_class" => "twbBlue", + "polemic_cat" => 'Q', + "polemic_keywords" => array("?","??"), + "polemic_color" => "#036AAE" + ) + ), + "2" => array( + "default" => array( + "colors" => array( + "h" => 0, + "s" => 0 + ) + ), + "positive" => array( + "display_name" => "++ | Remember", + "keywords" => "\\+\\+", + "colors" => array( + "h" => .3, + "s" => .65 + ), + "colors_class" => "twbGreen", + "polemic_cat" => 'OK', + "polemic_keywords" => array("++"), + "polemic_color" => "#1D973D" + ), + "negative" => array( + "display_name" => "!! | Discuss", + "keywords" => "\\!\\!", + "colors" => array( + "h" => 0, + "s" => .8 + ), + "colors_class" => "twbRed", + "polemic_cat" => 'KO', + "polemic_keywords" => array("!!"), + "polemic_color" => "#CE0A15" + ), + "reference" => array( + "display_name" => "== | Reference", + "keywords" => "\\=\\=", + "colors" => array( + "h" => .16, + "s" => .8 + ), + "colors_class" => "twbYellow", + "polemic_cat" => 'REF', + "polemic_keywords" => array("==","http://"), + "polemic_color" => "#C5A62D" + ), + "question" => array( + "display_name" => "?? | Question", + "keywords" => "\\?\\?", + "colors" => array( + "h" => .6, + "s" => .8 + ), + "colors_class" => "twbBlue", + "polemic_cat" => 'Q', + "polemic_keywords" => array("?","??"), + "polemic_color" => "#036AAE" + ) + ) + ); + + $annotation_protocol_version = isset($config['annotation_protocol_version'])?$config['annotation_protocol_version']:"1"; + + $annotations_def = (isset($config['annotations']) && !empty($config['annotations']))?$config['annotations']:$default_protocol_annotations[$annotation_protocol_version]; + + $annotations = array(); + + foreach ($annotations_def as $annot_cat => $annot_def) { + if(isset($annot_def['display_name'])) { + $disp_parts = array_map('trim',explode("|",$annot_def['display_name'])); + if(count($disp_parts) > 1) { + $disp_parts[1] = $translate->_($disp_parts[1]); + } + $annot_def['display_name'] = implode(" | ", $disp_parts); + } + $annotations[$annot_cat] = $annot_def; + } + return $annotations; +} + + function get_archive_box($rep, $metadata, $url_root, $basepath, &$translate) { include("$basepath$rep/config.php"); @@ -429,6 +566,8 @@ global $realm; + $_SESSION['auth'] = 'polemictweet'; + return array('username'=>'polemictweet'); if (empty($_SERVER['PHP_AUTH_DIGEST']) || !isset($_SESSION['http_digest_nonce'])) { $_SESSION['http_digest_nonce'] = uniqid(); @@ -555,3 +694,50 @@ return strtolower($f); } + +function rgb2hex($rgb) { + $hex = "#"; + $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT); + $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT); + $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT); + + return $hex; // returns the hex value including the number sign (#) +} + +function hsl2Rgb( $h, $s, $l ){ + $r; + $g; + $b; + $c = ( 1 - abs( 2 * $l - 1 ) ) * $s; + $x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) ); + $m = $l - ( $c / 2 ); + if ( $h < 60 ) { + $r = $c; + $g = $x; + $b = 0; + } else if ( $h < 120 ) { + $r = $x; + $g = $c; + $b = 0; + } else if ( $h < 180 ) { + $r = 0; + $g = $c; + $b = $x; + } else if ( $h < 240 ) { + $r = 0; + $g = $x; + $b = $c; + } else if ( $h < 300 ) { + $r = $x; + $g = 0; + $b = $c; + } else { + $r = $c; + $g = 0; + $b = $x; + } + $r = ( $r + $m ) * 255; + $g = ( $g + $m ) * 255; + $b = ( $b + $m ) * 255; + return array( floor( $r ), floor( $g ), floor( $b ) ); +}