2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-15 22:32:24 +00:00
* 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 - Site Links
*
* $Source : / cvs_backup / e107_0 . 8 / e107_admin / links . php , v $
2009-07-17 07:53:13 +00:00
* $Revision : 1.25 $
* $Date : 2009 - 07 - 17 07 : 53 : 13 $
2009-07-07 06:50:56 +00:00
* $Author : e107coders $
2008-12-15 22:32:24 +00:00
*
2006-12-02 04:36:16 +00:00
*/
2008-12-15 22:32:24 +00:00
require_once ( '../class2.php' );
if ( ! getperms ( 'I' ))
2008-07-10 20:37:03 +00:00
{
2008-12-15 22:32:24 +00:00
header ( 'location:' . e_BASE . 'index.php' );
exit ();
2006-12-02 04:36:16 +00:00
}
$e_sub_cat = 'links' ;
2008-12-15 22:32:24 +00:00
if ( ! is_object ( $tp ))
$tp = new e_parse ();
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
// ----- Presets.----------
2008-12-15 22:32:24 +00:00
require_once ( e_HANDLER . " preset_class.php " );
$pst = new e_preset ();
2008-12-19 14:01:07 +00:00
$pst -> form = " core-links-edit-form " ;
2006-12-02 04:36:16 +00:00
$pst -> page = " links.php?create " ;
$pst -> id = " admin_links " ;
2008-12-15 22:32:24 +00:00
require_once ( 'auth.php' );
2006-12-02 04:36:16 +00:00
// --------------------
$pst -> save_preset ();
2008-12-15 22:32:24 +00:00
require_once ( e_HANDLER . 'userclass_class.php' );
require_once ( e_HANDLER . 'form_handler.php' );
require_once ( e_HANDLER . " message_handler.php " );
require_once ( e_HANDLER . " ren_help.php " );
2006-12-02 04:36:16 +00:00
2008-12-15 22:32:24 +00:00
$rs = new form ();
$linkpost = new links ();
$emessage = & eMessage :: getInstance ();
2006-12-02 04:36:16 +00:00
2007-10-13 19:08:37 +00:00
$action = '' ;
2008-12-15 22:32:24 +00:00
if ( e_QUERY )
2007-10-13 19:08:37 +00:00
{
2008-12-15 22:32:24 +00:00
$tmp = explode ( '.' , e_QUERY );
$action = $tmp [ 0 ];
$sub_action = varset ( $tmp [ 1 ], '' );
$id = varset ( $tmp [ 2 ], '' );
unset ( $tmp );
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
define ( " URL_SEPARATOR " , 'X' ); // Used in names of 'inc' and 'dec' fields
2007-10-13 19:08:37 +00:00
$incdec_action = '' ;
2006-12-02 04:36:16 +00:00
foreach ( array_keys ( $_POST ) as $k )
{
2008-12-15 22:32:24 +00:00
if ( preg_match ( " #(.*?)_delete_( \ d+)(.*)# " , $k , $matches ))
{
$delete = $matches [ 1 ];
$del_id = $matches [ 2 ];
} elseif ( ! $incdec_action && ( preg_match ( " #^(inc|dec) " . URL_SEPARATOR . " ( \ d+) " . URL_SEPARATOR . " ( \ d+)_[x|y]# " , $k , $matches )))
{
$incdec_action = $matches [ 1 ];
$linkid = intval ( $matches [ 2 ]);
$link_order = intval ( $matches [ 3 ]);
}
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
if ( isset ( $_POST [ 'generate_sublinks' ]) && isset ( $_POST [ 'sublink_type' ]) && $_POST [ 'sublink_parent' ] != " " )
2007-10-13 19:08:37 +00:00
{
2006-12-02 04:36:16 +00:00
$subtype = $_POST [ 'sublink_type' ];
$sublink = $linkpost -> sublink_list ( $subtype );
2008-12-15 22:32:24 +00:00
if ( ! is_object ( $sql2 ))
2007-10-13 19:08:37 +00:00
{
2008-12-15 22:32:24 +00:00
$sql2 = new db ();
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$sql -> db_Select ( " links " , " * " , " link_id = ' " . $_POST [ 'sublink_parent' ] . " ' " );
$par = $sql -> db_Fetch ();
2006-12-02 04:36:16 +00:00
extract ( $par );
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$sql -> db_Select ( $sublink [ 'table' ], " * " , $sublink [ 'query' ]);
2006-12-02 04:36:16 +00:00
$count = 1 ;
2008-12-15 22:32:24 +00:00
while ( $row = $sql -> db_Fetch ())
2008-11-02 10:15:37 +00:00
{
2006-12-02 04:36:16 +00:00
$subcat = $row [( $sublink [ 'fieldid' ])];
$name = $row [( $sublink [ 'fieldname' ])];
2008-12-15 22:32:24 +00:00
$subname = $name ; // eliminate old embedded hierarchy from names. (e.g. 'submenu.TopName.name')
$suburl = str_replace ( " # " , $subcat , $sublink [ 'url' ]);
2006-12-02 04:36:16 +00:00
$subicon = ( $sublink [ 'fieldicon' ]) ? $row [( $sublink [ 'fieldicon' ])] : $link_button ;
$subdiz = ( $sublink [ 'fielddiz' ]) ? $row [( $sublink [ 'fielddiz' ])] : $link_description ;
$subparent = $_POST [ 'sublink_parent' ];
2008-12-16 11:05:36 +00:00
2008-11-02 10:15:37 +00:00
if ( $sql2 -> db_Insert ( " links " , " 0, ' $subname ', ' $suburl ', ' $subdiz ', ' $subicon ', ' $link_category ', ' $count ', ' $subparent ', ' $link_open ', ' $link_class ' " ))
{
2008-12-15 22:32:24 +00:00
$message .= LAN_CREATED . " ( { $name } )[!br!] " ;
$emessage -> add ( LAN_CREATED . " ( { $name } ) " , E_MESSAGE_SUCCESS );
} else
2008-11-02 10:15:37 +00:00
{
2008-12-15 22:32:24 +00:00
$message .= LAN_CREATED_FAILED . " ( { $name } )[!br!] " ;
$emessage -> add ( LAN_CREATED_FAILED . " ( { $name } ) " , E_MESSAGE_ERROR );
2006-12-02 04:36:16 +00:00
}
$count ++ ;
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $message )
2008-11-02 10:15:37 +00:00
{
2008-12-15 22:32:24 +00:00
sitelinks_adminlog ( '01' , $message ); // 'Sublinks generated'
2006-12-02 04:36:16 +00:00
}
}
2008-12-15 22:32:24 +00:00
if ( $incdec_action == 'inc' )
2007-09-29 20:20:36 +00:00
{
2008-12-15 22:32:24 +00:00
$sql -> db_Update ( " links " , " link_order=link_order+1 WHERE link_order=' " . intval ( $link_order - 1 ) . " ' " );
2008-11-02 10:15:37 +00:00
$sql -> db_Update ( " links " , " link_order=link_order-1 WHERE link_id=' " . intval ( $linkid ) . " ' " );
sitelinks_adminlog ( '02' , 'Id: ' . $linkid );
2008-12-16 11:05:36 +00:00
}
2008-12-15 22:32:24 +00:00
elseif ( $incdec_action == 'dec' )
2007-09-29 20:20:36 +00:00
{
2008-12-15 22:32:24 +00:00
$sql -> db_Update ( " links " , " link_order=link_order-1 WHERE link_order=' " . intval ( $link_order + 1 ) . " ' " );
2008-11-02 10:15:37 +00:00
$sql -> db_Update ( " links " , " link_order=link_order+1 WHERE link_id=' " . intval ( $linkid ) . " ' " );
sitelinks_adminlog ( '03' , 'Id: ' . $linkid );
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
if ( isset ( $_POST [ 'update' ]))
2007-09-29 20:20:36 +00:00
{
2008-12-15 22:32:24 +00:00
foreach ( $_POST [ 'link_order' ] as $loid )
2007-09-29 20:20:36 +00:00
{
2008-12-15 22:32:24 +00:00
$tmp = explode ( " . " , $loid );
$sql -> db_Update ( " links " , " link_order= " . intval ( $tmp [ 1 ]) . " WHERE link_id= " . intval ( $tmp [ 0 ]));
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
foreach ( $_POST [ 'link_class' ] as $lckey => $lcid )
2007-09-29 20:20:36 +00:00
{
2008-12-15 22:32:24 +00:00
$sql -> db_Update ( " links " , " link_class=' " . $lcid . " ' WHERE link_id= " . intval ( $lckey ));
2006-12-02 04:36:16 +00:00
}
$e107cache -> clear ( " sitelinks " );
2008-12-15 22:32:24 +00:00
$emessage -> add ( LAN_UPDATED , E_MESSAGE_SUCCESS );
2008-11-02 10:15:37 +00:00
sitelinks_adminlog ( '04' , '' );
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
if ( isset ( $_POST [ 'updateoptions' ]))
2008-11-02 10:15:37 +00:00
{
$changed = FALSE ;
2008-12-15 22:32:24 +00:00
foreach ( array ( 'linkpage_screentip' , 'sitelinks_expandsub' ) as $opt )
2008-11-02 10:15:37 +00:00
{
$temp = intval ( $_POST [ $opt ]);
2008-12-15 22:32:24 +00:00
if ( $temp != $pref [ $opt ])
2008-11-02 10:15:37 +00:00
{
$pref [ $opt ] = $temp ;
$changed = TRUE ;
}
}
2008-12-15 22:32:24 +00:00
if ( $changed )
2008-11-02 10:15:37 +00:00
{
save_prefs ();
$e107cache -> clear ( " sitelinks " );
sitelinks_adminlog ( '05' , $pref [ 'linkpage_screentip' ] . ',' . $pref [ 'sitelinks_expandsub' ]);
2008-12-15 22:32:24 +00:00
$emessage -> add ( LCLAN_1 , E_MESSAGE_SUCCESS );
2008-12-16 11:05:36 +00:00
}
2008-11-02 10:15:37 +00:00
else
{
2008-12-15 22:32:24 +00:00
// Nothing changed
$emessage -> add ( LINKLAN_11 );
2008-11-02 10:15:37 +00:00
}
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
if ( $delete == 'main' )
2006-12-02 04:36:16 +00:00
{
2008-12-15 22:32:24 +00:00
if ( $sql -> db_Select ( " links " , " link_id, link_name, link_order, link_parent " , " link_id= " . intval ( $del_id )))
2008-09-23 19:37:36 +00:00
{
2006-12-02 04:36:16 +00:00
$row = $sql -> db_Fetch ();
2008-12-15 22:32:24 +00:00
$linkpost -> delete_link ( $row ); // Admin logging in class routine
2006-12-02 04:36:16 +00:00
}
}
2008-12-15 22:32:24 +00:00
if ( isset ( $_POST [ 'add_link' ]))
2008-11-02 10:15:37 +00:00
{
2006-12-02 04:36:16 +00:00
$linkpost -> submit_link ( $sub_action , $_POST [ 'link_id' ]);
unset ( $id );
}
$linkArray = $linkpost -> getLinks ();
2009-01-16 17:57:57 +00:00
switch ( $action ) {
case 'create' :
$linkpost -> create_link ( $sub_action , $id );
break ;
case 'debug' :
$linkpost -> show_existing_items ( TRUE );
break ;
case 'opt' :
$linkpost -> show_pref_options ();
break ;
case 'sublinks' :
$linkpost -> show_sublink_generator ();
break ;
case 'savepreset' :
case 'clr_preset' :
default : //handles preset urls as well
$action = 'main' ;
$sub_action = $id = '' ;
$linkpost -> show_existing_items ();
break ;
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
require_once ( 'footer.php' );
exit ();
2006-12-02 04:36:16 +00:00
// End ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
2008-12-15 22:32:24 +00:00
2006-12-02 04:36:16 +00:00
class links
{
var $link_total ;
var $aIdOptPrep , $aIdOptData , $aIdOptTest ;
2007-06-05 20:07:35 +00:00
var $debug_dis = FALSE ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
function getLinks ()
{
global $sql ;
if ( $this -> link_total = $sql -> db_Select ( " links " , " * " , " ORDER BY link_category,link_order, link_id ASC " , " nowhere " ))
{
while ( $row = $sql -> db_Fetch ())
{
$ret [ $row [ 'link_parent' ]][] = $row ;
}
}
return $ret ;
}
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
function linkName ( $text )
{
// This function is ONLY needed for link databases that have been upgraded from
// before 0.7+ -- all new link collections make use of link_parent instead
// of hierarchy embedded in the link_name. (Unfortunately, the upgraded
// data still includes embedded coding.)
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
if ( substr ( $text , 0 , 8 ) == " submenu. " ) // for backwards compatibility only.
{
2008-12-15 22:32:24 +00:00
$tmp = explode ( " . " , $text );
switch ( count ( $tmp ))
{
case 3 : // submenu.parent.node
$tmp = $tmp [ 2 ];
break ;
case 5 : // submenu.parent.midlev.child.node
$tmp = $tmp [ 4 ];
break ;
case 2 : // submenu.parent (invalid?)
default :
$parentLen = strlen ( $tmp [ 1 ]);
$tmp = substr ( $text , 8 + $parentLen + 1 ); // Skip submenu.parent.
2006-12-02 04:36:16 +00:00
}
return $tmp ;
2008-12-16 11:05:36 +00:00
}
2006-12-02 04:36:16 +00:00
else
{
return $text ;
}
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function dropdown ( $curval = " " , $lid = 0 , $indent = 0 )
{ // Drop-down list using on the parent_id. :)
global $linkArray , $id , $sub_action ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( 0 == $indent )
{
$ret = " <option value=''> " . LINKLAN_3 . " </option> \n " ;
}
2006-12-02 04:36:16 +00:00
foreach ( $linkArray [ $lid ] as $l )
{
2008-12-15 22:32:24 +00:00
$s = ( $l [ 'link_id' ] == $curval ? " selected='selected' " : " " );
2006-12-02 04:36:16 +00:00
$thename = $this -> linkName ( $l [ 'link_name' ]);
2008-12-15 22:32:24 +00:00
// prevent making self the parent.
if ( $l [ 'link_id' ] == $id )
{
$thename = " ( " . $thename . " ) " ;
}
2006-12-02 04:36:16 +00:00
if ( $sub_action == " sub " )
{
2008-12-15 22:32:24 +00:00
$thelink = ( $l [ 'link_id' ] != $lid ) ? $l [ 'link_id' ] : $l [ 'link_parent' ];
2008-12-16 11:05:36 +00:00
}
2006-12-02 04:36:16 +00:00
else
{
2008-12-15 22:32:24 +00:00
$thelink = ( $l [ 'link_id' ] != $id ) ? $l [ 'link_id' ] : $l [ 'link_parent' ];
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
$ret .= " <option value=' " . $thelink . " ' { $s } > " . str_pad ( " " , $indent * 36 , " " ) . $thename . " </option> \n " ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
if ( array_key_exists ( $l [ 'link_id' ], $linkArray ))
{
2008-12-15 22:32:24 +00:00
$ret .= $this -> dropdown ( $curval , $l [ 'link_id' ], $indent + 1 );
2006-12-02 04:36:16 +00:00
}
}
return $ret ;
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function existing ( $id = 0 , $level = 0 )
2006-12-02 04:36:16 +00:00
{
global $linkArray ;
$ret = " " ;
foreach ( $linkArray [ $id ] as $l )
{
2008-12-15 22:32:24 +00:00
$s = ( $l [ 'link_parent' ] == $curval ? " selected='selected' " : " " );
2006-12-02 04:36:16 +00:00
$ret .= $this -> display_row ( $l , $level );
if ( array_key_exists ( $l [ 'link_id' ], $linkArray ))
{
2008-12-15 22:32:24 +00:00
$ret .= $this -> existing ( $l [ 'link_id' ], $level + 1 );
2006-12-02 04:36:16 +00:00
}
}
return $ret ;
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function show_existing_items ( $dbg_display = FALSE )
2006-12-02 04:36:16 +00:00
{
2008-12-15 22:32:24 +00:00
global $sql , $rs , $e107 , $tp , $linkArray , $emessage ;
2007-06-05 20:07:35 +00:00
$this -> debug_dis = $dbg_display ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( count ( $linkArray ))
2006-12-02 04:36:16 +00:00
{
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
$this -> prepIdOpts (); // Prepare the options list for all links
$text = $rs -> form_open ( " post " , e_SELF , " myform_ { $link_id } " , " " , " " );
2008-12-15 22:32:24 +00:00
$text .= "
< fieldset id = 'core-links-list-1' >
< legend class = 'e-hideme' > " .LCLAN_12. " : 1 </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminlist' >
< colgroup >
< col style = 'width: 5%' />
< col style = 'width: 60%' />
< col style = 'width: 15%' />
2009-07-17 07:53:13 +00:00
2008-12-15 22:32:24 +00:00
< col style = 'width: 5%' />
< col style = 'width: 5%' />
2009-07-17 07:53:13 +00:00
< col style = 'width: 10%' />
2008-12-15 22:32:24 +00:00
</ colgroup >
< thead >
< tr >
< th class = 'center' > " .LCLAN_89. " </ th >
< th > " .LCLAN_15. " </ th >
2009-07-17 07:53:13 +00:00
< th class = 'center' > " .LCLAN_95. " </ th >
2008-12-15 22:32:24 +00:00
< th class = 'center' > " .LCLAN_91. " </ th >
< th class = 'center last' > " .LAN_ORDER. " </ th >
2009-07-17 07:53:13 +00:00
< th class = 'center' > " .LAN_OPTIONS. " </ th >
2008-12-15 22:32:24 +00:00
</ tr >
</ thead >
< tbody >
" ;
$text .= $this -> existing ( 0 );
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$text .= "
</ tbody >
</ table >
< div class = 'buttons-bar center' >
< button class = 'update' type = 'submit' name = 'update' value = '".LAN_UPDATE."' >< span > " .LAN_UPDATE. " </ span ></ button >
</ div >
</ fieldset >
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
" ;
2006-12-02 04:36:16 +00:00
$text .= $rs -> form_close ();
2008-12-16 11:05:36 +00:00
}
2008-12-15 22:32:24 +00:00
else
{
2008-12-16 11:05:36 +00:00
$text .= " <div class='center'> " . LCLAN_61 . " </div> " ;
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
$e107 -> ns -> tablerender ( LCLAN_8 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function prepIdOpts ()
{
for ( $a = 1 ; $a <= $this -> link_total ; $a ++ )
{
2006-12-02 04:36:16 +00:00
$sTxt = " " . $a ;
2008-12-15 22:32:24 +00:00
$this -> aIdOptData [] = array ( 'val' => '|||.' . $a , 'txt' => $sTxt ); // Later, ||| becomes Id
2006-12-02 04:36:16 +00:00
$this -> aIdOptTest [] = $sTxt ;
}
$this -> aIdOptPrep = $this -> prepOpts ( $this -> aIdOptData );
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function display_row ( $row2 , $indent = FALSE )
2007-10-13 19:08:37 +00:00
{
2009-07-07 06:50:56 +00:00
global $sql , $rs , $tp , $linkArray , $previous_cat ;
2006-12-02 04:36:16 +00:00
extract ( $row2 );
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
if ( $link_category > 1 && $link_category != $previous_cat )
{
2008-12-15 22:32:24 +00:00
$text .= "
</ tbody >
</ table >
</ fieldset >
< fieldset id = 'core-links-list-".$link_category."' >
< legend class = 'e-hideme' > " .LCLAN_12. " : " . $link_category . " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminlist' >
< colgroup >
< col style = 'width: 5%' />
< col style = 'width: 60%' />
< col style = 'width: 15%' />
2009-07-17 07:53:13 +00:00
< col style = 'width: 10%' />
2008-12-15 22:32:24 +00:00
< col style = 'width: 5%' />
< col style = 'width: 5%' />
</ colgroup >
< thead >
2006-12-02 04:36:16 +00:00
< tr >
2008-12-15 22:32:24 +00:00
< th class = 'center' > " .LCLAN_89. " </ th >
< th > " .LCLAN_15. " ( " .LCLAN_12. " : " . $link_category . " ) </ th >
2009-07-17 07:53:13 +00:00
< th class = 'center' > " .LAN_OPTIONS. " hihihi </ th >
2008-12-15 22:32:24 +00:00
< th class = 'center' > " .LCLAN_95. " </ th >
< th class = 'center' > " .LCLAN_91. " </ th >
< th class = 'center last' > " .LAN_ORDER. " </ th >
</ tr >
</ thead >
< tbody >
" ;
2006-12-02 04:36:16 +00:00
$previous_cat = $link_category ;
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( strpos ( $link_name , " submenu. " ) !== FALSE || $link_parent != 0 ) // 'submenu' for upgrade compatibility only.
2006-12-02 04:36:16 +00:00
{
2008-12-15 22:32:24 +00:00
$link_name = $this -> linkName ( $link_name );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $this -> debug_dis )
2007-06-05 20:07:35 +00:00
{
2008-12-15 22:32:24 +00:00
$link_name .= ' [' . $link_url . ']' ;
2007-06-05 20:07:35 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $indent )
2007-10-13 19:08:37 +00:00
{
2009-07-17 07:53:13 +00:00
$subimage = " <img src=' " . e_IMAGE . " generic/branchbottom.gif' alt='' /> " ;
2008-12-15 22:32:24 +00:00
$subspacer = ( $indent > 1 ) ? " style='padding-left: " . (( $indent - 1 ) * 16 ) . " px' " : " " ;
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$text .= "
< tr >
< td title = '".$link_description."' >
" ;
2008-12-16 11:05:36 +00:00
$text .= $link_button ? " <img class='icon S16' src=' " . e_IMAGE_ABS . " icons/ " . $link_button . " ' alt='' /> " : " " ;
2008-12-15 22:32:24 +00:00
$text .= "
</ td >
< td title = '".$link_description."' " . $subspacer . " >
2009-04-29 01:51:12 +00:00
" . $subimage . " < a href = '".$tp->replaceConstants(e_BASE.$row2[' link_url '], true, true)."' > " . $link_name . " </ a >
2008-12-15 22:32:24 +00:00
</ td >
" ;
$text .= "
2009-07-17 07:53:13 +00:00
2009-04-26 19:24:47 +00:00
< td > " .r_userclass( " link_class [ " . $link_id . " ] " , $link_class , " off " , " public , guest , nobody , member , main , admin , classes " ). " </ td >
2008-12-15 22:32:24 +00:00
< td class = 'center' >
" ;
2007-10-13 19:08:37 +00:00
$name_suffix = URL_SEPARATOR . $link_id . URL_SEPARATOR . $link_order ;
2008-12-15 22:32:24 +00:00
$text .= "
2009-07-17 03:53:14 +00:00
< input name = 'inc".$name_suffix."' type = 'image' src = '".ADMIN_UP_ICON_PATH."' title = '".LCLAN_30."' />
< input name = 'dec".$name_suffix."' type = 'image' src = '".ADMIN_DOWN_ICON_PATH."' title = '".LCLAN_31."' />
2008-12-15 22:32:24 +00:00
</ td >
< td >
< select name = 'link_order[]' class = 'tbox select order' > \n
" ;
$text .= $this -> genOpts ( $this -> aIdOptPrep , $this -> aIdOptTest , $link_order , $link_id );
$text .= "
</ select >
</ td >
2009-07-17 07:53:13 +00:00
< td class = 'center' >
< a href = '".e_SELF."?create.sub.{$link_id}' title = '".LINKLAN_10."' > " .ADMIN_ADD_ICON. " </ a >& nbsp ;
< a href = '".e_SELF."?create.edit.{$link_id}' > " .ADMIN_EDIT_ICON. " </ a >& nbsp ;
< input class = 'action delete' type = 'image' name = 'main_delete_{$link_id}' src = '".ADMIN_DELETE_ICON_PATH."' title = '".$tp->toJS(LCLAN_58." [ $link_name ]")."' />
</ td >
2008-12-15 22:32:24 +00:00
</ tr >
" ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
return $text ;
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function show_message ( $message )
{
2006-12-02 04:36:16 +00:00
global $ns ;
$ns -> tablerender ( LAN_UPDATE , " <div style='text-align:center'><b> " . $message . " </b></div> " );
}
2008-12-16 11:05:36 +00:00
2008-11-02 10:15:37 +00:00
// Show the form for link create/edit
2008-12-15 22:32:24 +00:00
function create_link ( $sub_action , $id )
2008-11-02 10:15:37 +00:00
{
2008-12-16 11:05:36 +00:00
global $sql , $e107 , $pst , $tp , $emessage ;
2009-01-16 17:57:57 +00:00
$frm = new e_form ();
2006-12-02 04:36:16 +00:00
$preset = $pst -> read_preset ( " admin_links " );
extract ( $preset );
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $sub_action == " edit " && ! $_POST [ 'submit' ])
2006-12-02 04:36:16 +00:00
{
2008-12-15 22:32:24 +00:00
if ( $sql -> db_Select ( " links " , " * " , " link_id=' $id ' " ))
2006-12-02 04:36:16 +00:00
{
$row = $sql -> db_Fetch ();
extract ( $row );
}
}
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
if ( " sub " == $sub_action )
{
$link_parent = $id ;
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( strpos ( $link_name , " submenu. " ) !== FALSE )
{ // 'submenu' for upgrade compatibility only.
$link_name = $this -> linkName ( $link_name );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
require_once ( e_HANDLER . " file_class.php " );
$fl = new e_file ();
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $iconlist = $fl -> get_files ( e_IMAGE . " icons/ " , '\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG' ))
2008-11-20 20:35:24 +00:00
{
2008-12-15 22:32:24 +00:00
sort ( $iconlist );
}
$text = "
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
< form method = 'post' action = '".e_SELF."' id = 'core-links-edit-form' >
< fieldset id = 'core-links-edit' >
< legend class = 'e-hideme' > " .LCLAN_29. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminform' >
< colgroup span = '2' >
< col class = 'col-label' ></ col >
< col class = 'col-control' ></ col >
</ colgroup >
< tbody >
< tr >
< td class = 'label' > " .LINKLAN_2. " </ td >
< td class = 'control' >
< select class = 'tbox select' name = 'link_parent' >
" . $this->dropdown ( $link_parent ). "
</ select >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_15. " : </ td >
< td class = 'control' >
< input class = 'tbox input-text' type = 'text' name = 'link_name' size = '60' value = '{$link_name}' maxlength = '100' />
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_16. " : </ td >
< td class = 'control' >
< input class = 'tbox input-text' type = 'text' name = 'link_url' size = '60' value = '".$tp->replaceConstants($link_url, TRUE)."' maxlength = '200' />
" .((e_MENU == " debug " ) ? $link_url : " " ). "
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_17. " : </ td >
< td class = 'control' >
2008-12-16 11:05:36 +00:00
< textarea class = 'tbox textarea' id = 'link_description' name = 'link_description' cols = '70' rows = '5' onselect = 'storeCaret(this);' onclick = 'storeCaret(this);' onkeyup = 'storeCaret(this)' > " . $tp->toForm ( $link_description ). " </ textarea >
2008-12-15 22:32:24 +00:00
< br /> " .display_help( " helpb " , " admin " ). "
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_18. " : </ td >
< td class = 'control' >
2008-12-16 11:05:36 +00:00
2009-01-16 17:57:57 +00:00
" ;
2008-12-16 11:05:36 +00:00
2009-01-16 17:57:57 +00:00
//SecretR - more nice view now handled by e_form (inner use of new sc {ICONPICKER})
//Example sc opts (4th func argument)
//$opts = 'path='.e_IMAGE.'icons/|'.e_IMAGE.'generic/';
//$opts .= '&path_omit='.e_IMAGE.'icons/';
$text .= $frm -> iconpicker ( 'link_button' , $link_button , LCLAN_39 );
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
// 1 = _blank
// 2 = _parent not in use.
// 3 = _top not in use.
2008-12-15 22:32:24 +00:00
$linkop [ 0 ] = LCLAN_20 ; // 0 = same window
2006-12-02 04:36:16 +00:00
$linkop [ 1 ] = LCLAN_23 ;
2008-12-15 22:32:24 +00:00
$linkop [ 4 ] = LCLAN_24 ; // 4 = miniwindow 600x400
$linkop [ 5 ] = LINKLAN_1 ; // 5 = miniwindow 800x600
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
2008-12-15 22:32:24 +00:00
$text .= "
2009-01-16 17:57:57 +00:00
2008-12-15 22:32:24 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_19. " : </ td >
< td class = 'control' >
< select name = 'linkopentype' class = 'tbox select' >
" ;
foreach ( $linkop as $key => $val )
{
2008-12-16 11:05:36 +00:00
$selectd = ( $link_open == $key ) ? " selected='selected' " : " " ;
$text .= " <option value=' $key ' { $selectd } > " . $val . " </option> \n " ;
2008-12-15 22:32:24 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$text .= "
</ select >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_12. " : </ td >
< td class = 'control' >
< select name = 'linkrender' class = 'tbox select' >
" ;
$rentype = array ( " " , " Main " , " Alt " , " Alt " , " Alt " , " Alt " , " Alt " , " Alt " , " Alt " , " Alt " , " Alt " );
for ( $i = 1 ; $i < count ( $rentype ); $i ++ )
{
2008-12-16 11:05:36 +00:00
$sel = ( $link_category == $i ) ? " selected='selected' " : " " ;
$text .= " <option value=' $i ' { $sel } > $i - " . $rentype [ $i ] . " </option> " ;
2008-12-15 22:32:24 +00:00
}
;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$text .= "
</ select >
< div class = 'smalltext field-help' > " .LCLAN_96. " { SITELINKS = flat : [ rendertype number ]} </ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_25. " :
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
</ td >
< td class = 'control' >
2009-04-26 19:24:47 +00:00
" .r_userclass( " link_class " , $link_class , " off " , " public , guest , nobody , member , main , admin , classes " ). "
2008-12-15 22:32:24 +00:00
< div class = 'smalltext field-help' > ( " .LCLAN_26. " ) </ div >
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" ;
if ( $id && $sub_action == " edit " )
{
$text .= "
< button class = 'update' type = 'submit' name = 'add_link' value = '".LCLAN_27."' >< span > " .LCLAN_27. " </ span ></ button >
2008-12-16 11:05:36 +00:00
< input type = 'hidden' name = 'link_id' value = '{$link_id}' />
2008-12-15 22:32:24 +00:00
" ;
} else
{
$text .= "
< button class = 'create' type = 'submit' name = 'add_link' value = '".LCLAN_28."' >< span > " .LCLAN_28. " </ span ></ button >
" ;
}
$text .= "
</ div >
</ fieldset >
2006-12-02 04:36:16 +00:00
</ form >
2008-12-15 22:32:24 +00:00
" ;
$e107 -> ns -> tablerender ( LCLAN_29 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function submit_link ( $sub_action , $id )
2008-06-06 19:14:20 +00:00
{
2008-12-15 22:32:24 +00:00
global $sql , $e107cache , $tp , $emessage ;
if ( ! is_object ( $tp ))
2008-06-06 19:14:20 +00:00
{
2008-12-15 22:32:24 +00:00
$tp = new e_parse ();
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-06-06 19:14:20 +00:00
$id = intval ( $id );
2006-12-02 04:36:16 +00:00
$parent_id = ( $_POST [ 'link_parent' ]) ? intval ( $_POST [ 'link_parent' ]) : 0 ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
$link_name = $tp -> toDB ( $_POST [ 'link_name' ]);
$link_url = $tp -> createConstants ( $_POST [ 'link_url' ]);
2008-12-15 22:32:24 +00:00
$link_url = str_replace ( " & " , " & " , $link_url ); // xhtml compliant links.
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
$link_description = $tp -> toDB ( $_POST [ 'link_description' ]);
$link_button = $tp -> toDB ( $_POST [ 'link_button' ]);
2008-06-06 19:14:20 +00:00
$link_render = intval ( $_POST [ 'linkrender' ]);
$link_open = intval ( $_POST [ 'linkopentype' ]);
$link_class = $tp -> toDB ( $_POST [ 'link_class' ]);
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$message = implode ( '[!br!]' , array ( $link_name , $link_url , $link_class )); // Probably enough to log
2006-12-02 04:36:16 +00:00
$link_t = $sql -> db_Count ( " links " , " (*) " );
2008-12-15 22:32:24 +00:00
if ( $id )
2008-06-06 19:14:20 +00:00
{
2008-11-02 10:15:37 +00:00
$sql -> db_Update ( " links " , " link_parent=' { $parent_id } ', link_name=' { $link_name } ', link_url=' { $link_url } ', link_description=' { $link_description } ', link_button= ' { $link_button } ', link_category=' { $link_render } ', link_open=' { $link_open } ', link_class=' { $link_class } ' WHERE link_id=' { $id } ' " );
2006-12-02 04:36:16 +00:00
//rename all sublinks to eliminate old embedded 'submenu' etc hierarchy.
2008-12-15 22:32:24 +00:00
// this is for upgrade compatibility only. Current hierarchy uses link_parent.
2006-12-02 04:36:16 +00:00
$e107cache -> clear ( " sitelinks " );
2008-12-15 22:32:24 +00:00
sitelinks_adminlog ( '08' , $message );
$emessage -> add ( LCLAN_3 , E_MESSAGE_SUCCESS );
2008-12-16 11:05:36 +00:00
}
2008-12-15 22:32:24 +00:00
else
{ // New link
$sql -> db_Insert ( " links " , " 0, ' $link_name ', ' $link_url ', ' $link_description ', ' $link_button ', " . $link_render . " , " . ( $link_t + 1 ) . " , " . $parent_id . " , " . $link_open . " , " . $link_class );
2006-12-02 04:36:16 +00:00
$e107cache -> clear ( " sitelinks " );
2008-12-15 22:32:24 +00:00
sitelinks_adminlog ( '07' , $message );
$emessage -> add ( LCLAN_2 , E_MESSAGE_SUCCESS );
2006-12-02 04:36:16 +00:00
}
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function show_pref_options ()
2008-11-02 10:15:37 +00:00
{
2008-12-15 22:32:24 +00:00
global $pref , $e107 , $emessage ;
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
< fieldset id = 'core-links-options' >
< legend class = 'e-hideme' > " .LCLAN_88. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminform' >
< colgroup span = '2' >
< col class = 'col-label' ></ col >
< col class = 'col-control' ></ col >
</ colgroup >
< tbody >
< tr >
< td class = 'label' > " .LCLAN_78. " </ td >
< td class = 'control' >
< div class = 'auto-toggle-area autocheck' >
< input type = 'checkbox' class = 'checkbox' name = 'linkpage_screentip' value = '1' " .( $pref['linkpage_screentip'] ? " checked = 'checked' " : " " ). " />
< div class = 'smalltext field-help' > " .LCLAN_79. " </ div >
</ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LCLAN_80. " </ td >
< td class = 'control' >
< div class = 'auto-toggle-area autocheck' >
< input type = 'checkbox' class = 'checkbox' name = 'sitelinks_expandsub' value = '1' " .( $pref['sitelinks_expandsub'] ? " checked = 'checked' " : " " ). " />
< div class = 'smalltext field-help' > " .LCLAN_81. " </ div >
</ div >
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
< button class = 'update' type = 'submit' name = 'updateoptions' value = '".LAN_UPDATE."' >< span > " .LAN_UPDATE. " </ span ></ button >
</ div >
</ fieldset >
</ form >
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
" ;
$e107 -> ns -> tablerender ( LCLAN_88 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-09-23 19:37:36 +00:00
// Delete link
// We need to update the 'order' number of other links with the same parentage - may be top level or a sub-level
2008-12-15 22:32:24 +00:00
function delete_link ( $linkInfo )
2008-09-23 19:37:36 +00:00
{
2008-12-15 22:32:24 +00:00
global $sql , $emessage , $e107cache ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $sql -> db_Select ( " links " , " link_id " , " link_order > ' { $linkInfo [ 'link_order' ] } ' AND `link_parent`= { $linkInfo [ 'link_parent' ] } " ))
2008-09-23 19:37:36 +00:00
{
2006-12-02 04:36:16 +00:00
$linkList = $sql -> db_getList ();
2008-09-23 19:37:36 +00:00
foreach ( $linkList as $l )
{
2006-12-02 04:36:16 +00:00
$sql -> db_Update ( " links " , " link_order = link_order -1 WHERE link_id = ' { $l [ 'link_id' ] } ' " );
}
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $sql -> db_Delete ( " links " , " link_id=' " . $linkInfo [ 'link_id' ] . " ' " ))
2008-09-23 19:37:36 +00:00
{
// Update orphaned sublinks - just hide them, and make them top level. And delete any obsolete naming while we're there
2006-12-02 04:36:16 +00:00
$sql -> db_Update ( " links " , " link_name = SUBSTRING_INDEX(link_name, '.', -1) , link_parent = '0', link_class='255' WHERE link_parent= ' " . $linkInfo [ 'link_id' ] . " ' " );
2008-12-16 11:05:36 +00:00
2008-11-02 10:15:37 +00:00
$message = LCLAN_53 . " # " . $linkInfo [ 'link_id' ] . " " . LCLAN_54 ;
2008-12-15 22:32:24 +00:00
$emessage -> add ( $message , E_MESSAGE_SUCCESS );
sitelinks_adminlog ( '06' , $message . '[!br!]' . $linkInfo [ 'link_name' ]);
$e107cache -> clear ( " sitelinks " );
} else
2008-11-02 10:15:37 +00:00
{
2008-12-15 22:32:24 +00:00
$emessage -> add ( $message , E_MESSAGE_ERROR );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
// -------------------------- Sub links generator ------------->
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
2008-12-15 22:32:24 +00:00
function show_sublink_generator ()
2008-09-23 19:37:36 +00:00
{
2008-12-15 22:32:24 +00:00
global $e107 , $sql , $emessage ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$sublinks = $this -> sublink_list ();
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
< fieldset id = 'core-links-generator' >
< legend class = 'e-hideme' > " .LINKLAN_4. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminform' >
< colgroup span = '2' >
< col class = 'col-label' ></ col >
< col class = 'col-control' ></ col >
</ colgroup >
< tbody >
< tr >
< td class = 'label' > " .LINKLAN_6. " </ td >
< td class = 'control' >
< select name = 'sublink_type' class = 'tbox select' >
< option value = '' ></ option > " ;
foreach ( $sublinks as $key => $type )
{
$text .= "
< option value = '$key' > " . $type['title'] . " </ option >
" ;
}
$text .= "
</ select >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LINKLAN_7. " </ td >
< td class = 'control' >
< select name = 'sublink_parent' class = 'tbox select' >
< option value = '' ></ option > " ;
$sql -> db_Select ( " links " , " * " , " link_parent='0' ORDER BY link_name ASC " );
while ( $row = $sql -> db_Fetch ())
2008-09-23 19:37:36 +00:00
{
2008-12-15 22:32:24 +00:00
$text .= "
< option value = '".$row[' link_id ']."' > " . $row['link_name'] . " </ option >
" ;
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
$text .= "
</ select >
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
< button class = 'create' type = 'submit' name = 'generate_sublinks' value = '".LINKLAN_5."' >< span > " .LINKLAN_5. " </ span ></ button >
</ div >
</ fieldset >
</ form >
" ;
$e107 -> ns -> tablerender ( LINKLAN_4 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function sublink_list ( $name = " " )
2008-09-23 19:37:36 +00:00
{
2008-12-15 22:32:24 +00:00
global $sql , $PLUGINS_DIRECTORY ;
$sublink_type [ 'news' ][ 'title' ] = LINKLAN_8 ; // "News Categories";
$sublink_type [ 'news' ][ 'table' ] = " news_category " ;
$sublink_type [ 'news' ][ 'query' ] = " category_id !='-2' ORDER BY category_name ASC " ;
$sublink_type [ 'news' ][ 'url' ] = " news.php?cat.# " ;
$sublink_type [ 'news' ][ 'fieldid' ] = " category_id " ;
$sublink_type [ 'news' ][ 'fieldname' ] = " category_name " ;
$sublink_type [ 'news' ][ 'fieldicon' ] = " category_icon " ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$sublink_type [ 'downloads' ][ 'title' ] = LINKLAN_9 ; //"Download Categories";
$sublink_type [ 'downloads' ][ 'table' ] = " download_category " ;
$sublink_type [ 'downloads' ][ 'query' ] = " download_category_parent ='0' ORDER BY download_category_name ASC " ;
$sublink_type [ 'downloads' ][ 'url' ] = " download.php?list.# " ;
$sublink_type [ 'downloads' ][ 'fieldid' ] = " download_category_id " ;
$sublink_type [ 'downloads' ][ 'fieldname' ] = " download_category_name " ;
$sublink_type [ 'downloads' ][ 'fieldicon' ] = " download_category_icon " ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $sql -> db_Select ( " plugin " , " plugin_path " , " plugin_installflag = '1' " ))
2008-09-23 19:37:36 +00:00
{
2008-12-15 22:32:24 +00:00
while ( $row = $sql -> db_Fetch ())
{
$sublink_plugs [] = $row [ 'plugin_path' ];
}
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
foreach ( $sublink_plugs as $plugin_id )
{
if ( is_readable ( e_PLUGIN . $plugin_id . '/e_linkgen.php' ))
{
require_once ( e_PLUGIN . $plugin_id . '/e_linkgen.php' );
}
}
if ( $name )
{
return $sublink_type [ $name ];
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
return $sublink_type ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function prepOpts ( $aData )
2006-12-02 04:36:16 +00:00
{
2008-12-15 22:32:24 +00:00
//
// Prepare an array that can rapidly (no looping)
// generate an HTML option string, with one item possibly selected.
// prepOpts returns a prepared array containing the possible values in this form:
//
// <option value="xxxxx"
// >text for first</option><option value="yyyy"
// >text for next</option>
//
// $aData is an array containing value/text pairs:
// each entry is array( 'val'=>value, 'txt'=>text )
//
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
2008-12-15 22:32:24 +00:00
$i = 0 ;
foreach ( $aData as $aVal )
{
$sVal = $aVal [ 'val' ];
$sTxt = $aVal [ 'txt' ];
$sOut = " " ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
if ( $i )
$sOut = '>' . $sTxtPrev . '</option>' ;
$sOut .= '<option value="' . $sVal . '"' ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
$aPrep [ $i ++ ] = $sOut ;
$sTxtPrev = $sTxt ;
}
if ( $i )
{ // terminate final option
$aPrep [ $i ] = '>' . $sTxtPrev . '</option>' ;
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
return $aPrep ;
2008-11-02 10:15:37 +00:00
}
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
function genOpts ( $aPrep , $aTest , $sSelected , $sId )
2008-11-02 10:15:37 +00:00
{
2008-12-15 22:32:24 +00:00
//
// Generate an HTML option string, with one item possibly selected.
// aGen is a prepared array containing the possible values in this form.
// if sSelected matches an aTest entry, that entry is selected.
// aTest can be any array that matches one-for-one with the options
//
// if $sId is nonblank, a global search/replace is done to change all "|||" to $sId.
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
2008-12-15 22:32:24 +00:00
$iKey = array_search ( $sSelected , $aTest );
if ( $iKey !== FALSE )
{
$aNew = $aPrep ;
$aNew [ $iKey ] .= " selected='selected' " ;
$sOut = implode ( $aNew );
} else
{
$sOut = implode ( $aPrep );
}
if ( strlen ( $sId ))
$sOut = str_replace ( " ||| " , $sId , $sOut );
return $sOut ;
}
2006-12-02 04:36:16 +00:00
2008-12-15 22:32:24 +00:00
} // End - class 'links'
2008-11-02 10:15:37 +00:00
// Log event to admin log
2008-12-15 22:32:24 +00:00
function sitelinks_adminlog ( $msg_num = '00' , $woffle = '' )
2008-11-02 10:15:37 +00:00
{
2008-12-15 22:32:24 +00:00
global $pref , $admin_log ;
// if (!varset($pref['admin_log_log']['admin_sitelinks'],0)) return;
$admin_log -> log_event ( 'SLINKS_' . $msg_num , $woffle , E_LOG_INFORMATIVE , '' );
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
function links_adminmenu ()
2008-09-23 19:37:36 +00:00
{
2006-12-02 04:36:16 +00:00
global $action ;
2008-12-15 22:32:24 +00:00
if ( $action == " " )
2008-09-23 19:37:36 +00:00
{
2006-12-02 04:36:16 +00:00
$action = " main " ;
}
$var [ 'main' ][ 'text' ] = LCLAN_62 ;
$var [ 'main' ][ 'link' ] = e_SELF ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
$var [ 'create' ][ 'text' ] = LCLAN_63 ;
$var [ 'create' ][ 'link' ] = e_SELF . " ?create " ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
$var [ 'opt' ][ 'text' ] = LAN_OPTIONS ;
$var [ 'opt' ][ 'link' ] = e_SELF . " ?opt " ;
2008-12-16 11:05:36 +00:00
2006-12-02 04:36:16 +00:00
$var [ 'sub' ][ 'text' ] = LINKLAN_4 ;
$var [ 'sub' ][ 'link' ] = e_SELF . " ?sublinks " ;
2008-12-16 11:05:36 +00:00
2008-12-15 22:32:24 +00:00
// $var['debug']['text'] = "List DB";
// $var['debug']['link'] = e_SELF."?debug";
2008-12-16 11:05:36 +00:00
2007-06-05 20:07:35 +00:00
2008-12-21 12:53:11 +00:00
e_admin_menu ( LCLAN_68 , $action , $var );
2006-12-02 04:36:16 +00:00
}
2008-12-15 22:32:24 +00:00
/**
* 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(LCLAN_58). " ) . addModLan ( 'core' , 'delete_confirm' );
</ script >
< script type = 'text/javascript' src = '".e_FILE_ABS."jslib/core/admin.js' ></ script >
" ;
return $ret ;
}
?>