function getViewForTeacher($userID) { $academyID = getTeacherAcademie($userID); $school = getTeacherOneSchool($userID); $schoolType = $school->type; $schoolID = $school->ID; $schoolX = $school->X; $schoolY = $school->Y; $displaysCols = 2; $nbSchoolsDisplay = 9; $schools = getNearbySchools($academyID, $schoolType, $schoolX, $schoolY); $schools = array_slice($schools, 0, $nbSchoolsDisplay); $schoolNames = array_map(function ($s) { return getSchoolShortName($s->name); }, $schools); $schoolNames = array_filter($schoolNames, function ($x) { return trim($x) != ""; }); // todo: fixe link if ($schoolType == "Lycée") { $sUrlFullAction = "viewParticipLycees"; } else { if ($schoolType == "Collège") { $sUrlFullAction = "viewParticipColleges"; } else { $sUrlFullAction = "viewParticipAll"; } } $sUrlFull = "nearbySchools.php?action={$sUrlFullAction}&academie={$academyID}"; $sRows1 = ''; $sRows2 = ''; $nb1 = ($nbSchoolsDisplay + 1) / $displaysCols; $schoolNames1 = array_slice($schoolNames, 0, $nb1); $schoolNames2 = array_slice($schoolNames, $nb1); foreach ($schoolNames1 as $schoolName) { $sRows1 .= "<li> {$schoolName} </li>"; } foreach ($schoolNames2 as $schoolName) { $sRows2 .= "<li> {$schoolName} </li>"; } $sFullList = "<li>... <span style='font-size: small'><a href='{$sUrlFull}'>voir la liste complète</a></span></li>"; if ($displaysCols == 1) { $sRows1 .= $sFullList; } else { $sRows2 .= $sFullList; } $s = ''; // TODO: fixer ça une fois qu'on a choisit $width = 100 / $displaysCols; $s .= "<style>\n #spread-castor {\n background: #FFCCCC;\n border: 1px solid black;\n width: 21em;\n padding-left: 0.5em;\n padding-right: 0.2em;\n padding-bottom: 0.5em;\n }\n #spread-castor h2 {\n margin: 0.2em;\n margin-bottom: 0.4em;\n padding: 0em;\n font-size: 1.5em;\n font-weight: bold;\n text-align: center;\n }\n #spread-castor ul {\n margin-top: 0.2em;\n margin-bottom: 1em;\n padding-left: 1.5em;\n }\n #spread-castor-table td {\n vertical-align: top;\n width: {$width}%;\n }\n #spread-castor-email {\n width: 8em;\n }\n </style>"; $s .= "<div id='spread-castor'>\n <h2>Faites connaître le Castor<br> autour de vous !</h2>"; if ($academyID != -1) { $s .= "<div>Établissements n'ayant pas de coordinateur :</div>\n <table class='spread-castor-table'><tr>\n <td><ul>{$sRows1}</ul></td>\n <td><ul>{$sRows2}</ul></td>\n </tr></table>\n "; } $s .= "\n <div style='padding-bottom:0.2em'>Recommander le Castor de ma part à :</div>\n <div><i>e-mail</i> \n <input id='spread-castor-email' type='text'>\n <input id='spread-castor-send' type='button' value='Envoyer'></div>\n </div>\n "; return $s; }
function getNearbySchoolResults($userID) { $academyID = getTeacherAcademie($userID); $school = getTeacherOneSchool($userID); $schoolLevel = $school->type; $schoolID = $school->ID; $schoolX = $school->X; $schoolY = $school->Y; $nbSchools = 9; $schools = getNearbySchools($academyID, $schoolLevel, $schoolX, $schoolY, $nbSchools); $schoolNames = array_map(function ($s) { return getSchoolShortName($s->name); }, $schools); $schoolNames = array_filter($schoolNames, function ($x) { return trim($x) != ""; }); $level = ''; if ($schoolLevel == "Collège") { $level = "College"; } else { if ($schoolLevel == "Lycée") { $level = "Lycee"; } } return array('schoolNames' => $schoolNames, 'academyID' => $academyID, 'level' => $level); }