コード例 #1
0
function treatItemArray($list)
{
    $data = DatabaseData::getInstance();
    $high = 0;
    $low = 0;
    foreach ($list as $item) {
        $rate = $data->getItemVoteRate($item->id);
        if ($high == 0 || $low == 0) {
            $high = $rate;
            $low = $rate;
        } else {
            if ($rate > $high) {
                $high = $rate;
            }
            if ($rate < $low) {
                $low = $rate;
            }
        }
    }
    $gap = $high - $low;
    if ($gap == 0) {
        $gap = 1;
    }
    $i = 0;
    foreach ($list as $item) {
        $vote = getItemRate($item->id);
        //$perc = ($vote - $low) / $gap;
        $class = $vote >= 0 ? "item-plus" : "item-minus";
        // Mathieu : type de media
        $class_type_media = "type-media-" . getItemMediaType($item);
        $offset = $vote >= 0 ? 160 : 70;
        if (isset($_SESSION["visited"][(int) $item->id])) {
            $class .= "-visited";
        }
        global $question;
        //$position = ($offset - ($highest - $vote));
        $position = $offset - $vote * 10;
        if ($position < 30) {
            $position = 30;
        }
        //$itemTitle = utf8_encode($item->title);
        $itemTitle = $item->title;
        echo "<a href=\"mosaicMedia.php?itemId=" . $item->id . "\" class=\"item " . $class . "\" rel=\"" . $class_type_media . "\" ";
        echo "alt=\"" . $itemTitle . "\"";
        //echo "title=\"".$itemTitle." (vote:".$vote.")\"";
        echo "style=\"position:relative;margin-top:" . $position . "px;\">";
        echo getTextToSpeech($itemTitle);
        echo "</a>";
        $i++;
    }
}
コード例 #2
0
ファイル: api_class.php プロジェクト: ConcertUrbain/handicap
 public static function reloadDb()
 {
     $db = DatabaseData::getInstance(true);
     $db->reloadAll();
     return $db->queries;
 }
コード例 #3
0
ファイル: uploadVote.php プロジェクト: ConcertUrbain/handicap
<?php

include "includes.php";
?>

<?php 
$output = array();
$output["content"] = "";
//récup l'avis
$rate = $_POST["vote"];
//récup l'id de l'item
$itemId = $_POST["item-id"];
//$itemId = $_POST["itemId"];
$output["result"] += $itemId;
//echo "RATE = ".$rate;
//echo "ITEMID = ".$itemId;
//envoi l'avis à la db
$voteId = api__vote($itemId, $rate);
if (USE_CACHE) {
    DatabaseData::getInstance()->cache__reloadVotes($itemId);
    DatabaseData::cache__save();
}
//resultat
$output = "item id : " . $itemId . ", vote id : " . $voteId;
echo JSON_encode($output);
//displayThanks();
//DatabaseData::clean();
コード例 #4
0
ファイル: upload.php プロジェクト: ConcertUrbain/handicap
?>
	</head>
	
	<body>
<?php 
//echo "\nUPLOAD MEDIA";
//echo "<br />"; print_r($_FILES);
//echo "<br />"; print_r($_POST);
//MC-pmkRruaZ-V
$mediaId = "test-id";
if (isset($_POST["add-item"])) {
    $mediaId = api__sendFormFile();
    //echo "<br />[FILE] >> media id : ".$mediaId;
    $qstId = $_POST["question-id"];
    api__addItem($qstId, $_POST["title"], $_POST["description"], $mediaId);
    DatabaseData::getInstance()->cache__reloadItems($qstId);
} else {
    if (isset($_POST["record"])) {
        $_FILE = $_POST["bytes"];
        $mediaId = api__sendFormFile();
        //echo "<br />[RECORD] >> media id : ".$mediaId;
    } else {
        //echo "<br />[DEFAULT]";
        $text = "";
        $mediaId = -1;
        //TEXT
        if (!empty($_POST["temoin-text"])) {
            $text = $_POST["temoin-text"];
            $_SESSION[UPLOAD]["temoin-text"] = $text;
            //echo "<br />[RESULT] Got text from form";
        } else {
コード例 #5
0
ファイル: cache.php プロジェクト: ConcertUrbain/handicap
<?php 
include "includes.php";
/*
  # Le cache est chargé au lancement du site en variable de SESSION
  # Le cache a une unique ID qui permet de savoir si la session a la bonne version du cache
  # On compare donc l'id avec celle en session pour savoir si il faut reload le contenu
*/
?>
<html>
  <head><title>CACHE MANAGER</title></head>
  <body>
    <?php 
$filePath = CACHE_FOLDER . CACHE_FILE . "." . CACHE_FILE_EXT;
//echo "<br/>Opening cache file (".$filePath.")";
$fileContent = file_get_contents($filePath);
//echo "<br/>Decode file to json";
//echo "FILE=".$fileContent;
$data = Zend_Json_Decoder::decode($fileContent);
$db = DatabaseData::getInstance();
echo "<br />CACHE ID = " . $data["uniq"];
echo "<br/>SESSION ID = " . $db->uniq;
if ($data["uniq"] != $db->uniq) {
    echo "<div style=\"color:#a00;\">Cache is OUT OF DATE</div>";
}
echo "<div style=\"color:#0a0;\">Cache is loaded</div>";
echo "<br/>";
echo "<div><b>CONTENT DATA</b></div>";
print_r($db);
?>
  </body>
</html>
コード例 #6
0
ファイル: tools.php プロジェクト: ConcertUrbain/handicap
function clearMem()
{
    unset($_SESSION[API_ID]);
    DatabaseData::clean();
}
コード例 #7
0
<?php

ini_set('display_errors', '1');
include "includes.php";
?>
<html>
  <head>CACHE RELOADER</head>
  <body>
    <?php 
//create cache file
DatabaseData::cache__save(true);
?>
  </body>
</html>