Permalink
Browse files

Merge branch 'MDL-25637'

  • Loading branch information...
2 parents c9b2e8b + 80c1289 commit 912d099cc94e40777b73b2412d12ffd95f79856d Sam Hemelryk committed Jan 24, 2011
@@ -12,7 +12,7 @@
// Find out whether host supports https
$protocol = 'http://';
if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'){
- $protocol = 'https://';
+ $protocol = 'https://';
}
// Front channel logout
@@ -197,11 +197,12 @@ function LogoutNotification($SessionID){
/*****************************************************************************/
// Same function as in adodb, but cannot be used for file session for some reason...
-function unserializesession( $serialized_string ){
- $variables = array( );
- $a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
- for( $i = 0; $i < count( $a ); $i = $i+2 ) {
- $variables[$a[$i]] = unserialize( $a[$i+1] );
+function unserializesession($serialized_string) {
+ $variables = array();
+ $a = preg_split("/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
+ $counta = count($a);
+ for ($i = 0; $i < $counta; $i = $i+2) {
+ $variables[$a[$i]] = unserialize($a[$i+1]);
}
- return( $variables );
+ return $variables;
}
View
@@ -119,7 +119,7 @@ function delete_dir_contents ($dir,$excludeddir="") {
}
// Loop through all directory entries, and construct two temporary arrays containing files and sub directories
- while(false !== ($entry = readdir($handle))) {
+ while (false !== ($entry = readdir($handle))) {
if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != "." && $entry != $excludeddir) {
$dir_subdirs[] = $dir. $slash .$entry;
}
@@ -129,15 +129,17 @@ function delete_dir_contents ($dir,$excludeddir="") {
}
// Delete all files in the curent directory return false and halt if a file cannot be removed
- for($i=0; $i<count($dir_files); $i++) {
+ $countdirfiles = count($dir_files);
+ for ($i=0; $i<$countdirfiles; $i++) {
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == FALSE) {
return false;
}
}
// Empty sub directories and then remove the directory
- for($i=0; $i<count($dir_subdirs); $i++) {
+ $countdirsubdirs = count($dir_subdirs);
+ for($i=0; $i<$countdirsubdirs; $i++) {
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if (delete_dir_contents($dir_subdirs[$i]) == FALSE) {
return false;
@@ -377,7 +377,8 @@ function restore_create_blogs($restore,$xml_file) {
$tagsarr = $info['BLOG']['#']['BLOG_TAGS']['0']['#']['BLOG_TAG'];
//Iterate over tags
$tags = array();
- for($i = 0; $i < sizeof($tagsarr); $i++) {
+ $sizetagsarr = sizeof($tagsarr);
+ for ($i = 0; $i < $sizetagsarr; $i++) {
$tag_info = $tagsarr[$i];
///traverse_xmlize($tag_info); //Debug
///print_object ($GLOBALS['traverse_array']); //Debug
@@ -128,9 +128,10 @@ function get_printval($item, $value) {
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
$data = $analysed_item->data;
- if(is_array($data)) {
+ if (is_array($data)) {
echo '<tr><th colspan="2" align="left">'. $itemnr . '&nbsp;('. $item->label .') ' . $item->name .'</th></tr>';
- for($i = 0; $i < sizeof($data); $i++) {
+ $sizeofdata = sizeof($data);
+ for ($i = 0; $i < $sizeofdata; $i++) {
echo '<tr><td colspan="2" valign="top" align="left">-&nbsp;&nbsp;' . str_replace("\n", '<br />', $data[$i]->show) . '</td></tr>';
}
}
@@ -144,11 +145,12 @@ function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid,
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
$worksheet->write_string($rowOffset, 1, $item->name, $xlsFormats->head2);
$data = $analysed_item->data;
- if(is_array($data)) {
+ if (is_array($data)) {
// $worksheet->setFormat("<l><ro2><vo>");
$worksheet->write_string($rowOffset, 2, $data[0]->show, $xlsFormats->value_bold);
$rowOffset++;
- for($i = 1; $i < sizeof($data); $i++) {
+ $sizeofdata = sizeof($data);
+ for ($i = 1; $i < $sizeofdata; $i++) {
// $worksheet->setFormat("<l><vo>");
$worksheet->write_string($rowOffset, 2, $data[$i]->show, $xlsFormats->default);
$rowOffset++;
@@ -119,14 +119,15 @@ function get_analysed($item, $groupid = false, $courseid = false) {
$analysedAnswer = array();
if($info->subtype == 'c') {
- for($i = 1; $i <= sizeof($answers); $i++) {
+ $sizeofanswers = sizeof($answers);
+ for ($i = 1; $i <= $sizeofanswers; $i++) {
$ans = null;
$ans->answertext = $answers[$i-1];
$ans->answercount = 0;
- foreach($values as $value) {
+ foreach ($values as $value) {
//ist die Antwort gleich dem index der Antworten + 1?
$vallist = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value->value);
- foreach($vallist as $val) {
+ foreach ($vallist as $val) {
if ($val == $i) {
$ans->answercount++;
}
@@ -136,11 +137,12 @@ function get_analysed($item, $groupid = false, $courseid = false) {
$analysedAnswer[] = $ans;
}
}else {
- for($i = 1; $i <= sizeof($answers); $i++) {
+ $sizeofanswers = sizeof($answers);
+ for ($i = 1; $i <= $sizeofanswers; $i++) {
$ans = null;
$ans->answertext = $answers[$i-1];
$ans->answercount = 0;
- foreach($values as $value) {
+ foreach ($values as $value) {
//ist die Antwort gleich dem index der Antworten + 1?
if ($value->value == $i) {
$ans->answercount++;
@@ -159,26 +161,30 @@ function get_printval($item, $value) {
$printval = '';
- if(!isset($value->value)) return $printval;
+ if (!isset($value->value)) {
+ return $printval;
+ }
// @list($presentation) = explode(FEEDBACK_RADIO_ADJUST_SEP, $item->presentation); //remove the adjustment-info
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
- if($info->subtype == 'c') {
+ if ($info->subtype == 'c') {
$vallist = array_values(explode (FEEDBACK_MULTICHOICE_LINE_SEP, $value->value));
- for($i = 0; $i < sizeof($vallist); $i++) {
- for($k = 0; $k < sizeof($presentation); $k++) {
- if($vallist[$i] == ($k + 1)) {//Die Werte beginnen bei 1, das Array aber mit 0
+ $sizeofvallist = sizeof($vallist);
+ $sizeofpresentation = sizeof($presentation);
+ for ($i = 0; $i < $sizeofvallist; $i++) {
+ for ($k = 0; $k < $sizeofpresentation; $k++) {
+ if ($vallist[$i] == ($k + 1)) {//Die Werte beginnen bei 1, das Array aber mit 0
$printval .= trim($presentation[$k]) . chr(10);
break;
}
}
}
- }else {
+ } else {
$index = 1;
foreach($presentation as $pres){
- if($value->value == $index){
+ if ($value->value == $index){
$printval = $pres;
break;
}
@@ -231,8 +237,9 @@ function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid,
//frage schreiben
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2_green);
$worksheet->write_string($rowOffset, 1, $analysed_item[1], $xlsFormats->head2_green);
- if(is_array($data)) {
- for($i = 0; $i < sizeof($data); $i++) {
+ if (is_array($data)) {
+ $sizeofdata = sizeof($data);
+ for ($i = 0; $i < $sizeofdata; $i++) {
$aData = $data[$i];
// $worksheet->setFormat("<l><f><ro2><vo><c:blue>");
@@ -244,7 +251,7 @@ function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid,
$worksheet->write_number($rowOffset + 2, $i + 2, $aData->quotient, $xlsFormats->procent);
}
}
- $rowOffset +=3 ;
+ $rowOffset += 3;
return $rowOffset;
}
@@ -560,14 +567,15 @@ function get_info($item) {
}
function item_arrayToString($value) {
- if(!is_array($value)) {
+ if (!is_array($value)) {
return $value;
}
$retval = '';
$arrvals = array_values($value);
$arrvals = clean_param($arrvals, PARAM_INT); //prevent sql-injection
$retval = $arrvals[0];
- for($i = 1; $i < sizeof($arrvals); $i++) {
+ $sizeofarrvals = sizeof($arrvals);
+ for ($i = 1; $i < $sizeofarrvals; $i++) {
$retval .= FEEDBACK_MULTICHOICE_LINE_SEP.$arrvals[$i];
}
return $retval;
@@ -120,8 +120,8 @@ function get_analysed($item, $groupid = false, $courseid = false) {
//schleife ueber den Werten und ueber die Antwortmoeglichkeiten
$analysedAnswer = array();
-
- for($i = 1; $i <= sizeof($lines); $i++) {
+ $sizeoflines = sizeof($lines);
+ for($i = 1; $i <= $sizeoflines; $i++) {
$item_values = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $lines[$i-1]);
$ans = null;
$ans->answertext = $item_values[1];
@@ -215,7 +215,8 @@ function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid,
$worksheet->write_string($rowOffset, 1, $analysed_item[1], $xlsFormats->head2);
if(is_array($data)) {
$avg = 0.0;
- for($i = 0; $i < sizeof($data); $i++) {
+ $sizeofdata = sizeof($data);
+ for($i = 0; $i < $sizeofdata; $i++) {
$aData = $data[$i];
// $worksheet->setFormat("<l><f><ro2><vo><c:blue>");
@@ -142,7 +142,8 @@ function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid,
$worksheet->write_string($rowOffset, 2, $data[0], $xlsFormats->value_bold);
}
$rowOffset++;
- for($i = 1; $i < sizeof($data); $i++) {
+ $sizeofdata = sizeof($data);
+ for($i = 1; $i < $sizeofdata; $i++) {
// $worksheet->setFormat("<l><vo>");
$worksheet->write_string($rowOffset, 2, $data[$i], $xlsFormats->default);
$rowOffset++;
@@ -139,7 +139,8 @@ function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid,
// $worksheet->setFormat("<l><ro2><vo>");
$worksheet->write_string($rowOffset, 2, $data[0], $xlsFormats->value_bold);
$rowOffset++;
- for($i = 1; $i < sizeof($data); $i++) {
+ $sizeofdata = sizeof($data);
+ for($i = 1; $i < $sizeofdata; $i++) {
// $worksheet->setFormat("<l><vo>");
$worksheet->write_string($rowOffset, 2, $data[$i], $xlsFormats->default);
$rowOffset++;
@@ -187,7 +187,8 @@
}
$xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
- for($i = 0; $i < sizeof($xmlentries); $i++) {
+ $sizeofxmlentries = sizeof($xmlentries);
+ for($i = 0; $i < $sizeofxmlentries; $i++) {
// Inserting the entries
$xmlentry = $xmlentries[$i];
unset($newentry);
@@ -247,7 +248,8 @@
$importedentries++;
$xmlaliases = @$xmlentry['#']['ALIASES'][0]['#']['ALIAS']; // ignore missing ALIASES
- for($k = 0; $k < sizeof($xmlaliases); $k++) {
+ $sizeofxmlaliases = sizeof($xmlaliases);
+ for($k = 0; $k < $sizeofxmlaliases; $k++) {
/// Importing aliases
$xmlalias = $xmlaliases[$k];
$aliasname = $xmlalias['#']['NAME'][0]['#'];
@@ -263,7 +265,8 @@
if (!empty($data->catsincl)) {
// If the categories must be imported...
$xmlcats = @$xmlentry['#']['CATEGORIES'][0]['#']['CATEGORY']; // ignore missing CATEGORIES
- for($k = 0; $k < sizeof($xmlcats); $k++) {
+ $sizeofxmlcats = sizeof($xmlcats);
+ for($k = 0; $k < $sizeofxmlcats; $k++) {
$xmlcat = $xmlcats[$k];
$newcat = new stdClass();
@@ -110,7 +110,8 @@
// want to allow <b><i>(maybe more) tags but when we do that
// the preg_match messes up.
preg_match_all("/(<([\w]+)[^>]*>)([^<\\2>]*)(<\/\\2>)/", $string, $matches);
- for($i = 0; $i < count($matches[1]); $i++) { // go through all of our div matches
+ $countmatches = count($matches[1]);
+ for($i = 0; $i < $countmatches; $i++) { // go through all of our div matches
$class = lesson_importppt_isolate_class($matches[1][$i]); // first step in isolating the class
@@ -207,4 +208,4 @@
echo $OUTPUT->box_start('generalbox boxaligncenter');
$mform->display();
echo $OUTPUT->box_end();
-echo $OUTPUT->footer();
+echo $OUTPUT->footer();
@@ -300,8 +300,9 @@ function ouwiki_line($data,$linepos) {
$pos=0;
while(true) {
// Find a non-space
- for(;$pos < strlen($data) && substr($data,$pos,1)===' ';$pos++) ;
- if($pos==strlen($data)) {
+ $strlendata = strlen($data);
+ for(;$pos < $strlendata && substr($data,$pos,1)===' ';$pos++) ;
+ if($pos==$strlendata) {
// No more content
break;
}
@@ -527,7 +528,8 @@ function internal_find_deletes($diff,$count2) {
// resulting array will be -,-,3,3,3,-,0
$squidges=array();
$lowest=0;
- for($index1=count($diff);$index1>=1;$index1--) {
+ $countdiff = count($diff);
+ for($index1=$countdiff;$index1>=1;$index1--) {
$index2=$diff[$index1];
if($index2===0) {
$squidges[$index1]=$lowest;
@@ -142,7 +142,8 @@ private function get_table_cells($string) {
$cells = array();
foreach($normalcells as $nc) {
$headercells = explode("!!", $nc);
- for($i = 0; $i < count($headercells); $i++) {
+ $countheadercells = count($headercells);
+ for($i = 0; $i < $countheadercells; $i++) {
$cells[] = array($type, $headercells[$i]);
$type = 'header';
}
@@ -73,15 +73,17 @@ function clean_temp_dir($dir='') {
}
// Delete all files in the curent directory return false and halt if a file cannot be removed
- for($i=0; $i<count($dir_files); $i++) {
+ $countdir_files = count($dir_files);
+ for($i=0; $i<$countdir_files; $i++) {
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == FALSE) {
return false;
}
}
// Empty sub directories and then remove the directory
- for($i=0; $i<count($dir_subdirs); $i++) {
+ $countdir_subdirs = count($dir_subdirs);
+ for($i=0; $i<$countdir_subdirs; $i++) {
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if ($this->clean_temp_dir($dir_subdirs[$i]) == FALSE) {
return false;
@@ -168,7 +168,8 @@ function question_edit_calculatedsimple_form(&$submiturl, &$question, &$category
$calcmax = optional_param('calcmax', '', PARAM_NUMBER);
$oldoptions = optional_param('defoptions', '', PARAM_RAW);
$newdatasetvalues = false ;
- for($key = 1 ; $key <= sizeof($olddef) ; $key++) {
+ $sizeofolddef = sizeof($olddef);
+ for($key = 1; $key <= $sizeofolddef; $key++) {
$def = $olddef[$key] ;
$this->datasetdefs[$def]= new stdClass ;
$this->datasetdefs[$def]->type = 1;

0 comments on commit 912d099

Please sign in to comment.