Minor - Fixing comments, fixing PHP warnings.

1.9.x
Julio Montoya 12 years ago
parent ea9f20b0c9
commit 20ecb6d390
  1. 14
      main/exercice/tests_category.php
  2. 10
      main/forum/forumfunction.inc.php
  3. 74
      main/glossary/index.php
  4. 4
      main/gradebook/lib/scoredisplay.class.php
  5. 98
      main/inc/lib/gradebook.lib.php
  6. 2
      main/inc/lib/promotion.lib.php
  7. 2
      main/inc/lib/timeline.lib.php
  8. 4
      main/notebook/index.php
  9. 4
      main/survey/create_new_survey.php
  10. 182
      main/wiki/diff.inc.php
  11. 813
      main/wiki/index.php
  12. 139
      main/wiki/wiki.inc.php

@ -63,27 +63,27 @@ function edit_category_form($in_action) {
$category_id = Security::remove_XSS($_GET['category_id']);
$objcat = new Testcategory($category_id);
// initiate the object
// initiate the object
$form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action . '&category_id=' . $category_id);
// settting the form elements
// settting the form elements
$form->addElement('header', get_lang('EditCategory'));
$form->addElement('hidden', 'category_id');
$form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
$form->addElement('style_submit_button', 'SubmitNote', get_lang('ModifyCategory'), 'class="add"');
// setting the defaults
// setting the defaults
$defaults = array();
$defaults["category_id"] = $objcat->id;
$defaults["category_name"] = $objcat->name;
$defaults["category_description"] = $objcat->description;
$form->setDefaults($defaults);
// setting the rules
// setting the rules
$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
@ -138,7 +138,7 @@ function add_category_form($in_action) {
$in_action = Security::remove_XSS($in_action);
// initiate the object
$form = new FormValidator('note', 'post', api_get_self() . '?action=' . $in_action);
// settting the form elements
// Setting the form elements
$form->addElement('header', get_lang('AddACategory'));
$form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
@ -227,4 +227,4 @@ function protectJSDialogQuote($in_txt) {
$res = str_replace("'", "\'", $res);
$res = str_replace('"', "\'\'", $res); // super astuce pour afficher les " dans les boite de dialogue
return $res;
}
}

