Пример #1
0
 public function si($name)
 {
     $si = Si::get($name);
     if (!$si) {
         error_log(caller_landmark(2) . ": setting {$name}: missing information");
     }
     return $si;
 }
Пример #2
0
<br/>
<h3 class="title">Presentation</h3>


<?php 
// Calling the data of the model.
$simodel = new Si();
$json = $simodel->getAll('space_invaders.json');
?>



<div id="space-container">
<?php 
foreach ($json as $key => $value) {
    ?>
    <div class="card">
        <div class="card-head">
            <img src="<?php 
    echo $urlPrefix . REL_IMG_FOLDER . 'si/' . $value['img'];
    ?>
" />
            <span><?php 
    echo $value['name'];
    ?>
</span>
        </div>
        <div class="description">
            <p><?php 
    echo $value['description'];
    ?>
 function parse($sv, $si)
 {
     global $Conf;
     if (!$sv->newv("resp_active")) {
         return false;
     }
     $old_roundnames = $Conf->resp_round_list();
     $roundnames = array(1);
     $roundnames_set = array();
     if (isset($sv->req["resp_roundname"])) {
         $rname = trim(get_s($sv->req, "resp_roundname"));
         if ($rname === "" || $rname === "none" || $rname === "1") {
             /* do nothing */
         } else {
             if ($rerror = Conf::resp_round_name_error($rname)) {
                 $sv->set_error("resp_roundname", $rerror);
             } else {
                 $roundnames[0] = $rname;
                 $roundnames_set[strtolower($rname)] = 0;
             }
         }
     }
     for ($i = 1; isset($sv->req["resp_roundname_{$i}"]); ++$i) {
         $rname = trim(get_s($sv->req, "resp_roundname_{$i}"));
         if ($rname === "" && get($old_roundnames, $i)) {
             $rname = $old_roundnames[$i];
         }
         if ($rname === "") {
             continue;
         } else {
             if ($rerror = Conf::resp_round_name_error($rname)) {
                 $sv->set_error("resp_roundname_{$i}", $rerror);
             } else {
                 if (get($roundnames_set, strtolower($rname)) !== null) {
                     $sv->set_error("resp_roundname_{$i}", "Response round name “" . htmlspecialchars($rname) . "” has already been used.");
                 } else {
                     $roundnames[] = $rname;
                     $roundnames_set[strtolower($rname)] = $i;
                 }
             }
         }
     }
     foreach ($roundnames_set as $i) {
         $isuf = $i ? "_{$i}" : "";
         if (($v = parse_value($sv, "resp_open{$isuf}", Si::get("resp_open"))) !== null) {
             $sv->save("resp_open{$isuf}", $v <= 0 ? null : $v);
         }
         if (($v = parse_value($sv, "resp_done{$isuf}", Si::get("resp_done"))) !== null) {
             $sv->save("resp_done{$isuf}", $v <= 0 ? null : $v);
         }
         if (($v = parse_value($sv, "resp_grace{$isuf}", Si::get("resp_grace"))) !== null) {
             $sv->save("resp_grace{$isuf}", $v <= 0 ? null : $v);
         }
         if (($v = parse_value($sv, "resp_words{$isuf}", Si::get("resp_words"))) !== null) {
             $sv->save("resp_words{$isuf}", $v < 0 ? null : $v);
         }
         if (($v = parse_value($sv, "msg.resp_instrux{$isuf}", Si::get("msg.resp_instrux"))) !== null) {
             $sv->save("msg.resp_instrux{$isuf}", $v);
         }
     }
     if (count($roundnames) > 1 || $roundnames[0] !== 1) {
         $sv->save("resp_rounds", join(" ", $roundnames));
     } else {
         $sv->save("resp_rounds", null);
     }
     return false;
 }
Пример #4
0
 function parse($sv, $si)
 {
     global $Conf;
     if (!isset($sv->req["rev_roundtag"])) {
         $sv->save("rev_roundtag", null);
         return false;
     }
     // round names
     $roundnames = $roundnames_set = array();
     $roundname0 = $round_deleted = null;
     for ($i = 0; isset($sv->req["roundname_{$i}"]) || isset($sv->req["deleteround_{$i}"]) || !$i; ++$i) {
         $rname = trim(get_s($sv->req, "roundname_{$i}"));
         if ($rname === "(no name)" || $rname === "default" || $rname === "unnamed") {
             $rname = "";
         }
         if ((get($sv->req, "deleteround_{$i}") || $rname === "") && $i) {
             $roundnames[] = ";";
             if (Dbl::fetch_ivalue("select reviewId from PaperReview where reviewRound={$i} limit 1")) {
                 $this->rev_round_changes[] = array($i, 0);
             }
             if ($round_deleted === null && !isset($sv->req["roundname_0"]) && $i < $sv->req["oldroundcount"]) {
                 $round_deleted = $i;
             }
         } else {
             if ($rname === "") {
                 /* ignore */
             } else {
                 if ($rerror = Conf::round_name_error($rname)) {
                     $sv->set_error("roundname_{$i}", $rerror);
                 } else {
                     if ($i == 0) {
                         $roundname0 = $rname;
                     } else {
                         if (get($roundnames_set, strtolower($rname))) {
                             $roundnames[] = ";";
                             $this->rev_round_changes[] = array($i, $roundnames_set[strtolower($rname)]);
                         } else {
                             $roundnames[] = $rname;
                             $roundnames_set[strtolower($rname)] = $i;
                         }
                     }
                 }
             }
         }
     }
     if ($roundname0 && !get($roundnames_set, strtolower($roundname0))) {
         $roundnames[] = $roundname0;
         $roundnames_set[strtolower($roundname0)] = count($roundnames);
     }
     if ($roundname0) {
         array_unshift($this->rev_round_changes, array(0, $roundnames_set[strtolower($roundname0)]));
     }
     // round deadlines
     foreach ($Conf->round_list() as $i => $rname) {
         $suffix = $i ? "_{$i}" : "";
         foreach (Conf::$review_deadlines as $k) {
             $sv->save($k . $suffix, null);
         }
     }
     $rtransform = array();
     if ($roundname0 && ($ri = $roundnames_set[strtolower($roundname0)]) && !isset($sv->req["pcrev_soft_{$ri}"])) {
         $rtransform[0] = "_{$ri}";
         $rtransform[$ri] = false;
     }
     if ($round_deleted) {
         $rtransform[$round_deleted] = "";
         if (!isset($rtransform[0])) {
             $rtransform[0] = false;
         }
     }
     for ($i = 0; $i < count($roundnames) + 1; ++$i) {
         if ((isset($rtransform[$i]) || ($i ? $roundnames[$i - 1] !== ";" : !isset($sv->req["deleteround_0"]))) && get($rtransform, $i) !== false) {
             $isuffix = $i ? "_{$i}" : "";
             if (($osuffix = get($rtransform, $i)) === null) {
                 $osuffix = $isuffix;
             }
             $ndeadlines = 0;
             foreach (Conf::$review_deadlines as $k) {
                 $v = parse_value($sv, $k . $isuffix, Si::get($k));
                 $sv->save($k . $osuffix, $v <= 0 ? null : $v);
                 $ndeadlines += $v > 0;
             }
             if ($ndeadlines == 0 && $osuffix) {
                 $sv->save("pcrev_soft{$osuffix}", 0);
             }
             foreach (array("pcrev_", "extrev_") as $k) {
                 list($soft, $hard) = ["{$k}soft{$osuffix}", "{$k}hard{$osuffix}"];
                 list($softv, $hardv) = [$sv->savedv($soft), $sv->savedv($hard)];
                 if (!$softv && $hardv) {
                     $sv->save($soft, $hardv);
                 } else {
                     if ($hardv && $softv > $hardv) {
                         $desc = $i ? ", round " . htmlspecialchars($roundnames[$i - 1]) : "";
                         $sv->set_error($soft, Si::get("{$k}soft", "short_description") . $desc . ": Must come before " . Si::get("{$k}hard", "short_description") . ".");
                         $sv->set_error($hard);
                     }
                 }
             }
         }
     }
     // round list (save after deadlines processing)
     while (count($roundnames) && $roundnames[count($roundnames) - 1] === ";") {
         array_pop($roundnames);
     }
     $sv->save("tag_rounds", join(" ", $roundnames));
     // default round
     $t = trim($sv->req["rev_roundtag"]);
     $sv->save("rev_roundtag", null);
     if (preg_match('/\\A(?:|\\(none\\)|\\(no name\\)|default|unnamed)\\z/i', $t)) {
         /* do nothing */
     } else {
         if ($t === "#0") {
             if ($roundname0) {
                 $sv->save("rev_roundtag", $roundname0);
             }
         } else {
             if (preg_match('/^#[1-9][0-9]*$/', $t)) {
                 $rname = get($roundnames, substr($t, 1) - 1);
                 if ($rname && $rname !== ";") {
                     $sv->save("rev_roundtag", $rname);
                 }
             } else {
                 if (!($rerror = Conf::round_name_error($t))) {
                     $sv->save("rev_roundtag", $t);
                 } else {
                     $sv->set_error("rev_roundtag", $rerror);
                 }
             }
         }
     }
     if (count($this->rev_round_changes)) {
         $sv->need_lock["PaperReview"] = true;
         return true;
     } else {
         return false;
     }
 }