Browse Source

Fix:Coding style

MOODLE_20_STABLE
Vasilis Daloukas 9 years ago
parent
commit
95740ab5ae
  1. 749
      bookquiz/importodt.php
  2. 480
      bookquiz/importppt.php
  3. 15
      classes/event/course_module_instance_list_viewed.php
  4. 10
      lib.php
  5. 25
      locallib.php
  6. 2
      millionaire/play.php
  7. 2
      pagelib.php
  8. 1
      showanswers.php
  9. 2
      showattempts.php
  10. 4
      snakes/play.php
  11. 8
      sudoku/sdd/class.SDD.php
  12. 2
      sudoku/sdd/class.logfile.php

749
bookquiz/importodt.php

@ -1,749 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This is a very rough importer for odt
*
* The script supports book
* Is based on class office from http://www.phpclasses.org/browse/package/2586.html
*
* @version $Id: importodt.php,v 1.5 2012/07/25 11:16:04 bdaloukas Exp $
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package game
**/
require_once("../../../config.php");
require_once( "../header.php");
require_once("../locallib.php");
$subchapter = optional_param('subchapter', '', PARAM_ALPHA);
$overwrite = optional_param('overwrite', 0, PARAM_INT);
$attempt = game_getattempt( $game, $detail);
$bookid = $game->bookid;
if ($bookid == 0) {
print_error( get_string( 'bookquiz_not_select_book', 'game'));
}
if ($form = data_submitted()) {
// Filename.
if (empty($_FILES['newfile'])) {
// File was just uploaded.
notify(get_string("uploadproblem") );
}
if ((!is_uploaded_file($_FILES['newfile']['tmp_name']) or $_FILES['newfile']['size'] == 0)) {
notify(get_string("uploadnofilefound") );
} else {
// Valid file is found.
if (readdata( $course->id, 'game', $dirtemp, $rlevels, $rtitles, $rtexts, $dirfordelete)) {
// First try to reall all of the data in.
if ($overwrite) {
game_bookquiz_deletebook( $course->id, $bookid);
}
// Parse all the html files into objects.
$pageobjects = extract_data( $course->id, 'book', $bookid, $dirtemp, $subchapter, $rlevels, $rtitles, $rtexts);
clean_temp( $dirfordelete); // All done with files so dump em.
// Function to preps the data to be sent to DB.
$objects = game_bookquiz_create_objects( $pageobjects, $bookid);
if (!game_bookquiz_save_objects( $objects)) {
// Sends it to DB.
print_error('could not save');
}
} else {
print_error('could not get data');
}
print_continue("{$CFG->wwwroot}/mod/game/view.php?id=$cm->id");
echo $OUTPUT->footer($course);
exit;
}
}
// Print upload form.
print_heading_with_help( get_string( "bookquiz_import_odt", "game"), "importodt", "game");
echo $OUTPUT->box_start('center');
?>
<form id="theform" enctype="multipart/form-data" method="post">
<input type="hidden" name="id" value="<?php echo $cm->id; ?>" />
<table cellpadding="5">
<tr><td align="right"><b>
<?php print_string("upload"); ?> :</td><td>
<input name="newfile" type="file" size="50" />
<tr valign="top">
<td valign="top" align="right">
<b><?php echo get_string( 'bookquiz_subchapter', 'game');?>:</b>
</td>
<td>
<input name="subchapter" type="checkbox" value="1" checked="1" /> </td>
</tr>
<tr valign="top"><td align="right"><b></b></td><td align="left"><select id="overwrite" name="overwrite" >
<option value="0" selected="selected">Προσθήκη στο τέλος</option>
<option value="1">Αντικατάσταση</option>
</select>
</td></tr>
</td></tr><tr><td>&nbsp;</td><td>
<input type="submit" name="save" value="<?php echo get_string("uploadthisfile"); ?>" />
</td></tr>
</table>
</form>
<?php
echo $OUTPUT->box_end();
echo $OUTPUT->footer($course);
// START OF FUNCTIONS.
// The rbasedir variable contains the directory where the temp files are.
// At the end the directory must be deleted.
function readdata( $courseid, $modname, &$rbasedir, &$rlevels, &$rtitles, &$rtexts, &$dirfordelete) {
// This function expects a odt file to be uploaded. Then it parses the content.xml to determine.
// Then copies the images.
global $CFG;
// Create a random upload directory in temp.
$newdir = $CFG->dataroot."/temp/$modname";
if (!file_exists( $newdir)) {
mkdir( $newdir);
}
$i = 1;
srand((double)microtime() * 1000000);
while (true) {
$rbasedir = "$modname/$i-".rand(0, 10000);
$newdir = $CFG->dataroot.'/temp/'.$rbasedir;
if (!file_exists( $newdir)) {
mkdir( $newdir);
$newdir .= '/';
break;
}
$i++;
}
$dirfordelete = $rbasedir;
$rbasedir .= '/';
$zipfile = $_FILES["newfile"]["name"];
$tempzipfile = $_FILES["newfile"]["tmp_name"];
// Creates our directory.
$pathparts = pathinfo($zipfile);
// Takes off the extension.
$dirname = substr($zipfile, 0, strpos($zipfile, '.'.$pathparts['extension']));
if (!file_exists($newdir.$dirname)) {
mkdir($newdir.$dirname);
}
// Move our uploaded file to temp/game.
move_uploaded_file( $tempzipfile, $newdir.$zipfile);
// If the file ends with .lnk then use .odt instead.
if (substr( $zipfile, -4) == ".lnk") {
$zipfile = substr( $zipfile, 0, -4).".odt";
}
// Unzip it!
unzip_file ( $newdir.$zipfile, $newdir.$dirname, false);
$rbasedir .= $dirname; // Update the base.
$newdir .= $dirname;
// This is the file where we get the names of the files for the slides (in the correct order too).
$content = $newdir.'/content.xml';
$data = file_get_contents( $content);
$content = $newdir.'/styles.xml';
if (file_exists( $content)) {
$datastyle = file_get_contents( $content);
} else {
$datastyle = '';
}
oo_game_convert_ver2( $data, $datastyle, $rlevels, $rtitles, $rtexts);
return true;
}
function oo_game_convert_ver2( $data, $datastyle, &$rlevels, &$rtitles, &$rtexts) {
$rlevels = array();
$rtitles = array();
$rtexts = array();
// We have tables, encode it here so all <text:p in them don't get preg_match_all few lines later.
if (ereg('table:table', $data)) {
$data = str_replace('<table:table', '<text:p text:style-name="RKRK"><table:table', $data);
$data = str_replace('</table:table>', '</table:table></text:p>', $data);
$data = preg_replace('#<table:table(.*?)</table:table>#es', "base64_encode('\\1')", $data);
}
$styles = array();
game_bookquiz_convert_ver2_computestyles( $datastyle, $styles, true);
game_bookquiz_convert_ver2_computestyles( $data, $styles, false);
game_bookquiz_splitsections($data, $positions, $inputs, $titles, $titleframes, $texts);
for ($i = 0; $i < count( $positions); $i++) {
preg_match_all( "#text:outline-level=\"([0-9]*)\"#es", $inputs[ $i], $matches);
$levels = $matches[ 1];
if (count( $levels) > 0) {
$level = $levels[ 0];
} else {
$level = 0;
}
$rlevels[] = $level;
$rtitles[] = strip_tags( $titles[ $i]);
$textframe = game_bookquiz_convert($titleframes[ $i], $styles, $images);
$text = game_bookquiz_convert($texts[ $i], $styles, $images);
if ($textframe != '') {
$text = $textframe.'<br>'.$text;
}
echo "<hr><b>".$titles[ $i]."</b><br>".$text."\r\n\r\n\r\n\r\n";
$rtexts[] = $text;
}
}
function extract_data( $courseid, $modname, $id, $basedir, $subchapter, $levels, $titles, $texts) {
global $CFG;
global $matches;
$dirtemp = $CFG->dataroot.'/temp/'.$basedir;
for ($i = 0; $i < count( $levels); $i++) {
echo $levels[ $i]." ".$titles[ $i]."<br>";
}
$extractedpages = array();
// Directory for images.
make_mod_upload_directory( $courseid); // Make sure moddata is made.
make_upload_directory( $courseid.'/moddata/'.$modname, false);
// We store our images in a subfolder in here.
make_upload_directory( $courseid.'/moddata/'.$modname."/".$id, false);
$imagedir = $CFG->dataroot.'/'.$courseid.'/moddata/'.$modname."/".$id;
if ($CFG->slasharguments) {
$imagelink = $CFG->wwwroot.'/file.php/'.$courseid.'/moddata/'.$modname."/".$id;
} else {
$imagelink = $CFG->wwwroot.'/file.php?file=/'.$courseid.'/moddata/'.$modname."/".$id;
}
// Try to make a unique subfolder to store the images.
$i = 1;
while (true) {
$newdir = $imagedir.'/'.$i;
if (!file_exists( $newdir)) {
// Ok doesnt exist so make the directory and update our paths.
mkdir( $newdir);
$imagedir = $newdir;
$imagelink = $imagelink.'/'.$i;
break;
}
$i++;
}
for ($i = 0; $i < count( $titles); $i++) {
// Start building our page.
$page = new stdClass;
$page->title = $titles[ $i];
$page->content = $texts[ $i];
$page->subchapter = ( $levels[ $i] >= 2);
// Check if the nexts are subchapters.
for ($j = $i + 1; $j < count( $titles); $j++) {
if ($levels[ $j] > 2) {
$page->content .= '<br><b><u>'.$titles[ $j].'</u></b><br>'.$texts[ $j];
$i = $j;
continue;
}
break;
}
preg_match_all('#="Pictures/([a-z .A-Z_0-9]*)"#es', $page->content, $imgs);
foreach ($imgs[1] as $img) {
$src = $dirtemp.'/Pictures/'.$img;
$dest = $imagedir.'/'.$img;
rename( $src, $dest);
$page->content = str_replace( "Pictures/$img", $imagelink."/".$img, $page->content);
}
// Add the page to the array.
$extractedpages[] = $page;
} // End $pages foreach loop.
return $extractedpages;
}
/*
Clean up the temp directory
*/
function clean_temp( $base) {
global $CFG;
// This function is broken, use it to clean up later.
// Should only clean up what we made as well because someone else could be importing ppt as well.
$dir = $CFG->dataroot.'/temp/'.$base;
remove_dir( $dir);
}
/*
Creates objects an chapter object that is to be inserted into the database
*/
function game_bookquiz_create_objects( $pageobjects, $bookid) {
global $DB;
$chapters = array();
$lastpagenum = $DB->get_field('book_chapters', 'MAX(pagenum) as num', array( 'bookid' => $bookid));
foreach ($pageobjects as $pageobject) {
$chapter = new stdClass;
// Same for all chapters.
$chapter->bookid = $bookid;
$chapter->pagenum = ++$lastpagenum;
$chapter->timecreated = time();
$chapter->timemodified = time();
$chapter->subchapter = 0;
if ($pageobject->title == '') {
$chapter->title = "Page $count"; // No title set so make a generic one.
} else {
$chapter->title = addslashes($pageobject->title);
}
$chapter->subchapter = $pageobject->subchapter;
$content = str_replace("\n", '', $pageobject->content);
$content = str_replace("\r", '', $content);
$content = str_replace('&#13;', '', $content); // Puts in returns?
$content = '<p>'.$content.'</p>';
$chapter->content = addslashes( $content);
$chapters[] = $chapter;
}
return $chapters;
}
// Save the chapter objects to the database.
function game_bookquiz_save_objects($chapters) {
global $DB;
// Nothing fancy, just save them all in order.
foreach ($chapters as $chapter) {
if (!$newid = $DB->insert_record('book_chapters', $chapter)) {
print_error('Could not insert to table book_chapters');
}
}
return true;
}
// Splits the data to.
function game_bookquiz_splitsections($data, &$positions, &$inputs, &$titles, &$titleframes, &$texts) {
preg_match_all('#<text:h (.*?)>(.*?)</text:h>#es', $data, $matches, PREG_OFFSET_CAPTURE);
$in = $matches[ 1];
$title = $matches[ 2];
$positions = array();
$inputs = array();
$titles = array();
$oldposition = 0;
$oldlen = 0;
for ($i = 0; $i < count( $in); $i++) {
$inputs[] = $in[ $i][ 0];
$newposition = $in[ $i][ 1];
$positions[] = $newposition;
$titlenet = $title[ $i][ 0];
$titleframe = '';
// Frames inside header.
preg_match_all('#<draw:frame (.*?)>(.*?)</draw:frame>#es', $titlenet, $titlematches, PREG_OFFSET_CAPTURE);
$frames = $titlematches[ 2];
if (count( $frames) > 0) {
for ($j = 0; $j < count( $frames); $j++) {
$titleframe .= $frames[ $j][ 0];
$titlenet = substr( $titlenet, $frames[ $j][ 1] + strlen( $frames[ $j][ 0]) + 13);
}
}
$titles[] = $titlenet;
$titleframes[] = $titleframe;
if ($i > 0) {
$texts[] = substr( $data, $oldposition + $oldlen, $newposition - $oldposition - $oldlen);
}
$oldlen = strlen( $title[ $i][ 0]) + strlen( $in[ $i][ 0]) + 10;
$oldposition = $newposition;
}
$newposition = strlen( $data);
$texts[] = substr( $data, $oldposition + $oldlen, $newposition - $oldposition - $oldlen);
}
function game_bookquiz_convert( $data, $styles, &$images) {
$images = array();
// Get data.
preg_match_all('#<text:p text:style-name="([a-z A-Z_0-9]*)">(.*?)</text:p>#es', $data, $text);
$originals = $text[ 0];
$names = $text[ 1];
$texts = $text[ 2];
for ($i = 0; $i < count( $texts); $i++) {
$name = $names[ $i];
$text = $texts[ $i];
// Repairs draw:frame.
$pattern = "#<draw:frame draw:style-name=\"([a-z .A-Z_0-9]*)\" (.*?)<draw:image xlink:href=\"Pictures/([a-z .A-Z_0-9]*)(.*?)</draw:frame>#es";
preg_match_all( $pattern, $text, $matches);
if (count( $matches[ 1]) ) {
$new = game_bookquiz_convert_image( $matches, $styles, $images);
$data = str_replace( $originals[ $i], $new, $data);
} else if ($name == 'RKRK') {
$new = game_bookquiz_convert_RKRK( $text);
$data = str_replace( $originals[ $i], $new, $data);
} else {
$new = '<P>'.game_bookquiz_convert_text( $text, $styles).'</P>';
$data = str_replace( $originals[ $i], $new, $data);
}
}
// Repairs text:span text:style-name.
preg_match_all( '#<text:span text:style-name="([a-z .A-Z_0-9]*)">(.*?)</text:span>#es', $data, $text);
$originals = $text[ 0];
$names = $text[ 1];
$texts = $text[ 2];
for ($i = 0; $i < count( $texts); $i++) {
$name = $names[ $i];
$text = $texts[ $i];
$pattern = "#<draw:frame draw:style-name=\"([a-z .A-Z_0-9]*)\" (.*?)<draw:image xlink:href=\"Pictures/([a-z .A-Z_0-9]*)(.*?)</draw:frame>#es";
preg_match_all( $pattern, $text, $matches);
if (count( $matches[ 1]) ) {
$new = game_bookquiz_convert_image( $matches, $styles, $images);
$data = str_replace( $originals[ $i], $new, $data);
} else if ($name == 'RKRK') {
$new = game_bookquiz_convert_RKRK( $text);
$data = str_replace( $originals[ $i], $new, $data);
} else {
$new = "<span ".$styles[ $name].'>'.game_bookquiz_convert_text( $text, $styles).'</span>';
$data = str_replace( $originals[ $i], $new, $data);
}
}
// Repairs text:a.
preg_match_all( '#<text:a (.*?) xlink:href="(.*?)">(.*?)</text:a>#es', $data, $text);
$originals = $text[ 0];
$hrefs = $text[ 2];
$texts = $text[ 3];
for ($i = 0; $i < count( $texts); $i++) {
$href = $hrefs[ $i];
$text = $texts[ $i];
$new = "<a href=\"$href\">$text</a>";
$data = str_replace( $originals[ $i], $new, $data);
}
// Repair text:list.
preg_match_all( '#<text:list text:style-name="([a-z A-Z_0-9]*)">(.*?)</text:list>#es', $data, $text);
$originals = $text[ 0];
$names = $text[ 1];
$texts = $text[ 2];
for ($i = 0; $i < count( $texts); $i++) {
$new = '<UL>'.$texts[ $i].'</UL>';
$data = str_replace( $originals[ $i], $new, $data);
// I have to repair the listitems.
preg_match_all( '#<text:list-item>(.*?)</text:list-item>#es', $data, $listitems);
$originallistitems = $listitems[ 0];
$items = $listitems[ 1];
for ($j = 0; $j < count( $items); $j++) {
$new = '<LI>'.$items[ $j];
$data = str_replace( $originallistitems[ $j], $new, $data);
}
}
$data = str_replace( '<text:line-break/>', '<br>', $data);
return $data;
}
function game_bookquiz_convert_text( $text, $styles) {
$pattern = "#<text:span text:style-name=\"([a-z .A-Z_0-9]*)\">(.*?)</text:span>#es";
preg_match_all( $pattern, $text, $matches);
$originals = $matches[ 0];
$names = $matches[ 1];
$spantexts = $matches[ 2];
for ($i = 0; $i < count( $names); $i++) {
$name = $names[ $i];
$style = $styles[ $name];
$new = "<text:span style=\"$style\">".$spantexts[ $i]."</text:span>";
$text = str_replace( $originals[ $i], $new, $text);
}
return $text;
}
function game_bookquiz_convert_image( $matches, $xmlstyles, &$images) {
$ret = '';
$styles = $matches[ 1];
$pictures = $matches[ 3];
for ($j = 0; $j < count( $pictures); $j++) {
$style = $styles[ $j];
$ret .= '<div class="'.$style.'"><img src="Pictures/'.$pictures[$j].'"></div>';
$images[] = $pictures[$j];
}
return $ret;
}
function game_bookquiz_convert_rkrk( $text) {
$table = base64_decode($text);
$table = stripslashes($table);
$table = strtr($table, array('</table:table>' => '</table>', '<table:table-row>' => '<tr>', '</table:table-row>' => '</tr>', '</table:table-cell>' => '</td>', '</table:table-header-rows>' => '', '<table:table-header-rows>' => '', '>' => ">\n", '</text:p>' => ''));
preg_match_all('#table:name="(.*?)" table:style-name="(.*?)">#es', $table, $repl);
foreach ($repl[0] as $val) {
$table = str_replace($val, '<table border="1"><tr>', $table);
}
preg_match_all('#<text:p text:style-name="(.*?)">#es', $table, $repl);
foreach ($repl[0] as $key => $val) {
$table = str_replace($val, '', $table);
}
preg_match_all('#<table:table-column (.*?)">#es', $table, $repl);
foreach ($repl[0] as $val) {
$table = str_replace($val, '', $table);
}
preg_match_all('#<table:table-cell table:style-name="(.*?)" office:value-type=(.*?)">#es', $table, $repl);
foreach ($repl[0] as $val) {
$table = str_replace($val, '<td>', $table);
}
// Maybe there are a lot of pictures inside a table.
preg_match_all('#xlink:href="Pictures/([a-z.A-Z_0-9]*)"#es', $table, $repl);
foreach ($repl[ 1] as $picture) {
$table = str_replace('<draw:image xlink:href="Pictures/'.$picture.'" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>', '<img src="Pictures/'.$picture.'">', $table);
}
if (strpos( $table, "</table>") === false) {
$table .= "</table>";
}
$ret = '<BR>'.$table.'<BR>';
return $ret;
}
function game_bookquiz_deletebook( $courseid, $bookid) {
global $CFG;
if (!delete_records( 'book_chapters', 'bookid', $bookid)) {
print_error( "Can't delete records from book_chapters bookid=$bookid");
}
game_full_rmdir( "$CFG->dataroot/$courseid/moddata/book/$bookid");
}
function game_bookquiz_convert_ver2_computestyles( $data, &$styles, $isstyle) {
preg_match_all('#<style:style style:name="(.*?)"(.*?)>(.*?)</style:style>#es', $data, $style);
$stylenames = $style[ 1];
$styleinfos = $style[ 2];
$styledatas = $style[ 3];
for ($i = 0; $i < count( $stylenames); $i++) {
$name = $stylenames[ $i];
$change = false;
for (;;) {
$pos1 = strpos( $styledatas[ $i], 'style:parent-style-name');
$pos2 = strpos( $styledatas[ $i], '/>');
if (($pos1 === false) or ($pos2 === false)) {
break;
}
if ($pos1 > $pos2) {
break;
}
// Is a parent style.
$s = substr( $styledatas[ $i], 0, $pos2 + 2);
game_bookquiz_convertstyle_parent( $s, $styles);
$styledatas[ $i] = substr( $styledatas[ $i], $pos2 + 2);
$change = true;
}
if ($change) {
// Must to recompute name, styledatas, styleinfos.
preg_match_all('#<style:style style:name="(.*?)"(.*?)>(.*?)</style:style>#es', $data, $style);
$name = $style[ 1][ 0];
$styleinfos[ $i] = $style[ 2][ 0];
$styledatas[ $i] = $style[ 3][ 0];
}
$styles[ $name] = game_bookquiz_convertstyle( $styledatas[ $i], $styleinfos[ $i], $styles);
}
}
function game_bookquiz_convertstyle_parent( $data, &$styles) {
$styleitems = array();
preg_match_all( '#(.*?)style:name="(.*?)"(.*?)style:parent-style-name="(.*?)"(.*?)#es', $data, $infos);
$names = $infos[ 2];
$parents = $infos[ 4];
if (count( $parents)) {
if (array_key_exists( $parents[ 0], $styles)) {
// Is a child style. Must to copy the properties of the parent style.
$a = explode( ';', $styles[ $parents[ 0]]);
foreach ($a as $s) {
$pos = strpos( $s, ':');
$key = substr( $s, 0, $pos);
$item = substr( $s, $pos + 1);
if ($item == '') {
continue;
}
$styleitems[ $key] = $item;
}
}
$name = $names[ 0];
}
$style = '';
foreach ($styleitems as $key => $item) {
$style .= ';'.$key.':'.$item;
}
$styles[ $name] = substr( $style, 1);
}
function game_bookquiz_convertstyle( $data, $styleinfo, $styles) {
$styleitems = array();
preg_match_all( '#<style:paragraph-properties (.*?)/>#es', $data, $infos);
$lines = $infos[ 1];
if (count( $lines)) {
$line = $lines[ 0];
if ($line != '') {
game_bookquiz_convertstyle_paragraph( $line, $styleitems);
}
}
preg_match_all( '#<style:text-properties (.*?)/>#es', $data, $infos);
$lines = $infos[ 1];
if (count( $lines)) {
$line = $lines[ 0];
if ($line != '') {
game_bookquiz_convertstyle_textproperties( $line, $styleitems);
}
}
if (count( $styleitems) == 0) {
return '';
}
$style = '';
foreach ($styleitems as $key => $item) {
$style .= ';'.$key.':'.$item;
}
return substr( $style, 1);
}
function game_bookquiz_convertstyle_paragraph( $line, &$styleitems) {
preg_match_all( '#(.*?)=(.*?) #es', $line.' ', $datas);
$data1 = $datas[ 1];
$data2 = $datas[ 2];
$ret = '';
for ($i = 0; $i < count( $data1); $i++) {
$eq1 = $data1[ $i];
$eq2 = $data2[ $i];
if ((substr( $eq2, 0, 1) == '"') and (substr( $eq2, -1, 1) == '"')) {
$eq2 = substr( $eq2, 1, -1);
}
switch ($eq1) {
case 'fo:text-align':
$styleitems[ 'align'] = $eq2;
break;
case 'fo:background-color':
$styleitems[ 'background-color'] = $eq2;
break;
}
}
}
function game_bookquiz_convertstyle_textproperties( $line, &$styleitems) {
preg_match_all( '#(.*?)=(.*?) #es', $line.' ', $datas);
$data1 = $datas[ 1];
$data2 = $datas[ 2];
$ret = '';
for ($i = 0; $i < count( $data1); $i++) {
$eq1 = $data1[ $i];
$eq2 = $data2[ $i];
if ((substr( $eq2, 0, 1) == '"') and (substr( $eq2, -1, 1) == '"')) {
$eq2 = substr( $eq2, 1, -1);
}
switch( $eq1) {
case 'fo:font-size':
case 'fo:color':
case 'fo:background-color':
case 'fo:font-style':
case 'fo:font-weight':
$styleitems[ substr( $eq1, 3)] = $eq2;
break;
case 'style_text_underline_style':
if ($eq2 == 'solid') {
$styleitems[ 'text-decoration'] = 'underline';
}
break;
}
}
}

