Skip to content

Commit

Permalink
Dev: some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 13, 2017
1 parent e5682b0 commit fd8c1a4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
38 changes: 34 additions & 4 deletions application/models/TemplateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class TemplateManifest extends TemplateConfiguration
/** @var SimpleXMLElement $oOptions The template options */
public $oOptions;


/** @var string $iSurveyId The current Survey Id. It can be void. It's use only to retreive the current template of a given survey */
private $iSurveyId='';

Expand Down Expand Up @@ -202,7 +201,12 @@ public function getFilePathForEdition($sFile, $aAllowedFiles=null)
return $this->getFilePath($sFile, $this);
}


/**
* Copy a file from mother template to local directory and edit manifest if needed
*
* @param string $sTemplateName
* @return string template url
*/
public function extendsFile($sFile)
{

Expand Down Expand Up @@ -262,6 +266,13 @@ public function extendsFile($sFile)
return $this->getFilePath($sFile, $this);
}

/**
* Get the files (css or js) defined in the manifest of a template and its mother templates
*
* @param string $type css|js
* @param string $oRTemplate template from which the recurrence should start
* @return array
*/
public function getFilesForPackages($type, $oRTemplate)
{
$aFiles = array();
Expand All @@ -273,6 +284,14 @@ public function getFilesForPackages($type, $oRTemplate)
return $aFiles;
}


/**
* Get the template for a given file. It checks if a file exist in the current template or in one of its mother templates
*
* @param string $sFile the file to look for (must contain relative path, unless it's a view file)
* @param string $oRTemplate template from which the recurrence should start
* @return TemplateManifest
*/
public function getTemplateForFile($sFile, $oRTemplate)
{
while (!file_exists($oRTemplate->path.'/'.$sFile) && !file_exists($oRTemplate->viewPath.$sFile)){
Expand All @@ -287,6 +306,10 @@ public function getTemplateForFile($sFile, $oRTemplate)
return $oRTemplate;
}

/**
* Get the list of all the files for a template and its mother templates
* @return array
*/
public function getOtherFiles()
{
$otherfiles = array();
Expand Down Expand Up @@ -397,6 +420,7 @@ static public function extendsConfig($sToExtends, $sNewName)
* And it will publish the CSS and the JS defined in config.xml. So CSS can use relative path for pictures.
* The publication of the package itself is in LSETwigViewRenderer::renderTemplateFromString()
*
* @param $oTemplate TemplateManifest
*/
private function createTemplatePackage($oTemplate)
{
Expand Down Expand Up @@ -455,8 +479,8 @@ private function createTemplatePackage($oTemplate)

/**
* Change the mother template configuration depending on template settings
* @var $sType string the type of settings to change (css or js)
* @var $aSettings array array of local setting
* @param $sType string the type of settings to change (css or js)
* @param $aSettings array array of local setting
* @return array
*/
private function changeMotherConfiguration( $sType, $aSettings )
Expand Down Expand Up @@ -642,6 +666,12 @@ private function getDependsPackages($oTemplate)
return $packages;
}

/**
* Get the list of file replacement from Engine Framework
* @param string $sType css|js the type of file
* @param boolean $bInlcudeRemove also get the files to remove
* @return array
*/
private function getFrameworkAssetsToReplace( $sType, $bInlcudeRemove = false)
{
$aAssetsToRemove = array();
Expand Down
6 changes: 3 additions & 3 deletions templates/default/views/layout_global.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
{{ registerTemplateCssFile("css/background-image.css") }}
{% endif %}

{% else %}
{{ unregisterScriptForAjax()}}
{% endif %}
{% else %}
{{ unregisterScriptForAjax()}}
{% endif %}



Expand Down

0 comments on commit fd8c1a4

Please sign in to comment.