[svn r22096] FS#2867 - The "Surveys" tool: Eliminating the global variable $fck_attribute.

skala
Ivan Tcholakov 16 years ago
parent 8c97c2e803
commit b6c324f368
  1. 3
      main/inc/introductionSection.inc.php
  2. 2
      main/inc/lib/fckeditor/toolbars/survey.php
  3. 3
      main/inc/lib/formvalidator/Element/html_editor.php
  4. 19
      main/inc/lib/main_api.lib.php
  5. 16
      main/survey/create_new_survey.php
  6. 3
      main/survey/fillsurvey.php
  7. 21
      main/survey/survey.lib.php
  8. 5
      main/survey/survey_invite.php

@ -49,10 +49,13 @@ $renderer =& $form->defaultRenderer();
$renderer->setElementTemplate('<div style="width: 80%; margin: 0px auto; padding-bottom: 10px; ">{element}</div>');
$toolbar_set = 'Introduction';
// The global variable $fck_attribute has been deprecated. It stays here for supporting old external code.
global $fck_attribute;
if (is_array($fck_attribute) && isset($fck_attribute['Config']['ToolbarSet'])) {
$toolbar_set = $fck_attribute['Config']['ToolbarSet'];
}
if (is_array($editor_config)) {
if (!isset($editor_config['ToolbarSet'])) {
$editor_config['ToolbarSet'] = $toolbar_set;

@ -44,4 +44,4 @@ $config['ToolbarSets']['Maximized'] = array(
// Here new width and height of the editor may be set.
// Possible values, examples: 300 , '250' , '100%' , ...
//$config['Width'] = '100%';
//$config['Height'] = '300';
//$config['Height'] = '120';

@ -1,5 +1,5 @@
<?php
// $Id: html_editor.php 22048 2009-07-14 03:34:42Z ivantcholakov $
// $Id: html_editor.php 22096 2009-07-15 03:43:25Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
@ -42,6 +42,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
*/
function HTML_QuickForm_html_editor($elementName = null, $elementLabel = null, $attributes = null, $config = null)
{
// The global variable $fck_attribute has been deprecated. It stays here for supporting old external code.
global $fck_attribute;
HTML_QuickForm_element :: HTML_QuickForm_element($elementName, $elementLabel, $attributes);

@ -2240,38 +2240,47 @@ function api_get_themes() {
functions for the WYSIWYG html editor, TeX parsing...
==============================================================================
*/
/**
* Displays the FckEditor WYSIWYG editor for online editing of html
* @param string $name The name of the form-element
* @param string $content The default content of the html-editor
* @param int $height The height of the form element
* @param int $width The width of the form element
* @param string $optAttrib optional attributes for the form element
* @param string $attributes (optional) attributes for the form element
* @param array $editor_config (optional) Configuration options for the html-editor
*/
function api_disp_html_area($name, $content = '', $height = '', $width = '100%', $optAttrib = '') {
function api_disp_html_area($name, $content = '', $height = '', $width = '100%', $attributes = null, $editor_config = null) {
global $_configuration, $_course, $fck_attribute;
require_once(dirname(__FILE__).'/formvalidator/Element/html_editor.php');
$editor = new HTML_QuickForm_html_editor($name);
$editor = new HTML_QuickForm_html_editor($name, null, $attributes, $editor_config);
$editor->setValue($content);
// The global variable $fck_attribute has been deprecated. It stays here for supporting old external code.
if( $height != '') {
$fck_attribute['Height'] = $height;
}
if( $width != '') {
$fck_attribute['Width'] = $width;
}
echo $editor->toHtml();
}
function api_return_html_area($name, $content = '', $height = '', $width = '100%', $optAttrib = '') {
function api_return_html_area($name, $content = '', $height = '', $width = '100%', $attributes = null, $editor_config = null) {
global $_configuration, $_course, $fck_attribute;
require_once(dirname(__FILE__).'/formvalidator/Element/html_editor.php');
$editor = new HTML_QuickForm_html_editor($name);
$editor = new HTML_QuickForm_html_editor($name, null, $attributes, $editor_config);
$editor->setValue($content);
// The global variable $fck_attribute has been deprecated. It stays here for supporting old external code.
if( $height != '') {
$fck_attribute['Height'] = $height;
}
if( $width != '') {
$fck_attribute['Width'] = $width;
}
return $editor->toHtml();
}

@ -25,7 +25,7 @@
* @author unknown, the initial survey that did not make it in 1.8 because of bad code
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code
* @author Julio Montoya Armas <gugli100@gmail.com>, Dokeos: Personality Test modification and rewriting large parts of the code
* @version $Id: create_new_survey.php 21034 2009-05-28 11:45:43Z pcool $
* @version $Id: create_new_survey.php 22096 2009-07-15 03:43:25Z ivantcholakov $
*
* @todo only the available platform languages should be used => need an api get_languages and and api_get_available_languages (or a parameter)
*/
@ -154,13 +154,8 @@ if ($_GET['action'] == 'edit') {
$form->applyFilter('survey_code', 'api_strtoupper');
}
$fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '200';
$fck_attribute['ToolbarSet'] = 'Survey';
$form->addElement('html_editor', 'survey_title', get_lang('SurveyTitle'));
$fck_attribute['Config']['ToolbarStartExpanded']='false';
$fck_attribute['Height'] = '100';
$form->addElement('html_editor', 'survey_subtitle', get_lang('SurveySubTitle'));
$form->addElement('html_editor', 'survey_title', get_lang('SurveyTitle'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '200'));
$form->addElement('html_editor', 'survey_subtitle', get_lang('SurveySubTitle'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '100', 'ToolbarStartExpanded' => false));
/*
$lang_array = api_get_languages();
foreach ($lang_array['name'] as $key=>$value) {
@ -176,11 +171,10 @@ $form->addElement('datepickerdate', 'end_date', get_lang('EndDate'), array('form
/** TODO maybe it is better to change this into false instead see line 95 in survey.lib.php */
//$group[] =& HTML_QuickForm::createElement('radio', 'survey_share',null, get_lang('No'),0);
$fck_attribute['Height'] = '130';
//$form->addGroup($group, 'survey_share', get_lang('ShareSurvey'), '&nbsp;');
$form->addElement('checkbox', 'anonymous', get_lang('Anonymous'));
$form->addElement('html_editor', 'survey_introduction', get_lang('SurveyIntroduction'));
$form->addElement('html_editor', 'survey_thanks', get_lang('SurveyThanks'));
$form->addElement('html_editor', 'survey_introduction', get_lang('SurveyIntroduction'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false));
$form->addElement('html_editor', 'survey_thanks', get_lang('SurveyThanks'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false));
/*

@ -432,8 +432,7 @@ if ($survey_data['form_fields']!='' && $survey_data['anonymous'] == 0 && is_arra
$form->freeze('extra_' . $field_details[1]);
break;
case USER_FIELD_TYPE_TEXTAREA :
$form->add_html_editor('extra_' . $field_details[1], $field_details[3], false);
//$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
$form->add_html_editor('extra_' . $field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profil', 'Width' => '100%', 'Height' => '130'));
$form->applyFilter('extra_' . $field_details[1], 'stripslashes');
$form->applyFilter('extra_' . $field_details[1], 'trim');

@ -24,7 +24,7 @@
* @package dokeos.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code
@author Julio Montoya Armas <gugli100@gmail.com>, Dokeos: Personality Test modification and rewriting large parts of the code
* @version $Id: survey.lib.php 21701 2009-07-01 19:12:25Z aportugal $
* @version $Id: survey.lib.php 22096 2009-07-15 03:43:25Z ivantcholakov $
*
* @todo move this file to inc/lib
* @todo use consistent naming for the functions (save vs store for instance)
@ -1331,7 +1331,6 @@ class question
function create_form($form_content)
{
global $charset;
global $fck_attribute;
global $survey_data;
//$tool_name = '<img src="../img/'.survey_manager::icon_question($_GET['type']).'" alt="'.get_lang(ucfirst($_GET['type'])).'" title="'.get_lang(ucfirst($_GET['type'])).'" />';
@ -1359,16 +1358,12 @@ class question
$this->html .= ' <input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_GET['type']).'"/>';
// question field
$fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '120';
$fck_attribute['ToolbarSet'] = 'Survey';
$this->html .= ' <div class="row">';
$this->html .= ' <div class="label">';
$this->html .= ' <span class="form_required">*</span> '.get_lang('Question');
$this->html .= ' </div>';
$this->html .= ' <div class="formw">';
$this->html .= api_return_html_area('question', Security::remove_XSS(stripslashes($form_content['question'])));
$this->html .= api_return_html_area('question', Security::remove_XSS(stripslashes($form_content['question'])), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120'));
$this->html .= ' </div>';
$this->html .= ' </div>';
@ -1647,13 +1642,13 @@ class yesno extends question
$this->html .= ' <td align="right"><label for="answers[0]">1</label></td>';
//$this->html .= ' <td><input type="text" name="answers[0]" id="answers[0]" value="'.$form_content['answers'][0].'" /></td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers[0]', stripslashes($form_content['answers'][0])).'</td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers[0]', stripslashes($form_content['answers'][0]), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
$this->html .= ' <td><input type="image" src="../img/down.gif" value="move_down[0]" name="move_down[0]"/></td>';
$this->html .= ' </tr>';
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers[1]">2</label></td>';
//$this->html .= ' <td><input type="text" name="answers[1]" id="answers[1]" value="'.$form_content['answers'][1].'" /></td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers[1]', stripslashes($form_content['answers'][1])).'</td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers[1]', stripslashes($form_content['answers'][1]), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
$this->html .= ' <td><input type="image" src="../img/up.gif" value="move_up[1]" name="move_up[1]" /></td>';
$this->html .= ' </tr>';
$this->html .= ' </table>';
@ -1747,7 +1742,7 @@ class multiplechoice extends question
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
//$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key]), ENT_QUOTES, $charset)).'</td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key]), ENT_QUOTES, $charset), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
$this->html .= ' <td>';
if ($key<$total_number_of_answers-1) {
$this->html .= ' <input type="image" src="../img/down.gif" value="move_down['.$key.']" name="move_down['.$key.']"/>';
@ -1848,7 +1843,7 @@ class personality extends question
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
//$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key]))).'</td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key])), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
$this->html .= ' <td>';
if ($total_number_of_answers> 2)
@ -1940,7 +1935,7 @@ class multipleresponse extends question
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
//$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key]), ENT_QUOTES, $charset)).'</td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key]), ENT_QUOTES, $charset), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
$this->html .= ' <td>';
if ($key<$total_number_of_answers-1) {
$this->html .= ' <input type="image" src="../img/down.gif" value="move_down['.$key.']" name="move_down['.$key.']"/>';
@ -2246,7 +2241,7 @@ class score extends question
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
//$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', stripslashes($form_content['answers'][$key])).'</td>';
$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', stripslashes($form_content['answers'][$key]), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
$this->html .= ' <td>';
if ($key<$total_number_of_answers-1)
{

@ -141,10 +141,7 @@ $form->addElement('static', null, null, get_lang('AdditonalUsersComment'));
// the title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'),array('size' => '80'));
// the text of the mail
$fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '150';
$fck_attribute['ToolbarSet'] = 'Survey';
$form->addElement('html_editor', 'mail_text', get_lang('MailText'));
$form->addElement('html_editor', 'mail_text', get_lang('MailText'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150'));
// some explanation of the mail
$form->addElement('static', null, null, get_lang('UseLinkSyntax'));
$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));

Loading…
Cancel
Save