1<?php
2/**
3 * This view generate the advanced question attributes
4 */
5$currentfieldset='';
6$categoryNum=0;
7?>
8<!-- Advanced Settings -->
9<?php foreach ($attributedata as $index=>$aAttribute):?>
10
11    <!-- Fieldsets -->
12    <?php if ($currentfieldset!=$aAttribute['category']): ?>
13        <?php $categoryNum++; ?>
14        <?php if ($currentfieldset!=''): ?>
15            </div></div></div></div>
16        </div>
17        <?php endif; ?>
18        <div class="panel panel-default panel-advancedquestionsettings">
19            <div class="panel-heading" role="tab">
20                <a class="panel-title h4 selector--questionEdit-collapse" id="button-collapse<?php echo $categoryNum ?>"  role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-cat<?php echo $categoryNum ?>" aria-expanded="false" aria-controls="collapse-cat<?php echo $categoryNum ?>">
21                    <?php echo $aAttribute['category']; ?>
22                </a>
23            </div>
24            <div id="collapse-cat<?php echo $categoryNum ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="button-collapse<?php echo $categoryNum ?>">
25                <div class="panel-body">
26                    <div>
27
28        <?php $currentfieldset=$aAttribute['category']; ?>
29    <?php endif; ?>
30    <div class="form-group">
31    <!-- Form Group -->
32        <!-- Label -->
33        <label class="control-label" for='<?php echo $aAttribute['name'];?>'>
34            <?php
35                echo $aAttribute['caption'];
36                if ($aAttribute['i18n']==true) { ?> (<?php echo $aAttribute['language'] ?>)<?php }
37            ?>
38            <?php if (!empty($aAttribute['help'])): ?>
39            <a class="text-primary show-help" data-toggle="collapse" href="#help<?php echo $aAttribute['name'];?>" aria-expanded="false" aria-controls="help<?php echo $aAttribute['name'];?>" aria-hidden=true>
40                <span class="fa fa-info-circle" ></span>
41            </a>
42            <?php endif; ?>
43        </label>
44        <?php if (!empty($aAttribute['help'])): ?>
45        <p class="help-block collapse" id="help<?php echo $aAttribute['name'];?>"><?php echo $aAttribute['help'];?></p>
46        <?php endif; ?>
47        <!-- Input -->
48        <div class="">
49            <?php
50                $readonly = ( $aAttribute['readonly'] || ($aAttribute['readonly_when_active'] && $bIsActive) );
51                switch ($aAttribute['inputtype'])
52                {
53                    // Switch
54                    case 'switch':
55                         $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
56                            'name' => $aAttribute['name'],
57                            'value'=> $aAttribute['value'],
58                            'onLabel'=>gT('On'),
59                            'offLabel'=>gT('Off'),
60                            'htmlOptions'=>array(
61                                'disabled'=>$readonly,
62                                'aria-describedby'=>"help{$aAttribute['name']}",
63                            ),
64                        ));
65                        break;
66                        // Button group
67                    case 'buttongroup':
68                        $this->widget('yiiwheels.widgets.buttongroup.WhButtonGroup', array(
69                            'name' => $aAttribute['name'],
70                            'value'=> $aAttribute['value'] ,
71                            'selectOptions'=>$aAttribute['options'],
72                            'htmlOptions'=>array(
73                                'disabled'=>$readonly,
74                                'aria-describedby'=>"help{$aAttribute['name']}",
75                            ),
76                        ));
77                        break;
78                        // Single select
79                    case 'singleselect':
80                        echo CHtml::dropDownList($aAttribute['name'],$aAttribute['value'],$aAttribute['options'],array(
81                            'class'=>"form-control",
82                            'disabled'=>$readonly,
83                            'encode'=>false, // gt encode it by default
84                            'aria-describedby'=>"help{$aAttribute['name']}",
85                        ));
86                        break;
87                        // Text
88                    case 'text':
89                        if($aAttribute['expression']>=2) {
90                            echo CHtml::tag('div',array('class'=>"input-group"),"",false);
91                            echo CHtml::tag('div',array('class'=>"input-group-addon"),"{");
92                        }
93                         echo CHtml::textField($aAttribute['name'],$aAttribute['value'],array(
94                            'class'=>"form-control",
95                            'disabled'=>$readonly,
96                            'aria-describedby'=>"help{$aAttribute['name']}",
97                        ));
98                        if($aAttribute['expression']>=2) {
99                            echo CHtml::tag('div',array('class'=>"input-group-addon"),"}");
100                            echo CHtml::closeTag('div');
101                        }
102                        break;
103
104                    // Integer
105                    case 'integer':
106                        echo CHtml::numberField($aAttribute['name'],$aAttribute['value'],array(
107                            'class'=>"form-control",
108                            'disabled'=>$readonly,
109                            'step'=>1,
110                            'pattern'=>'\d+',
111                            'min'=>(isset($aAttribute['min'])?$aAttribute['min']:1),
112                            'max'=>(isset($aAttribute['max'])?$aAttribute['max']:null),
113                            'aria-describedby'=>"help{$aAttribute['name']}",
114                        ));
115                        break;
116
117                    // Float
118                    case 'float':
119                        echo CHtml::numberField($aAttribute['name'],$aAttribute['value'],array(
120                            'class'=>"form-control",
121                            'disabled'=>$readonly,
122                            'step'=>1,
123                            'pattern'=>'^[-+]?[0-9]*\.[0-9]+$',
124                            'min'=>(isset($aAttribute['min'])?$aAttribute['min']:null),
125                            'max'=>(isset($aAttribute['max'])?$aAttribute['max']:null)
126                        ));
127                        break;
128
129
130                    // Columns
131                    case 'columns':
132                        echo CHtml::numberField($aAttribute['name'],$aAttribute['value'],array(
133                            'class'=>"form-control",
134                            'disabled'=>$readonly,
135                            'step'=>1,
136                            'pattern'=>'\d+',
137                            'min'=>1,
138                            'max'=>12,
139                            'aria-describedby'=>"help{$aAttribute['name']}",
140                        ));
141                        break;
142                    // Textarea
143                    case 'textarea':
144                        if ($aAttribute['expression']>=2) {
145                            echo CHtml::tag('div',array('class'=>"input-group"),"",false);
146                            echo CHtml::tag('div',array('class'=>"input-group-addon"),"{");
147                        }
148                        echo CHtml::textArea($aAttribute['name'],$aAttribute['value'],array(
149                            'class'=>"form-control",
150                            'disabled'=>$readonly,
151                            'aria-describedby'=>"help{$aAttribute['name']}",
152                        ));
153                        if ($aAttribute['expression']>=2) {
154                            echo CHtml::tag('div',array('class'=>"input-group-addon"),"}");
155                            echo CHtml::closeTag('div');
156                        }
157                        break;
158
159                    // Question template selector
160                    case 'question_template':
161                        echo CHtml::dropDownList($aAttribute['name'],$aAttribute['value'],$aQuestionTemplates,array(
162                            'class'=>"form-control",
163                            'disabled'=>$readonly,
164                            'aria-describedby'=>"help{$aAttribute['name']}",
165                        ));
166                        break;
167
168                }
169                ?>
170            </div>
171        </div>
172<?php endforeach;?>
173<input type='hidden' name='advancedquestionsettingsLoaded' value="ok" />
174 </div></div></div></div>
175<?php
176/* Launch all needed script (here after load) needed for widget */
177foreach (Yii::app()->clientScript->scripts as $index=>$script)
178{
179    // Add specific view script
180    $script[] = "$('.show-help').tooltip({ html:true, title : function() { return $($(this).attr('href')).html(); }, trigger: 'hover' });";
181    echo CHtml::script(implode("\n",$script));
182}
183Yii::app()->clientScript->reset();
184?>
185
186<!-- end of Advanced Settings -->
187