Source for file jFormsBuilderHtml.class.php

Documentation is available at jFormsBuilderHtml.class.php

  1. <?php
  2. /**
  3. @package     jelix
  4. @subpackage  forms
  5. @author      Laurent Jouanneau
  6. @contributor Julien Issler, Dominique Papin
  7. @copyright   2006-2011 Laurent Jouanneau
  8. @copyright   2008-2011 Julien Issler, 2008 Dominique Papin
  9. @link        http://www.jelix.org
  10. @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  11. */
  12.  
  13. /**
  14.  * HTML form builder
  15.  * @package     jelix
  16.  * @subpackage  jelix-plugins
  17.  */
  18. class jFormsBuilderHtml extends jFormsBuilderBase {
  19.  
  20.     protected $jFormsJsVarName = 'jForms';
  21.  
  22.     protected $options;
  23.  
  24.     protected $isRootControl = true;
  25.  
  26.     public function outputAllControls({
  27.  
  28.         echo '<table class="jforms-table" border="0">';
  29.         foreach$this->_form->getRootControls(as $ctrlref=>$ctrl){
  30.             if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden'continue;
  31.             if(!$this->_form->isActivated($ctrlref)) continue;
  32.             if($ctrl->type == 'group'{
  33.                 echo '<tr><td colspan="2">';
  34.                 $this->outputControl($ctrl);
  35.                 echo '</td></tr>';
  36.             }else{
  37.                 echo '<tr><th scope="row">';
  38.                 $this->outputControlLabel($ctrl);
  39.                 echo '</th><td>';
  40.                 $this->outputControl($ctrl);
  41.                 echo "</td></tr>\n";
  42.             }
  43.         }
  44.         echo '</table> <div class="jforms-submit-buttons">';
  45.         if $ctrl $this->_form->getReset() ) {
  46.             if(!$this->_form->isActivated($ctrl->ref)) continue;
  47.             $this->outputControl($ctrl);
  48.             echo ' ';
  49.         }
  50.         foreach$this->_form->getSubmits(as $ctrlref=>$ctrl){
  51.             if(!$this->_form->isActivated($ctrlref)) continue;
  52.             $this->outputControl($ctrl);
  53.             echo ' ';
  54.         }
  55.         echo "</div>\n";
  56.     }
  57.  
  58.     public function outputMetaContent($t{
  59.         global $gJCoord$gJConfig;
  60.         $resp$gJCoord->response;
  61.         if($resp === null || $resp->getType(!='html'){
  62.             return;
  63.         }
  64.         $www =$gJConfig->urlengine['jelixWWWPath'];
  65.         $bp =$gJConfig->urlengine['basePath'];
  66.         $resp->addJSLink($www.'js/jforms_light.js');
  67.         $resp->addCSSLink($www.'design/jform.css');
  68.         foreach($t->_vars as $k=>$v){
  69.             if($v instanceof jFormsBase && count($edlist $v->getHtmlEditors())) {
  70.                 foreach($edlist as $ed{
  71.                     if(isset($gJConfig->htmleditors[$ed->config.'.engine.file'])){
  72.                         if(is_array($gJConfig->htmleditors[$ed->config.'.engine.file'])){
  73.                             foreach($gJConfig->htmleditors[$ed->config.'.engine.file'as $url{
  74.                                 $resp->addJSLink($bp.$url);
  75.                             }
  76.                         }else
  77.                             $resp->addJSLink($bp.$gJConfig->htmleditors[$ed->config.'.engine.file']);
  78.                     }
  79.                     if(isset($gJConfig->htmleditors[$ed->config.'.config']))
  80.                         $resp->addJSLink($bp.$gJConfig->htmleditors[$ed->config.'.config']);
  81.                     $skin $ed->config.'.skin.'.$ed->skin;
  82.                     if(isset($gJConfig->htmleditors[$skin]&& $gJConfig->htmleditors[$skin!= '')
  83.                         $resp->addCSSLink($bp.$gJConfig->htmleditors[$skin]);
  84.                 }
  85.             }
  86.         }
  87.     }
  88.  
  89.     protected function outputHeaderScript(){
  90.                 echo '<script type="text/javascript">
  91. //<![CDATA[
  92. '.$this->jFormsJsVarName.'.tForm = new jFormsForm(\''.$this->_name.'\');
  93. '.$this->jFormsJsVarName.'.tForm.setErrorDecorator(new '.$this->options['errorDecorator'].'());
  94. '.$this->jFormsJsVarName.'.declareForm(jForms.tForm);
  95. //]]>
  96. </script>';
  97.     }
  98.  
  99.     /**
  100.      * output the header content of the form
  101.      * @param array $params some parameters <ul>
  102.      *       <li>"errDecorator"=>"name of your javascript object for error listener"</li>
  103.      *       <li>"method" => "post" or "get". default is "post"</li>
  104.      *       </ul>
  105.      */
  106.     public function outputHeader($params){
  107.         $this->options = array_merge(array('errorDecorator'=>$this->jFormsJsVarName.'ErrorDecoratorHtml',
  108.             'method'=>'post')$params);
  109.         if (isset($params['attributes']))
  110.             $attrs $params['attributes'];
  111.         else
  112.             $attrs array();
  113.  
  114.         echo '<form';
  115.         if (preg_match('#^https?://#',$this->_action)) {
  116.             $urlParams $this->_actionParams;
  117.             $attrs['action'$this->_action;
  118.         else {
  119.             $url jUrl::get($this->_action$this->_actionParams2)// returns the corresponding jurl
  120.             $urlParams $url->params;
  121.             $attrs['action'$url->getPath();
  122.         }
  123.         $attrs['method'$this->options['method'];
  124.         $attrs['id'$this->_name;
  125.  
  126.         if($this->_form->hasUpload())
  127.             $attrs['enctype'"multipart/form-data";
  128.  
  129.         $this->_outputAttr($attrs);
  130.         echo '>';
  131.  
  132.         $this->outputHeaderScript();
  133.  
  134.         $hiddens '';
  135.         foreach ($urlParams as $p_name => $p_value{
  136.             $hiddens .= '<input type="hidden" name="'$p_name .'" value="'htmlspecialchars($p_value)'"'.$this->_endt"\n";
  137.         }
  138.  
  139.         foreach ($this->_form->getHiddens(as $ctrl{
  140.             if(!$this->_form->isActivated($ctrl->ref)) continue;
  141.             $hiddens .= '<input type="hidden" name="'$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'" value="'htmlspecialchars($this->_form->getData($ctrl->ref))'"'.$this->_endt"\n";
  142.         }
  143.  
  144.         if($this->_form->securityLevel){
  145.             $tok $this->_form->createNewToken();
  146.             $hiddens .= '<input type="hidden" name="__JFORMS_TOKEN__" value="'.$tok.'"'.$this->_endt"\n";
  147.         }
  148.  
  149.         if($hiddens){
  150.             echo '<div class="jforms-hiddens">',$hiddens,'</div>';
  151.         }
  152.  
  153.         $errors $this->_form->getContainer()->errors;
  154.         if(count($errors)){
  155.             $ctrls $this->_form->getControls();
  156.             echo '<ul id="'.$this->_name.'_errors" class="jforms-error-list">';
  157.             $errRequired='';
  158.             foreach($errors as $cname => $err){
  159.                 if(!$this->_form->isActivated($ctrls[$cname]->ref)) continue;
  160.                 if ($err === jForms::ERRDATA_REQUIRED{
  161.                     if ($ctrls[$cname]->alertRequired){
  162.                         echo '<li>'$ctrls[$cname]->alertRequired,'</li>';
  163.                     }
  164.                     else {
  165.                         echo '<li>'jLocale::get('jelix~formserr.js.err.required'$ctrls[$cname]->label),'</li>';
  166.                     }
  167.                 }else if ($err === jForms::ERRDATA_INVALID{
  168.                     if($ctrls[$cname]->alertInvalid){
  169.                         echo '<li>'$ctrls[$cname]->alertInvalid,'</li>';
  170.                     }else{
  171.                         echo '<li>'jLocale::get('jelix~formserr.js.err.invalid'$ctrls[$cname]->label),'</li>';
  172.                     }
  173.                 }
  174.                 elseif ($err === jForms::ERRDATA_INVALID_FILE_SIZE{
  175.                     echo '<li>'jLocale::get('jelix~formserr.js.err.invalid.file.size'$ctrls[$cname]->label),'</li>';
  176.                 }
  177.                 elseif ($err === jForms::ERRDATA_INVALID_FILE_TYPE{
  178.                     echo '<li>'jLocale::get('jelix~formserr.js.err.invalid.file.type'$ctrls[$cname]->label),'</li>';
  179.                 }
  180.                 elseif ($err === jForms::ERRDATA_FILE_UPLOAD_ERROR{
  181.                     echo '<li>'jLocale::get('jelix~formserr.js.err.file.upload'$ctrls[$cname]->label),'</li>';
  182.                 }
  183.                 elseif ($err != ''{
  184.                     echo '<li>'$err,'</li>';
  185.                 }
  186.             }
  187.             echo '</ul>';
  188.         }
  189.     }
  190.  
  191.     protected $jsContent = '';
  192.  
  193.     protected $lastJsContent = '';
  194.  
  195.     public function outputFooter(){
  196.         echo '<script type="text/javascript">
  197. //<![CDATA[
  198. (function(){var c, c2;
  199. '.$this->jsContent.$this->lastJsContent.'
  200. })();
  201. //]]>
  202. </script>';
  203.         echo '</form>';
  204.     }
  205.  
  206.     public function outputControlLabel($ctrl){
  207.         if($ctrl->type == 'hidden' || $ctrl->type == 'group'return;
  208.         $required ($ctrl->required == false || $ctrl->isReadOnly()?'':' jforms-required');
  209.         $reqhtml ($required?'<span class="jforms-required-star">*</span>':'');
  210.         $inError (isset($this->_form->getContainer()->errors[$ctrl->ref]?' jforms-error':'');
  211.         $hint ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"');
  212.         $id $this->_name.'_'.$ctrl->ref;
  213.         $idLabel ' id="'.$id.'_label"';
  214.         if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons' || $ctrl->type == 'date' || $ctrl->type == 'datetime' || $ctrl->type == 'choice'){
  215.             echo '<span class="jforms-label',$required,$inError,'"',$idLabel,$hint,'>',htmlspecialchars($ctrl->label),$reqhtml,"</span>\n";
  216.         }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){
  217.             echo '<label class="jforms-label',$required,$inError,'" for="',$id,'"',$idLabel,$hint,'>',htmlspecialchars($ctrl->label),$reqhtml,"</label>\n";
  218.         }
  219.     }
  220.  
  221.     public function outputControl($ctrl$attributes=array()){
  222.         if($ctrl->type == 'hidden'return;
  223.         $ro $ctrl->isReadOnly();
  224.         $attributes['name'$ctrl->ref;
  225.         $attributes['id'$this->_name.'_'.$ctrl->ref;
  226.  
  227.         if ($ro)
  228.             $attributes['readonly''readonly';
  229.         else
  230.             unset($attributes['readonly']);
  231.         if (!isset($attributes['title']&& $ctrl->hint{
  232.             $attributes['title'$ctrl->hint;
  233.         }
  234.  
  235.         $class 'jforms-ctrl-'.$ctrl->type;
  236.         $class .= ($ctrl->required == false || $ro?'':' jforms-required');
  237.         $class .= (isset($this->_form->getContainer()->errors[$ctrl->ref]?' jforms-error':'');
  238.         $class .= ($ro && $ctrl->type != 'captcha'?' jforms-readonly':'');
  239.         if (isset($attributes['class']))
  240.             $attributes['class'].= ' '.$class;
  241.         else
  242.             $attributes['class'$class;
  243.         $this->{'output'.$ctrl->type}($ctrl$attributes);
  244.         echo "\n";
  245.         $this->{'js'.$ctrl->type}($ctrl);
  246.         $this->outputHelp($ctrl);
  247.     }
  248.  
  249.     protected function _outputAttr(&$attributes{
  250.         foreach($attributes as $name=>$val{
  251.             echo ' '.$name.'="'.htmlspecialchars($val).'"';
  252.         }
  253.     }
  254.  
  255.     protected function escJsStr($str{
  256.         return '\''.str_replace(array("'","\n"),array("\\'""\\n")$str).'\'';
  257.     }
  258.  
  259.     /**
  260.      * @param jFormsControl $ctrl 
  261.      */
  262.     protected function commonJs($ctrl{
  263.         if ($ctrl->isReadOnly()) {
  264.             $this->jsContent .="c.readOnly = true;\n";
  265.         }
  266.  
  267.         if($ctrl->required){
  268.             $this->jsContent .="c.required = true;\n";
  269.             if($ctrl->alertRequired){
  270.                 $this->jsContent .="c.errRequired=".$this->escJsStr($ctrl->alertRequired).";\n";
  271.             }
  272.             else {
  273.                 $this->jsContent .="c.errRequired=".$this->escJsStr(jLocale::get('jelix~formserr.js.err.required'$ctrl->label)).";\n";
  274.             }
  275.         }
  276.  
  277.         if($ctrl->alertInvalid){
  278.             $this->jsContent .="c.errInvalid=".$this->escJsStr($ctrl->alertInvalid).";\n";
  279.         }
  280.         else {
  281.             $this->jsContent .="c.errInvalid=".$this->escJsStr(jLocale::get('jelix~formserr.js.err.invalid'$ctrl->label)).";\n";
  282.         }
  283.  
  284.         if ($this->isRootControl$this->jsContent .= $this->jFormsJsVarName.".tForm.addControl(c);\n";
  285.         
  286.     }
  287.  
  288.     protected function outputInput($ctrl&$attr{
  289.         $value $this->_form->getData($ctrl->ref);
  290.         if ($ctrl->size != 0)
  291.             $attr['size'$ctrl->size;
  292.         $maxl$ctrl->datatype->getFacet('maxLength');
  293.         if($maxl !== null)
  294.             $attr['maxlength']=$maxl;
  295.         $attr['value'$value;
  296.         $attr['type''text';
  297.         echo '<input';
  298.         $this->_outputAttr($attr);
  299.         echo $this->_endt;
  300.     }
  301.  
  302.     protected function jsInput($ctrl{
  303.  
  304.         $datatype array('jDatatypeBoolean'=>'Boolean','jDatatypeDecimal'=>'Decimal','jDatatypeInteger'=>'Integer','jDatatypeHexadecimal'=>'Hexadecimal',
  305.                         'jDatatypeDateTime'=>'Datetime','jDatatypeDate'=>'Date','jDatatypeTime'=>'Time',
  306.                         'jDatatypeUrl'=>'Url','jDatatypeEmail'=>'Email','jDatatypeIPv4'=>'Ipv4','jDatatypeIPv6'=>'Ipv6');
  307.         $isLocale false;
  308.         $data_type_class get_class($ctrl->datatype);
  309.         if(isset($datatype[$data_type_class]))
  310.             $dt $datatype[$data_type_class];
  311.         else if ($ctrl->datatype instanceof jDatatypeLocaleTime)
  312.             $dt 'Time'$isLocale true}
  313.         else if ($ctrl->datatype instanceof jDatatypeLocaleDate)
  314.             $dt 'LocaleDate'$isLocale true}
  315.         else if ($ctrl->datatype instanceof jDatatypeLocaleDateTime)
  316.             $dt 'LocaleDatetime'$isLocale true}
  317.         else
  318.             $dt 'String';
  319.  
  320.         $this->jsContent .="c = new ".$this->jFormsJsVarName."Control".$dt."('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  321.         if ($isLocale)
  322.             $this->jsContent .="c.lang='".$GLOBALS['gJConfig']->locale."';\n";
  323.  
  324.         $maxl$ctrl->datatype->getFacet('maxLength');
  325.         if($maxl !== null)
  326.             $this->jsContent .="c.maxLength = '$maxl';\n";
  327.  
  328.         $minl$ctrl->datatype->getFacet('minLength');
  329.         if($minl !== null)
  330.             $this->jsContent .="c.minLength = '$minl';\n";
  331.         $re $ctrl->datatype->getFacet('pattern');
  332.         if($re !== null)
  333.             $this->jsContent .="c.regexp = ".$re.";\n";
  334.  
  335.         $this->commonJs($ctrl);
  336.     }
  337.  
  338.     protected function _outputDateControlDay($ctrl$attr$value){
  339.         $attr['name'$ctrl->ref.'[day]';
  340.         $attr['id'.= 'day';
  341.         if($GLOBALS['gJConfig']->forms['controls.datetime.input'== 'textboxes'){
  342.             $attr['value'$value;
  343.             echo '<input type="text" size="2" maxlength="2"';
  344.             $this->_outputAttr($attr);
  345.             echo $this->_endt;
  346.         }
  347.         else{
  348.             echo '<select';
  349.             $this->_outputAttr($attr);
  350.             echo '><option value="">'.htmlspecialchars(jLocale::get('jelix~jforms.date.day.label')).'</option>';
  351.             for($i=1;$i<32;$i++){
  352.                 $k ($i<10)?'0'.$i:$i;
  353.                 echo '<option value="'.$k.'"'.($k == $value?' selected="selected"':'').'>'.$k.'</option>';
  354.             }
  355.             echo '</select>';
  356.         }
  357.     }
  358.  
  359.     protected function _outputDateControlMonth($ctrl$attr$value){
  360.         $attr['name'$ctrl->ref.'[month]';
  361.         $attr['id'.= 'month';
  362.         if($GLOBALS['gJConfig']->forms['controls.datetime.input'== 'textboxes'{
  363.             $attr['value'$value;
  364.             echo '<input type="text" size="2" maxlength="2"';
  365.             $this->_outputAttr($attr);
  366.             echo $this->_endt;
  367.         }
  368.         else{
  369.             $monthLabels $GLOBALS['gJConfig']->forms['controls.datetime.months.labels'];
  370.             echo '<select';
  371.             $this->_outputAttr($attr);
  372.             echo '><option value="">'.htmlspecialchars(jLocale::get('jelix~jforms.date.month.label')).'</option>';
  373.             for($i=1;$i<13;$i++){
  374.                 $k ($i<10)?'0'.$i:$i;
  375.                 if($monthLabels == 'names')
  376.                     $l htmlspecialchars(jLocale::get('jelix~date_time.month.'.$k.'.label'));
  377.                 else if($monthLabels == 'shortnames')
  378.                     $l htmlspecialchars(jLocale::get('jelix~date_time.month.'.$k.'.shortlabel'));
  379.                 else
  380.                     $l $k;
  381.                 echo '<option value="'.$k.'"'.($k == $value?' selected="selected"':'').'>'.$l.'</option>';
  382.             }
  383.             echo '</select>';
  384.         }
  385.     }
  386.  
  387.     protected function _outputDateControlYear($ctrl$attr$value){
  388.         $attr['name'$ctrl->ref.'[year]';
  389.         $attr['id'.= 'year';
  390.         if($GLOBALS['gJConfig']->forms['controls.datetime.input'== 'textboxes'{
  391.             $attr['value'$value;
  392.             echo '<input type="text" size="4" maxlength="4"';
  393.             $this->_outputAttr($attr);
  394.             echo $this->_endt;
  395.         }
  396.         else{
  397.             $minDate $ctrl->datatype->getFacet('minValue');
  398.             $maxDate $ctrl->datatype->getFacet('maxValue');
  399.             if($minDate && $maxDate){
  400.                 echo '<select';
  401.                 $this->_outputAttr($attr);
  402.                 echo '><option value="">'.htmlspecialchars(jLocale::get('jelix~jforms.date.year.label')).'</option>';
  403.                 for($i=$minDate->year;$i<=$maxDate->year;$i++)
  404.                     echo '<option value="'.$i.'"'.($i == $value?' selected="selected"':'').'>'.$i.'</option>';
  405.                 echo '</select>';
  406.             }
  407.             else{
  408.                 $attr['value'$value;
  409.                 echo '<input type="text" size="4" maxlength="4"';
  410.                 $this->_outputAttr($attr);
  411.                 echo $this->_endt;
  412.             }
  413.         }
  414.     }
  415.  
  416.     protected function _outputDateControlHour($ctrl$attr$value){
  417.         $attr['name'$ctrl->ref.'[hour]';
  418.         $attr['id'.= 'hour';
  419.         if($GLOBALS['gJConfig']->forms['controls.datetime.input'== 'textboxes'{
  420.             $attr['value'$value;
  421.             echo '<input type="text" size="2" maxlength="2"';
  422.             $this->_outputAttr($attr);
  423.             echo $this->_endt;
  424.         }
  425.         else{
  426.             echo '<select';
  427.             $this->_outputAttr($attr);
  428.             echo '><option value="">'.htmlspecialchars(jLocale::get('jelix~jforms.time.hour.label')).'</option>';
  429.             for($i=0;$i<24;$i++){
  430.                 $k ($i<10)?'0'.$i:$i;
  431.                 echo '<option value="'.$k.'"'.(string) $k === $value?' selected="selected"':'').'>'.$k.'</option>';
  432.             }
  433.             echo '</select>';
  434.         }
  435.     }
  436.  
  437.     protected function _outputDateControlMinutes($ctrl$attr$value){
  438.         $attr['name'$ctrl->ref.'[minutes]';
  439.         $attr['id'.= 'minutes';
  440.         if($GLOBALS['gJConfig']->forms['controls.datetime.input'== 'textboxes'{
  441.             $attr['value'$value;
  442.             echo '<input type="text" size="2" maxlength="2"';
  443.             $this->_outputAttr($attr);
  444.             echo $this->_endt;
  445.         }
  446.         else{
  447.             echo '<select';
  448.             $this->_outputAttr($attr);
  449.             echo '><option value="">'.htmlspecialchars(jLocale::get('jelix~jforms.time.minutes.label')).'</option>';
  450.             for($i=0;$i<60;$i++){
  451.                 $k ($i<10)?'0'.$i:$i;
  452.                 echo '<option value="'.$k.'"'.(string) $k === $value?' selected="selected"':'').'>'.$k.'</option>';
  453.             }
  454.             echo '</select>';
  455.         }
  456.     }
  457.  
  458.     protected function _outputDateControlSeconds($ctrl$attr$value){
  459.         $attr['name'$ctrl->ref.'[seconds]';
  460.         $attr['id'.= 'seconds';
  461.         if(!$ctrl->enableSeconds)
  462.             echo '<input type="hidden" id="'.$attr['id'].'" name="'.$attr['name'].'" value="'.$value.'"'.$this->_endt;
  463.         else if($GLOBALS['gJConfig']->forms['controls.datetime.input'== 'textboxes'{
  464.             $attr['value'$value;
  465.             echo '<input type="text"';
  466.             $this->_outputAttr($attr);
  467.             echo $this->_endt;
  468.         }
  469.         else{
  470.             echo '<select';
  471.             $this->_outputAttr($attr);
  472.             echo '><option value="">'.htmlspecialchars(jLocale::get('jelix~jforms.time.seconds.label')).'</option>';
  473.             for($i=0;$i<60;$i++){
  474.                 $k ($i<10)?'0'.$i:$i;
  475.                 echo '<option value="'.$k.'"'.(string) $k === $value?' selected="selected"':'').'>'.$k.'</option>';
  476.             }
  477.             echo '</select>';
  478.         }
  479.     }
  480.  
  481.     protected function outputDate($ctrl&$attr){
  482.         $attr['id'$this->_name.'_'.$ctrl->ref.'_';
  483.         $v array('year'=>'','month'=>'','day'=>'');
  484.         if(preg_match('#^(\d{4})?-(\d{2})?-(\d{2})?$#',$this->_form->getData($ctrl->ref),$matches)){
  485.             if(isset($matches[1]))
  486.                 $v['year'$matches[1];
  487.             if(isset($matches[2]))
  488.                 $v['month'$matches[2];
  489.             if(isset($matches[3]))
  490.                 $v['day'$matches[3];
  491.         }
  492.         $f jLocale::get('jelix~format.date');
  493.         for($i=0;$i<strlen($f);$i++){
  494.             if($f[$i== 'Y')
  495.                 $this->_outputDateControlYear($ctrl$attr$v['year']);
  496.             else if($f[$i== 'm')
  497.                 $this->_outputDateControlMonth($ctrl$attr$v['month']);
  498.             else if($f[$i== 'd')
  499.                 $this->_outputDateControlDay($ctrl$attr$v['day']);
  500.             else
  501.                 echo ' ';
  502.         }
  503.     }
  504.  
  505.     protected function jsDate($ctrl){
  506.         $this->jsContent .= "c = new ".$this->jFormsJsVarName."ControlDate('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  507.         $this->jsContent .= "c.multiFields = true;\n";
  508.         $minDate $ctrl->datatype->getFacet('minValue');
  509.         $maxDate $ctrl->datatype->getFacet('maxValue');
  510.         if($minDate)
  511.             $this->jsContent .= "c.minDate = '".$minDate->toString(jDateTime::DB_DFORMAT)."';\n";
  512.         if($maxDate)
  513.             $this->jsContent .= "c.maxDate = '".$maxDate->toString(jDateTime::DB_DFORMAT)."';\n";
  514.         $this->commonJs($ctrl);
  515.     }
  516.  
  517.     protected function outputDatetime($ctrl&$attr){
  518.         $attr['id'$this->_name.'_'.$ctrl->ref.'_';
  519.         $v array('year'=>'','month'=>'','day'=>'','hour'=>'','minutes'=>'','seconds'=>'');
  520.         if(preg_match('#^(\d{4})?-(\d{2})?-(\d{2})? (\d{2})?:(\d{2})?(:(\d{2})?)?$#',$this->_form->getData($ctrl->ref),$matches)){
  521.             if(isset($matches[1]))
  522.                 $v['year'$matches[1];
  523.             if(isset($matches[2]))
  524.                 $v['month'$matches[2];
  525.             if(isset($matches[3]))
  526.                 $v['day'$matches[3];
  527.             if(isset($matches[4]))
  528.                 $v['hour'$matches[4];
  529.             if(isset($matches[5]))
  530.                 $v['minutes'$matches[5];
  531.             if(isset($matches[7]))
  532.                 $v['seconds'$matches[7];
  533.         }
  534.         $f jLocale::get('jelix~format.datetime');
  535.         for($i=0;$i<strlen($f);$i++){
  536.             if($f[$i== 'Y')
  537.                 $this->_outputDateControlYear($ctrl$attr$v['year']);
  538.             else if($f[$i== 'm')
  539.                 $this->_outputDateControlMonth($ctrl$attr$v['month']);
  540.             else if($f[$i== 'd')
  541.                 $this->_outputDateControlDay($ctrl$attr$v['day']);
  542.             else if($f[$i== 'H')
  543.                 $this->_outputDateControlHour($ctrl$attr$v['hour']);
  544.             else if($f[$i== 'i')
  545.                 $this->_outputDateControlMinutes($ctrl$attr$v['minutes']);
  546.             else if($f[$i== 's')
  547.                 $this->_outputDateControlSeconds($ctrl$attr$v['seconds']);
  548.             else
  549.                 echo ' ';
  550.         }
  551.     }
  552.  
  553.     protected function jsDatetime($ctrl){
  554.         $this->jsContent .= "c = new ".$this->jFormsJsVarName."ControlDatetime('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  555.         $this->jsContent .= "c.multiFields = true;\n";
  556.         $minDate $ctrl->datatype->getFacet('minValue');
  557.         $maxDate $ctrl->datatype->getFacet('maxValue');
  558.         if($minDate)
  559.             $this->jsContent .= "c.minDate = '".$minDate->toString(jDateTime::DB_DTFORMAT)."';\n";
  560.         if($maxDate)
  561.             $this->jsContent .= "c.maxDate = '".$maxDate->toString(jDateTime::DB_DTFORMAT)."';\n";
  562.         $this->commonJs($ctrl);
  563.     }
  564.  
  565.     protected function outputCheckbox($ctrl&$attr{
  566.         $value $this->_form->getData($ctrl->ref);
  567.  
  568.         if($ctrl->valueOnCheck == $value){
  569.             $attr['checked'"checked";
  570.          }
  571.         $attr['value'$ctrl->valueOnCheck;
  572.         $attr['type''checkbox';
  573.         echo '<input';
  574.         $this->_outputAttr($attr);
  575.         echo $this->_endt;
  576.     }
  577.  
  578.     protected function jsCheckbox($ctrl{
  579.  
  580.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlBoolean('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  581.  
  582.         $this->commonJs($ctrl);
  583.     }
  584.  
  585.     protected function echoCheckboxes($span$id&$values&$attr&$value&$i{
  586.         foreach($values as $v=>$label){
  587.             $attr['id'$id.$i;
  588.             $attr['value'$v;
  589.             echo $span;
  590.             $this->_outputAttr($attr);
  591.             if((is_array($value&& in_array((string) $v,$value,true)) || ($value === (string) $v))
  592.                 echo ' checked="checked"';
  593.             echo $this->_endt,'<label for="',$id,$i,'">',htmlspecialchars($label),"</label></span>\n";
  594.             $i++;
  595.         }
  596.     }
  597.  
  598.     protected function showRadioCheck($ctrl&$attr&$value$span{
  599.         $id $this->_name.'_'.$ctrl->ref.'_';
  600.         $i=0;
  601.         $data $ctrl->datasource->getData($this->_form);
  602.         if ($ctrl->datasource instanceof jIFormsDatasource2 && $ctrl->datasource->hasGroupedData()) {
  603.             if (isset($data[''])) {
  604.                 $this->echoCheckboxes($span$id$data['']$attr$value$i);
  605.             }
  606.             foreach($data as $group=>$values){
  607.                 if ($group === '')
  608.                     continue;
  609.                 echo '<fieldset><legend>'.htmlspecialchars($group).'</legend>'."\n";
  610.                 $this->echoCheckboxes($span$id$values$attr$value$i);
  611.                 echo "</fieldset>\n";
  612.             }
  613.         }else{
  614.             $this->echoCheckboxes($span$id$data$attr$value$i);
  615.         }
  616.     }
  617.  
  618.     protected function outputCheckboxes($ctrl&$attr{
  619.         $value $this->_form->getData($ctrl->ref);
  620.         $attr['name'$ctrl->ref.'[]';
  621.         unset($attr['title']);
  622.         if(is_array($value&& count($value== 1)
  623.             $value $value[0];
  624.         $span ='<span class="jforms-chkbox jforms-ctl-'.$ctrl->ref.'"><input type="checkbox"';
  625.  
  626.         if(is_array($value)){
  627.             $value array_map(create_function('$v''return (string) $v;'),$value);
  628.         }
  629.         else {
  630.             $value = (string) $value;
  631.         }
  632.         $this->showRadioCheck($ctrl$attr$value$span);
  633.     }
  634.  
  635.     protected function jsCheckboxes($ctrl{
  636.  
  637.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."[]', ".$this->escJsStr($ctrl->label).");\n";
  638.  
  639.         $this->commonJs($ctrl);
  640.     }
  641.  
  642.     protected function outputRadiobuttons($ctrl&$attr{
  643.         $id $this->_name.'_'.$ctrl->ref.'_';
  644.         $attr['name'$ctrl->ref;
  645.         unset($attr['title']);
  646.         $value $this->_form->getData($ctrl->ref);
  647.         if(is_array($value)){
  648.             if(isset($value[0]))
  649.                 $value $value[0];
  650.             else
  651.                 $value '';
  652.         }
  653.         $value = (string) $value;
  654.         $span ='<span class="jforms-radio jforms-ctl-'.$ctrl->ref.'"><input type="radio"';
  655.         $this->showRadioCheck($ctrl$attr$value$span);
  656.     }
  657.  
  658.     protected function jsRadiobuttons($ctrl{
  659.  
  660.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  661.  
  662.         $this->commonJs($ctrl);
  663.     }
  664.  
  665.  
  666.     protected function fillSelect($ctrl$value{
  667.         $data $ctrl->datasource->getData($this->_form);
  668.         if ($ctrl->datasource instanceof jIFormsDatasource2 && $ctrl->datasource->hasGroupedData()) {
  669.             if (isset($data[''])) {
  670.                 foreach($data[''as $v=>$label){
  671.                     if(is_array($value))
  672.                         $selected in_array((string) $v,$value,true);
  673.                     else
  674.                         $selected ((string) $v===$value);
  675.                     echo '<option value="',htmlspecialchars($v),'"',($selected?' selected="selected"':''),'>',htmlspecialchars($label),"</option>\n";
  676.                 }
  677.             }
  678.             foreach($data as $group=>$values{
  679.                 if ($group === '')
  680.                     continue;
  681.                 echo '<optgroup label="'.htmlspecialchars($group).'">';
  682.                 foreach($values as $v=>$label){
  683.                     if(is_array($value))
  684.                         $selected in_array((string) $v,$value,true);
  685.                     else
  686.                         $selected ((string) $v===$value);
  687.                     echo '<option value="',htmlspecialchars($v),'"',($selected?' selected="selected"':''),'>',htmlspecialchars($label),"</option>\n";
  688.                 }
  689.                 echo '</optgroup>';
  690.             }
  691.         }
  692.         else {
  693.             foreach($data as $v=>$label){
  694.                     if(is_array($value))
  695.                         $selected in_array((string) $v,$value,true);
  696.                     else
  697.                         $selected ((string) $v===$value);
  698.                 echo '<option value="',htmlspecialchars($v),'"',($selected?' selected="selected"':''),'>',htmlspecialchars($label),"</option>\n";
  699.             }
  700.         }
  701.  
  702.     }
  703.  
  704.     protected function outputMenulist($ctrl&$attr{
  705.         if (isset($attr['readonly'])) {
  706.             $attr['disabled''disabled';
  707.             unset($attr['readonly']);
  708.         }
  709.  
  710.         $attr['size''1';
  711.         echo '<select';
  712.         $this->_outputAttr($attr);
  713.         echo ">\n";
  714.         $value $this->_form->getData($ctrl->ref);
  715.         if(is_array($value)){
  716.             if(isset($value[0]))
  717.                 $value $value[0];
  718.             else
  719.                 $value='';
  720.         }
  721.         $value = (string) $value;
  722.         if ($ctrl->emptyItemLabel !== null || !$ctrl->required)
  723.             echo '<option value=""',($value===''?' selected="selected"':''),'>',htmlspecialchars($ctrl->emptyItemLabel),"</option>\n";
  724.         $this->fillSelect($ctrl$value);
  725.         echo '</select>';
  726.     }
  727.  
  728.     protected function jsMenulist($ctrl{
  729.  
  730.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  731.  
  732.         $this->commonJs($ctrl);
  733.     }
  734.  
  735.     protected function outputListbox($ctrl&$attr{
  736.         if (isset($attr['readonly'])) {
  737.             $attr['disabled''disabled';
  738.             unset($attr['readonly']);
  739.         }
  740.         $attr['size'$ctrl->size;
  741.  
  742.         if($ctrl->multiple){
  743.             $attr['name'$ctrl->ref.'[]';
  744.             $attr['id'$this->_name.'_'.$ctrl->ref;
  745.             $attr['multiple''multiple';
  746.             echo '<select';
  747.             $this->_outputAttr($attr);
  748.             echo ">\n";
  749.             $value $this->_form->getData($ctrl->ref);
  750.             if($ctrl->emptyItemLabel !== null)
  751.                 echo '<option value=""',(in_array('',$value,true)?' selected="selected"':''),'>',htmlspecialchars($ctrl->emptyItemLabel),"</option>\n";
  752.             if(is_array($value&& count($value== 1)
  753.                 $value $value[0];
  754.  
  755.             if(is_array($value)){
  756.                 $value array_map(create_function('$v''return (string) $v;'),$value);
  757.                 $this->fillSelect($ctrl$value);
  758.             }else{
  759.                 $this->fillSelect($ctrl(string)$value);
  760.             }
  761.             echo '</select>';
  762.         }else{
  763.             $value $this->_form->getData($ctrl->ref);
  764.  
  765.             if(is_array($value)){
  766.                 if(count($value>= 1)
  767.                     $value $value[0];
  768.                 else
  769.                     $value ='';
  770.             }
  771.  
  772.             $value = (string) $value;
  773.             echo '<select';
  774.             $this->_outputAttr($attr);
  775.             echo ">\n";
  776.             if($ctrl->emptyItemLabel !== null)
  777.                 echo '<option value=""',($value===''?' selected="selected"':''),'>',htmlspecialchars($ctrl->emptyItemLabel),"</option>\n";
  778.             $this->fillSelect($ctrl$value);
  779.             echo '</select>';
  780.         }
  781.     }
  782.  
  783.     protected function jsListbox($ctrl{
  784.         if($ctrl->multiple){
  785.             $this->jsContent .= "c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."[]', ".$this->escJsStr($ctrl->label).");\n";
  786.             $this->jsContent .= "c.multiple = true;\n";
  787.         else {
  788.             $this->jsContent .= "c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  789.         }
  790.  
  791.         $this->commonJs($ctrl);
  792.     }
  793.  
  794.     protected function outputTextarea($ctrl&$attr{
  795.         if (!isset($attr['rows']))
  796.             $attr['rows'$ctrl->rows;
  797.         if (!isset($attr['cols']))
  798.             $attr['cols'$ctrl->cols;
  799.         echo '<textarea';
  800.         $this->_outputAttr($attr);
  801.         echo '>',htmlspecialchars($this->_form->getData($ctrl->ref)),'</textarea>';
  802.     }
  803.  
  804.     protected function jsTextarea($ctrl$withjsobj=true{
  805.         if ($withjsobj)
  806.             $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  807.  
  808.         $maxl$ctrl->datatype->getFacet('maxLength');
  809.         if($maxl !== null)
  810.             $this->jsContent .="c.maxLength = '$maxl';\n";
  811.  
  812.         $minl$ctrl->datatype->getFacet('minLength');
  813.         if($minl !== null)
  814.             $this->jsContent .="c.minLength = '$minl';\n";
  815.  
  816.         $this->commonJs($ctrl);
  817.     }
  818.  
  819.     protected function outputHtmleditor($ctrl&$attr{
  820.         $this->outputTextarea($ctrl$attr);
  821.     }
  822.  
  823.     protected function jsHtmleditor($ctrl{
  824.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlHtml('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  825.         $this->jsTextarea($ctrlfalse);
  826.         $engine $GLOBALS['gJConfig']->htmleditors[$ctrl->config.'.engine.name'];
  827.         $this->jsContent .= 'jelix_'.$engine.'_'.$ctrl->config.'("'.$this->_name.'_'.$ctrl->ref.'","'.$this->_name.'","'.$ctrl->skin."\",".$this->jFormsJsVarName.".config);\n";
  828.     }
  829.  
  830.     protected function outputWikieditor($ctrl&$attr{
  831.         $this->outputTextarea($ctrl$attr);
  832.     }
  833.  
  834.     protected function jsWikieditor($ctrl{
  835.  
  836.     }
  837.  
  838.     protected function outputSecret($ctrl&$attr{
  839.         if ($ctrl->size != 0)
  840.             $attr['size'$ctrl->size;
  841.         $maxl $ctrl->datatype->getFacet('maxLength');
  842.         if($maxl !== null)
  843.             $attr['maxlength'$maxl;
  844.         $attr['type''password';
  845.         $attr['value'$this->_form->getData($ctrl->ref);
  846.         echo '<input';
  847.         $this->_outputAttr($attr);
  848.         echo $this->_endt;
  849.     }
  850.  
  851.     protected function jsSecret($ctrl{
  852.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlSecret('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  853.  
  854.         $maxl$ctrl->datatype->getFacet('maxLength');
  855.         if($maxl !== null)
  856.             $this->jsContent .="c.maxLength = '$maxl';\n";
  857.  
  858.         $minl$ctrl->datatype->getFacet('minLength');
  859.         if($minl !== null)
  860.             $this->jsContent .="c.minLength = '$minl';\n";
  861.         $re $ctrl->datatype->getFacet('pattern');
  862.         if($re !== null)
  863.             $this->jsContent .="c.regexp = ".$re.";\n";
  864.         $this->commonJs($ctrl);
  865.     }
  866.  
  867.     protected function outputSecretconfirm($ctrl&$attr{
  868.         if ($ctrl->size != 0)
  869.             $attr['size'$ctrl->size;
  870.         $attr['type''password';
  871.         $attr['value'$this->_form->getData($ctrl->ref);
  872.         echo '<input';
  873.         $this->_outputAttr($attr);
  874.         echo $this->_endt;
  875.     }
  876.  
  877.     protected function jsSecretconfirm($ctrl{
  878.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlConfirm('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  879.         $this->commonJs($ctrl);
  880.     }
  881.  
  882.     protected function outputOutput($ctrl&$attr{
  883.         unset($attr['readonly']);
  884.         unset($attr['class']);
  885.         if (isset($attr['title'])){
  886.             $hint ' title="'.htmlspecialchars($attr['title']).'"';
  887.             unset($attr['title']);
  888.         }
  889.         else $hint '';
  890.         $attr['type''hidden';
  891.         $attr['value'$this->_form->getData($ctrl->ref);
  892.         echo '<input';
  893.         $this->_outputAttr($attr);
  894.         echo $this->_endt;
  895.         echo '<span class="jforms-value"',$hint,'>',htmlspecialchars($attr['value']),'</span>';
  896.     }
  897.  
  898.     protected function jsOutput($ctrl{
  899.     }
  900.  
  901.     protected function outputUpload($ctrl&$attr{
  902.         /*if($ctrl->maxsize){
  903.             echo '<input type="hidden" name="MAX_FILE_SIZE" value="',$ctrl->maxsize,'"',$this->_endt;
  904.         }*/
  905.         $attr['type''file';
  906.         $attr['value''';
  907.         echo '<input';
  908.         $this->_outputAttr($attr);
  909.         echo $this->_endt;
  910.     }
  911.  
  912.     protected function jsUpload($ctrl{
  913.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlString('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  914.  
  915.         $this->commonJs($ctrl);
  916.     }
  917.  
  918.     protected function outputSubmit($ctrl$attr{
  919.         unset($attr['readonly']);
  920.         $attr['class''jforms-submit';
  921.         $attr['type''submit';
  922.  
  923.         if($ctrl->standalone){
  924.             $attr['value'$ctrl->label;
  925.             echo '<input';
  926.             $this->_outputAttr($attr);
  927.             echo $this->_endt;
  928.         }else{
  929.             $id $this->_name.'_'.$ctrl->ref.'_';
  930.             $attr['name'$ctrl->ref;
  931.             foreach($ctrl->datasource->getData($this->_formas $v=>$label){
  932.                 // because IE6 sucks with <button type=submit> (see ticket #431), we must use input :-(
  933.                 $attr['value'$label;
  934.                 $attr['id'$id.$v;
  935.                 echo ' <input';
  936.                 $this->_outputAttr($attr);
  937.                 echo $this->_endt;
  938.             }
  939.         }
  940.     }
  941.  
  942.     protected function jsSubmit($ctrl{
  943.         // no javascript
  944.     }
  945.  
  946.     protected function outputReset($ctrl&$attr{
  947.         unset($attr['readonly']);
  948.         $attr['class''jforms-reset';
  949.         $attr['type''reset';
  950.         echo '<button';
  951.         $this->_outputAttr($attr);
  952.         echo '>',htmlspecialchars($ctrl->label),'</button>';
  953.     }
  954.  
  955.     protected function jsReset($ctrl{
  956.         // no javascript
  957.     }
  958.  
  959.     protected function outputCaptcha($ctrl&$attr{
  960.         $ctrl->initExpectedValue();
  961.         echo '<span class="jforms-captcha-question">',htmlspecialchars($ctrl->question),'</span> ';
  962.  
  963.         unset($attr['readonly']);
  964.         $attr['type''text';
  965.         $attr['value''';
  966.         echo '<input';
  967.         $this->_outputAttr($attr);
  968.         echo $this->_endt;
  969.     }
  970.  
  971.     protected function jsCaptcha($ctrl{
  972.         $this->jsTextarea($ctrl);
  973.     }
  974.  
  975.     protected function outputGroup($ctrl&$attr{
  976.         echo '<fieldset id="',$attr['id'],'"><legend>',htmlspecialchars($ctrl->label),"</legend>\n";
  977.         echo '<table class="jforms-table-group" border="0">',"\n";
  978.         foreach$ctrl->getChildControls(as $ctrlref=>$c){
  979.             if($c->type == 'submit' || $c->type == 'reset' || $c->type == 'hidden'continue;
  980.             if(!$this->_form->isActivated($ctrlref)) continue;
  981.             echo '<tr><th scope="row">';
  982.             $this->outputControlLabel($c);
  983.             echo "</th>\n<td>";
  984.             $this->outputControl($c);
  985.             echo "</td></tr>\n";
  986.         }
  987.         echo "</table></fieldset>";
  988.     }
  989.  
  990.     protected function jsGroup($ctrl{
  991.         //no javacript
  992.     }
  993.  
  994.     protected function outputChoice($ctrl&$attr{
  995.         echo '<ul class="jforms-choice jforms-ctl-'.$ctrl->ref.'" >',"\n";
  996.  
  997.         $value $this->_form->getData($ctrl->ref);
  998.         if(is_array($value)){
  999.             if(isset($value[0]))
  1000.                 $value $value[0];
  1001.             else
  1002.                 $value='';
  1003.         }
  1004.  
  1005.         $i=0;
  1006.         $attr['name'$ctrl->ref;
  1007.         $id $this->_name.'_'.$ctrl->ref.'_';
  1008.         $attr['type']='radio';
  1009.         unset($attr['class']);
  1010.         $readonly (isset($attr['readonly']&& $attr['readonly']!='');
  1011.  
  1012.         $this->jsChoiceInternal($ctrl);
  1013.         $this->jsContent .="c2 = c;\n";
  1014.         $this->isRootControl = false;
  1015.         foreach$ctrl->items as $itemName=>$listctrl){
  1016.             if (!$ctrl->isItemActivated($itemName))
  1017.                 continue;
  1018.             echo '<li><label><input';
  1019.             $attr['id'$id.$i;
  1020.             $attr['value'$itemName;
  1021.             if ($itemName==$value)
  1022.                 $attr['checked''checked';
  1023.             else
  1024.                 unset($attr['checked']);
  1025.             $this->_outputAttr($attr);
  1026.             echo ' onclick="'.$this->jFormsJsVarName.'.getForm(\'',$this->_name,'\').getControl(\'',$ctrl->ref,'\').activate(\'',$itemName,'\')"'$this->_endt;
  1027.             echo htmlspecialchars($ctrl->itemsNames[$itemName]),"</label>\n";
  1028.  
  1029.             $displayedControls false;
  1030.             foreach($listctrl as $ref=>$c{
  1031.                 if(!$this->_form->isActivated($ref|| $c->type == 'hidden'continue;
  1032.                 $displayedControls true;
  1033.                 echo ' <span class="jforms-item-controls">';
  1034.                 $this->outputControlLabel($c);
  1035.                 echo ' ';
  1036.                 $this->outputControl($c);
  1037.                 echo "</span>\n";
  1038.                 $this->jsContent .="c2.addControl(c, ".$this->escJsStr($itemName).");\n";
  1039.             }
  1040.             if(!$displayedControls{
  1041.                 $this->jsContent .="c2.items[".$this->escJsStr($itemName)."]=[];\n";
  1042.             }
  1043.  
  1044.             echo "</li>\n";
  1045.             $i++;
  1046.         }
  1047.         echo "</ul>\n";
  1048.         $this->isRootControl = true;
  1049.     }
  1050.  
  1051.     protected function jsChoice($ctrl{
  1052.         $value $this->_form->getData($ctrl->ref);
  1053.         if(is_array($value)){
  1054.             if(isset($value[0]))
  1055.                 $value $value[0];
  1056.             else
  1057.                 $value='';
  1058.         }
  1059.         $this->jsContent .= "c2.activate('".$value."');\n";
  1060.     }
  1061.  
  1062.     protected function jsChoiceInternal($ctrl{
  1063.  
  1064.         $this->jsContent .="c = new ".$this->jFormsJsVarName."ControlChoice('".$ctrl->ref."', ".$this->escJsStr($ctrl->label).");\n";
  1065.  
  1066.         $this->commonJs($ctrl);
  1067.     }
  1068.  
  1069.     protected function outputHelp($ctrl{
  1070.         if ($ctrl->help{
  1071.             if($ctrl->type == 'checkboxes' || ($ctrl->type == 'listbox' && $ctrl->multiple)){
  1072.                 $name=$ctrl->ref.'[]';
  1073.             }else{
  1074.                 $name=$ctrl->ref;
  1075.             }
  1076.             // additionnal &nbsp, else background icon is not shown in webkit
  1077.             echo '<span class="jforms-help" id="'$this->_name.'_'.$ctrl->ref.'-help">&nbsp;<span>'.htmlspecialchars($ctrl->help).'</span></span>';
  1078.         }
  1079.     }
  1080. }

Documentation generated on Wed, 24 Sep 2014 21:59:20 +0200 by phpDocumentor 1.4.3