@ -149,7 +149,7 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id)
// hidden field if from learning path
$form->addElement('hidden', 'lp_id', $lp_id);
// Settting the form elements.
// Setting the form elements.
$form->addElement('header', '', get_lang('AddForumCategory'));
$form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles" id="category_title"');
@ -404,7 +404,7 @@ function show_edit_forumcategory_form($inputvalues = array())
$gradebook = Security::remove_XSS($_GET['gradebook']);
$form = new FormValidator('forumcategory', 'post', 'index.php?&gradebook='.$gradebook.'');
// Settting the form elements.
// Setting the form elements.
$form->addElement('header', '', get_lang('EditForumCategory'));
$form->addElement('hidden', 'forum_category_id');
$form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles"');
@ -2154,7 +2154,7 @@ function show_add_post_form($action = '', $id = '', $form_values = '')
$form->addElement('header', $text);
// Settting the form elements.
// Setting the form elements.
$form->addElement('hidden', 'forum_id', intval($my_forum));
$form->addElement('hidden', 'thread_id', intval($my_thread));
$form->addElement('hidden', 'gradebook', $my_gradebook);
@ -2602,7 +2602,7 @@ function show_edit_post_form($current_post, $current_thread, $current_forum, $fo
// Initialize the object.
$form = new FormValidator('edit_post', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&gradebook='.$gradebook.'&origin='.$origin.'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post']));
$form->addElement('header', get_lang('EditPost'));
// Settting the form elements.
// Setting the form elements.
$form->addElement('hidden', 'post_id', $current_post['post_id']);
$form->addElement('hidden', 'thread_id', $current_thread['thread_id']);
$form->addElement('hidden', 'id_attach', $id_attach);
@ -3554,7 +3554,7 @@ function forum_search()
// Initialize the object.
$form = new FormValidator('forumsearch', 'post', 'forumsearch.php?origin='.$origin.'');
// Settting the form elements.
// Setting the form elements.
$form->addElement('header', '', get_lang('ForumSearch'));
$form->addElement('text', 'search_term', get_lang('SearchTerm'), 'class="input_titles" id="search_title"');
$form->applyFilter('search_term', 'html_filter');

@ -50,39 +50,39 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
$tool = 'GlossaryManagement';
$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('Glossary'));
$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('Glossary'));
if (!empty($action)) {
}
switch ($action) {
case 'addglossary':
case 'addglossary':
$tool_name = get_lang('Add');
break;
case 'edit_glossary':
$tool_name = get_lang('Edit');
break;
case 'edit_glossary':
$tool_name = get_lang('Edit');
break;
case 'import':
$tool_name = get_lang('ImportGlossary');
$tool_name = get_lang('ImportGlossary');
break;
case 'changeview':
$tool_name = get_lang('List');
break;
$tool_name = get_lang('List');
break;
}
if (isset($_GET['action']) && $_GET['action'] == 'export') {
if (isset($_GET['action']) && $_GET['action'] == 'export') {
$data = GlossaryManager::get_glossary_data(0, GlossaryManager::get_number_glossary_terms (api_get_session_id()), 0, 'ASC');
usort($data, "sorter");
$list = array();
$list[] = array('term','definition');
foreach($data as $line) {
$list[] = array ($line[0], $line[1]);
}
}
$filename = 'glossary_course_'.api_get_course_id();
Export::export_table_csv_utf8($list, $filename);
}
if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') {
if (isset($_GET['action']) && $_GET['action'] == 'export_to_pdf') {
GlossaryManager::export_to_pdf();
}
@ -100,11 +100,11 @@ if (isset($_GET['action']) && $_GET['action'] == 'changeview' AND in_array($_GET
}
if (api_is_allowed_to_edit(null, true)) {
switch ($action) {
case 'addglossary':
case 'addglossary':
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// settting the form elements
// Setting the form elements
$form->addElement('header', '', get_lang('TermAddNew'));
$form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'80', 'id'=>'glossary_title'));
//$form->applyFilter('glossary_title', 'html_filter');
@ -125,23 +125,23 @@ if (api_is_allowed_to_edit(null, true)) {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
$form->display();
}
break;
case 'edit_glossary':
if (is_numeric($_GET['glossary_id'])) {
// initiate the object
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&glossary_id='.Security::remove_XSS($_GET['glossary_id']));
// settting the form elements
// Setting the form elements
$form->addElement('header', '', get_lang('TermEdit'));
$form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'80'));
//$form->applyFilter('glossary_title', 'html_filter');
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));
$element = $form->addElement('text', 'insert_date', get_lang('CreationDate'),array('size'=>'100'));
$element ->freeze();
$element ->freeze();
$element = $form->addElement('text', 'update_date', get_lang('UpdateDate'),array('size'=>'100'));
$element ->freeze();
$element ->freeze();
$form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"');
// setting the defaults
@ -179,7 +179,7 @@ if (api_is_allowed_to_edit(null, true)) {
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}
}
break;
case 'delete_glossary':
@ -196,18 +196,18 @@ if (api_is_allowed_to_edit(null, true)) {
break;
case 'import':
$form = new FormValidator('glossary','post', api_get_self().'?action=import');
$form->addElement('header', '', get_lang('ImportGlossary'));
$form->addElement('header', '', get_lang('ImportGlossary'));
$form->addElement('file', 'file', get_lang('ImportCSVFileLocation'));
$form->addElement('checkbox', 'replace', null, get_lang('DeleteAllGlossaryTerms'));
$form->addElement('style_submit_button', 'SubmitImport', get_lang('Import'), 'class="save"');
$form->display();
$form->display();
echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')';
echo '<pre>
<strong>term</strong>;<strong>definition</strong>;
"Hello";"Hola";
"Good";"Bueno";</pre>';
if ($form->validate()) {
//this is a bad idea //jm
if (isset($_POST['replace']) && $_POST['replace']) {
@ -216,33 +216,33 @@ if (api_is_allowed_to_edit(null, true)) {
Display::display_error_message (get_lang ("CannotDeleteGlossary") . ':' . $term['id']);
}
}
}
//$data = Import::csv_to_array($_FILES['file']['tmp_name']);
}
//$data = Import::csv_to_array($_FILES['file']['tmp_name']);
$data = Import::csv_reader($_FILES['file']['tmp_name']);
$good = 0;
$bad = 0;
foreach ($data as $item) {
if (GlossaryManager::save_glossary(array('glossary_title' => $item['term'], 'glossary_comment' => $item['definition']), false))
$bad = 0;
foreach ($data as $item) {
if (GlossaryManager::save_glossary(array('glossary_title' => $item['term'], 'glossary_comment' => $item['definition']), false))
$good++;
else
$bad++;
}
Display::display_confirmation_message (get_lang ("TermsImported") . ':' . $good);
if ($bad)
Display::display_error_message (get_lang ("TermsNotImported") . ':' . $bad);
GlossaryManager::display_glossary();
}
break;
default:
GlossaryManager::display_glossary();
break;
break;
}
} else {
GlossaryManager::display_glossary();
}
// Footer
Display::display_footer();
Display::display_footer();

