";
$ns->tablerender(LCLAN_29, $text);
}
function submit_link($sub_action, $id)
{
global $sql, $e107cache, $tp;
if(!is_object($tp))
{
$tp=new e_parse;
}
$id = intval($id);
$parent_id = ($_POST['link_parent']) ? intval($_POST['link_parent']) : 0;
$link_name = $tp->toDB($_POST['link_name']);
$link_url = $tp->createConstants($_POST['link_url']);
$link_url = str_replace("&","&",$link_url); // xhtml compliant links.
$link_description = $tp->toDB($_POST['link_description']);
$link_button = $tp->toDB($_POST['link_button']);
$link_render = intval($_POST['linkrender']);
$link_open = intval($_POST['linkopentype']);
$link_class = $tp->toDB($_POST['link_class']);
$link_t = $sql->db_Count("links", "(*)");
if ($id)
{
$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}'");
//rename all sublinks to eliminate old embedded 'submenu' etc hierarchy.
// this is for upgrade compatibility only. Current hierarchy uses link_parent.
$e107cache->clear("sitelinks");
$this->show_message(LCLAN_3);
}
else
{
$sql->db_Insert("links", "0, '$link_name', '$link_url', '$link_description', '$link_button', ".$link_render.", ".($link_t+1).", ".$parent_id.", ".$link_open.", ".$link_class);
$e107cache->clear("sitelinks");
$this->show_message(LCLAN_2);
}
}
function show_pref_options() {
global $pref, $ns;
$text = "
";
$ns->tablerender(LCLAN_88, $text);
}
// Delete link
// We need to update the 'order' number of other links with the same parentage - may be top level or a sub-level
function delete_link($linkInfo)
{
global $sql;
if ($sql->db_Select("links", "link_id", "link_order > '{$linkInfo['link_order']}' AND `link_parent`={$linkInfo['link_parent']} "))
{
$linkList = $sql->db_getList();
foreach($linkList as $l)
{
$sql->db_Update("links", "link_order = link_order -1 WHERE link_id = '{$l['link_id']}'");
}
}
if ($sql->db_Delete("links", "link_id='".$linkInfo['link_id']."'"))
{
// Update orphaned sublinks - just hide them, and make them top level. And delete any obsolete naming while we're there
$sql->db_Update("links", "link_name = SUBSTRING_INDEX(link_name, '.', -1) , link_parent = '0', link_class='255' WHERE link_parent= '".$linkInfo['link_id']."'");
return LCLAN_53." #".$linkInfo['link_id']." ".LCLAN_54." ";
}else{
return DELETED_FAILED;
}
}
// -------------------------- Sub links generator ------------->
function show_sublink_generator()
{
global $ns,$sql;
$sublinks = $this->sublink_list();
$text = "
";
$ns->tablerender(LINKLAN_4, $text);
}
function sublink_list($name="")
{
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";
$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";
if ($sql -> db_Select("plugin", "plugin_path", "plugin_installflag = '1'"))
{
while ($row = $sql -> db_Fetch())
{
$sublink_plugs[] = $row['plugin_path'];
}
}
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];
}
return $sublink_type;
}
function prepOpts($aData)
{
//
// 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:
//
//
//
// $aData is an array containing value/text pairs:
// each entry is array( 'val'=>value, 'txt'=>text )
//
$i=0;
foreach($aData as $aVal)
{
$sVal = $aVal['val'];
$sTxt = $aVal['txt'];
$sOut="";
if ($i) $sOut = '>'.$sTxtPrev.'';
$sOut .= '';
}
return $aPrep;
}
function genOpts($aPrep, $aTest,$sSelected, $sId)
{
//
// 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.
$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;
}
}
function links_adminmenu()
{
global $action;
if ($action == "")
{
$action = "main";
}
$var['main']['text'] = LCLAN_62;
$var['main']['link'] = e_SELF;
$var['create']['text'] = LCLAN_63;
$var['create']['link'] = e_SELF."?create";
$var['opt']['text'] = LAN_OPTIONS;
$var['opt']['link'] = e_SELF."?opt";
$var['sub']['text'] = LINKLAN_4;
$var['sub']['link'] = e_SELF."?sublinks";
// $var['debug']['text'] = "List DB";
// $var['debug']['link'] = e_SELF."?debug";
show_admin_menu(LCLAN_68, $action, $var);
}
?>