diff --git a/main/wiki/index.php b/main/wiki/index.php
index 1db294413e..7f15714eda 100644
--- a/main/wiki/index.php
+++ b/main/wiki/index.php
@@ -35,8 +35,7 @@ require_once (api_get_path(LIBRARY_PATH).'events.lib.inc.php');
require_once (api_get_path(LIBRARY_PATH).'security.lib.php');
require_once(api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php');
require_once(api_get_path(INCLUDE_PATH).'conf/mail.conf.php');
-
-
+require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
/*
-----------------------------------------------------------
ADDITIONAL STYLE INFORMATION
@@ -543,38 +542,67 @@ if ($_GET['action']=='mvisited')
echo '
';
echo ''.get_lang('MostVisitedPages').'
';
echo '
';
-
- if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
- {
- $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY tsum DESC, reflink LIMIT 10'; //first ten pages
- }
- else
- {
- $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink ORDER BY tsum DESC, reflink LIMIT 10'; //first ten pages
- }
+ if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
+ {
+ $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY tsum DESC, reflink';
+ }
+ else
+ {
+ $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink ORDER BY tsum DESC, reflink';
+ }
$allpages=api_sql_query($sql,__FILE__,__LINE__);
- echo '';
- while ($row=Database::fetch_array($allpages))
+
+ //show table
+ if (mysql_num_rows($allpages) > 0)
{
- //fix assignment icon
- if($row['assignment']==1)
- {
- $ShowAssignment='';
- }
- elseif ($row['assignment']==2)
+ $row = array ();
+ while ($obj = mysql_fetch_object($allpages))
{
- $ShowAssignment='';
+ //get author
+ $userinfo=Database::get_user_info_from_id($obj->user_id);
+
+ //get time
+ $year = substr($obj->timestamp, 0, 4);
+ $month = substr($obj->timestamp, 5, 2);
+ $day = substr($obj->timestamp, 8, 2);
+ $hours = substr($obj->timestamp, 11,2);
+ $minutes = substr($obj->timestamp, 14,2);
+ $seconds = substr($obj->timestamp, 17,2);
+
+ //get type assignment icon
+ if($obj->assignment==1)
+ {
+ $ShowAssignment='';
+ }
+ elseif ($obj->assignment==2)
+ {
+ $ShowAssignment='';
+ }
+ elseif ($obj->assignment==0)
+ {
+ $ShowAssignment='';
+ }
+
+ $row = array ();
+ $row[] =$ShowAssignment;
+ $row[] = ''.$obj->title.'';
+ $row[] =''.$userinfo['lastname'].', '.$userinfo['firstname'].'';
+ $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds;
+ $row[] = $obj->tsum;
+ $rows[] = $row;
}
- elseif ($row['assignment']==0)
- {
- $ShowAssignment='';
- }
- echo '- '.$ShowAssignment.''.$row['title'].' '.get_lang('With').' '.$row['tsum'].' '.get_lang('Visits').'
'; //TODO:check if hidden and assignment mode
- }
- echo '
';
+ $table = new SortableTableFromArrayConfig($rows,4,10,'MostVisitedPages_table','','','DESC');
+ $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_GET['action'],'group_id'=>Security::remove_XSS($_GET['group_id'])));
+ $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
+ $table->set_header(1,get_lang('Title'), true);
+ $table->set_header(2,get_lang('Author'), true);
+ $table->set_header(3,get_lang('Date'), true);
+ $table->set_header(4,get_lang('Visits'), true);
+ $table->display();
+ }
}
/////////////////////// Wanted pages /////////////////////// Juan Carlos RaƱa Trabado
@@ -1051,7 +1079,7 @@ if ($_GET['action']=='edit')
//Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher
- if(($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit() || !api_is_platform_admin()))
+ if(($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit()))
{
Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));