Example #1
0
function select_media(&$out, &$lang)
{
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.multimedia.php';
    $form = new Form();
    $from = importVar("from");
    $item_id = (int) importVar("item_id");
    $src = "";
    $title = "";
    $path = "";
    switch ($from) {
        case "cms":
            if (!canAccessCmsMedia()) {
                die("You can't access!");
            }
            $path = _FPATH_INTERNAL;
            $relative_path = _FPATH;
            $preview_path = _PPATH;
            $qtxt = "SELECT t1.fname, t1.real_fname, t1.media_url, t2.title FROM " . $GLOBALS["prefix_cms"] . "_media as t1 ";
            $qtxt .= "LEFT JOIN " . $GLOBALS["prefix_cms"] . "_media_info as t2 ON (t2.idm=t1.idMedia) ";
            $qtxt .= "WHERE t1.idMedia='" . $item_id . "' AND t1.publish='1'";
            $q = sql_query($qtxt);
            if ($q && mysql_num_rows($q) > 0) {
                $row = mysql_fetch_array($q);
                $src = $row["real_fname"];
                $title = $row["title"];
                if (!empty($row["media_url"])) {
                    $src = $row["media_url"];
                } else {
                    $src = $row["real_fname"];
                }
            }
            break;
        case "personal":
            if (!canAccessPersonalMedia()) {
                die("You can't access!");
            }
            $user_id = Docebo::user()->getIdSt();
            $path = _USER_FPATH_INTERNAL;
            $relative_path = _USER_FPATH;
            $preview_path = _USER_FPATH;
            $qtxt = "SELECT real_fname, media_url FROM " . $GLOBALS["prefix_fw"] . "_user_file ";
            $qtxt .= "WHERE id='" . $item_id . "' AND user_idst='" . $user_id . "' AND type='image'";
            $q = sql_query($qtxt);
            if ($q && mysql_num_rows($q) > 0) {
                $row = mysql_fetch_array($q);
                if (!empty($row["media_url"])) {
                    $src = $row["media_url"];
                } else {
                    $src = $row["real_fname"];
                }
            }
            break;
    }
    //	$src=rawurlencode($src);
    $res = "";
    $url = getPopupBaseUrl() . "&op=main";
    if (!empty($row["media_url"])) {
        $media_url = $row["media_url"];
        $popup_file_path = $media_url;
    } else {
        $popup_file_path = $path . $src;
    }
    addMediaPopupJS($popup_file_path);
    // TODO: remove inline style
    if (file_exists($preview_path . $src)) {
        $style = "width: 100px; padding: 2px; border: 1px solid #AAAAAA; margin-bottom: 0.4em;";
        $res .= "<img style=\"" . $style . "\" src=\"" . $preview_path . $src . "\" alt=\"" . $title . "\" title=\"" . $title . "\" />\n";
    } else {
        $media_type = getMediaType($src);
        $style = "width: 64px; padding: 2px; border: 1px solid #AAAAAA; margin-bottom: 0.4em;";
        $res .= "<img style=\"" . $style . "\" src=\"" . getPathImage('fw') . "media/" . $media_type . ".png\" alt=\"" . $title . "\" title=\"" . $title . "\" />\n";
    }
    $res .= $form->openForm("popup_form", $url, false, false, '', "onSubmit=\"insItem();\" onReset=\"closePopup();\"");
    $res .= $form->openElementSpace();
    $type = getPopupSelType();
    switch ($type) {
        case "image":
            $res .= $form->getTextfield($lang->def("_ALT_TXT"), "alt_text", "alt_text", 255, $title);
            $res .= $form->getTextfield($lang->def("_TITLE"), "title_text", "title_text", 255, $title);
            //$res.=$form->getTextfield($lang->def("_BORDER"), "border", "border", 3, "0");
            break;
        case "flash":
            $flash_info = getSwfInfoArray($relative_path . $src);
            $res .= $form->getTextfield($lang->def("_WIDTH"), "width", "width", 4, $flash_info["width"]);
            $res .= $form->getTextfield($lang->def("_HEIGHT"), "height", "height", 4, $flash_info["height"]);
            $res .= $form->getTextfield($lang->def("_BGCOLOR"), "bgcolor", "border", 7, "#FFF");
            break;
        case "audio":
        case "video":
        case "streaming":
            require_once _base_ . '/lib/lib.json.php';
            $json = new Services_JSON();
            if (!empty($media_url)) {
                $code = getStreamingEmbed($media_url, FALSE, $src);
            } else {
                $cut_from = strlen($GLOBALS["where_files_relative"]);
                $base_relative_path = $GLOBALS["base_where_files_relative"] . substr($relative_path, $cut_from);
                $current_pl = Get::cur_plat();
                $site_file_path = getPLSetting($current_pl, "url") . $base_relative_path;
                $code = getEmbedPlay($site_file_path, $src, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE);
            }
            $code = '<div>' . $code . '</div>';
            $core_url = getPLSetting("framework", "url");
            $bad_path = $GLOBALS["where_framework_relative"] . "/addons/players/";
            $good_path = $core_url . "addons/players/";
            $code = str_replace($bad_path, $good_path, $code);
            $content = array("code" => $code);
            $embed_code = $json->encode($content);
            $res .= $form->getHidden("embed_code", "embed_code", rawurlencode($embed_code));
            $res .= $src;
            break;
    }
    $res .= $form->closeElementSpace();
    $res .= $form->openButtonSpace();
    $res .= $form->getButton('apply', 'apply', $lang->def('_SAVE'));
    $res .= $form->getReset('undo', 'undo', $lang->def('_UNDO'));
    $res .= $form->closeButtonSpace();
    $res .= $form->closeForm();
    $out->add($res);
}
 function getViewUserFileDetail()
 {
     require_once _base_ . '/lib/lib.navbar.php';
     $viewer = $this->getViewer();
     $type = Get::req('type', DOTY_MIXED, '');
     $id_file = Get::req('id_file', DOTY_MIXED, '');
     $this->loadUserData($viewer);
     // main container ---------------------------------------------------------------------
     $html = '<h1>' . $this->_lang->def('_PROFILE') . ': ' . $this->resolveUsername() . '</h1>';
     $html .= '<div id="up_user_info" class="up_user_info">';
     $html .= $this->getUserRelatedAction($type);
     require_once $GLOBALS['where_framework'] . '/lib/lib.myfiles.php';
     $user_file = new MyFilesPolicy($this->_user_profile->getIdUser(), $this->getViewer(), $this->_up_data_man->isFriend($this->_user_profile->getIdUser(), $this->getViewer()), $this->_up_data_man->isTeacher($this->getViewer()));
     $file = $user_file->getFileInfo($id_file);
     if ($file == false) {
         $html .= $this->_lang->def('_THE_FILE_DOESNT_EXIST') . '</div>';
         return $html;
     }
     $html .= '<h2 class="up_type1">' . $file[MYFILE_TITLE] . '</h2>';
     if ($file[MYFILE_DESCRIPTION] != '') {
         $html .= '<div class="up_description">' . '<b>' . $this->_lang->def('_DESCRIPTION') . ': </b>' . $file[MYFILE_DESCRIPTION] . '</div>';
     }
     $id_thread = Get::req('idThread', DOTY_INT, 0);
     $html .= getBackUi($this->_url_man->getUrl('id_user='******'&' . $this->_varname_action . '=view_files&type=' . $type . '&idThread=' . $id_thread . ''), $this->_lang->def('_BACK'));
     $html .= '<div class="up_box_details">';
     $type = $file[MYFILE_AREA];
     switch ($type) {
         case "image":
             $html .= '<img src="' . $GLOBALS['where_files_relative'] . $user_file->getFileAddress($file[MYFILE_FILE_NAME]) . '" ' . 'title="' . strip_tags($file[MYFILE_DESCRIPTION]) . '" alt="' . strip_tags($file[MYFILE_TITLE]) . '" />';
             break;
         case "video":
             require_once _base_ . '/lib/lib.multimedia.php';
             $html .= getEmbedPlay($GLOBALS['where_files_relative'] . $user_file->getFilePath(), $file[MYFILE_FILE_NAME]);
             break;
         case "audio":
             require_once _base_ . '/lib/lib.multimedia.php';
             $html .= getEmbedPlay($GLOBALS['where_files_relative'] . $user_file->getFilePath(), $file[MYFILE_FILE_NAME]);
             break;
         case "other":
             require_once _base_ . '/lib/lib.multimedia.php';
             $html .= getEmbedPlay($user_file->getFilePath(), $file[MYFILE_FILE_NAME]);
             break;
     }
     $html .= '</div>';
     $id_thread = Get::req('idThread', DOTY_INT, 0);
     $html .= getBackUi($this->_url_man->getUrl('id_user='******'&' . $this->_varname_action . '=view_files&type=' . $type . '&idThread=' . $id_thread . ''), $this->_lang->def('_BACK'));
     $html .= '</div>';
     return $html;
 }
