Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cint
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jul 26, 2016
2 parents db634b5 + 223a434 commit aee547c
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 67 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -16,7 +16,7 @@
$config['dbversionnumber'] = 258;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '27';
$config['assetsversionnumber'] = '28';
return $config;

?>
5 changes: 1 addition & 4 deletions application/controllers/AdminController.php
Expand Up @@ -40,10 +40,7 @@ protected function _init()
if (!Yii::app()->getConfig("subaction")) {Yii::app()->setConfig("subaction", returnGlobal('subaction'));} //Desired subaction
if (!Yii::app()->getConfig("editedaction")) {Yii::app()->setConfig("editedaction", returnGlobal('editedaction'));} // for html editor integration

// Variable not used, but keep it here so the object is initialized at the right place.
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
$oAdminTheme = AdminTheme::getInstance();
$oAdminTheme->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'admin_core.js' );
AdminTheme::staticRegisterScriptFile('ADMIN_SCRIPT_PATH', 'admin_core.js' );
}

/**
Expand Down
5 changes: 3 additions & 2 deletions application/controllers/admin/questions.php
Expand Up @@ -920,8 +920,9 @@ public function getSubquestionRow( $surveyid, $gid, $qid, $codes, $language, $fi
$oldCode = false;

//Capture "true" and "false" as strings
$first = ($first == "false" ? false : true);

if(is_string($first)){
$first = ($first == "false" ? false : true);
}
// We get the numerical part of each code and we store them in Arrays
// One array is to store the pure numerical values (so we can search in it for the greates value, and increment it)
// Another array is to store the string values (so we keep all the prefixed "0")
Expand Down
20 changes: 13 additions & 7 deletions application/models/AdminTheme.php
Expand Up @@ -26,7 +26,7 @@ class AdminTheme extends CFormModel
public $path; // Admin Theme's path
public $sTemplateUrl; // URL to reach Admin Theme (used to get CSS/JS/Files when asset manager is off)
public $config; // Contains the Admin Theme's configuration file
public $use_asset_manager; // If true, force the use of asset manager even if debug mode is on (useful to debug asset manager's problems)
public static $use_asset_manager; // If true, force the use of asset manager even if debug mode is on (useful to debug asset manager's problems)
private static $instance; // The instance of theme object

/**
Expand Down Expand Up @@ -106,7 +106,7 @@ public function setAdminTheme()
$this->config = json_decode( json_encode ( ( array ) simplexml_load_string($sXMLConfigFile), 1));

// If developers want to test asset manager with debug mode on
$this->use_asset_manager = isset($this->config->engine->use_asset_manager_in_debug_mode)?( $this->config->engine->use_asset_manager_in_debug_mode == 'true'):'false';
self::$use_asset_manager = isset($this->config->engine->use_asset_manager_in_debug_mode)?( $this->config->engine->use_asset_manager_in_debug_mode == 'true'):'false';

$this->defineConstants(); // Define the (still) necessary constants
$this->registerStylesAndScripts(); // Register all CSS and JS
Expand Down Expand Up @@ -184,7 +184,7 @@ public function registerStylesAndScripts()
// When defining the package with a base path (a directory on the file system), the asset manager is used
// When defining the package with a base url, the file is directly registerd without the asset manager
// See : http://www.yiiframework.com/doc/api/1.1/CClientScript#packages-detail
if( !YII_DEBUG || $this->use_asset_manager)
if( !YII_DEBUG || self::$use_asset_manager)
{
Yii::setPathOfAlias('admin.theme.path', $this->path);
$package['basePath'] = 'admin.theme.path'; // add the base path to the package, so it will use the asset manager
Expand Down Expand Up @@ -214,7 +214,7 @@ public function registerStylesAndScripts()
public function registerCssFile( $sPath='template', $sFile='' )
{
// We check if we should use the asset manager or not
if (!YII_DEBUG || $this->use_asset_manager)
if (!YII_DEBUG || self::$use_asset_manager)
{
$path = ($sPath == 'PUBLIC')?dirname(Yii::app()->request->scriptFile).'/styles-public/':$this->path . '/css/'; // We get the wanted path
App()->getClientScript()->registerCssFile( App()->getAssetManager()->publish($path.$sFile) ); // We publish the asset
Expand All @@ -226,14 +226,20 @@ public function registerCssFile( $sPath='template', $sFile='' )
}
}

public function registerScriptFile( $cPATH, $sFile )
{
self::staticRegisterScriptFile( $cPATH, $sFile );
}

/**
* Register a Css File from the correct directory (publict style, style, upload, etc) using the correct method (with / whithout asset manager)
* This function is called from the different controllers when they want to register a specific css file
* Static method is necessary to avoid to init the admin theme to register admin_core script... (see: AdminController::_init())
*
* @var string $sPath 'SCRIPT_PATH' for root/scripts/ ; 'ADMIN_SCRIPT_PATH' for root/scripts/admin/; else templates/scripts (uppercase is an heritage from 2.06, which was using constants )
* @var string $sFile the name of the js file
*/
public function registerScriptFile( $cPATH, $sFile )
static public function staticRegisterScriptFile( $cPATH, $sFile )
{
$bIsInAdminTheme = !($cPATH == 'ADMIN_SCRIPT_PATH' || $cPATH == 'SCRIPT_PATH'); // we check if the path required is in Admin Theme itself.

Expand All @@ -251,7 +257,7 @@ public function registerScriptFile( $cPATH, $sFile )
}

