Skip to content

Commit

Permalink
Fixed issue #11296: Asset directory clearing, use AdminTheme::registe…
Browse files Browse the repository at this point in the history
…rScriptFile() for all the admin ui scripts registration
  • Loading branch information
LouisGac committed Jun 2, 2016
1 parent 839b023 commit 97b2bf3
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 49 deletions.
2 changes: 1 addition & 1 deletion application/controllers/RegisterController.php
Expand Up @@ -462,7 +462,7 @@ private function display($iSurveyId)
if(empty(App()->clientScript->scripts)){
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-touch-punch');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");
useFirebug();
$this->render('/register/display',$aViewData);
}else{
Expand Down
5 changes: 3 additions & 2 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -1143,7 +1143,7 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$aViewUrls = array();

$oQuestion = Question::model()->find('qid=:qid', array(':qid'=>$qid));
$aData['oQuestion']=$oQuestion;
$aData['oQuestion']=$oQuestion;

$aData['surveyid'] = $iSurveyID;
$aData['qid'] = $qid;
Expand Down Expand Up @@ -1619,7 +1619,8 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
if (isset($conditionsList) && is_array($conditionsList))
{
//TIBO
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts").'jquery/jquery.multiselect.min.js');
$this->registerScriptFile( 'SCRIPT_PATH', 'jquery.multiselect.min.js');
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'checkgroup.js');

// TODO
$aViewUrls['output'] .= "<script type='text/javascript'>$(document).ready(function () { $('#copytomultiselect').multiselect( { autoOpen: true, noneSelectedText: '".gT("No questions selected")."', checkAllText: '".gT("Check all")."', uncheckAllText: '".gT("Uncheck all")."', selectedText: '# ".gT("selected")."', beforeclose: function(){ return false;},height: 200 } ); });</script>";
Expand Down
3 changes: 1 addition & 2 deletions application/controllers/admin/statistics.php
Expand Up @@ -812,8 +812,7 @@ public function simpleStatistics($surveyid)
*/
protected function _renderWrappedTemplate($sAction = 'export', $aViewUrls = array(), $aData = array())
{
$switch = Yii::app()->getBaseUrl(true).'/application/extensions/yiiwheels/widgets/switch/assets/js/bootstrap-switch.min.js ';
App()->getClientScript()->registerScriptFile( $switch );
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'bootstrap-switch.min.js');

$aData['menu']['closeurl'] = Yii::app()->request->getUrlReferrer(Yii::app()->createUrl("/admin/survey/sa/view/surveyid/".$aData['surveyid']), array('simpleStatistics', 'admin/statistics/sa/index') );

Expand Down
25 changes: 0 additions & 25 deletions application/core/Survey_Common_Action.php
Expand Up @@ -1338,18 +1338,6 @@ public function registerScriptFile( $cPATH, $sFile )
{
$oAdminTheme = AdminTheme::getInstance();
$oAdminTheme->registerScriptFile( $cPATH, $sFile );
/*
if (!YII_DEBUG)
{
$path = ($cPATH == 'ADMIN_SCRIPT_PATH')?ADMIN_SCRIPT_PATH:SCRIPT_PATH; // We get the wanted constant
App()->getClientScript()->registerScriptFile( App()->getAssetManager()->publish( $path . $sFile )); // We publish the asset
}
else
{
$url = ($cPATH == 'ADMIN_SCRIPT_PATH')?Yii::app()->getConfig('adminscripts'):Yii::app()->getConfig('generalscripts'); // We get the wanted url defined in config
App()->getClientScript()->registerScriptFile( $url . $sFile ); // We publish the script
}
*/
}

/**
Expand All @@ -1362,19 +1350,6 @@ public function registerCssFile( $sPath, $sFile )
{
$oAdminTheme = AdminTheme::getInstance();
$oAdminTheme->registerCssFile( $sPath, $sFile );
/*
if (!YII_DEBUG)
{
$path = ($sPath == 'PUBLIC')?dirname(Yii::app()->request->scriptFile).'/styles-public/':ADMIN_CSS_PATH; // We get the wanted constant
App()->getClientScript()->registerCssFile( App()->getAssetManager()->publish($path.$sFile) ); // We publish the asset
}
else
{
$url = ($sPath == 'PUBLIC')?Yii::app()->getConfig('publicstyleurl'):Yii::app()->getConfig('adminstyleurl').'/css/'; // We get the wanted url defined in config
App()->getClientScript()->registerCssFile( $url.$sFile ); // We publish the css file
}
*/
}

protected function _filterImportedResources($extractdir, $destdir)
Expand Down
6 changes: 3 additions & 3 deletions application/models/UpdateForm.php
Expand Up @@ -377,17 +377,17 @@ public function republishAssets()
Template::model()->forceAssets();
AdminTheme::forceAssets();

// Clear asset directory, but not the directory itself not the index.html at the root ^^
// Delete all the content in the asset directory, but not the directory itself nor the index.html file at its root ^^
$sAssetsDir = Yii::app()->getConfig('tempdir') . '/assets/';
$dir = dir($sAssetsDir);
while (false !== $entry = $dir->read())
{
if ($entry == '.' || $entry == '..' || $entry == 'index.html' ) {
if ($entry == '.' || $entry == '..' || $entry == 'index.html' )
{
continue;
}
rmdirr($sAssetsDir . DIRECTORY_SEPARATOR . $entry);
}

}


Expand Down
@@ -1,6 +1,7 @@
<?php
$surveyinfo = getSurveyInfo($surveyid);
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'emailtemplates.js');

$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'emailtemplates.js');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . 'popup-dialog.css');

$count=0;
Expand Down
@@ -1,6 +1,6 @@
<?php
/**
* This file register chartjs, and define needed js variables for statistics view.
* This file register chartjs, and define needed js variables for statistics view.
*/
?>
<script type='text/javascript'>
Expand All @@ -10,7 +10,9 @@
var showTextInline="<?php echo $showtextinline ?>";
</script>

<?php App()->getClientScript()->registerScriptFile(Yii::app()->baseUrl.'/third_party/chartjs/Chart.min.js'); ?>
<?php
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'Chart.min.js');
?>

<script>
var CSS_COLOR_NAMES = ["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","Darkorange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"];
Expand Down
@@ -1,6 +1,6 @@
<?php
App()->getClientScript()->registerPackage('jquery-nestedSortable');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'organize.js');
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'organize.js');
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . 'organize.css');
?>

Expand Down
25 changes: 13 additions & 12 deletions application/views/admin/token/bounce.php
Expand Up @@ -107,20 +107,21 @@
</div>
</div>
</div>

</div>
<!-- buttons -->
<div class="buttons control-group hidden">
<button name="save" value="save" class="btn" type="submit">Save bounce settings</button>
<a class="btn btn-link button" href="/LimeSurveyNext/index.php/admin/tokens?sa=index&amp;surveyid=274928">
Cancel
</a>
</div>


</div>

<!-- buttons -->
<div class="buttons control-group hidden">
<button name="save" value="save" class="btn" type="submit">Save bounce settings</button>
<a class="btn btn-link button" href="/LimeSurveyNext/index.php/admin/tokens?sa=index&amp;surveyid=274928">
Cancel
</a>
</div>
</form>
</div> <!-- bouncesettingsdiv -->
</div> <!-- col -->
</div> <!-- Row -->
</div> <!-- Side body -->
<?php App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "tokenbounce.js"); ?>

<?php
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'tokenbounce.js');
?>
11 changes: 11 additions & 0 deletions scripts/admin/Chart.min.js

Large diffs are not rendered by default.

0 comments on commit 97b2bf3

Please sign in to comment.