";
if ($_GET['action']=='more')
{
- echo '
';
- echo '
'.get_lang('More').'';
- echo '
';
+
+ echo '
'.get_lang('More').'
';
if(api_is_allowed_to_edit() || api_is_platform_admin())
{
@@ -529,9 +503,7 @@ if ($_GET['action']=='more')
if ($_GET['action']=='mactiveusers')
{
- echo '
';
- echo '
'.get_lang('MostActiveUsers').'';
- echo '
';
+ echo '
'.get_lang('MostActiveUsers').'
';
$sql='SELECT *, COUNT(*) AS NUM_EDIT FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY user_id';
$allpages=api_sql_query($sql,__FILE__,__LINE__);
@@ -545,8 +517,8 @@ if ($_GET['action']=='mactiveusers')
$userinfo=Database::get_user_info_from_id($obj->user_id);
$row = array ();
- $row[] = $obj->user_id <>0 ? '
'.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')';
- $row[] ='
'.$obj->NUM_EDIT.'';
+ $row[] = $obj->user_id <>0 ? '
'.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')';
+ $row[] ='
'.$obj->NUM_EDIT.'';
$rows[] = $row;
}
@@ -564,9 +536,8 @@ if ($_GET['action']=='mactiveusers')
if ($_GET['action']=='usercontrib')
{
$userinfo=Database::get_user_info_from_id(Security::remove_XSS($_GET['user_id']));
- echo '
';
- echo '
'.get_lang('UserContributions').': '.$userinfo['lastname'].', '.$userinfo['firstname'].'';
- echo '
';
+
+ echo '
';
if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
@@ -615,7 +586,7 @@ if ($_GET['action']=='usercontrib')
$row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds;
$row[] =$ShowAssignment;
- $row[] = '
'.$obj->title.'';
+ $row[] = '
'.$obj->title.'';
$row[] =$obj->version;
$row[] =$obj->comment;
//$row[] =strlen($obj->comment)>30 ? substr($obj->comment,0,30).'...' : $obj->comment;
@@ -653,9 +624,7 @@ if ($_GET['action']=='usercontrib')
if ($_GET['action']=='mostchanged')
{
- echo '
';
- echo '
'.get_lang('MostChangedPages').'';
- echo '
';
+ echo '
'.get_lang('MostChangedPages').'
';
if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
@@ -691,7 +660,7 @@ if ($_GET['action']=='mostchanged')
$row = array ();
$row[] =$ShowAssignment;
- $row[] = '
'.$obj->title.'';
+ $row[] = '
'.$obj->title.'';
$row[] = $obj->MAX;
$rows[] = $row;
}
@@ -710,9 +679,7 @@ if ($_GET['action']=='mostchanged')
if ($_GET['action']=='mvisited')
{
- echo '
';
- echo '
'.get_lang('MostVisitedPages').'';
- echo '
';
+ echo '
'.get_lang('MostVisitedPages').'
';
if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
{
@@ -747,7 +714,7 @@ if ($_GET['action']=='mvisited')
$row = array ();
$row[] =$ShowAssignment;
- $row[] = '
'.$obj->title.'';
+ $row[] = '
'.$obj->title.'';
$row[] = $obj->tsum;
$rows[] = $row;
}
@@ -765,9 +732,8 @@ if ($_GET['action']=='mvisited')
if ($_GET['action']=='wanted')
{
- echo '
';
- echo '
'.get_lang('WantedPages').'';
- echo '
';
+ echo '
'.get_lang('WantedPages').'
';
+
$pages = array();
$refs = array();
$sort_wanted=array();
@@ -816,9 +782,7 @@ if ($_GET['action']=='wanted')
if ($_GET['action']=='orphaned')
{
- echo '
';
- echo '
'.get_lang('OrphanedPages').'';
- echo '
';
+ echo '
'.get_lang('OrphanedPages').'
';
$pages = array();
$refs = array();
@@ -888,7 +852,7 @@ if ($_GET['action']=='orphaned')
$ShowAssignment='

';
}
- echo '
'.$ShowAssignment.''.$row['title'].'';
+ echo '
'.$ShowAssignment.''.$row['title'].'';
}
echo '';
}
@@ -902,9 +866,7 @@ if ($_GET['action']=='delete')
if(api_is_allowed_to_edit() || api_is_platform_admin())
{
- echo '
';
- echo '
'.get_lang('DeletePageHistory').'';
- echo '
';
+ echo '
'.get_lang('DeletePageHistory').'
';
if($page=="index")
{
@@ -945,116 +907,55 @@ if ($_GET['action']=='delete')
if ($_GET['action']=='deletewiki')
{
- echo '
';
- echo '
'.get_lang('DeleteWiki').'';
- echo '
';
-}
+ echo '
'.get_lang('DeleteWiki').'
';
-
-/////////////////////// search pages /////////////////////// Juan Carlos Ra�a Trabado
-//// 1 Searchpages: input search
-
-if ($_GET['action']=='searchpages')
-{
- echo '
';
- echo '
'.$SearchPages.'';
- echo '
';
-
- if (!$_POST['Skeyword'])
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
{
- echo '
';
- }
-}
-
-//// 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 '
';
+ $message = get_lang('ConfirmDeleteWiki');
+ $message .= '
+ '.get_lang('No').'
+ |
+ '.get_lang('Yes').'
+
';
- $_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." 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
+ if (!isset($_GET['delete']))
{
- $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
- }
+ Display::display_warning_message($message,false);
}
- else
- {
- if($_POST['Scontent']=="1")
- {
-
- $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND visibility=1 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." s1 WHERE ".$groupfilter." AND visibility=1 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
- }
+ Display::display_normal_message(get_lang("OnlyAdminDeleteWiki"));
}
+}
- $result=api_sql_query($sql,__LINE__,__FILE__);
-
- //show table
- if (mysql_num_rows($result) > 0)
- {
- $row = array ();
- while ($obj = mysql_fetch_object($result))
- {
- //get author
- $userinfo=Database::get_user_info_from_id($obj->user_id);
+/////////////////////// search wiki pages ///////////////////////
+if ($_GET['action']=='searchpages')
+{
+ // initiate the object
+ $form = new FormValidator('wiki_search','post', api_get_self().'?cidReq='.Security::remove_XSS($_GET['cidReq']).'&action='.Security::remove_XSS($_GET['action']).'&group_id='.Security::remove_XSS($_GET['group_id']));
+
+ // settting the form elements
+ $form->addElement('header', '', get_lang('SearchPages'));
+ $form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"');
+ $form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent'));
+ $form->addElement('style_submit_button', 'SubmitWikiSearch', get_lang('Search'), 'class="search"');
- //get time
- $year = substr($obj->dtime, 0, 4);
- $month = substr($obj->dtime, 5, 2);
- $day = substr($obj->dtime, 8, 2);
- $hours = substr($obj->dtime, 11,2);
- $minutes = substr($obj->dtime, 14,2);
- $seconds = substr($obj->dtime, 17,2);
+ // setting the rules
+ $form->addRule('search_term', '
'.get_lang('ThisFieldIsRequired'), 'required');
+ $form->addRule('search_term', get_lang('TooShort'),'minlength',3);
- //get type assignment icon
- if($obj->assignment==1)
- {
- $ShowAssignment='

';
- }
- elseif ($obj->assignment==2)
+ if ($form->validate())
{
- $ShowAssignment='

';
+ $form->display();
+ $values = $form->exportValues();
+ display_wiki_search_results($values['search_term'], $values['search_content']);
}
- elseif ($obj->assignment==0)
+ else
{
- $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;
+ $form->display();
}
- $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();
- }
}
@@ -1062,13 +963,12 @@ if ($_GET['action']=='showsearchpages')
if ($_GET['action']=='links')
{
- echo '
';
- echo '
'.$LinksPages.'';
- echo '
';
+
if (!$_GET['title'])
{
- Display::display_normal_message(get_lang("MustSelectPage"));
+ echo '
';
+ Display::display_error_message(get_lang("MustSelectPage"));
}
else
{
@@ -1099,7 +999,9 @@ if ($_GET['action']=='links')
$page='index';
}
- echo $LinksPagesFrom.': '.$ShowAssignment.'
'.$row['title'].'';
+ echo '
';
//fix index to title Main page into linksto
if ($page=='index')
@@ -1153,7 +1055,7 @@ if ($_GET['action']=='links')
$row = array ();
$row[] =$ShowAssignment;
- $row[] = '
'.$obj->title.'';
+ $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;
@@ -1193,16 +1095,18 @@ if ($_GET['action']=='addnew')
elseif (check_addnewpagelock() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false))
{
- Display::display_normal_message(get_lang('AddPagesLocked'));
+ Display::display_error_message(get_lang('AddPagesLocked'));
}
else
{
if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']) || Security::remove_XSS($_GET['group_id'])==0)
{
- echo '
';
- echo '
'.get_lang('AddNew').'';
- echo '
';
+ echo '
';
+ echo '';
+ echo '
';
+ echo '
';
display_new_wiki_form();
+ echo '
';
}
else
{
@@ -1239,13 +1143,23 @@ if ($_GET['action']=='edit')
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
+ if ($row['content']=='' AND $row['title']=='' AND $page='index')
+ {
+ $content=sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH));
+ $title=get_lang('DefaultTitle');
+ }
+ else
+ {
+ $content=$row['content'];
+ $title=$row['title'];
+ }
+ echo '
';
+ echo $icon_assignment.' '.$title.'
';
//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()))
{
-
- Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));
-
+ Display::display_error_message(get_lang('OnlyEditPagesCourseManager'));
}
else
{
@@ -1304,20 +1218,9 @@ if ($_GET['action']=='edit')
}
else
{
- if ($row['content']=='' AND $row['title']=='' AND $page='index')
- {
- $content=sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH));
- $title=get_lang('DefaultTitle');
- }
- else
- {
- $content=$row['content'];
- $title=$row['title'];
- }
- echo '
';
- echo $icon_assignment.' '.$title.'
';
+
echo '