@ -91,12 +91,12 @@ class ScoreDisplay
$this->category_id = $category_id;
}
//Loading portal settings + using standard functions
// Loading portal settings + using standard functions.
$value = api_get_setting('gradebook_score_display_coloring');
$value = $value['my_display_coloring'];
//Settting coloring
// Setting coloring.
$this->coloring_enabled = $value == 'true' ? true : false;
if ($this->coloring_enabled) {

@ -8,47 +8,47 @@
/**
* Code
*/
class Gradebook extends Model {
class Gradebook extends Model {
public $columns = array('id', 'name', 'description', 'course_code', 'parent_id', 'grade_model_id', 'session_id', 'weight', 'user_id');
public function __construct() {
$this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$this->table_skill = Database::get_main_table(TABLE_MAIN_SKILL);
$this->table_skill_rel_gradebook = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
$this->table_skill_rel_gradebook = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
}
/**
* Returns true if the gradebook is active and visible in a course, false
* otherwise.
*
*
* @param int $c_id Course integer id, defaults to the current course
* @return boolean
* @return boolean
*/
public static function is_active($c_id = null) {
$name = 'gradebook';
$name = 'gradebook';
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * from $table WHERE variable='course_hide_tools' AND subkey='$name'";
$setting = ResultSet::create($sql)->first();
$setting = $setting ? $setting : array();
$setting = $setting ? $setting : array();
$inactive = isset($setting['selected_value']) && $setting['selected_value'] == 'true';
if ($inactive) {
return false;
}
$c_id = $c_id ? intval($c_id) : api_get_course_int_id();
$c_id = $c_id ? intval($c_id) : api_get_course_int_id();
$table = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT * from $table WHERE c_id = $c_id and name='$name'";
$item = ResultSet::create($sql)->first();
$item = ResultSet::create($sql)->first();
if (empty($item)) {
return true;
}
}
return $item['visibility'] == '1';
}
public function get_all($options = array()) {
$gradebooks = parent::get_all($options);
foreach($gradebooks as &$gradebook) {
@ -57,78 +57,78 @@ class Gradebook extends Model {
}
//$gradebook['name'] = $gradebook['course_code'] .' > '.$gradebook['name'];
}
return $gradebooks;
return $gradebooks;
}
public function update($params) {
return parent::update($params);
}
public function update_skills_to_gradebook($gradebook_id, $skill_list) {
if (!empty($skill_list)) {
//Cleaning skills
$skill_list = array_map('intval', $skill_list);
$skill_list = array_filter($skill_list);
$skill_list = array_filter($skill_list);
$skill_gradebook = new SkillRelGradebook();
$skill_gradebooks_source = $skill_gradebook->get_all(array('where'=>array('gradebook_id = ?' =>$gradebook_id)));
$clean_gradebook = array();
if (!empty($skill_gradebooks_source)) {
foreach($skill_gradebooks_source as $source) {
$clean_gradebook[]= $source['skill_id'];
$clean_gradebook[]= $source['skill_id'];
}
}
}
if (!empty($clean_gradebook)) {
$skill_to_remove = array_diff($clean_gradebook, $skill_list);
}
}
foreach ($skill_list as $skill_id) {
$params = array();
$params = array();
$params['gradebook_id'] = $gradebook_id;
$params['skill_id'] = $skill_id;
if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) {
$params['skill_id'] = $skill_id;
if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) {
$skill_gradebook->save($params);
}
}
if (!empty($skill_to_remove)) {
foreach($skill_to_remove as $remove) {
foreach($skill_to_remove as $remove) {
$skill_item = $skill_gradebook->get_skill_info($remove, $gradebook_id);
$skill_gradebook->delete($skill_item['id']);
}
}
}
return true;
}
return false;
}
return false;
}
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
* @return obj form validator obj
*/
public function show_skill_form($gradebook_id, $url, $header = null) {
$form = new FormValidator('gradebook_add_skill', 'POST', $url);
// Settting the form elements
// Setting the form elements
if (!isset($header)) {
$header = get_lang('Add');
}
}
$form->addElement('header', '', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$skill = new Skill();
$skills = $skill->get_all();
$clean_skill_list = array();
foreach ($skills as $skill) {
$clean_skill_list[$skill['id']] = $skill['name'];
}
}
$form->addElement('select', 'skill', get_lang('Skills'), $clean_skill_list, array('width'=>'450px', 'class'=>'chzn-select','multiple' => 'multiple'));
$selected_skills = self::get_skills_by_gradebook($gradebook_id);
$clean_selected_skills = array();
if (!empty($selected_skills)) {
@ -136,29 +136,29 @@ class Gradebook extends Model {
$clean_selected_skills[] = $skill['id'];
}
}
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
$form->setDefaults(array('skill'=>$clean_selected_skills));
return $form;
return $form;
}
function get_skills_by_gradebook($gradebook_id) {
$gradebook_id = intval($gradebook_id);
$sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook
ON skill.id = skill_rel_gradebook.skill_id
ON skill.id = skill_rel_gradebook.skill_id
WHERE skill_rel_gradebook.gradebook_id = $gradebook_id";
$result = Database::query($sql);
$result = Database::query($sql);
$result = Database::store_result($result,'ASSOC');
return $result;
}
/**
* Displays the title + grid
*/
public function display() {
// action links
echo Display::grid_html('gradebooks');
echo Display::grid_html('gradebooks');
}
}

