Exemple #1
0
        $b = 1;
        switch ($i) {
            case 0:
                list($r, $g, $b) = array($v, $k, $m);
                break;
            case 1:
                list($r, $g, $b) = array($n, $v, $m);
                break;
            case 2:
                list($r, $g, $b) = array($m, $v, $k);
                break;
            case 3:
                list($r, $g, $b) = array($m, $n, $v);
                break;
            case 4:
                list($r, $g, $b) = array($k, $m, $v);
                break;
            case 5:
            case 6:
                list($r, $g, $b) = array($v, $m, $n);
                break;
        }
        return array('r' => floor($r * 255), 'g' => floor($g * 255), 'b' => floor($b * 255));
    }
}
/*
 * h=hueRange
 * s=saturationRange : bounds[0][0] ; bounds[-][0]
 */
RandomColor::$dictionary = array('monochrome' => array('bounds' => array(array(0, 0), array(100, 0)), 'h' => NULL, 's' => array(0, 100)), 'red' => array('bounds' => array(array(20, 100), array(30, 92), array(40, 89), array(50, 85), array(60, 78), array(70, 70), array(80, 60), array(90, 55), array(100, 50)), 'h' => array(-26, 18), 's' => array(20, 100)), 'orange' => array('bounds' => array(array(20, 100), array(30, 93), array(40, 88), array(50, 86), array(60, 85), array(70, 70), array(100, 70)), 'h' => array(19, 46), 's' => array(20, 100)), 'yellow' => array('bounds' => array(array(25, 100), array(40, 94), array(50, 89), array(60, 86), array(70, 84), array(80, 82), array(90, 80), array(100, 75)), 'h' => array(47, 62), 's' => array(25, 100)), 'green' => array('bounds' => array(array(30, 100), array(40, 90), array(50, 85), array(60, 81), array(70, 74), array(80, 64), array(90, 50), array(100, 40)), 'h' => array(63, 178), 's' => array(30, 100)), 'blue' => array('bounds' => array(array(20, 100), array(30, 86), array(40, 80), array(50, 74), array(60, 60), array(70, 52), array(80, 44), array(90, 39), array(100, 35)), 'h' => array(179, 257), 's' => array(20, 100)), 'purple' => array('bounds' => array(array(20, 100), array(30, 87), array(40, 79), array(50, 70), array(60, 65), array(70, 59), array(80, 52), array(90, 45), array(100, 42)), 'h' => array(258, 282), 's' => array(20, 100)), 'pink' => array('bounds' => array(array(20, 100), array(30, 90), array(40, 86), array(60, 84), array(80, 80), array(90, 75), array(100, 73)), 'h' => array(283, 334), 's' => array(20, 100)));
Exemple #2
0
 public static function initData()
 {
     global $file_db;
     /**************************************
      * Creer tables                        *
      **************************************/
     // Table des boulettes
     $file_db->exec("CREATE TABLE IF NOT EXISTS boulette (\n\t\t                id_boulette INTEGER PRIMARY KEY AUTOINCREMENT, \n\t\t                id_categorie INTEGER,\n\t\t                timestamp  DATETIME DEFAULT (strftime('%s', 'now')),\n                        archive INTEGER DEFAULT 0)");
     // Table des phrases
     $file_db->exec("CREATE TABLE IF NOT EXISTS phrase (\n\t\t                id_phrase INTEGER PRIMARY KEY AUTOINCREMENT, \n\t\t                id_collaborateur INTEGER, \n\t\t                id_boulette INTEGER,\n\t\t                message TEXT)");
     // Table des phrases
     $file_db->exec("CREATE TABLE IF NOT EXISTS categorie (\n\t\t                id_categorie INTEGER PRIMARY KEY AUTOINCREMENT, \n\t\t                nom TEXT)");
     // Table des collaborateurs
     $file_db->exec("CREATE TABLE IF NOT EXISTS collaborateur (\n\t\t                id_collaborateur INTEGER PRIMARY KEY AUTOINCREMENT, \n\t\t                prenom TEXT, \n\t\t                nom TEXT,\n\t\t                couleur TEXT)");
     /**************************************
      * COLLABORATEURS                      *
      **************************************/
     $collaborateurs = array(array('prenom' => 'Charles', 'nom' => 'Dupont'), array('prenom' => 'Jean', 'nom' => 'Miche'), array('prenom' => 'Test', 'nom' => 'Dupont'), array('prenom' => 'Sébastien', 'nom' => 'Heuzé'));
     $insert = "INSERT INTO collaborateur (prenom, nom, couleur) \n\t\t            VALUES (:prenom, :nom, :couleur)";
     $stmt = $file_db->prepare($insert);
     $stmt->bindParam(':prenom', $prenom);
     $stmt->bindParam(':nom', $nom);
     $stmt->bindParam(':couleur', $couleur);
     //On insère tout
     foreach ($collaborateurs as $c) {
         // Set values to bound variables
         $prenom = $c['prenom'];
         $nom = $c['nom'];
         $couleur = RandomColor::one();
         // Execute statement
         $stmt->execute();
     }
     /**************************************
      * CATEGORIES                          *
      **************************************/
     $categories = array(array('id_categorie' => 0, 'nom' => 'Non Classée'), array('id_categorie' => 1, 'nom' => 'Non Sens'), array('id_categorie' => 2, 'nom' => 'Sexuelle'), array('id_categorie' => 3, 'nom' => 'Pensées et Réflexions'), array('id_categorie' => 4, 'nom' => 'Techno-blagues'), array('id_categorie' => 5, 'nom' => 'Retourne à l\'école'));
     $insert = "INSERT INTO categorie (id_categorie, nom) \n\t\t            VALUES (:id_categorie, :nom)";
     $stmt = $file_db->prepare($insert);
     $stmt->bindParam(':nom', $nom);
     $stmt->bindParam(':id_categorie', $id_categorie);
     foreach ($categories as $cat) {
         // Set values to bound variables
         $nom = $cat['nom'];
         $id_categorie = $cat['id_categorie'];
         // Execute statement
         $stmt->execute();
     }
     /**************************************
      * BOULETTES                           *
      **************************************/
     $boulettes = array(array('phrases' => array(array('id_collaborateur' => 1, 'message' => 'Le Beschrelle ça s\'écrit comment ? Je connaissais pas comme site')), 'timestamp' => 1327301464, 'id_categorie' => 5), array('phrases' => array(array('id_collaborateur' => 2, 'message' => '(à Gildas) Tu vas te marier ? Encore avec la même personne ?')), 'timestamp' => 1327301464, 'id_categorie' => 3), array('phrases' => array(array('id_collaborateur' => 1, 'message' => '(debout) Je voulais faire un truc… ah oui m\'assoir !')), 'timestamp' => 1327301464, 'id_categorie' => 1), array('phrases' => array(array('id_collaborateur' => 2, 'message' => 'Ha ! Désolé elle est pas open, Audrey'), array('id_collaborateur' => 4, 'message' => 'Audrey elle est pas open ?'), array('id_collaborateur' => 2, 'message' => 'Ha ! Non Audrey elle est pas open !')), 'timestamp' => 1327301464, 'id_categorie' => 1), array('phrases' => array(array('id_collaborateur' => 3, 'message' => 'Il devrait passer avant tout à l\'heure. Avant tout à l\'heure c\'est quelque part entre maintenant et plus tard')), 'timestamp' => 1327301464, 'id_categorie' => 3));
     $insert_b = "INSERT INTO boulette (id_categorie) values (:id_categorie)";
     $insert_p = "INSERT INTO phrase (id_collaborateur, message, id_boulette) \n\t\t            VALUES (:id_collaborateur, :message, :id_boulette)";
     $stmt_b = $file_db->prepare($insert_b);
     $stmt_b->bindParam(':id_categorie', $id_categorie);
     $stmt_p = $file_db->prepare($insert_p);
     $stmt_p->bindParam(':id_collaborateur', $id_collaborateur);
     $stmt_p->bindParam(':message', $message);
     $stmt_p->bindParam(':id_boulette', $id_boulette);
     //On insère tout
     foreach ($boulettes as $b) {
         $id_categorie = $b['id_categorie'];
         $stmt_b->execute();
         $id_boulette = $file_db->lastInsertId();
         foreach ($b['phrases'] as $p) {
             $id_collaborateur = $p['id_collaborateur'];
             $message = $p['message'];
             // Execute statement
             $stmt_p->execute();
             $id_phrase = $file_db->lastInsertId();
         }
     }
 }
