Actualización

This commit is contained in:
Xes
2025-04-10 12:49:05 +02:00
parent 4aff98e77b
commit 1cdd00920f
9151 changed files with 1800913 additions and 0 deletions

View File

@@ -0,0 +1,152 @@
<?php
/* Integrate svg-edit libraries with Chamilo default documents
* @author Juan Carlos Raña Trabado
* @since 25/september/2010
*/
require_once '../../../../../../inc/global.inc.php';
//Add security from Chamilo
api_protect_course_script();
api_block_anonymous_users();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$course_info = api_get_course_info();
$groupId = api_get_group_id();
$group_properties = GroupManager::get_group_properties($groupId);
$groupIid = 0;
if ($group_properties) {
$groupdirpath = $group_properties['directory'];
$groupIid = $group_properties['iid'];
}
$group_disk_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$groupdirpath.'/';
$group_web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$groupdirpath.'/';
//get all group files and folders
$docs_and_folders = DocumentManager::getAllDocumentData(
$course_info,
$groupdirpath,
$groupIid,
null,
$is_allowed_to_edit,
false
);
// get all group filenames
$array_to_search = !empty($docs_and_folders) ? $docs_and_folders : array();
if (count($array_to_search) > 0) {
while (list($key) = each($array_to_search)) {
$all_files[] = basename($array_to_search[$key]['path']);
}
}
//get all svg and png group files
$accepted_extensions = array('.svg', '.png');
if (is_array($all_files) && count($all_files) > 0) {
foreach ($all_files as & $file) {
$slideshow_extension = strrchr($file, '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$png_svg_files[] =$file;
}
}
}
$style = '<style>';
$style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";';
$style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";';
$style .='</style>';
?>
<!doctype html>
<?php echo api_get_jquery_js(); ?>
<?php echo $style ?>
<body>
<?php
echo '<h2>'.get_lang('GroupSingle').': '.$group_properties['name'].'</h2>';
if ((
$group_properties['doc_state'] == 2 &&
($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $group_properties))) || $group_properties['doc_state'] == 1
){
if (!empty($png_svg_files)) {
echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>';
echo '<ul>';
foreach($png_svg_files as $filename) {
$image = $group_disk_path.$filename;
if (strpos($filename, "svg")){
$new_sizes['width'] = 60;
$new_sizes['height'] = 60;
} else {
$new_sizes = api_resize_image($image, 60, 60);
}
echo '<li style="display:inline; padding:8px;">';
echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">';
echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
}
echo '</ul>';
}
} else {
echo Display::return_message(get_lang('OnlyAccessFromYourGroup'), 'warning');
}
?>
</body>
<script>
$('a').click(function() {
var href = this.href;
// Convert Non-SVG images to data URL first
// (this could also have been done server-side by the library)
if(this.href.indexOf('.svg') === -1) {
var meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
window.top.postMessage(meta_str, "*");
var img = new Image();
img.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
// load the raster image into the canvas
canvas.getContext("2d").drawImage(this,0,0);
// retrieve the data: URL
try {
var dataurl = canvas.toDataURL();
} catch(err) {
// This fails in Firefox with file:// URLs :(
alert("Data URL conversion failed: " + err);
var dataurl = "";
}
window.top.postMessage('|' + href + '|' + dataurl, "*");
}
img.src = href;
} else {
// Send metadata (also indicates file is about to be sent)
var meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
window.top.postMessage(meta_str, "*");
// Do ajax request for image's href value
$.get(href, function(data) {
data = '|' + href + '|' + data;
// This is where the magic happens!
window.top.postMessage(data, "*");
}, 'html'); // 'html' is necessary to keep returned data as a string
}
return false;
});
</script>

View File

@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
<h1>Select an image:</h1>
<a href="smiley.svg">smiley.svg</a>
<br>
<a href="../../images/logo.png">logo.png</a>
<script>
/*globals $*/
/*jslint vars: true*/
$('a').click(function() {'use strict';
var meta_str;
var href = this.href;
var target = window.parent;
// Convert Non-SVG images to data URL first
// (this could also have been done server-side by the library)
if (this.href.indexOf('.svg') === -1) {
meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
target.postMessage(meta_str, '*');
var img = new Image();
img.onload = function() {
var canvas = document.createElement('canvas');
canvas.width = this.width;
canvas.height = this.height;
// load the raster image into the canvas
canvas.getContext('2d').drawImage(this, 0, 0);
// retrieve the data: URL
var dataurl;
try {
dataurl = canvas.toDataURL();
} catch(err) {
// This fails in Firefox with file:// URLs :(
alert("Data URL conversion failed: " + err);
dataurl = "";
}
target.postMessage('|' + href + '|' + dataurl, '*');
};
img.src = href;
} else {
// Send metadata (also indicates file is about to be sent)
meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
target.postMessage(meta_str, '*');
// Do ajax request for image's href value
$.get(href, function(data) {
data = '|' + href + '|' + data;
// This is where the magic happens!
target.postMessage(data, '*');
}, 'html'); // 'html' is necessary to keep returned data as a string
}
return false;
});
</script>
</body>
</html>