480
bookquiz/importppt.php

@ -1,480 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This is a very rough importer for powerpoint slides
* Export a powerpoint presentation with powerpoint as html pages
* Do it with office 2002 (I think?) and no special settings
* Then zip the directory with all of the html pages
* and the zip file is what you want to upload
*
* The script supports book and lesson.
*
* @version $Id: importppt.php,v 1.3 2012/07/25 11:16:05 bdaloukas Exp $
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
require_once("../../config.php");
require_once("locallib.php");
$id = required_param('id', PARAM_INT); // Course Module ID.
$pageid = optional_param('pageid', '', PARAM_INT); // Page ID.
global $matches;
if (! $cm = get_coursemodule_from_id('lesson', $id)) {
print_error('Course Module ID was incorrect');
}
if (! $course = $DB->get_record('course', array( 'id' => $cm->course))) {
print_error('Course is misconfigured');
}
// Allows for adaption for multiple modules.
if (!$modname = $DB->get_field('modules', 'name', array( 'id' => $cm->module))) {
print_error('Could not find module name');
}
if (! $mod = $DB->get_record($modname, array( "id" => $cm->instance))) {
print_error('Course module is incorrect');
}
require_login($course->id, false);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lesson:edit', $context);
$strimportppt = get_string("importppt", "lesson");
$strlessons = get_string("modulenameplural", "lesson");
echo $OUTPUT->heading("$strimportppt", " $strimportppt",
"<a href=\"index.php?id=$course->id\">$strlessons</a>".
" -> <a href=\"{$CFG->wwwroot}/mod/$modname/view.php?id=$cm->id\">".format_string($mod->name, true)."</a>-> $strimportppt");
if ($form = data_submitted()) { // Filename.
if (empty($_FILES['newfile'])) { // File was just uploaded.
notify(get_string("uploadproblem") );
}
if ((!is_uploaded_file($_FILES['newfile']['tmp_name']) or $_FILES['newfile']['size'] == 0)) {
notify(get_string("uploadnofilefound") );
} else {
// Valid file is found.
if ($rawpages = readdata($_FILES, $course->id, $modname)) {
// First try to reall all of the data in.
// parse all the html files into objects.
$pageobjects = extract_data($rawpages, $course->id, $mod->name, $modname);
clean_temp(); // All done with files so dump em.
$modcreateobjects = $modname.'_create_objects';
$modsaveobjects = $modname.'_save_objects';
// Function to preps the data to be sent to DB.
$objects = $modcreateobjects($pageobjects, $mod->id);
if (! $modsaveobjects($objects, $mod->id, $pageid)) {
// Sends it to DB.
print_error( 'could not save');
}
} else {
print_error('could not get data');
}
echo "<hr>";
print_continue("{$CFG->wwwroot}/mod/$modname/view.php?id=$cm->id");
echo $OUTPUT->footer($course);
exit;
}
}
// Print upload form.
print_heading_with_help($strimportppt, "importppt", "lesson");
echo $OUTPUT->box_start('center');
echo "<form id=\"theform\" enctype=\"multipart/form-data\" method=\"post\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
echo "<input type=\"hidden\" name=\"pageid\" value=\"$pageid\" />\n";
echo "<table cellpadding=\"5\">";
echo "<tr><td align=\"right\">";
print_string("upload");
echo ":</td><td>";
echo "<input name=\"newfile\" type=\"file\" size=\"50\" />";
echo "</td></tr><tr><td>&nbsp;</td><td>";
echo "<input type=\"submit\" name=\"save\" value=\"".get_string("uploadthisfile")."\" />";
echo "</td></tr>";
echo "</table>";
echo "</form>";
echo $OUTPUT->box_end();
echo $OUTPUT->footer($course);
// START OF FUNCTIONS.
/* this function expects a zip file to be uploaded. Then it parses
* outline.htm to determine the slide path. Then parses each
* slide to get data for the content
*/
function readdata($file, $courseid, $modname) {
global $CFG;
// Create an upload directory in temp.
make_upload_directory('temp/'.$modname);
$base = $CFG->dataroot."/temp/$modname/";
$zipfile = $_FILES["newfile"]["name"];
$tempzipfile = $_FILES["newfile"]["tmp_name"];
// Create our directory.
$pathparts = pathinfo($zipfile);
// Take off the extension.
$dirname = substr($zipfile, 0, strpos($zipfile, '.'.$pathparts['extension']));
if (!file_exists($base.$dirname)) {
mkdir($base.$dirname);
}
// Move our uploaded file to temp/lesson.
move_uploaded_file($tempzipfile, $base.$zipfile);
// Unzip it!
unzip_file($base.$zipfile, $base, false);
$base = $base.$dirname; // Update the base.
// This is the file where we get the names of the files for the slides (in the correct order too).
$outline = $base.'/outline.htm';
$pages = array();
if (file_exists($outline) and is_readable($outline)) {
$outlinecontents = file_get_contents($outline);
$filenames = array();
// This gets all of our files names.
preg_match_all("/javascript:GoToSld\('(.*)'\)/", $outlinecontents, $filenames);
// File $pages with the contents of all of the slides.
foreach ($filenames[1] as $file) {
$path = $base.'/'.$file;
if (is_readable($path)) {
$pages[$path] = file_get_contents($path);
} else {
return false;
}
}
} else {
// Cannot find the outline, so grab all files that start with slide.
$dh = opendir($base);
while (false !== ($file = readdir($dh))) { // Read throug the directory.
if ('slide' == substr($file, 0, 5)) {
// Check for name (may want to check extension later).
$path = $base.'/'.$file;
if (is_readable($path)) {
$pages[$path] = file_get_contents($path);
} else {
return false;
}
}
}
ksort($pages); // Order them by file name.
}
if (empty($pages)) {
return false;
}
return $pages;
}
/* This function attempts to extract the content out of the slides
* the slides are ugly broken xml. and the xml is broken... yeah...
*/
function extract_data($pages, $courseid, $lessonname, $modname) {
global $CFG;
global $matches;
$extratedpages = array();
// Directory for images.
make_mod_upload_directory($courseid); // Make sure moddata is made.
// We store our images in a subfolder in here.
make_upload_directory($courseid.'/moddata/'.$modname, false);
$imagedir = $CFG->dataroot.'/'.$courseid.'/moddata/'.$modname;
if ($CFG->slasharguments) {
$imagelink = $CFG->wwwroot.'/file.php/'.$courseid.'/moddata/'.$modname;
} else {
$imagelink = $CFG->wwwroot.'/file.php?file=/'.$courseid.'/moddata/'.$modname;
}
// Try to make a unique subfolder to store the images.
$lessonname = str_replace(' ', '_', $lessonname); // Get rid of spaces.
$i = 0;
while (true) {
if (!file_exists($imagedir.'/'.$lessonname.$i)) {
// Ok doesnt exist so make the directory and update our paths.
mkdir($imagedir.'/'.$lessonname.$i);
$imagedir = $imagedir.'/'.$lessonname.$i;
$imagelink = $imagelink.'/'.$lessonname.$i;
break;
}
$i++;
}
foreach ($pages as $file => $content) {
/* to make life easier on our preg_match_alls, we strip out all tags except
* for div and img (where our content is). We want div because sometimes we
* can identify the content in the div based on the div's class
*/
$tags = '<div><img>'; // Should also allow <b><i>.
$string = strip_tags($content, $tags);
$matches = array();
/* this will look for a non nested tag that is closed
* 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);
$pathparts = pathinfo($file);
// Get rid of the extension.
$file = substr($pathparts['basename'], 0, strpos($pathparts['basename'], '.'));
$imgs = array();
// This preg matches all images.
preg_match_all("/<img[^>]*(src\=\"(".$file."\_image[^>^\"]*)\"[^>]*)>/i", $string, $imgs);
// Start building our page.
$page = new stdClass;
$page->title = '';
$page->contents = array();
$page->images = array();
$page->source = $pathparts['basename']; // Need for book only.
/* This foreach keeps the style intact.
* Found it doesn't help much. But if you want back uncomment
* this foreach and uncomment the line with the comment imgstyle in it.
* Also need to comment out
* the $page->images[]... line in the next foreach
*/
foreach ($imgs[2] as $img) {
copy($pathparts['dirname'].'/'.$img, $imagedir.'/'.$img);
// Comment out this line if you are using the above foreach loop.
$page->images[] = "<img src=\"$imagelink/$img\" title=\"$img\" />";
}
for ($i = 0; $i < count($matches[1]); $i++) { // Go through all of our div matches.
$class = isolate_class($matches[1][$i]); // First step in isolating the class.
// Check for any static classes.
switch ($class) {
case 'T': // Class T is used for Titles.
$page->title = $matches[3][$i];
break;
// I would guess that all bullet lists would start with B then go to B1, B2, etc.
case 'B':
// B1-B4 are just insurance, should just hit B and all be taken care of.
case 'B1':
case 'B2':
case 'B3':
case 'B4':
// This is a recursive function that will grab all the bullets and rebuild the list in html.
$page->contents[] = build_list('<ul>', $i, 0);
break;
default:
if ($matches[3][$i] != '&#13;') { // Odd crap generated... sigh.
if (substr($matches[3][$i], 0, 1) == ':') {// Check for leading : ..hate MS .
$page->contents[] = substr($matches[3][$i], 1); // Get rid of :.
} else {
$page->contents[] = $matches[3][$i];
}
}
break;
}
}
// Add the page to the array.
$extratedpages[] = $page;
} // End $pages foreach loop.
return $extratedpages;
}
// A recursive function to build a html list.
function build_list($list, &$i, $depth) {
global $matches; // Not sure why I global this...
while ($i < count($matches[1])) {
$class = isolate_class($matches[1][$i]);
if (strstr($class, 'B')) { // Make sure we are still working with bullet classes.
if ($class == 'B') {
$thisdepth = 0; // Calling class B depth 0.
} else {
// Set the depth number. So B1 is depth 1 and B2 is depth 2 and so on.
$thisdepth = substr($class, 1);
if (!is_numeric($thisdepth)) {
print_error( 'Depth not parsed!');
}
if ($thisdepth < $depth) {
// We are moving back a level in the nesting.
break;
}
if ($thisdepth > $depth) {
// We are moving in a lvl in nesting.
$list .= '<ul>';
$list = build_list($list, $i, $thisdepth);
// Once we return back, should go to the start of the while.
continue;
}
// No depth changes, so add the match to our list.
if ($cleanstring = ppt_clean_text($matches[3][$i])) {
$list .= '<li>'.ppt_clean_text($matches[3][$i]).'</li>';
}
$i++;
} else {
// Not a B class, so get out of here...
break;
}
}
// End the list and return it.
$list .= '</ul>';
return $list;
}
// Given an html tag, this function will.
function isolate_class($string) {
if ($class = strstr($string, 'class=')) {
// First step in isolating the class.
// This gets rid of <div blawblaw class= there are no "" or '' around the clas name ...sigh...
$class = substr($class, strpos($class, '=') + 1);
if (strstr($class, ' ')) {
// Spaces found, so cut off everything off after the first space.
return substr($class, 0, strpos($class, ' '));
} else {
// No spaces so nothing else in the div tag, cut off the >.
return substr($class, 0, strpos($class, '>'));
}
} else {
// No class defined in the tag.
return '';
}
}
// This function strips off the random chars that ppt puts infront of bullet lists.
function ppt_clean_text($string) {
$chop = 1; // Default: just a single char infront of the content.
// Look for any other crazy things that may be infront of the content.
if (strstr($string, '&lt;') and strpos($string, '&lt;') == 0) {
// Look for the &lt; in the sting and make sure it is in the front.
$chop = 4; // Increase the $chop.
}
// May need to add more later....
$string = substr($string, $chop);
if ($string != '&#13;') {
return $string;
} else {
return false;
}
}
// Clean up the temp directory.
function clean_temp() {
global $CFG;
/* this function is broken, use it to clean up later
* should only clean up what we made as well because someone else could be importing ppt as well
* delDirContents($CFG->dataroot.'/temp/lesson');
*/
}
// Creates objects an chapter object that is to be inserted into the database.
function book_create_objects($pageobjects, $bookid) {
$chapters = array();
$chapter = new stdClass;
// Same for all chapters.
$chapter->bookid = $bookid;
$chapter->pagenum = $DB->count_records('book_chapters', array( 'bookid' => $bookid)) + 1;
$chapter->timecreated = time();
$chapter->timemodified = time();
$chapter->subchapter = 0;
$i = 1;
foreach ($pageobjects as $pageobject) {
$page = prep_page($pageobject, $i); // Get title and contents.
$chapter->importsrc = addslashes($pageobject->source); // Add the source.
$chapter->title = $page->title;
$chapter->content = $page->contents;
$chapters[] = $chapter;
// Increment our page number and our counter.
$chapter->pagenum = $chapter->pagenum + 1;
$i++;
}
return $chapters;
}
// Builds the title and content strings from an object.
function prep_page($pageobject, $count) {
if ($pageobject->title == '') {
$page->title = "Page $count"; // No title set so make a generic one.
} else {
$page->title = addslashes($pageobject->title);
}
$page->contents = '';
// Nab all the images first.
foreach ($pageobject->images as $image) {
$image = str_replace("\n", '', $image);
$image = str_replace("\r", '', $image);
$image = str_replace("'", '"', $image); // Imgstyle.
$page->contents .= addslashes($image);
}
// Go through the contents array and put <p> tags around each element and strip out \n which I have found to be uneccessary.
foreach ($pageobject->contents as $content) {
$content = str_replace("\n", '', $content);
$content = str_replace("\r", '', $content);
$content = str_replace('&#13;', '', $content); // Puts in returns?
$content = '<p>'.$content.'</p>';
$page->contents .= addslashes($content);
}
return $page;
}
// Save the chapter objects to the database.
function book_save_objects($chapters, $bookid, $pageid='0') {
global $DB;
// Nothing fancy, just save them all in order.
foreach ($chapters as $chapter) {
if (!$chapter->id = $DB->insert_record('book_chapters', $chapter)) {
print_error('Could not update your book');
}
}
return true;
}

15
classes/event/course_module_instance_list_viewed.php

@ -36,18 +36,5 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
/** // No code required here as the parent class handles it all.
* Create the event from course record.
*
* @param \stdClass $course
* @return course_module_instance_list_viewed
*/
public static function create_from_course(\stdClass $course) {
$params = array(
'context' => \context_course::instance($course->id)
);
$event = \mod_game\event\course_module_instance_list_viewed::create( $params);
$event->add_record_snapshot('course', $course);
return $event;
}
} }