@ -171,7 +171,7 @@ class Promotion extends Model
$oFCKeditor->CreateHtml();
$form = new FormValidator('promotion', 'post', $url);
// Settting the form elements
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');

@ -123,7 +123,7 @@ class Timeline extends Model
{
$form = new FormValidator('item_form', 'post', $url);
// Settting the form elements
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');

@ -72,7 +72,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
// Initiate the object
$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// Settting the form elements
// Setting the form elements
$form->addElement('header', '', get_lang('NoteAddNew'));
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '95', 'id' => 'note_title'));
//$form->applyFilter('note_title', 'html_filter');
@ -118,7 +118,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_
// Initialize the object
$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.Security::remove_XSS($_GET['notebook_id']));
// Settting the form elements
// Setting the form elements
$form->addElement('header', '', get_lang('ModifyNote'));
$form->addElement('hidden', 'notebook_id');
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100'));

@ -118,7 +118,7 @@ $form = new FormValidator('survey', 'post', api_get_self().'?action='.Security::
$form->addElement('header', '', $tool_name);
// Settting the form elements
// Setting the form elements
if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) {
$form->addElement('hidden', 'survey_id');
}
@ -320,4 +320,4 @@ if ($form->validate()) {
}
// Footer
Display :: display_footer();
Display :: display_footer();

