From ddf5e51eb841c7ed2f6b37c75bc8223ca8716d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Fri, 10 Oct 2008 00:13:49 +0200 Subject: [PATCH] [svn r16482] fix tables into most visited pages add tables to all pages and search --- main/wiki/index.php | 294 ++++++++++++++++++++++---------------------- 1 file changed, 148 insertions(+), 146 deletions(-) diff --git a/main/wiki/index.php b/main/wiki/index.php index 7f15714eda..e9ff41ffad 100644 --- a/main/wiki/index.php +++ b/main/wiki/index.php @@ -544,12 +544,12 @@ if ($_GET['action']=='mvisited') 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'; + { + $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink'; // warning GROUP BY reflink don't return the last version, always the first id } else { - $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink ORDER BY tsum DESC, reflink'; + $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink'; // warning GROUP BY reflink don't return the last version, always the first id } $allpages=api_sql_query($sql,__FILE__,__LINE__); @@ -560,17 +560,6 @@ if ($_GET['action']=='mvisited') $row = array (); while ($obj = mysql_fetch_object($allpages)) { - //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) { @@ -588,19 +577,15 @@ if ($_GET['action']=='mvisited') $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; } - $table = new SortableTableFromArrayConfig($rows,4,10,'MostVisitedPages_table','','','DESC'); + $table = new SortableTableFromArrayConfig($rows,2,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->set_header(1,get_lang('Title'), true); + $table->set_header(2,get_lang('Visits'), true); $table->display(); } } @@ -619,7 +604,8 @@ if ($_GET['action']=='wanted') //get name pages $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY reflink ASC'; - $allpages=api_sql_query($sql,__FILE__,__LINE__); + $allpages=api_sql_query($sql,__FILE__,__LINE__); + while ($row=Database::fetch_array($allpages)) { $pages[] = $row['reflink']; @@ -798,103 +784,110 @@ if ($_GET['action']=='deletewiki') /////////////////////// search pages /////////////////////// Juan Carlos Raña Trabado +//// 1 Searchpages: input search if ($_GET['action']=='searchpages') { echo '
'; echo ''.$SearchPages.''; echo '
'; - + if (!$_POST['Skeyword']) { - echo '
'; + echo ''; echo ''; echo '

'; echo ' '.get_lang('AlsoSearchContent'); echo '
'; } - else - { +} + +//// 2 SearchPages: find and show pages + +if ($_GET['action']=='showsearchpages') +{ + echo '
'; + echo ''.$Search.': '.$_POST['Skeyword']; //TODO: post is lost when a table has some pages + echo '
'; + + $_clean['group_id']=(int)$_SESSION['_gid']; + + if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden + { if($_POST['Scontent']=="1") { - $sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' OR content LIKE '%".$_POST['Skeyword']."%' GROUP BY reflink ORDER BY title ASC"; + $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' OR content LIKE '%".$_POST['Skeyword']."%' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink)";// warning don't use group by reflink because don't return the last version } else { - $sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' GROUP BY reflink ORDER BY title ASC"; + $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink)";// warning don't use group by reflink because don't return the last version } - - //show result - $_clean['group_id']=(int)$_SESSION['_gid']; - $result=api_sql_query($sql,__LINE__,__FILE__); + } + else + { + if($_POST['Scontent']=="1") + { - echo ''; - } -} + elseif ($obj->assignment==2) + { + $ShowAssignment=''.get_lang('AssignmentWork').''; + } + elseif ($obj->assignment==0) + { + $ShowAssignment=''; + } + + $row = array (); + $row[] =$ShowAssignment; + $row[] = ''.$obj->title.''; + $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; + $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; + $rows[] = $row; + } + + $table = new SortableTableFromArrayConfig($rows,1,10,'SearchPages_table','','','ASC'); + $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->display(); + } +} /////////////////////// What links here. Show pages that have linked this page /////////////////////// Juan Carlos Raña Trabado @@ -1493,66 +1486,75 @@ if ($_GET['action']=='recentchanges') if ($_GET['action']=='allpages') -{ - $_clean['group_id']=(int)$_SESSION['_gid']; - - $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY title ASC'; //tasks grouped by reflink instead of tilte, because there may be pages with the same name but with different reflink. This is true of the tasks - - $result=api_sql_query($sql,__LINE__,__FILE__); - - echo '
'; +{ + echo '
'; echo ''.get_lang('AllPages').''; - echo '
'; + echo '
'; - echo ''; + + $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC'); + $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->display(); + } } - - - /////////////////////// discuss pages ///////////////////////