Skip to content

Commit

Permalink
Revert "Dev: Merged branch fancytree_new into master"
Browse files Browse the repository at this point in the history
This reverts commit 0ab3fe9.
  • Loading branch information
lacrioque committed Dec 2, 2016
1 parent 115d8f2 commit 3e7c8c9
Show file tree
Hide file tree
Showing 509 changed files with 4,672 additions and 111,629 deletions.
6 changes: 3 additions & 3 deletions application/config/config-defaults.php
Expand Up @@ -336,9 +336,9 @@

$config['pdfdefaultfont'] = 'auto'; //Default font for the pdf Export
/**
* $alternatepdffontfile - array of the font file name used to created pdf in statistics in specific language - this font are included in tcpdf core
* $alternatepdffontfile - array of the font file name used to created pdf in statistics in specific langage - this font are included in tcpdf core
* Only used if $pdfdefaultfont is set to auto or set to a PDF core fonts
* Some language are not tested : need translation for Yes,No and Gender : ckb, swh
* Some langage are not tested : need translation for Yes,No and Gender : ckb, swh
*/
$config['alternatepdffontfile']=array(
'ar'=>'dejavusans',// 'dejavusans' work but maybe more characters in aealarabiya or almohanad: but then need a dynamic font size too
Expand Down Expand Up @@ -407,7 +407,7 @@
*/
$config['chartfontfile']='auto';
/**
* $alternatechartfontfile - array of the font file name used to created the charts in statistics in specific language - this font must reside in <limesurvey root folder>/fonts
* $alternatechartfontfile - array of the font file name used to created the charts in statistics in specific langage - this font must reside in <limesurvey root folder>/fonts
* Only used if $chartfontfile is set to auto. If font file doesn't exist in <limesurvey root folder>/fonts, an alert is sent to admin
*/
$config['alternatechartfontfile']=array(
Expand Down
11 changes: 1 addition & 10 deletions application/config/third_party.php
Expand Up @@ -268,6 +268,7 @@
'Uri.js'
),
),

'bootstrap-datetimepicker' => array(
'basePath' => 'third_party.bootstrap-datetimepicker',
'css' => array(
Expand Down Expand Up @@ -297,16 +298,6 @@
'moment'
)
),

'fancytree' => array(
'basePath' => 'third_party.fancytree',
'js' => array(
'dist/jquery.fancytree-all.js'
),
'css' => array(
'dist/skin-bootstrap-ls/ui.fancytree.css'
),
),

'jquery-datatable' => array(
'basePath' => 'third_party.jquery-datatable',
Expand Down
162 changes: 0 additions & 162 deletions application/controllers/admin/questiongroups.php
Expand Up @@ -506,168 +506,6 @@ public function update($gid)
}
}