@ -18,10 +18,10 @@
/**
* Code
*/
define( "DIFF_EQUAL", "=" );
define( "DIFF_ADDED", "+" );
define( "DIFF_DELETED", "-" );
define( "DIFF_MOVED", "M" );
define("DIFF_EQUAL", "=");
define("DIFF_ADDED", "+");
define("DIFF_DELETED", "-");
define("DIFF_MOVED", "M");
/**
* Get difference between two strings
@ -33,32 +33,33 @@ define( "DIFF_MOVED", "M" );
* (default 'format_line')
* @return string formated diff output
*/
function diff( $old, $new, $show_equals = false, $format_line_function = 'format_line' )
{
$oldArr = str_split_on_new_line( $old );
$newArr = str_split_on_new_line( $new );
function diff(
$old,
$new,
$show_equals = false,
$format_line_function = 'format_line'
) {
$oldArr = str_split_on_new_line($old);
$newArr = str_split_on_new_line($new);
$oldCount = count ( $oldArr );
$newCount = count ( $newArr );
$oldCount = count($oldArr);
$newCount = count($newArr);
$max = max( $oldCount, $newCount );
$max = max($oldCount, $newCount);
//get added and deleted lines
$deleted = array_diff_assoc( $oldArr, $newArr );
$added = array_diff_assoc( $newArr, $oldArr );
$deleted = array_diff_assoc($oldArr, $newArr);
$added = array_diff_assoc($newArr, $oldArr);
$moved = array();
foreach ( $added as $key => $candidate )
{
foreach ( $deleted as $index => $content )
{
if ( $candidate == $content )
{
foreach ($added as $key => $candidate) {
foreach ($deleted as $index => $content) {
if ($candidate == $content) {
$moved[$key] = $candidate;
unset( $added[$key] );
unset( $deleted[$index] );
unset($added[$key]);
unset($deleted[$index]);
break;
}
}
@ -66,41 +67,29 @@ function diff( $old, $new, $show_equals = false, $format_line_function = 'format
$output = '';
for ( $i = 0; $i < $max; $i++ )
{
for ($i = 0; $i < $max; $i++) {
// line changed
if ( isset ( $deleted[$i] ) && isset( $added[$i] ) )
{
$output .= $format_line_function( $i, DIFF_DELETED, $deleted[$i] );
$output .= $format_line_function( $i, DIFF_ADDED, $added[$i] );
if (isset ($deleted[$i]) && isset($added[$i])) {
$output .= $format_line_function($i, DIFF_DELETED, $deleted[$i]);
$output .= $format_line_function($i, DIFF_ADDED, $added[$i]);
}
// line deleted
elseif ( isset ( $deleted[$i] ) && ! isset ( $added[$i] ) )
{
$output .= $format_line_function( $i, DIFF_DELETED, $deleted[$i] );
} // line deleted
elseif (isset ($deleted[$i]) && !isset ($added[$i])) {
$output .= $format_line_function($i, DIFF_DELETED, $deleted[$i]);
}
// line added
elseif ( isset ( $added[$i] ) && ! isset ( $deleted[$i] ) )
{
$output .= $format_line_function( $i, DIFF_ADDED, $added[$i] );
} // line added
elseif (isset ($added[$i]) && !isset ($deleted[$i])) {
$output .= $format_line_function($i, DIFF_ADDED, $added[$i]);
}
// line moved
elseif ( isset ( $moved[$i] ) )
{
$output .= $format_line_function( $i, DIFF_MOVED, $newArr[$i] );
} // line moved
elseif (isset ($moved[$i])) {
$output .= $format_line_function($i, DIFF_MOVED, $newArr[$i]);
}
// line unchanged
elseif ( $show_equals )
{
$output .= $format_line_function( $i, DIFF_EQUAL, $newArr[$i] );
} // line unchanged
elseif ($show_equals) {
$output .= $format_line_function($i, DIFF_EQUAL, $newArr[$i]);
}
else
{
} else {
// skip
}
}
@ -111,24 +100,17 @@ function diff( $old, $new, $show_equals = false, $format_line_function = 'format
/**
* Split strings on new line
*/
function str_split_on_new_line( $str )
function str_split_on_new_line($str)
{
$content = array();
if ( api_strpos( $str, "\r\n" ) !== false )
{
$content = explode("\r\n", $str );
}
elseif ( api_strpos( $str, "\n" ) !== false )
{
$content = explode( "\n", $str );
}
elseif ( api_strpos( $str, "\r" ) !== false )
{
$content = explode( "\r", $str );
}
else
{
if (api_strpos($str, "\r\n") !== false) {
$content = explode("\r\n", $str);
} elseif (api_strpos($str, "\n") !== false) {
$content = explode("\n", $str);
} elseif (api_strpos($str, "\r") !== false) {
$content = explode("\r", $str);
} else {
$content[] = $str;
}
@ -144,45 +126,31 @@ function str_split_on_new_line( $str )
* @param boolean skip_empty skip empty lines (default false)
* @return string formated diff line
*/
function format_line( $line, $type, $value, $skip_empty = false )
function format_line($line, $type, $value, $skip_empty = false)
{
if ( trim( $value ) == "" && $skip_empty )
{
if (trim($value) == "" && $skip_empty) {
return "";
}
elseif ( trim( $value ) == "" )
{
} elseif (trim($value) == "") {
$value = '&nbsp;';
}
switch ( $type )
{
switch ($type) {
case DIFF_EQUAL:
{
// return $line. ' : ' . ' = <span class="diffEqual" >' . $value . '</span><br />' . "\n" ;
return '<span class="diffEqual" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color
// return $line. ' : ' . ' = <span class="diffEqual" >' . $value . '</span><br />' . "\n" ;
return '<span class="diffEqual" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break;
}
case DIFF_MOVED:
{
//return $line. ' : ' . ' M <span class="diffMoved" >' . $value . '</span><br />' . "\n" ; //juan carlos ra<EFBFBD>a la sustitye la inverior
return '<span class="diffMoved" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color
return '<span class="diffMoved" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break;
}
case DIFF_ADDED:
{
//return $line . ' : ' . ' + <span class="diffAdded" >' . $value . '</span><br />' . "\n" ;
return '<span class="diffAdded" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color
return '<span class="diffAdded" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break;
}
case DIFF_DELETED:
{
//return $line . ' : ' . ' - <span class="diffDeleted" >' . $value . '</span><br />' . "\n" ; //juan carlos ra<EFBFBD>a la sustitye la inverior
return '<span class="diffDeleted" >' . $value . '</span><br />' . "\n" ; //juan carlos muestra solo color
return '<span class="diffDeleted" >' . $value . '</span><br />' . "\n"; //juan carlos muestra solo color
break;
}
}
}
@ -190,46 +158,30 @@ function format_line( $line, $type, $value, $skip_empty = false )
* Table format line function
* @see format_line
*/
function format_table_line( $line, $type, $value, $skip_empty = false )
function format_table_line($line, $type, $value, $skip_empty = false)
{
if ( trim( $value ) == "" && $skip_empty )
{
if (trim($value) == "" && $skip_empty) {
return "";
}
elseif ( trim( $value ) == "" )
{
} elseif (trim($value) == "") {
$value = '&nbsp;';
}
switch ( $type )
{
switch ($type) {
case DIFF_EQUAL:
{
//return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;=</td><td><span class="diffEqual" >' . $value . '</span></td></tr>' . "\n"; //juan carlos comentado
return '<tr><td></td><td bgcolor="#FFFFFF">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
return '<tr><td></td><td bgcolor="#FFFFFF">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
break;
}
case DIFF_MOVED:
{
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;M</td><td><span class="diffMoved" >' . $value . '</span></td></tr>' . "\n" //juan carlos comenta
;
return '<tr><td></td><td bgcolor="#FFFFAA">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;M</td><td><span class="diffMoved" >' . $value . '</span></td></tr>' . "\n" //juan carlos comenta
return '<tr><td></td><td bgcolor="#FFFFAA">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
break;
}
case DIFF_ADDED:
{
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;+</td><td><span class="diffAdded" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado
return '<tr><td></td><td bgcolor="#CCFFCC">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;+</td><td><span class="diffAdded" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado
return '<tr><td></td><td bgcolor="#CCFFCC">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
break;
}
case DIFF_DELETED:
{
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;-</td><td><span class="diffDeleted" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado
return '<tr><td></td><td bgcolor="#FFAAAA">'. $value . '</td></tr>' . "\n" ; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
}
// return '<tr><td>' . $line. '&nbsp;:&nbsp;' . '&nbsp;-</td><td><span class="diffDeleted" >' . $value . '</span></td></tr>' . "\n" ; //juan carlos comentado
return '<tr><td></td><td bgcolor="#FFAAAA">' . $value . '</td></tr>' . "\n"; //juan carlos muestra solo color (no tambi<EFBFBD>n la l<EFBFBD>nea). Adem<EFBFBD>s EN IEXPLORER VA BIEN PERO EN FIREFOX 3 la etiqueta span no muestra el color de fondo que est<EFBFBD> definido en la hoja de estilos como background-color, aceptando s<EFBFBD>lo la propiedad color pero esta solo da color al texto con lo cual los cambios quedan poco resaltados, adem<EFBFBD>s los cambios de otros objetos que no sean texto no se indican por ej. a<EFBFBD>adir una imagen, por esta raz<EFBFBD>n doy el color de fondo al td directamente.
}
}

File diff suppressed because it is too large Load Diff

@ -36,7 +36,8 @@ function createreflink($testvalue)
* @return bool False if title is already taken
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
**/
function checktitle($paramwk) {
function checktitle($paramwk)
{
global $tbl_wiki;
global $groupfilter;
global $condition_session;
@ -53,9 +54,8 @@ function checktitle($paramwk) {
// the value has not been found and is this available
if ($numberofresults==0) {
return true;
}
else // the value has been found
{
} else {
// the value has been found
return false;
}
}
@ -66,14 +66,15 @@ function checktitle($paramwk) {
**/
function links_to($input)
{
$input_array=preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
$input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
$all_links = array();
foreach ($input_array as $key=>$value) {
if ($input_array[$key-1]=='[[' AND $input_array[$key+1]==']]') {
if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' &&
isset($input_array[$key+1]) && $input_array[$key+1] == ']]'
) {
if (api_strpos($value, "|") !== false) {
$full_link_array=explode("|", $value);
$full_link_array=explode("|", $value);
$link=trim($full_link_array[0]);
$title=trim($full_link_array[1]);
} else {
@ -82,10 +83,11 @@ function links_to($input)
}
unset($input_array[$key-1]);
unset($input_array[$key+1]);
$all_links[]= Database::escape_string(str_replace(' ','_',$link)).' '; //replace blank spaces by _ within the links. But to remove links at the end add a blank space
//replace blank spaces by _ within the links. But to remove links at the end add a blank space
$all_links[]= Database::escape_string(str_replace(' ','_',$link)).' ';
}
}
$output=implode($all_links);
$output = implode($all_links);
return $output;
}
@ -168,35 +170,15 @@ function detect_irc_link($input) {
function make_wiki_link_clickable($input)
{
$groupId = api_get_group_id();
$input_array=preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE); //now doubles brackets
//now doubles brackets
$input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($input_array as $key=>$value) {
foreach ($input_array as $key => $value) {
//now doubles brackets
if ($input_array[$key-1] == '[[' AND $input_array[$key+1]==']]') {
/////////// TODO: metawiki
/*
if ($session_id==0)
{
if ($groupId==0)
{
$titleg_ex='';
}
else
{
$group_properties = GroupManager :: get_group_properties($groupId);
$group_name= $group_properties['name'];
$titleg_ex='<sup><img src="css/wgroup.gif" alt="('.$group_name.')" title="Link to Wikigroup:'.$group_name.'"/></sup>';
}
}
else
{
TODO:logic for sessions
}
*/
/////////
//now full wikilink
if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' AND
$input_array[$key+1] == ']]'
) {
// now full wikilink
if (api_strpos($value, "|") !== false){
$full_link_array=explode("|", $value);
$link=trim(strip_tags($full_link_array[0]));
@ -275,19 +257,21 @@ function save_wiki()
$_clean['fprogress3']=Database::escape_string($_POST['fprogress3']);
}
if (Security::remove_XSS($_POST['initstartdate']==1)) {
if (isset($_POST['initstartdate']) && $_POST['initstartdate'] == 1) {
$_clean['startdate_assig']=Database::escape_string(get_date_from_select('startdate_assig'));
} else {
$_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']);
}
if (Security::remove_XSS($_POST['initenddate']==1)) {
$_clean['enddate_assig']=Database::escape_string(get_date_from_select('enddate_assig'));
if (isset($_POST['initenddate']) && $_POST['initenddate']==1) {
$_clean['enddate_assig'] = Database::escape_string(get_date_from_select('enddate_assig'));
} else {
$_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']);
$_clean['enddate_assig'] = Database::escape_string($_POST['enddate_assig']);
}
$_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']);
if (isset($_POST['delayedsubmit'])) {
$_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']);
}
if (!empty($_POST['max_text']) || !empty($_POST['max_version'])) {
$_clean['max_text'] =Database::escape_string($_POST['max_text']);
@ -389,8 +373,13 @@ function save_new_wiki() {
global $tbl_wiki_conf;
global $page;
$_clean = array();
// cleaning the variables
$_clean['assignment']=Database::escape_string($_POST['assignment']);
$_clean['assignment'] = null;
if (isset($_POST['assignment'])) {
$_clean['assignment'] = Database::escape_string($_POST['assignment']);
}
// session_id
$session_id = api_get_session_id();
@ -414,7 +403,7 @@ function save_new_wiki() {
return false;
}
if($_clean['assignment']==2) {//config by default for individual assignment (students)
if ($_clean['assignment']==2) {//config by default for individual assignment (students)
//Identifies the user as a creator, not the teacher who created
$_clean['user_id']=(int)Database::escape_string($assig_user_id);
$_clean['visibility']=0;
@ -501,31 +490,32 @@ function save_new_wiki() {
* @return html code
**/
function display_new_wiki_form() {
global $page;
global $page;
?>
<script>
function CheckSend()
{
if(document.form1.title.value == "")
{
if (document.form1.title.value == "") {
alert("<?php echo get_lang('NoWikiPageTitle');?>");
document.form1.title.focus();
return false;
}
return true;
return true;
}
function setFocus(){
$("#wiki_title").focus();
}
$(document).ready(function () {
setFocus();
});
function setFocus(){
$("#wiki_title").focus();
}
$(document).ready(function () {
setFocus();
});
</script>
<?php
$title = isset($_GET['title']) ? Security::remove_XSS($_GET['title']) : null;
//form
echo '<form name="form1" method="post" onsubmit="return CheckSend()" action="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&amp;title='.api_htmlentities(urlencode(strtolower(str_replace(' ','_',$page)))).'&group_id='.api_htmlentities($_GET['group_id']).'">';
echo '<div id="wikititle" style="min-height:30px;">';
echo '<div style="width:70%;float:left;"><span class="form_required">*</span> '.get_lang('Title').': <input type="text" id="wiki_title" name="title" value="'.api_htmlentities($_GET['title']).'" size="40"></div>';
echo '<div style="width:70%;float:left;">
<span class="form_required">*</span> '.get_lang('Title').': <input type="text" id="wiki_title" name="title" value="'.$title.'" size="40"></div>';
if(api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
echo'<a href="javascript://" onclick="advanced_parameters()" ><span id="plus_minus" style="float:right">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'</span></a>';
@ -685,7 +675,8 @@ return true;
* @author Juan Carlos Raña Trabado
* @return html code
**/
function display_wiki_entry($newtitle) {
function display_wiki_entry($newtitle)
{
global $tbl_wiki, $tbl_wiki_conf, $groupfilter, $condition_session, $page;
$course_id = api_get_course_int_id();
if ($newtitle) {
@ -694,12 +685,11 @@ function display_wiki_entry($newtitle) {
$pageMIX=$page;//display current page
}
$session_id=api_get_session_id();
if ($_GET['view']) {
$session_id = api_get_session_id();
$filter = null;
if (isset($_GET['view']) && $_GET['view']) {
$_clean['view']=(int)Database::escape_string($_GET['view']);
$filter=' AND w.id="'.$_clean['view'].'"';
$filter =' AND w.id="'.$_clean['view'].'"';
}
//first, check page visibility in the first page version
@ -713,21 +703,21 @@ function display_wiki_entry($newtitle) {
$KeyVisibility=$row['visibility'];
// second, show the last version
$sql='SELECT * FROM '.$tbl_wiki.' w , '.$tbl_wiki_conf.' wc
WHERE wc.c_id = '.$course_id.' AND
w.c_id = '.$course_id.' AND
wc.page_id = w.page_id AND
w.reflink = "'.Database::escape_string($pageMIX).'" AND
w.session_id = '.$session_id.' AND
w.'.$groupfilter.' '.$filter.'
ORDER BY id DESC';
$sql = 'SELECT * FROM '.$tbl_wiki.' w , '.$tbl_wiki_conf.' wc
WHERE
wc.c_id = '.$course_id.' AND
w.c_id = '.$course_id.' AND
wc.page_id = w.page_id AND
w.reflink = "'.Database::escape_string($pageMIX).'" AND
w.session_id = '.$session_id.' AND
w.'.$groupfilter.' '.$filter.'
ORDER BY id DESC';
$result = Database::query($sql);
$row = Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
//log users access to wiki (page_id)
if (!empty($row['page_id']))
{
if (!empty($row['page_id'])) {
event_system(LOG_WIKI_ACCESS, LOG_WIKI_PAGE_ID, $row['page_id']);
}
//update visits
@ -754,14 +744,15 @@ function display_wiki_entry($newtitle) {
}
//assignment mode: identify page type
$icon_assignment = null;
if ($row['assignment']==1) {
$icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
$icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
} elseif($row['assignment']==2) {
$icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
$icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
}
//task mode
$icon_task = null;
if (!empty($row['task'])) {
$icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
}

Loading…
Cancel
Save