Example #3
0
function showdemo()
{
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.multimedia.php';
    $lang = DoceboLanguage::createInstance('course', 'lms');
    $id_course = importVar('id_course', true, 0);
    $man_course = new Man_Course();
    $course = $man_course->getCourseInfo($id_course);
    $back = importVar('back', false, '');
    if ($back == 'details') {
        $page_title = array('index.php?modname=coursecatalogue&amp;op=courselist' => $lang->def('_COURSE_LIST'), $lang->def('_SHOW_DEMO'));
    } else {
        $page_title = array('index.php?modname=coursecatalogue&amp;op=courselist' => $lang->def('_COURSE_LIST'), 'index.php?modname=coursecatalogue&amp;op=coursedetails&amp;id_course=' . $id_course => $course['name'], $lang->def('_SHOW_DEMO'));
    }
    $GLOBALS['page']->add(getTitleArea($page_title, 'course') . '<div class="std_block">' . '<div class="align_center">', 'content');
    $ext = end(explode('.', $course['course_demo']));
    $GLOBALS['page']->add(getEmbedPlay('/appLms/' . Get::sett('pathcourse'), $course['course_demo'], $ext, '450', '450', true, $lang->def('_SHOW_DEMO')), 'content');
    $GLOBALS['page']->add('</div>' . '<h2><span class="code_course">' . $course['code'] . ' - </span> ' . $course['name'] . '</h2>' . '<p>' . $course['description'] . '</p>' . '</div>', 'content');
}
     require_once _base_ . '/lib/lib.json.php';
     $json = new Services_JSON();
     $output = $json->encode($value);
     aout($output);
     break;
 case "play_demo":
     require_once $GLOBALS["where_lms"] . "/lib/lib.course.php";
     require_once _base_ . '/lib/lib.multimedia.php';
     $lang =& DoceboLanguage::createInstance('standard', 'framework');
     $lang->setGlobal();
     $lang =& DoceboLanguage::createInstance('course', 'lms');
     $id_course = importVar('id_course', true);
     $course_man = new DoceboCourse($id_course);
     $course_demo = $course_man->getValue('course_demo');
     $ext = end(explode('.', $course_demo));
     $value = array("next_op" => '', "id" => 'course_materials', "title" => $lang->def('_DEMO'), "content" => getEmbedPlay('/appLms/' . Get::sett('pathcourse'), $course_demo, $ext, '450', '450', false, false, '../../' . $GLOBALS['where_files_relative']));
     require_once _base_ . '/lib/lib.json.php';
     $json = new Services_JSON();
     $output = $json->encode($value);
     aout($output);
     break;
 default:
     $lang =& DoceboLanguage::createInstance('standard', 'framework');
     $lang->setGlobal();
     $lang =& DoceboLanguage::createInstance('catalogue', 'framework');
     $value = array("next_op" => 'prova', "id" => 'prova', "title" => 'creazione window', "content" => 'prova di creazione di una window');
     require_once _base_ . '/lib/lib.json.php';
     $json = new Services_JSON();
     $output = $json->encode($value);
     aout($output);
     break;