-
Notifications
You must be signed in to change notification settings - Fork 0
/
mosaicContent.php.old
251 lines (170 loc) · 6.64 KB
/
mosaicContent.php.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<div id="menu">
<div id="debat" class="pres-link question-number-container" alt="pres-questions">
<a class="menu-presentation" href="?cat=presentation-debat"><span class="menu-debat-rollover">les autres questions</span></a>
</div>
<div id="intro" class="pres-link question-number-container" alt="pres-intro">
<a href="aide.php">
</a>
</div>
<div class="clear"></div>
<div id="menu-popup-border">
<div id="menu-popup"></div>
</div>
</div>
<div id="mosaic">
<?php
//print_r($_SESSION["visited"]);
$moreAlt = "en savoir plus sur la question";
$moreUrl = "mosaicQuestion.php";
$label = $question["content"];
if (isset($_GET['page']))
{
$pageCourante = addslashes($_GET['page']);
}
else
{
$pageCourante = 0;
}
?>
<?php
$DIRECT_LOAD = true;
if ($DIRECT_LOAD) {
//ITEMS
//$data->reload_question($qstId);
//echo "QUESTION ID ? ".$qstId;
// $items = getMosaicItems($qstId);
$question = getCurrentQuestion();
$qstId = $question["id"];
$items = getMosaicItems($qstId);
//s"paration des items dans deux cat"gories (+ et -)
$items_plus = array();
$items_minus = array();
foreach($items as $item) {
if(!$item->isValid)
continue;
if(getItemRate($item) >= 0) array_push($items_plus, $item);
else array_push($items_minus, $item);
}
//echo "PLUS =".count($items_plus);echo "MINUS =".count($items_minus);
}
?>
<div id="items-frame-border">
<div id="items-frame">
<!-- REPLACED BY AJAX -->
<div id="items-positive">
<div style="position:relative"><?php if($DIRECT_LOAD) $noPageMaxPlus = treatItemArray($items_plus, $pageCourante); ?></div>
</div>
<div id="items-negative">
<div style="position:relative"><?php if($DIRECT_LOAD) $noPageMaxMinus = treatItemArray($items_minus, $pageCourante); ?></div>
</div>
<!-- ### -->
</div>
</div>
<?php
$nbPages = max($noPageMaxPlus, $noPageMaxMinus) + 1;
if ($nbPages > 1)
{
$divNoPages = "";
for ($i = 0; $i < $nbPages; $i++) {
$no = $i + 1;
$classNoPageActive = $i == $pageCourante ? "nopage_actif" : "";
$divNoPages .= '<span id="nopage' . $i . '" class="nopage ' . $classNoPageActive . '" ><a href="#">' . $no . '...</a></span>';
}
?>
<div id="items_navigation_pagination">
<div id="items_navigation_precedent_suite">
<span id="pagePrecedente"><a href="#"><img src="images/mosaic/previous.png" /></a></span>
<span id="nopages"><?php echo $divNoPages; ?></span>
<span id="pageSuivante"><a href="#"><img src="images/mosaic/next.png" /></a></span>
<span id="legende" class="page0" data-id="<?php echo $nbPages ?>"></span>
</div>
</div>
<?php
}
?>
<!-- CADRE BLANC CENTRE PAGE QUESTION -->
<a class="cursor" id="question-frame" href="<?php echo $moreUrl."?id=".$question["id"]; ?>">
<img id="question-icon" class="question-icon-<?php echo $question["id"]; ?>" src='images/question_icons/qst-<?php echo $question["id"]; ?>.png' />
<div id="question-label" title="<?php echo $moreAlt; ?>">
<?php echo $label; ?>
</div>
<div class="clear"></div>
</a>
<a id="plus-add" href="formRecord.php?qstId=<?php echo $qstId; ?>" title="je témoigne, je propose"></a>
<!-- popups resources -->
<div class="popup-border">
<div class="popup">Nadia : Les transports sont dangereux.</div>
</div>
<div id="popup-question">
<!--
<div id="popup-question-val"></div>
<div id="popup-question-media" style="background-image:url('images/question_makatons/qst-<?php echo $qstId; ?>.jpg');"></div>
-->
<div id="popup-question-talker"><a class="cursor" href="<?php echo $moreUrl."?id=".$question["id"]; ?>"></a></div>
<div class="clear"></div>
</div>
<!-- POPUP TOOL -->
<div id="popup-info"></div>
</div>
<?php
function treatItemArray($list, $pageCourante){
$high = 0;
$low = 0;
for($i = 0; $i < count($list); $i++){
$item = $list[$i];
$rate = getItemRate($item);
$list[$i]->rate = $rate;
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;
$left = 0;
$pageNo = 0;
// Nombre de témoignages par page (en X)
$nbTemoignagesMax = 22;
foreach($list as $item) {
// PAGE :
$pageNo = floor($i / $nbTemoignagesMax);
// LEFT : (on repart à x = 0 à chaque page)
$left = ($i % $nbTemoignagesMax) * 35;
// TOP : (on place le plus près du centre vertical, et on retire un nombre de pixels par vote)
$vote = $item->rate;
$limit = 10; // limit haute et basse du nombre de vote qui amène le pouce au bord
// Pour tester les positions minimales
//$vote = ($vote >= 0) ? 0 : -1;
// Pour tester les positions extremes
//$vote = ($vote >= 0) ? $limit : -$limit;
//$perc = ($vote - $low) / $gap;
$class = ($vote >= 0) ? "item-plus" : "item-minus";
// Mathieu : type de media
$class_type_media = "type-media-".getItemMediaType($item);
// 140 : 70 rapproche les pouces du centre, 200 : 100 éloigne les pouces du centre
$offset = ($vote >= 0) ? 170 : 20; // 0 c'est soit le top de la zone verte, soit le top de la zone rouge en fonction du Math.abs()
if(isset($_SESSION["visited"][(int)$item->id])) $class .= "-visited";
//$position = ($offset - ($highest - $vote));
// RQ DENIS : les placements en Y n'étant pas proportionnels (?), on limite le vote pour le calcul de la position en Y...
$sign = ($vote >= 0) ? 1 : -1;
if ($vote > $limit * $sign) $vote = $limit * $sign; // position maximum en hauteur
$position = $offset - ($vote * 14);
// ??? if ($position < 40) $position = 40; // position maximum en hauteur
//$itemTitle = utf8_encode($item->title);
// On masque les pages suivantes
$displayClass = $pageNo != $pageCourante ? "item_hidden" : "";
$itemTitle = $item->title;
echo '<a href="mosaicMedia.php?itemId='.$item->id.'&page='.$pageNo.'" class="' . $displayClass . ' item ' . $class . ' page'. $pageNo . '" rel="'.$class_type_media.'"';
// Titre du témoignage pour la bulle de mouse hover
if(strlen($itemTitle) > 0) echo ' alt="'.$itemTitle.'"';
//echo "title=\"".$itemTitle." (vote:".$vote.")\"";
echo ' style="position:absolute;left:'.$left.'px;top:'.$position.'px;" rel="position:'.$position.', vote:'.$vote.'"></a>';
$i++;
}
return $pageNo;
}
?>