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 .= ''; } 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 ''; } function getAction() { return 'setInputBox_'.$this->iBoxId.'(\''.implode('\', \'', array_map('addslashes', $this->getTag())).'\');'; } function getBox() { return '
'; } function getHtml() { return "\n".$this->getJavaScript()."\n".''; } } ?>