예제 #1
0
 private function _row_text($rstate, $row, $fieldDef)
 {
     global $Conf;
     $rowidx = count($rstate->ids);
     $rstate->ids[] = (int) $row->paperId;
     $trclass = "k" . $rstate->colorindex;
     if (get($row, "paperTags") && ($viewable = $row->viewable_tags($this->contact, true)) && ($m = TagInfo::color_classes($viewable))) {
         if (TagInfo::classes_have_colors($m)) {
             $rstate->hascolors = true;
             $trclass = $m;
         } else {
             $trclass .= " " . $m;
         }
         if ($row->conflictType > 0 && !$this->contact->can_view_tags($row, false)) {
             $trclass .= " conflictmark";
         }
     }
     if ($highlightclass = get($this->search->highlightmap, $row->paperId)) {
         $trclass .= " {$highlightclass}mark";
     }
     $rstate->colorindex = 1 - $rstate->colorindex;
     $rstate->last_trclass = $trclass;
     $this->row_attr = [];
     // main columns
     $tm = "";
     foreach ($fieldDef as $fdef) {
         if ($fdef->view != Column::VIEW_COLUMN) {
             continue;
         }
         $empty = $fdef->content_empty($this, $row);
         if ($fdef->is_folded) {
             if (!$empty) {
                 $fdef->has_content = true;
             }
         } else {
             $tm .= "<td class=\"pl " . $fdef->className;
             if ($fdef->foldable) {
                 $tm .= " fx{$fdef->foldable}";
             }
             $tm .= "\">";
             if (!$empty && ($c = $fdef->content($this, $row, $rowidx)) !== "") {
                 $tm .= $c;
                 $fdef->has_content = true;
             }
             $tm .= "</td>";
         }
     }
     // extension columns
     $tt = "";
     foreach ($fieldDef as $fdef) {
         if ($fdef->view != Column::VIEW_ROW) {
             continue;
         }
         $empty = $fdef->content_empty($this, $row);
         $is_authors = $fdef->name === "authors";
         if ($fdef->is_folded && !$is_authors) {
             if (!$empty) {
                 $fdef->has_content = true;
             }
         } else {
             $tt .= "<div class=\"" . $fdef->className;
             if ($is_authors) {
                 $tt .= " fx1";
                 if ($this->contact->can_view_authors($row, false)) {
                     $rstate->has_openau = true;
                 } else {
                     $tt .= " fx2";
                     $rstate->has_anonau = true;
                 }
             } else {
                 if ($fdef->foldable) {
                     $tt .= " fx" . $fdef->foldable;
                 }
             }
             $tt .= "\">";
             if (!$empty && ($c = $fdef->content($this, $row, $rowidx)) !== "") {
                 if ($c[0] !== "<" || !preg_match('/\\A((?:<(?:div|p).*?>)*)([\\s\\S]*)\\z/', $c, $cm)) {
                     $cm = [null, "", $c];
                 }
                 $tt .= $cm[1] . '<em class="plx">' . $fdef->header($this, -1) . ':</em> ' . $cm[2];
                 $fdef->has_content = true;
             }
             $tt .= "</div>";
         }
     }
     if (isset($row->folded) && $row->folded) {
         $trclass .= " fx3";
         $rstate->row_folded = true;
     } else {
         if ($rstate->row_folded) {
             $rstate->row_folded = false;
         }
     }
     $t = "  <tr";
     if ($this->_row_id_pattern) {
         $t .= " id=\"" . str_replace("#", $row->paperId, $this->_row_id_pattern) . "\"";
     }
     $t .= " class=\"pl {$trclass}\" data-pid=\"{$row->paperId}";
     foreach ($this->row_attr as $k => $v) {
         $t .= "\" {$k}=\"" . htmlspecialchars($v);
     }
     $t .= "\">" . $tm . "</tr>\n";
     if ($tt !== "") {
         $t .= "  <tr class=\"plx {$trclass}\" data-pid=\"{$row->paperId}\">";
         if ($rstate->skipcallout > 0) {
             $t .= "<td colspan=\"{$rstate->skipcallout}\"></td>";
         }
         $t .= "<td class=\"plx\" colspan=\"" . ($rstate->ncol - $rstate->skipcallout) . "\">{$tt}</td></tr>\n";
     }
     return $t;
 }
