Skip to content
Permalink
Browse files

ReviewForm internals: Rely on forder more.

It only has displayed fields.
  • Loading branch information...
kohler committed Aug 22, 2019
1 parent 2ccc4f7 commit 7264fdca1f31029cae7b8f20143f58cf82e396be
Showing with 74 additions and 63 deletions.
  1. +5 −13 graph.php
  2. +3 −4 search.php
  3. +5 −6 src/conference.php
  4. +3 −2 src/help/h_keywords.php
  5. +1 −1 src/listactions/la_getreviewcsv.php
  6. +57 −37 src/review.php
@@ -76,20 +76,12 @@ function formulas_qrow($i, $q, $s, $status) {
if ($Graph == "formula") {
// derive a sample graph
if (!isset($Qreq->x) || !isset($Qreq->y)) {
$all_review_fields = $Conf->all_review_fields();
$field1 = get($all_review_fields, "overAllMerit");
$field2 = null;
foreach ($all_review_fields as $f) {
if ($f->has_options && !$field1)
$field1 = $f;
else if ($f->has_options && !$field2 && $field1 != $f)
$field2 = $f;
}
$fields = $Conf->review_form()->example_fields($Me);
unset($Qreq->x, $Qreq->y);
if ($field1)
$Qreq->y = "avg(" . $field1->search_keyword() . ")";
if ($field1 && $field2)
$Qreq->x = "avg(" . $field2->search_keyword() . ")";
if (count($fields) > 0)
$Qreq->y = "avg(" . $fields[0]->search_keyword() . ")";
if (count($fields) > 1)
$Qreq->x = "avg(" . $fields[1]->search_keyword() . ")";
else
$Qreq->x = "pid";
}
@@ -270,11 +270,10 @@ function checkbox_item($column, $type, $title, $options = []) {
$display_options->checkbox_item(20, "shepherd", "Shepherds");
// Scores group
$rf = $Conf->review_form();
$revViewScore = $Me->permissive_view_score_bound($Qreq->t == "a");
foreach ($rf->forder as $f)
if ($f->view_score > $revViewScore && $f->has_options)
foreach ($Conf->review_form()->user_visible_fields($Me) as $f) {
if ($f->has_options)
$display_options->checkbox_item(30, $f->search_keyword(), $f->name_html);
}
if (!empty($display_options->items[30])) {
$display_options->set_header(30, "<strong>Scores:</strong>");
$sortitem = '<div class="mt-2">Sort by: &nbsp;'
@@ -1106,12 +1106,13 @@ function abbrev_matcher() {
$this->_abbrev_matcher = new AbbreviationMatcher;
// XXX exposes invisible paper options, review fields
$this->paper_opts->populate_abbrev_matcher($this->_abbrev_matcher);
foreach ($this->all_review_fields() as $f)
if ($f->displayed)
$this->_abbrev_matcher->add($f->name, $f, self::FSRCH_REVIEW);
foreach ($this->named_formulas() as $f)
foreach ($this->all_review_fields() as $f) {
$this->_abbrev_matcher->add($f->name, $f, self::FSRCH_REVIEW);
}
foreach ($this->named_formulas() as $f) {
if ($f->name)
$this->_abbrev_matcher->add($f->name, $f, self::FSRCH_FORMULA);
}
}
return $this->_abbrev_matcher;
}
@@ -1137,11 +1138,9 @@ function review_form() {
function all_review_fields() {
return $this->review_form()->all_fields();
}
function review_field($fid) {
return $this->review_form()->field($fid);
}
function find_review_field($text) {
return $this->abbrev_matcher()->find1($text, self::FSRCH_REVIEW);
}
@@ -177,9 +177,10 @@ static function render($hth) {
echo $hth->search_trow("dec:none", "decision unspecified");
// find names of review fields to demonstrate syntax
$farr = array(array(), array());
foreach ($hth->conf->all_review_fields() as $f)
$farr = [[], []];
foreach ($hth->conf->review_form()->user_visible_fields($hth->user) as $f) {
$farr[$f->has_options ? 0 : 1][] = $f;
}
if (!empty($farr[0]) || !empty($farr[1]))
echo $hth->tgroup("Review fields");
if (count($farr[0])) {
@@ -40,7 +40,7 @@ function run(Contact $user, $qreq, $ssel) {
$text["email"] = $rrow->email;
$text["reviewername"] = Text::name_text($rrow);
}
foreach ($rf->all_visible_fields($viewer, $prow, $rrow) as $f) {
foreach ($rf->paper_visible_fields($viewer, $prow, $rrow) as $f) {
$fields[$f->id] = true;
$text[$f->name] = $f->unparse_value(get($rrow, $f->id), ReviewField::VALUE_TRIM);
}
@@ -99,8 +99,9 @@ function assign($j) {
if (get($j, "position")) {
$this->displayed = true;
$this->display_order = $j->position;
} else
} else {
$this->displayed = $this->display_order = false;
}
$this->round_mask = get_i($j, "round_mask");
if ($this->has_options) {
$options = get($j, "options") ? : array();
@@ -188,7 +189,8 @@ function is_round_visible(ReviewInfo $rrow = null) {
}
function include_word_count() {
return $this->displayed && !$this->has_options
return $this->displayed
&& !$this->has_options
&& $this->view_score >= VIEWSCORE_AUTHORDEC;
}
@@ -411,8 +413,8 @@ class ReviewForm implements JsonSerializable {
const NOTIFICATION_DELAY = 10800;
public $conf;
public $fmap = array();
public $forder;
public $fmap; // all fields, whether or not displayed, key id
public $forder; // displayed fields in display order, key id
public $fieldName;
private $_stopwords;
@@ -445,6 +447,7 @@ static function fmap_compare($a, $b) {
function __construct($rfj, Conf $conf) {
$this->conf = $conf;
$this->fmap = $this->fieldName = $this->forder = [];
// parse JSON
if (!$rfj)
@@ -457,39 +460,57 @@ function __construct($rfj, Conf $conf) {
"t02":{"name":"Comments to authors","position":4,"visibility":"au"},
"t03":{"name":"Comments to PC","position":5,"visibility":"pc"}}');
foreach ($rfj as $fid => $j)
foreach ($rfj as $fid => $j) {
if (($finfo = ReviewInfo::field_info($fid, $conf))) {
$f = new ReviewField($finfo, $conf);
$this->fmap[$f->id] = $f;
$f->assign($j);
}
}
uasort($this->fmap, "ReviewForm::fmap_compare");
// assign field order
uasort($this->fmap, "ReviewForm::fmap_compare");
$this->fieldName = $this->forder = [];
$do = 0;
foreach ($this->fmap as $f)
foreach ($this->fmap as $f) {
if ($f->displayed) {
$this->fieldName[strtolower($f->name)] = $f->id;
$f->display_order = ++$do;
$this->forder[$f->id] = $f;
}
}
}
function field($fid) {
return get($this->forder, $fid, null);
}
function all_fields() {
return $this->forder;
}
function all_visible_fields(Contact $user, PaperInfo $prow, ReviewInfo $rrow = null) {
$forder = [];
function user_visible_fields(Contact $user) {
$bound = $user->permissive_view_score_bound();
return array_filter($this->forder, function ($f) use ($bound) {
return $f->view_score > $bound;
});
}
function paper_visible_fields(Contact $user, PaperInfo $prow, ReviewInfo $rrow = null) {
$bound = $user->view_score_bound($prow, $rrow);
foreach ($this->forder as $fid => $f) {
if ($f->view_score > $bound
&& (!$f->round_mask || $f->is_round_visible($rrow))) {
$forder[$fid] = $f;
return array_filter($this->forder, function ($f) use ($bound, $rrow) {
return $f->view_score > $bound
&& (!$f->round_mask || $f->is_round_visible($rrow));
});
}
function example_fields(Contact $user) {
$fs = [];
foreach ($this->user_visible_fields($user) as $f) {
if ($f->has_options && $f->search_keyword()) {
if ($f->id === "overAllMerit") {
array_unshift($fs, $f);
} else {
$fs[] = $f;
}
}
}
return $forder;
return $fs;
}
function stopwords() {
@@ -500,9 +521,7 @@ function stopwords() {
if ($this->_stopwords === null) {
$bits = [];
$bit = 1;
foreach ($this->fmap as $f) {
if (!$f->displayed)
continue;
foreach ($this->forder as $f) {
$words = preg_split('/[^A-Za-z0-9_.\']+/', strtolower(UnicodeHelper::deaccent($f->name)));
if (count($words) <= 4) // Few words --> all of them meaningful
continue;
@@ -519,35 +538,36 @@ function stopwords() {
return $this->_stopwords;
}
function field($fid) {
$f = get($this->fmap, $fid);
return $f && $f->displayed ? $f : null;
}
function default_display() {
$f = $this->fmap["overAllMerit"];
if (!$f->displayed) {
foreach ($this->forder as $f)
break;
if (!$f->displayed || !$f->search_keyword()) {
$f = null;
foreach ($this->forder as $fx) {
if ($fx->has_options && $fx->search_keyword()) {
$f = $fx;
break;
}
}
}
return $f && $f->displayed ? " " . $f->search_keyword() . " " : " ";
return $f ? " " . $f->search_keyword() . " " : " ";
}
function jsonSerialize() {
$fmap = [];
foreach ($this->fmap as $f)
foreach ($this->fmap as $f) {
$fmap[$f->id] = $f->unparse_json(true);
}
return $fmap;
}
function unparse_json($round_mask, $view_score_bound) {
$fmap = array();
foreach ($this->fmap as $f)
if ($f->displayed
foreach ($this->forder as $f) {
if ($f->view_score > $view_score_bound
&& (!$round_mask || !$f->round_mask
|| ($f->round_mask & $round_mask))
&& $f->view_score > $view_score_bound) {
|| ($f->round_mask & $round_mask))) {
$fmap[$f->uid()] = $f->unparse_json();
}
}
return $fmap;
}
@@ -565,7 +585,7 @@ private function webFormRows(PaperInfo $prow, $rrow, Contact $contact,
if (($fi = $this->format_info($rrow)))
$format_description = $fi->description_preview_html();
echo '<div class="rve">';
foreach ($this->all_visible_fields($contact, $prow, $rrow) as $fid => $f) {
foreach ($this->paper_visible_fields($contact, $prow, $rrow) as $fid => $f) {
$rval = "";
if ($rrow)
$rval = $f->unparse_value(get($rrow, $fid), ReviewField::VALUE_STRING);
@@ -850,7 +870,7 @@ function pretty_text(PaperInfo $prow, ReviewInfo $rrow, Contact $contact,
if ($time > 1)
$x .= "* Updated: " . $this->conf->unparse_time($time) . "\n";
foreach ($this->all_visible_fields($contact, $prow, $rrow) as $fid => $f) {
foreach ($this->paper_visible_fields($contact, $prow, $rrow) as $fid => $f) {
$fval = "";
if (isset($rrow->$fid)) {
if ($f->has_options)
@@ -1204,7 +1224,7 @@ function unparse_review_json(Contact $user, PaperInfo $prow,
// review text
// (field UIDs always are uppercase so can't conflict)
foreach ($this->all_visible_fields($user, $prow, $rrow) as $fid => $f)
foreach ($this->paper_visible_fields($user, $prow, $rrow) as $fid => $f)
if ($f->view_score > VIEWSCORE_REVIEWERONLY
|| !($flags & self::RJ_NO_REVIEWERONLY)) {
$fval = get($rrow, $fid);
@@ -1249,7 +1269,7 @@ function unparse_flow_entry(PaperInfo $prow, ReviewInfo $rrow, Contact $contact)
$xbarsep = $barsep;
} else
$xbarsep = "";
foreach ($this->all_visible_fields($contact, $prow, $rrow) as $fid => $f)
foreach ($this->paper_visible_fields($contact, $prow, $rrow) as $fid => $f)
if (isset($rrow->$fid)
&& $f->has_options
&& (int) $rrow->$fid !== 0) {

0 comments on commit 7264fdc

Please sign in to comment.
You can’t perform that action at this time.