-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.php
159 lines (154 loc) · 7.93 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* $Id$
*
*
*/
header('Content-Type: text/html; charset=UTF-8');
ini_set ( 'display_errors', true );
ini_set ( 'include_path', './src' . PATH_SEPARATOR . ini_get ( 'include_path'));
require_once 'Org/Heigl/Hyphenator/Hyphenator.php';
\Org\Heigl\Hyphenator\Hyphenator::registerAutoload();
if ( ! isset ( $_REQUEST ['language'] ) ) {
$_REQUEST ['language'] = 'de_DE';
}
if ( ! isset ( $_REQUEST ['text'] ) ) {
$_REQUEST ['text'] = '';
}
if ( ! isset ( $_REQUEST ['quality'] ) ) {
$_REQUEST ['quality'] = '9';
}
if ( ! isset ( $_REQUEST ['leftMin'] ) ) {
$_REQUEST ['leftMin'] = '2';
}
if ( ! isset ( $_REQUEST ['rightMin'] ) ) {
$_REQUEST ['rightMin'] = '2';
}
if ( ! isset ( $_REQUEST ['wordMin'] ) ) {
$_REQUEST ['wordMin'] = '5';
}
if ( ! isset ( $_REQUEST ['customHyphen'] ) ) {
$_REQUEST ['customHyphen'] = '-';
}
if ( ! isset ( $_REQUEST ['noHyphenateMarker'] ) ) {
$_REQUEST ['noHyphenateMarker'] = 'nbr:';
}
if ( ! isset ( $_REQUEST ['usePdflib'] ) ) {
$_REQUEST ['usePdflib'] = false;
}
if ( ! isset ( $_REQUEST ['fontsize'] ) ) {
$_REQUEST ['fontsize'] = 9;
}
if ( ! isset ( $_REQUEST ['adjustmethod'] ) ) {
$_REQUEST ['adjustmethod'] = 'auto';
}
if ( ! isset ( $_REQUEST ['alignment'] ) ) {
$_REQUEST['alignment'] = 'left';
}
if ( ! isset ( $_REQUEST ['maxspacing'] ) ) {
$_REQUEST['maxspacing'] = '500';
}
if ( ! isset ( $_REQUEST ['minspacing'] ) ) {
$_REQUEST['minspacing'] = '50';
}
if ( ! isset ( $_REQUEST ['nofitlimit'] ) ) {
$_REQUEST['nofitlimit'] = '50';
}
if ( ! isset ( $_REQUEST ['shrinklimit'] ) ) {
$_REQUEST['shrinklimit'] = '85';
}
if ( ! isset ( $_REQUEST ['spreadlimit'] ) ) {
$_REQUEST['spreadlimit'] = '0';
}
if ( ! isset ( $_REQUEST ['charspacing'] ) ) {
$_REQUEST['charspacing'] = '100';
}
echo '<?xml version="1.0" ?'.'>'
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hyphenation-Tests</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<meta http-equiv="Content-type" value="text/html; charset=UTF-8"/>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<legend>Text to hyphenate</legend>
<textarea name="text"><?php echo $_REQUEST['text']; ?></textarea>
</fieldset>
<fieldset>
<legend>Hyphenator-Options</legend>
<label for="language">Language</label>
<select size="1" name="language">
<option <?php echo ('de_DE' === $_REQUEST['language'])?'selected="selected"':'';?>value="de_DE">German</option>
<option <?php echo ('en_GB' === $_REQUEST['language'])?'selected="selected"':'';?>value="en_GB">British English</option>
<option <?php echo ('en_US' === $_REQUEST['language'])?'selected="selected"':'';?>value="en_US">American English</option>
<option <?php echo ('hu_HU' === $_REQUEST['language'])?'selected="selected"':'';?>value="hu_HU">Hungarian</option>
</select>
<label for="quality">Quality</label>
<select size="1" name="quality">
<option <?php echo ('1' === $_REQUEST['quality'])?'selected="selected"':'';?>value="1">Best</option>
<option <?php echo ('3' === $_REQUEST['quality'])?'selected="selected"':'';?>value="3">Better</option>
<option <?php echo ('5' === $_REQUEST['quality'])?'selected="selected"':'';?>value="5">Normal</option>
<option <?php echo ('7' === $_REQUEST['quality'])?'selected="selected"':'';?>value="7">Poorer</option>
<option <?php echo ('9' === $_REQUEST['quality'])?'selected="selected"':'';?>value="9">Poorest</option>
</select>
<label for="leftMin">Minimum Characters on the left</label>
<select size="1" name="leftMin">
<option <?php echo ('2' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="2">2</option>
<option <?php echo ('3' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="3">3</option>
<option <?php echo ('4' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="4">4</option>
<option <?php echo ('5' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="5">5</option>
<option <?php echo ('6' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="6">6</option>
<option <?php echo ('7' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="7">7</option>
<option <?php echo ('8' === $_REQUEST['leftMin'])?'selected="selected"':'';?>value="8">8</option>
</select>
<label for="rightMin">Minimum Characters on the right</label>
<select size="1" name="rightMin">
<option <?php echo ('2' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="2">2</option>
<option <?php echo ('3' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="3">3</option>
<option <?php echo ('4' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="4">4</option>
<option <?php echo ('5' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="5">5</option>
<option <?php echo ('6' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="6">6</option>
<option <?php echo ('7' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="7">7</option>
<option <?php echo ('8' === $_REQUEST['rightMin'])?'selected="selected"':'';?>value="8">8</option>
</select>
<label for="wordMin">Minimum length of a word</label>
<select size="1" name="wordMin">
<option <?php echo ('2' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="2">2</option>
<option <?php echo ('3' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="3">3</option>
<option <?php echo ('4' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="4">4</option>
<option <?php echo ('5' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="5">5</option>
<option <?php echo ('6' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="6">6</option>
<option <?php echo ('7' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="7">7</option>
<option <?php echo ('8' === $_REQUEST['wordMin'])?'selected="selected"':'';?>value="8">8</option>
</select>
<label for="customHyphen">Custom Hyphen-String</label>
<input type="text" name="customHyphen" value="<?php echo $_REQUEST['customHyphen']; ?>" />
</fieldset>
<fieldset class="buttons">
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</fieldset>
</form>
<div class="result">
<?php
$hyphenator = \Org\Heigl\Hyphenator\Hyphenator::factory(null,$_REQUEST['language']);
$hyphenator->getOptions()
->setHyphen($_REQUEST['customHyphen'])
->setLeftMin ( $_REQUEST ['leftMin'])
->setRightMin ( $_REQUEST ['rightMin'])
->setWordMin ( $_REQUEST ['wordMin'])
->setQuality ( $_REQUEST ['quality']);
$hyphenated = $hyphenator->hyphenate($_REQUEST['text']);
echo '<span>' . $hyphenated . '</span>';
?>
</div>
<div class="result">
<?php echo $_REQUEST['text']; ?>
</div>
</body>
</html>