function reviewLinks($prow, $rrows, $crows, $rrow, $mode, &$allreviewslink)
{
    global $Conf, $Me;
    $conflictType = $Me->view_conflict_type($prow);
    $allow_admin = $Me->allow_administer($prow);
    $any_comments = false;
    $admin = $Me->can_administer($prow);
    $xsep = ' <span class="barsep">·</span> ';
    $nvisible = 0;
    $myrr = null;
    if ($rrows) {
        foreach ($rrows as $rr) {
            if ($Me->can_view_review($prow, $rr, null)) {
                $nvisible++;
            }
            if ($rr->contactId == $Me->contactId || !$myrr && $Me->is_my_review($rr)) {
                $myrr = $rr;
            }
        }
    }
    // comments
    $pret = "";
    if ($crows && count($crows) > 0 && !$rrow && $mode !== "edit") {
        $cids = array();
        $cnames = array();
        $tagger = new Tagger($Me);
        foreach ($crows as $cr) {
            if ($Me->can_view_comment($prow, $cr, null)) {
                if ($Me->can_view_comment_identity($prow, $cr, null)) {
                    $n = Text::abbrevname_html($cr->user());
                } else {
                    $n = "anonymous";
                }
                if ($cr->commentType & COMMENTTYPE_RESPONSE) {
                    $rname = $Conf->resp_round_name($cr->commentRound);
                    $n = $n === "anonymous" ? "" : " ({$n})";
                    if ($cr->commentType & COMMENTTYPE_DRAFT && $rname != "1") {
                        $n = "<i>Draft {$rname} Response</i>{$n}";
                    } else {
                        if ($cr->commentType & COMMENTTYPE_DRAFT) {
                            $n = "<i>Draft Response</i>{$n}";
                        } else {
                            if ($rname != "1") {
                                $n = "<i>{$rname} Response</i>{$n}";
                            } else {
                                $n = "<i>Response</i>{$n}";
                            }
                        }
                    }
                }
                $cids[] = $cid = CommentInfo::unparse_html_id($cr);
                $tclass = "cmtlink";
                if ($cr->commentTags && ($tags = Tagger::strip_nonviewable($cr->commentTags, $Me)) && $Me->can_view_comment_tags($prow, $cr, null) && ($color = TagInfo::color_classes($tags))) {
                    if (TagInfo::classes_have_colors($color)) {
                        $tclass .= " tagcolorspan";
                    }
                    $tclass .= " {$color} taghl";
                }
                $cnames[] = '<a class="' . $tclass . '" href="#' . $cid . '">' . $n . '</a>';
            }
        }
        if (count($cids) > 0) {
            $pret = '<div class="revnotes"><a href="#' . $cids[0] . '"><strong>' . plural(count($cids), "Comment") . '</strong></a>: <span class="nb">' . join(',</span> <span class="nb">', $cnames) . "</span></div>";
            $any_comments = true;
        }
    }
    $t = "";
    // see all reviews
    $allreviewslink = false;
    if (($nvisible > 1 || $nvisible > 0 && !$myrr) && ($mode !== "p" || $rrow)) {
        $allreviewslink = true;
        $x = '<a href="' . hoturl("paper", "p={$prow->paperId}") . '" class="xx">' . Ht::img("view24.png", "[All reviews]", "dlimg") . "&nbsp;<u>All reviews</u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
    }
    // edit paper
    if ($mode !== "edit" && $prow->conflictType >= CONFLICT_AUTHOR && !$Me->can_administer($prow)) {
        $x = '<a href="' . hoturl("paper", "p={$prow->paperId}&amp;m=edit") . '" class="xx">' . Ht::img("edit24.png", "[Edit paper]", "dlimg") . "&nbsp;<u><strong>Edit paper</strong></u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
    }
    // edit review
    if ($mode === "re" || $mode === "assign" && $t !== "" || !$prow) {
        /* no link */
    } else {
        if ($myrr && $rrow != $myrr) {
            $myrlink = unparseReviewOrdinal($myrr);
            $a = '<a href="' . hoturl("review", "p={$prow->paperId}&r={$myrlink}") . '" class="xx">';
            if ($Me->can_review($prow, $myrr)) {
                $x = $a . Ht::img("review24.png", "[Edit review]", "dlimg") . "&nbsp;<u><b>Edit your review</b></u></a>";
            } else {
                $x = $a . Ht::img("review24.png", "[Your review]", "dlimg") . "&nbsp;<u><b>Your review</b></u></a>";
            }
            $t .= ($t === "" ? "" : $xsep) . $x;
        } else {
            if (!$myrr && !$rrow && $Me->can_review($prow, null)) {
                $x = '<a href="' . hoturl("review", "p={$prow->paperId}&amp;m=re") . '" class="xx">' . Ht::img("review24.png", "[Write review]", "dlimg") . "&nbsp;<u><b>Write review</b></u></a>";
                $t .= ($t === "" ? "" : $xsep) . $x;
            }
        }
    }
    // review assignments
    if ($mode !== "assign" && $mode !== "edit" && $Me->can_request_review($prow, true)) {
        $x = '<a href="' . hoturl("assign", "p={$prow->paperId}") . '" class="xx">' . Ht::img("assign24.png", "[Assign]", "dlimg") . "&nbsp;<u>" . ($admin ? "Assign reviews" : "External reviews") . "</u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
    }
    // new comment
    $nocmt = preg_match('/\\A(?:assign|contact|edit|re)\\z/', $mode);
    if (!$allreviewslink && !$nocmt && $Me->can_comment($prow, null)) {
        $x = '<a href="#cnew" onclick="return papercomment.edit_new()" class="xx">' . Ht::img("comment24.png", "[Add comment]", "dlimg") . "&nbsp;<u>Add comment</u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
        $any_comments = true;
    }
    // new response
    if (!$nocmt && ($prow->conflictType >= CONFLICT_AUTHOR || $allow_admin) && ($rrounds = $Conf->time_author_respond())) {
        foreach ($rrounds as $i => $rname) {
            $cid = ($i ? $rname : "") . "response";
            $what = "Add";
            if ($crows) {
                foreach ($crows as $cr) {
                    if ($cr->commentType & COMMENTTYPE_RESPONSE && $cr->commentRound == $i) {
                        $what = "Edit";
                        if ($cr->commentType & COMMENTTYPE_DRAFT) {
                            $what = "Edit draft";
                        }
                    }
                }
            }
            $x = '<a href="#' . $cid . '" onclick=\'return papercomment.edit_response(' . json_encode($rname) . ')\' class="xx">' . Ht::img("comment24.png", "[{$what} response]", "dlimg") . "&nbsp;" . ($conflictType >= CONFLICT_AUTHOR ? '<u style="font-weight:bold">' : '<u>') . $what . ($i ? " {$rname}" : "") . ' response</u></a>';
            $t .= ($t === "" ? "" : $xsep) . $x;
            $any_comments = true;
        }
    }
    // override conflict
    if ($allow_admin && !$admin) {
        $x = '<a href="' . selfHref(array("forceShow" => 1)) . '" class="xx">' . Ht::img("override24.png", "[Override]", "dlimg") . "&nbsp;<u>Override conflict</u></a> to show reviewers and allow editing";
        $t .= ($t === "" ? "" : $xsep) . $x;
    } else {
        if ($Me->privChair && !$allow_admin) {
            $x = "You can’t override your conflict because this paper has an administrator.";
            $t .= ($t === "" ? "" : $xsep) . $x;
        }
    }
    if ($any_comments) {
        CommentInfo::echo_script($prow);
    }
    if (($list = SessionList::active()) && ($pret || $t)) {
        return '<div class="has_hotcrp_list" data-hotcrp-list="' . $list->listno . '">' . $pret . $t . '</div>';
    } else {
        return $pret . $t;
    }
}
예제 #3
0
 function reviewer_color_classes_for($x)
 {
     if ($this->isPC && isset($x->contactTags) && $x->contactTags) {
         if ($colors = $x->viewable_color_classes($this)) {
             if (TagInfo::classes_have_colors($colors)) {
                 $colors = "tagcolorspan " . $colors;
             }
             return $colors;
         }
     }
     return "";
 }
 function table_html($listname, $url, $listtitle = "", $foldsession = null)
 {
     global $Conf, $contactListFields;
     // PC tags
     $listquery = $listname;
     $queryOptions = array();
     if (str_starts_with($listname, "#")) {
         $queryOptions["where"] = "(u.contactTags like " . Dbl::utf8ci("'% " . sqlq_for_like(substr($listname, 1)) . "#%'") . ")";
         $listquery = "pc";
     }
     // get paper list
     if (!($baseFieldId = $this->listFields($listquery))) {
         Conf::msg_error("There is no people list query named “" . htmlspecialchars($listquery) . "”.");
         return null;
     }
     $this->limit = array_shift($baseFieldId);
     // get field array
     $fieldDef = array();
     $acceptable_fields = array();
     $this->any = (object) array("sel" => false);
     $ncol = 0;
     foreach ($baseFieldId as $fid) {
         if ($this->selector($fid, $queryOptions) === false) {
             continue;
         }
         if (!($fieldDef[$fid] = @$contactListFields[$fid])) {
             $fieldDef[$fid] = $contactListFields[self::FIELD_SCORE];
         }
         $acceptable_fields[$fid] = true;
         if ($fieldDef[$fid][1] == 1) {
             $ncol++;
         }
     }
     // run query
     $rows = $this->_rows($queryOptions);
     if (!$rows || count($rows) == 0) {
         return "No matching people";
     }
     // list number
     if ($this->listNumber === true) {
         $this->listNumber = SessionList::allocate("u/" . $this->limit);
         $this->contactLinkArgs .= "&amp;ls=" . $this->listNumber;
     }
     // sort rows
     if (!@$acceptable_fields[$this->sortField]) {
         $this->sortField = null;
     }
     $srows = $this->_sort($rows);
     // count non-callout columns
     $firstcallout = $lastcallout = null;
     $n = 0;
     foreach ($fieldDef as $fieldId => $fdef) {
         if ($fdef[1] == 1) {
             if ($firstcallout === null && $fieldId < self::FIELD_SELECTOR) {
                 $firstcallout = $n;
             }
             if ($fieldId < self::FIELD_SCORE) {
                 $lastcallout = $n + 1;
             }
             ++$n;
         }
     }
     $firstcallout = $firstcallout ? $firstcallout : 0;
     $lastcallout = ($lastcallout ? $lastcallout : $ncol) - $firstcallout;
     // collect row data
     $this->count = 0;
     $show_colors = $this->contact->isPC;
     $anyData = array();
     $body = '';
     $extrainfo = $hascolors = false;
     $ids = array();
     foreach ($srows as $row) {
         if (($this->limit == "resub" || $this->limit == "extsub") && $row->numReviewsSubmitted == 0) {
             continue;
         }
         $trclass = "k" . $this->count % 2;
         if ($show_colors && ($m = $row->viewable_color_classes($this->contact))) {
             if (TagInfo::classes_have_colors($m)) {
                 $trclass = $m;
                 $hascolors = true;
             } else {
                 $trclass .= " {$m}";
             }
         }
         if ($row->disabled && $this->contact->isPC) {
             $trclass .= " graytext";
         }
         $this->count++;
         $ids[] = (int) $row->contactId;
         // First create the expanded callout row
         $tt = "";
         foreach ($fieldDef as $fieldId => $fdef) {
             if ($fdef[1] >= 2 && ($d = $this->content($fieldId, $row)) !== "") {
                 $tt .= "<div";
                 //$t .= "  <tr class=\"pl_$fdef[0] pl_callout $trclass";
                 if ($fdef[1] >= 3) {
                     $tt .= " class=\"fx" . ($fdef[1] - 2) . "\"";
                 }
                 $tt .= '><em class="plx">' . $this->header($fieldId, -1, $row) . ":</em> " . $d . "</div>";
             }
         }
         if ($tt !== "") {
             $x = "  <tr class=\"plx {$trclass}\">";
             if ($firstcallout > 0) {
                 $x .= "<td colspan=\"{$firstcallout}\"></td>";
             }
             $tt = $x . "<td class=\"plx\" colspan=\"" . ($lastcallout - $firstcallout) . "\">" . $tt . "</td></tr>\n";
         }
         // Now the normal row
         $t = "  <tr class=\"pl {$trclass}\">\n";
         $n = 0;
         foreach ($fieldDef as $fieldId => $fdef) {
             if ($fdef[1] == 1) {
                 $c = $this->content($fieldId, $row);
                 $t .= "    <td class=\"pl pl_{$fdef['0']}\"";
                 if ($n >= $lastcallout && $tt != "") {
                     $t .= " rowspan=\"2\"";
                 }
                 $t .= ">" . $c . "</td>\n";
                 if ($c != "") {
                     $anyData[$fieldId] = 1;
                 }
                 ++$n;
             }
         }
         $t .= "  </tr>\n";
         $body .= $t . $tt;
     }
     $foldclasses = array();
     foreach (self::$folds as $k => $fold) {
         if (@$this->have_folds[$fold] !== null) {
             $this->have_folds[$fold] = strpos(displayOptionsSet("uldisplay"), " {$fold} ") !== false;
             $foldclasses[] = "fold" . ($k + 1) . ($this->have_folds[$fold] ? "o" : "c");
         }
     }
     $x = "<table id=\"foldul\" class=\"pltable pltable_full plt_" . htmlspecialchars($listquery);
     if ($foldclasses) {
         $x .= " " . join(" ", $foldclasses);
     }
     if ($foldclasses && $foldsession) {
         $x .= "\" data-fold-session=\"{$foldsession}";
     }
     $x .= "\">\n";
     if ($this->showHeader) {
         $x .= "  <thead class=\"pltable\">\n  <tr class=\"pl_headrow\">\n";
         $ord = 0;
         if ($this->sortable && $url) {
             $sortUrl = htmlspecialchars($url) . (strpos($url, "?") ? "&amp;" : "?") . "sort=";
             $q = '<a class="pl_sort" rel="nofollow" href="' . $sortUrl;
             foreach ($fieldDef as $fieldId => $fdef) {
                 if ($fdef[1] != 1) {
                     continue;
                 } else {
                     if (!isset($anyData[$fieldId])) {
                         $x .= "    <th class=\"pl pl_{$fdef['0']}\"></th>\n";
                         continue;
                     }
                 }
                 $x .= "    <th class=\"pl pl_{$fdef['0']}\">";
                 $ftext = $this->header($fieldId, $ord++);
                 if ($this->sortField == null && $fieldId == 1) {
                     $this->sortField = $fieldId;
                 }
                 if ($fieldId == $this->sortField) {
                     $x .= '<a class="pl_sort_def' . ($this->reverseSort ? "_rev" : "") . '" rel="nofollow" href="' . $sortUrl . $fieldId . ($this->reverseSort ? "N" : "R") . '">' . $ftext . "</a>";
                 } else {
                     if ($fdef[2]) {
                         $x .= $q . $fieldId . "\">" . $ftext . "</a>";
                     } else {
                         $x .= $ftext;
                     }
                 }
                 $x .= "</th>\n";
             }
         } else {
             foreach ($fieldDef as $fieldId => $fdef) {
                 if ($fdef[1] == 1 && isset($anyData[$fieldId])) {
                     $x .= "    <th class=\"pl pl_{$fdef['0']}\">" . $this->header($fieldId, $ord++) . "</th>\n";
                 } else {
                     if ($fdef[1] == 1) {
                         $x .= "    <th class=\"pl pl_{$fdef['0']}\"></th>\n";
                     }
                 }
             }
         }
         $x .= "  </tr></thead>\n";
     }
     reset($fieldDef);
     if (key($fieldDef) == self::FIELD_SELECTOR) {
         $x .= $this->footer($ncol, $hascolors);
     }
     $x .= "<tbody class=\"pltable" . ($hascolors ? " pltable_colored" : "") . "\">" . $body . "</tbody></table>";
     if ($this->listNumber) {
         $l = SessionList::create("u/" . $listname, $ids, $listtitle ? $listtitle : "Users", hoturl_site_relative_raw("users", ["t" => $listname]));
         SessionList::change($this->listNumber, $l);
     }
     return $x;
 }