Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/LimeSurvey/LimeSurvey
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed May 2, 2016
2 parents e18501b + b5ad3fa commit f5ae734
Show file tree
Hide file tree
Showing 44 changed files with 550 additions and 225 deletions.
4 changes: 0 additions & 4 deletions application/config/third_party.php
Expand Up @@ -21,10 +21,6 @@
'bootstrap' => array(
'basePath' => 'bootstrap',
'css'=> array(
/* Not needed for templates ! they use their own theme !
'css/bootstrap.css',
'css/yiistrap.css',
*/
),
'depends' => array(
'jquery',
Expand Down
25 changes: 20 additions & 5 deletions application/controllers/AdminController.php
Expand Up @@ -30,7 +30,15 @@ protected function _init()
$this->_sessioncontrol();
define('ADMIN_SCRIPT_PATH', realpath ( Yii::app()->basePath .'/../scripts/admin/') . '/');
define('SCRIPT_PATH', realpath ( Yii::app()->basePath .'/../scripts/') . '/');
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH.'/admin_core.js' ));

if(!YII_DEBUG)
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH.'/admin_core.js' ));
}
else
{
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "admin_core.js");
}

$this->user_id = Yii::app()->user->getId();
if (!Yii::app()->getConfig("surveyid")) {Yii::app()->setConfig("surveyid", returnGlobal('sid'));} //SurveyID
Expand Down Expand Up @@ -130,10 +138,10 @@ protected function _sessioncontrol()
public function run($action)
{
// Check if the DB is up to date
if (Yii::app()->db->schema->getTable('{{surveys}}'))
if (Yii::app()->db->schema->getTable('{{surveys}}') )
{
$sDBVersion = getGlobalSetting('DBVersion');
if ((int) $sDBVersion < Yii::app()->getConfig('dbversionnumber') && $action != 'databaseupdate' && $action != 'authentication')
if ((int) $sDBVersion < Yii::app()->getConfig('dbversionnumber') && $action != 'databaseupdate')
$this->redirect(array('/admin/databaseupdate/sa/db'));
}

Expand Down Expand Up @@ -307,7 +315,7 @@ public function _getAdminHeader($meta = false, $return = false)
// RTL style
if ($aData['bIsRTL'])
{
if (!isset($oAdmintheme->config->files->rtl)
if (!isset($oAdmintheme->config->files->rtl)
|| !isset($oAdmintheme->config->files->rtl->css))
{
throw new CException("Invalid template configuration: No CSS files found for right-to-left languages");
Expand Down Expand Up @@ -335,7 +343,14 @@ public function _getAdminHeader($meta = false, $return = false)
$sOutput = $this->renderPartial("/admin/super/header", $aData, true);

// Define images url
define('LOGO_URL', App()->getAssetManager()->publish( dirname(Yii::app()->request->scriptFile).'/styles/'.$oAdmintheme->name.'/images/logo.png'));
if(!YII_DEBUG)
{
define('LOGO_URL', App()->getAssetManager()->publish( dirname(Yii::app()->request->scriptFile).'/styles/'.$oAdmintheme->name.'/images/logo.png'));
}
else
{
define('LOGO_URL', Yii::app()->getBaseUrl().'/styles/'.$oAdmintheme->name.'/images/logo.png');
}

// Define presentation text on welcome page
if($oAdmintheme->config->metadatas->presentation)
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/assessments.php
Expand Up @@ -79,7 +79,7 @@ protected function _renderWrappedTemplate($sAction = 'assessments', $aViewUrls =
$aData['title_bar']['title'] = $surveyinfo['surveyls_title']."(".gT("ID").":".$iSurveyID.")";
$aData['surveybar']['savebutton']['form'] = TRUE;
$aData['gid']=null;
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'assessments.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'assessments.js');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

Expand Down
6 changes: 2 additions & 4 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -1192,8 +1192,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)

if ($scenariocount > 0)
{

App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("adminscripts").'checkgroup.js');
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'checkgroup.js');
foreach ($scenarioresult as $scenarionr)
{
$scenariotext = "";
Expand Down Expand Up @@ -1896,9 +1895,8 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)

$aViewUrls['output'] .= "</div>\n"; // end conditiontarget div

$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'conditions.js');

App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("adminscripts").'conditions.js');
//App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts").'jquery/lime-conditions-tabs.js');

if ($subaction == "editthiscondition" && isset($p_cid))
{
Expand Down
11 changes: 6 additions & 5 deletions application/controllers/admin/dataentry.php
Expand Up @@ -939,8 +939,9 @@ public function editdata($subaction, $id, $surveyid, $language='')
$aDataentryoutput .= '</div>';
App()->getClientScript()->registerPackage('jquery-actual');

App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( SCRIPT_PATH.'ranking.js' ));
App()->getClientScript()->registerCssFile( App()->getAssetManager()->publish( dirname(Yii::app()->request->scriptFile).'/styles-public/ranking.css') );
$this->registerScriptFile( 'SCRIPT_PATH', 'ranking.js');
$this->registerCssFile( 'PUBLIC', 'ranking.css' );

$aDataentryoutput .= "<script type='text/javascript'>\n"
. " <!--\n"
. "var aRankingTranslations = {
Expand Down Expand Up @@ -2194,9 +2195,9 @@ public function view($surveyid, $lang=NULL)
$answers[] = $ansrow;
}
$cdata['answers']=$answers;
App()->getClientScript()->registerPackage('jquery-actual');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . 'ranking.js');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . 'ranking.css');
App()->getClientScript()->registerPackage('jquery-actual');
$this->registerScriptFile( 'SCRIPT_PATH', 'ranking.js');
$this->registerCssFile( 'PUBLIC', 'ranking.css' );
unset($answers);
break;
case "M": //Multiple choice checkbox (Quite tricky really!)
Expand Down
4 changes: 1 addition & 3 deletions application/controllers/admin/emailtemplates.php
Expand Up @@ -177,10 +177,8 @@ function update($iSurveyId)
*/
protected function _renderWrappedTemplate($sAction = 'emailtemplates', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'emailtemplates.js' ));

