Skip to content

Commit

Permalink
Port vvimport to Yii framework: GCI task 7114260 by Aaron Schmitz.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11589 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Aaron Schmitz committed Dec 5, 2011
1 parent 5ac03ac commit 78a2dda
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 290 deletions.
2 changes: 1 addition & 1 deletion application/controllers/AdminController.php
Expand Up @@ -132,8 +132,8 @@ public function actions()
'user' => 'application.controllers.admin.useraction',
'participants' => 'application.controllers.admin.participantsaction',
'translate' => 'application.controllers.admin.translate',
'saved' => 'application.controllers.admin.saved',
'dataentry' => 'application.controllers.admin.dataentry',
'saved' => 'application.controllers.admin.saved'
);
}

Expand Down
504 changes: 259 additions & 245 deletions application/controllers/admin/dataentry.php

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions application/helpers/admin/html_helper.php
Expand Up @@ -160,14 +160,7 @@ function browsemenubar($title='', $surveyid=null, $load=false, $controller = fal
{

$data['display'] = $browsemenubar;
if (!$controller)
{
$this->getController()->render('/survey_view',$data);
}
else
{
$controller->render('/survey_view', $data);
}
Yii::app()->getController()->render('/survey_view',$data);
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions application/helpers/common_helper.php
Expand Up @@ -4979,7 +4979,6 @@ function createPassword()

function languageDropdown($surveyid,$selected)
{
$CI = &get_instance();
$homeurl = Yii::app()->getConfig('homeurl');
$slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
Expand All @@ -4988,7 +4987,7 @@ function languageDropdown($surveyid,$selected)

foreach ($slangs as $lang)
{
$link = site_url("admin/dataentry/view/".$surveyid."/".$lang);
$link = $homeurl."/admin/dataentry/view/".$surveyid."/".$lang;
if ($lang == $selected) $html .= "\t<option value='{$link}' selected='selected'>".getLanguageNameFromCode($lang,false)."</option>\n";
if ($lang != $selected) $html .= "\t<option value='{$link}'>".getLanguageNameFromCode($lang,false)."</option>\n";
}
Expand Down
8 changes: 4 additions & 4 deletions application/helpers/database_helper.php
Expand Up @@ -3,7 +3,7 @@
function &db_execute_assoc($sql,$inputarr=false,$silent=false)
{
//$connect->SetFetchMode(ADODB_FETCH_ASSOC);
/*try {*/
try {
if($inputarr)
{
$dataset=Yii::app()->db->createCommand($sql)->bindValues($inputarr)->query(); //Checked
Expand All @@ -13,11 +13,11 @@ function &db_execute_assoc($sql,$inputarr=false,$silent=false)
$dataset=Yii::app()->db->createCommand($sql)->query();

}
/*} catch(CDbException $e) {
} catch(CDbException $e) {
$dataset=false;
}*/
}

//if (!$silent && !$dataset) { safe_die('Error executing query in db_execute_assoc:'.$sql); }
if (!$silent && !$dataset) { safe_die('Error executing query in db_execute_assoc:'.$sql); }
return $dataset;
}

Expand Down
6 changes: 3 additions & 3 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -1883,8 +1883,8 @@ static function FinishProcessingPage()
// log_message('debug','**ERRORS**' . print_r($LEM->syntaxErrors,true));
if (count($LEM->syntaxErrors) > 0)
{
$CI =& get_instance();
$CI->db->insert_batch('expression_errors',$LEM->syntaxErrors);
foreach ($LEM->syntaxErrors as $errors)
Yii::app()->db->createCommand()->insert('{{expression_errors}}',$errors);
}
$LEM->initialized=false; // so detect calls after done
}
Expand Down Expand Up @@ -1928,7 +1928,7 @@ static function GetRelevanceAndTailoringJavaScript()

$jsParts=array();
$allJsVarsUsed=array();
$jsParts[] = '<script type="text/javascript" src="' . base_url() . '/scripts/admin/expressions/em_javascript.js"></script>';
$jsParts[] = '<script type="text/javascript" src="' . Yii::app()->baseUrl . '/scripts/admin/expressions/em_javascript.js"></script>';
$jsParts[] = "<script type='text/javascript'>\n<!--\n";
$jsParts[] = "function ExprMgr_process_relevance_and_tailoring(evt_type){\n";
$jsParts[] = "if (typeof LEM_initialized == 'undefined') {\nLEM_initialized=true;\nLEMsetTabIndexes();\nreturn;\n}\n";
Expand Down
1 change: 0 additions & 1 deletion application/libraries/Limesurvey_lang.php
Expand Up @@ -26,7 +26,6 @@

class Limesurvey_lang {

var $CI;
var $gettextclass;
var $langcode;

Expand Down
27 changes: 24 additions & 3 deletions application/models/Survey_dynamic.php
Expand Up @@ -16,7 +16,7 @@

class Survey_dynamic extends CActiveRecord
{
protected $sid = 0;
protected static $sid = 0;

/**
* Returns the static model of Settings table
Expand All @@ -32,6 +32,19 @@ public static function model($sid)
$instance->sid = $sid;
return $instance;
}

/**
* Sets the survey ID for the next model
*
* @static
* @access public
* @param int $sid
* @return void
*/
public static function sid($sid)
{
self::$sid = (int) $sid;
}

/**
* Returns the setting's table name to be used by the model
Expand All @@ -41,7 +54,7 @@ public static function model($sid)
*/
public function tableName()
{
return '{{survey_' . $this->sid . '}}';
return '{{survey_' . self::$sid . '}}';
}

/**
Expand All @@ -54,5 +67,13 @@ public function primaryKey()
{
return 'sid';
}

function insertRecords($data)
{
$record = new self;
foreach ($data as $k => $v)
$record->$k = $v;
return $record->save();
}
}
?>
?>
5 changes: 5 additions & 0 deletions application/models/Tokens_dynamic.php
Expand Up @@ -132,5 +132,10 @@ public function emquery($iSurveyID,$SQLemailstatuscondition,$maxemails,$tokenid=
Yii::app()->loadHelper("database");
return db_select_limit_assoc($emquery,$maxemails);
}

function insertToken($iSurveyID,$data)
{
return Yii::app()->db->createCommand()->insert("{{tokens_".$iSurveyID.'}}', $data)->query();
}
}
?>
4 changes: 2 additions & 2 deletions application/views/admin/dataentry/active_html_view.php
Expand Up @@ -23,7 +23,7 @@ function saveshow(value)
<td colspan='3' align='center'>
<table><tr><td align='left'>
<input type='checkbox' class='checkboxbtn' name='closerecord' id='closerecord' checked='checked'/><label for='closerecord'><?php echo $clang->gT("Finalize response submission"); ?></label></td></tr>
<input type='hidden' name='closedate' value='<?php echo date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->config->item('timeadjust')); ?>' />
<input type='hidden' name='closedate' value='<?php echo date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig('timeadjust')); ?>' />

<?php if ($thissurvey['allowsave'] == "Y")
{ ?>
Expand Down Expand Up @@ -99,7 +99,7 @@ function saveshow(value)
<td>
<input type='hidden' name='subaction' value='insert' />
<input type='hidden' name='sid' value='<?php echo $surveyid; ?>' />
<input type='hidden' name='language' value='<?php echo $sDataEntryLanguage; ?>' />
<input type='hidden' name='lang' value='<?php echo $sDataEntryLanguage; ?>' />
</td>
</tr>
</table>
Expand Down
4 changes: 2 additions & 2 deletions application/views/admin/dataentry/caption_view.php
@@ -1,6 +1,6 @@
<div class='header ui-widget-header'><?php echo $clang->gT("Data entry"); ?></div>

<form action='<?php echo site_url('admin/dataentry/insert'); ?>' enctype='multipart/form-data' name='addsurvey' method='post' id='addsurvey'>
<form action='<?php echo $this->createUrl('admin/dataentry/sa/insert'); ?>' enctype='multipart/form-data' name='addsurvey' method='post' id='addsurvey'>
<table class='data-entry-tbl' cellspacing='0'>
<tr>
<td colspan='3' align='center'>
Expand Down Expand Up @@ -53,7 +53,7 @@ function activateSubmit(me)

if ($thissurvey['datestamp'] == "Y") //Give datestampentry field
{
$localtimedate=date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $this->config->item('timeadjust')); ?>
$localtimedate=date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust')); ?>
<tr>
<td valign='top' width='1%'></td>
<td valign='top' align='right' width='30%'><strong>
Expand Down
38 changes: 19 additions & 19 deletions application/views/admin/dataentry/content_view.php
Expand Up @@ -19,7 +19,7 @@

<?php if ($deqrow['help'])
{ ?>
<img src='<?php echo $this->config->item('imageurl'); ?>/help.gif' alt='<?php echo $blang->gT("Help about this question"); ?>' align='right' onclick="javascript:alert('Question <?php echo $deqrow['title']; ?> Help: <?php echo $hh; ?>')" />
<img src='<?php echo Yii::app()->getConfig('imageurl'); ?>/help.gif' alt='<?php echo $blang->gT("Help about this question"); ?>' align='right' onclick="javascript:alert('Question <?php echo $deqrow['title']; ?> Help: <?php echo $hh; ?>')" />
<?php }
switch($deqrow['type'])
{
Expand Down Expand Up @@ -58,7 +58,7 @@
case "K": ?>

<table>
<?php foreach ($dearesult->result_array() as $dearow)
<?php foreach ($dearesult->readAll() as $dearow)
{ ?>
<tr><td align='right'>
<?php echo $dearow['question']; ?>
Expand All @@ -73,25 +73,25 @@

<table><tr><td></td><th><?php echo sprintf($clang->gT('Label %s'),'1').'</th><th>'.sprintf($clang->gT('Label %s'),'2'); ?></th></tr>

<?php foreach ($dearesult->result_array() as $dearow)
<?php foreach ($dearesult->readAll() as $dearow)
{
// first scale
$delquery = "SELECT * FROM ".$this->db->dbprefix."answers WHERE qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' and scale_id=0 ORDER BY sortorder, code";
$delquery = "SELECT * FROM {{answers}} WHERE qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' and scale_id=0 ORDER BY sortorder, code";
$delresult = db_execute_assoc($delquery); ?>
<tr><td><?php echo $dearow['question']; ?></td><td>
<select name='<?php echo $fieldname.$dearow['title']; ?>#0'>
<option selected='selected' value=''><?php echo $clang->gT("Please choose..."); ?></option>
<?php foreach ($delresult->result_array() as $delrow)
<?php foreach ($delresult->readAll() as $delrow)
{ ?>
<option value='<?php echo $delrow['code']; ?>'><?php echo $delrow['answer']; ?></option>
<?php } ?>
</select></td>
<?php $delquery = "SELECT * FROM ".$this->db->dbprefix."answers WHERE qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' and scale_id=1 ORDER BY sortorder, code";
<?php $delquery = "SELECT * FROM {{answers}} WHERE qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' and scale_id=1 ORDER BY sortorder, code";
$delresult = db_execute_assoc($delquery); ?>
<td>
<select name='<?php echo $fieldname.$dearow['title']; ?>#1'>
<option selected='selected' value=''><?php echo $clang->gT("Please choose..."); ?></option>
<?php foreach ($delresult->result_array() as $delrow)
<?php foreach ($delresult->readAll() as $delrow)
{ ?>
<option value='<?php echo $delrow['code']; ?>'><?php echo $delrow['answer']; ?></option>
<?php } ?>
Expand Down Expand Up @@ -234,7 +234,7 @@ function deletethis_<?php echo $thisqid; ?>($text, $value, $name, $thisname)
$divider=" </td> <td valign='top' width='$width%' nowrap='nowrap'>";
$upto=0; ?>
<table class='question'><tr> <td valign='top' width='<?php echo $width; ?>%' nowrap='nowrap'>
<?php foreach ($mearesult->result_array() as $mearow)
<?php foreach ($mearesult->readAll() as $mearow)
{
if ($upto == $maxrows)
{
Expand Down Expand Up @@ -279,7 +279,7 @@ function deletethis_<?php echo $thisqid; ?>($text, $value, $name, $thisname)
case "P": //Multiple choice with comments checkbox + text ?>
<table border='0'>

<?php foreach ($mearesult->result_array() as $mearow)
<?php foreach ($mearesult->readAll() as $mearow)
{ ?>
<tr>
<td>
Expand Down Expand Up @@ -402,7 +402,7 @@ function updateJSON<?php echo $fieldname; ?>() {
case "A": //ARRAY (5 POINT CHOICE) radio-buttons ?>

<table>
<?php foreach ($mearesult->result_array() as $mearow)
<?php foreach ($mearesult->readAll() as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
Expand All @@ -421,7 +421,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php break;
case "B": //ARRAY (10 POINT CHOICE) radio-buttons ?>
<table>
<?php foreach ($mearesult->result_array() as $mearow)
<?php foreach ($mearesult->readAll() as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
Expand All @@ -441,7 +441,7 @@ function updateJSON<?php echo $fieldname; ?>() {
case "C": //ARRAY (YES/UNCERTAIN/NO) radio-buttons
?>
<table>
<?php foreach ($mearesult->result_array() as $mearow)
<?php foreach ($mearesult->readAll() as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
Expand All @@ -459,7 +459,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<?php break;
case "E": //ARRAY (YES/UNCERTAIN/NO) radio-buttons
?> <table>
<?php foreach ($mearesult->result_array() as $mearow)
<?php foreach ($mearesult->readAll() as $mearow)
{ ?>
<tr>
<td align='right'><?php echo $mearow['question']; ?></td>
Expand All @@ -480,15 +480,15 @@ function updateJSON<?php echo $fieldname; ?>() {
?>
<table>
<tr><td></td>
<?php foreach($lresult->result_array() as $data)
<?php foreach($lresult->readAll() as $data)
{ ?>
<th><?php echo $data['question']; ?></th>
<?php $labelcodes[]=$data['title'];
}
?>
</tr>
<?php $i=0;
foreach ($mearesult->result_array() as $mearow)
foreach ($mearesult->readAll() as $mearow)
{

if (strpos($mearow['question'],'|'))
Expand Down Expand Up @@ -530,7 +530,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<table>
<tr><td></td>
<?php $labelcodes=array();
foreach ($lresult->result_array() as $data)
foreach ($lresult->readAll() as $data)
{ ?>
<th><?php echo $data['question']; ?></th>
<?php $labelcodes[]=$data['title'];
Expand All @@ -539,7 +539,7 @@ function updateJSON<?php echo $fieldname; ?>() {
</tr>

<?php $i=0;
foreach ($mearesult->result_array() as $mearow)
foreach ($mearesult->readAll() as $mearow)
{
if (strpos($mearow['question'],'|'))
{
Expand Down Expand Up @@ -569,7 +569,7 @@ function updateJSON<?php echo $fieldname; ?>() {
case "F": //ARRAY (Flexible Labels)
case "H": ?>
<table>
<?php foreach ( $mearesult->result_array() as $mearow)
<?php foreach ( $mearesult->readAll() as $mearow)
{

if (strpos($mearow['question'],'|'))
Expand All @@ -589,7 +589,7 @@ function updateJSON<?php echo $fieldname; ?>() {
<td>
<select name='<?php echo $fieldname.$mearow['title']; ?>'>
<option value=''><?php echo $blang->gT("Please choose"); ?>..</option>
<?php foreach ($fresult->result_array() as $frow)
<?php foreach ($fresult->readAll() as $frow)
{ ?>
<option value='<?php echo $frow['code']; ?>'><?php echo $frow['answer']; ?></option>
<?php } ?>
Expand Down

0 comments on commit 78a2dda

Please sign in to comment.