Exemple #3
0
    $db->groupBy('Country.id');
    $data = $db->get('Country_point', null, $column);
}
foreach ($data as $country) {
    ?>

        poly.createPolygon(map, {
            country: ["<?php 
    echo $country['name'];
    ?>
"],
            strokeColor: "#A52A2A",
            strokeOpacity: 0.1,
            strokeWeight: 2,
            fillColor: "<?php 
    echo RandomColor::one();
    ?>
",
            fillOpacity: 0.8,
            hoverFillColor: "#FF0000",
            hoverFillOpacity: 0.1,
            hoverStrokeColor: "#000",
            hoverStrokeWeight: 2,
            hoverStrokeOpacity: 0.5,
            onClickType: 1,
            onClickValue: {
                url: "/<?php 
    echo $country['name'];
    ?>
", popup: "<h3>HTML</h3>", callback: function () {
                    alert('test')
Exemple #4
0
<?php

$initial_data = array();
$options = array();
if (isset($_POST['prenom'])) {
    $update_query = "INSERT INTO `collaborateur` (`prenom`,`nom`,`couleur`) VALUES (?,?,?)";
    $qry = $file_db->prepare($update_query);
    $qry->execute(array($_POST['prenom'], $_POST['nom'], RandomColor::one()));
    $_SESSION['message'] = array("type" => "success", "message" => "collaborateur crée!");
    header('Location: ?page=collaborateur&action=list');
}
echo $twig->render('collaborateur/create.html.twig', array());
Exemple #5
0
 public function randomColor()
 {
     $color = RandomColor::one(array('format' => 'rgbCss'));
     return str_replace(['rgb', '(', ')'], '', $color);
 }