self::$data['page_link_cat'],
'link_name' => self::$data['page_title'],
'link_url' => 'viewpage.php?page_id='.self::$data['page_id'],
'link_icon' => '',
'link_cat' => 0,
'link_language' => LANGUAGE,
'link_visibility' => self::$data['page_access'],
'link_order' => 0,
'link_position' => 1,
'link_window' => 0,
'link_position_id' => 0,
'link_status' => 1
];
if ($has_link) {
$data = SiteLinks::get_current_SiteLinks("viewpage.php?page_id=".self::$data['page_id']);
}
if (isset($_GET['add_sl']) or $has_link === TRUE) {
if (isset($_POST['save_link'])) {
$data = [
"link_id" => $data['link_id'],
"link_cat" => form_sanitizer($_POST['link_cat'], 0, 'link_cat'),
"link_name" => form_sanitizer($_POST['link_name'], '', 'link_name'),
"link_url" => $data['link_url'],
"link_icon" => form_sanitizer($_POST['link_icon'], '', 'link_icon'),
"link_language" => $data['link_language'],
"link_visibility" => $data['link_visibility'],
"link_position" => form_sanitizer($_POST['link_position'], '', 'link_position'),
"link_order" => form_sanitizer($_POST['link_order'], '', 'link_order'),
"link_window" => form_sanitizer(isset($_POST['link_window']) && $_POST['link_window'] == 1 ? 1 : 0,
0,
'link_window'),
"link_status" => form_sanitizer($_POST['link_status'], 0, 'link_status')
];
if ($data['link_position'] > 3) {
$data['link_position'] = form_sanitizer($_POST['link_position_id'], 3,
'link_position_id');
}
$data['link_position_id'] = $data['link_position'];
if (empty($data['link_order'])) {
$max_order_query = "SELECT MAX(link_order) 'link_order' FROM ".DB_SITE_LINKS."
".(multilang_table("SL") ? "WHERE link_language='".LANGUAGE."' AND" : "WHERE")."
link_cat='".$data['link_cat']."'";
$data['link_order'] = dbresult(dbquery($max_order_query), 0) + 1;
}
if (\defender::safe()) {
if (!empty($data['link_id'])) {
dbquery_order(DB_SITE_LINKS, $data['link_order'], "link_order",
$data['link_id'],
"link_id",
$data['link_cat'], "link_cat", multilang_table("SL"),
"link_language",
"update");
dbquery_insert(DB_SITE_LINKS, $data, 'update');
addNotice("success", self::$locale['page_0313']);
} else {
dbquery_order(DB_SITE_LINKS, $data['link_order'], "link_order",
$data['link_id'],
"link_id",
$data['link_cat'], "link_cat", multilang_table("SL"),
"link_language", "save");
dbquery_insert(DB_SITE_LINKS, $data, 'save');
$id = dblastid();
dbquery("UPDATE ".DB_CUSTOM_PAGES." SET page_link_cat='$id'");
addNotice("success", self::$locale['page_0314']);
}
redirect(clean_request('', ['add_sl'], FALSE));
}
}
if ($data['link_position'] > 3) {
$data['link_position_id'] = $data['link_position'];
$data['link_position'] = 4;
}
add_to_jquery("
checkLinkPosition( ".$data['link_position']." );
$('#link_position').bind('change', function(e) {
checkLinkPosition( $(this).val() );
});
");
echo form_text('link_name', self::$locale['page_0315'], $data['link_name'],
['required' => TRUE, 'inline' => TRUE]).
form_select('link_position', self::$locale['page_0316'], $data['link_position'],
[
'options' => SiteLinks::get_SiteLinksPosition(),
'inline' => TRUE,
'stacked' => form_text('link_position_id', '', '',
//$this->data['link_position_id'],
[
'required' => TRUE,
'placeholder' => 'ID',
'type' => 'number',
'width' => '150px',
'class' => 'm-b-0'
]
)
]).
form_text('link_order', self::$locale['page_0317'], $data['link_order'],
['type' => 'number', 'width' => '150px', 'inline' => TRUE]).
form_text('link_icon', self::$locale['page_0318'], $data['link_icon'],
['width' => '150px', 'inline' => TRUE]).
form_select('link_status', self::$locale['page_0319a'], $data['link_status'],
['inline' => TRUE, 'options' => [0 => self::$locale['unpublish'], 1 => self::$locale['publish']]]).
form_select_tree('link_cat', self::$locale['page_0319'], $data['link_cat'], [
"parent_value" => self::$locale['parent'],
'inline' => TRUE,
'query' => (multilang_table("SL") ? "WHERE link_language='".LANGUAGE."'" : ''),
'disable_opts' => self::$data['page_link_cat'],
'hide_disabled' => FALSE,
'class' => 'm-b-0'
], DB_SITE_LINKS, "link_name", "link_id", "link_cat")."
",
form_button('save_link', self::$locale['page_0321'], 'save_link', ['class' => 'btn-primary']);
?>