$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'emailtemplates.js');
$aData['display']['menu_bars']['surveysummary'] = 'editemailtemplates';

parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

Expand Down
6 changes: 3 additions & 3 deletions application/controllers/admin/export.php
Expand Up @@ -144,8 +144,8 @@ public function exportresults()

Yii::app()->loadHelper("admin/exportresults");

App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( SCRIPT_PATH . '/expressions/em_javascript.js' ));
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . '/exportresults.js' ));
$this->registerScriptFile( 'SCRIPT_PATH', '/expressions/em_javascript.js');
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', '/exportresults.js');

$sExportType = Yii::app()->request->getPost('type');
$sHeadingFormat = Yii::app()->request->getPost('headstyle');
Expand Down Expand Up @@ -1091,7 +1091,7 @@ public function quexml($iSurveyID)
$aData['sidemenu']['state'] = false;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title']."(".gT("ID").":".$iSurveyID.")";

array_unshift($aData['slangs'],$aData['baselang']);

Yii::import("application.libraries.admin.quexmlpdf",TRUE);
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/expressions.php
Expand Up @@ -35,9 +35,9 @@ function index()
else
{
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( SCRIPT_PATH . 'survey_runtime.js' ));
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( SCRIPT_PATH . '/expressions/em_javascript.js' ));

