Initial commit

This commit is contained in:
2013-08-07 14:41:29 +02:00
commit 66571766b0
333 changed files with 108874 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
<?php
/* Input box (get user typed info), replacing javascript messageBox */
class InputBox
{
private $iBoxId;
private $sBoxTitle;
private $sQuestion;
private $asAnswers;
private $asStyle;
private $sAction;
/**
*
* @param $sBoxTitle
* @param $sQuestion
* @param $asAnswers
* @param $asStyle
* @return unknown_type
*/
function __construct($sBoxTitle, $sQuestion, $asAnswers=array(), $asStyle=array())
{
$this->iBoxId = 'input_box_id_'.rand(1, 1000);
$this->sBoxTitle = $sBoxTitle;
$this->sQuestion = $sQuestion;
$this->setAnswers($asAnswers);
$this->setStyle($asStyle);
$this->setTags(array());
}
function setAnswers($asAnswers)
{
if(count($asAnswers)==0)
{
$this->asAnswers = array('Oui'=>'submitForm(\'#formName#\')', 'Non'=>'');
}
else
{
$this->asAnswers = $asAnswers;
}
}
function getAnswers()
{
$sAnswers = '';
foreach($this->asAnswers as $sAnswertext=>$sAnswerAction)
{
$sAnswers .= '<input type="button" style="margin:auto 10px;" onclick="setInputBoxDisplay_'.$this->iBoxId.'();'.$sAnswerAction.';" value="'.$sAnswertext.'" />';
}
return $sAnswers;
}
function setStyle($asStyle)
{
$this->asStyle = array('display'=>'none', 'position'=>'absolute');
$this->asStyle = array_merge($this->asStyle, $asStyle);
}
function getStyle()
{
$sStyle = '';
foreach($this->asStyle as $sStyleTag=>$sStyleValue)
{
$sStyle .= $sStyleTag.':'.$sStyleValue.';';
}
return $sStyle;
}
function setTags($asTags)
{
$this->asTagNames = $asTags;
}
function getTag($sTagName=false, $bKey=false, $bJavaScript=false)
{
return ($sTagName===false)?$this->asTagNames:$this->asTagNames[$sTagName];
}
function getTagNames()
{
return array_keys($this->getTag());
}
function getJavaScript()
{
$asTagReplace = array();
foreach($this->getTagNames() as $sTagName)
{
$asTagReplace[] = 'box = box.replace(/\#'.$sTagName.'\#/g, '.$sTagName.');';
}
return '<script type="text/javascript">
function setInputBox_'.$this->iBoxId.'('.implode(', ', $this->getTagNames()).')
{
//initiate box HTML
var box = \''.printJsString($this->getBox()).'\';
//replace specific values
'.implode("\n", $asTagReplace).'
//display the box
document.getElementById(\''.$this->iBoxId.'\').innerHTML = box;
setInputBoxDisplay_'.$this->iBoxId.'();
}
function setInputBoxDisplay_'.$this->iBoxId.'()
{
document.getElementById(\''.$this->iBoxId.'\').style.top = (Y-80)+"px";
document.getElementById(\''.$this->iBoxId.'\').style.left = (X-250)+"px";
setBoxDisplay(\''.$this->iBoxId.'\');
setBoxDisplay("layer");
}
</script>';
}
function getAction()
{
return 'setInputBox_'.$this->iBoxId.'(\''.implode('\', \'', array_map('addslashes', $this->getTag())).'\');';
}
function getBox()
{
return ' <fieldset class="inputBox rounded">
<legend class="rounded">'.$this->sBoxTitle.'</legend>
<p style="font-weight:bold;text-align:center;">'.$this->sQuestion.'</p>
<form style="text-align:center;">'.$this->getAnswers().'</form>
</fieldset>';
}
function getHtml()
{
return "\n".$this->getJavaScript()."\n".'<div id="'.$this->iBoxId.'" style="'.$this->getStyle().'"></div>';
}
}
?>