Skip to content

Commit

Permalink
Dev: added LS_Twig_Extension::getPostion() to get the CClientscript c…
Browse files Browse the repository at this point in the history
…onstant
  • Loading branch information
LouisGac committed May 11, 2017
1 parent 2af75e5 commit 5634b1c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions application/core/LS_Twig_Extension.php
Expand Up @@ -79,6 +79,7 @@ public static function registerTemplateCssFile($sTemplateCssFileName)
*/
public static function registerGeneralScript($sGeneralScriptFileName, $position=null, array $htmlOptions=array())
{
$position = self::getPosition($position);
Yii::app()->getClientScript()->registerScriptFile(
App()->getConfig('generalscripts') .
$sGeneralScriptFileName,
Expand All @@ -96,6 +97,7 @@ public static function registerTemplateScript($sTemplateScriptFileName, $positio
{
$oAdminTheme = AdminTheme::getInstance();

$position = self::getPosition($position);
Yii::app()->getClientScript()->registerScriptFile(
$oAdminTheme->sTemplateUrl .
$sTemplateScriptFileName,
Expand All @@ -104,6 +106,29 @@ public static function registerTemplateScript($sTemplateScriptFileName, $positio
);
}


public static function getPosition($position){
switch($position) {
case "POS_HEAD":
$position = CClientScript::POS_HEAD;
break;

case "POS_BEGIN":
$position = CClientScript::POS_BEGIN;
break;

case "POS_END":
$position = CClientScript::POS_END;
break;

default:
$position = '';
break;
}

return $position;
}

/**
* Retreive the question classes for a given question id
* Use in survey template question.twig file.
Expand Down

0 comments on commit 5634b1c

Please sign in to comment.