コード例 #1
0
ファイル: index.class.php プロジェクト: hansek/Tagger
 public function initialize()
 {
     $this->tagger = new Tagger($this->modx);
     $this->addCss($this->tagger->getOption('cssUrl') . 'mgr.css');
     $this->addJavascript($this->tagger->getOption('jsUrl') . 'mgr/tagger.js');
     $this->addHtml('<script type="text/javascript">
     Ext.onReady(function() {
         Tagger.config = ' . $this->modx->toJSON($this->tagger->options) . ';
         Tagger.config.connector_url = "' . $this->tagger->getOption('connectorUrl') . '";
     });
     </script>');
     return parent::initialize();
 }
コード例 #2
0
ファイル: lib_extract.php プロジェクト: 1upon0/ui
function process($text)
{
    $filter = new \DefaultFilter($min_occurrence = 5, $keep_if_strength = 1);
    $tagger = new \Tagger('english');
    $tagger->initialize($use_apc = true);
    $extractor = new \TermExtractor($tagger, $filter);
    $terms = $extractor->extract($text);
    $res = array();
    foreach ($terms as $term_info) {
        list($term, $occurrence, $word_count) = $term_info;
        $res[] = $term;
    }
    return $res;
}
コード例 #3
0
ファイル: Tagger.php プロジェクト: knagakubo/twitter-matching
 /**
  * バイナリ辞書を読み込んで、形態素解析器のインスタンスを作成する
  *
  * @param dataDir
  *            バイナリ辞書があるディレクトリ
  */
 public function __construct($dataDir, $outputEncoding)
 {
     self::$BOS_NODES[0] = ViterbiNode::makeBOSEOS();
     $this->wdc = new WordDic($dataDir);
     $this->unk = new Unknown($dataDir);
     $this->mtx = new Matrix($dataDir);
     $this->outEnc = $outputEncoding;
     if (IGO_LITTLE_ENDIAN) {
         self::$DIC_ENC = "UTF-16LE";
     } else {
         self::$DIC_ENC = "UTF-16BE";
     }
 }
コード例 #4
0
ファイル: settings.php プロジェクト: silentworks/tagger
" name="rowspage" />
				</td>
                <td class="help"><?php 
echo __('Sets the number of tags to be displayed per page in the backend.');
?>
</td>
        	</tr>
	        <tr>
	            <td class="label"><label for="sort_field"><?php 
echo __('Sort Field');
?>
: </label></td>
	            <td class="field">
					<select name="sort_field" id="sort_field">
						<?php 
foreach (Tagger::sortField() as $key => $field) {
    ?>
							<option value="<?php 
    echo $key;
    ?>
" <?php 
    if ($sort_field == $key) {
        echo 'selected ="";';
    }
    ?>
><?php 
    echo $field;
    ?>
</option>
						<?php 
}
コード例 #5
0
 public function purged()
 {
     Tagger::purge_old();
     redirect(get_url('plugin/tagger'));
 }
コード例 #6
0
 static function votereport_api($user, $qreq, $prow)
 {
     $tagger = new Tagger($user);
     if (!($tag = $tagger->check($qreq->tag, Tagger::NOVALUE))) {
         json_exit(["ok" => false, "error" => $tagger->error_html]);
     }
     if (!$user->can_view_peruser_tags($prow, $tag)) {
         json_exit(["ok" => false, "error" => "Permission error."]);
     }
     $votemap = [];
     preg_match_all('/ (\\d+)~' . preg_quote($tag) . '#(\\S+)/i', $prow->all_tags_text(), $m);
     $is_approval = TagInfo::is_approval($tag);
     $min_vote = $is_approval ? 0 : 0.001;
     for ($i = 0; $i != count($m[0]); ++$i) {
         if ($m[2][$i] >= $min_vote) {
             $votemap[$m[1][$i]] = $m[2][$i];
         }
     }
     $user->ksort_cid_array($votemap);
     $result = [];
     foreach ($votemap as $k => $v) {
         if ($is_approval) {
             $result[] = $user->reviewer_html_for($k);
         } else {
             $result[] = $user->reviewer_html_for($k) . " ({$v})";
         }
     }
     if (empty($result)) {
         json_exit(["ok" => true, "result" => ""]);
     } else {
         json_exit(["ok" => true, "result" => '<span class="nw">' . join(',</span> <span class="nw">', $result) . '</span>']);
     }
 }
コード例 #7
0
  private static function getController(RestResponse $response, $path_array) {
    // Check versions of the api.
    if ('v1' != $path_array[0]) {
      die(RestUtils::sendResponse(501));
    }
    try {
      if ('tag' == $path_array[1]) {
        include './tagger/Tagger.php';
        $tagger = Tagger::getTagger();
        if ($response->getRequestVars('url')) {
          $text = file_get_contents($response->getRequestVars('url'));
        } else if ($response->getRequestVars('text')) {
          $text = $response->getRequestVars('text');
        } else {
          RestUtils::sendResponse(500, 'Missing argument: text or url');
        }
        
        $configuration = $tagger->getConfiguration();

        if (empty($configuration['vocab_names'])) {
          RestUtils::sendResponse(500, 'No configured vocabs');
        }

        return $tagger->tagText(
            $text,
            $configuration['vocab_names'],
            $response->getRequestVars('disambiguate') ? true : false,
            $response->getRequestVars('uris') ? true : false,
            $response->getRequestVars('unmatched') ? true : false,
            $response->getRequestVars('markup') ? true : false,
            $response->getRequestVars('nl2br') ? true : false
          );
      }
    }
    catch (Exception $e) {
      die(RestUtils::sendResponse(400));
    }
    die(RestUtils::sendResponse(404));
  }
コード例 #8
0
 private function _tag_description()
 {
     if ($this->q === "") {
         return false;
     } else {
         if (strlen($this->q) <= 24) {
             return htmlspecialchars($this->q);
         } else {
             if (!preg_match(',\\A(#|-#|tag:|-tag:|notag:|order:|rorder:)(.*)\\z,', $this->q, $m)) {
                 return false;
             }
         }
     }
     $tagger = new Tagger($this->contact);
     if (!$tagger->check($m[2])) {
         return false;
     } else {
         if ($m[1] === "-tag:") {
             return "no" . substr($this->q, 1);
         } else {
             return $this->q;
         }
     }
 }
コード例 #9
0
ファイル: Tagger_Generic.php プロジェクト: rmourembles/resto
 /**
  * Tag metadata
  * 
  * @param array $metadata
  * @param array $options
  * @return array
  * @throws Exception
  */
 public function tag($metadata, $options = array())
 {
     parent::tag($metadata, $options);
     return $this->process($metadata['footprint'], $options);
 }
コード例 #10
0
 public function parse($sv, $si)
 {
     $tagger = new Tagger();
     $tracks = (object) array();
     $missing_tags = false;
     for ($i = 1; isset($sv->req["name_track{$i}"]); ++$i) {
         $trackname = trim($sv->req["name_track{$i}"]);
         if ($trackname === "" || $trackname === "(tag)") {
             continue;
         } else {
             if (!$tagger->check($trackname, Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE) || $trackname === "_" && $i != 1) {
                 if ($trackname !== "_") {
                     $sv->set_error("name_track{$i}", "Track name: " . $tagger->error_html);
                 } else {
                     $sv->set_error("name_track{$i}", "Track name “_” is reserved.");
                 }
                 $sv->set_error("tracks");
                 continue;
             }
         }
         $t = (object) array();
         foreach (Track::$map as $type => $value) {
             if (($ttype = defval($sv->req, "{$type}_track{$i}", "")) == "+" || $ttype == "-") {
                 $ttag = trim(defval($sv->req, "{$type}tag_track{$i}", ""));
                 if ($ttag === "" || $ttag === "(tag)") {
                     $sv->set_error("{$type}_track{$i}", "Tag missing for track setting.");
                     $sv->set_error("tracks");
                 } else {
                     if ($ttype == "+" && strcasecmp($ttag, "none") == 0 || $tagger->check($ttag, Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE)) {
                         $t->{$type} = $ttype . $ttag;
                     } else {
                         $sv->set_error("{$type}_track{$i}", $tagger->error_html);
                         $sv->set_error("tracks");
                     }
                 }
             } else {
                 if ($ttype == "none") {
                     $t->{$type} = "+none";
                 }
             }
         }
         if (count((array) $t) || get($tracks, "_")) {
             $tracks->{$trackname} = $t;
         }
     }
     $sv->save("tracks", count((array) $tracks) ? json_encode($tracks) : null);
     return false;
 }
コード例 #11
0
 public function check()
 {
     global $Error, $Qreq;
     $atypes = array("rev" => "r", "revadd" => "r", "revpc" => "r", "lead" => true, "shepherd" => true, "prefconflict" => true, "clear" => true, "discorder" => true);
     $this->atype = $Qreq->a;
     if (!$this->atype || !isset($atypes[$this->atype])) {
         $Error["ass"] = true;
         return Conf::msg_error("Malformed request!");
     }
     $this->atype_review = $atypes[$this->atype] === "r";
     $r = false;
     if ($this->atype_review) {
         $r = $Qreq[$this->atype . "type"];
         if ($r != REVIEW_PRIMARY && $r != REVIEW_SECONDARY && $r != REVIEW_PC) {
             $Error["ass"] = true;
             return Conf::msg_error("Malformed request!");
         }
     } else {
         if ($this->atype === "clear") {
             $r = $Qreq->cleartype;
             if ($r != REVIEW_PRIMARY && $r != REVIEW_SECONDARY && $r != REVIEW_PC && $r !== "conflict" && $r !== "lead" && $r !== "shepherd") {
                 $Error["clear"] = true;
                 return Conf::msg_error("Malformed request!");
             }
         }
     }
     $this->reviewtype = $r;
     if ($this->atype_review && $Qreq->rev_roundtag !== "" && ($err = Conf::round_name_error($Qreq->rev_roundtag))) {
         $Error["rev_roundtag"] = true;
         return Conf::msg_error($err);
     }
     if ($this->atype === "rev" && cvtint($Qreq->revct, -1) <= 0) {
         $Error["rev"] = true;
         return Conf::msg_error("Enter the number of reviews you want to assign.");
     } else {
         if ($this->atype === "revadd" && cvtint($Qreq->revaddct, -1) <= 0) {
             $Error["revadd"] = true;
             return Conf::msg_error("You must assign at least one review.");
         } else {
             if ($this->atype === "revpc" && cvtint($Qreq->revpcct, -1) <= 0) {
                 $Error["revpc"] = true;
                 return Conf::msg_error("You must assign at least one review.");
             }
         }
     }
     if ($this->atype === "discorder") {
         $tag = trim((string) $Qreq->discordertag);
         $tag = $tag === "" ? "discuss" : $tag;
         $tagger = new Tagger();
         if (!($tag = $tagger->check($tag, Tagger::NOVALUE))) {
             $Error["discordertag"] = true;
             return Conf::msg_error($tagger->error_html);
         }
         $this->discordertag = $tag;
     }
     return $this->ok = true;
 }
コード例 #12
0
ファイル: generateTags.php プロジェクト: djnewtown/judge
<?php

/**
 * Generate tag file for use with MageCompatibility plugin for Judge
 */
if (count($argv) !== 2) {
    die('Please submit exactly one param: The path to the Magento root directory' . PHP_EOL);
}
$magentoDir = $argv[1];
if (substr($magentoDir, -1) !== '/') {
    $magentoDir .= '/';
}
if (!file_exists($magentoDir . '/app/Mage.php')) {
    die('Are you sure, there is a Magento? Couldn\'t find Mage.php!' . PHP_EOL);
}
$tagger = new Tagger($magentoDir);
$tagger->run();
class Tagger
{
    protected $_magentoDir;
    protected $_tagFile;
    protected $_edition;
    protected $_version;
    protected $_needed = array('function' => array('token_node' => T_FUNCTION, 'name_node' => T_STRING, 'node_type' => 'f', 'steps_to_name' => 1), 'class' => array('token_node' => T_CLASS, 'name_node' => T_STRING, 'node_type' => 'c', 'steps_to_name' => 1), 'define' => array('token_node' => T_STRING, 'name_node' => T_CONSTANT_ENCAPSED_STRING, 'node_type' => 'd', 'steps_to_name' => 2), 'interface' => array('token_node' => T_INTERFACE, 'name_node' => T_STRING, 'node_type' => 'i', 'steps_to_name' => 1));
    /**
     * @param string $magentoDir
     */
    public function __construct($magentoDir)
    {
        $this->_magentoDir = $magentoDir;
        $this->_verifyMagento();
コード例 #13
0
 public function save($req, $contact)
 {
     global $Conf, $Now;
     if (is_array($req)) {
         $req = (object) $req;
     }
     $Table = $this->prow->comment_table_name();
     $LinkTable = $this->prow->table_name();
     $LinkColumn = $this->prow->id_column();
     $req_visibility = get($req, "visibility");
     $is_response = !!($this->commentType & COMMENTTYPE_RESPONSE);
     if ($is_response && get($req, "submit")) {
         $ctype = COMMENTTYPE_RESPONSE | COMMENTTYPE_AUTHOR;
     } else {
         if ($is_response) {
             $ctype = COMMENTTYPE_RESPONSE | COMMENTTYPE_AUTHOR | COMMENTTYPE_DRAFT;
         } else {
             if ($req_visibility == "a" || $req_visibility == "au") {
                 $ctype = COMMENTTYPE_AUTHOR;
             } else {
                 if ($req_visibility == "p" || $req_visibility == "pc") {
                     $ctype = COMMENTTYPE_PCONLY;
                 } else {
                     if ($req_visibility == "admin") {
                         $ctype = COMMENTTYPE_ADMINONLY;
                     } else {
                         if ($this->commentId && $req_visibility === null) {
                             $ctype = $this->commentType;
                         } else {
                             // $req->visibility == "r" || $req->visibility == "rev"
                             $ctype = COMMENTTYPE_REVIEWER;
                         }
                     }
                 }
             }
         }
     }
     if ($is_response ? $this->prow->blind : $Conf->is_review_blind(!!get($req, "blind"))) {
         $ctype |= COMMENTTYPE_BLIND;
     }
     // tags
     if ($is_response) {
         $ctags = " response ";
         if (($rname = $Conf->resp_round_name($this->commentRound)) != "1") {
             $ctags .= "{$rname}response ";
         }
     } else {
         if (get($req, "tags") && preg_match_all(',\\S+,', $req->tags, $m)) {
             $tagger = new Tagger($contact);
             $ctags = array();
             foreach ($m[0] as $text) {
                 if (($text = $tagger->check($text, Tagger::NOVALUE)) && !stri_ends_with($text, "response")) {
                     $ctags[strtolower($text)] = $text;
                 }
             }
             $tagger->sort($ctags);
             $ctags = count($ctags) ? " " . join(" ", $ctags) . " " : null;
         } else {
             $ctags = null;
         }
     }
     // notifications
     $displayed = !($ctype & COMMENTTYPE_DRAFT);
     // query
     $text = get_s($req, "text");
     $q = "";
     $qv = array();
     if ($text === "" && $this->commentId) {
         $change = true;
         $q = "delete from {$Table} where commentId={$this->commentId}";
     } else {
         if ($text === "") {
             /* do nothing */
         } else {
             if (!$this->commentId) {
                 $change = true;
                 $qa = ["contactId, {$LinkColumn}, commentType, comment, commentOverflow, timeModified, replyTo"];
                 $qb = [$contact->contactId, $this->prow->{$LinkColumn}, $ctype, "?", "?", $Now, 0];
                 if (strlen($text) <= 32000) {
                     array_push($qv, $text, null);
                 } else {
                     array_push($qv, UnicodeHelper::utf8_prefix($text, 200), $text);
                 }
                 if ($ctags !== null) {
                     $qa[] = "commentTags";
                     $qb[] = "?";
                     $qv[] = $ctags;
                 }
                 if ($is_response) {
                     $qa[] = "commentRound";
                     $qb[] = $this->commentRound;
                 }
                 if ($displayed) {
                     $qa[] = "timeDisplayed, timeNotified";
                     $qb[] = "{$Now}, {$Now}";
                 }
                 $q = "insert into {$Table} (" . join(", ", $qa) . ") select " . join(", ", $qb) . "\n";
                 if ($is_response) {
                     // make sure there is exactly one response
                     $q .= " from (select {$LinkTable}.{$LinkColumn}, coalesce(commentId, 0) commentId\n                from {$LinkTable}\n                left join {$Table} on ({$Table}.{$LinkColumn}={$LinkTable}.{$LinkColumn} and (commentType&" . COMMENTTYPE_RESPONSE . ")!=0 and commentRound={$this->commentRound})\n                where {$LinkTable}.{$LinkColumn}={$this->prow->{$LinkColumn}} limit 1) t\n        where t.commentId=0";
                 }
             } else {
                 $change = $this->commentType >= COMMENTTYPE_AUTHOR != $ctype >= COMMENTTYPE_AUTHOR;
                 if ($this->timeModified >= $Now) {
                     $Now = $this->timeModified + 1;
                 }
                 // do not notify on updates within 3 hours
                 $qa = "";
                 if ($this->timeNotified + 10800 < $Now || $ctype & COMMENTTYPE_RESPONSE && !($ctype & COMMENTTYPE_DRAFT) && $this->commentType & COMMENTTYPE_DRAFT) {
                     $qa .= ", timeNotified={$Now}";
                 }
                 // reset timeDisplayed if you change the comment type
                 if ((!$this->timeDisplayed || $this->ordinal_missing($ctype)) && $text !== "" && $displayed) {
                     $qa .= ", timeDisplayed={$Now}";
                 }
                 $q = "update {$Table} set timeModified={$Now}{$qa}, commentType={$ctype}, comment=?, commentOverflow=?, commentTags=? where commentId={$this->commentId}";
                 if (strlen($text) <= 32000) {
                     array_push($qv, $text, null);
                 } else {
                     array_push($qv, UnicodeHelper::utf8_prefix($text, 200), $text);
                 }
                 $qv[] = $ctags;
             }
         }
     }
     $result = Dbl::qe_apply($q, $qv);
     if (!$result) {
         return false;
     }
     $cmtid = $this->commentId ?: $result->insert_id;
     if (!$cmtid) {
         return false;
     }
     // log
     $contact->log_activity("Comment {$cmtid} " . ($text !== "" ? "saved" : "deleted"), $this->prow->{$LinkColumn});
     // ordinal
     if ($text !== "" && $this->ordinal_missing($ctype)) {
         $this->save_ordinal($cmtid, $ctype, $Table, $LinkTable, $LinkColumn);
     }
     // reload
     if ($text !== "") {
         $comments = $this->prow->fetch_comments("commentId={$cmtid}");
         $this->merge($comments[$cmtid], $this->prow);
         if ($this->timeNotified == $this->timeModified) {
             self::$watching = $this;
             $this->prow->notify(WATCHTYPE_COMMENT, "CommentInfo::watch_callback", $contact);
             self::$watching = null;
         }
     } else {
         $this->commentId = 0;
         $this->comment = "";
         $this->commentTags = null;
     }
     return true;
 }
コード例 #14
0
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf;
     $papers = $ssel->selection();
     $act = $qreq->tagfn;
     $tagreq = trim(str_replace(",", " ", (string) $qreq->tag));
     $tags = preg_split('/\\s+/', $tagreq);
     if ($act == "da") {
         $otags = $tags;
         foreach ($otags as $t) {
             $tags[] = "all~" . preg_replace(',\\A.*~([^~]+)\\z', '$1', $t);
         }
         $act = "d";
     } else {
         if ($act == "sor") {
             shuffle($papers);
         }
     }
     $x = array("action,paper,tag\n");
     if ($act == "s" || $act == "so" || $act == "sos" || $act == "sor") {
         foreach ($tags as $t) {
             $x[] = "cleartag,all," . TagInfo::base($t) . "\n";
         }
     }
     if ($act == "s" || $act == "a") {
         $action = "tag";
     } else {
         if ($act == "d") {
             $action = "cleartag";
         } else {
             if ($act == "so" || $act == "sor" || $act == "ao") {
                 $action = "nexttag";
             } else {
                 if ($act == "sos" || $act == "aos") {
                     $action = "seqnexttag";
                 } else {
                     $action = null;
                 }
             }
         }
     }
     $assignset = new AssignmentSet($user, $user->privChair);
     if (count($papers) && $action) {
         foreach ($papers as $p) {
             foreach ($tags as $t) {
                 $x[] = "{$action},{$p},{$t}\n";
             }
         }
         $assignset->parse(join("", $x));
     } else {
         if (count($papers) && $act == "cr" && $user->privChair) {
             $source_tag = trim((string) $qreq->tagcr_source);
             if ($source_tag == "") {
                 $source_tag = substr($tagreq, 0, 2) == "~~" ? substr($tagreq, 2) : $tagreq;
             }
             $tagger = new Tagger($user);
             if ($tagger->check($tagreq, Tagger::NOPRIVATE | Tagger::NOVALUE) && $tagger->check($source_tag, Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE)) {
                 $r = new PaperRank($source_tag, $tagreq, $papers, $qreq->tagcr_gapless, "Search", "search");
                 $r->run($qreq->tagcr_method);
                 $r->apply($assignset);
                 $assignset->finish();
                 if ($qreq->q === "") {
                     $qreq->q = "order:{$tagreq}";
                 }
             } else {
                 $assignset->error($tagger->error_html);
             }
         }
     }
     if ($errors = join("<br />\n", $assignset->errors_html())) {
         if ($assignset->has_assigners()) {
             Conf::msg_warning("Some tag assignments were ignored:<br />\n{$errors}");
             $assignset->clear_errors();
         } else {
             Conf::msg_error($errors);
         }
     }
     $success = $assignset->execute();
     if (!$Conf->headerPrinted && $qreq->ajax) {
         $Conf->ajaxExit(array("ok" => $success));
     } else {
         if (!$Conf->headerPrinted && $success) {
             if (!$errors) {
                 $Conf->confirmMsg("Tags saved.");
             }
             $args = array("atab" => "tag");
             foreach (array("tag", "tagfn", "tagcr_method", "tagcr_source", "tagcr_gapless") as $arg) {
                 if (isset($qreq[$arg])) {
                     $args[$arg] = $qreq[$arg];
                 }
             }
             redirectSelf($args);
         }
     }
 }
コード例 #15
0
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;
    }
}
コード例 #16
0
ファイル: Tagger_Always.php プロジェクト: rmourembles/resto
 /**
  * Constructor
  * 
  * @param DatabaseHandler $dbh
  * @param array $config
  */
 public function __construct($dbh, $config)
 {
     parent::__construct($dbh, $config);
 }
