Skip to content

Commit

Permalink
Dev Removed several global functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jun 29, 2015
1 parent 278f289 commit b5d4f42
Show file tree
Hide file tree
Showing 34 changed files with 462 additions and 1,292 deletions.
5 changes: 4 additions & 1 deletion application/config/internal.php
Expand Up @@ -87,12 +87,15 @@
'vardump' => [
'class' => 'CWebLogRoute',
'levels'=>'error, warning, trace, info',
'except' => [
'system.CModule'
],
'enabled' => true
],
'trace' => array(
'class' => 'CWebLogRoute', // you can include more levels separated by commas... trace is shown on debug only
'levels' => 'trace', // you can include more separated by commas
'enabled' => YII_DEBUG && false
'enabled' => false && true || YII_DEBUG && false
),
'profile' => [
'class' => 'CProfileLogRoute'
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/OptinController.php
Expand Up @@ -92,11 +92,11 @@ function actiontokens($surveyid, $token, $langcode = '')
//PRINT COMPLETED PAGE
if (!$aSurveyInfo['templatedir'])
{
$sTemplate=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
$sTemplate=Template::getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
$sTemplate=getTemplatePath($aSurveyInfo['templatedir']);
$sTemplate=Template::getTemplatePath($aSurveyInfo['templatedir']);
}
$this->_renderHtml($sMessage,$sTemplate,$aSurveyInfo);
}
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/OptoutController.php
Expand Up @@ -89,11 +89,11 @@ function actiontokens()
//PRINT COMPLETED PAGE
if (!$aSurveyInfo['templatedir'])
{
$sTemplate=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
$sTemplate=Template::getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
$sTemplate=getTemplatePath($aSurveyInfo['templatedir']);
$sTemplate=Template::getTemplatePath($aSurveyInfo['templatedir']);
}

$this->_renderHtml($sMessage,$sTemplate,$aSurveyInfo);
Expand Down Expand Up @@ -176,11 +176,11 @@ function actionparticipants()
//PRINT COMPLETED PAGE
if (!$aSurveyInfo['templatedir'])
{
$sTemplate=getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
$sTemplate=Template::getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
}
else
{
$sTemplate=getTemplatePath($aSurveyInfo['templatedir']);
$sTemplate=Template::getTemplatePath($aSurveyInfo['templatedir']);
}

$this->_renderHtml($sMessage,$sTemplate, $aSurveyInfo);
Expand Down
12 changes: 6 additions & 6 deletions application/controllers/PrintanswersController.php
Expand Up @@ -67,13 +67,13 @@ function actionView($surveyid,$printableexport=FALSE)
{
sendCacheHeaders();
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/startpage.pstpl'),array());
echo templatereplace(file_get_contents(Template::getTemplatePath($sTemplate).'/startpage.pstpl'),array());
echo "<center><br />\n"
."\t<font color='RED'><strong>".gT("Error")."</strong></font><br />\n"
."\t".gT("We are sorry but your session has expired.")."<br />".gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.")."<br />\n"
."\t".sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail"))."\n"
."</center><br />\n";
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/endpage.pstpl'),array());
echo templatereplace(file_get_contents(Template::getTemplatePath($sTemplate).'/endpage.pstpl'),array());
doFooter();
exit;
}
Expand Down Expand Up @@ -143,17 +143,17 @@ function actionView($surveyid,$printableexport=FALSE)

sendCacheHeaders();
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/startpage.pstpl'),array(),$sData);
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/printanswers.pstpl'),array('ANSWERTABLE'=>$sOutput),$sData);
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/endpage.pstpl'),array(),$sData);
echo templatereplace(file_get_contents(Template::getTemplatePath($sTemplate).'/startpage.pstpl'),array(),$sData);
echo templatereplace(file_get_contents(Template::getTemplatePath($sTemplate).'/printanswers.pstpl'),array('ANSWERTABLE'=>$sOutput),$sData);
echo templatereplace(file_get_contents(Template::getTemplatePath($sTemplate).'/endpage.pstpl'),array(),$sData);
echo "</body></html>";