/**
* Generate the json array for question explorer tree.
* Fancy Tree is waiting for a unindexed array (no count)
* So we must build an array without index ($jDatas) and export it as Json
* For readability, we first build an indexed array ($aDatas)
*
* @see: http://php.net/manual/en/function.json-encode.php#example-4325 (Non-associative array output as array)
* @see: https://github.com/mar10/fancytree/wiki/TutorialLoadData#pass-a-javascript-array
*
* @param int $surveyid
* @param string $language
* @return string (json array)
*/
public function getGroupExplorerDatas($surveyid, $language)
{
$iSurveyID = (int) $surveyid;
$aGroups = QuestionGroup::model()->getGroupExplorerDatas($iSurveyID, $language); // Get an array of Groups and questions
$aDatas = array(); // The indexed array

// Two task :
// Clean the datas (ellipsize etc)
foreach($aGroups as $aGroup)
{
$aGroupArray = array();

$aGroupArray["key"] = $aGroup->gid; // The key is used by fancy tree to build the node id.
$aGroupArray["gid"] = $aGroup->gid;
$aGroupArray["title"] = $aGroup->sanitized_group_name; //shortening the name is a css thing now
$aGroupArray["folder"] = true; // Means it's a node with children
$aGroupArray["href"] = Yii::app()->createUrl('admin/questiongroups/sa/view/', array('surveyid' => $iSurveyID, 'gid' => $aGroup->gid)); // Means it's a node with children
$aGroupArray['extraClasses'] = 'lsi-tree-group-item';
$aGroupArray['buttonlinks'] = array(
"add" => array(
'title' => gT('Add a question to this group'),
'url' => Yii::app()->createUrl('admin/questions/sa/newquestion/', array('surveyid' => $iSurveyID, 'gid' => $aGroup->gid)),
'icon' => 'fa fa-plus-circle',
'toggle' => 'tooltip',
'cssclasses' => 'btn btn-xs btn-success',

),
"delete" => array(
'title' => gT('Delete this Group'),
'url' => Yii::app()->createUrl('admin/questiongroups/sa/delete/', array('surveyid' => $iSurveyID, 'gid' => $aGroup->gid)),
'icon' => 'fa fa-trash-o',
'toggle' => 'modal',
'target' => '#confirmation-modal',
'cssclasses' => 'btn btn-xs btn-danger deleteNode'
),
"edit" => array(
'title' => gT('Edit this group'),
'url' => Yii::app()->createUrl('admin/questiongroups/sa/edit/', array('surveyid' => $iSurveyID, 'gid' => $aGroup->gid)),
'icon' => 'fa fa-edit',
'toggle' => 'tooltip',
'cssclasses' => 'btn btn-xs btn-default',
),
);

foreach ($aGroup['aQuestions'] as $oQuestion)
{
$aDatasQuestions = array(); // The indexed array that will contain questions
$aDatasQuestions["key"] = $oQuestion->qid;
$aDatasQuestions["gid"] = $aGroup->gid;
$aDatasQuestions["title"] = "[".$oQuestion->sanitized_title . ']&nbsp;' . $oQuestion->sanitized_question;
$aDatasQuestions['href'] = Yii::app()->createUrl('admin/questions/sa/view/', array('surveyid' => $surveyid, 'gid' => $aGroup->gid, 'qid' => $oQuestion->qid));
$aDatasQuestions['toggle'] = 'tooltip';
$aDatasQuestions['placement'] = 'bottom';
$aDatasQuestions['extraClasses'] = 'lsi-tree-question-item';
$aDatasQuestions['buttonlinks'] = array(
"delete" => array(
'title' => gT('Delete this Question'),
'url' => Yii::app()->createUrl('admin/questions/sa/delete/', array('surveyid' => $iSurveyID, 'qid' => $oQuestion->qid)),
'icon' => 'fa fa-trash-o',
'toggle' => 'modal',
'target' => '#confirmation-modal',
'cssclasses' => 'btn btn-xs btn-danger deleteNode',
),
"edit" => array(
'title' => gT('Edit this group'),
'url' => Yii::app()->createUrl('admin/questions/sa/editquestion/', array('surveyid' => $iSurveyID, 'qid' => $oQuestion->qid)),
'icon' => 'fa fa-edit',
'toggle' => 'tooltip',
'cssclasses' => 'btn btn-xs btn-default',
),
);

$aGroupArray["children"][] = $aDatasQuestions; // Doing that, we push the questions in the children array, as an unindexed array (no count)
}
// Doing that, we push the Group as an unindexed array to jDatas, !IMPORTANT! don't index the jDatas array
$jDatas[] = $aGroupArray;
}

echo json_encode($jDatas);
}

