parent
608f9a6b60
commit
7d82db2dca
@ -1,123 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
require_once dirname(__FILE__).'/../inc/global.inc.php'; |
||||
|
||||
//session |
||||
if(isset($_GET['id_session'])) |
||||
$_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']); |
||||
|
||||
// the variables for the days and the months |
||||
// Defining the shorts for the days |
||||
$DaysShort = api_get_week_days_short(); |
||||
// Defining the days of the week to allow translation of the days |
||||
$DaysLong = api_get_week_days_long(); |
||||
// Defining the months of the year to allow translation of the months |
||||
$MonthsLong = api_get_months_long(); |
||||
|
||||
$iso_lang = api_get_language_isocode($language_interface); |
||||
|
||||
header('Content-Type: text/html; charset='. api_get_system_encoding()); |
||||
|
||||
?> |
||||
<!DOCTYPE html |
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $iso_lang; ?>" lang="<?php echo $iso_lang; ?>">
|
||||
<head> |
||||
<title>Calendar</title> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>">
|
||||
<style type="text/css"> |
||||
/*<![CDATA[*/ |
||||
@import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/<?php echo api_get_setting('stylesheets'); ?>/default.css";
|
||||
.data_table th |
||||
{ |
||||
font-size: 10px; |
||||
} |
||||
.data_table td |
||||
{ |
||||
font-size: 10px; |
||||
width: 25px; |
||||
height: 25px; |
||||
} |
||||
table.calendar td |
||||
{ |
||||
|
||||
background-color: #f5f5f5; |
||||
text-align: center; |
||||
} |
||||
.data_table td.selected |
||||
{ |
||||
border: 1px solid #ff0000; |
||||
background-color: #FFCECE; |
||||
} |
||||
.data_table td a |
||||
{ |
||||
width: 25px; |
||||
height: 25px; |
||||
text-decoration: none; |
||||
} |
||||
.data_table td a:hover |
||||
{ |
||||
background-color: #ffff00; |
||||
} |
||||
</style> |
||||
<script type="text/javascript"> |
||||
/* <![CDATA[ */ |
||||
/* added 2004-06-10 by Michael Keck |
||||
* we need this for Backwards-Compatibility and resolving problems |
||||
* with non DOM browsers, which may have problems with css 2 (like NC 4) |
||||
*/ |
||||
var isDOM = (typeof(document.getElementsByTagName) != 'undefined' |
||||
&& typeof(document.createElement) != 'undefined') |
||||
? 1 : 0; |
||||
var isIE4 = (typeof(document.all) != 'undefined' |
||||
&& parseInt(navigator.appVersion) >= 4) |
||||
? 1 : 0; |
||||
var isNS4 = (typeof(document.layers) != 'undefined') |
||||
? 1 : 0; |
||||
var capable = (isDOM || isIE4 || isNS4) |
||||
? 1 : 0; |
||||
// Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant |
||||
if (capable) { |
||||
if (typeof(window.opera) != 'undefined') { |
||||
var browserName = ' ' + navigator.userAgent.toLowerCase(); |
||||
if ((browserName.indexOf('konqueror 7') == 0)) { |
||||
capable = 0; |
||||
} |
||||
} else if (typeof(navigator.userAgent) != 'undefined') { |
||||
var browserName = ' ' + navigator.userAgent.toLowerCase(); |
||||
if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) { |
||||
capable = 0; |
||||
} |
||||
} // end if... else if... |
||||
} // end if |
||||
/* ]]> */ |
||||
</script> |
||||
<script type="text/javascript" src="tbl_change.js"></script> |
||||
<script type="text/javascript"> |
||||
/* <![CDATA[ */ |
||||
var month_names = new Array( |
||||
<?php |
||||
foreach($MonthsLong as $index => $month) |
||||
{ |
||||
echo '"'.$month.'",'; |
||||
} |
||||
?> |
||||
""); |
||||
var day_names = new Array( |
||||
<?php |
||||
foreach($DaysShort as $index => $day) |
||||
{ |
||||
echo '"'.$day.'",'; |
||||
} |
||||
?> |
||||
""); |
||||
/* ]]> */ |
||||
</script> |
||||
</head> |
||||
<body dir="<?php echo api_get_text_direction(); ?>" onLoad="javascript: initCalendar();">
|
||||
<div id="calendar_data"></div> |
||||
<div id="clock_data"></div> |
||||
</body> |
||||
</html> |
@ -1,159 +0,0 @@ |
||||
var day; |
||||
var month; |
||||
var year; |
||||
var hour; |
||||
var minute; |
||||
var second; |
||||
var clock_set = 0; |
||||
|
||||
/** |
||||
* Opens calendar window. |
||||
* |
||||
* @param string form name |
||||
* @param string field name |
||||
*/ |
||||
function openCalendar(form, field) { |
||||
window.open("./calendar.php", "calendar", "width=260,height=250,status=no,toolbar=no"); |
||||
day = eval("document." + form + "." + field + "day.options["+ "document." + form + "." + field + "day.selectedIndex].value"); |
||||
month = eval("document." + form + "." + field + "month.options["+ "document." + form + "." + field + "month.selectedIndex].value"); |
||||
month = month-1; |
||||
year = eval("document." + form + "." + field + "year.options["+ "document." + form + "." + field + "year.selectedIndex].value"); |
||||
formName = form; |
||||
fieldName =field; |
||||
} |
||||
|
||||
/** |
||||
* Formats number to two digits. |
||||
* |
||||
* @param int number to format. |
||||
*/ |
||||
function formatNum2(i, valtype) { |
||||
f = (i < 10 ? '0' : '') + i; |
||||
if (valtype && valtype != '') { |
||||
switch(valtype) { |
||||
case 'month': |
||||
f = (f > 12 ? 12 : f); |
||||
break; |
||||
|
||||
case 'day': |
||||
f = (f > 31 ? 31 : f); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return f; |
||||
} |
||||
|
||||
/** |
||||
* Formats number to four digits. |
||||
* |
||||
* @param int number to format. |
||||
*/ |
||||
function formatNum4(i) { |
||||
return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i; |
||||
} |
||||
|
||||
/** |
||||
* Initializes calendar window. |
||||
*/ |
||||
function initCalendar() { |
||||
if (!year && !month && !day) { |
||||
day = window.opener.day; |
||||
month = window.opener.month; |
||||
year = window.opener.year; |
||||
if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) { |
||||
dt = new Date(); |
||||
year = dt.getFullYear(); |
||||
month = dt.getMonth(); |
||||
day = dt.getDate(); |
||||
} |
||||
} else { |
||||
/* Moving in calendar */ |
||||
if (month > 11) { |
||||
month = 0; |
||||
year++; |
||||
} |
||||
if (month < 0) { |
||||
month = 11; |
||||
year--; |
||||
} |
||||
} |
||||
|
||||
if (document.getElementById) { |
||||
cnt = document.getElementById("calendar_data"); |
||||
} else if (document.all) { |
||||
cnt = document.all["calendar_data"]; |
||||
} |
||||
|
||||
cnt.innerHTML = ""; |
||||
|
||||
str = "" |
||||
|
||||
//heading table
|
||||
str += '<table class="data_table"><tr><th class="monthyear" width="50%">'; |
||||
str += '<a href="javascript:month--; initCalendar();">«</a> '; |
||||
str += month_names[month]; |
||||
str += ' <a href="javascript:month++; initCalendar();">»</a>'; |
||||
str += '</th><th class="monthyear" width="50%">'; |
||||
str += '<a href="javascript:year--; initCalendar();">«</a> '; |
||||
str += year; |
||||
str += ' <a href="javascript:year++; initCalendar();">»</a>'; |
||||
str += '</th></tr></table>'; |
||||
|
||||
str += '<table class="data_table"><tr>'; |
||||
for (i = 0; i < 7; i++) { |
||||
str += "<td class='weekdays'>" + day_names[i] + "</td>"; |
||||
} |
||||
str += "</tr>"; |
||||
|
||||
var firstDay = new Date(year, month, 1).getDay(); |
||||
var lastDay = new Date(year, month + 1, 0).getDate(); |
||||
|
||||
str += "<tr>"; |
||||
|
||||
dayInWeek = 0; |
||||
for (i = 0; i < firstDay; i++) { |
||||
str += "<td> </td>"; |
||||
dayInWeek++; |
||||
} |
||||
for (i = 1; i <= lastDay; i++) { |
||||
if (dayInWeek == 7) { |
||||
str += "</tr><tr>"; |
||||
dayInWeek = 0; |
||||
} |
||||
|
||||
dispmonth = 1 + month; |
||||
actVal = formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day'); |
||||
if (i == day) { |
||||
style = ' class="selected"'; |
||||
} else { |
||||
style = ''; |
||||
} |
||||
str += "<td" + style + "><a href=\"javascript:returnDate(" + i +","+month+","+year + ");\">" + i + "</a></td>" |
||||
dayInWeek++; |
||||
} |
||||
for (i = dayInWeek; i < 7; i++) { |
||||
str += "<td> </td>"; |
||||
} |
||||
|
||||
str += "</tr></table>"; |
||||
|
||||
cnt.innerHTML = str; |
||||
} |
||||
|
||||
/** |
||||
* Returns date from calendar. |
||||
* |
||||
* @param string date text |
||||
*/ |
||||
function returnDate(d,m,y) { |
||||
cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"day.selectedIndex = "+(d-1); |
||||
eval(cmd); |
||||
cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"month.selectedIndex = "+m; |
||||
eval(cmd); |
||||
date = new Date(); |
||||
year = date.getFullYear()-1; |
||||
cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"year.selectedIndex = "+(y-year); |
||||
eval(cmd); |
||||
window.close(); |
||||
} |
@ -1,156 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @deprecated code use DatePicker or DateTimePicker |
||||
*/ |
||||
require_once dirname(__FILE__).'/../../../global.inc.php'; |
||||
|
||||
//session |
||||
if(isset($_GET['id_session'])) |
||||
$_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']); |
||||
|
||||
// the variables for the days and the months |
||||
// Defining the shorts for the days |
||||
$DaysShort = api_get_week_days_short(); |
||||
// Defining the days of the week to allow translation of the days |
||||
$DaysLong = api_get_week_days_long(); |
||||
// Defining the months of the year to allow translation of the months |
||||
$MonthsLong = api_get_months_long(); |
||||
|
||||
$iso_lang = api_get_language_isocode($language_interface); |
||||
|
||||
header('Content-Type: text/html; charset='. api_get_system_encoding()); |
||||
|
||||
?> |
||||
<!DOCTYPE html |
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $iso_lang; ?>" lang="<?php echo $iso_lang; ?>">
|
||||
<head> |
||||
<title>Calendar</title> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>">
|
||||
<style type="text/css"> |
||||
/*<![CDATA[*/ |
||||
@import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/<?php echo api_get_setting('stylesheets'); ?>/default.css";
|
||||
table.calendar { |
||||
width: 100%; |
||||
font-size: 12px; |
||||
font-family: verdana, arial, helvetica, sans-serif; |
||||
} |
||||
table.calendar .monthyear |
||||
{ |
||||
background-color: #4171B5; |
||||
text-align: center; |
||||
color: #ffffff; |
||||
font-size:12px; |
||||
padding:5px; |
||||
margin:10px; |
||||
} |
||||
table.calendar .daynames { |
||||
background-color: #D3DFF1; |
||||
text-align: center; |
||||
} |
||||
table.calendar td |
||||
{ |
||||
width: 25px; |
||||
height: 25px; |
||||
background-color: #f5f5f5; |
||||
text-align: center; |
||||
} |
||||
table.calendar td.selected |
||||
{ |
||||
border: 1px solid #ff0000; |
||||
background-color: #FFCECE; |
||||
} |
||||
table.calendar td a |
||||
{ |
||||
width: 25px; |
||||
height: 25px; |
||||
text-decoration: none; |
||||
} |
||||
table.calendar td a:hover |
||||
{ |
||||
background-color: #ffff00; |
||||
} |
||||
|
||||
table.calendar td a div |
||||
{ |
||||
padding:5px; |
||||
} |
||||
|
||||
table.calendar td a div:hover |
||||
{ |
||||
background-color: #ffff00; |
||||
} |
||||
|
||||
table.calendar .monthyear a { |
||||
text-align: center; |
||||
/* color: #ffffff; */ |
||||
} |
||||
table.calendar .monthyear a:hover |
||||
{ |
||||
text-align: center; |
||||
/*color: #ff0000;*/ |
||||
/*background-color: #ffff00;*/ |
||||
} |
||||
/*]]>*/ |
||||
</style> |
||||
<script type="text/javascript"> |
||||
/* <![CDATA[ */ |
||||
/* added 2004-06-10 by Michael Keck |
||||
* we need this for Backwards-Compatibility and resolving problems |
||||
* with non DOM browsers, which may have problems with css 2 (like NC 4) |
||||
*/ |
||||
var isDOM = (typeof(document.getElementsByTagName) != 'undefined' |
||||
&& typeof(document.createElement) != 'undefined') |
||||
? 1 : 0; |
||||
var isIE4 = (typeof(document.all) != 'undefined' |
||||
&& parseInt(navigator.appVersion) >= 4) |
||||
? 1 : 0; |
||||
var isNS4 = (typeof(document.layers) != 'undefined') |
||||
? 1 : 0; |
||||
var capable = (isDOM || isIE4 || isNS4) |
||||
? 1 : 0; |
||||
// Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant |
||||
if (capable) { |
||||
if (typeof(window.opera) != 'undefined') { |
||||
var browserName = ' ' + navigator.userAgent.toLowerCase(); |
||||
if ((browserName.indexOf('konqueror 7') == 0)) { |
||||
capable = 0; |
||||
} |
||||
} else if (typeof(navigator.userAgent) != 'undefined') { |
||||
var browserName = ' ' + navigator.userAgent.toLowerCase(); |
||||
if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) { |
||||
capable = 0; |
||||
} |
||||
} // end if... else if... |
||||
} // end if |
||||
/* ]]> */ |
||||
</script> |
||||
<script type="text/javascript" src="tbl_change.js.php"></script> |
||||
<script type="text/javascript"> |
||||
/* <![CDATA[ */ |
||||
var month_names = new Array( |
||||
<?php |
||||
foreach($MonthsLong as $index => $month) |
||||
{ |
||||
echo '"'.$month.'",'; |
||||
} |
||||
?> |
||||
""); |
||||
var day_names = new Array( |
||||
<?php |
||||
foreach($DaysShort as $index => $day) |
||||
{ |
||||
echo '"'.$day.'",'; |
||||
} |
||||
?> |
||||
""); |
||||
/* ]]> */ |
||||
</script> |
||||
</head> |
||||
<body dir="<?php echo api_get_text_direction(); ?>" onLoad="javascript: initCalendar();">
|
||||
<div id="calendar_data"></div> |
||||
<div id="clock_data"></div> |
||||
</body> |
||||
</html> |
@ -1,198 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
require '../../../global.inc.php'; |
||||
?> |
||||
var day; |
||||
var month; |
||||
var year; |
||||
var hour; |
||||
var minute; |
||||
var second; |
||||
var clock_set = 0; |
||||
|
||||
/** |
||||
* Opens calendar window. |
||||
* |
||||
* @param string form name |
||||
* @param string field name |
||||
*/ |
||||
function openCalendar(form, field) { |
||||
formblock= document.getElementById(form); |
||||
forminputs = formblock.getElementsByTagName('select'); |
||||
var datevalues = new Array(); |
||||
var dateindex = 0; |
||||
for (i = 0; i < forminputs.length; i++) { |
||||
// regex here to check name attribute |
||||
var regex = new RegExp(field, "i"); |
||||
if (regex.test(forminputs[i].getAttribute('name'))) { |
||||
datevalues[dateindex++] = forminputs[i].value; |
||||
} |
||||
} |
||||
window.open("<?php echo api_get_path(WEB_LIBRARY_PATH); ?>formvalidator/Element/calendar_popup.php", "calendar", "width=260,height=230,status=no");
|
||||
day = datevalues[0]; |
||||
month = datevalues[1]; |
||||
year = datevalues[2]; |
||||
|
||||
|
||||
month--; |
||||
formName = form; |
||||
fieldName =field; |
||||
} |
||||
|
||||
/** |
||||
* Formats number to two digits. |
||||
* |
||||
* @param int number to format. |
||||
*/ |
||||
function formatNum2(i, valtype) { |
||||
f = (i < 10 ? '0' : '') + i; |
||||
if (valtype && valtype != '') { |
||||
switch(valtype) { |
||||
case 'month': |
||||
f = (f > 12 ? 12 : f); |
||||
break; |
||||
|
||||
case 'day': |
||||
f = (f > 31 ? 31 : f); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return f; |
||||
} |
||||
|
||||
/** |
||||
* Formats number to four digits. |
||||
* |
||||
* @param int number to format. |
||||
*/ |
||||
function formatNum4(i) { |
||||
return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i; |
||||
} |
||||
|
||||
/** |
||||
* Initializes calendar window. |
||||
*/ |
||||
function initCalendar() { |
||||
if (!year && !month && !day) { |
||||
day = window.opener.day; |
||||
month = window.opener.month; |
||||
year = window.opener.year; |
||||
if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) { |
||||
dt = new Date(); |
||||
year = dt.getFullYear(); |
||||
month = dt.getMonth(); |
||||
day = dt.getDate(); |
||||
} |
||||
} else { |
||||
/* Moving in calendar */ |
||||
if (month > 11) { |
||||
month = 0; |
||||
year++; |
||||
} |
||||
if (month < 0) { |
||||
month = 11; |
||||
year--; |
||||
} |
||||
} |
||||
|
||||
if (document.getElementById) { |
||||
cnt = document.getElementById("calendar_data"); |
||||
} else if (document.all) { |
||||
cnt = document.all["calendar_data"]; |
||||
} |
||||
|
||||
cnt.innerHTML = ""; |
||||
|
||||
str = "" |
||||
|
||||
//heading table |
||||
str += '<table class="calendar"><tr><th class="monthyear" width="50%">'; |
||||
str += '<a href="javascript:month--; initCalendar();"><?php echo Display::return_icon('action_prev.png',get_lang('Previous'));?></a> ';
|
||||
str += month_names[month]; |
||||
str += ' <a href="javascript:month++; initCalendar();"><?php echo Display::return_icon('action_next.png',get_lang('Next'));?></a>';
|
||||
str += '</th><th class="monthyear" width="50%">'; |
||||
str += '<a href="javascript:year--; initCalendar();"><?php echo Display::return_icon('action_prev.png',get_lang('Previous'));?></a> ';
|
||||
str += year; |
||||
str += ' <a href="javascript:year++; initCalendar();"><?php echo Display::return_icon('action_next.png',get_lang('Next'));?></a>';
|
||||
str += '</th></tr></table>'; |
||||
|
||||
str += '<table class="calendar"><tr>'; |
||||
for (i = 0; i < 7; i++) { |
||||
str += "<th class='daynames'>" + day_names[i] + "</th>"; |
||||
} |
||||
str += "</tr>"; |
||||
|
||||
var firstDay = new Date(year, month, 1).getDay(); |
||||
var lastDay = new Date(year, month + 1, 0).getDate(); |
||||
|
||||
str += "<tr>"; |
||||
|
||||
dayInWeek = 0; |
||||
for (i = 0; i < firstDay; i++) { |
||||
str += "<td> </td>"; |
||||
dayInWeek++; |
||||
} |
||||
for (i = 1; i <= lastDay; i++) { |
||||
if (dayInWeek == 7) { |
||||
str += "</tr><tr>"; |
||||
dayInWeek = 0; |
||||
} |
||||
|
||||
dispmonth = 1 + month; |
||||
actVal = formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day'); |
||||
if (i == day) { |
||||
style = ' class="selected"'; |
||||
} else { |
||||
style = ''; |
||||
} |
||||
str += "<td" + style + "><a href=\"javascript:returnDate(" + i +","+month+","+year + ");\" ><div>" + i + "</div></a></td>" |
||||
dayInWeek++; |
||||
} |
||||
for (i = dayInWeek; i < 7; i++) { |
||||
str += "<td> </td>"; |
||||
} |
||||
|
||||
str += "</tr></table>"; |
||||
|
||||
cnt.innerHTML = str; |
||||
} |
||||
|
||||
/** |
||||
* Returns date from calendar. |
||||
* |
||||
* @param string date text |
||||
*/ |
||||
function returnDate(d,m,y) { |
||||
|
||||
formblock= window.opener.document.getElementById(window.opener.formName); |
||||
forminputs = formblock.getElementsByTagName('select'); |
||||
var datevalues = new Array(); |
||||
var dateindex = 0; |
||||
for (i = 0; i < forminputs.length; i++) { |
||||
// regex here to check name attribute |
||||
var regex = new RegExp(window.opener.fieldName, "i"); |
||||
if (regex.test(forminputs[i].getAttribute('name'))) { |
||||
datevalues[dateindex] = forminputs[i]; |
||||
dateindex++; |
||||
window.close(); |
||||
} |
||||
} |
||||
datevalues[0].selectedIndex = (d-1) ; |
||||
datevalues[1].selectedIndex = m; |
||||
|
||||
date = new Date(); |
||||
|
||||
//Selecting the first option of the year |
||||
year = datevalues[2].options[0].value; |
||||
|
||||
datevalues[2].selectedIndex = y - year; |
||||
for(i = 0; i<= 3; i++) { |
||||
attributes = datevalues[i].attributes; |
||||
for (attr=0; attr<attributes.length; attr++) |
||||
if(attributes[attr].nodeName == 'onchange') { |
||||
datevalues[i].onchange(); |
||||
} |
||||
} |
||||
window.close(); |
||||
} |
@ -1,75 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Link category form class definition |
||||
* @package chamilo.link |
||||
*/ |
||||
/** |
||||
* Init |
||||
*/ |
||||
|
||||
namespace Link; |
||||
|
||||
/** |
||||
* Edit/create a LinkCategory. |
||||
* |
||||
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Genevas |
||||
* @license /license.txt |
||||
*/ |
||||
class CategoryForm extends \FormValidator |
||||
{ |
||||
|
||||
protected $category; |
||||
|
||||
function __construct($form_name = 'category', $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true) |
||||
{ |
||||
parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @return object |
||||
*/ |
||||
public function get_category() |
||||
{ |
||||
return $this->category; |
||||
} |
||||
|
||||
public function set_category($value) |
||||
{ |
||||
$this->category = $value; |
||||
} |
||||
/** |
||||
* |
||||
* @param \Link\LinkCategory $category |
||||
*/ |
||||
function init($category = null) |
||||
{ |
||||
$this->set_category($category); |
||||
|
||||
$defaults = array(); |
||||
$defaults['category_title'] = $category->category_title; |
||||
$defaults['category_description'] = $category->description; |
||||
|
||||
$this->addElement('hidden', 'c_id', $category->c_id); |
||||
$this->addElement('hidden', 'id', $category->id); |
||||
$this->addElement('hidden', 'session_id', $category->session_id); |
||||
|
||||
$form_name = $category->id ? get_lang('ModifyCategory') : get_lang('AddCategory'); |
||||
$this->addHeader($form_name); |
||||
$this->addText('category_title', get_lang('Title')); |
||||
$this->addRule('category_title', get_lang('Required'), 'required'); |
||||
|
||||
$this->addElement('textarea', 'category_description', get_lang('Description')); |
||||
$this->addElement('button', 'save', get_lang('Save'), array('class' => 'btn save')); |
||||
$this->setDefaults($defaults); |
||||
} |
||||
|
||||
function update_model() |
||||
{ |
||||
$values = $this->exportValues(); |
||||
$category = $this->get_category(); |
||||
$category->category_title = $values['category_title']; |
||||
$category->description = $values['category_description']; |
||||
} |
||||
} |
@ -1,188 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Link CSV import class definition |
||||
* @package chamilo.link |
||||
*/ |
||||
/** |
||||
* Init |
||||
*/ |
||||
|
||||
namespace Link; |
||||
|
||||
/** |
||||
* Import a csv file into the course/session. |
||||
* |
||||
* |
||||
* |
||||
* @license /licence.txt |
||||
* @author Laurent Opprecht <laurent@opprecht.info> |
||||
*/ |
||||
class ImportCsv |
||||
{ |
||||
|
||||
protected $c_id; |
||||
protected $session_id; |
||||
protected $path; |
||||
protected $links_imported = 0; |
||||
protected $links_skipped = 0; |
||||
protected $update_existing_entries = false; |
||||
|
||||
public function __construct($c_id, $session_id, $path, $update_existing_entries = false) |
||||
{ |
||||
$this->c_id = $c_id; |
||||
$this->session_id = $session_id; |
||||
$this->path = $path; |
||||
$this->update_existing_entries = $update_existing_entries; |
||||
} |
||||
|
||||
public function get_path() |
||||
{ |
||||
return $this->path; |
||||
} |
||||
|
||||
public function get_c_id() |
||||
{ |
||||
return $this->c_id; |
||||
} |
||||
|
||||
public function get_session_id() |
||||
{ |
||||
return $this->session_id; |
||||
} |
||||
|
||||
public function get_links_imported() |
||||
{ |
||||
return $this->links_imported; |
||||
} |
||||
|
||||
public function get_links_skipped() |
||||
{ |
||||
return $this->links_skipped; |
||||
} |
||||
|
||||
public function get_update_existing_entries() |
||||
{ |
||||
return $this->update_existing_entries; |
||||
} |
||||
|
||||
/** |
||||
* Read file and returns an array filled up with its' content. |
||||
* |
||||
* @return array of objects |
||||
*/ |
||||
public function get_data() |
||||
{ |
||||
$result = array(); |
||||
|
||||
$path = $this->path; |
||||
if (!is_readable($path)) { |
||||
return array(); |
||||
} |
||||
|
||||
$items = \Import::csv_reader($path); |
||||
foreach ($items as $item) { |
||||
$item = (object) $item; |
||||
$url = isset($item->url) ? trim($item->url) : ''; |
||||
$title = isset($item->title) ? trim($item->title) : ''; |
||||
$description = isset($item->description) ? trim($item->description) : ''; |
||||
$target = isset($item->target) ? trim($item->target) : ''; |
||||
$category_title = isset($item->category_title) ? trim($item->category_title) : ''; |
||||
$category_description = isset($item->category_description) ? trim($item->category_description) : ''; |
||||
if (empty($url)) { |
||||
continue; |
||||
} |
||||
if ($category_title) { |
||||
$category_title = \Security::remove_XSS($category_title); |
||||
$category_description = \Security::remove_XSS($category_description); |
||||
} else { |
||||
$category_description = ''; |
||||
} |
||||
|
||||
$url = \Security::remove_XSS($url); |
||||
$title = \Security::remove_XSS($title); |
||||
$description = \Security::remove_XSS($description); |
||||
$target = \Security::remove_XSS($target); |
||||
|
||||
$item->url = $url; |
||||
$item->title = $title; |
||||
$item->description = $description; |
||||
$item->target = $target; |
||||
$item->category_title = $category_title; |
||||
$item->category_description = $category_description; |
||||
$result[] = $item; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function run() |
||||
{ |
||||
$path = $this->path; |
||||
if (!is_readable($path)) { |
||||
return false; |
||||
} |
||||
$this->links_imported = 0; |
||||
$this->links_skipped = 0; |
||||
|
||||
$items = $this->get_data(); |
||||
foreach ($items as $item) { |
||||
$url = $item->url; |
||||
$title = $item->title; |
||||
$description = $item->description; |
||||
$target = $item->target; |
||||
$category_title = $item->category_title; |
||||
$category_description = $item->category_description; |
||||
|
||||
if ($category_title) { |
||||
$category = $this->ensure_category($category_title, $category_description); |
||||
} |
||||
|
||||
$link = $this->find_link_by_url($url); |
||||
if ($link && $this->update_existing_entries == false) { |
||||
$this->links_skipped++; |
||||
continue; |
||||
} |
||||
if (empty($link)) { |
||||
$link = new Link(); |
||||
$link->c_id = $this->c_id; |
||||
$link->session_id = $this->session_id; |
||||
$link->url = $url; |
||||
} |
||||
|
||||
$link->title = $title; |
||||
$link->description = $description; |
||||
$link->target = $target; |
||||
$link->category_id = $category ? $category->id : 0; |
||||
$repo = LinkRepository::instance(); |
||||
$repo->save($link); |
||||
$this->links_imported++; |
||||
} |
||||
} |
||||
|
||||
public function ensure_category($title, $description = '') |
||||
{ |
||||
$c_id = $this->c_id; |
||||
$session_id = $this->session_id; |
||||
$repo = LinkCategoryRepository::instance(); |
||||
$result = $repo->find_one_by_course_and_name($c_id, $session_id, $title); |
||||
if (empty($result)) { |
||||
$result = new LinkCategory(); |
||||
$result->c_id = $c_id; |
||||
$result->category_title = $title; |
||||
$result->description = $description; |
||||
$result->session_id = $session_id; |
||||
$repo->save($result); |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function find_link_by_url($url) |
||||
{ |
||||
$c_id = $this->c_id; |
||||
$session_id = $this->session_id; |
||||
$repo = LinkRepository::instance(); |
||||
$link = $repo->find_one_by_course_and_url($c_id, $session_id, $url); |
||||
return $link; |
||||
} |
||||
|
||||
} |
@ -1,105 +0,0 @@ |
||||
|
||||
function Proxy() {}; |
||||
|
||||
Proxy.prototype.root = function(){ |
||||
return www + '/main/inc/ajax/link.ajax.php'; |
||||
} |
||||
|
||||
Proxy.prototype.post = function(data, f){
|
||||
if(typeof(sec_token)!=='undefined'){
|
||||
data.sec_token = sec_token; |
||||
} |
||||
$.post(this.root(), data, f, 'json'); |
||||
} |
||||
|
||||
var Link = new Proxy(); |
||||
|
||||
Link.hide = function(c_id, id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'hide_link' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
Link.show = function(c_id, id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'show_link' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
Link.del = function(c_id, id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'delete_link' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
Link.delete_by_course = function(c_id, session_id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
session_id: session_id,
|
||||
action: 'delete_by_course' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
Link.sort = function(c_id, ids, f){ |
||||
var data = { |
||||
c_id: c_id,
|
||||
ids: ids,
|
||||
action: 'sort_links' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
Link.validate = function(c_id, id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'validate_link' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
|
||||
|
||||
var LinkCategory = new Proxy(); |
||||
|
||||
LinkCategory.del = function(c_id, id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'delete_category' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
LinkCategory.sort = function(c_id, ids, f){ |
||||
var data = { |
||||
c_id: c_id,
|
||||
ids: ids,
|
||||
action: 'sort_categories' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
|
||||
var message = {}; |
||||
|
||||
message.update = function(data){ |
||||
text = typeof(data)=='string' ? data : data.message; |
||||
$('#messages').html(text) |
||||
} |
@ -1,40 +0,0 @@ |
||||
/** |
||||
* Define a client proxy for ajax calls. |
||||
*/ |
||||
|
||||
|
||||
function Proxy() {}; |
||||
|
||||
Proxy.prototype.root = function(){ |
||||
return context.ajax; |
||||
} |
||||
|
||||
Proxy.prototype.post = function(data, f){
|
||||
if(typeof(context)!=='undefined' && typeof(context.sec_token)!=='undefined'){
|
||||
data.sec_token = context.sec_token; |
||||
} |
||||
$.post(this.root(), data, f, 'json'); |
||||
} |
||||
|
||||
|
||||
var notebook = new Proxy(); |
||||
|
||||
notebook.remove = function(c_id, id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
id: id,
|
||||
action: 'remove' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
||||
|
||||
notebook.remove_by_course = function(c_id, session_id, f) |
||||
{ |
||||
var data = { |
||||
c_id: c_id,
|
||||
session_id: session_id,
|
||||
action: 'remove_by_course' |
||||
}; |
||||
this.post(data, f); |
||||
}; |
@ -1,104 +0,0 @@ |
||||
/** |
||||
* User interface objects. |
||||
*/ |
||||
|
||||
var message = {}; |
||||
|
||||
message.update = function(data){ |
||||
var text = typeof(data)=='string' ? data : data.message; |
||||
$('#messages').html(text); |
||||
} |
||||
|
||||
message.error = function(data){ |
||||
text = typeof(data)=='string' ? data : data.message; |
||||
if(! text){ |
||||
return; |
||||
} |
||||
$('#messages').html('<div class="error-message">' + text + '</div>'); |
||||
} |
||||
|
||||
message.info = function(data){ |
||||
text = typeof(data)=='string' ? data : data.message; |
||||
if(! text){ |
||||
return; |
||||
} |
||||
$('#messages').html('<div class="normal-message">' + text + '</div>'); |
||||
} |
||||
|
||||
message.confirmation = function(data){ |
||||
text = typeof(data)=='string' ? data : data.message; |
||||
if(! text){ |
||||
return; |
||||
} |
||||
$('#messages').html('<div class="confirmation-message">' + text + '</div>'); |
||||
} |
||||
|
||||
message.warning = function(data){ |
||||
text = typeof(data)=='string' ? data : data.message; |
||||
if(! text){ |
||||
return; |
||||
} |
||||
$('#messages').html('<div class="warning-message">' + text + '</div>'); |
||||
} |
||||
|
||||
|
||||
var ui = {}; |
||||
|
||||
ui.message = message; |
||||
|
||||
ui.loading = function(btn){ |
||||
$(btn).addClass("loading"); |
||||
}; |
||||
|
||||
ui.done = function(btn){ |
||||
$(btn).removeClass("loading"); |
||||
}; |
||||
|
||||
ui.confirm = function(){ |
||||
if(!window.confirm(lang.ConfirmYourChoice)){ |
||||
return false; |
||||
} else { |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
ui.remove = function(name, btn){
|
||||
if(!this.confirm()){ |
||||
return false; |
||||
}
|
||||
|
||||
var item = $('#'+name); |
||||
var id = item.attr('data-id');
|
||||
var c_id = item.attr('data-c_id');
|
||||
|
||||
var f = function(data){ |
||||
if(data.success){ |
||||
item.remove(); |
||||
} |
||||
message.update(data); |
||||
ui.done(btn); |
||||
}; |
||||
ui.loading(btn); |
||||
ui.proxy.remove(c_id, id, f); |
||||
}; |
||||
|
||||
ui.remove_by_course = function(name, btn){ |
||||
if(!this.confirm()){ |
||||
return false; |
||||
}
|
||||
|
||||
var item = $('#'+name); |
||||
var c_id = item.attr('data-c_id');
|
||||
var session_id = item.attr('data-session_id');
|
||||
|
||||
var f = function(data){ |
||||
if(data.success){ |
||||
item.remove(); |
||||
} |
||||
message.update(data); |
||||
ui.done(btn); |
||||
}; |
||||
ui.loading(btn); |
||||
ui.proxy.remove_by_course(c_id, session_id, f); |
||||
|
||||
}; |
Loading…
Reference in new issue