<?php require 'lib/header.php'; require_once 'lib/lib_xml.php'; require_once 'lib/lib_history.php'; $lemma_id = (int) $_GET['lemma_id']; $set_id = (int) $_GET['set_id']; $smarty->assign('diff', dict_diff($lemma_id, $set_id)); $smarty->display('dict/diff.tpl'); log_timing();
function get_pending_updates($skip = 0, $limit = 500) { check_permission(PERM_DICT); $out = array('revisions' => array(), 'header' => array()); $r = sql_fetch_array(sql_query("SELECT COUNT(*) cnt FROM updated_tokens")); $out['cnt_tokens'] = $r['cnt']; $r = sql_fetch_array(sql_query("SELECT COUNT(*) cnt FROM updated_forms")); $out['cnt_forms'] = $r['cnt']; $res = sql_query("SELECT rev_id FROM dict_revisions WHERE f2l_check=0 LIMIT 1"); $out['outdated_f2l'] = sql_num_rows($res); // header $res = sql_query("\n SELECT dict_revision, lemma_id, lemma_text, COUNT(token_id) AS cnt\n FROM updated_tokens ut\n LEFT JOIN dict_revisions dr ON (ut.dict_revision = dr.rev_id)\n LEFT JOIN dict_lemmata dl USING (lemma_id)\n GROUP BY dict_revision\n ORDER BY dict_revision\n "); $sum = 0; // to count pages while ($r = sql_fetch_array($res)) { $out['header'][] = array('lemma' => $r['lemma_text'], 'lemma_id' => $r['lemma_id'], 'revision' => $r['dict_revision'], 'count' => $r['cnt'], 'skip' => $sum); $sum += $r['cnt']; } // main table $res = sql_pe("\n SELECT token_id, tf_text, sent_id, dict_revision, lemma_id, dr.set_id,\n tfr.rev_text AS token_rev_text\n FROM updated_tokens ut\n LEFT JOIN dict_revisions dr ON (ut.dict_revision = dr.rev_id)\n LEFT JOIN tokens tf ON (ut.token_id = tf.tf_id)\n LEFT JOIN tf_revisions tfr USING (tf_id)\n WHERE tfr.is_last = 1\n ORDER BY dict_revision, token_id\n LIMIT ?, ?\n ", array($skip, $limit)); $out['pages'] = array('active' => $limit ? floor($skip / $limit) : 0, 'total' => $limit ? $out['cnt_tokens'] / $limit : 1); $t = array(); $last = NULL; foreach ($res as $r) { if ($last && $last['dict_revision'] != $r['dict_revision']) { $out['revisions'][] = array('tokens' => $t, 'id' => $last['dict_revision'], 'diff' => dict_diff($last['lemma_id'], $last['set_id'])); $t = array(); } $context = get_context_for_word($r['token_id'], 4); $context['context'][$context['mainword']] = '<b>' . htmlspecialchars($context['context'][$context['mainword']]) . '</b>'; $t[] = array('id' => $r['token_id'], 'text' => $r['tf_text'], 'sentence_id' => $r['sent_id'], 'context' => join(' ', $context['context']), 'is_unkn' => preg_match('/v="UNKN"/', $r['token_rev_text']), 'human_edits' => check_for_human_edits($r['token_id'])); $last = $r; } if (sizeof($t)) { $out['revisions'][] = array('tokens' => $t, 'id' => $last['dict_revision'], 'diff' => dict_diff($last['lemma_id'], $last['set_id'])); } return $out; }