コード例 #17
0
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf;
     $settingrank = $Conf->setting("tag_rank") && $qreq->tag == "~" . $Conf->setting_data("tag_rank");
     if (!$user->isPC && !($user->is_reviewer() && $settingrank)) {
         return self::EPERM;
     }
     $tagger = new Tagger($user);
     if ($tag = $tagger->check($qreq->tag, Tagger::NOVALUE | Tagger::NOCHAIR)) {
         $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "tagIndex" => $tag, "order" => "order by tagIndex, PaperReview.overAllMerit desc, Paper.paperId")));
         $real = "";
         $null = "\n";
         while ($prow = PaperInfo::fetch($result, $user)) {
             if ($user->can_change_tag($prow, $tag, null, 1)) {
                 if ($prow->tagIndex === null) {
                     $null .= "X\t{$prow->paperId}\t{$prow->title}\n";
                 } else {
                     if ($real === "" || $lastIndex == $row->tagIndex - 1) {
                         $real .= "\t{$prow->paperId}\t{$prow->title}\n";
                     } else {
                         if ($lastIndex == $row->tagIndex) {
                             $real .= "=\t{$prow->paperId}\t{$prow->title}\n";
                         } else {
                             $real .= str_pad("", min($prow->tagIndex - $lastIndex, 5), ">") . "\t{$prow->paperId}\t{$prow->title}\n";
                         }
                     }
                 }
                 $lastIndex = $prow->tagIndex;
             }
         }
         $text = "# Edit the rank order by rearranging this file's lines.\n\n# The first line has the highest rank. Lines starting with \"#\" are\n# ignored. Unranked papers appear at the end in lines starting with\n# \"X\", sorted by overall merit. Create a rank by removing the \"X\"s and\n# rearranging the lines. Lines starting with \"=\" mark papers with the\n# same rank as the preceding papers. Lines starting with \">>\", \">>>\",\n# and so forth indicate rank gaps between papers. When you are done,\n# upload the file at\n" . "#   " . hoturl_absolute("offline") . "\n\n" . "Tag: " . trim($qreq->tag) . "\n" . "\n" . $real . $null;
         downloadText($text, "rank");
     } else {
         Conf::msg_error($tagger->error_html);
     }
 }