$this->registerScriptFile( 'SCRIPT_PATH', 'survey_runtime.js');
$this->registerScriptFile( 'SCRIPT_PATH', '/expressions/em_javascript.js');
$this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index'));
$aData['pagetitle']="ExpressionManager: {$aData['sa']}";

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/globalsettings.php
Expand Up @@ -318,7 +318,7 @@ private function _checkSettings()
*/
protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . "globalsettings.js" ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'globalsettings.js');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
}
2 changes: 1 addition & 1 deletion application/controllers/admin/homepagesettings.php
Expand Up @@ -332,7 +332,7 @@ protected function performAjaxValidation($model)
*/
protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'homepagesettings.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'homepagesettings.js');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

Expand Down
6 changes: 2 additions & 4 deletions application/controllers/admin/labels.php
Expand Up @@ -175,7 +175,6 @@ public function index($sa, $lid=0)
{
if ($sa == "editlabelset" && Permission::model()->hasGlobalPermission('labelsets','update'))
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . 'labels.js' ));
$result = LabelSet::model()->findAllByAttributes(array('lid' => $lid));
foreach ($result as $row)
{
Expand Down Expand Up @@ -250,7 +249,6 @@ public function view($lid = 0)
$aData = array();

// Includes some javascript files
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'labels.js' ));
App()->getClientScript()->registerPackage('jquery-json');
// Checks if user have the sufficient rights to manage the labels
// Get a result containing labelset with the specified id
Expand Down Expand Up @@ -423,8 +421,6 @@ public function exportmulti()
{
if (Permission::model()->hasGlobalPermission('labelsets','export'))
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'labels.js' ));

$aData['labelbar']['savebutton']['form'] = 'exportlabelset';
$aData['labelbar']['savebutton']['text'] = gT("Export multiple label sets");
$aData['labelbar']['closebutton']['url'] = Yii::app()->request->getUrlReferrer( Yii::app()->createUrl('admin/labels/sa/view'), array('newlabelset') );
Expand Down Expand Up @@ -499,6 +495,8 @@ public function ajaxSets()
*/
protected function _renderWrappedTemplate($sAction = 'labels', $aViewUrls = array(), $aData = array())
{
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH ', 'labels.js');

if (!isset($aData['display']['menu_bars']['labels']) || $aData['display']['menu_bars']['labels'] != false)
{
if (empty($aData['labelsets']))
Expand Down
18 changes: 8 additions & 10 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -62,7 +62,7 @@ private function _loadjqGrid($sScript = '', $aData = array())
App()->getClientScript()->registerPackage('jqgrid');
if (!empty($sScript))
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . $sScript . '.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', $sScript . '.js');
$this->_renderWrappedTemplate('participants', array('participantsPanel', $sScript), $aData);
}
}
Expand Down Expand Up @@ -1002,9 +1002,7 @@ public function viewAttribute()
'attributevalues' => ParticipantAttributeName::model()->getAttributesValues($iAttributeId),
'aAttributes' => ParticipantAttributeName::model()->getAllAttributes()
);
//App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl').'participants.css');
//App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl').'viewAttribute.css');
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . "viewAttribute.js"));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'viewAttribute.js');
$this->_renderWrappedTemplate('participants', array('participantsPanel', 'viewAttribute'), $aData);
}

Expand Down Expand Up @@ -1198,7 +1196,7 @@ public function attributeMapCSV()
);
App()->getClientScript()->registerPackage('qTip2');
App()->getClientScript()->registerPackage('jquery-nestedSortable');
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . "attributeMapCSV.js" ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'attributeMapCSV.js');

$sAttributeMapJS="var copyUrl = '".App()->createUrl("admin/participants/sa/uploadCSV")."';\n"
."var displayParticipants = '".App()->createUrl("admin/participants/sa/displayParticipants")."';\n"
Expand Down Expand Up @@ -1514,14 +1512,14 @@ public function shareParticipants()
$iShareUserId = Yii::app()->request->getPost('shareuser');
$bCanEdit = Yii::app()->request->getPost('can_edit');

// Some input validation needed
// Some input validation needed
if ($iShareUserId == '') {
printf(gT("Please select a user"));
return;
}

