@@ -1,43 +1,41 @@
< ? php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20> Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/frontpage.php,v $
| $Revision: 1.7 $
| $Date: 2008-11-14 06:01:06 $
| $Author: e107coders $
|
+----------------------------------------------------------------------------+
* e107 website system
*
* Copyright (C) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Administration Area - Front page
*
* $Source: /cvs_backup/e107_0.8/e107_admin/frontpage.php,v $
* $Revision: 1.8 $
* $Date: 2008-12-15 13:31:01 $
* $Author: secretr $
*
*/
require_once ( '../class2.php' );
if ( ! getperms ( 'G' ))
{
header ( 'location:' . e_BASE . 'index.php' );
exit ;
exit () ;
}
$e_sub_cat = 'frontpage' ;
require_once ( 'auth.php' );
require_once ( e_HANDLER . 'form_handler.php' );
$rs = new form ;
require_once ( e_HANDLER . " message_handler.php " ) ;
$rs = new form ();
$frm = new e_form ();
$emessage = & eMessage :: getInstance ();
require_once ( e_HANDLER . 'userclass_class.php' );
// Get list of possible options for front page
$front_page [ 'news' ] = array ( 'page' => 'news.php' , 'title' => ADLAN_0 );
$front_page [ 'download' ] = array ( 'page' => 'download.php' , 'title' => ADLAN_24 );
$front_page [ 'wmessage' ] = array ( 'page' => 'index.php' , 'title' => ADLAN_28 );
if ( $sql -> db_Select ( " page " , " * " , " page_theme='' " ))
{
$front_page [ 'custom' ][ 'title' ] = 'Custom Page' ;
@@ -56,7 +54,6 @@ foreach($pref['e_frontpage_list'] as $val)
}
}
// Now sort out list of rules for display (based on $pref data to start with)
$gotpub = FALSE ;
if ( is_array ( $pref [ 'frontpage' ]))
@@ -89,7 +86,6 @@ if (!$gotpub)
$fp_update_prefs = FALSE ;
if ( isset ( $_POST [ 'fp_inc' ]))
{
$mv = intval ( $_POST [ 'fp_inc' ]);
@@ -115,7 +111,6 @@ elseif (isset($_POST['fp_dec']))
}
}
// Edit an existing rule
if ( isset ( $_POST [ 'fp_edit_rule' ]))
{
@@ -123,12 +118,9 @@ if (isset($_POST['fp_edit_rule']))
$_POST [ 'class' ] = key ( $_POST [ 'edit' ]);
}
// Cancel Edit
if ( isset ( $_POST [ 'fp_save_new' ]))
{ // Add or edit an existing rule here.
// fp_order - zero for a new rule, non-zero if editing an existing rule
@@ -181,7 +173,8 @@ if (isset($_POST['fp_save_new']))
$ind = 0 ;
for ( $i = 1 ; $i <= count ( $fp_settings ); $i ++ )
{
if ( $fp_settings [ $i ][ 'class' ] == $temp [ 'class' ]) $ind = $i ;
if ( $fp_settings [ $i ][ 'class' ] == $temp [ 'class' ])
$ind = $i ;
}
if ( $ind )
{
@@ -202,7 +195,8 @@ if (isset($_POST['fp_save_new']))
}
else
{ // Someone playing games
$ns -> tablerender( LAN_UPDATED, " <div style='text-align:center'><b>" . " Software error" . " </b></div>" );
//$ns-> tablerender( LAN_UPDATED, " <div style='text-align:center'><b>"." Software error"." </b></div>" );
$emessage -> add ( 'Software error' , E_MESSAGE_ERROR );
}
}
@@ -224,7 +218,6 @@ if (isset($_POST['fp_delete_rule']))
}
}
if ( $fp_update_prefs )
{ // Save the two arrays
$fp_list = array ();
@@ -240,7 +233,9 @@ if ($fp_update_prefs)
$pref [ 'frontpage' ] = $fp_list ;
$pref [ 'frontpage_force' ] = $fp_force ;
save_prefs ();
$ns -> tablerender( LAN_UPDATED, " <div style='text-align:center'><b>" . FRTLAN_1 . " </b></div>" );
//$ns-> tablerender( LAN_UPDATED, " <div style='text-align:center'><b>".FRTLAN_1." </b></div>" );
$emessage -> add ( FRTLAN_1 , E_MESSAGE_SUCCESS );
// }
// else
// {
@@ -248,7 +243,6 @@ if ($fp_update_prefs)
// }
}
/* For reference:
define("e_UC_PUBLIC", 0);
define("e_UC_MAINADMIN", 250);
@@ -259,140 +253,189 @@ define("e_UC_ADMIN", 254);
define("e_UC_NOBODY", 255);
*/
$fp = new frontpage ;
$fp = new frontpage () ;
if ( isset ( $_POST [ 'fp_add_new' ]))
{
$fp -> edit_rule ( array ( 'order' => 0 , 'class' => e_UC_PUBLIC , 'page' => 'news.php' , 'force' => FALSE )); // Display edit form as well
$fp -> select_class ( FALSE );
$text = $fp -> edit_rule ( array ( 'order' => 0 , 'class' => e_UC_PUBLIC , 'page' => 'news.php' , 'force' => FALSE )); // Display edit form as well
$text .= $fp -> select_class ( FALSE );
$e107 -> ns -> tablerender ( FRTLAN_PAGE_TITLE . " - " . FRTLAN_42 , $text );
}
elseif ( isset ( $_POST [ 'fp_edit_rule' ]))
{
$fp -> edit_rule ( $fp_settings [ key ( $_POST [ 'fp_edit_rule' ])]); // Display edit form as well
$fp -> select_class ( FALSE );
$text = $fp -> edit_rule ( $fp_settings [ key ( $_POST [ 'fp_edit_rule' ])]); // Display edit form as well
$text .= $fp -> select_class ( FALSE );
$e107 -> ns -> tablerender ( FRTLAN_PAGE_TITLE . " - " . FRTLAN_46 , $text );
}
else
{ // Just show existing rules
$fp -> select_class ( TRUE );
$e107 -> ns -> tablerender ( FRTLAN_PAGE_TITLE . " - " . FRTLAN_13 , $fp -> select_class ( TRUE )) ;
}
class frontpage
{
function select_class ( $show_button = TRUE )
{ // Display existing data
global $fp_settings , $rs , $ns , $front_page , $imod e ;
global $fp_settings , $frm , $emessag e ;
//Inline Page Help Info - system message for now
//TODO - inline tooltip help system
$emessage -> add ( FRTLAN_38 . " . " . FRTLAN_39 . " . " . FRTLAN_41 . " . " );
// List of current settings
$text = " <div style='text-align:center'>
$show_legend = $show_button ? " class='e-hideme' " : '' ;
$text = "
<form method='post' action=' " . e_SELF . " '>
<table style=' " . ADMIN_WIDTH . " ' class='fborder '>
<colgroup >
<fieldset id='frontpage-settings '>
<legend { $show_legend } > " . FRTLAN_13 . " </legend >
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='5'>
<col style='width: 5%' />
<col style='width: 25%' />
<col style='width: 30%' />
<col style='width: 30%' />
<col style='width: 10%' />
</colgroup>
<tr><td class='forumheader3' colspan='5' style='text-align:center'> " . FRTLAN_38 . " <br /> " . FRTLAN_39 . " <br /> " . FRTLAN_41 . " </td></tr >
<thead >
<tr>
<td class='fcaption '> " . FRTLAN_40 . " </td >
<td class='fcaption' > " . FRTLAN_53 . " </td >
<td class='fcaption' > " . FRTLAN_49 . " </td >
<td class='fcaption' > " . FRTLAN_35 . " </td >
<td class='fcaption' style='text-align: center'> " . LAN_EDIT . " </td >
</tr>" ;
<th class='first '>" . FRTLAN_40 . " </th >
<th > " . FRTLAN_53 . " </th >
<th > " . FRTLAN_49 . " </th >
<th > " . FRTLAN_35 . " </th >
<th class='center last '>" . LAN_EDIT . " </th >
</tr>
</thead>
<tbody> " ;
foreach ( $fp_settings as $order => $current_value )
{
$title = r_userclass_name ( $current_value [ 'class' ]);
$text .= " <tr><td class='forumheader3'> " . $order . " </td>
<td class='forumheader3'> " . $title . " </td >
<td class='forumheader3'> " . $this -> lookup_path ( $current_value [ 'page' ]) . " </td>
<td class='forumheader3'> " . $this -> lookup_path ( $current_value [ 'force' ]) . " </td>
<td class='forumheader3' style='text-align:center' >
<input type='image' src=' " . e_IMAGE . " admin_images/up.png' title=' " . FRTLAN_47 . " ' value=' " . $order . " ' name='fp_inc' / >
<input type='image' src=' " . e_IMAGE . " admin_images/down.png' title=' " . FRTLAN_48 . " ' value=' " . $order . " ' name='fp_dec' / >
<input type='image' title =' " . LAN_EDIT . " ' name='fp_edit_rule[ " . $order . " ] ' src ='" . ADMIN_EDIT_ICON_PATH . " ' />
<input type='image' title =' " . LAN_DELETE . " ' name='fp_delete_rule[ " . $order . " ] ' src ='" . ADMIN_DELETE_ICON_PATH . " ' />
$text .= "
<tr >
<td class='right'> " . $order . " </td>
<td> " . $title . " </td>
<td> " . $this -> lookup_path ( $current_value [ 'page' ]) . " </td >
<td> " . $this -> lookup_path ( $current_value [ 'force' ]) . " </td >
<td class='center' >
<input class='image' type='image' src =' " . e_IMAGE_ABS . " admin_images/up.png' title=' " . FRTLAN_47 . " ' value =' " . $order . " ' name='fp_inc ' />
<input class='image' type='image' src =' " . e_IMAGE_ABS . " admin_images/down.png' title=' " . FRTLAN_48 . " ' value =' " . $order . " ' name='fp_dec ' />
<input class='image edit' type='image' title=' " . LAN_EDIT . " ' name='fp_edit_rule[ " . $order . " ]' src=' " . ADMIN_EDIT_ICON_PATH . " ' />
<input class='image delete' type='image' title=' " . LAN_DELETE . " ' name='fp_delete_rule[ " . $order . " ]' src=' " . ADMIN_DELETE_ICON_PATH . " ' />
</td>
</tr> " ;
}
$text .= "
</tbody>
</table> " ;
if ( $show_button )
{
$text .= " <tr><td colspan='5' style='text-align: center' class='forumheader'>
" . $rs -> form_button ( 'submit' , 'fp_add_new' , FRTLAN_42 ) . " </td></tr> " ;
}
$text .= " </table></form> </div> " ;
$ns -> tablerender ( FRTLAN_33 , $text );
$text .= "
<div class='buttons-bar center'>
" . $frm -> admin_button ( 'fp_add_new' , FRTLAN_42 , 'create' ) . "
</div>" ;
}
$text .= "
</fieldset>
</form> " ;
return ( $show_button ? $emessage -> render () : '' ) . $text ;
}
function edit_rule ( $rule_info )
{ // Display form to add/edit rules
global $front_page , $rs , $ns ;
global $front_page , $frm ;
// $rule_info contains existing data as an array, or a set of defaults otherwise ('order', 'class', 'page', 'force')
$is_other_home = TRUE ;
$is_other_force = TRUE ;
$force_checked = $rule_info[ 'force'] ? " checked='checked'" : '' ;
$text = " <div style='text-align:center'>
<form method='post' action=' " . e_SELF . " '>
<table style=' " . ADMIN_WIDTH . " ' class='fborder'>
<colgroup>
<col style='width: 4%' />
<col style='width: 24%' />
<col style='width: 24%' />
<col style='width: 4%' />
<col style='width: 4%' />
<col style='width: 24%' />
<col style='width: 24%' />
</colgroup>
<tr><td colspan='7' class='fcaption' style='text-align:center;'> " . ( $rule_info [ 'order' ] ? FRTLAN_46 : FRTLAN_42 ) . " </td></tr>
<tr>
<td class='forumheader3' style='text-align:center' colspan='7'>
" . FRTLAN_43 . r_userclass ( 'class' , $rule_info [ 'class' ], 'off' , 'public,guest,member,admin,main,classes' ) . " </td>
</tr><tr><td colspan='3' class='fcaption' style='text-align:center;'> " . FRTLAN_49 . " </td><td> </td>
<td colspan='3' class='fcaption' style='text-align:center;'> " . FRTLAN_35 . " <br /> " . FRTLAN_50 . " </td></tr> " ;
// $force_checked = $rule_info[ 'force'] ? " checked='checked'" : '';
$text_tmp_1 = " " ;
$text_tmp_2 = " " ;
foreach ( $front_page as $front_key => $front_value )
{
$type_selected = FALSE;
$text .= " <tr> " . $this -> show_front_val ( 'frontpage' , $front_key , $front_value , $is_other_home , $rule_info [ 'page' ]);
$text .= " <td> </td> " ; // Spacer
$text .= $this -> show_front_val ( 'fp_force_page' , $front_key , $front_value , $is_other_force , $rule_info [ 'force' ]) . " </tr> " ;
}
// Now add in the 'other' URL box
$text .= " <tr> " . $this -> add_other ( 'frontpage' , $is_other_home , $rule_info [ 'page' ]) . " <td> </td> " .
$this -> add_other ( 'fp_force_page' , $is_other_force , $rule_info [ 'force' ]) . " </tr> " ;
// $type_selected = FALSE;
// 'Save' and 'Cancel' buttons
$text .= " <tr style='vertical-align:top' >
<td colspan='7' style='text-align: center' class='forumheader'> " ;
$text .= $rs -> form_hidden ( 'fp_order' , $rule_info [ 'order' ]);
$text .= $rs -> form_button ( 'submit' , 'fp_save_new' , FRTLAN_12 ) . " " . $rs -> form_button ( 'submit' , 'fp_cancel' , LAN_CANCEL );
$text .= " </td>
$text_tmp_1 .= "
<tr >
" . $this -> show_front_val ( 'frontpage' , $front_key , $front_value , $is_other_home , $rule_info [ 'page' ]) . "
</tr>
" ;
</table>
</form >
</div><br /><br /> " ;
$text_tmp_2 .= "
<tr >
" . $this -> show_front_val ( 'fp_force_page' , $front_key , $front_value , $is_other_force , $rule_info [ 'force' ]) . "
</tr>
" ;
$ns -> tablerender ( FRTLAN_13 , $text );
}
$text = "
<form method='post' action=' " . e_SELF . " '>
<fieldset id='core-frontpage-edit'>
<legend class='e-hideme'> " . ( $rule_info [ 'order' ] ? FRTLAN_46 : FRTLAN_42 ) . " </legend>
<div id='core-frontpage-edit-home'>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'>
<col style='width: 40%' />
<col style='width: 60%' />
</colgroup>
<thead>
<tr>
<th colspan='2' class='last'>
" . FRTLAN_49 . "
</th>
</tr>
</thead>
<tbody>
{ $text_tmp_1 }
<tr>
" . $this -> add_other ( 'frontpage' , $is_other_home , $rule_info [ 'page' ]) . "
</tr>
</tbody>
</table>
</div>
<div id='core-frontpage-edit-post-login'>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'>
<col style='width: 40%' />
<col style='width: 60%' />
</colgroup>
<thead>
<tr>
<th colspan='2' class='last'>
" . FRTLAN_35 . " " . FRTLAN_50 . "
</th>
</tr>
</thead>
<tbody>
{ $text_tmp_2 }
<tr>
" . $this -> add_other ( 'fp_force_page' , $is_other_force , $rule_info [ 'force' ]) . "
</tr>
</tbody>
</table>
</div>
<div class='buttons-bar center'>
" . $frm -> hidden ( 'fp_order' , $rule_info [ 'order' ]) . "
" . FRTLAN_43 . r_userclass ( 'class' , $rule_info [ 'class' ], 'off' , 'public,guest,member,admin,main,classes' ) . "
" . $frm -> admin_button ( 'fp_save_new' , FRTLAN_12 , 'update' ) . "
" . $frm -> admin_button ( 'fp_cancel' , LAN_CANCEL , 'cancel' ) . "
</div>
</fieldset>
</form>
" ;
return $text ;
}
// Given a path string, returns the 'type' (title) for it
function lookup_path ( $path )
{
global $front_page ;
foreach ( $front_page as $front_key => $front_ value )
foreach ( $front_page as $front_value )
{
if ( is_array ( $front_value [ 'page' ]))
{ // Its a URL with multiple options
@@ -413,15 +456,15 @@ class frontpage
}
}
}
if ( strlen ( $path )) return FRTLAN_51 . " : " . $path ; // 'Other'
else return FRTLAN_52 ; // 'None '
if ( strlen ( $path ))
return FRTLAN_51 . " : " . $path ; // 'Other '
else
return FRTLAN_52 ; // 'None'
}
function show_front_val ( $ob_name , $front_key , $front_value , & $is_other , $current_setting )
{
global $rs ;
global $frm ;
$type_selected = FALSE ;
$text = '' ;
@@ -446,45 +489,48 @@ class frontpage
}
}
$text .= " <td class='forumheader3'> " ;
$text .= $rs -> form_radio ( $ob_name , $front_key , $type_selected );
$text .= " </td> " ;
if ( is_array ( $front_value [ 'page' ]))
{ // Multiple options for same page name
$text .= " <td class='forumheader3'> " . $front_value [ 'title' ] . " </td> " ;
$text .= " <td class='forumheader3'> " ;
$text .= $rs -> form_select_open ( $ob_name . '_multipage[' . $front_key . ']' );
$text .= "
<td>
" . $frm -> radio ( $ob_name , $front_key , $type_selected ) . "
" . $frm -> label ( $front_value [ 'title' ], $ob_name , $front_key ) . "
</td>
<td>
" ;
$text .= $frm -> select_open ( $ob_name . '_multipage[' . $front_key . ']' );
foreach ( $front_value [ 'page' ] as $multipage_key => $multipage_value )
{
$sub_selected = ( $current_setting == $multipage_value [ 'page' ]) ? TRUE : FALSE ;
$text .= $rs -> form_option ( $multipage_value [ 'title' ], $sub_selected , $multipage_key );
$text .= " \n " . $frm -> option ( $multipage_value [ 'title' ], $multipage_key , ( $current_setting == $multipage_value [ 'page' ])) . " \n " ;
}
$text .= $rs -> form_ select_close ();
$text .= $frm -> select_close ();
$text .= " </td> " ;
}
else
{ // Single option for URL
$text .= " <td colspan='2' class='forumheader3'> " . $front_value [ 'title' ] . " </td> " ;
$text .= "
<td>
" . $frm -> radio ( $ob_name , $front_key , $type_selected ) . "
" . $frm -> label ( $front_value [ 'title' ], $ob_name , $front_key ) . "
</td>
<td> </td> " ;
}
return $text ;
}
function add_other ( $ob_name , $cur_val , $cur_page )
{
global $rs ;
return " <td class='forumheader3'> " . $rs -> form_radio ( $ob_name , 'other' , $cur_val ) . " </td>
<td class='forumheader3'> " . FRTLAN_15 . " </td>
<td class='forumheader3' >
" . $rs -> form_text ( $ob_name . '_other' , 50 , ( $cur_val ? $cur_page : '' ), 150 ) . "
</td> " ;
global $frm ;
return "
<td> " . $frm -> radio ( $ob_name , 'other' , $cur_val ) . " " . $frm -> label ( FRTLAN_15 , $ob_name , 'other' ) . " </td>
<td> " . $frm -> text ( $ob_name . '_other' , ( $cur_val ? $cur_page : '' ), 150 , " size=50&id= { $ob_name } -other-txt " ) . " </td >
" ;
}
}
require_once ( 'footer.php' );
// Log event to admin log
function frontpage_adminlog ( $msg_num = '00' , $woffle = '' )
{
@@ -492,5 +538,23 @@ function frontpage_adminlog($msg_num='00', $woffle='')
$admin_log -> log_event ( 'FRONTPG_' . $msg_num , $woffle , E_LOG_INFORMATIVE , '' );
}
/**
* Handle page DOM within the page header
*
* @return string JS source
*/
function headerjs ()
{
require_once ( e_HANDLER . 'js_helper.php' );
$ret = "
<script type='text/javascript'>
//add required core lan - delete confirm message
( " . e_jshelper :: toString ( FRTLAN_54 ) . " ).addModLan('core', 'delete_confirm');
</script>
<script type='text/javascript' src=' " . e_FILE_ABS . " jslib/core/admin.js'></script>
" ;
return $ret ;
}
?>