[svn r14637] Use “Today”, “Yesterday” and “Two days ago” to specify the date for recent files. (See FS#2349)

skala
Julio Montoya 18 years ago
parent fa403f1133
commit 97540137c5
  1. 7
      main/css/academica/default.css
  2. 7
      main/css/baby/default.css
  3. 7
      main/css/corporativa/default.css
  4. 6
      main/css/default/default.css
  5. 6
      main/css/default_with_tabs/default.css
  6. 7
      main/css/dokeosgrey/default.css
  7. 9
      main/dropbox/dropbox_functions.inc.php
  8. 145
      main/dropbox/index.php
  9. 62
      main/inc/lib/display.lib.php
  10. 69
      main/inc/lib/sortabletable.class.php
  11. 126
      main/inc/lib/tablesort.lib.php
  12. 134
      main/inc/lib/text.lib.php

@ -1366,6 +1366,13 @@ a.specialLink:hover,a.specialLink:focus {
margin: 0 .8em;
}
.dropbox_date {
color: #737780;
font-style: italic ;
font-weight: normal;
}
/*
==============================================================================
SYSTEM ANNOUNCEMENTS

@ -1306,6 +1306,13 @@ th span {
margin: 0 .8em;
}
.dropbox_date {
color: #737780;
font-style: italic ;
font-weight: normal;
}
/*
==============================================================================
SYSTEM ANNOUNCEMENTS

@ -1269,6 +1269,13 @@ a.specialLink:hover,a.specialLink:focus {
margin: 0 .8em;
}
.dropbox_date {
color: #737780;
font-style: italic ;
font-weight: normal;
}
/*
==============================================================================
SYSTEM ANNOUNCEMENTS

@ -1045,8 +1045,10 @@ dl.upload_option {
font-style: italic
}
.dropbox_person {
font-weight: bold
.dropbox_date {
color: #737780;
font-style: italic ;
font-weight: normal;
}
.dropbox_listTitle {

@ -746,7 +746,11 @@ dl.upload_option {margin: 1em 0; padding: 0;}
**********************************************/
/* styles from dropbox.php file */
.dropbox_detail {font-size: small}
.dropbox_date {font-style: italic}
.dropbox_date {
color: #737780;
font-style: italic ;
font-weight: normal;
}
.dropbox_person {font-weight: bold}
.dropbox_listTitle { color: #000000;}
.dropbox_feedback {font-size: x-small; height: 50px; width: 200px; overflow: auto}

@ -721,7 +721,12 @@ dl.upload_option {margin: 1em 0; padding: 0;}
**********************************************/
/* styles from dropbox.php file */
.dropbox_detail {font-size: small}
.dropbox_date {font-style: italic}
.dropbox_date {
color: #737780;
font-style: italic ;
font-weight: normal;
}
.dropbox_person {font-weight: bold}
.dropbox_listTitle { color: #000000;}
.dropbox_feedback {font-size: x-small; height: 50px; width: 200px; overflow: auto}

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2006 Dokeos S.A.
Copyright (c) 2006-2008 Dokeos S.A.
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
@ -1047,10 +1047,9 @@ function feedback($array)
*/
function format_feedback($feedback)
{
$output.='<strong>'.get_lang('Date').'</strong>: '.$feedback['feedback_date'].'<br />';
$output.='<strong>'.get_lang('Author').'</strong>: '.display_user_link($feedback['author_user_id']).'<br />';
$output.='<strong>'.get_lang('Text').'</strong>: '.nl2br($feedback['feedback']).'<hr size="1" noshade/>';
$output.=display_user_link($feedback['author_user_id']);
$output.='&nbsp;&nbsp;['.$feedback['feedback_date'].']<br>';
$output.='<div style="padding-top:6px">'.nl2br($feedback['feedback']).'</div><hr size="1" noshade/><br>';
return $output;
}

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2006 Dokeos S.A.
Copyright (c) 2006-2008 Dokeos S.A.
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
@ -160,6 +160,7 @@ if ($_GET['action']=="add")
{
display_add_form();
}
if ($_POST['submitWork'])
{
$check = Security::check_token();
@ -251,7 +252,8 @@ if (isset($_GET['error']) AND !empty($_GET['error']))
if ($_GET['action']!="add")
{
// getting all the categories in the dropbox for the given user
$dropbox_categories=get_dropbox_categories();
// creating the arrays with the categories for the received files and for the sent files
@ -290,7 +292,6 @@ if ($dropbox_cnf['sent_received_tabs'])
RECEIVED FILES
-----------------------------------------------------------
*/
if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_tabs']==false)
{
//echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
@ -305,13 +306,14 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
$view_dropbox_category_received=0;
}
/* *** Menu Received *** */
if ($view_dropbox_category_received<>0)
{
echo get_lang('CurrentlySeeing').': <strong>'.$dropbox_categories[$view_dropbox_category_received]['cat_name'].'</strong><br />';
echo '<img src="../img/folder_up.gif" alt="'.get_lang('up').'" align="absmiddle" /><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'">'.get_lang('Root')."</a>\n";
}
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=addreceivedcategory\"><img src=\"../img/folder_new.gif\" alt=\"".get_lang('NewFolder')."\" align=\"absmiddle\"/> ".get_lang('AddNewCategory')."</a>\n";
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory"><img src="../img/folder_new.gif" align=\"absmiddle\"/> '.get_lang('AddNewCategory').'</a>';
// object initialisation
@ -329,12 +331,38 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
$column_header[] = array('',false,'');
$column_header[] = array(get_lang('Type'),true,'style="width:40px"');
$column_header[] = array(get_lang('ReceivedTitle'), TRUE, '');
$column_header[] = array(get_lang('Authors'), TRUE, '');
$column_header[] = array(get_lang('Description'), TRUE, '');
$column_header[] = array(get_lang('Size'), TRUE, '');
$column_header[] = array(get_lang('LastResent'), TRUE, '');
$column_header[] = array(get_lang('Authors'), TRUE, '');
$column_header[] = array(get_lang('LastResent'), true);
$column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"');
$column_header[] = array('RealDate', true);
// An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=0;
// Here we change the way how the colums are going to be sort
// in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
// because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
$column_order[]=1;
$column_order[]=2;
$column_order[]=3;
$column_order[]=4;
$column_order[]=7;
$column_order[]=6;
$column_order[]=7;
$column_order[]=8;
// the content of the sortable table = the received files
foreach ( $dropbox_person -> receivedWork as $dropbox_file)
{
@ -342,6 +370,7 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
if ($view_dropbox_category_received==$dropbox_file->category) // we only display the files that are in the category that we are in.
{
$dropbox_file_data[]=$dropbox_file->id;
// new icon
if ($dropbox_file->last_upload_date > $last_access AND !in_array($dropbox_file->id,$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX]))
{
@ -352,11 +381,13 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
$new_icon='';
}
$dropbox_file_data[]=build_document_icon_tag('file',$dropbox_file->title);
$dropbox_file_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download"><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'"/></a><a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'.$dropbox_file->title.'</a>'.$new_icon;
$dropbox_file_data[]=$dropbox_file->author;
$dropbox_file_data[]=$dropbox_file->description;
$dropbox_file_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download"><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'"/></a><a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'.$dropbox_file->title.'</a>'.$new_icon.'<br>'.$dropbox_file->description;
$dropbox_file_data[]=ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB');
$dropbox_file_data[]=$dropbox_file->last_upload_date;
$dropbox_file_data[]=$dropbox_file->author;
//$dropbox_file_data[]=$dropbox_file->description;
$dropbox_file_data[]=date_to_str_ago($dropbox_file->last_upload_date).'<br><span class="dropbox_date">'.$dropbox_file->last_upload_date.'</span>';
$action_icons=check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'"><img src="../img/comment_bubble.gif" alt="'.get_lang('Comment').'" align="absmiddle" /></a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'"><img src="../img/deplacer_fichier.gif" alt="'.get_lang('Move').'" align="absmiddle"/></a>
@ -364,18 +395,22 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
//$action_icons=' <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'"><img src="../img/deplacer.gif" alt="'.get_lang('Move').'"/></a>
// <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'" onclick="return confirmation(\''.$dropbox_file->title.'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a>';
// this is a hack to have an additional row in a sortable table
if($_GET['action']=='viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id'])
{
$action_icons.="</td></tr>\n"; // ending the normal row of the sortable table
$action_icons.="<tr>\n\t<td colspan=\"2\"><a href=\"index.php?".api_get_cidreq()."&view_received_category=".$_GET['view_received_category']."&amp;view_sent_category=".$_GET['view_sent_category']."&amp;view=".$_GET['view']."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
$action_icons.='<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category']."&amp;view_sent_category=".$_GET['view_sent_category']."&amp;view=".$_GET['view']."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
}
$dropbox_file_data[]=$action_icons;
$action_icons='';
$dropbox_data_recieved[]=$dropbox_file_data;
$dropbox_file_data[]=$dropbox_file->last_upload_date;//date
$dropbox_data_recieved[]=$dropbox_file_data;
}
}
// the content of the sortable table = the categories (if we are not in the root)
if ($view_dropbox_category_received==0)
@ -392,7 +427,6 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=editcategory&amp;id='.$category['cat_id'].'"><img src="../img/edit.gif" alt="'.get_lang('Edit').'" /></a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="return confirmation(\''.$category['cat_name'].'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'" /></a>';
}
@ -401,19 +435,14 @@ if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_t
$dropbox_data_recieved[]=$dropbox_category_data;
}
}
}
// Displaying the table
$additional_get_parameters=array('view'=>$_GET['view'], 'view_received_category'=>$_GET['view_received_category'],'view_sent_category'=>$_GET['view_sent_category']);
Display::display_sortable_table($column_header, $dropbox_data_recieved, $sorting_options, $paging_options, $additional_get_parameters, array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')));
$additional_get_parameters=array('view'=>$_GET['view'], 'view_received_category'=>$_GET['view_received_category'],'view_sent_category'=>$_GET['view_sent_category']);
Display::display_sortable_config_table($column_header, $dropbox_data_recieved, $sorting_options, $paging_options, $additional_get_parameters,$column_show,$column_order, array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')));
}
/*
-----------------------------------------------------------
SENT FILES
@ -439,8 +468,8 @@ if ($_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false)
echo get_lang('CurrentlySeeing').': <strong>'.$dropbox_categories[$view_dropbox_category_sent]['cat_name'].'</strong><br />';
echo '<img src="../img/folder_up.gif" alt="'.get_lang('Up').'" align="absmiddle" /><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category=0&amp;view='.$_GET['view'].'">'.get_lang('Root')."</a>\n";
}
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$_GET['view']."&amp;action=add\"><img src=\"../img/submit_file.gif\" alt=\"".get_lang('Upload')."\" align=\"absmiddle\"/> ".get_lang('UploadNewFile')."</a>&nbsp;\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$_GET['view']."&amp;action=addsentcategory\"><img src=\"../img/folder_new.gif\" alt=\"".get_lang('NewFolder')."\" align=\"absmiddle\" /> ".get_lang('AddNewCategory')."</a>\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$_GET['view']."&amp;action=add\"><img src=\"../img/submit_file.gif\" align=\"absmiddle\"/> ".get_lang('UploadNewFile')."</a>&nbsp;\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$_GET['view']."&amp;action=addsentcategory\"><img src=\"../img/folder_new.gif\" align=\"absmiddle\" /> ".get_lang('AddNewCategory')."</a>\n";
//echo '<form name="sent_files" method="post" action="'.api_get_self().'?view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'">';
@ -454,39 +483,63 @@ if ($_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false)
$sorting_options = array();
$paging_options = array();
// the headers of the sortable tables
$column_header=array();
$column_header[] = array('',false,'');
$column_header[] = array(get_lang('Type'),true,'style="width:40px"','style="text-align:center"');
$column_header[] = array(get_lang('SentTitle'), TRUE, '');
$column_header[] = array(get_lang('Authors'), TRUE, '');
$column_header[] = array(get_lang('Description'), TRUE, '');
$column_header[] = array(get_lang('Size'), TRUE, '');
$column_header[] = array(get_lang('SentTo'), TRUE, '');
$column_header[] = array(get_lang('LastResent'), TRUE, '');
$column_header[] = array(get_lang('SentTo'), TRUE, '');
$column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"');
$column_header[] = array('RealDate', FALSE);
$column_show=array();
$column_order=array();
// An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=1;
$column_show[]=0;
// Here we change the way how the colums are going to be sort
// in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
// because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
$column_order[]=1;
$column_order[]=2;
$column_order[]=3;
$column_order[]=4;
$column_order[]=7;
$column_order[]=6;
$column_order[]=7;
$column_order[]=8;
// the content of the sortable table = the received files
foreach ( $dropbox_person -> sentWork as $dropbox_file)
{
$dropbox_file_data=array();
if ($view_dropbox_category_sent==$dropbox_file->category)
{
$dropbox_file_data[]=$dropbox_file->id;
$dropbox_file_data[]=build_document_icon_tag('file',$dropbox_file->title);
$dropbox_file_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download"><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'" /></a><a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'.$dropbox_file->title.'</a>';
$dropbox_file_data[]=$dropbox_file->author;
$dropbox_file_data[]=$dropbox_file->description;
$dropbox_file_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download"><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'" /></a><a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'.$dropbox_file->title.'</a><br>'.$dropbox_file->description;
$dropbox_file_data[]=ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB');
$dropbox_file_data[]=$dropbox_file->last_upload_date;
foreach ($dropbox_file->recipients as $recipient)
{
$receivers_celldata=display_user_link($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
}
$dropbox_file_data[]=$receivers_celldata;
$dropbox_file_data[]=$receivers_celldata;
$dropbox_file_data[]=date_to_str_ago($dropbox_file->last_upload_date).'<br><span class="dropbox_date">'.$dropbox_file->last_upload_date.'</span>';
//$dropbox_file_data[]=$dropbox_file->author;
$receivers_celldata='';
$action_icons=check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'"><img src="../img/comment_bubble.gif" alt="'.get_lang('Comment').'" align="absmiddle" /></a>
@ -499,7 +552,8 @@ if ($_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false)
$action_icons.="<tr>\n\t<td colspan=\"2\"><a href=\"index.php?".api_get_cidreq()."&view_received_category=".$_GET['view_received_category']."&amp;view_sent_category=".$_GET['view_sent_category']."&amp;view=".$_GET['view']."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
}
$dropbox_file_data[]=$action_icons;
$dropbox_file_data[]=$action_icons;
$dropbox_file_data[]=$dropbox_file->last_upload_date;
$action_icons='';
$dropbox_data_sent[]=$dropbox_file_data;
@ -517,9 +571,9 @@ if ($_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false)
$dropbox_category_data[]=''; // this is where the checkbox icon for the files appear
$dropbox_category_data[]=build_document_icon_tag('folder',$category['cat_name']);
$dropbox_category_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent"><img width="16" height="16" src="../img/folder_zip.gif" style="float:right;" alt="'.get_lang('Save').'" /></a><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$_GET['view'].'">'.$category['cat_name'].'</a>';
//$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='';
//$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='';
$dropbox_category_data[]='<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=editcategory&id='.$category['cat_id'].'"><img src="../img/edit.gif" alt="'.get_lang('Edit').'"/></a>
@ -530,16 +584,11 @@ if ($_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false)
$dropbox_data_sent[]=$dropbox_category_data;
}
}
}
// Displaying the table
$additional_get_parameters=array('view'=>$_GET['view'], 'view_received_category'=>$_GET['view_received_category'],'view_sent_category'=>$_GET['view_sent_category']);
Display::display_sortable_table($column_header, $dropbox_data_sent, $sorting_options, $paging_options, $additional_get_parameters, array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')));
Display::display_sortable_config_table($column_header, $dropbox_data_sent, $sorting_options, $paging_options, $additional_get_parameters,$column_show,$column_order, array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')));
}
}
Display::display_footer();
?>

@ -4,7 +4,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) Roan Embrechts, Vrije Universiteit Brussel
Copyright (c) Wolfgang Schneider
Copyright (c) Bert Vanderkimpen, Ghent University
@ -281,17 +281,75 @@ class Display {
global $origin;
$column = isset ($sorting_options['column']) ? $sorting_options['column'] : 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
$table = new SortableTableFromArray($content, $column, $default_items_per_page);
if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars);
}
foreach ($header as $index => $header_item)
{
{
$table->set_header($index, $header_item[0], $header_item[1], $header_item[2], $header_item[3]);
}
$table->set_form_actions($form_actions);
$table->display();
}
/**
* Display a table with a special configuration
* @param array $header Titles for the table header
* each item in this array can contain 3 values
* - 1st element: the column title
* - 2nd element: true or false (column sortable?)
* - 3th element: additional attributes for
* th-tag (eg for column-width)
* - 4the element: additional attributes for the td-tags
* @param array $content 2D-array with the tables content
* @param array $sorting_options Keys are:
* 'column' = The column to use as sort-key
* 'direction' = SORT_ASC or SORT_DESC
* @param array $paging_options Keys are:
* 'per_page_default' = items per page when switching from
* full- list to per-page-view
* 'per_page' = number of items to show per page
* 'page_nr' = The page to display
* @param array $query_vars Additional variables to add in the query-string
* @param array $column_show Array of binaries 1= show columns 0. hide a column
* @param array $column_order An array of integers that let us decide how the columns are going to be sort.
* i.e: $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
* @param array $form_actions Set optional forms actions
*
* @author Julio Montoya
*/
function display_sortable_config_table($header, $content, $sorting_options = array (), $paging_options = array (), $query_vars = null, $column_show=array(),$column_order=array(),$form_actions=array())
{
global $origin;
$column = isset ($sorting_options['column']) ? $sorting_options['column'] : 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
$table = new SortableTableFromArrayConfig($content, $column, $default_items_per_page,'tablename',$column_show,$column_order);
if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars);
}
// show or hide the columns header
if (is_array($column_show) )
{
for ($i=0;$i<count($column_show);$i++)
{
if ($column_show[$i])
{
$table->set_header($i, $header[$i][0], $header[$i][1], $header[$i][2], $header[$i][3]);
}
}
}
$table->set_form_actions($form_actions);
$table->display();
}
/**
* Displays a normal message. It is recommended to use this function
* to display any normal information messages.

@ -4,7 +4,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2005 Dokeos S.A.
Copyright (c) 2005-2008 Dokeos S.A.
Copyright (c) Bart Mollet (bart.mollet@hogent.be)
For a full list of contributors, see "credits.txt".
@ -107,6 +107,8 @@ class SortableTable extends HTML_Table
* table
*/
var $other_tables;
/**
* Create a new SortableTable
* @param string $table_name A name for the table (default = 'table')
@ -612,4 +614,69 @@ class SortableTableFromArray extends SortableTable
return count($this->table_data);
}
}
/**
* Sortable table which can be used for data available in an array
*
* Is a variation of SortableTableFromArray because we add 2 new arrays $column_show and $column_order
* $column_show is an array that lets us decide which are going to be the columns to show
* $column_order is an array that lets us decide the ordering of the columns
* i.e: $column_header=array('a','b','c','d','e'); $column_order=array(1,2,5,4,5);
* These means that the 3th column (letter "c") will be sort like the order we use in the 5th column
*/
class SortableTableFromArrayConfig extends SortableTable
{
/**
* The array containing the columns that will be show i.e $column_show=array('1','0','0'); we will show only the 1st column
*/
private $column_show;
/**
*The array containing the real sort column $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
*/
private $column_order;
/**
* The array containing all data for this table
*/
private $table_data;
/**
* Constructor
* @param array $table_data All the information of the table
* @param int $default_column Default column that will be use in the sorts functions
* @param int $default_items_per_page quantity of pages that we are going to see
* @param int $tablename Name of the table
* @param array $column_show An array with binary values 1: we show the column 2: we don't show it
* @param array $column_order An array of integers that let us decide how the columns are going to be sort.
*/
public function SortableTableFromArrayConfig($table_data, $default_column = 1, $default_items_per_page = 20, $tablename = 'tablename',$column_show=null,$column_order=null)
{
$this->column_show=$column_show;
$this->column_order=$column_order;
parent :: SortableTable($tablename, null, null, $default_column, $default_items_per_page,'ASC');
$this->table_data = $table_data;
}
/**
* Get table data to show on current page
* @see SortableTable#get_table_data
*/
public function get_table_data($from = 1)
{
$content = TableSort :: sort_table_config($this->table_data, $this->column, $this->direction == 'ASC' ? SORT_ASC : SORT_DESC ,$this->column_show, $this->column_order);
return array_slice($content, $from, $this->per_page);
}
/**
* Get total number of items
* @see SortableTable#get_total_number_of_items
*/
public function get_total_number_of_items()
{
return count($this->table_data);
}
}
?>

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Bart Mollet (bart.mollet@hogent.be)
@ -36,31 +36,31 @@ class TableSort
/**
* String to lowercase (keep accents).
* @param string $txt The string to convert
* @author René Haentjens
* @author Ren<EFBFBD> Haentjens
* This function is 8859-1 specific and should be adapted when Dokeos is
* used with other charsets.
*/
function strtolower_keepaccents($txt)
{
return strtolower(strtr($txt, "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ", "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ"));
return strtolower(strtr($txt, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
}
/**
* String to lowercase.
* @param string $txt The string to convert
* @author René Haentjens
* @author Ren<EFBFBD> Haentjens
* This function is 8859-1 specific and should be adapted when Dokeos is
* used with other charsets.
*/
function strtolower_eorlatin($txt)
{
return str_replace(array ("æ", "ß"), array ("ae", "ss"), strtr(TableSort::strtolower_keepaccents($txt), "àáâãäåçèéêëìíîïðñòóôõöøùúûüýÿ", "aaaaaaceeeeiiiidnoooooouuuuyy"));
// do not replace "þ" by "th", leave it at the end of the alphabet...
// do not replace any of "$&¢£¥©ª®µº", though they resemble letters...
return str_replace(array ("<EFBFBD>", "<EFBFBD>"), array ("ae", "ss"), strtr(TableSort::strtolower_keepaccents($txt), "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "aaaaaaceeeeiiiidnoooooouuuuyy"));
// do not replace "<EFBFBD>" by "th", leave it at the end of the alphabet...
// do not replace any of "$&<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", though they resemble letters...
}
/**
* Create a string to use in sorting.
* @param string $txt The string to convert
* @author René Haentjens
* @author Ren<EFBFBD> Haentjens
* This function is 8859-1 specific and should be adapted when Dokeos is
* used with other charsets.
* See http://anubis.dkuug.dk/CEN/TC304/EOR/eorhome.html
@ -69,7 +69,7 @@ class TableSort
*/
function orderingstring($txt)
{
return ereg_replace("[^0-9a-zþ]", "", TableSort::strtolower_eorlatin($txt));
return ereg_replace("[^0-9a-z<EFBFBD>]", "", TableSort::strtolower_eorlatin($txt));
}
/**
* Sort 2-dimensional table.
@ -101,7 +101,6 @@ class TableSort
{
return TableSort::sort_table($data, $column, $direction, SORT_NUMERIC);
}
return TableSort::sort_table($data, $column, $direction, SORT_STRING);
break;
case SORT_NUMERIC :
@ -130,13 +129,13 @@ class TableSort
* @author bart.mollet@hogent.be
*/
function is_numeric_column($data, $column)
{
{
$is_numeric = true;
foreach ($data as $index => $row)
{
$is_numeric &= is_numeric(strip_tags($row[$column]));
}
return $is_numeric;
}
}
/**
* Checks if a column of a 2D-array contains only dates (GNU date syntax)
@ -146,7 +145,7 @@ class TableSort
* @author bart.mollet@hogent.be
*/
function is_date_column($data, $column)
{
{
$is_date = true;
foreach ($data as $index => $row)
{
@ -182,5 +181,104 @@ class TableSort
}
return $is_image;
}
/**
* Sort 2-dimensional table. It is possile of change the columns that will be show and the way that the columns are sorted.
* @param array $data The data to be sorted.
* @param int $column The column on which the data should be sorted (default = 0)
* @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC)
* @param array $column_show The columns that we will show in the table i.e: $column_show=array('1','0','1') we will show the 1st and the 3th column.
* @param array $column_order Changes how the columns will be sorted ie. $column_order=array('1','4','3','4') The 2nd column will be sorted like the 4 column
* @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC,SORT_STRING,SORT_DATE,SORT_IMAGE) *
* @return array The sorted dataset
* @author bart.mollet@hogent.be
*/
function sort_table_config($data, $column = 0, $direction = SORT_ASC, $column_show=null, $column_order=null,$type = SORT_REGULAR)
{
if(!is_array($data) || count($data)==0)
{
return array();
}
// Change columns sort
// Here we say that the real way of how the columns are going to be order is manage by the $column_order array
if(is_array($column_order))
{
for($i=0;$i<count($column_order);$i++)
{
if ($column== $i+1)
{
$column=$column_order[$i];
}
}
}
switch ($type)
{
case SORT_REGULAR :
if (TableSort::is_image_column($data, $column))
{
return TableSort::sort_table_config($data, $column, $direction, $column_show, $column_order,SORT_IMAGE);
}
elseif (TableSort::is_date_column($data, $column))
{
return TableSort::sort_table_config($data, $column, $direction, $column_show, $column_order,SORT_DATE);
}
elseif (TableSort::is_numeric_column($data, $column))
{
return TableSort::sort_table_config($data, $column, $direction, $column_show, $column_order,SORT_NUMERIC);
}
return TableSort::sort_table_config($data, $column, $direction, $column_show, $column_order,SORT_STRING);
break;
case SORT_NUMERIC :
$compare_function = 'strip_tags($el1) > strip_tags($el2)';
break;
case SORT_STRING :
$compare_function = 'strnatcmp(TableSort::orderingstring(strip_tags($el1)),TableSort::orderingstring(strip_tags($el2))) > 0';
break;
case SORT_IMAGE :
$compare_function = 'strnatcmp(TableSort::orderingstring(strip_tags($el1,"<img>")),TableSort::orderingstring(strip_tags($el2,"<img>"))) > 0';
break;
case SORT_DATE :
$compare_function = 'strtotime(strip_tags($el1)) > strtotime(strip_tags($el2))';
}
$function_body = '$el1 = $a['.$column.']; ' .
'$el2 = $b['.$column.']; ' .
'return ('.$direction.' == SORT_ASC ? ('.$compare_function.') : !('.$compare_function.'));';
// Sort the content
usort($data, create_function('$a,$b', $function_body));
// We show only the columns data that were set up on the $column_show array
$new_order_data=array();
if(is_array($column_show))
{
for ($j=0;$j<count($data);$j++)
{
$k=0;
for ($i=0;$i<count($column_show);$i++)
{
if ($column_show[$i])
{
$new_order_data[$j][$k]=$data[$j][$i];
}
$k++;
}
}
//replace the multi-arrays
$data=$new_order_data;
}
else
{
return $data;
}
return $data;
}
}
?>

@ -1,9 +1,9 @@
<?php // $Id: text.lib.php 9246 2006-09-25 13:24:53Z bmol $
<?php // $Id: text.lib.php 14637 2008-03-17 22:44:52Z juliomontoya $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
@ -75,7 +75,7 @@ function make_clickable($string)
* formats the date according to the locale settings
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Christophe Gesché <gesche@ipm.ucl.ac.be>
* @author Christophe Gesch<EFBFBD> <gesche@ipm.ucl.ac.be>
* originally inspired from from PhpMyAdmin
* @param string $formatOfDate date pattern
* @param integer $timestamp, default is NOW.
@ -278,4 +278,132 @@ function latex_gif_renderer($latex_code)
$return .= '<img src="'.api_get_path(WEB_COURSE_PATH).$_course['path'].'/temp/'.$latex_filename.'" alt="'.$latex_code.'" border="0" /></a>';
return $return;
}
/**
* This function returns the difference between the current date (date(now)) with the parameter $date in a string format like "2 days, 1 hour"
* Example: $date="2008-03-07 15:44:08";
* date_to_str($date) it will return 3 days, 20 hours
*
* @param string This string has to be the result of a date function in this format -> date("Y-m-d H:i:s",time());
* @return string The difference between the current date and the parameter in a literal way "3 days, 2 hour" *
* @author Julio Montoya
*/
function date_to_str_ago($date)
{
$dst_date=strtotime($date);
//for not call date several times
$date_array=date("s/i/G/j/n/Y",$dst_date);
$date_split=explode("/",$date_array);
$dst_s=$date_split[0];
$dst_m=$date_split[1];
$dst_h=$date_split[2];
$dst_day=$date_split[3];
$dst_mth=$date_split[4];
$dst_yr=$date_split[5];
$dst_date = mktime($dst_h,$dst_m,$dst_s,$dst_mth,$dst_day,$dst_yr);
$time=$offset = time()-$dst_date; //seconds between current days and today
//------------ Here start the functions sec_to_str
$act_day=date('d');
$act_mth=date('n');
$act_yr = date('Y');
if ($dst_day==$act_day && $dst_mth==$act_mth && $dst_yr == $act_yr )
{
return ucfirst(get_lang('Today'));
}
if ($dst_day==$act_day-1 && $dst_mth==$act_mth && $dst_yr == $act_yr )
{
return ucfirst(get_lang('Yesterday'));
}
// original 1
//$sec_time=array("century"=>3.1556926*pow(10,9),"decade"=>315569260,"year"=>31556926,"month"=>2629743.83,"week"=>604800,"day"=>86400,"hour"=>3600,"minute"=>60,"second"=>1);
//$sec_time=array(get_lang('MinDecade')=>315569260,get_lang('MinYear')=>31556926,get_lang('MinMonth')=>2629743.83,get_lang('MinWeek')=>604800,get_lang('MinDay')=>86400,get_lang('MinHour')=>3600,get_lang('MinMinute')=>60);
$MinDecade=get_lang('MinDecade');
$MinYear=get_lang('MinYear');
$MinMonth=get_lang('MinMonth');
$MinWeek=get_lang('MinWeek');
$MinDay=get_lang('MinDay');
$MinHour=get_lang('MinHour');
$MinMinute=get_lang('MinMinute');
$MinDecades=get_lang('MinDecades');
$MinYears=get_lang('MinYears');
$MinMonths=get_lang('MinMonths');
$MinWeeks=get_lang('MinWeeks');
$MinDays=get_lang('MinDays');
$MinHours=get_lang('MinHours');
$MinMinutes=get_lang('MinMinutes');
$sec_time_time=array(315569260,31556926,2629743.83,604800,86400,3600,60);
$sec_time_sing=array($MinDecade,$MinYear,$MinMonth,$MinWeek,$MinDay,$MinHour,$MinMinute);
$sec_time_plu =array($MinDecades,$MinYears,$MinMonths,$MinWeeks,$MinDays,$MinHours,$MinMinutes);
$str_result=array();
$time_result=array();
$key_result=array();
$str='';
$i=0;
for ($i=0;$i<count($sec_time_time);$i++)
{
$seconds=$sec_time_time[$i];
if($seconds > $time) {
continue;
}
$current_value=intval($time/$seconds);
if ($current_value!='1')
{
$date_str= $sec_time_plu[$i];
}
else
{
$date_str= $sec_time_sing[$i];
}
$key_result[]=$sec_time_sing[$i];
$str_result[]=$current_value.' '.$date_str;
$time_result[]= $current_value;
$str.=$current_value.$date_str;
$time%=$seconds;
}
if ($key_result[0]== $MinDay && $key_result[1]== $MinMinute)
{
$key_result[1]=' 0 '.$MinHours;
$str_result[0]=$time_result[0].' '.$key_result[0];
$str_result[1]=$key_result[1];
}
if ($key_result[0]== $MinYear && ($key_result[1]== $MinDay || $key_result[1]== $MinWeek))
{
$key_result[1]=' 0 '.$MinMonths;
$str_result[0]=$time_result[0].' '.$key_result[0];
$str_result[1]=$key_result[1];
}
if (!empty($str_result[1]))
{
$str=$str_result[0].', '.$str_result[1];
}
else
{
$str=$str_result[0];
}
return $str;
}
?>
Loading…
Cancel
Save