ob_flush();
}
if($sExportType == 'pdf')
{
// Get images for TCPDF from template directory
define('K_PATH_IMAGES', getTemplatePath($aSurveyInfo['template']).DIRECTORY_SEPARATOR);
define('K_PATH_IMAGES', Template::getTemplatePath($aSurveyInfo['template']).DIRECTORY_SEPARATOR);

Yii::import('application.libraries.admin.pdf', true);
Yii::import('application.helpers.pdfHelper');
Expand Down
6 changes: 3 additions & 3 deletions application/controllers/RegisterController.php
Expand Up @@ -52,7 +52,7 @@ public function actionAJAXRegisterForm($surveyid)
$sLanguage = Yii::app()->request->getParam('lang',$oSurvey->language);
Yii::app()->setLanguage($sLanguage);

$thistpl=getTemplatePath($oSurvey->template);
$thistpl=Template::getTemplatePath($oSurvey->template);
$data['sid'] = $iSurveyId;
$data['startdate'] = $oSurvey->startdate;
$data['enddate'] = $oSurvey->expires;
Expand Down Expand Up @@ -159,7 +159,7 @@ public function getRegisterErrors($iSurveyId){
public function getRegisterForm($iSurveyId){

$aSurveyInfo=getSurveyInfo($iSurveyId,App()->language);
$sTemplate=getTemplatePath($aSurveyInfo['template']);
$sTemplate=Template::getTemplatePath($aSurveyInfo['template']);

// Event to replace register form
$event = new PluginEvent('beforeRegisterForm');
Expand Down Expand Up @@ -419,7 +419,7 @@ private function display($iSurveyId)
$sLanguage=Yii::app()->language;
$aData['surveyid']=$surveyid=$iSurveyId;
$aData['thissurvey']=getSurveyInfo($iSurveyId,$sLanguage);
$sTemplate=getTemplatePath($aData['thissurvey']['template']);
$sTemplate=Template::getTemplatePath($aData['thissurvey']['template']);
Yii::app()->setConfig('surveyID',$iSurveyId);//Needed for languagechanger
$aData['languagechanger']=makeLanguageChangerSurvey($sLanguage);
$aData['sitename']=App()->name;
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/Statistics_userController.php
Expand Up @@ -83,7 +83,7 @@ function actionAction($surveyid,$language=null)
// CHANGE JSW_NZ - let's get the survey title for display
$thisSurveyTitle = $surveyinfo["name"];
// CHANGE JSW_NZ - let's get css from individual template.css - so define path
$thisSurveyCssPath = getTemplateURL($surveyinfo["template"]);
$thisSurveyCssPath = \Template::getTemplateURL($surveyinfo["template"]);
if ($surveyinfo['publicstatistics']!='Y')
{
throw new \CHttpException(500, 'The public statistics for this survey are deactivated.');
Expand Down Expand Up @@ -353,7 +353,7 @@ function actionAction($surveyid,$language=null)
//---------- CREATE STATISTICS ----------
$redata = compact(array_keys(get_defined_vars()));
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($data['sTemplatePath']).DIRECTORY_SEPARATOR."startpage.pstpl"),array(), $redata);
echo templatereplace(file_get_contents(Template::getTemplatePath($data['sTemplatePath']).DIRECTORY_SEPARATOR."startpage.pstpl"),array(), $redata);


//some progress bar stuff
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/SurveysController.php
Expand Up @@ -284,7 +284,7 @@ public function actionAbort()
}
}

$templatePath = getTemplatePath('default');
$templatePath = Template::getTemplatePath('default');
return $this->render('abort', [
'templatePath' => $templatePath,
'surveyId' => isset($surveyId) ? $surveyId : null
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/TokensController.php
Expand Up @@ -42,15 +42,15 @@ public function actionResponses($id, $surveyId) {
'wrapper' => 'col-md-10 col-md-offset-2'
]);
} else {
echo "No responses for this token.";
echo "No responses for this token";
}
}
public function actionCreate($surveyId)
{
$survey = \Survey::model()->findByPk($surveyId);
$this->menus['survey'] = $survey;
if (!$survey->bool_usetokens) {
throw new \CHttpException(412, "The survey you selected does not have tokens enabled.");
throw new \CHttpException(412, "The survey you selected does not have tokens enabled");
}

$token = \Token::create($survey->sid);
Expand All @@ -60,7 +60,7 @@ public function actionCreate($surveyId)
// Validate & safe.
if ($token->save()) {
// On success.
App()->user->setFlash('success', 'Token created.');
App()->user->setFlash('success', 'Token created');
$this->redirect(['tokens/index', 'surveyId' => $survey->sid]);
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public function actionUpdate($surveyId, $id)
// Validate & safe.
if ($token->save()) {
// On success.
App()->user->setFlash('success', 'Token created.');
App()->user->setFlash('success', 'Token updated');
$this->redirect(['tokens/index', 'surveyId' => $survey->sid]);
}
}
Expand Down

0 comments on commit b5d4f42

Please sign in to comment.