* Get needed objects
 */
$neededObjAr = array(AMA_TYPE_VISITOR => array('layout', 'course'), AMA_TYPE_STUDENT => array('layout', 'tutor', 'course', 'course_instance'), AMA_TYPE_TUTOR => array('layout', 'course', 'course_instance'), AMA_TYPE_AUTHOR => array('layout', 'course'));
/**
 * Performs basic controls before entering this module
 */
$trackPageToNavigationHistory = false;
require_once ROOT_DIR . '/include/module_init.inc.php';
//$self = 'index';
include_once '../include/browsing_functions.inc.php';
/**
 * YOUR CODE HERE
 */
include_once CORE_LIBRARY_PATH . '/includes.inc.php';
/**
 * extract the author id from the passed media_url
 */
$regExp = preg_quote(HTTP_ROOT_DIR . MEDIA_PATH_DEFAULT, '/') . '(\\d+)\\/.*';
preg_match('/' . $regExp . '/', $_GET['media_url'], $matches);
// mathces[1] will hold the author id
if (!is_null($matches) && !empty($matches) && isset($matches[1]) && is_numeric($matches[1])) {
    $mediaObj = new MediaViewer(HTTP_ROOT_DIR . MEDIA_PATH_DEFAULT . $matches[1] . '/', array(), array(_VIDEO => VIDEO_PLAYING_MODE));
    /**
     * only videos gets the openInRightPanel onclick function call
     * so I assume it's a video that we are going to render
     */
    $retVal = $mediaObj->getViewer(array('type' => _VIDEO, 'value' => basename($matches[0]), 'width' => isset($_GET['width']) && intval($_GET['width']) > 0 ? intval($_GET['width']) : null, 'height' => isset($_GET['height']) && intval($_GET['height']) > 0 ? intval($_GET['height']) : null));
} else {
    $retVal = translateFN('La url passata non è valida');
}
die($retVal);
Exemple #2
0
 public function getLinkToMedia()
 {
     $media_dataAr = array(0 => null, 1 => $this->_type, 2 => $this->getDisplayFilename(), 3 => $this->_fileName, 4 => $this->pathToMedia(), 5 => $this->title);
     if (file_exists(ROOT_DIR . $this->_pathToOwnerDir . $this->_fileName)) {
         $this->_pathToFile = $this->_pathToOwnerDir . $this->_fileName;
         $mediaViewer = new MediaViewer(HTTP_ROOT_DIR . $this->_pathToOwnerDir, array(), array());
     } else {
         $this->_pathToFile = $this->_pathToOwnerCourseDir . $this->_fileName;
         $mediaViewer = new MediaViewer(HTTP_ROOT_DIR . $this->_pathToOwnerCourseDir, array(), array());
     }
     return $mediaViewer->getMediaLink($media_dataAr);
 }