diff --git a/TODO b/TODO index abb73f62..3330ec80 100644 --- a/TODO +++ b/TODO @@ -8,10 +8,6 @@ * php extension * database table or column * kathrine tickets - show/hide - * admin panel Menus: - * open in external window (_blank option) - * color of the link - * should the link blink? * cache: * hooks * Menus in templates diff --git a/common.php b/common.php index 44e3ba0f..2484acdb 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.8.0-dev'); -define('DATABASE_VERSION', 22); +define('DATABASE_VERSION', 23); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/system/migrations/23.php b/system/migrations/23.php new file mode 100644 index 00000000..ee1e33f0 --- /dev/null +++ b/system/migrations/23.php @@ -0,0 +1,7 @@ +hasColumn(TABLE_PREFIX . 'menu', 'blank')) + $db->query('ALTER TABLE `' . TABLE_PREFIX . 'menu` ADD `blank` TINYINT(1) NOT NULL DEFAULT 0 AFTER `link`;'); + +if(!$db->hasColumn(TABLE_PREFIX . 'menu', 'color')) + $db->query('ALTER TABLE `' . TABLE_PREFIX . 'menu` ADD `color` CHAR(6) NOT NULL DEFAULT "ffffff" AFTER `blank`;'); \ No newline at end of file diff --git a/system/pages/admin/menus.php b/system/pages/admin/menus.php index cf7ed13e..e5ec54fd 100644 --- a/system/pages/admin/menus.php +++ b/system/pages/admin/menus.php @@ -22,6 +22,8 @@ if(isset($_REQUEST['template'])) { if(isset($_REQUEST['menu'])) { $post_menu = $_REQUEST['menu']; $post_menu_link = $_REQUEST['menu_link']; + $post_menu_blank = $_REQUEST['menu_blank']; + $post_menu_color = $_REQUEST['menu_color']; if(count($post_menu) != count($post_menu_link)) { echo 'Menu count is not equal menu links. Something went wrong when sending form.'; return; @@ -34,7 +36,7 @@ if(isset($_REQUEST['template'])) { continue; try { - $db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'category' => $category, 'ordering' => $i)); + $db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'blank' => $post_menu_blank[$category][$i] == 'on', 'color' => str_replace('#', '', $post_menu_color[$category][$i]), 'category' => $category, 'ordering' => $i)); } catch(PDOException $error) { warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage()); @@ -59,15 +61,18 @@ if(isset($_REQUEST['template'])) { return; } - echo 'Hint: You can drag menu items.
Editing: ' . $template . ' template.'; + echo 'Hint: You can drag menu items.
+ Hint: Add links to external sites using: http:// prefix.
+ Not all templates support blank and colorful links.
+ Editing: ' . $template . ' template.'; $menus = array(); - $menus_db = $db->query('SELECT `name`, `link`, `category`, `ordering` FROM `' . TABLE_PREFIX . 'menu` WHERE `enabled` = 1 AND `template` = ' . $db->quote($template) . ' ORDER BY `ordering` ASC;')->fetchAll(); + $menus_db = $db->query('SELECT `name`, `link`, `blank`, `color`, `category`, `ordering` FROM `' . TABLE_PREFIX . 'menu` WHERE `enabled` = 1 AND `template` = ' . $db->quote($template) . ' ORDER BY `ordering` ASC;')->fetchAll(); foreach($menus_db as $menu) { - $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'ordering' => $menu['ordering']); + $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'blank' => $menu['blank'], 'color' => $menu['color'], 'ordering' => $menu['ordering']); } - + $last_id = array(); - echo '
'; + echo ''; echo ''; foreach($config['menu_categories'] as $id => $cat) { echo '

' . $cat['name'] . '

'; @@ -75,7 +80,14 @@ if(isset($_REQUEST['template'])) { if(isset($menus[$id])) { $i = 0; foreach($menus[$id] as $menu) { - echo '
  • '; + echo '
  • + + + + + + +
  • '; $i++; $last_id[$id] = $i; diff --git a/system/template.php b/system/template.php index 55b7de0d..6fc3c166 100644 --- a/system/template.php +++ b/system/template.php @@ -101,9 +101,10 @@ function get_template_menus() { global $db, $config, $template_name; $menus = array(); - $query = $db->query('SELECT `name`, `link`, `category` FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($template_name) . ' ORDER BY `category`, `ordering` ASC'); + $query = $db->query('SELECT `name`, `link`, `blank`, `color`, `category` FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($template_name) . ' ORDER BY `category`, `ordering` ASC'); foreach($query->fetchAll() as $menu) { - $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link']); + $link_full = strpos(trim($menu['link']), 'http') === 0 ? $menu['link'] : getLink($menu['link']); + $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'link_full' => $link_full, 'blank' => $menu['blank'] == 1, 'color' => '#' . $menu['color']); } $new_menus = array(); diff --git a/system/templates/admin.menus.js.html.twig b/system/templates/admin.menus.js.html.twig index d52b8405..edfff02d 100644 --- a/system/templates/admin.menus.js.html.twig +++ b/system/templates/admin.menus.js.html.twig @@ -1,4 +1,4 @@ - + - \ No newline at end of file + + + + \ No newline at end of file diff --git a/templates/kathrine/template.php b/templates/kathrine/template.php index 56ce5daf..38c94df0 100644 --- a/templates/kathrine/template.php +++ b/templates/kathrine/template.php @@ -91,12 +91,7 @@ defined('MYAAC') or die('Direct access not allowed!'); $i = 0; foreach($menus[$category] as $menu) { - if(strpos(trim($menu['link']), 'http') === 0) { - echo '' . $menu['name'] . ''; - } - else { - echo '' . $menu['name'] . ''; - } + echo '' . $menu['name'] . ''; if(++$i != $size) { echo ''; diff --git a/templates/tibiacom/index.php b/templates/tibiacom/index.php index c03765b4..f20c4dc6 100644 --- a/templates/tibiacom/index.php +++ b/templates/tibiacom/index.php @@ -341,13 +341,12 @@ foreach($config['menu_categories'] as $id => $cat) {
    _Submenu' class='Submenu'> $menu) { - $is_external = strpos(trim($menu['link']), 'http') === 0; ?> - '> -