From 5be363265f4b0f5017c2496a1fecdfbbde443b9a Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Mon, 23 Nov 2009 11:51:02 +0000 Subject: [PATCH] re-write of admin->links + some form-handler option fixes. --- e107_admin/links.php | 1467 +++++++------------------------- e107_handlers/e107_class.php | 6 +- e107_handlers/form_handler.php | 16 +- 3 files changed, 310 insertions(+), 1179 deletions(-) diff --git a/e107_admin/links.php b/e107_admin/links.php index 038da3fce..98c55c1c6 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -1,1102 +1,118 @@ form = "core-links-edit-form"; -$pst->page = "links.php?create"; -$pst->id = "admin_links"; -require_once ('auth.php'); -// -------------------- -$pst->save_preset(); - -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"); - -$rs = new form(); - -define("URL_SEPARATOR", 'X'); // Used in names of 'inc' and 'dec' fields - -$linkpost = new links(); -$emessage = &eMessage::getInstance(); -/* -$action = ''; -if(e_QUERY) +class links_admin extends e_admin_dispatcher { - $tmp = explode('.', e_QUERY); - $action = $tmp[0]; - $sub_action = varset($tmp[1], ''); - $id = varset($tmp[2], ''); - unset($tmp); -} -*/ + + protected $modes = array( + 'main' => array( + 'controller' => 'links_admin_ui', + 'path' => null, + 'ui' => 'links_admin_form_ui', + 'uipath' => null + ) + ); -/* -$incdec_action = ''; -foreach(array_keys($_POST) as $k) -{ - 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]); - } -}*/ + protected $adminMenu = array( + 'main/list' => array('caption'=> LCLAN_62, 'perm' => 'I'), + 'main/create' => array('caption'=> LCLAN_63, 'perm' => 'I'), + 'main/prefs' => array('caption'=> LAN_OPTIONS, 'perm' => 'I'), + 'main/sublinks' => array('caption'=> LINKLAN_4, 'perm' => 'I') + ); -if(isset($_POST['generate_sublinks']) && isset($_POST['sublink_type']) && $_POST['sublink_parent'] != "") -{ - $subtype = $_POST['sublink_type']; - $sublink = $linkpost->sublink_list($subtype); - - $sql2 = e107::getDb('sql2'); - - $sql->db_Select("links", "*", "link_id = '".$_POST['sublink_parent']."'"); - $par = $sql->db_Fetch(); - extract($par); - - $sql->db_Select($sublink['table'], "*", $sublink['query']); - $count = 1; - while($row = $sql->db_Fetch()) - { - $subcat = $row[($sublink['fieldid'])]; - $name = $row[($sublink['fieldname'])]; - $subname = $name; // eliminate old embedded hierarchy from names. (e.g. 'submenu.TopName.name') - $suburl = str_replace("#", $subcat, $sublink['url']); - $subicon = ($sublink['fieldicon']) ? $row[($sublink['fieldicon'])] : $link_button; - $subdiz = ($sublink['fielddiz']) ? $row[($sublink['fielddiz'])] : $link_description; - $subparent = $_POST['sublink_parent']; - - if($sql2->db_Insert("links", "0, '$subname', '$suburl', '$subdiz', '$subicon', '$link_category', '$count', '$subparent', '$link_open', '$link_class' ")) - { - $message .= LAN_CREATED." ({$name})[!br!]"; - $emessage->add(LAN_CREATED." ({$name})", E_MESSAGE_SUCCESS); - } else - { - $message .= LAN_CREATED_FAILED." ({$name})[!br!]"; - $emessage->add(LAN_CREATED_FAILED." ({$name})", E_MESSAGE_ERROR); - } - $count++; - } - - if($message) - { - sitelinks_adminlog('01', $message); // 'Sublinks generated' - } -} -// DEPRECATED. -/* -if($incdec_action == 'inc') -{ - $sql->db_Update("links", "link_order=link_order+1 WHERE link_order='".intval($link_order - 1)."'"); - $sql->db_Update("links", "link_order=link_order-1 WHERE link_id='".intval($linkid)."'"); - sitelinks_adminlog('02', 'Id: '.$linkid); -} -elseif($incdec_action == 'dec') -{ - $sql->db_Update("links", "link_order=link_order-1 WHERE link_order='".intval($link_order + 1)."'"); - $sql->db_Update("links", "link_order=link_order+1 WHERE link_id='".intval($linkid)."'"); - sitelinks_adminlog('03', 'Id: '.$linkid); -}*/ - -// DEPRECATED - use batch method instead. -/*if(isset($_POST['update'])) -{ - foreach($_POST['link_order'] as $loid) - { - $tmp = explode(".", $loid); - $sql->db_Update("links", "link_order=".intval($tmp[1])." WHERE link_id=".intval($tmp[0])); - } - foreach($_POST['link_class'] as $lckey => $lcid) - { - $sql->db_Update("links", "link_class='".$lcid."' WHERE link_id=".intval($lckey)); - } - $e107cache->clear("sitelinks"); - $emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS); - sitelinks_adminlog('04', ''); -}*/ - -if(isset($_POST['updateoptions'])) -{ - $changed = FALSE; - foreach(array('linkpage_screentip', 'sitelinks_expandsub') as $opt) - { - $temp = intval($_POST[$opt]); - if($temp != $pref[$opt]) - { - $pref[$opt] = $temp; - $changed = TRUE; - } - } - if($changed) - { - save_prefs(); - $e107cache->clear("sitelinks"); - sitelinks_adminlog('05', $pref['linkpage_screentip'].','.$pref['sitelinks_expandsub']); - $emessage->add(LCLAN_1, E_MESSAGE_SUCCESS); - } - else - { - // Nothing changed - $emessage->add(LINKLAN_11); - } -} - - - - - - -require_once ('footer.php'); -exit(); - -// End --------------------------------------------------------------------------------------------------------------------------------------------------------------------- - - -class links -{ - var $link_total; - var $aIdOptPrep, $aIdOptData, $aIdOptTest; - var $debug_dis = FALSE; - var $linkArray = array(); - var $linkCategory = array(); - var $linkOpen = array(); - var $mode = 'main'; - private $linkFunctions = array(); + protected $adminMenuAliases = array( + 'main/edit' => 'main/list' + ); - function __construct() - { - global $user_pref; - $sql = e107::getDb(); + protected $menuTitle = 'links'; +} + +class links_admin_ui extends e_admin_ui +{ - if(varset($_GET['mode'])) - { - $this->mode = $_GET['mode']; - } + protected $pluginTitle = "Site links"; + protected $pluginName = 'core'; + protected $table = "links"; - // get e_sitelink functions. - $tmp = e107::getAddonConfig('e_sitelink','sitelinks'); - $this->linkFunctions[0] = "(".LAN_OPTIONAL.")"; - foreach($tmp as $cat=> $array) - { - $func = array(); - foreach($array as $val) - { - $newkey = $cat.'::'.$val['function']; - $func[$newkey] = $val['name']; - } - $this->linkFunctions[$cat] = $func; - } - - - - if (varset($_POST['etrigger_ecolumns'])) - { - $user_pref['admin_links_columns'] = $_POST['e-columns']; - save_prefs('user'); - } - - $this->linkCategory = array( - 1 => "1 - Main", - 2 => "2 - Alt", - 3 => "3 - Alt", - 4 => "4 - Alt", - 5 => "5 - Alt", - 6 => "6 - Alt", - 7 => "7 - Alt", - 8 => "8 - Alt", - 9 => "9 - Alt", - 10 => "10 - Alt" + /** + * If present this array will be used to build your list query + * You can link fileds from $field array with 'table' parameter, which should equal to a key (table) from this array + * 'leftField', 'rightField' and 'fields' attributes here are required, the rest is optional + * + * @var array [optional] + */ + protected $tableJoin = array ( + // 'u.user' => array('leftField' => 'comment_author_id', 'rightField' => 'user_id', 'fields' => '*'/*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => 'AND u.user_ban=0', 'where' => ''*/) ); - $this->linkOpen = array( - 0 => LCLAN_20, // 0 = same window - 1 => LCLAN_23, // new window - 4 => LCLAN_24, // 4 = miniwindow 600x400 - 5 => LINKLAN_1 // 5 = miniwindow 800x600 - ); + //protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #links"; // without any Order or Limit. + //protected $editQry = "SELECT * FROM #links WHERE comment_id = {ID}"; - $this->fields = array( - 'checkboxes' => array('title'=> '','width' => '3%','forced' => true,'thclass' => 'center first'), - 'link_button' => array('title'=> LCLAN_89, 'width'=>'5%', 'thclass' => 'center'), - 'link_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), - 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'text'), - 'link_url' => array('title'=> LCLAN_93, 'width'=>'auto','type'=>'text'), - 'link_class' => array('title'=> LAN_USERCLASS, 'type' => 'array', 'method'=>'tinymce_class', 'width' => 'auto'), - 'link_description' => array('title'=> LCLAN_17, 'type' => 'array', 'method'=>'tinymce_plugins', 'width' => 'auto'), - 'link_category' => array('title'=> LCLAN_12, 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>1, 'width' => 'auto'), - 'link_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>2, 'width' => 'auto'), - 'link_parent' => array('title'=> LINKLAN_2, 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>3, 'width' => 'auto', 'thclass' => 'left first'), - 'link_open' => array('title'=> LCLAN_19, 'type' => 'text', 'method'=>'tinymce_buttons', 'methodparms'=>4, 'width' => 'auto', 'thclass' => 'left first'), - 'increment' => array('title'=> LCLAN_91,'width' => '3%','forced' => true,'thclass' => 'center'), - 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last') + protected $pid = "link_id"; + protected $perPage = 15; + protected $batchDelete = true; + + protected $fields = array( + 'checkboxes' => array('title'=> '', 'width' => '3%','forced' => true,'thclass' => 'center first','class' => 'center first'), + 'link_button' => array('title'=> LAN_ICON, 'type'=>'icon', 'width'=>'5%', 'thclass' => 'center', 'class'=>'center'), + 'link_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), + 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'text'), + 'link_parent' => array('title'=> 'Sublink of', 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), + 'link_url' => array('title'=> LCLAN_93, 'width'=>'auto','type'=>'text'), + 'link_class' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'batch'=>true, 'filter'=>true, 'width' => 'auto'), + 'link_description' => array('title'=> LCLAN_17, 'type' => 'bbarea', 'method'=>'tinymce_plugins', 'width' => 'auto'), + 'link_category' => array('title'=> LCLAN_12, 'type' => 'method', 'batch'=>true, 'filter'=>true, 'width' => 'auto'), + 'link_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto'), + 'link_open' => array('title'=> LCLAN_19, 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), + 'link_function' => array('title'=> 'Function', 'type' => 'method', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left first'), + + // 'increment' => array('title'=> LCLAN_91, 'width' => '3%','forced' => true,'thclass' => 'center'), + 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class'=>'center') ); - $this->fieldpref = (varset($user_pref['admin_links_columns'])) ? $user_pref['admin_links_columns'] : array_keys($this->fields); - - if(varset($_POST['inc'])) - { - list($link_id,$link_order) = explode(URL_SEPARATOR,key($_POST['inc'])); - $sql->db_Update("links", "link_order=link_order+1 WHERE link_order='".intval($link_order - 1)."'"); - $sql->db_Update("links", "link_order=link_order-1 WHERE link_id='".intval($link_id)."'"); - sitelinks_adminlog('02', 'Id: '.$link_id); - } - - if(varset($_POST['dec'])) - { - list($link_id,$link_order) = explode(URL_SEPARATOR,key($_POST['dec'])); - $sql->db_Update("links", "link_order=link_order-1 WHERE link_order='".intval($link_order + 1)."'"); - $sql->db_Update("links", "link_order=link_order+1 WHERE link_id='".intval($link_id)."'"); - sitelinks_adminlog('03', 'Id: '.$link_id); - } - - if(varset($_POST['execute_batch'])) - { - $this->process_batch($_POST['link_selected']); - } - - if(varset($_POST['add_link'])) - { - $this->submit_link($sub_action, $_POST['link_id']); - } - - if(varset($_POST['delete'])) - { - $del_id = key($_POST['delete']); - if($sql->db_Select("links", "link_id, link_name, link_order, link_parent", "link_id=".intval($del_id))) - { - $row = $sql->db_Fetch(); - $this->delete_link($row); // Admin logging in class routine - } - } - - $this->linkArray = $this->getLinks(); - - if(varset($_POST['edit'])) - { - $this->create_link('edit', key($_POST['edit'])); - return; - } - - if(varset($_POST['sub'])) - { - $this->mode = 'sub'; - $this->create_link('sub', key($_POST['sub'])); - return; - } - - - switch ($this->mode) // page display mode - { - - case 'main': - - $this->show_existing_items(); - break; - - case 'create': - $this->create_link($sub_action,0); - break; - - case 'debug': - $linkpost->show_existing_items(TRUE); - break; - - case 'opt': - $this->show_pref_options(); - break; - - case 'sub': - $this->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; - } - - } - - - 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; - } - - 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.) - - - if(substr($text, 0, 8) == "submenu.") // for backwards compatibility only. - { - $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. - } - return $tmp; - } - else - { - return $text; - } - } - - function dropdown($curval = "", $lid = 0, $indent = 0) - { // Drop-down list using on the parent_id. :) - - - global $linkArray, $id, $sub_action; - - if(0 == $indent) - { - $ret = "\n"; - } - foreach($this->linkArray[$lid] as $l) - { - $s = ($l['link_id'] == $curval ? " selected='selected' " : ""); - $thename = $this->linkName($l['link_name']); - // prevent making self the parent. - if($l['link_id'] == $id) - { - $thename = "(".$thename.")"; - } - if($sub_action == "sub") - { - $thelink = ($l['link_id'] != $lid) ? $l['link_id'] : $l['link_parent']; - } - else - { - $thelink = ($l['link_id'] != $id) ? $l['link_id'] : $l['link_parent']; - } - $ret .= "\n"; - - if(array_key_exists($l['link_id'], $this->linkArray)) - { - $ret .= $this->dropdown($curval, $l['link_id'], $indent + 1); - } - } - return $ret; - } - - - function existing($id = 0, $level = 0) - { - global $linkArray; - $ret = ""; - foreach($linkArray[$id] as $l) - { - $s = ($l['link_parent'] == $curval ? " selected='selected' " : ""); - $ret .= $this->display_row($l, $level); - if(array_key_exists($l['link_id'], $this->linkArray)) - { - $ret .= $this->existing($l['link_id'], $level + 1); - } - } - return $ret; - } - - - function show_existing_items($dbg_display = FALSE) - { - global $rs, $emessage; - - $sql = e107::getDb(); - $frm = e107::getForm(); - $tp = e107::getParser(); - $ns = e107::getRender(); - - $this->debug_dis = $dbg_display; - - if(count($this->linkArray)) - { - $text = $rs->form_open("post", e_SELF, "myform_{$link_id}", "", ""); - $text .= " - - - "; - - /* - - $this->prepIdOpts(); // Prepare the options list for all links - $text = $rs->form_open("post", e_SELF, "myform_{$link_id}", "", ""); - $text .= " - - - "; - - $text .= $rs->form_close(); - */ - - } - else - { - $text .= "
".LCLAN_61."
"; - } - - $ns->tablerender(LCLAN_8, $emessage->render().$text); - } - - - - function renderValue($key,$row) - { - $frm = e107::getForm(); - $tp = e107::getParser(); - - $text = ""; - $att = $this->fields[$key]; - - if($key == 'checkboxes') - { - $rowid = "link_selected[".$row["link_id"]."]"; - return $frm->checkbox($rowid, $row['link_id']); - } - - if($key == "link_name") // FIXME - incorrect links. - { - $link = (substr($row['link_url'],0,3)=='{e_') ? $tp->replaceConstants($row['link_url']) : e_BASE.$row['link_url']; - return "".$this->linkName($row['link_name']).""; - } - - if($key == "link_button") - { - $button = $tp->replaceConstants($row['link_button']); - return ($button) ? "" : " "; - } - - if($key == "link_class") - { - return $frm->uc_label($row['link_class']); - } - - if($key == "link_category") - { - $cat = $row['link_category']; - return $this->linkCategory[$cat]; - } - - if($key == "link_open") - { - return $this->linkOpen[$row['link_open']]; - } - - if($key == "increment") - { - $name_suffix = $row["link_id"].URL_SEPARATOR.$row["link_order"]; - $text .= ""; - $text .= ""; - return $text; - } - - - if($key == "options") - { - $id = $row['link_id']; - - $text .= ""; - $text .= ""; - $text .= ""; - return $text; - } - - return $row[$key]; - } - - - - - function prepIdOpts() - { - for($a = 1; $a <= $this->link_total; $a++) - { - $sTxt = "".$a; - $this->aIdOptData[] = array('val' => '|||.'.$a, 'txt' => $sTxt); // Later, ||| becomes Id - $this->aIdOptTest[] = $sTxt; - } - $this->aIdOptPrep = $this->prepOpts($this->aIdOptData); - } - - function display_row($row2, $indent = FALSE) - { - global $sql, $rs, $tp, $linkArray, $previous_cat; - extract($row2); - - if($link_category > 1 && $link_category != $previous_cat) - { - $text .= " - - - - - - "; - $e107->ns->tablerender(LCLAN_29, $emessage->render().$text); - } - - function submit_link($sub_action, $id) - { - global $e107cache,$emessage; - $sql = e107::getDb(); - $tp = e107::getParser(); - - - $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 = ; - // $link_button = ; - // $link_render = ; -// $link_open = ; - $link_class = $tp->toDB($_POST['link_class']); - - $message = implode('[!br!]', array($link_name, $link_url, $link_class)); // Probably enough to log - $link_t = $sql->db_Count("links", "(*)"); + //required (but should be optional) - default column user prefs + // protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_comment', 'comment_type', 'options'); - $insert = array( - 'link_parent' => $parent_id, - 'link_name' => $link_name, - 'link_url' => $link_url, - 'link_description' => $tp->toDB($_POST['link_description']), - 'link_button' => $tp->toDB($_POST['link_button']), - 'link_category' => intval($_POST['linkrender']), - 'link_open' => intval($_POST['linkopentype']), - 'link_class' => $link_class, - 'link_function' => $_POST['link_function'], - 'WHERE' => "link_id=".$id + // optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName); + + protected $prefs = array( + 'linkpage_screentip' => array('title'=>LCLAN_78, 'type'=>'boolean', 'help'=>LCLAN_79), + 'sitelinks_expandsub' => array('title'=>LCLAN_80, 'type'=>'boolean', 'help'=>LCLAN_81) ); - - - 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}'"); - $status = $sql->db_Update("links", $insert) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; - //rename all sublinks to eliminate old embedded 'submenu' etc hierarchy. - // this is for upgrade compatibility only. Current hierarchy uses link_parent. - $e107cache->clear("sitelinks"); - sitelinks_adminlog('08', $message); - $emessage->add(LCLAN_3, $status); - } - else - { // New link - - $insert['link_order'] = $link_t + 1; - // $sql->db_Insert("links", "0, '$link_name', '$link_url', '$link_description', '$link_button', ".$link_render.", ".($link_t + 1).", ".$parent_id.", ".$link_open.", ".$link_class,TRUE); - $status = $sql->db_Insert("links", $insert) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; - - $e107cache->clear("sitelinks"); - sitelinks_adminlog('07', $message); - $emessage->add(LCLAN_2, $status); - } - } - - function show_pref_options() - { - global $pref, $e107, $emessage; - $text = " -
- -
- - - "; - $e107->ns->tablerender(LCLAN_88, $emessage->render().$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, $emessage, $e107cache; - - 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']."'"); - - $message = LCLAN_53." #".$linkInfo['link_id']." ".LCLAN_54; - $emessage->add($message, E_MESSAGE_SUCCESS); - sitelinks_adminlog('06', $message.'[!br!]'.$linkInfo['link_name']); - $e107cache->clear("sitelinks"); - } else - { - $emessage->add($message, E_MESSAGE_ERROR); - } - - } - - // -------------------------- Sub links generator -------------> - - - function show_sublink_generator() + + function sublinksPage() { global $e107, $sql, $emessage; @@ -1151,7 +167,8 @@ class links "; - $e107->ns->tablerender(LINKLAN_4, $emessage->render().$text); + //$e107->ns->tablerender(LINKLAN_4, $emessage->render().$text); + echo $emessage->render().$text; } function sublink_list($name = "") @@ -1196,123 +213,229 @@ class links return $sublink_type; } - - function prepOpts($aData) + + + function init() { - // - // 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) + $sql = e107::getDb(); + $mes = e107::getMessage(); + + if(isset($_POST['generate_sublinks']) && isset($_POST['sublink_type']) && $_POST['sublink_parent'] != "") { - $sVal = $aVal['val']; - $sTxt = $aVal['txt']; - $sOut = ""; - - if($i) - $sOut = '>'.$sTxtPrev.''; - $sOut .= '