View File

@@ -0,0 +1,136 @@
<?php
/* Integrate svg-edit libraries with Chamilo default documents
* @author Juan Carlos Raña Trabado
* @since 25/september/2010
*/
require_once '../../../../../../inc/global.inc.php';
//Add security from Chamilo
api_protect_course_script();
api_block_anonymous_users();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$curdirpath='/images/gallery'; //path of library directory
$course_info = api_get_course_info();
//get all files and folders
$docs_and_folders = DocumentManager::getAllDocumentData(
$course_info,
$curdirpath,
0,
null,
$is_allowed_to_edit,
false
);
//get all filenames
$array_to_search = !empty($docs_and_folders) ? $docs_and_folders : array();
if (count($array_to_search) > 0) {
while (list($key) = each($array_to_search)) {
$all_files[] = basename($array_to_search[$key]['path']);
}
}
//get all svg and png files
$accepted_extensions = array('.svg', '.png');
if (is_array($all_files) && count($all_files) > 0) {
foreach ($all_files as & $file) {
$slideshow_extension = strrchr($file, '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$png_svg_files[] =$file;
}
}
}
$disk_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images/gallery/';
$web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document/images/gallery/';
$style = '<style>';
$style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";';
$style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";';
$style .='</style>';
?>
<!doctype html>
<?php echo api_get_jquery_js(); ?>
<?php echo $style ?>
<body>
<?php
echo '<h2>'.get_lang('Course').': '.$course_info['name'].'</h2>';
if (!empty($png_svg_files)) {
echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>';
echo '<ul>';
foreach($png_svg_files as $filename) {
$image=$disk_path.$filename;
if (strpos($filename, "svg")){
$new_sizes['width'] = 60;
$new_sizes['height'] = 60;
}
else {
$new_sizes = api_resize_image($image, 60, 60);
}
echo '<li style="display:inline; padding:8px;"><a href="'.$web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
}
echo '</ul>';
} else {
echo Display::return_message(get_lang('NoSVGImagesInImagesGalleryPath'), 'warning');
}
?>
</body>
<script>
$('a').click(function() {
var href = this.href;
// Convert Non-SVG images to data URL first
// (this could also have been done server-side by the library)
if(this.href.indexOf('.svg') === -1) {
var meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
window.top.postMessage(meta_str, "*");
var img = new Image();
img.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
// load the raster image into the canvas
canvas.getContext("2d").drawImage(this,0,0);
// retrieve the data: URL
try {
var dataurl = canvas.toDataURL();
} catch(err) {
// This fails in Firefox with file:// URLs :(
alert("Data URL conversion failed: " + err);
var dataurl = "";
}
window.top.postMessage('|' + href + '|' + dataurl, "*");
}
img.src = href;
} else {
// Send metadata (also indicates file is about to be sent)
var meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
window.top.postMessage(meta_str, "*");
// Do ajax request for image's href value
$.get(href, function(data) {
data = '|' + href + '|' + data;
// This is where the magic happens!
window.top.postMessage(data, "*");
}, 'html'); // 'html' is necessary to keep returned data as a string
}
return false;
});
</script>

View File

