Skip to content

Commit

Permalink
Search: Move pageurl options into a PaperSearch method.
Browse files Browse the repository at this point in the history
And types.
  • Loading branch information
kohler committed Aug 30, 2020
1 parent b87975c commit e2793f5
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 77 deletions.
7 changes: 2 additions & 5 deletions autoassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
$SSel = SearchSelection::make($Qreq, $Me);
}
if ($SSel->is_empty()) {
$search = new PaperSearch($Me, array("t" => $Qreq->t, "q" => $Qreq->q));
$search = new PaperSearch($Me, ["t" => $Qreq->t, "q" => $Qreq->q]);
$SSel = new SearchSelection($search->paper_ids());
}
}
Expand Down Expand Up @@ -540,10 +540,7 @@ function divClass($name, $classes = null) {
echo join("", $tOpt);
echo "   ", Ht::submit("requery", "List", ["id" => "requery"]);
if (isset($Qreq->requery) || isset($Qreq->haspap)) {
$search = new PaperSearch($Me, [
"t" => $Qreq->t, "q" => $Qreq->q,
"pageurl" => $Conf->hoturl_site_relative_raw("autoassign")
]);
$search = (new PaperSearch($Me, ["t" => $Qreq->t, "q" => $Qreq->q]))->set_urlbase("autoassign");
$plist = new PaperList("reviewersSel", $search);
$plist->set_selection($SSel);

Expand Down
5 changes: 1 addition & 4 deletions conflictassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
echo "</div>\n";


$search = new PaperSearch($Me, [
"t" => "alladmin", "q" => "",
"pageurl" => $Conf->hoturl_site_relative_raw("conflictassign", ["neg" => $Qreq->neg ? 1 : null])
]);
$search = (new PaperSearch($Me, ["t" => "alladmin", "q" => ""]))->set_urlbase("conflictassign", ["neg" => $Qreq->neg ? 1 : null]);
$rowset = $Conf->paper_set(["allConflictType" => 1, "allReviewerPreference" => 1, "tags" => 1, "paperId" => $search->paper_ids()], $Me);

if ($Qreq->neg) {
Expand Down
30 changes: 25 additions & 5 deletions lib/tagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,49 @@ class TagInfo {
public $conf;
/** @var false|string */
public $pattern = false;
/** @var bool */
public $pattern_instance = false;
/** @var int */
public $pattern_version = 0;
/** @var bool */
public $is_private = false;
/** @var bool */
public $chair = false;
/** @var bool */
public $readonly = false;
/** @var bool */
public $hidden = false;
/** @var bool */
public $track = false;
/** @var bool */
public $votish = false;
/** @var bool */
public $approval = false;
/** @var false|float */
public $allotment = false;
/** @var bool */
public $sitewide = false;
/** @var bool */
public $rank = false;
/** @var bool */
public $public_peruser = false;
/** @var bool */
public $automatic = false;
/** @var bool */
public $order_anno = false;
/** @var ?list<TagAnno> */
private $_order_anno_list;
/** @var int */
private $_order_anno_search = 0;
/** @var ?list<string> */
public $colors;
/** @var bool */
public $basic_color = false;
public $badges;
public $emoji;
/** @var ?string */
public $autosearch;
/** @var ?string */
public $autosearch_value;
/** @param string $tag */
function __construct($tag, TagMap $tagmap) {
Expand Down Expand Up @@ -65,7 +84,7 @@ function merge(TagInfo $t) {
}
foreach (["colors", "badges", "emoji"] as $property) {
if ($t->$property)
$this->$property = array_unique(array_merge($this->$property ? : [], $t->$property));
$this->$property = array_unique(array_merge($this->$property ?? [], $t->$property));
}
}
function tag_regex() {
Expand Down Expand Up @@ -331,7 +350,7 @@ function __construct(Conf $conf) {
}

/** @param string $ltag
* @return bool */
* @return string|false */
function check_emoji_code($ltag) {
$len = strlen($ltag);
if ($len >= 3 && $ltag[0] === ":" && $ltag[$len - 1] === ":") {
Expand Down Expand Up @@ -683,8 +702,9 @@ function canonical_colors() {
function badge_regex() {
if (!$this->badge_re) {
$re = "{(?:\\A| )(?:\\d*~|)(";
foreach ($this->filter("badges") as $t)
foreach ($this->filter("badges") as $t) {
$re .= $t->tag_regex() . "|";
}
$this->badge_re = substr($re, 0, -1) . ")(?:#[-\\d.]+)?(?=\\z| )}i";
}
return $this->badge_re;
Expand Down Expand Up @@ -881,7 +901,7 @@ static function make(Conf $conf) {
$vt = $conf->setting_data("tag_vote") ?? "";
foreach (Tagger::split_unpack($vt) as $ti) {
$t = $map->add($ti[0]);
$t->allotment = ($ti[1] ? : 1);
$t->allotment = ($ti[1] ? : 1.0);
$map->has_allotment = true;
$t->votish = $map->has_votish = true;
$t->automatic = $map->has_automatic = true;
Expand Down Expand Up @@ -1267,7 +1287,7 @@ function unparse_decoration_html($tags, $type = 0) {
if ($dt->has_badges
&& preg_match_all($dt->badge_regex(), $tags, $m, PREG_SET_ORDER)) {
foreach ($m as $mx) {
if (($t = $dt->check($mx[1])) && $t->badges) {
if (($t = $dt->check($mx[1])) && $t->badges !== null) {
$klass = ' class="badge ' . $t->badges[0] . 'badge"';
$tag = $this->unparse(trim($mx[0]));
if ($type === self::DECOR_PAPER && ($link = $this->link($tag))) {
Expand Down
2 changes: 1 addition & 1 deletion mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
$Qreq->q = join(" ", $papersel);
$Qreq->plimit = 1;
} else if (isset($Qreq->plimit)) {
$search = new PaperSearch($Me, array("t" => $Qreq->t, "q" => $Qreq->q));
$search = new PaperSearch($Me, ["t" => $Qreq->t, "q" => $Qreq->q]);
$papersel = $search->paper_ids();
sort($papersel);
} else {
Expand Down
5 changes: 1 addition & 4 deletions manualassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,7 @@ function show_ass_elements($pl) {
'">Search for current and potential conflicts</a></div>';

// main assignment form
$search = new PaperSearch($Me, [
"t" => $Qreq->t, "q" => $Qreq->q, "reviewer" => $reviewer,
"pageurl" => $Conf->hoturl_site_relative_raw("manualassign")
]);
$search = (new PaperSearch($Me, ["t" => $Qreq->t, "q" => $Qreq->q, "reviewer" => $reviewer]))->set_urlbase("manualassign");
if (!empty($hlsearch)) {
$search->set_field_highlighter_query(join(" OR ", $hlsearch));
}
Expand Down
5 changes: 1 addition & 4 deletions reviewprefs.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,7 @@ function parseUploadedPreferences($text, $filename, $apply) {


// search
$search = new PaperSearch($Me, [
"t" => $Qreq->t, "q" => $Qreq->q, "reviewer" => $reviewer,
"pageurl" => $Conf->hoturl_site_relative_raw("reviewprefs")
]);
$search = (new PaperSearch($Me, ["t" => $Qreq->t, "q" => $Qreq->q, "reviewer" => $reviewer]))->set_urlbase("reviewprefs");
$pl = new PaperList("pf", $search, ["sort" => true], $Qreq);
$pl->apply_view_report_default();
$pl->apply_view_session();
Expand Down
16 changes: 12 additions & 4 deletions src/api/api_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ static function search(Contact $user, Qrequest $qreq) {
if (empty($topt) || ($qreq->t && !isset($topt[$qreq->t]))) {
return new JsonResult(403, "Permission error.");
}
$t = $qreq->t ? : key($topt);

$t = $qreq->t ?? key($topt);
$q = $qreq->q;
if ($qreq->urlbase) {
error_log("{$user->conf->dbname}: api/search with urlbase"); // XXX
}

if (isset($q)) {
$q = trim($q);
if ($q === "(All)")
Expand All @@ -21,13 +25,17 @@ static function search(Contact $user, Qrequest $qreq) {
return new JsonResult(400, "Missing parameter.");
}

$search = new PaperSearch($user, ["t" => $t, "q" => $q, "qt" => $qreq->qt, "urlbase" => $qreq->urlbase, "reviewer" => $qreq->reviewer]);
$search = new PaperSearch($user, ["t" => $t, "q" => $q, "qt" => $qreq->qt, "reviewer" => $qreq->reviewer]);
$pl = new PaperList($qreq->report ? : "pl", $search, ["sort" => true], $qreq);
$pl->apply_view_report_default();
$pl->apply_view_session();
$ih = $pl->ids_and_groups();
return ["ok" => true, "ids" => $ih[0], "groups" => $ih[1],
"hotlist" => $pl->session_list_object()->info_string()];
return [
"ok" => true,
"ids" => $ih[0],
"groups" => $ih[1],
"hotlist" => $pl->session_list_object()->info_string()
];
}

static function fieldhtml(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
Expand Down
1 change: 1 addition & 0 deletions src/conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ function _add_emoji_code($val, $key) {
return false;
}
}
/** @return array<string,string> */
function emoji_code_map() {
if ($this->_emoji_codes === null) {
$this->_emoji_codes = json_decode(file_get_contents(SiteLoader::find("scripts/emojicodes.json")));
Expand Down
Loading

0 comments on commit e2793f5

Please sign in to comment.