Exemplo n.º 1
0
function filter_poodll_callback(array $link)
{
    global $CFG, $COURSE, $USER;
    $lm = new \filter_poodll\licensemanager();
    if (!$lm->validate_registrationkey($CFG->filter_poodll_registrationkey)) {
        return $lm->fetch_unregistered_content();
    }
    //get our filter props
    //we use a function in the poodll poodllresourcelib, because
    //parsing will also need to be done by the html editor
    $filterprops = \filter_poodll\poodlltools::fetch_filter_properties($link[0]);
    //if we have no props, quit
    if (empty($filterprops)) {
        return "";
    }
    //if we want to ignore the filter (for "how to use a filter" demos) we let it go
    //to use this, make the last parameter of the filter passthrough=1
    if (!empty($filterprops['passthrough'])) {
        return str_replace(",passthrough=1", "", $link[0]);
    }
    //Init our return variable
    $returnHtml = "";
    //Runtime JS or Flash
    if (empty($filterprops['runtime'])) {
        $filterprops['runtime'] = 'auto';
    }
    //depending on the type of filter
    switch ($filterprops['type']) {
        case 'adminconsole':
            $returnHtml = \filter_poodll\poodlltools::fetch_poodllconsole($filterprops['runtime']);
            break;
        case 'audio':
            $returnHtml = \filter_poodll\poodlltools::fetchSimpleAudioPlayer($filterprops['runtime'], $filterprops['path'], !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'rtmp', !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_audiowidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_audioheight, !empty($filterprops['embed']) ? $filterprops['embed'] == 'true' : false, !empty($filterprops['embedstring']) ? $filterprops['embedstring'] : 'Play', false, !empty($filterprops['usepoodlldata']) ? $filterprops['usepoodlldata'] == 'true' : false, !empty($filterprops['splashurl']) ? $filterprops['splashurl'] : '');
            break;
        case 'audiolist':
            $returnHtml = \filter_poodll\poodlltools::fetchAudioListPlayer($filterprops['runtime'], $filterprops['path'], !empty($filterprops['filearea']) ? $filterprops['filearea'] : 'content', !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'rtmp', !empty($filterprops['width']) ? $filterprops['width'] : 400, !empty($filterprops['height']) ? $filterprops['height'] : 250, !empty($filterprops['sequentialplay']) ? $filterprops['sequentialplay'] : 'true', !empty($filterprops['player']) ? $filterprops['player'] : $CFG->filter_poodll_defaultplayer, !empty($filterprops['showplaylist']) ? $filterprops['showplaylist'] == 'true' : true, !empty($filterprops['usepoodlldata']) ? $filterprops['usepoodlldata'] == 'true' : false);
            break;
        case 'audiorecorder':
            $returnHtml = \filter_poodll\poodlltools::fetchSimpleAudioRecorder($filterprops['runtime'], !empty($filterprops['savefolder']) ? $filterprops['savefolder'] : '');
            break;
        case 'audiotest':
            $returnHtml = \filter_poodll\poodlltools::fetchAudioTestPlayer($filterprops['runtime'], $filterprops['path'], !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'rtmp', !empty($filterprops['width']) ? $filterprops['width'] : 400, !empty($filterprops['height']) ? $filterprops['height'] : 50, !empty($filterprops['filearea']) ? $filterprops['filearea'] : 'content', !empty($filterprops['usepoodlldata']) ? $filterprops['usepoodlldata'] == 'true' : false);
            break;
        case 'bigvideogallery':
            $returnHtml = \filter_poodll\poodlltools::fetchBigVideoGallery($filterprops['runtime'], $filterprops['path'], !empty($filterprops['filearea']) ? $filterprops['filearea'] : 'content', !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'http', !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_biggallwidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_biggallheight, !empty($filterprops['usepoodlldata']) ? $filterprops['usepoodlldata'] == 'true' : false);
            break;
        case 'calculator':
            $returnHtml = \filter_poodll\poodlltools::fetch_poodllcalc($filterprops['runtime'], !empty($filterprops['width']) ? $filterprops['width'] : 300, !empty($filterprops['height']) ? $filterprops['height'] : 400, !empty($filterprops['size']) ? $filterprops['size'] : 'normal');
            break;
        case 'countdown':
            $returnHtml = \filter_poodll\poodlltools::fetch_countdowntimer($filterprops['runtime'], $filterprops['initseconds'], !empty($filterprops['usepresets']) ? $filterprops['usepresets'] : 'false', !empty($filterprops['width']) ? $filterprops['width'] : 400, !empty($filterprops['height']) ? $filterprops['height'] : 300, !empty($filterprops['fontheight']) ? $filterprops['fontheight'] : 64, !empty($filterprops['mode']) ? $filterprops['mode'] : 'normal', !empty($filterprops['permitfullscreen']) ? $filterprops['permitfullscreen'] : false, !empty($filterprops['uniquename']) ? $filterprops['uniquename'] : 'auniquename');
            break;
        case 'counter':
            $returnHtml = \filter_poodll\poodlltools::fetch_counter($filterprops['runtime'], !empty($filterprops['initcount']) ? $filterprops['initcount'] : 0, !empty($filterprops['usepresets']) ? $filterprops['usepresets'] : 'false', !empty($filterprops['width']) ? $filterprops['width'] : 480, !empty($filterprops['height']) ? $filterprops['height'] : 265, !empty($filterprops['fontheight']) ? $filterprops['fontheight'] : 64, !empty($filterprops['permitfullscreen']) ? $filterprops['permitfullscreen'] : false);
            break;
        case 'dice':
            $returnHtml = \filter_poodll\poodlltools::fetch_dice($filterprops['runtime'], !empty($filterprops['dicecount']) ? $filterprops['dicecount'] : 1, !empty($filterprops['dicesize']) ? $filterprops['dicesize'] : 200, !empty($filterprops['width']) ? $filterprops['width'] : 600, !empty($filterprops['height']) ? $filterprops['height'] : 300);
            break;
        case 'flashcards':
            $returnHtml = \filter_poodll\poodlltools::fetch_flashcards($filterprops['runtime'], !empty($filterprops['cardset']) ? $filterprops['cardset'] : -1, !empty($filterprops['qname']) ? $filterprops['qname'] : "", !empty($filterprops['frontcolor']) ? $filterprops['frontcolor'] : "0xDDDDDD", !empty($filterprops['backcolor']) ? $filterprops['backcolor'] : "0x000000", !empty($filterprops['cardwidth']) ? $filterprops['cardwidth'] : 300, !empty($filterprops['cardheight']) ? $filterprops['cardheight'] : 150, !empty($filterprops['randomize']) ? $filterprops['randomize'] : 'yes', !empty($filterprops['width']) ? $filterprops['width'] : 400, !empty($filterprops['height']) ? $filterprops['height'] : 300);
            break;
        case 'miniplayer':
            $returnHtml = \filter_poodll\poodlltools::fetch_miniplayer($filterprops['runtime'], $filterprops['url'], !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'http', !empty($filterprops['imageurl']) ? $filterprops['imageurl'] : '', !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_miniplayerwidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_miniplayerwidth, !empty($filterprops['iframe']) ? $filterprops['iframe'] == 'true' : false);
            break;
        case 'onceplayer':
            $returnHtml = \filter_poodll\poodlltools::fetch_onceplayer($filterprops['runtime'], $filterprops['url'], !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'http', !empty($filterprops['width']) ? $filterprops['width'] : 0, !empty($filterprops['height']) ? $filterprops['height'] : 0, !empty($filterprops['iframe']) ? $filterprops['iframe'] == 'true' : false);
            break;
        case 'newpoodllpairwork':
            $returnHtml = \filter_poodll\poodlltools::fetch_embeddablepairclient($filterprops['runtime'], !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_newpairwidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_newpairheight, !empty($filterprops['chat']) ? $filterprops['chat'] : true, !empty($filterprops['whiteboard']) ? $filterprops['whiteboard'] : false, !empty($filterprops['showvideo']) ? $filterprops['showvideo'] : false, !empty($filterprops['whiteboardback']) ? $filterprops['whiteboardback'] : '');
            break;
        case 'stopwatch':
            $returnHtml = \filter_poodll\poodlltools::fetch_stopwatch($filterprops['runtime'], !empty($filterprops['width']) ? $filterprops['width'] : 400, !empty($filterprops['height']) ? $filterprops['height'] : 265, !empty($filterprops['fontheight']) ? $filterprops['fontheight'] : 64, !empty($filterprops['mode']) ? $filterprops['mode'] : 'normal', !empty($filterprops['permitfullscreen']) ? $filterprops['permitfullscreen'] : false, !empty($filterprops['uniquename']) ? $filterprops['uniquename'] : 'auniquename');
            break;
        case 'smallvideogallery':
            $returnHtml = \filter_poodll\poodlltools::fetchSmallVideoGallery($filterprops['runtime'], $filterprops['path'], !empty($filterprops['filearea']) ? $filterprops['filearea'] : 'content', !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'http', !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_smallgallwidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_smallgallheight, !empty($filterprops['permitfullscreen']) ? $filterprops['permitfullscreen'] : false, !empty($filterprops['usepoodlldata']) ? $filterprops['usepoodlldata'] == 'true' : false);
            break;
        case 'poodllpalette':
            $returnHtml = \filter_poodll\poodlltools::fetch_poodllpalette($filterprops['runtime'], $filterprops['width'], $filterprops['height'], "swf");
            break;
        case 'wordplayer':
            $returnHtml = \filter_poodll\poodlltools::fetch_wordplayer($filterprops['runtime'], $filterprops['url'], $filterprops['word'], !empty($filterprops['fontsize']) ? $filterprops['fontsize'] : $CFG->filter_poodll_wordplayerfontsize, !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'http', !empty($filterprops['width']) ? $filterprops['width'] : "0", !empty($filterprops['height']) ? $filterprops['height'] : "0", !empty($filterprops['iframe']) ? $filterprops['iframe'] == 'true' : false);
            break;
        case 'whiteboard':
            $returnHtml = \filter_poodll\poodlltools::fetch_whiteboard($filterprops['runtime'], !empty($filterprops['boardname']) ? $filterprops['boardname'] : "whiteboard", !empty($filterprops['backimage']) ? $filterprops['backimage'] : "", !empty($filterprops['slave']) && $filterprops['slave'] == 'true' ? $filterprops['slave'] : false, !empty($filterprops['rooms']) ? $filterprops['rooms'] : "", !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_whiteboardwidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_whiteboardheight, !empty($filterprops['mode']) ? $filterprops['mode'] : 'normal', !empty($filterprops['standalone']) && $filterprops['standalone'] == 'true' ? $filterprops['standalone'] : 'false');
            break;
        case 'poodllpairwork':
            $courseid = $COURSE->id;
            $username = $USER->username;
            $poodllpairworkplayer = "";
            $studentalias = "";
            $pairmap = "";
            if ($pairmap = get_record("poodllpairwork_usermap", "username", $username, "course", $courseid)) {
                $studentalias = $pairmap->role;
            }
            //if we have a role and hence a session.
            if ($studentalias != "") {
                $me = get_record('user', 'username', $username);
                $partner = get_record('user', 'username', $pairmap->partnername);
                $partnerpic = \filter_poodll\poodlltools::fetch_user_picture($partner, 35);
                $mepic = \filter_poodll\poodlltools::fetch_user_picture($me, 35);
                $poodllpairworkplayer = "<h4>" . get_string("yourpartneris", "poodllpairwork") . fullname($partner) . "</h4>";
                $poodllpairworkplayer .= \filter_poodll\poodlltools::fetchPairworkPlayer($pairmap->username, $pairmap->partnername, $mepic, fullname($me), $partnerpic, fullname($partner));
            }
            $returnHtml = $poodllpairworkplayer;
            break;
        case 'quizlet':
            $returnHtml = fetch_quizlet($filterprops['id'], !empty($filterprops['title']) ? $filterprops['title'] : 'quizlet', !empty($filterprops['mode']) ? $filterprops['mode'] : 'familiarize', !empty($filterprops['width']) ? $filterprops['width'] : '100%', !empty($filterprops['height']) ? $filterprops['height'] : '310');
            break;
        case 'scrollerstart':
            $returnHtml = \filter_poodll\poodlltools::fetch_poodllscroller(true, !empty($filterprops['width']) ? $filterprops['width'] : '400', !empty($filterprops['height']) ? $filterprops['height'] : '200', !empty($filterprops['speed']) ? $filterprops['speed'] : '10', !empty($filterprops['repeat']) ? $filterprops['repeat'] : 'yes', !empty($filterprops['axis']) ? $filterprops['axis'] : 'y', !empty($filterprops['pixelshift']) ? $filterprops['pixelshift'] : '2');
            break;
        case 'scrollerstop':
            $returnHtml = \filter_poodll\poodlltools::fetch_poodllscroller(false);
            break;
        case 'snapshot':
            $returnHtml = \filter_poodll\poodlltools::fetchSnapshotCamera(!empty($filterprops['updatecontrol']) ? $filterprops['updatecontrol'] : 'filename', !empty($filterprops['filename']) ? $filterprops['filename'] : 'filename', !empty($filterprops['width']) ? $filterprops['width'] : '350', !empty($filterprops['height']) ? $filterprops['height'] : '400');
            break;
        case 'videorecorder':
            $returnHtml = \filter_poodll\poodlltools::fetchSimpleVideoRecorder($filterprops['runtime'], !empty($filterprops['savefolder']) ? $filterprops['savefolder'] : '');
            break;
        case 'video':
            //$returnHtml= fetchSimpleVideoPlayer($filterprops['path'],$filterprops['width'],$filterprops['height']);
            $returnHtml = \filter_poodll\poodlltools::fetchSimpleVideoPlayer($filterprops['runtime'], $filterprops['path'], !empty($filterprops['width']) ? $filterprops['width'] : $CFG->filter_poodll_videowidth, !empty($filterprops['height']) ? $filterprops['height'] : $CFG->filter_poodll_videoheight, !empty($filterprops['protocol']) ? $filterprops['protocol'] : 'rtmp', !empty($filterprops['embed']) ? $filterprops['embed'] == 'true' : false, !empty($filterprops['permitfullscreen']) ? $filterprops['permitfullscreen'] : false, !empty($filterprops['embedstring']) ? $filterprops['embedstring'] : 'Play', !empty($filterprops['splashurl']) ? $filterprops['splashurl'] : '');
            break;
        default:
    }
    //return our html
    return $returnHtml;
}