@@ -0,0 +1,12 @@
<svg width="137" height="137" xmlns="http://www.w3.org/2000/svg">
<title>Cool smiley</title>
<path fill="url(#svg_4)" stroke="#000000" stroke-width="3" d="m32.18682,97.71674q36.3159,24.94076 72.54585,0m-64.67542,-49.25576c0,-3.8554 3.12526,-6.98079 6.98068,-6.98079c3.85449,0 6.97872,3.12539 6.97872,6.98079c0,3.85346 -3.12423,6.97867 -6.97872,6.97867c-3.85542,0 -6.98068,-3.12521 -6.98068,-6.97867m42.93047,0c0,-3.8554 3.12529,-6.98079 6.97963,-6.98079c3.8544,0 6.97971,3.12539 6.97971,6.98079c0,3.85346 -3.12531,6.97867 -6.97971,6.97867c-3.85434,0 -6.97963,-3.12521 -6.97963,-6.97867m-81.48596,20.036l0,0c0,-37.00197 29.99679,-66.99892 67.00095,-66.99892c37.00303,0 66.99998,29.99695 66.99998,66.99892c0,37.00409 -29.99695,67.00101 -66.99998,67.00101c-37.00416,0 -67.00095,-29.99692 -67.00095,-67.00101zm0,0l0,0c0,-37.00197 29.99679,-66.99892 67.00095,-66.99892c37.00303,0 66.99998,29.99695 66.99998,66.99892c0,37.00409 -29.99695,67.00101 -66.99998,67.00101c-37.00416,0 -67.00095,-29.99692 -67.00095,-67.00101z" id="svg_1"/>
<path id="svg_5" d="m23.84005,41.03445l17.57052,0l5.42937,-19.67914l5.42941,19.67914l17.5706,0l-14.21488,12.16242l5.42982,19.67939l-14.21495,-12.16281l-14.21489,12.16281l5.42991,-19.67939l-14.21491,-12.16242l0,0z" stroke-width="3" fill="#000000"/>
<path id="svg_6" d="m65.84005,41.03445l17.57052,0l5.42937,-19.67914l5.42941,19.67914l17.5706,0l-14.21487,12.16242l5.42982,19.67939l-14.21496,-12.1628l-14.2149,12.1628l5.42992,-19.67939l-14.21491,-12.16242l0,0z" stroke-width="3" fill="#000000"/>
<defs>
<linearGradient y2="0.25391" x2="0.46484" y1="0.94922" x1="0.44531" id="svg_4">
<stop stop-color="#ff0000" offset="0"/>
<stop stop-color="#ffff00" offset="1"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,119 @@
<?php
/* Integrate svg-edit libraries with Chamilo default documents
* @author Juan Carlos Raña Trabado
* @since 25/september/2010
*/
require_once '../../../../../../inc/global.inc.php';
//Add security from Chamilo
api_protect_course_script();
api_block_anonymous_users();
$userId = api_get_user_id();
$user_disk_path = UserManager::getUserPathById($userId, 'system').'my_files/';
$user_web_path = UserManager::getUserPathById($userId, 'web').'my_files/';
//get all files and folders
$scan_files = [];
if (is_dir($user_disk_path)) {
$scan_files = scandir($user_disk_path);
}
//get all svg and png files
$accepted_extensions = array('.svg', '.png');
if (is_array($scan_files) && count($scan_files) > 0) {
foreach ($scan_files as & $file) {
$slideshow_extension = strrchr($file, '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$png_svg_files[] =$file;
}
}
}
$style = '<style>';
$style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";';
$style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";';
$style .='</style>';
?>
<!doctype html>
<?php echo api_get_jquery_js(); ?>
<?php echo $style ?>
<body>
<?php
echo '<h2>'.get_lang('SocialNetwork').': '.get_lang('MyFiles').'</h2>';
if (!empty($png_svg_files)) {
echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>';
echo '<ul>';
foreach($png_svg_files as $filename) {
$image = $user_disk_path.$filename;
if (strpos($filename, "svg")){
$new_sizes['width'] = 60;
$new_sizes['height'] = 60;
} else {
$new_sizes = api_resize_image($image, 60, 60);
}
echo '<li style="display:inline; padding:8px;"><a href="'.$user_web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$user_web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>';
}
echo '</ul>';
} else {
echo Display::return_message(get_lang('NoSVGImages'), 'warning');
}
?>
</body>
<script>
$('a').click(function() {
var href = this.href;
// Convert Non-SVG images to data URL first
// (this could also have been done server-side by the library)
if(this.href.indexOf('.svg') === -1) {
var meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
window.top.postMessage(meta_str, "*");
var img = new Image();
img.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
// load the raster image into the canvas
canvas.getContext("2d").drawImage(this,0,0);
// retrieve the data: URL
try {
var dataurl = canvas.toDataURL();
} catch(err) {
// This fails in Firefox with file:// URLs :(
alert("Data URL conversion failed: " + err);
var dataurl = "";
}
window.top.postMessage('|' + href + '|' + dataurl, "*");
}
img.src = href;
} else {
// Send metadata (also indicates file is about to be sent)
var meta_str = JSON.stringify({
name: $(this).text(),
id: href
});
window.top.postMessage(meta_str, "*");
// Do ajax request for image's href value
$.get(href, function(data) {
data = '|' + href + '|' + data;
// This is where the magic happens!
window.top.postMessage(data, "*");
}, 'html'); // 'html' is necessary to keep returned data as a string
}
return false;
});
</script>