function getQuestionDetailData($surveyid, $language, $gid=null, $qid=null){
$iSurveyID = (int) $surveyid;
if($qid === null){
$jDetailsArray = $this->collectQuestionGroupDetail($surveyid, $language, $gid);
} else {
$jDetailsArray = $this->collectQuestionDetail($surveyid, $language, $qid);
}

echo json_encode($jDetailsArray);
Yii::app()->end();
}
private function collectQuestionGroupDetail($surveyid, $language, $gid){

$oQuestionGroup = QuestionGroup::model()->findByPk(array('gid' => $gid, 'language' => $language));
$jDetailsArray = array(print_r($oQuestionGroup,true));
$jDetailContent = "<div class='container-center'>
<dl>
<dt>".gT('Description')."</dt>
<dd class='text-right'>&nbsp;".$oQuestionGroup->getGroupDescription($gid,$language)."</dd>
<dt>".gT('Questions')."</dt>
<dd class='text-right'>&nbsp;".$oQuestionGroup->questionsInGroup."</dd>
<dt>".gT('Randomization Group')."</dt>
<dd class='text-right'>&nbsp;".$oQuestionGroup->randomization_group."</dd>
<dt>".gT('Relevance')."</dt>
<dd class='text-right'>&nbsp;".LimeExpressionManager::UnitTestConvertConditionsToRelevance($surveyid,$oQuestionGroup->gid)."</dd>
</dl>";

$jDetailsArray = array(
'success' => true,
'title' => "<p style='white-space: pre-wrap; word-wrap:break-word;'>".$oQuestionGroup->sanitized_group_name."</p>",
'content' => $jDetailContent
);
return $jDetailsArray;
}
private function collectQuestionDetail($surveyid, $language, $qid){

$oQuestion = Question::model()->findByPk(array('qid' => $qid, 'language' => $language));
LimeExpressionManager::ProcessString("{" . $oQuestion->relevance . "}", $qid);
$jDetailContent = "<div class='container-center'>
<dl>
<dt>".gT('Code')."</dt>
<dd class='text-right'>&nbsp;".$oQuestion->sanitized_title."</dd>
<dt>".gT('Question type')."</dt>
<dd class='text-right'>&nbsp;".$oQuestion->typedesc."</dd>
<dt>".gT('Mandatory')."</dt>
<dd class='text-right'>&nbsp;".$oQuestion->mandatoryIcon."</dd>
<dt>".gT('Other')."</dt>
<dd class='text-right'>&nbsp;".$oQuestion->otherIcon."</dd>
<dt>".gT('Relevance equation')."</dt>
<dd class='text-right'>&nbsp;".LimeExpressionManager::GetLastPrettyPrintExpression()."</dd>
</dl>";

$jDetailsArray = array(
'success' => true,
'title' => "<p style='white-space: pre-wrap; word-wrap:break-word;'>".$oQuestion->sanitized_question."</p>",
'content' => $jDetailContent
);
return $jDetailsArray;
}
/**
* Renders template(s) wrapped in header and footer
*
Expand Down
1 change: 0 additions & 1 deletion application/controllers/admin/questions.php
Expand Up @@ -2099,5 +2099,4 @@ protected function abortIfSurveyIsActive(array $surveyInfo)
$this->getController()->redirect(Yii::app()->request->urlReferrer);
}
}

}
2 changes: 1 addition & 1 deletion application/controllers/survey/index.php
Expand Up @@ -121,7 +121,7 @@ function action()
$sOldLang=isset($_SESSION['survey_'.$surveyid]['s_lang'])?$_SESSION['survey_'.$surveyid]['s_lang']:"";// Keep the old value, because SetSurveyLanguage update $_SESSION
if (!empty($param['lang']))
{
$sDisplayLanguage = $param['lang'];// $param take lang from returnGlobal and returnGlobal sanitize languagecode
$sDisplayLanguage = $param['lang'];// $param take lang from returnGlobal and returnGlobal sanitize langagecode
}
elseif (isset($_SESSION['survey_'.$surveyid]['s_lang']))
{
Expand Down
5 changes: 1 addition & 4 deletions application/core/Survey_Common_Action.php
Expand Up @@ -872,7 +872,6 @@ function _surveybar($aData)
{
$sAlternativeUrl = $aData['surveybar']['closebutton']['url'];
$aData['surveybar']['closebutton']['url'] = Yii::app()->request->getUrlReferrer( Yii::app()->createUrl($sAlternativeUrl));

}

if($aData['gid']==null)
Expand Down Expand Up @@ -927,7 +926,6 @@ function _surveysidemenu($aData)
}

// Question explorer
/*
$aGroups = QuestionGroup::model()->findAllByAttributes(array('sid' => $iSurveyID, "language" => $sumresult1->defaultlanguage->surveyls_language),array('order'=>'group_order ASC'));
if(count($aGroups))
{
Expand All @@ -944,9 +942,8 @@ function _surveysidemenu($aData)
}
}
}
*/
$aData['quickmenu'] = $this->renderQuickmenu($aData);
$aData['aGroups'] = QuestionGroup::model()->getGroupExplorerDatas($iSurveyID, $sumresult1->defaultlanguage->surveyls_language);
$aData['aGroups'] = $aGroups;
$aData['surveycontent'] = Permission::model()->hasSurveyPermission($aData['surveyid'], 'surveycontent', 'read');
$aData['surveycontentupdate'] = Permission::model()->hasSurveyPermission($aData['surveyid'], 'surveycontent', 'update');
$aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour');
Expand Down
1 change: 0 additions & 1 deletion application/models/AdminTheme.php
Expand Up @@ -388,7 +388,6 @@ public static function getOtherAssets()
// Third party assets
'third_party/jquery-tablesorter/tests/assets',
'third_party/jquery-tablesorter/docs/assets',
'third_party/fancytree'
);
}