10
lib.php

@ -539,7 +539,9 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course
$groupjoin = ""; $groupjoin = "";
} }
if (!$attempts = $DB->get_records_sql("SELECT qa.*, qa.gameid, q.grade, u.lastname,u.firstname, firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.lastnamephonetic, u.picture if (!$attempts = $DB->get_records_sql("SELECT qa.*, qa.gameid, q.grade, u.lastname,".
" u.firstname, firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename,".
" u.lastnamephonetic, u.picture
FROM {game_attempts} qa FROM {game_attempts} qa
JOIN {game} q ON q.id = qa.gameid JOIN {game} q ON q.id = qa.gameid
JOIN {user} u ON u.id = qa.userid JOIN {user} u ON u.id = qa.userid
@ -604,7 +606,7 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course
$tmpactivity->user->alternatename = $attempt->alternatename; $tmpactivity->user->alternatename = $attempt->alternatename;
$tmpactivity->user->middlename = $attempt->middlename; $tmpactivity->user->middlename = $attempt->middlename;
$tmpactivity->user->firstnamephonetic = $attempt->firstnamephonetic; $tmpactivity->user->firstnamephonetic = $attempt->firstnamephonetic;
$tmpactivity->user->lastnamephonetic = $attempt->lastnamephonetic; $tmpactivity->user->lastnamephonetic = $attempt->lastnamephonetic;
$tmpactivity->user->picture = $attempt->picture; $tmpactivity->user->picture = $attempt->picture;
$tmpactivity->user->imagealt = $attempt->imagealt; $tmpactivity->user->imagealt = $attempt->imagealt;
$tmpactivity->user->email = $attempt->email; $tmpactivity->user->email = $attempt->email;
@ -619,7 +621,6 @@ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames
echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">'; echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
echo "<tr><td class=\"userpicture\" valign=\"top\">"; echo "<tr><td class=\"userpicture\" valign=\"top\">";
//print_user_picture($activity->user->userid, $courseid, $activity->user->picture);
echo $OUTPUT->user_picture($activity->user, array('courseid' => $courseid)); echo $OUTPUT->user_picture($activity->user, array('courseid' => $courseid));
echo "</td><td>"; echo "</td><td>";
@ -636,7 +637,8 @@ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames
echo get_string("attempt", "game")." {$activity->content->attempt}: "; echo get_string("attempt", "game")." {$activity->content->attempt}: ";
$grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})"; $grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})";
echo "<a href=\"{$CFG->wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}&q={$activity->gameid}\">$grades</a>"; echo "<a href=\"{$CFG->wwwroot}/mod/game/review.php".
"?attempt={$activity->content->attemptid}&q={$activity->gameid}\">$grades</a>";
echo '</div>'; echo '</div>';
echo '<div class="user">'; echo '<div class="user">';

