Adding jcapture plugin see #5101

1.9.x
Julio Montoya 12 years ago
parent 480f4be00f
commit 333a71ac05
  1. 40
      main/document/document.php
  2. 10
      plugin/jcapture/plugin.php
  3. 83
      plugin/jcapture/plugin_applet.php
  4. 63
      plugin/jcapture/upload.php

@ -66,27 +66,27 @@ $sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path.$course_dir;
$http_www = api_get_path(WEB_COURSE_PATH).$courseInfo['directory'].'/document';
$document_path = $base_work_dir;
//$plugin_jcapture = api_get_path(WEB_PLUGIN_PATH).'jcapture/lib/jcapture.jar';
//Removing sessions
unset($_SESSION['draw_dir']);
unset($_SESSION['paint_dir']);
unset($_SESSION['temp_audio_nanogong']);
/*
$htmlHeadXtra[] = '<script>
function startApplet() {
appletsource = "<applet code=\"com.hammurapi.jcapture.JCaptureApplet.class\" archive=\"'.$plugin_jcapture.'\">";
appletsource += "<param name=\"outputDir\" value=\"'.$base_work_dir.'\">";
appletsource += "</applet>";
document.getElementById("appletplace").innerHTML=appletsource;
// alert(appletsource);
}
$(function() {
$("#jcapture").click(function(){
startApplet();
$plugin = new AppPlugin();
$pluginList = $plugin->get_installed_plugins();
$capturePluginInstalled = in_array('jcapture', $pluginList);
if ($capturePluginInstalled) {
$jcapturePath = api_get_path(WEB_PLUGIN_PATH).'jcapture/plugin_applet.php';
$htmlHeadXtra[] = '<script>
$(function() {
function insertAtCarret() {
}
$("#jcapture").click(function(){
$("#appletplace").load("'.$jcapturePath.'");
});
});
});
</script>';*/
</script>';
}
// Create directory certificates
DocumentManager::create_directory_certificate_in_course(api_get_course_id());
@ -1359,7 +1359,6 @@ if (!isset($folders) || $folders === false) {
$folders = array();
}
//echo '<div id="appletplace"></div>';
$actions = '<div class="actions">';
if (!$is_certificate_mode) {
/* BUILD SEARCH FORM */
@ -1485,6 +1484,15 @@ if ($is_allowed_to_edit ||
/*echo '<a href="#" id="jcapture">';
echo Display::display_icon('capture.png', get_lang('CatchScreenCasts'), '', ICON_SIZE_MEDIUM).'</a>';*/
if ($capturePluginInstalled) {
$actions .= '<span id="appletplace"></span>';
$actions .= Display::url(
Display::return_icon('capture.png', get_lang('CatchScreenCasts'), '', ICON_SIZE_MEDIUM),
'#',
array('id' => 'jcapture')
);
}
// Create directory
if (!$is_certificate_mode) {
$actions .= Display::url(

@ -0,0 +1,10 @@
<?php
/**
* Screencast widget
*/
$plugin_info = array(
'title' => 'Jcapture Screencast',
'comment' => "Screencast widget",
'version' => '1.0',
'author' => 'Julio Montoya'
);

@ -0,0 +1,83 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../../main/inc/global.inc.php';
$plugin = new AppPlugin();
$pluginList = $plugin->get_installed_plugins();
$capturePluginInstalled = in_array('jcapture', $pluginList);
if (!$capturePluginInstalled) {
exit;
}
$capturePath = api_get_path(WEB_PLUGIN_PATH).'jcapture/';
$hostName = api_get_path(WEB_PATH);
define('DOKU_BASE', '/tmp');
function getSecurityToken() {};
//close sesseion
session_write_close();
header('Content-Type: text/html; charset=utf-8');
$imageFormat = "PNG";
$cookies = null;
foreach (array_keys($_COOKIE) as $cookieName) {
$cookies.=bin2hex($cookieName)."=".bin2hex($_COOKIE[$cookieName]).";";
}
$pageName = 'file';
$edid = '1';
?>
<script>
function insertAtCarret() {
location.reload();
}
</script>
<object type="application/x-java-applet">
<param name="ID" value="jCaptureApplet" />
<param name="scriptable" value="true" />
<param name="mayscript" value="true" />
<param name="JAVA_CODEBASE" value="/somenonexistingcodebase" />
<param name="WIDTH" value="1" />
<param name="HEIGHT" value="1" />
<param name="CODE" value="com.hammurapi.jcapture.JCaptureApplet.class" />
<param name="ARCHIVE" value="<?php echo $capturePath; ?>lib/jcapture.jar" />
<param name="NAME" value="jCapture" />
<param name="dokuBase" value="<?php echo bin2hex(DOKU_BASE); ?>" />
<param name="sectok" value="<?php echo getSecurityToken(); ?>" />
<param name="cookies" value="<?php echo $cookies; ?>" />
<param name="pageName" value="<?php echo $pageName; ?>" />
<param name="edid" value="<?php echo $edid; ?>" />
<param name="host" value="<?php echo $hostName; ?>" />
<param name="uploadUrl" value="<?php echo $capturePath.'upload.php'; ?>" />
<param name="scriptable" value="false" />
<param name="pluginspage" value="http://java.sun.com/products/plugin/index.html#download" />
<embed type="application/x-java-applet;jpi-version=1.7.0"
ID = "jCaptureApplet"
scriptable = "true"
mayscript = "true"
JAVA_CODEBASE = "/somenonexistingcodebase"
WIDTH = "1"
HEIGHT = "1"
CODE = "com.hammurapi.jcapture.JCaptureApplet.class"
ARCHIVE = "<?php echo $capturePath; ?>lib/jcapture.jar"
NAME = "jCapture"
dokuBase ="<?php echo bin2hex(DOKU_BASE); ?>"
sectok ="<?php echo getSecurityToken(); ?>"
cookies ="<?php echo $cookies; ?>"
pageName = "<?php echo $pageName; ?>"
edid = "<?php echo $edid; ?>"
host ="<?php echo $hostName; ?>"
uploadUrl = "<?php echo $capturePath.'upload.php'; ?>"
scriptable = "false"
pluginspage="http://java.sun.com/products/plugin/index.html#download">
</embed>
<?php echo get_lang('NoJava'); ?>
</object>

@ -0,0 +1,63 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
api_protect_course_script();
$plugin = new AppPlugin();
$pluginList = $plugin->get_installed_plugins();
$capturePluginInstalled = in_array('jcapture', $pluginList);
if (!$capturePluginInstalled) {
exit;
}
if (!isset($_FILES['Filedata'])) {
exit;
}
$courseInfo = api_get_course_info();
$folderName = 'captures';
$documentId = DocumentManager::get_document_id($courseInfo, '/'.$folderName);
$path = null;
if (empty($documentId)) {
$course_dir = $courseInfo['path'] . '/document';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$dir = $sys_course_path . $course_dir;
$createdDir = create_unexisting_directory(
$courseInfo,
api_get_user_id(),
api_get_session_id(),
null,
null,
$dir,
'/'.$folderName,
$folderName
);
if ($createdDir) {
$path = '/'.$folderName;
}
} else {
$data = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
$path = $data['path'];
}
if (empty($path)) {
exit;
}
$files = array(
'file' => $_FILES['Filedata']
);
DocumentManager::upload_document(
$files,
$path,
$_FILES['Filedata']['name'],
null,
false,
'rename',
false,
true
);
Loading…
Cancel
Save