[svn r21481] Logic changes - Allow see glossary terms in document tool - (partial FS#4337)

skala
Isaac Flores 17 years ago
parent d18c4da1da
commit da9dcd1bf8
  1. 62
      main/document/document_with_glossary_terms.php
  2. 4
      main/document/headerpage.php
  3. 17
      main/document/showinframes.php
  4. 41
      main/glossary/glossary.class.php
  5. 21
      main/glossary/glossary_ajax_request.php

@ -0,0 +1,62 @@
<?php
$language_file[] = 'document';
require_once '../inc/global.inc.php';
require_once '../glossary/glossary.class.php';
/*
==============================================================================
Main section
==============================================================================
*/
$file = Security::remove_XSS(urldecode($_GET['file']));
$file=explode('?cidReq',$file);
$file=$file[0];
$file_root=$_course['path'].'/document'.str_replace('%2F', '/',$file);
$file_url_sys=api_get_path(SYS_COURSE_PATH).$file_root;
$file_url_web=api_get_path(WEB_COURSE_PATH).$file_root;
$content_html=file_get_contents($file_url_sys);
$array_glossary=GlossaryManager::get_glossary_terms();
if (count($array_glossary)>0) {
foreach ($array_glossary as $index_glossary => $value_glossary) {
$to_be_replaced[]=$str_href='<a name="link'.$value_glossary['id'].'" href="javascript:void(0)" >'.$value_glossary['name'].'</a>';
$to_replaced[]=$value_glossary['name'];
}
}
$new_file=str_replace($to_replaced,$to_be_replaced,$content_html);
$new_file=str_replace('<head>','<head><script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script><script type="text/javascript">
function display_notebook_info(notebook_id) {
data_notebook=notebook_id.split("link");
$("#gls"+data_notebook[1]).attr("style","display:inline;float:left;position:absolute;background-color: white;border-bottom: 1px dashed #dddddd;border-right: 1px dashed #dddddd;border-left: 1px dashed #dddddd;border-top: 1px dashed #dddddd;color:#305582;margin-left:5px;margin-right:5px;");
}
function hide_notebook_info(notebook_id) {
data_notebook=notebook_id.split("link");
$("#gls"+data_notebook[1]).attr("style","display:none");
}
$(document).ready(function() {
$("body a").toggle(function(){
$(this).append("<div id=\"div_show_id\" >&nbsp;</div>");
$("div#div_show_id").attr("style","display:inline;float:left;position:absolute;background-color:#F5F6CE;border-bottom: 1px dashed #dddddd;border-right: 1px dashed #dddddd;border-left: 1px dashed #dddddd;border-top: 1px dashed #dddddd;color:#305582;margin-left:5px;margin-right:5px;");
notebook_id=$(this).attr("name");
data_notebook=notebook_id.split("link");
my_glossary_id=data_notebook[1];
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
$("div#div_show_id").html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "../glossary/glossary_ajax_request.php",
data: "glossary_id="+my_glossary_id,
success: function(datos) {
$("div#div_show_id").html(datos);
}
});
},function(){
$("div#div_show_id").remove();
});
});
</script>',$new_file);
echo $new_file;
?>

@ -29,6 +29,8 @@ $interbreadcrumb[]= array ("url"=>"showinframes.php?file=".$header_file, "name"=
Display::display_header(null,"Doc");
echo "<div align=\"center\">";
echo "<a href='".api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$header_file."?".api_get_cidreq()."' target='blank'>".$lang_cut_paste_link."</a></div>";
$file_url_web='document_with_glossary_terms.php?file='.urlencode(Security::remove_XSS($_GET['file']));
$file_origin_url_web=api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$header_file."?".api_get_cidreq();
echo "<a href='".$file_url_web."' target='blank'>".$lang_cut_paste_link."</a></div>";
?>

@ -1,4 +1,4 @@
<?php // $Id: showinframes.php 21106 2009-05-30 16:25:16Z iflorespaz $
<?php // $Id: showinframes.php 21481 2009-06-18 04:47:18Z iflorespaz $
/*
==============================================================================
Dokeos - elearning and course management software
@ -54,7 +54,7 @@
*/
$language_file[] = 'document';
require_once '../inc/global.inc.php';
require_once '../glossary/glossary.class.php';
if (!empty($_GET['nopages']))
{
$nopages=Security::remove_XSS($_GET['nopages']);
@ -71,7 +71,6 @@ $_SESSION['whereami'] = 'document/view';
$interbreadcrumb[]= array ('url'=>'./document.php', 'name'=> get_lang('Documents'));
$nameTools = get_lang('Documents');
$file = Security::remove_XSS(urldecode($_GET['file']));
/*
==============================================================================
Main section
@ -92,15 +91,17 @@ if($is_courseAdmin)
{
$frameheight = 165;
}
$file_root=$_course['path'].'/document'.str_replace('%2F', '/',$file);
$file_url_sys=api_get_path('SYS_COURSE_PATH').$file_root;
$file_url_web=api_get_path('WEB_COURSE_PATH').$file_root;
$file_root=$_course['path'].'/document'.str_replace('%2F', '/',$file);
$file_url_sys=api_get_path(SYS_COURSE_PATH).$file_root;
$file_url_web=api_get_path(WEB_COURSE_PATH).$file_root;
$file_url_web='document_with_glossary_terms.php?file='.urlencode($_GET['file']);
?>
<html>
<head>
<title><?php echo $browser_display_title;?></title>
<title>
<?php echo $browser_display_title;?>
</title>
</head>
<frameset rows="<?php echo $frameheight; ?>,*" border="0" frameborder="no" >
<frame name="top" scrolling="no" noresize target="contents" src="headerpage.php?file=<?php echo $file.'&amp;'.api_get_cidreq(); ?>">

@ -0,0 +1,41 @@
<?php
class GlossaryManager {
function __construct() {
}
/**
* Get all glossary terms
* @author Isaac Flores <isaac.flores@dokeos.com>
* @return Array Contain glossary terms
*/
public static function get_glossary_terms () {
global $course;
$glossary_id=array();
$glossary_name=array();
$glossary_desc=array();
$glossary_table = Database::get_course_table(TABLE_GLOSSARY);
$sql='SELECT glossary_id as id,name,description FROM '.$glossary_table;
$rs=Database::query($sql,__FILE__,__LINE__);
while ($row=Database::fetch_array($rs)) {
$glossary_data[]=$row;
}
return $glossary_data;
}
/**
* Get glossary term by glossary id
* @author Isaac Flores <florespaz@bidsoftperu.com>
* @param Integer The glossay id
* @return String The glossary description
*/
public static function get_glossary_term_by_glossary_id ($glossary_id) {
global $course;
$glossary_table = Database::get_course_table(TABLE_GLOSSARY);
$sql='SELECT description FROM '.$glossary_table.' WHERE glossary_id="'.Database::escape_string($glossary_id).'"';
$rs=Database::query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($rs);
return $row['description'];
}
}
?>

@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
// including the global dokeos file
require_once '../inc/global.inc.php';
require_once '../glossary/glossary.class.php';
// notice for unauthorized people.
api_protect_course_script(true);
/*
* search a term and return description from a glossary
*/
$glossary_id=Security::remove_XSS($_POST['glossary_id']);
$glossary_description=GlossaryManager::get_glossary_term_by_glossary_id($glossary_id);
if (isset($_POST['glossary_id']) && $_POST['glossary_id']==strval(intval($_POST['glossary_id']))) {
echo api_xml_http_response_encode($glossary_description);
} else {
echo '';
}
Loading…
Cancel
Save