diff --git a/main/exercice/tests_category.php b/main/exercice/tests_category.php index 384e9e42e5..5ab0c166b3 100644 --- a/main/exercice/tests_category.php +++ b/main/exercice/tests_category.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; -} \ No newline at end of file +} diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index c503b7a438..5673de58ef 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -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'); diff --git a/main/glossary/index.php b/main/glossary/index.php index 447d7de55a..31e2103aa9 100644 --- a/main/glossary/index.php +++ b/main/glossary/index.php @@ -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 '
term;definition;
"Hello";"Hola";
"Good";"Bueno";';
-
+
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();
\ No newline at end of file
+Display::display_footer();
diff --git a/main/gradebook/lib/scoredisplay.class.php b/main/gradebook/lib/scoredisplay.class.php
index 7fb6bbe6f0..f10f465348 100644
--- a/main/gradebook/lib/scoredisplay.class.php
+++ b/main/gradebook/lib/scoredisplay.class.php
@@ -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) {
diff --git a/main/inc/lib/gradebook.lib.php b/main/inc/lib/gradebook.lib.php
index f597d8f90b..daee9b1e0d 100644
--- a/main/inc/lib/gradebook.lib.php
+++ b/main/inc/lib/gradebook.lib.php
@@ -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');
}
}
diff --git a/main/inc/lib/promotion.lib.php b/main/inc/lib/promotion.lib.php
index 39abfa9be8..d29af50d46 100644
--- a/main/inc/lib/promotion.lib.php
+++ b/main/inc/lib/promotion.lib.php
@@ -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');
diff --git a/main/inc/lib/timeline.lib.php b/main/inc/lib/timeline.lib.php
index 89c78ea751..b33a524a8e 100644
--- a/main/inc/lib/timeline.lib.php
+++ b/main/inc/lib/timeline.lib.php
@@ -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');
diff --git a/main/notebook/index.php b/main/notebook/index.php
index add05c9e66..0778df5770 100644
--- a/main/notebook/index.php
+++ b/main/notebook/index.php
@@ -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']).'¬ebook_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'));
diff --git a/main/survey/create_new_survey.php b/main/survey/create_new_survey.php
index 0eb803f9bb..e8f32c53de 100644
--- a/main/survey/create_new_survey.php
+++ b/main/survey/create_new_survey.php
@@ -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();
\ No newline at end of file
+Display :: display_footer();
diff --git a/main/wiki/diff.inc.php b/main/wiki/diff.inc.php
index 68d133b2bd..9460c0524b 100755
--- a/main/wiki/diff.inc.php
+++ b/main/wiki/diff.inc.php
@@ -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 = ' ';
}
- switch ( $type )
- {
+ switch ($type) {
case DIFF_EQUAL:
- {
- // return $line. ' : ' . ' = ' . $value . '