コード例 #18
0
 public function prepare(PaperList $pl, $visible)
 {
     if (!$pl->contact->can_view_tags(null)) {
         return false;
     }
     if (!$this->dtag && $visible === PaperColumn::PREP_COMPLETION) {
         return true;
     }
     $tagger = new Tagger($pl->contact);
     if (!($ctag = $tagger->check($this->dtag, Tagger::NOVALUE | Tagger::ALLOWCONTACTID))) {
         return false;
     }
     $this->ctag = strtolower(" {$ctag}#");
     if ($visible) {
         $pl->qopts["tags"] = 1;
     }
     $this->className = $this->is_value ? "pl_tagval" : "pl_tag";
     return true;
 }
コード例 #19
0
function do_tags()
{
    global $Conf, $Me, $papersel;
    // check tags
    $tagger = new Tagger($Me);
    $t1 = array();
    $errors = array();
    foreach (preg_split('/[\\s,]+/', (string) @$_REQUEST["tag"]) as $t) {
        if ($t === "") {
            /* nada */
        } else {
            if (!($t = $tagger->check($t, Tagger::NOPRIVATE))) {
                $errors[] = $tagger->error_html;
            } else {
                if (TagInfo::base($t) === "pc") {
                    $errors[] = "The “pc” user tag is set automatically for all PC members.";
                } else {
                    $t1[] = $t;
                }
            }
        }
    }
    if (count($errors)) {
        return Conf::msg_error(join("<br>", $errors));
    } else {
        if (!count($t1)) {
            return $Conf->warnMsg("Nothing to do.");
        }
    }
    // modify database
    Dbl::qe("lock tables ContactInfo write");
    Conf::$no_invalidate_caches = true;
    $users = array();
    if ($_REQUEST["tagtype"] === "s") {
        // erase existing tags
        $likes = array();
        $removes = array();
        foreach ($t1 as $t) {
            list($tag, $index) = TagInfo::split_index($t);
            $removes[] = $t;
            $likes[] = "contactTags like " . Dbl::utf8ci("'% " . sqlq_for_like($tag) . "#%'");
        }
        foreach (Dbl::fetch_first_columns(Dbl::qe("select contactId from ContactInfo where " . join(" or ", $likes))) as $cid) {
            $users[(int) $cid] = (object) array("id" => (int) $cid, "add_tags" => [], "remove_tags" => $removes);
        }
    }
    // account for request
    $key = $_REQUEST["tagtype"] === "d" ? "remove_tags" : "add_tags";
    foreach ($papersel as $cid) {
        if (!isset($users[(int) $cid])) {
            $users[(int) $cid] = (object) array("id" => (int) $cid, "add_tags" => [], "remove_tags" => []);
        }
        $users[(int) $cid]->{$key} = array_merge($users[(int) $cid]->{$key}, $t1);
    }
    // apply modifications
    foreach ($users as $cid => $cj) {
        $us = new UserStatus(array("send_email" => false));
        if (!$us->save($cj)) {
            $errors = array_merge($errors, $us->error_messages());
        }
    }
    Dbl::qe("unlock tables");
    Conf::$no_invalidate_caches = false;
    $Conf->invalidateCaches(["pc" => true]);
    // report
    if (!count($errors)) {
        $Conf->confirmMsg("Tags saved.");
        redirectSelf(array("tagact" => null, "tag" => null));
    } else {
        Conf::msg_error(join("<br>", $errors));
    }
}
コード例 #20
0
 public function add_tag_info_json($pj, Contact $user)
 {
     if (!property_exists($this, "paperTags")) {
         $this->load_tags();
     }
     $tagger = new Tagger($user);
     $editable = $this->editable_tags($user);
     $viewable = $this->viewable_tags($user);
     $tags_view_html = $tagger->unparse_and_link($viewable, $this->paperTags, false);
     $pj->tags = TagInfo::split($viewable);
     $pj->tags_edit_text = $tagger->unparse($editable);
     $pj->tags_view_html = $tags_view_html;
     $pj->color_classes = TagInfo::color_classes($viewable);
 }
