Extract UI lib from Utils.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
include_once "config.php";
|
include_once "config.php";
|
||||||
include_once "utils.php";
|
include_once "utils.php";
|
||||||
|
include_once "ui.php";
|
||||||
|
|
||||||
$Commands=array();
|
$Commands=array();
|
||||||
|
|
||||||
@@ -20,9 +21,9 @@ function ExecCommand($command){
|
|||||||
function ShowCommandLog(){
|
function ShowCommandLog(){
|
||||||
global $Commands;
|
global $Commands;
|
||||||
foreach($Commands as $loggedCommand){
|
foreach($Commands as $loggedCommand){
|
||||||
DrawParagraph($loggedCommand["Command"],"font-weight: bold;");
|
echo RenderParagraph($loggedCommand["Command"],"font-weight: bold;");
|
||||||
DrawParagraph($loggedCommand["Result"]);
|
echo RenderParagraph($loggedCommand["Result"]);
|
||||||
DrawParagraph($loggedCommand["Error"],"color: red;");
|
echo RenderParagraph($loggedCommand["Error"],"color: red;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +111,11 @@ if(RequestParm("btnScan",false)){
|
|||||||
echo '<form id="frmMain" method="GET" action="index.php">'."\n";
|
echo '<form id="frmMain" method="GET" action="index.php">'."\n";
|
||||||
|
|
||||||
// Render header info
|
// Render header info
|
||||||
DrawFieldInfo("Scanner",$SaneScanner);
|
echo RenderFieldInfo("Scanner",$SaneScanner);
|
||||||
DrawFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution);
|
echo RenderFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution);
|
||||||
DrawFieldCombo("Format","ddlFormat",$Formats,$Format);
|
echo RenderFieldCombo("Format","ddlFormat",$Formats,$Format);
|
||||||
DrawFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz);
|
echo RenderFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz);
|
||||||
DrawButton("Scan","btnScan");
|
echo RenderFieldButton("","btnScan","Scan");
|
||||||
if($DestFile!=null){
|
if($DestFile!=null){
|
||||||
$DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8");
|
$DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8");
|
||||||
echo '<div><a href="'.$DestFileFixed.'">'.
|
echo '<div><a href="'.$DestFileFixed.'">'.
|
||||||
@@ -125,4 +126,4 @@ if($DestFile!=null){
|
|||||||
|
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
ShowCommandLog();
|
ShowCommandLog();
|
||||||
?>
|
|
||||||
|
|||||||
147
code/ui.php
Normal file
147
code/ui.php
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function RenderLabel($text){
|
||||||
|
if($text!="" && $text!=null){
|
||||||
|
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
||||||
|
return '<span class="fieldLabel">'.$textFixed.":</span>\n";
|
||||||
|
}else{
|
||||||
|
return '<span class="fieldLabel"></span>'."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderInfo($text){
|
||||||
|
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
||||||
|
return '<div class="fieldContent">'.$textFixed."</div>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderText($idText,$value){
|
||||||
|
$idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8");
|
||||||
|
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
||||||
|
$render='<div class="fieldContent">'."\n";
|
||||||
|
$render.='<input type="text" id="'.$idTextFixed.'" name="'.$idTextFixed.'"'.
|
||||||
|
' value="'.$valueFixed.'" '.
|
||||||
|
' class="textBox"/>'."\n";
|
||||||
|
$render.="</div>\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderCheck($idCheck,$checked,$value){
|
||||||
|
$idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8");
|
||||||
|
$valueFixed=htmlentities($idText,ENT_HTML5, "UTF-8");
|
||||||
|
$render='<div class="fieldContent">'."\n";
|
||||||
|
$render.='<input type="checkbox" id="'.$idCheckFixed.'" '.
|
||||||
|
'name="'.$idCheckFixed.'" ';
|
||||||
|
if($checked){ $render.=" checked "; }
|
||||||
|
$render.='class="check">'.$valueFixed."\n";
|
||||||
|
$render.="</input>\n";
|
||||||
|
$render.="</div>\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function RenderCheckText($idCheck,$checked,$idText,$value){
|
||||||
|
$idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8");
|
||||||
|
$idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8");
|
||||||
|
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
||||||
|
$render='<div class="fieldContent">'."\n";
|
||||||
|
$render.='<input type="checkbox" id="'.$idCheckFixed.'" '.
|
||||||
|
'name="'.$idCheckFixed.'" ';
|
||||||
|
if($checked){ $render.=" checked "; }
|
||||||
|
$render.='class="check" />'."\n";
|
||||||
|
$render.='<input type="text" id="'.$idTextFixed.'" name="'.$idTextFixed.'" '.
|
||||||
|
'value="'.$valueFixed.'" class="textBox" />';
|
||||||
|
$render.="</input>\n";
|
||||||
|
$render.="</div>\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderCombo($id,$options,$selected){
|
||||||
|
$idFixed=htmlentities($id,ENT_HTML5, "UTF-8");
|
||||||
|
$render='<div class="fieldContent">'."\n";
|
||||||
|
$render.='<select id="'.$idFixed.'" name="'.$idFixed.'" '.
|
||||||
|
'class="combo">'."\n";
|
||||||
|
foreach ($options as $key => $value) {
|
||||||
|
$keyFixed=htmlentities($key,ENT_HTML5, "UTF-8");
|
||||||
|
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
||||||
|
if($value==$selected){
|
||||||
|
$render.='<option value="'.$valueFixed.
|
||||||
|
'" title="'.$valueFixed.'" selected >'.
|
||||||
|
$keyFixed."</option>/n";
|
||||||
|
}else{
|
||||||
|
$render.='<option value="'.$valueFixed.
|
||||||
|
'" title="'.$valueFixed.'">'.
|
||||||
|
$keyFixed."</option>/n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$render.="</select>\n";
|
||||||
|
$render.="</div>\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderButton($id,$value){
|
||||||
|
$idFixed=htmlentities($id,ENT_HTML5, "UTF-8");
|
||||||
|
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
||||||
|
return '<input type="submit" value="'.$valueFixed.'" '.
|
||||||
|
'id="'.$idFixed.'" name="'.$idFixed.'" class="button" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderFieldInfo($text,$info){
|
||||||
|
$render='<div class="field">'."\n";
|
||||||
|
$render.=RenderLabel($text);
|
||||||
|
$render.=RenderInfo($info);
|
||||||
|
$render.='</div>'."\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderFieldText($text,$idText,$value){
|
||||||
|
$render='<div class="field">'."\n";
|
||||||
|
$render.=RenderLabel($text);
|
||||||
|
$render.=RenderText($idText,$value);
|
||||||
|
$render.='</div>'."\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderFieldCheck($text,$idCheck,$checked,$value){
|
||||||
|
$render='<div class="field">'."\n";
|
||||||
|
$render.=RenderLabel($text);
|
||||||
|
$render.=RenderCheck($idCheck,$checked,$value);
|
||||||
|
$render.='</div>'."\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderFieldCheckText($text,$idCheck,$checked,$idText,$value){
|
||||||
|
$render='<div class="field">'."\n";
|
||||||
|
$render.=RenderLabel($text);
|
||||||
|
$render.=RenderCheckText($idCheck,$checked,$idText,$value);
|
||||||
|
$render.='</div>'."\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderFieldCombo($text,$idCombo,$options,$selected){
|
||||||
|
$render='<div class="field">'."\n";
|
||||||
|
$render.=RenderLabel($text);
|
||||||
|
$render.=RenderCombo($idCombo,$options,$selected);
|
||||||
|
$render.='</div>'."\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RenderFieldButton($text,$idButton,$value){
|
||||||
|
$render='<div class="field">'."\n";
|
||||||
|
$render.=RenderLabel($text);
|
||||||
|
$render.=RenderButton($idButton,$value);
|
||||||
|
$render.='</div>'."\n";
|
||||||
|
return $render;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function RenderParagraph($text,$style=null){
|
||||||
|
if($text==null || $text==""){ return ""; }
|
||||||
|
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
||||||
|
if($style==null){
|
||||||
|
return "<p>".$textFixed."</p>\n";
|
||||||
|
}else{
|
||||||
|
return "<p style=\"".$style."\">".$textFixed."</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
100
code/utils.php
100
code/utils.php
@@ -1,104 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function DrawFieldInfo($text,$info){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
$infoFixed=htmlentities($info,ENT_HTML5, "UTF-8");
|
|
||||||
echo '<div class="field">'."\n";
|
|
||||||
echo '<span class="fieldLabel">'.$textFixed.":</span>\n";
|
|
||||||
echo '<div class="fieldText">'.$infoFixed."</div>\n";
|
|
||||||
echo '</div>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function DrawFieldCombo($text,$id,$options,$selected){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
$idFixed=htmlentities($id,ENT_HTML5, "UTF-8");
|
|
||||||
echo '<div class="field">'."\n";
|
|
||||||
echo '<span class="fieldLabel">'.$textFixed.":</span>\n";
|
|
||||||
echo '<div class="fieldCombo">'."\n";
|
|
||||||
echo '<select id="'.$idFixed.'" name="'.$idFixed.'" '.
|
|
||||||
'class="combo">'."\n";
|
|
||||||
foreach ($options as $key => $value) {
|
|
||||||
$keyFixed=htmlentities($key,ENT_HTML5, "UTF-8");
|
|
||||||
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
|
||||||
if($value==$selected){
|
|
||||||
echo '<option value="'.$valueFixed.
|
|
||||||
'" title="'.$valueFixed.'" selected >'.
|
|
||||||
$keyFixed."</option>/n";
|
|
||||||
}else{
|
|
||||||
echo '<option value="'.$valueFixed.
|
|
||||||
'" title="'.$valueFixed.'">'.
|
|
||||||
$keyFixed."</option>/n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo "</select>\n";
|
|
||||||
echo "</div>\n";
|
|
||||||
echo '</div>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function DrawFieldText($text,$idText,$value){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
$idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8");
|
|
||||||
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
|
||||||
echo '<div class="field">'."\n";
|
|
||||||
echo '<span class="fieldLabel">'.$textFixed.":</span>\n";
|
|
||||||
echo '<div class="fieldText">'."\n";
|
|
||||||
echo '<input type="text" id="'.$idTextFixed.'" name="'.$idTextFixed.'"'.
|
|
||||||
' value="'.$valueFixed.'" '.
|
|
||||||
' class="textBox"/>'."\n";
|
|
||||||
echo "</div>\n";
|
|
||||||
echo '</div>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function DrawFieldCheck($text,$idCheck,$checked,$value){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
$idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8");
|
|
||||||
$valueFixed=htmlentities($idText,ENT_HTML5, "UTF-8");
|
|
||||||
echo '<div class="field">'."\n";
|
|
||||||
echo '<span class="fieldLabel">'.$textFixed.":</span>\n";
|
|
||||||
echo '<div class="fieldCombo">'."\n";
|
|
||||||
echo '<input type="checkbox" id="'.$idCheckFixed.'" '.
|
|
||||||
'name="'.$idCheckFixed.'" ';
|
|
||||||
if($checked){ echo " checked "; }
|
|
||||||
echo 'class="check">'.$valueFixed."\n";
|
|
||||||
echo "</input>\n";
|
|
||||||
echo "</div>\n";
|
|
||||||
echo '</div>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function DrawFieldCheckText($text,$idCheck,$checked,$idText,$value){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
$idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8");
|
|
||||||
$idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8");
|
|
||||||
$valueFixed=htmlentities($value,ENT_HTML5, "UTF-8");
|
|
||||||
echo '<div class="field">'."\n";
|
|
||||||
echo '<span class="fieldLabel">'.$textFixed.":</span>\n";
|
|
||||||
echo '<div class="fieldCombo">'."\n";
|
|
||||||
echo '<input type="checkbox" id="'.$idCheckFixed.'" '.
|
|
||||||
'name="'.$idCheckFixed.'" ';
|
|
||||||
if($checked){ echo " checked "; }
|
|
||||||
echo 'class="check" />'."\n";
|
|
||||||
echo '<input type="text" id="'.$idTextFixed.'" name="'.$idTextFixed.'" '.
|
|
||||||
'value="'.$valueFixed.'" class="textBox" />';
|
|
||||||
echo "</div>\n";
|
|
||||||
echo '</div>'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function DrawButton($text,$id){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
$idFixed=htmlentities($id,ENT_HTML5, "UTF-8");
|
|
||||||
echo '<input type="submit" value="'.$textFixed.'" '.
|
|
||||||
'id="'.$idFixed.'" name="'.$idFixed.'" class="button" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
function DrawParagraph($text,$style=null){
|
|
||||||
$textFixed=htmlentities($text,ENT_HTML5, "UTF-8");
|
|
||||||
if($style==null){
|
|
||||||
echo "<p>".$textFixed."</p>\n";
|
|
||||||
}else{
|
|
||||||
echo "<p style=\"".$style."\">".$textFixed."</p>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function RequestParm($name,$defaultValue){
|
function RequestParm($name,$defaultValue){
|
||||||
if(isset($_GET[$name])){
|
if(isset($_GET[$name])){
|
||||||
return $_GET[$name];
|
return $_GET[$name];
|
||||||
@@ -127,4 +28,3 @@ function ExecFull($cmd, $input='') {
|
|||||||
return array($return_code, $stdout, $stderr);
|
return array($return_code, $stdout, $stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
}
|
}
|
||||||
.fieldText,
|
.fieldContent{
|
||||||
.fieldCombo{
|
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
width:80%;
|
width:80%;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
.button{
|
.button{
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
padding:5px;
|
padding:5px;
|
||||||
margin:5px;
|
margin:0;
|
||||||
background-color: rgb(192,192,192);
|
background-color: rgb(192,192,192);
|
||||||
border: solid 1px rgb(32,32,32);
|
border: solid 1px rgb(32,32,32);
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
|
|||||||
Reference in New Issue
Block a user