Skip to content

Commit

Permalink
Dev: rename setTemplateConfiguration to prepareTemplateRendering
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Aug 14, 2017
1 parent 7a4957f commit 96d3966
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
10 changes: 5 additions & 5 deletions application/controllers/admin/templateoptions.php
Expand Up @@ -74,10 +74,10 @@ private function _updateCommon($model,$sid=null){
// $this->performAjaxValidation($model);

$templateOptionPage = $model->optionPage;

yii::app()->clientScript->registerPackage('bootstrap-switch');
$aData = array(
'model'=>$model,
'model'=>$model,
'templateOptionPage' => $templateOptionPage
);
if($sid !== null){
Expand All @@ -102,8 +102,8 @@ public function update($id)
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/templateoptions"));
}
$model = $this->loadModel($id);
$model->setTemplateConfiguration();
$model->prepareTemplateRendering();

if(isset($_POST['TemplateConfiguration'])){
$model->attributes=$_POST['TemplateConfiguration'];
if($model->save())
Expand All @@ -127,7 +127,7 @@ public function updatesurvey($sid)
}

$model = Template::getTemplateConfiguration(null, $sid);
$model->setTemplateConfiguration();
$model->prepareTemplateRendering();

if(isset($_POST['TemplateConfiguration'])){
$model->attributes=$_POST['TemplateConfiguration'];
Expand Down
10 changes: 5 additions & 5 deletions application/controllers/admin/templates.php
Expand Up @@ -43,7 +43,7 @@ public function runWithParams($params)
public function templatezip($templatename)
{
$oEditedTemplate = Template::model()->getTemplateConfiguration($templatename);
$oEditedTemplate->setTemplateConfiguration($sTemplateName);
$oEditedTemplate->prepareTemplateRendering($sTemplateName);
if (!Permission::model()->hasGlobalPermission('templates','export'))
{
die('No permission');
Expand Down Expand Up @@ -230,7 +230,7 @@ public function uploadfile()
$editfile = App()->request->getPost('editfile');
$templatename = returnGlobal('templatename');
$oEditedTemplate = Template::model()->getTemplateConfiguration($templatename);
$oEditedTemplate->setTemplateConfiguration($sTemplateName);
$oEditedTemplate->prepareTemplateRendering($sTemplateName);
$templatedir = $oEditedTemplate->viewPath;
$screenname = returnGlobal('screenname');
$cssfiles = $oEditedTemplate->getValidScreenFiles("css");
Expand Down Expand Up @@ -389,7 +389,7 @@ public function templatefiledelete()
}

$sTemplateName = Template::templateNameFilter(App()->request->getPost('templatename'));
$oEditedTemplate = Template::model()->getTemplateConfiguration($sTemplateName); $oEditedTemplate->setTemplateConfiguration($sTemplateName);
$oEditedTemplate = Template::model()->getTemplateConfiguration($sTemplateName); $oEditedTemplate->prepareTemplateRendering($sTemplateName);
$templatedir = $oEditedTemplate->viewPath;
$filesdir = $oEditedTemplate->filesPath;
$sPostedFile = App()->request->getPost('otherfile');
Expand Down Expand Up @@ -587,7 +587,7 @@ public function templatesavechanges()
$sTemplateName = Template::templateNameFilter(App()->request->getPost('templatename'));
$screenname = returnGlobal('screenname');
$oEditedTemplate = Template::model()->getTemplateConfiguration($sTemplateName, null,null, true);
$oEditedTemplate->setTemplateConfiguration($sTemplateName);
$oEditedTemplate->prepareTemplateRendering($sTemplateName);
$aScreenFiles = $oEditedTemplate->getValidScreenFiles("view");
$cssfiles = $oEditedTemplate->getValidScreenFiles("css");
$jsfiles = $oEditedTemplate->getValidScreenFiles("js");
Expand Down Expand Up @@ -702,7 +702,7 @@ protected function _templatesummary($templatename, $screenname, $editfile, $rela
$aData['time'] = $time;
/* Load this template config, else 'survey-template' package can be outdated */
$oEditedTemplate = Template::model()->getTemplateConfiguration($templatename, null,null, true);
$oEditedTemplate->setTemplateConfiguration($templatename);
$oEditedTemplate->prepareTemplateRendering($templatename);
if (!$fnew) {
$aData['filenotwritten'] = true;
}else{
Expand Down
8 changes: 4 additions & 4 deletions application/models/Template.php
Expand Up @@ -212,7 +212,7 @@ public static function getTemplateConfiguration($sTemplateName=null, $iSurveyId=
$criteria->addCondition('gsid=:gsid');
$criteria->addCondition('templates_name=:templates_name');
$criteria->params = array('gsid' => $iSurveyGroupId, 'templates_name' => $sTemplateName);

$oTemplateConfigurationModel = TemplateConfiguration::model()->find($criteria);

// No specific template configuration for this survey
Expand Down Expand Up @@ -268,7 +268,7 @@ public static function getTemplateConfiguration($sTemplateName=null, $iSurveyId=
$oTemplateConfigurationModel = new TemplateManifest;
}

//$oTemplateConfigurationModel->setTemplateConfiguration($sTemplateName, $iSurveyId);
//$oTemplateConfigurationModel->prepareTemplateRendering($sTemplateName, $iSurveyId);
return $oTemplateConfigurationModel;
}

Expand Down Expand Up @@ -428,7 +428,7 @@ public static function isStandardTemplate($sTemplateName)
* Get instance of template object.
* Will instantiate the template object first time it is called.
*
* NOTE 1: This function will call setTemplateConfiguration that create/update all the packages needed to render the template, which imply to do the same for all mother templates
* NOTE 1: This function will call prepareTemplateRendering that create/update all the packages needed to render the template, which imply to do the same for all mother templates
* NOTE 2: So if you just want to access the TemplateConfiguration AR Object, you don't need to use this one. Call it only before rendering anything related to the template.
* NOTE 3: If you need to get the related configuration to this template, rather use: getTemplateConfiguration()
*
Expand All @@ -449,7 +449,7 @@ public static function getInstance($sTemplateName='', $iSurveyId='', $iSurveyGro

if (empty(self::$instance)) {
self::$instance = self::getTemplateConfiguration($sTemplateName, $iSurveyId, $iSurveyGroupId, $bForceXML);
self::$instance->setTemplateConfiguration($sTemplateName, $iSurveyId);
self::$instance->prepareTemplateRendering($sTemplateName, $iSurveyId);
}

return self::$instance;
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateConfig.php
Expand Up @@ -266,7 +266,7 @@ protected function setIsStandard()
// Then, the lonely differences between TemplateManifest and TemplateConfiguration should be how to retreive and format the data
// Note: signature are already the same

public function setTemplateConfiguration($sTemplateName='', $iSurveyId=''){}
public function prepareTemplateRendering($sTemplateName='', $iSurveyId=''){}
public function addFileReplacement($sFile, $sType){}

protected function getFilesToLoad($oTemplate, $sType){}
Expand Down
18 changes: 10 additions & 8 deletions application/models/TemplateConfiguration.php
Expand Up @@ -15,6 +15,8 @@
/*
* This is the model class for table "{{template_configuration}}".
*
* NOTE: if you only need to access to the table, you don't need to call
*
* The followings are the available columns in table '{{template_configuration}}':
* @property string $id
* @property string $templates_name
Expand Down Expand Up @@ -194,7 +196,7 @@ public function getPreview()
public static function importManifest($sTemplateName)
{
$oEditedTemplate = Template::model()->getTemplateConfiguration($sTemplateName, null,null, false);
$oEditedTemplate->setTemplateConfiguration($sTemplateName);
$oEditedTemplate->prepareTemplateRendering($sTemplateName);

$oEditTemplateDb = Template::model()->findByPk($oEditedTemplate->oMotherTemplate->sTemplateName);
$oNewTemplate = new Template;
Expand Down Expand Up @@ -261,7 +263,7 @@ public function checkTemplate()
* @param string $iSurveyId the id of the survey. If
* @return $this
*/
public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')
public function prepareTemplateRendering($sTemplateName='', $iSurveyId='')
{
$this->sTemplateName = $this->template->name;
$this->setIsStandard(); // Check if it is a CORE template
Expand Down Expand Up @@ -341,7 +343,7 @@ class='btn btn-default'>

public function getHasOptionPage()
{
$this->setTemplateConfiguration();
$this->prepareTemplateRendering();
$oRTemplate = $this;
$sOptionFile = '/options/options.twig';
while (!file_exists($oRTemplate->path.$sOptionFile)){
Expand All @@ -351,15 +353,15 @@ public function getHasOptionPage()
return false;
break;
}
$oMotherTemplate->setTemplateConfiguration();
$oMotherTemplate->prepareTemplateRendering();
$oRTemplate = $oMotherTemplate;
}
return true;
}

public function getOptionPage()
{
$this->setTemplateConfiguration();
$this->prepareTemplateRendering();
return Yii::app()->twigRenderer->renderOptionPage($this, array('templateConfiguration' =>$this->attributes));
}

Expand Down Expand Up @@ -429,16 +431,16 @@ protected function removeFileFromPackage( $sPackageName, $sType, $aSettings )

/**
* Configure the mother template (and its mother templates)
* This is an object recursive call to TemplateConfiguration::setTemplateConfiguration()
* This is an object recursive call to TemplateConfiguration::prepareTemplateRendering()
*/
protected function setMotherTemplates()
{
if(!empty($this->template->extends_templates_name)){
$sMotherTemplateName = $this->template->extends_templates_name;
$this->oMotherTemplate = Template::getTemplateConfiguration($sMotherTemplateName);
$this->oMotherTemplate->setTemplateConfiguration($sMotherTemplateName);
$this->oMotherTemplate->prepareTemplateRendering($sMotherTemplateName);
if ($this->oMotherTemplate->checkTemplate()){
$this->oMotherTemplate->setTemplateConfiguration($sMotherTemplateName); // Object Recursion
$this->oMotherTemplate->prepareTemplateRendering($sMotherTemplateName); // Object Recursion
}else{
// Throw exception? Set to default template?
}
Expand Down
6 changes: 3 additions & 3 deletions application/models/TemplateManifest.php
Expand Up @@ -368,7 +368,7 @@ private function setTemplateName($sTemplateName='', $iSurveyId='')
* @param string $iSurveyId the id of the survey. If
* @return $this
*/
public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')
public function prepareTemplateRendering($sTemplateName='', $iSurveyId='')
{
$this->setTemplateName($sTemplateName, $iSurveyId); // Check and set template name
$this->setIsStandard(); // Check if it is a CORE template
Expand Down Expand Up @@ -475,14 +475,14 @@ protected function removeFileFromPackage( $sPackageName, $sType, $aSetting )

/**
* Configure the mother template (and its mother templates)
* This is an object recursive call to TemplateManifest::setTemplateConfiguration()
* This is an object recursive call to TemplateManifest::prepareTemplateRendering()
*/
protected function setMotherTemplates()
{
if (isset($this->config->metadatas->extends)){
$sMotherTemplateName = (string) $this->config->metadatas->extends;
$this->oMotherTemplate = new TemplateManifest;
$this->oMotherTemplate->setTemplateConfiguration($sMotherTemplateName); // Object Recursion
$this->oMotherTemplate->prepareTemplateRendering($sMotherTemplateName); // Object Recursion
}
}

Expand Down

0 comments on commit 96d3966

Please sign in to comment.