Expand Down
53 changes: 27 additions & 26 deletions application/models/Question.php
Expand Up @@ -20,10 +20,6 @@ class Question extends LSActiveRecord
// Stock the active group_name for questions list filtering
public $group_name;

private $ellipsized_question=null;
private $sanitized_question=null;
private $sanitized_title = null;

/**
* Returns the static model of Settings table
*
Expand All @@ -32,7 +28,6 @@ class Question extends LSActiveRecord
* @param string $class
* @return CActiveRecord
*/

public static function model($class = __CLASS__)
{
return parent::model($class);
Expand Down Expand Up @@ -807,7 +802,6 @@ public function getOrderedSubQuestions($random=0, $exclude_all_others='')
return $ansresult;
}


public function getMandatoryIcon()
{
if ($this->type != "X" && $this->type != "|")
Expand All @@ -834,32 +828,39 @@ public function getOtherIcon()
}
return $sIcon;
}
public function getEllipsized_question($length = 60)
{
if(!isset($this->ellipsized_question) )
{
$this->ellipsized_question = viewHelper::flatEllipsizeText($this->getSanitized_question(),true,$length,'[...]',0.5);
}
return $this->ellipsized_question;
}

public function getSanitized_question()
/**
* Get an new title/code for a question
* @param integer|string $index base for question code (exemple : inde of question when survey import)
* @return string|null : new title, null if impossible
*/
public function getNewTitle($index=0)
{
if(!isset($this->sanitized_question))
$sOldTitle=$this->title;
if($this->validate(array('title'))){
return $sOldTitle;
}
/* Maybe it's an old invalid title : try to fix it */
$sNewTitle=preg_replace("/[^A-Za-z0-9]/", '', $sOldTitle);
if (is_numeric(substr($sNewTitle,0,1)))
{
$this->sanitized_question = str_replace( '<br />', ' ', sanitize_html_string(strip_tags($this->question)));
$sNewTitle='q' . $sNewTitle;
}
return $this->sanitized_question;

}

public function getSanitized_title()
{
if(!isset($this->sanitized_title))
/* Maybe there are another question with same title try to fix it 10 times */
$attempts = 0;
while (!$this->validate(array('title')))
{
$this->sanitized_title = sanitize_html_string(strip_tags($this->title));
$rand = mt_rand(0, 1024);
$sNewTitle= 'q' . $index.'r' . $rand ;
$this->title = $sNewTitle;
$attempts++;
if ($attempts > 10)
{
$this->addError('title', 'Failed to resolve question code problems after 10 attempts.');
return null;
}
}
return $this->sanitized_title;
return $sNewTitle;
}

public function search()
Expand Down

0 comments on commit 3e7c8c9

Please sign in to comment.