// We check if we should use the asset manager or not
if (!YII_DEBUG || $this->use_asset_manager)
if (!YII_DEBUG || self::$use_asset_manager)
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( $path . $sFile )); // We publish the asset
}
Expand Down Expand Up @@ -411,7 +417,7 @@ static private function getThemeList($sDir)
private function defineConstants()
{
// Define images url
if (!YII_DEBUG || $this->use_asset_manager)
if (!YII_DEBUG || self::$use_asset_manager )
{
define('LOGO_URL', App()->getAssetManager()->publish( $this->path . '/images/logo.png'));
}
Expand Down
3 changes: 2 additions & 1 deletion application/models/Participant.php
Expand Up @@ -1467,7 +1467,8 @@ function updateAttributeValueToken($surveyId, $participantId, $participantAttrib

function copyToCentral($surveyid, $aAttributesToBeCreated, $aMapped, $overwriteauto=false, $overwriteman=false, $createautomap=true)
{
$tokenid = Yii::app()->session['participantid']; //List of token_id's to add to participants table
$tokenid_string = Yii::app()->session['participantid']; //List of token_id's to add to participants table
$tokenid = json_decode($tokenid_string);
$duplicate = 0;
$sucessfull = 0;
$writearray = array();
Expand Down
7 changes: 5 additions & 2 deletions application/models/TemplateConfiguration.php
Expand Up @@ -230,9 +230,12 @@ private function setOtherFiles()
{
while (false !== ($file = readdir($handle)))
{
if (!is_dir($file))
if($file!='.' && $file!='..')
{
$otherfiles[] = array("name" => $file);
if (!is_dir($file))
{
$otherfiles[] = array("name" => $file);
}
}
}
closedir($handle);
Expand Down
Expand Up @@ -52,7 +52,7 @@
?>

<!-- settings -->
<div class="col-sm-12 col-md-5" id="accordion-container" style="background-color: #fff; z-index: 2;">
<div class="col-sm-12 col-md-5" id="accordion-container" style="background-color: #fff;">
<?php
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'read'))
{
Expand Down
5 changes: 4 additions & 1 deletion application/views/admin/survey/editLocalSettings_view.php
Expand Up @@ -96,7 +96,10 @@
$this->widget('yiiwheels.widgets.buttongroup.WhButtonGroup', array(
'name' => 'numberformat_'.$esrow['surveyls_language'],
'value'=> $esrow['surveyls_numberformat'] ,
'selectOptions'=>$aRadixPoint
'selectOptions'=>$aRadixPoint,
'htmlOptions' => array(
"style" => "z-index:-1"
)
));
?>
</div>
Expand Down
11 changes: 9 additions & 2 deletions docs/release_notes.txt
Expand Up @@ -35,16 +35,23 @@ Thank you to everyone who helped with this new release!
CHANGE LOG
------------------------------------------------------

Changes from 2.50+ (build 160727) to 2.50+ (build 160728) July 26, 2016
-Fixed issue #11484: PHP error when adding participants to CPDB (markusfluer)
-Fixed issue: Manually adding subquestions did not work correctly (markusfluer)

Changes from 2.50+ (build 160726) to 2.50+ (build 160727) July 26, 2016
-Fixed issue #11496: Numbers not adding correctly (markusfluer)
-Fixed issue: Z-index problems in survey editing (markusfluer)

Changes from 2.50+ (build 160725) to 2.50+ (build 160726) July 26, 2016
-Fixed issue #11488: HTML editor in "Edit subquestions" (Array numbers) not working correctly (markusfluer)
-Fixed issue #11492: Answer Lists (DropDowns) disappeared from all my surveys (markusfluer)
-Fixed issue #11492: Answer lists (dropDowns) disappeared from all my surveys (markusfluer)
#Updated translation: French (France) by arnaud21
#Updated translation: German by c_schmitz
#Updated translation: Greek by kiolalis
#Updated translation: Polish by elisa
#Updated translation: Polish (Informal) by elisa


Changes from 2.50+ (build 160718) to 2.50+ (build 160725) July 25, 2016
-Fixed issue: [security] Better check on XML uploads
-Fixed issue #11416: Google Analytics Global Configuration is not being used by survey (Markus Flür)
Expand Down
80 changes: 34 additions & 46 deletions scripts/array-totalsum.js
Expand Up @@ -11,80 +11,68 @@ $( document ).ready(function() {

function updatetotals()
{
sRadix=LSvar.sLEMradix;
sTableID=$(this).closest('table').attr('id')
iGrandTotal=0;
var sRadix=LSvar.sLEMradix;
var sTableID=$(this).closest('table').attr('id');
var sTable=$(this).closest('table');
var iGrandTotal=0;

// Sum all rows
$('#'+sTableID+' tr').each(function () {
sTable.find('tr').each(function () {
//the value of sum needs to be reset for each row, so it has to be set inside the row loop
var sum = 0
var sum = new Number(0);
//find the elements in the current row and sum it
$(this).find('input:enabled:visible').each(function () {
//sum the values
sum +=normalizeValue($(this).val());
var value = normalizeValue($(this).val());
sum += value;
});
//set the value of currents rows sum to the total-combat element in the current row
$(this).find('input:disabled').val(formatValue(sum));
iGrandTotal +=sum;
});
// Sum all columns
// First get number of columns (only visible and enabled inputs)
iColumns=$('#'+sTableID+' tbody tr:first-child input:enabled:visible').length;
for (i = 1; i <= iColumns; i++) {
var iColumnNum=$('#'+sTableID+' tbody tr:first-child input:enabled:visible').length;
//Get An array of jQuery Objects
var $iRow = sTable.find('tr');
//Iterate through the columns
for (var i = 1; i <= iColumnNum; i++)
{
var sum = 0;
$('#'+sTableID+' tbody tr td.text-item:nth-of-type('+i+') input:enabled:visible').each(function () {
$iRow.each(function(){
var item = $($(this).find('td').get((i-1))).find('input:enabled:visible'),
val = normalizeValue($(item).val());
//sum the values
sum +=normalizeValue($(this).val());
sum += val;
});
$('#'+sTableID+' tr td.total:nth-of-type('+i+') input:disabled').val(formatValue(sum));
$($iRow.last().find('td').get((i-1))).find('input:disabled').val(formatValue(sum));
}
iColumns++;
$('#'+sTableID+' tr:last-child td.total:nth-of-type('+iColumns+') input:disabled').val(formatValue(iGrandTotal));

//$('#'+sTableID+' tr:last-child td.total:nth-of-type('+iColumns+') input:disabled').val(formatValue(iGrandTotal));
//$iRow.last().find('td.total').find('input:disabled').val(formatValue(iGrandTotal,numberOfDecimals));
// Grand total
}
function formatValue(sValue)
{
sValue=''+sValue;
sRadix=LSvar.sLEMradix;
sValue=sValue.replace('.',sRadix)

sValue=Number(sValue).toString();
var sRadix=LSvar.sLEMradix;
sValue=sValue.replace('.',sRadix);
return sValue;
}

function normalizeValue(aValue)
{
var numRegex;
var sRadix;

sRadix=LSvar.sLEMradix;
if (sRadix=='.')
{
numRegex = /^[+-]?((\d+(\.\d*)?)|(\.\d+))$/;
}
else
{
numRegex = /^-?\d{1,3}(?:\.\d{3})*(?:,\d+)?$/;
}
if (aValue.slice(-1)==sRadix)
{
aValue=aValue.slice(0, -1);
}
if (numRegex.test(aValue))
{
if (sRadix==',')
{
aValue=aValue.replace(/ \./g,'')
aValue=aValue.replace(/,/g,'.')
}
else{
aValue=aValue.replace(/ ,/g,'')
}
}
else
aValue = aValue || 0;
var number = new Number(aValue);
if(isNaN(number))
{
aValue=0;
var numReplaced = aValue.replace(/,/g, ".");
var number = new Number(numReplaced);
return number;
} else {
return number;
}
return +aValue || 0;
}


0 comments on commit aee547c

Please sign in to comment.