-
Notifications
You must be signed in to change notification settings - Fork 86
/
ajax_word_counts.php
46 lines (36 loc) · 1.68 KB
/
ajax_word_counts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**************************************************************
"Learning with Texts" (LWT) is released into the Public Domain.
This applies worldwide.
In case this is not legally possible, any entity is granted the
right to use this work for any purpose, without any conditions,
unless such conditions are required by law.
Developed by J. Pierre in 2011
***************************************************************/
/**************************************************************
Call: ajax_word_counts.php?id=[textid]
Calculating Word Counts, Ajax call in edit_texts.php
***************************************************************/
include "connect.inc.php";
include "settings.inc.php";
include "utilities.inc.php";
$id = $_POST["id"] + 0;
$txttotalwords = textwordcount($id);
$txtworkedwords = textworkcount($id);
$txtworkedexpr = textexprcount($id);
$txtworkedall = $txtworkedwords + $txtworkedexpr;
$txttodowords = $txttotalwords - $txtworkedwords;
$percentunknown = 0;
if ($txttotalwords != 0) {
$percentunknown =
round(100*$txttodowords/$txttotalwords,0);
if ($percentunknown > 100) $percentunknown = 100;
if ($percentunknown < 0) $percentunknown = 0;
}
$r = array();
$r[] = '<span title="Total"> ' . $txttotalwords . ' </span>';
$r[] = '<span title="Saved" class="status4"> ' . ($txtworkedall > 0 ? '<a href="edit_words.php?page=1&query=&status=&tag12=0&tag2=&tag1=&text=' . $id . '">' . $txtworkedwords . '+' . $txtworkedexpr . '</a>' : '0' ) . ' ';
$r[] = '<span title="Unknown" class="status0"> ' . $txttodowords . ' </span>';
$r[] = '<span title="Unknown (%)">' . $percentunknown . '</span></td>';
echo json_encode($r);
?>