$i = 0;
// $iShareUserId == 0 means any user
// $iShareUserId == 0 means any user
if (Permission::model()->hasGlobalPermission('participantpanel','update') && $iShareUserId !== '')
foreach ($iParticipantId as $iId)
{
Expand Down Expand Up @@ -1655,7 +1653,7 @@ public function addToTokenattmap()
public function attributeMap()
{
Yii::app()->loadHelper('common');
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . "attributeMap.js" ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'attributeMap.js');

$iSurveyId = Yii::app()->request->getPost('survey_id');
$redirect = Yii::app()->request->getPost('redirect');
Expand Down Expand Up @@ -1727,8 +1725,8 @@ public function attributeMap()
public function attributeMapToken()
{
Yii::app()->loadHelper('common');
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . "attributeMapToken.js"));
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') ."css/attributeMapToken.css");
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'attributeMapToken.js');
$this->registerCssFile( 'ADMIN', 'attributeMapToken.css' );

$iSurveyID = (int)Yii::app()->request->getQuery('sid');
$aCPDBAttributes = ParticipantAttributeName::model()->getCPDBAttributes();
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/questiongroups.php
Expand Up @@ -159,8 +159,8 @@ function add($surveyid)
$grplangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$baselang = Survey::model()->findByPk($surveyid)->language;
$grplangs[] = $baselang;
$grplangs = array_reverse($grplangs);
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'questiongroup.js' ));
$grplangs = array_reverse($grplangs);
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'questiongroup.js');

$aData['display']['menu_bars']['surveysummary'] = 'addgroup';
$aData['surveyid'] = $surveyid;
Expand Down
9 changes: 4 additions & 5 deletions application/controllers/admin/questions.php
Expand Up @@ -424,7 +424,7 @@ public function answeroptions($surveyid, $gid, $qid)
$surveyid = sanitize_int($surveyid);
$qid = sanitize_int($qid);
$gid = sanitize_int($gid);
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'answers.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'answers.js');
App()->getClientScript()->registerPackage('jquery-selectboxes');

$surveyinfo = Survey::model()->findByPk($surveyid)->surveyinfo;
Expand Down Expand Up @@ -634,7 +634,7 @@ public function subquestions($surveyid, $gid, $qid)
$aData['gid'] = $gid = sanitize_int($gid);
$aData['qid'] = $qid = sanitize_int($qid);

App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'subquestions.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'subquestions.js');
App()->getClientScript()->registerPackage('jquery-blockUI');
App()->getClientScript()->registerPackage('jquery-selectboxes');
Yii::app()->session['FileManagerContext'] = "edit:answer:{$surveyid}";
Expand Down Expand Up @@ -983,8 +983,7 @@ public function newquestion($surveyid)
{
$aData['oqresult'] = array();
}

App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'questions.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'questions.js');

$aViewUrls['editQuestion_view'][] = $aData;
$aViewUrls['questionJavascript_view'][] = array('type' => $eqrow['type']);
Expand Down Expand Up @@ -1232,7 +1231,7 @@ public function index($sa, $surveyid, $gid, $qid=null)
$oqresult = Question::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $baselang, 'parent_qid'=> 0), array('order' => 'question_order'));
$aData['oqresult'] = $oqresult;
}
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . 'questions.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'questions.js');

$aData['sValidateUrl'] = ($adding || $copying)?$this->getController()->createUrl('admin/questions', array('sa' => 'ajaxValidate','surveyid'=>$surveyid)):$this->getController()->createUrl('admin/questions', array('sa' => 'ajaxValidate','surveyid'=>$surveyid,'qid'=>$qid));

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/quotas.php
Expand Up @@ -623,7 +623,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
*/
protected function _renderWrappedTemplate($sAction = 'quotas', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( ADMIN_SCRIPT_PATH . '/quotas.js' ));
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'quotas.js');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

Expand Down

0 comments on commit f5ae734

Please sign in to comment.