Ejemplo n.º 1
0
 function export()
 {
     global $game, $DB;
     $mform = $this->_form;
     $html->id = $this->_customdata['html']->id;
     $html->type = optional_param('type', 0, PARAM_ALPHANUM);
     $html->filename = $mform->getElementValue('filename');
     $html->title = $mform->getElementValue('title');
     $html->maxpicturewidth = optional_param('maxpicturewidth', 0, PARAM_INT);
     $html->maxpictureheight = optional_param('maxpictureheight', 0, PARAM_INT);
     if ($mform->elementExists('checkbutton')) {
         $checkbuttonvalue = $mform->getElementValue('checkbutton');
         $html->checkbutton = $checkbuttonvalue[0];
     }
     if ($mform->elementExists('printbutton')) {
         $printbuttonvalue = $mform->getElementValue('printbutton');
         $html->printbutton = $printbuttonvalue[0];
     }
     if (!$DB->update_record('game_export_html', $html)) {
         print_error("game_export_html: not updated id={$html->id}");
     }
     $cm = get_coursemodule_from_instance('game', $game->id, $game->course);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     require_once "exporthtml.php";
     game_OnExportHTML($game, $context, $html);
 }
function game_OnExport($gameid)
{
    $kind = $_POST['kind'];
    if ($kind == 'javame') {
        $javame->id = $_POST['id'];
        $javame->filename = $_POST['filename'];
        $javame->icon = $_POST['icon'];
        $javame->createdby = $_POST['createdby'];
        $javame->vendor = $_POST['vendor'];
        $javame->name = $_POST['name'];
        $javame->description = $_POST['description'];
        $javame->version = $_POST['version'];
        $javame->type = $_POST['type'];
        $javame->maxpicturewidth = $_POST['maxpicturewidth'];
        $javame->maxpictureheight = $_POST['maxpictureheight'];
        if (!update_record("game_export_javame", $javame)) {
            error("game_export_javame: not updated id={$javame->id}");
        }
        game_OnExportJavaME($gameid, $javame);
    } else {
        if ($kind == 'html') {
            $html->id = $_POST['id'];
            if (array_key_exists('type', $_POST)) {
                $html->type = $_POST['type'];
            } else {
                $html->type = '';
            }
            $html->filename = $_POST['filename'];
            $html->title = $_POST['title'];
            if (array_key_exists('maxpicturewidth', $_POST)) {
                $html->maxpicturewidth = $_POST['maxpicturewidth'];
            } else {
                $html->maxpicturewidth = 0;
            }
            if (array_key_exists('maxpictureheight', $_POST)) {
                $html->maxpictureheight = $_POST['maxpictureheight'];
            } else {
                $html->maxpictureheight = 0;
            }
            if (array_key_exists('checkbutton', $_POST)) {
                $html->checkbutton = $_POST['checkbutton'] ? 1 : 0;
            }
            if (array_key_exists('printbutton', $_POST)) {
                $html->printbutton = $_POST['printbutton'] ? 1 : 0;
            }
            if (!update_record("game_export_html", $html)) {
                error("game_export_html: not updated id={$html->id}");
            }
            $update = $_POST['update'];
            require_once "exporthtml.php";
            game_OnExportHTML($gameid, $html, $update);
        }
    }
}