コード例 #21
0
 public function compile(FormulaCompiler $state)
 {
     $state->queryOptions["tags"] = true;
     $tagger = new Tagger($state->contact);
     $e_tag = $tagger->check($this->tag);
     $t_tags = $state->define_gvar("tags", "\$contact->can_view_tags(\$prow, \$forceShow) ? \$prow->all_tags_text() : \"\"");
     $t_tagpos = $state->define_gvar("tagpos_{$this->tag}", "stripos({$t_tags}, \" {$e_tag}#\")");
     $t_tagval = $state->define_gvar("tagval_{$this->tag}", "({$t_tagpos} !== false ? (float) substr({$t_tags}, {$t_tagpos} + " . (strlen($e_tag) + 2) . ") : false)");
     if ($this->isvalue) {
         return $t_tagval;
     } else {
         return "({$t_tagval} !== (float) 0 ? {$t_tagval} : true)";
     }
 }
コード例 #22
0
function parse_value($sv, $name, $info)
{
    global $Conf, $Me, $Now, $Opt;
    if (!isset($sv->req[$name])) {
        $xname = str_replace(".", "_", $name);
        if (isset($sv->req[$xname])) {
            $sv->req[$name] = $sv->req[$xname];
        } else {
            if ($info->type === "checkbox" || $info->type === "cdate") {
                return 0;
            } else {
                return null;
            }
        }
    }
    $v = trim($sv->req[$name]);
    if ($info->placeholder && $info->placeholder === $v || $info->invalid_value && $info->invalid_value === $v) {
        $v = "";
    }
    if ($info->type === "checkbox") {
        return $v != "" ? 1 : 0;
    } else {
        if ($info->type === "cdate" && $v == "1") {
            return 1;
        } else {
            if ($info->type === "date" || $info->type === "cdate" || $info->type === "ndate") {
                if ($v == "" || !strcasecmp($v, "N/A") || !strcasecmp($v, "same as PC") || $v == "0" || $info->type !== "ndate" && !strcasecmp($v, "none")) {
                    return -1;
                } else {
                    if (!strcasecmp($v, "none")) {
                        return 0;
                    } else {
                        if (($v = $Conf->parse_time($v)) !== false) {
                            return $v;
                        } else {
                            $err = unparse_setting_error($info, "Invalid date.");
                        }
                    }
                }
            } else {
                if ($info->type === "grace") {
                    if (($v = parseGrace($v)) !== null) {
                        return intval($v);
                    } else {
                        $err = unparse_setting_error($info, "Invalid grace period.");
                    }
                } else {
                    if ($info->type === "int" || $info->type === "zint") {
                        if (preg_match("/\\A[-+]?[0-9]+\\z/", $v)) {
                            return intval($v);
                        } else {
                            $err = unparse_setting_error($info, "Should be a number.");
                        }
                    } else {
                        if ($info->type === "string") {
                            // Avoid storing the default message in the database
                            if (substr($name, 0, 9) == "mailbody_") {
                                $t = expandMailTemplate(substr($name, 9), true);
                                $v = cleannl($v);
                                if ($t["body"] == $v) {
                                    return "";
                                }
                            }
                            return $v;
                        } else {
                            if ($info->type === "simplestring") {
                                return simplify_whitespace($v);
                            } else {
                                if ($info->type === "tag" || $info->type === "tagbase") {
                                    $tagger = new Tagger($Me);
                                    $v = trim($v);
                                    if ($v === "" && $info->optional) {
                                        return $v;
                                    }
                                    $v = $tagger->check($v, $info->type === "tagbase" ? Tagger::NOVALUE : 0);
                                    if ($v) {
                                        return $v;
                                    }
                                    $err = unparse_setting_error($info, $tagger->error_html);
                                } else {
                                    if ($info->type === "emailheader") {
                                        $v = MimeText::encode_email_header("", $v);
                                        if ($v !== false) {
                                            return $v == "" ? "" : MimeText::decode_header($v);
                                        }
                                        $err = unparse_setting_error($info, "Invalid email header.");
                                    } else {
                                        if ($info->type === "emailstring") {
                                            $v = trim($v);
                                            if ($v === "" && $info->optional) {
                                                return "";
                                            } else {
                                                if (validate_email($v) || $v === $v_active) {
                                                    return $v;
                                                } else {
                                                    $err = unparse_setting_error($info, "Invalid email.");
                                                }
                                            }
                                        } else {
                                            if ($info->type === "urlstring") {
                                                $v = trim($v);
                                                if ($v === "" && $info->optional || preg_match(',\\A(?:https?|ftp)://\\S+\\z,', $v)) {
                                                    return $v;
                                                } else {
                                                    $err = unparse_setting_error($info, "Invalid URL.");
                                                }
                                            } else {
                                                if ($info->type === "htmlstring") {
                                                    if (($v = CleanHTML::basic_clean($v, $err)) === false) {
                                                        $err = unparse_setting_error($info, $err);
                                                    } else {
                                                        if ($info->message_default && $v === $Conf->message_default_html($info->message_default)) {
                                                            return "";
                                                        } else {
                                                            return $v;
                                                        }
                                                    }
                                                } else {
                                                    if ($info->type === "radio") {
                                                        foreach ($info->values as $allowedv) {
                                                            if ((string) $allowedv === $v) {
                                                                return $allowedv;
                                                            }
                                                        }
                                                        $err = unparse_setting_error($info, "Parse error (unexpected value).");
                                                    } else {
                                                        return $v;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $sv->set_error($name, $err);
    return null;
}
コード例 #23
0
 private function make_tags_array($x, $key)
 {
     $t0 = array();
     if (is_string($x)) {
         $t0 = preg_split("/[\\s,]+/", $x);
     } else {
         if (is_array($x)) {
             $t0 = $x;
         } else {
             if ($x !== null) {
                 $this->set_error($key, "Format error [{$key}]");
             }
         }
     }
     $tagger = new Tagger();
     $t1 = array();
     foreach ($t0 as $t) {
         if ($t !== "" && ($t = $tagger->check($t, Tagger::NOPRIVATE))) {
             $t1[] = $t;
         } else {
             if ($t !== "") {
                 $this->set_error($key, $tagger->error_html);
             }
         }
     }
     return $t1;
 }
コード例 #24
0
 function viewable_tags(Contact $user)
 {
     if ($user->isPC) {
         $tags = $this->all_contact_tags();
         return Tagger::strip_nonviewable($tags, $user);
     } else {
         return "";
     }
 }
コード例 #25
0
require '../TermExtractor.php';
// Filters
// -------
// Permissive - accept everything
//require '../TermExtractor/PermissiveFilter.php';
//$filter = new PermissiveFilter();
// Default - accept terms based on occurrence and word count
// min_occurrence - specify the number of times the term must appear in the original text for it be accepted.
// keep_if_strength - keep a term if the term's word count is equal to or greater than this, regardless of occurrence.
require '../DefaultFilter.php';
$filter = new DefaultFilter($min_occurrence = 2, $keep_if_strength = 2);
// Tagger
// ------
// Create Tagger instance.
// English is the only supported language at the moment.
$tagger = new Tagger('english');
// Initialise the Tagger instance.
// Use APC if available to store the dictionary file in memory
// (otherwise it gets loaded from disk every time the Tagger is initialised).
$tagger->initialize($use_apc = true);
// Term Extractor
// --------------
// Creater TermExtractor instance
$extractor = new TermExtractor($tagger, $filter);
// Extract terms from the text
$terms = $extractor->extract($text);
// We're outputting results in plain text...
header('Content-Type: text/plain; charset=UTF-8');
// Loop through extracted terms and print each term on a new line
foreach ($terms as $term_info) {
    // index 0: term
コード例 #26
0
 private function _prepare_sort()
 {
     global $Conf;
     $this->default_sort_column = PaperColumn::lookup("id");
     $this->sorters[0]->field = null;
     if ($this->search->sorters) {
         foreach ($this->search->sorters as $sorter) {
             if ($sorter->type && ($field = PaperColumn::lookup($sorter->type)) && $field->prepare($this, PaperColumn::PREP_SORT) && $field->comparator) {
                 $sorter->field = $field;
             } else {
                 if ($sorter->type) {
                     if ($this->contact->can_view_tags(null) && ($tagger = new Tagger()) && ($tag = $tagger->check($sorter->type)) && ($result = Dbl::qe("select paperId from PaperTag where tag=? limit 1", $tag)) && edb_nrows($result)) {
                         $this->search->warn("Unrecognized sort “" . htmlspecialchars($sorter->type) . "”. Did you mean “sort:#" . htmlspecialchars($sorter->type) . "”?");
                     } else {
                         $this->search->warn("Unrecognized sort “" . htmlspecialchars($sorter->type) . "”.");
                     }
                     continue;
                 }
             }
             ListSorter::push($this->sorters, $sorter);
         }
         if (count($this->sorters) > 1 && $this->sorters[0]->empty) {
             array_shift($this->sorters);
         }
     }
     if (get($this->sorters[0], "field")) {
         /* all set */
     } else {
         if ($this->sorters[0]->type && ($c = PaperColumn::lookup($this->sorters[0]->type)) && $c->prepare($this, PaperColumn::PREP_SORT)) {
             $this->sorters[0]->field = $c;
         } else {
             $this->sorters[0]->field = $this->default_sort_column;
         }
     }
     $this->sorters[0]->type = $this->sorters[0]->field->name;
     // set defaults
     foreach ($this->sorters as $s) {
         if ($s->reverse === null) {
             $s->reverse = false;
         }
         if ($s->score === null) {
             $s->score = ListSorter::default_score_sort();
         }
     }
 }
コード例 #27
0
function setTagIndexes()
{
    global $Conf, $Me, $Error;
    $filename = null;
    if (isset($_REQUEST["upload"]) && fileUploaded($_FILES["file"])) {
        if (($text = file_get_contents($_FILES["file"]["tmp_name"])) === false) {
            Conf::msg_error("Internal error: cannot read file.");
            return;
        }
        $filename = @$_FILES["file"]["name"];
    } else {
        if (!($text = defval($_REQUEST, "data"))) {
            Conf::msg_error("Choose a file first.");
            return;
        }
    }
    $RealMe = $Me;
    $tagger = new Tagger();
    if ($tag = defval($_REQUEST, "tag")) {
        $tag = $tagger->check($tag, Tagger::NOVALUE);
    }
    $curIndex = 0;
    $lineno = 1;
    $settings = $titles = $linenos = $errors = array();
    foreach (explode("\n", rtrim(cleannl($text))) as $l) {
        if (substr($l, 0, 4) == "Tag:" || substr($l, 0, 6) == "# Tag:") {
            if (!$tag) {
                $tag = $tagger->check(trim(substr($l, $l[0] == "#" ? 6 : 4)), Tagger::NOVALUE);
            }
            ++$lineno;
            continue;
        } else {
            if ($l == "" || $l[0] == "#") {
                ++$lineno;
                continue;
            }
        }
        if (preg_match('/\\A\\s*?([Xx=]|>*|\\([-\\d]+\\))\\s+(\\d+)\\s*(.*?)\\s*\\z/', $l, $m)) {
            if (isset($settings[$m[2]])) {
                $errors[$lineno] = "Paper #{$m['2']} already given on line " . $linenos[$m[2]];
            }
            if ($m[1] == "X" || $m[1] == "x") {
                $settings[$m[2]] = null;
            } else {
                if ($m[1] == "" || $m[1] == ">") {
                    $settings[$m[2]] = $curIndex = $curIndex + 1;
                } else {
                    if ($m[1][0] == "(") {
                        $settings[$m[2]] = $curIndex = substr($m[1], 1, -1);
                    } else {
                        if ($m[1] == "=") {
                            $settings[$m[2]] = $curIndex;
                        } else {
                            $settings[$m[2]] = $curIndex = $curIndex + strlen($m[1]);
                        }
                    }
                }
            }
            $titles[$m[2]] = $m[3];
            $linenos[$m[2]] = $lineno;
        } else {
            if ($RealMe->privChair && preg_match('/\\A\\s*<\\s*([^<>]*?(|<[^<>]*>))\\s*>\\s*\\z/', $l, $m)) {
                if (count($settings) && $Me) {
                    saveTagIndexes($tag, $filename, $settings, $titles, $linenos, $errors);
                }
                $ret = ContactSearch::make_pc($m[1], $RealMe);
                $Me = null;
                if (count($ret->ids) == 1) {
                    $Me = $ret->contact(0);
                } else {
                    if (count($ret->ids) == 0) {
                        $errors[$lineno] = htmlspecialchars($m[1]) . " matches no PC member";
                    } else {
                        $errors[$lineno] = htmlspecialchars($m[1]) . " matches more than one PC member, give a full email address to disambiguate";
                    }
                }
            } else {
                if (trim($l) !== "") {
                    $errors[$lineno] = "Syntax error";
                }
            }
        }
        ++$lineno;
    }
    if (count($settings) && $Me) {
        saveTagIndexes($tag, $filename, $settings, $titles, $linenos, $errors);
    }
    $Me = $RealMe;
    if (count($errors)) {
        ksort($errors);
        if ($filename) {
            foreach ($errors as $lineno => &$error) {
                $error = '<span class="lineno">' . htmlspecialchars($filename) . ':' . $lineno . ':</span> ' . $error;
            }
        }
        $Error["tags"] = '<div class="parseerr"><p>' . join("</p>\n<p>", $errors) . '</p></div>';
    }
    if (isset($Error["tags"])) {
        Conf::msg_error($Error["tags"]);
    } else {
        if (isset($_REQUEST["setvote"])) {
            $Conf->confirmMsg("Votes saved.");
        } else {
            $Conf->confirmMsg("Ranking saved.  To view it, <a href='" . hoturl("search", "q=order:" . urlencode($tag)) . "'>search for &ldquo;order:{$tag}&rdquo;</a>.");
        }
    }
}