25
locallib.php

@ -1489,7 +1489,7 @@ function game_grade_responses( $question, $responses, $maxgrade, &$answertext, &
return $answer->fraction * $maxgrade; return $answer->fraction * $maxgrade;
} else { } else {
$name = "resp{$question->id}_"; $name = "resp{$question->id}_";
if( !isset( $responses->$name)) { if (!isset( $responses->$name)) {
$answered = false; $answered = false;
return 0; // Not answered this question. return 0; // Not answered this question.
} }
@ -1818,14 +1818,27 @@ function game_get_string_lang( $identifier, $module, $lang) {
$langfile = "{$CFG->dirroot}/mod/game/lang/$lang/game.php"; $langfile = "{$CFG->dirroot}/mod/game/lang/$lang/game.php";
if ($result = get_string_from_file( $identifier, $langfile, "\$ret")) { $result = get_string_from_file( $identifier, $langfile, "\$ret");
eval($result); if ($result != '') {
if ($ret != '') { $pos = strpos( $result, '=');
return $ret; if ($pos > 0) {
$result = substr( $result, $pos + 1);
$pos = strpos( $result, "'");
if ($pos > 0) {
$result = substr( $result, $pos + 1);
$pos = strpos( $result, "'");
if ($pos > 0) {
$result = substr( $result, 0, $pos);
}
}
} }
} }
return get_string( $identifier, $module); if ($result != '') {
return $result;
} else {
return get_string( $identifier, $module);
}
} }
function get_string_from_file($identifier, $langfile, $destination) { function get_string_from_file($identifier, $langfile, $destination) {

2
millionaire/play.php

@ -172,7 +172,7 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aanswer,
$styletext = "style='$stylequestion'"; $styletext = "style='$stylequestion'";
} }
$aval = array( 100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000); $aval = array( 100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000);
for ($i = 15; $i >= 1; $i--) { for ($i = 15; $i >= 1; $i--) {
$btr = false; $btr = false;

2
pagelib.php

@ -21,8 +21,6 @@ define('PAGE_GAME_VIEW', 'mod-game-view');
page_map_class( PAGE_GAME_VIEW, 'page_game'); page_map_class( PAGE_GAME_VIEW, 'page_game');
$DEFINEDPAGES = array( PAGE_GAME_VIEW);
/** /**
* Class that models the behavior of a game * Class that models the behavior of a game
* *

1
showanswers.php

@ -307,7 +307,6 @@ function game_showanswers_question_select( $game, $table, $select, $fields, $ord
foreach ($recs as $rec) { foreach ($recs as $rec) {
if ($i++ > 0) { if ($i++ > 0) {
echo '<br>'; echo '<br>';
if ($rec->fraction == 1) { if ($rec->fraction == 1) {
echo " <b>$rec->answer</b>"; echo " <b>$rec->answer</b>";
if ($rec->feedback == '') { if ($rec->feedback == '') {

2
showattempts.php

@ -73,7 +73,7 @@ function game_showusers($game) {
function onselectuser() function onselectuser()
{ {
var groupid = document.getElementById('menugroup').value; var groupid = document.getElementById('menugroup').value;
window.location.href = "<?php echo $href;?>" + document.getElementById('menuuser').value + '&groupid=' + groupid; window.location.href = "<?php echo $href;?>" + document.getElementById('menuuser').value + '&groupid='+groupid;
} }
</script> </script>
<?php <?php

4
snakes/play.php

@ -294,7 +294,7 @@ function game_snakes_showquestion_glossary( $id, $snakes, $query, $game) {
} }
function game_snakes_check_questions( $id, $game, $attempt, $snakes, $context) { function game_snakes_check_questions( $id, $game, $attempt, $snakes, $context) {
global $QTYPES, $CFG, $DB; global $CFG, $DB;
$responses = data_submitted(); $responses = data_submitted();
@ -330,7 +330,7 @@ function game_snakes_check_questions( $id, $game, $attempt, $snakes, $context) {
} }
function game_snakes_check_glossary( $id, $game, $attempt, $snakes, $context) { function game_snakes_check_glossary( $id, $game, $attempt, $snakes, $context) {
global $QTYPES, $CFG, $DB; global $CFG, $DB;
$responses = data_submitted(); $responses = data_submitted();

8
sudoku/sdd/class.SDD.php

@ -88,7 +88,7 @@ class sdd {
* this object. By default, logging is off. * this object. By default, logging is off.
*/ */
public function sdd($thehtmlflag = null, $theloggingflag = false) { public function init($thehtmlflag = null, $theloggingflag = false) {
if ($thehtmlflag === null) { if ($thehtmlflag === null) {
$thehtmlflag = (!empty($_SERVER['DOCUMENT_ROOT'])); $thehtmlflag = (!empty($_SERVER['DOCUMENT_ROOT']));
} }
@ -160,7 +160,7 @@ class sdd {
$thestring = ssd::dArray($thevalue, $thehtmlflag, $theindent . " "); $thestring = ssd::dArray($thevalue, $thehtmlflag, $theindent . " ");
$theoutput[$theindex] = substr($thestring, 0, strlen($thestring) - 1); $theoutput[$theindex] = substr($thestring, 0, strlen($thestring) - 1);
} else if (is_object($thevalue)) { } else if (is_object($thevalue)) {
$theoutput[$theindex] = sdd::dobject($thevalue, $thehtmlflag); $theoutput[$theindex] = $this->dobject($thevalue, $thehtmlflag);
} else { } else {
$theoutput[$theindex] = ($thehtmlflag ? preg_replace('|<|s', '&lt;', $theoutput[$theindex] = ($thehtmlflag ? preg_replace('|<|s', '&lt;',
var_export($thevalue, true)) : var_export($thevalue, true)); var_export($thevalue, true)) : var_export($thevalue, true));
@ -244,9 +244,9 @@ class sdd {
foreach ($theclassvars[$theclass] as $thevariable => $value) { foreach ($theclassvars[$theclass] as $thevariable => $value) {
if (array_key_exists($thevariable, $theobjectvars)) { if (array_key_exists($thevariable, $theobjectvars)) {
if (is_array($theobjectvars[$thevariable])) { if (is_array($theobjectvars[$thevariable])) {
$theoutput[$theclass][] = $thevariable . " = " . sdd::darray($theobjectvars[$thevariable], $thehtmlflag); $theoutput[$theclass][] = $thevariable . " = " .$this->darray($theobjectvars[$thevariable], $thehtmlflag);
} else if (is_object($theobjectvars[$thevariable])) { } else if (is_object($theobjectvars[$thevariable])) {
$theoutput[$theclass][] = $thevariable . " = " . sdd::dobject($theobjectvars[$thevariable], $thehtmlflag); $theoutput[$theclass][] = $thevariable . " = ".$this->dobject($theobjectvars[$thevariable], $thehtmlflag);
} else { } else {
$theotput[$theclass][] = $thevariable . " = " . $theotput[$theclass][] = $thevariable . " = " .
($thehtmlflag ? preg_replace('|<|s', '&lt;', var_export( ($thehtmlflag ? preg_replace('|<|s', '&lt;', var_export(

2
sudoku/sdd/class.logfile.php

@ -47,7 +47,7 @@ class logfile extends SDD {
* @access public * @access public
*/ */
public function logfile($thefilename) { public function init($thefilename) {
if (file_exists($thefilename)) { if (file_exists($thefilename)) {
$this->m_handle = fopen($thefilename, 'a'); $this->m_handle = fopen($thefilename, 'a');
} else { } else {

Loading…
Cancel
Save