} } */ // Interbreadcrumb for the current directory root path if (empty($document_data['parents'])) { $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); } else { foreach ($document_data['parents'] as $document_sub_data) { $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']); } } Display::display_header($nameTools, 'Doc'); echo '<div class="actions">'; echo '<a href="document.php?id=' . $document_id . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '</div>'; if (api_browser_support('svg')) { //automatic loading the course language $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); $langsvgedit = api_get_language_isocode(); $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; $langsvgedit = file_exists(api_get_path(LIBRARY_PATH) . 'svg-edit/locale/lang.' . $langsvgedit . '.js') ? $langsvgedit : 'en'; $svg_url = api_get_path(WEB_LIBRARY_PATH) . 'svg-edit/svg-editor.php?lang=' . $langsvgedit; ?> <script> document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?> " width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'); function resizeIframe() { var height = window.innerHeight -50; //max lower size
/** * Set header parameters */ private function set_header_parameters() { global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $noPHP_SELF, $_configuration, $this_section; $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as & $thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('online.png')); $this->assign('offline_button',Display::return_icon('offline.png')); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('Institution'); $title_list[] = api_get_setting('siteName'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $this->set_css_files(); $this->set_js_files(); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-'.$this_section); $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep.'favicon.ico')) { $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->set_help(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang( 'ReportABug' ).'"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); //Preparing values for the menu //Logout link if (isset($_configuration['hide_logout_button']) && $_configuration['hide_logout_button'] == 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id()); } //Profile link if (api_get_setting('allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH).'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH).'messages/inbox.php'; $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('Institution'); $portal_name = empty($institution) ? api_get_setting('siteName') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); //Setting notifications $count_unread_message = 0; if (api_get_setting('allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id( api_get_user_id() ); $group_pending_invitations = GroupPortalManager::get_groups_by_user( api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false ); $group_pending_invitations = 0; if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval( $count_unread_message ); } $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : null); $this->assign('user_notifications', $total_invitations); //Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); //if ($this->show_header == 1) { header('Content-Type: text/html; charset='.api_get_system_encoding()); header( 'X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'], 0, 1) ); //} }
/** * Display survey question chart * @param array Chart data * @param boolean Tells if the chart has a serie. False by default * @return void (direct output) */ public static function drawChart($chartData, $hasSerie = false, $chartContainerId = 'chartContainer') { $htmlChart = ''; if (api_browser_support("svg")) { $htmlChart .= api_get_js("js/d3/d3.v3.5.4.min.js"); $htmlChart .= api_get_js("js/dimple.v2.1.2.min.js") . ' <script type="text/javascript"> var svg = dimple.newSvg("#' . $chartContainerId . '", "100%", 400); var data = ['; $serie = array(); $order = array(); foreach ($chartData as $chartDataElement) { $htmlChart .= '{"'; if (!$hasSerie) { $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['option'] . '", "'; array_push($order, $chartDataElement['option']); } else { if (!is_array($chartDataElement['serie'])) { $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['serie'] . '", "' . get_lang("Score") . '":"' . $chartDataElement['option'] . '", "'; array_push($serie, $chartDataElement['serie']); } else { $htmlChart .= get_lang("Serie") . '":"' . $chartDataElement['serie'][0] . '", "' . get_lang("Option") . '":"' . $chartDataElement['serie'][1] . '", "' . get_lang("Score") . '":"' . $chartDataElement['option'] . '", "'; } } $htmlChart .= get_lang("Votes") . '":"' . $chartDataElement['votes'] . '"},'; } rtrim($htmlChart, ","); $htmlChart .= ']; var myChart = new dimple.chart(svg, data); myChart.addMeasureAxis("y", "' . get_lang("Votes") . '");'; if (!$hasSerie) { $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "' . get_lang("Option") . '"); xAxisCategory.addOrderRule(' . json_encode($order) . '); myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);'; } else { if (!is_array($chartDataElement['serie'])) { $serie = array_values(array_unique($serie)); $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]); xAxisCategory.addOrderRule(' . json_encode($serie) . '); xAxisCategory.addGroupOrderRule("' . get_lang("Score") . '"); myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);'; } else { $htmlChart .= 'myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]); myChart.addSeries("' . get_lang("Serie") . '", dimple.plot.bar);'; } } $htmlChart .= 'myChart.draw(); </script>'; } return $htmlChart; }
/** * Checks whether a document can be previewed by using the browser. * @param string $file_extension The filename extension of the document (it must be in lower case). * @return bool Returns TRUE or FALSE. */ public static function is_browser_viewable($file_extension) { static $allowed_extensions = array('htm', 'html', 'xhtml', 'gif', 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'pdf', 'svg', 'swf', 'txt', 'log', 'mp4', 'ogg', 'ogv', 'ogx', 'mpg', 'mpeg', 'mov', 'avi', 'webm', 'wmv', 'mp3', 'oga', 'wav', 'au', 'wma', 'mid', 'kar'); /* //TODO: make a admin swich to strict mode 1. global default $allowed_extensions only: 'htm', 'html', 'xhtml', 'gif', 'jpg', 'jpeg', 'png', 'bmp', 'txt', 'log' if (in_array($file_extension, $allowed_extensions)) { // Assignment + a logical check. return true; } 2. check native support 3. check plugins: quicktime, mediaplayer, vlc, acrobat, flash, java */ if (!($result = in_array($file_extension, $allowed_extensions))) { // Assignment + a logical check. return false; } //check native support (Explorer, Opera, Firefox, Chrome, Safari) if ($file_extension == "pdf") { return api_browser_support('pdf'); } elseif ($file_extension == "mp3") { return api_browser_support('mp3'); } elseif ($file_extension == "mp4") { return api_browser_support('mp4'); } elseif ($file_extension == "ogg" || $file_extension == "ogx" || $file_extension == "ogv" || $file_extension == "oga") { return api_browser_support('ogg'); } elseif ($file_extension == "svg") { return api_browser_support('svg'); } elseif ($file_extension == "mpg" || $file_extension == "mpeg") { return api_browser_support('mpg'); } elseif ($file_extension == "mov") { return api_browser_support('mov'); } elseif ($file_extension == "wav") { return api_browser_support('wav'); } elseif ($file_extension == "mid" || $file_extension == "kar") { return api_browser_support('mid'); } elseif ($file_extension == "avi") { return api_browser_support('avi'); } elseif ($file_extension == "wma") { return api_browser_support('wma'); } elseif ($file_extension == "wmv") { return api_browser_support('wmv'); } elseif ($file_extension == "tif" || $file_extension == "tiff") { return api_browser_support('tif'); } elseif ($file_extension == "mov") { return api_browser_support('mov'); } elseif ($file_extension == "au") { return api_browser_support('au'); } elseif ($file_extension == "webm") { return api_browser_support('webm'); } return $result; }
$defaults['renameTo'] = $file_name; $defaults['comment'] = $document_data['comment']; $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null; $form->setDefaults($defaults); show_return($parent_id, $dir_original, $call_from_tool, $slide_id, $is_certificate_mode); if ($is_certificate_mode) { $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id()); $str_info = ''; foreach ($all_information_by_create_certificate[0] as $info_value) { $str_info .= $info_value . '<br/>'; } $create_certificate = get_lang('CreateCertificateWithTags'); Display::display_normal_message($create_certificate . ': <br /><br />' . $str_info, false); } if ($extension == 'svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') { Display::display_warning_message(get_lang('BrowserDontSupportsSVG')); } echo $form->return_form(); } Display::display_footer(); /* General functions */ /* Workhorse functions These do the actual work that is expected from of this tool, other functions are only there to support these ones. */ /** This function changes the name of a certain file. It needs no global variables, it takes all info from parameters.
/** * Set header parameters * @param bool $sendHeaders send headers */ private function set_header_parameters($sendHeaders) { global $httpHeadXtra, $interbreadcrumb, $language_file, $_configuration, $this_section; $_course = api_get_course_info(); $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as &$thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM)); $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('platform.institution'); $title_list[] = api_get_setting('platform.site_name'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $css = $this->setCssFiles(); $this->set_js_files(); $this->setCssCustomFiles($css); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="' . $host . '">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-' . $this_section); //Defaul root chamilo favicon $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />'; //Added to verify if in the current Chamilo Theme exist a favicon $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/'; //If exist pick the current chamilo theme favicon if (is_file($favicoThemeUrl . 'favicon.ico')) { $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />'; } if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url'])); $clean_url = api_replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH) . 'home/' . $clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_APP_PATH) . 'home/' . $clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep . 'favicon.ico')) { $favico = '<link rel="shortcut icon" href="' . $homep . 'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->setHelp(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="' . api_get_path(WEB_IMG_PATH) . 'bug.large.png" style="vertical-align: middle;" alt="' . get_lang('ReportABug') . '" title="' . get_lang('ReportABug') . '"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); $resize = ''; if (api_get_setting('accessibility_font_resize') == 'true') { $resize .= '<div class="resize_font">'; $resize .= '<div class="btn-group">'; $resize .= '<a title="' . get_lang('DecreaseFontSize') . '" href="#" class="decrease_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '<a title="' . get_lang('ResetFontSize') . '" href="#" class="reset_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '<a title="' . get_lang('IncreaseFontSize') . '" href="#" class="increase_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '</div>'; $resize .= '</div>'; } $this->assign('accessibility', $resize); // Preparing values for the menu // Logout link $hideLogout = api_get_setting('hide_logout_button'); if ($hideLogout === 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH) . 'index.php?logout=logout&uid=' . api_get_user_id()); } //Profile link if (api_get_setting('social.allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH) . 'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('message.allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH) . 'messages/inbox.php'; $message_link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'messages/inbox.php">' . get_lang('Inbox') . '</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('platform.institution'); $portal_name = empty($institution) ? api_get_setting('platform.site_name') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); // Setting notifications $count_unread_message = 0; if (api_get_setting('message.allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('social.allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); $usergroup = new UserGroup(); $group_pending_invitations = $usergroup->get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false); if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } else { $group_pending_invitations = 0; } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message); } $total_invitations = !empty($total_invitations) ? Display::badge($total_invitations) : null; $this->assign('user_notifications', $total_invitations); // Block Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); if ($sendHeaders) { header('Content-Type: text/html; charset=' . api_get_system_encoding()); header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1)); } $socialMeta = ''; $metaTitle = api_get_setting('meta_title'); if (!empty($metaTitle)) { $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n"; $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n"; $metaDescription = api_get_setting('meta_description'); if (!empty($metaDescription)) { $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n"; } $metaSite = api_get_setting('meta_twitter_site'); if (!empty($metaSite)) { $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; $metaCreator = api_get_setting('meta_twitter_creator'); if (!empty($metaCreator)) { $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; } } $metaImage = api_get_setting('meta_image_path'); if (!empty($metaImage)) { if (is_file(api_get_path(SYS_PATH) . $metaImage)) { $path = api_get_path(WEB_PATH) . $metaImage; $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; } } } $this->assign('social_meta', $socialMeta); }
/** * DEPRECATED - use rl_get_resource_link() instead - DEPRECATED * Displays the link that opens a new browser window that views the added resource. * * @author Patrick Cool <*****@*****.**>, Ghent University * @param $type the type of the tool * @param $id the id of the resource * @param $style this is used to style the link (for instance when a resource is hidden => the added resources should also be styled like they are hidden) * @todo use the constants for the type definitions. */ function display_addedresource_link($type, $id, $style = '') { global $_course; $course_id = api_get_course_int_id(); // Styling the link of the added resource. if ($style != '') { $styling = ' class="' . $style . '"'; } switch ($type) { case 'Agenda': $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $result = Database::query("SELECT * FROM {$TABLEAGENDA} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"' . $styling . '>' . $myrow['title'] . "</a><br />\n"; break; case 'Ad_Valvas': $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $result = Database::query("SELECT * FROM {$tbl_announcement} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"' . $styling . '>' . $myrow['title'] . "</a><br />\n"; break; case 'Link': $TABLETOOLLINK = Database::get_course_table(TABLE_LINK); $result = Database::query("SELECT * FROM {$TABLETOOLLINK} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id=' . $myrow['id'] . '&link_url=' . urlencode($myrow['url']) . "','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"" . $styling . '>' . $myrow['title'] . "</a><br />\n"; break; case 'Exercise': $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $result = Database::query("SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercise_submit.php?exerciseId=' . $myrow['id'] . '"' . $styling . '>' . $myrow['title'] . "</a><br />\n"; break; case 'Forum': $TBL_FORUMS = Database::get_course_table(TABLE_FORUM); $result = Database::query("SELECT * FROM {$TBL_FORUMS} WHERE c_id = {$course_id} AND forum_id={$id}"); $myrow = Database::fetch_array($result); echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewforum.php?forum=' . $myrow['forum_id'] . '&md5=' . $myrow['md5'] . '"' . $styling . '>' . $myrow['forum_name'] . "</a><br />\n"; break; case 'Thread': //=topics //@deprecated bb_posts, bb_posts_text, bb_forums /* $tbl_posts = $_course['dbNameGlu'].'bb_posts'; $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text'; $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums'; $result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id"); $myrow = Database::fetch_array($result); // grabbing the title of the post $sql_title = "SELECT * FROM $tbl_posts_text WHERE c_id = $course_id AND post_id=".$myrow["post_id"]; $result_title = Database::query($sql_title); $myrow_title = Database::fetch_array($result_title); echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$myrow['topic_id'].'&forum='.$myrow['forum_id'].'&md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n"; */ break; case 'Post': $tbl_post = Database::get_course_table(TABLE_FORUM_POST); $sql = "SELECT * FROM {$tbl_post} p WHERE c_id = {$course_id} AND post_id = {$id}"; $result = Database::query($sql); $post = Database::fetch_object($result); echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic=' . $post->topic_id . '&forum=' . $post->forum_id . '"' . $styling . '>' . $post->post_title . "</a><br />\n"; break; case 'Document': $dbTable = Database::get_course_table(TABLE_DOCUMENT); $result = Database::query("SELECT * FROM {$dbTable} WHERE c_id = {$course_id} AND id={$id}"); $myrow = Database::fetch_array($result); $pathname = explode('/', $myrow['path']); // Making a correct name for the link. $last = count($pathname) - 1; // Making a correct name for the link. $filename = $pathname[$last]; // Making a correct name for the link. $image = choose_image($filename); $ext = explode('.', $filename); $ext = strtolower($ext[sizeof($ext) - 1]); $myrow['path'] = rawurlencode($myrow['path']); $array_ext = array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'); if (api_browser_support('svg')) { $array_ext[] = 'svg'; } if (api_browser_support('ogg')) { $array_ext[] = 'ogg'; } $in_frames = in_array($ext, $array_ext); echo '<img src="../img/' . $image . '" align="middle" /> <a href="../document/' . ($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=') . $myrow['path'] . '"' . $styling . '>' . $filename . "</a><br />\n"; break; case 'Externallink': echo '<img src="../img/links.gif" align="middle" /> <a href="' . $id . '"' . $styling . '>' . $id . "</a><br />\n"; break; } }
/** * Returns the HTML form to upload a nano file or upload a file * @param string * @return string */ public function return_form($message = null) { $params = $this->get_params(true); $url = api_get_path(WEB_AJAX_PATH) . 'nanogong.ajax.php?a=save_file&' . $params; //check browser support and load form $array_browser = api_browser_support('check_browser'); $preview_file = $this->show_audio_file(true, true); $preview_file = Display::div($preview_file, array('id' => 'preview', 'style' => 'text-align:center; padding-left: 25px;')); $html = '<center>'; //Use normal upload file $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'), '', ICON_SIZE_BIG); $html .= '<br />'; $html .= '<div id="nanogong_div">'; $html .= '<applet id="nanogong" archive="' . api_get_path(WEB_LIBRARY_PATH) . 'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="40" align="middle">'; //echo '<param name="ShowRecordButton" value="false" />'; // default true // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) $html .= '<param name="ShowSpeedButton" value="false" />'; // default true //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) $html .= '<param name="ShowTime" value="true" />'; // default false $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF //echo '<param name="StartTime" value="10.5" />'; //echo '<param name="EndTime" value="65" />'; $html .= '<param name="AudioFormat" value="ImaADPCM" />'; // ImaADPCM (more speed), Speex (more compression)|(default Speex) //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) //echo '<param name="MaxDuration" value="60" />'; //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") $html .= '</applet>'; $html .= '<br /><br /><br />'; $html .= '<form name="form_nanogong_advanced">'; $html .= '<input type="hidden" name="is_nano" value="1">'; $html .= '<a href="#" class="btn" onclick="send_voice()" />' . get_lang('SendRecord') . '</a>'; $html .= '</form></div>'; $html .= Display::url(get_lang('ProblemsRecordingUploadYourOwnAudioFile'), 'javascript:void(0)', array('onclick' => 'show_simple_upload_form();')); $html .= '<br /><br /><div id="no_nanogong_div">'; //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); $html .= '<form id="form_nanogong_simple" class="form-search" action="' . $url . '" name="form_nanogong" method="POST" enctype="multipart/form-data">'; $html .= '<input type="file" name="file">'; $html .= '<a href="#" class="btn" onclick="upload_file()" />' . get_lang('UploadFile') . '</a>'; $html .= '</form>'; $html .= '</div>'; $html .= '</center>'; $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; $html .= '<div id="messages">' . $message . '</div>'; $html .= $preview_file; return $html; }
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,jpeg,png,bmp,tif,psd,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,ogg,ogx,ogv,oga, aif,aiff,wav,mp3,swf,flv, mp4, aac, ppt,rtf,doc, pdf,xls,txt,flv,odt,ods,odp,odg,odc,odf,odb,odi,pps,docx,pptx,xlsx,accdb,xml,mid, midi, svg, svgz, mm'); //Updated for Chamilo //define viewable valid exts $viewable = 'gif,bmp,txt,jpg,jpeg,png,tif,html,htm,mp3,wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf,mid,midi'; //updated by Chamilo $viewable_array = explode(" ", $viewable); if (api_browser_support('svg')) { $viewable_array[] = ',svg'; } if (api_browser_support('ogg')) { $viewable_array[] = ',ogg'; $viewable_array[] = ',ogx'; $viewable_array[] = ',oga'; $viewable_array[] = ',ogv'; } if (api_browser_support('pdf')) { $viewable_array[] = ',pdf'; } $viewable = implode(" ", $viewable_array); $viewable = preg_replace('/\\s+/', '', $viewable); //clean spaces //print_r($viewable); define("CONFIG_VIEWABLE_VALID_EXTS", $viewable); //define invalid exts define('CONFIG_UPLOAD_INVALID_EXTS', 'php,php3,php4,php5,php6,phps,phtml,asp,aspx,jsp,cfm,cfc,pl,jar,sh,cgi,js,exe,com,bat,pif,scr,msi,ws,wsc,wsf,vb,vbe,vbs,reg,dll,ini'); //Updated for Chamilo. //Preview define('CONFIG_IMG_THUMBNAIL_MAX_X', 100); define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100); define('CONFIG_THICKBOX_MAX_WIDTH', 400); //only for html, pdf, svg