Skip to content

Commit

Permalink
Dev: Fix some issue in template editor : save/load review
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Dec 13, 2016
1 parent 68d124f commit 9c7012d
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 78 deletions.
4 changes: 2 additions & 2 deletions application/config/third_party.php
Expand Up @@ -7,8 +7,8 @@
/* Tag if debug is set : debug is set in user config file and this file is directly required in internal.php where $userConfig var arry is set */
/* This allow us to use minified version according to debug */
$debug = isset($userConfig['config']['debug']) ? $userConfig['config']['debug'] : 0;
/* To add more easily min version */
$minVersion = ($debug<2) ? ".min": "";
/* To add more easily min version : config > 2 , seems really an core dev issue to fix bootstrap.js ;) */
$minVersion = ($debug>2) ? "":".min";
/* Please : comment the reason, mantis bug link: ajax don't need any package if i don't make error */
/* Ajax must renderPartial (better : always return json) and never render and don't registerScript (IMHO) / Shnoulle on 2016-11-16 */
if(isset($_GET['isAjax'])){
Expand Down
45 changes: 32 additions & 13 deletions application/controllers/admin/templates.php
Expand Up @@ -887,7 +887,8 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$screens['printanswers'] = gT('Print answers page','unescaped');
$screens['printablesurvey'] = gT('Printable survey page','unescaped');

// Page display blocks
/* pstpl file list */
/* used for call AND for pstl editable files list */
$SurveyList = array('startpage.pstpl',
'surveylist.pstpl',
'endpage.pstpl'
Expand Down Expand Up @@ -1099,16 +1100,18 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
switch ($screenname)
{
case 'surveylist':
$aSurveyListTexts = array(
"nosid" => gT("You have not provided a survey identification number"),
"contact" => sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")),
"listheading" => gT("The following surveys are available:"),
"list" => $this->getController()->renderPartial('/admin/templates/templateeditor_surveylist_view', array(), true),
$aSurveyList = array(
'publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(),
'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll(),
);
$aData['surveylist'] = $aSurveyListTexts;
$aData['aReplacements'] = $aGlobalReplacements;
$aReplacementSurveyList = array(
"SURVEYCONTACT" => sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")),
"SURVEYLISTHEADING" => gT("The following surveys are available:"),
"SURVEYLIST" => $this->getController()->renderPartial('/admin/templates/templateeditor_surveylist_view', $aSurveyList, true),
);
//$aData['surveylist'] = $aSurveyListTexts;
$aData['aReplacements'] = array_merge($aGlobalReplacements,$aReplacementSurveyList);
$myoutput[] = "";
//$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$files=$SurveyList;
foreach ($files as $qs)
{
Expand Down Expand Up @@ -1221,17 +1224,33 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$files=$Save;
$aData['aReplacements'] = $aGlobalReplacements;
$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/save.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$aData['aReplacements']['SAVEHEADING'] = App()->getController()->renderPartial("/survey/frontpage/saveForm/heading",array(),true);
$aData['aReplacements']['SAVEMESSAGE'] = App()->getController()->renderPartial("/survey/frontpage/saveForm/message",array(),true);
$aData['aReplacements']['SAVEALERT'] = App()->getController()->renderPartial("/survey/frontpage/saveForm/anonymized",array(),true);
$aData['aReplacements']['SAVEERROR'] = "";
$saveForm = CHtml::beginForm(array("/survey/index","sid"=>$surveyid), 'post',array('id'=>'form-save'));
$saveForm .= App()->getController()->renderPartial("/survey/frontpage/saveForm/form",array('captcha'=>false),true);
$saveForm .= CHtml::endForm();
$aData['aReplacements']['SAVEFORM'] = $saveForm;
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/save.pstpl", $aData, $oEditedTemplate));
$myoutput[] = templatereplace(file_get_contents("$templatedir/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = "\n";
break;

case 'load':
$files=$Load;
$aData['aReplacements'] = $aGlobalReplacements;
$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/load.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(),$aData['aReplacements'], 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$aData['aReplacements']['LOADHEADING'] = App()->getController()->renderPartial("/survey/frontpage/loadForm/heading",array(),true);
$aData['aReplacements']['LOADMESSAGE'] = App()->getController()->renderPartial("/survey/frontpage/loadForm/message",array(),true);
$aData['aReplacements']['LOADERROR'] = "";
$loadForm = CHtml::beginForm(array("/survey/index","sid"=>$surveyid), 'post',array('id'=>'form-load'));
$loadForm .= App()->getController()->renderPartial("/survey/frontpage/loadForm/form",array('captcha'=>false),true);
$loadForm .= CHtml::endForm();
$aData['aReplacements']['LOADFORM'] = $loadForm;
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/load.pstpl", $aData, $oEditedTemplate));
$myoutput[] = templatereplace(file_get_contents("$templatedir/endpage.pstpl"), $aData['aReplacements'], $aData['aReplacements'], 'Unspecified', false, NULL, array(), false, $oEditedTemplate);

$myoutput[] = "\n";
break;

Expand Down
@@ -1,14 +1,15 @@
<?php
App()->getController()->renderPartial('/survey/questions/longfreetext/answer', array(
App()->getController()->renderPartial('/survey/questions/answer/longfreetext/answer', array(
'extraclass' => 'col-sm-12',
'coreClass' =>"ls-answers answer-item text-item",
'withColumn' =>true,
'kpclass' => '',
'name' => '1234X56X78',
'basename' => '1234X56X78',
'drows' => 5,
'dispVal' => gT('Some text in this answer'),
'tiwidth' => 40,
'maxlength' => '',
'checkconditionFunction' => '',
'inputsize' => null
));
?>
152 changes: 91 additions & 61 deletions application/views/admin/templates/templateeditor_surveylist_view.php
@@ -1,65 +1,95 @@
<ul class="surveys-list">
<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 1
</a>
<?php
$outputSurveys = 0;
$list = "<div class='surveys-list-container'>";
$list .= "<ul class='list-unstyled surveys-list'>";

<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>
foreach($publicSurveys as $survey)
{
$outputSurveys++;
/* get final lang of survey */
if(!in_array(App()->language,$survey->getAllLanguages())){
$surveylang=$survey->language;
}else{
$surveylang=App()->language;
}
/* get the col class for with (src : http://encosia.com/using-btn-block-bootstrap-3-dropdown-button-groups) */
if ($survey->publicstatistics == "Y"){
$colClass="col-xs-10 col-md-11";
}else{
$colClass="col-xs-12";
}
$surveyLine = CHtml::link(
$survey->localizedTitle,
array(
'survey/index',
'sid' => $survey->sid,
'lang' => $surveylang,
),
array(
'class' => "surveytitle btn btn-primary {$colClass}",
'title'=>gT('Start survey'),
'lang'=>$surveylang // Must add dir ?
)
);
if ($survey->publicstatistics == "Y"){
$surveyLine .= CHtml::link('<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only">'. gT('View statistics') .'</span>',
array('statistics_user/action', 'surveyid' => $survey->sid,'language' => $surveylang),
array(
'class'=>'view-stats btn btn-success col-xs-2 col-md-1',
'title'=>gT('View statistics'),
)
);
}
$list .= CHtml::tag("li",
array("class"=>"btn-group btn-block"),
$surveyLine
);
}

<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 2
</a>
<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>
$list .= "</ul>";
$list .= "</div>";

<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 3
</a>
<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>
if (!empty($futureSurveys)) /* Dis someone use it ? */
{
$list .= "<div class=\"survey-list-heading\">". gT("Following survey(s) are not yet active but you can register for them.")."</div>";
$list .= "<div class='surveys-list-container futuresurveys-list-container'>";
$list .= "<ul class='list-unstyled surveys-list'>";
foreach($futureSurveys as $survey)
{
$outputSurveys++;
if(!in_array(App()->language,$survey->getAllLanguages())){
$surveylang=$survey->language;
}else{
$surveylang=App()->language;
}
$surveyLine = CHtml::link(
$survey->localizedTitle,
array(
'survey/index',
'sid' => $survey->sid,
'lang' => $surveylang,
),
array(
'class' => "surveytitle btn btn-primary col-xs-12",
'title'=>gT('Start survey'),
// broken : jquery-ui tooltip replace bs tooltip 'data-toggle'=>'tooltip',
'lang'=>$surveylang // Must add dir ?
)
);
$surveyLine .= CHtml::tag('div', array(
'data-regformsurvey' => $survey->sid,
'class' => 'col-xs-12'
));
}
$list .= "</ul>";
$list .= "</div>";
}

<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 4
</a>
<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>

<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 5
</a>
<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>

<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 6
</a>
<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>

<li>
<a class="surveytitle btn btn-primary" href="/LimeSurveyNext/index.php/282267?lang=en">
Survey Number 7
</a>
<a class="view-stats btn btn-success" title="" data-toggle="tooltip" href="#" data-original-title="View statistics">
<span class="fa fa-bar-chart" aria-hidden="true"></span><span class="sr-only"><?php eT("View statistics");?></span>
</a>
</li>
</ul>
$listheading="<div class='h3 '>
".gT("The following surveys are available:")."
</div>";
if( $outputSurveys==0)
{
$list=CHtml::openTag('div',array('class'=>'col-xs-12')).gT("No available surveys").CHtml::closeTag('div');
}
echo $list;

1 comment on commit 9c7012d

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still the 2 print views ....

Please sign in to comment.