aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/config_default.inc.php29
-rw-r--r--include/menubar.inc.php33
-rw-r--r--template/yoga/menubar.tpl9
3 files changed, 57 insertions, 14 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 42a7cae8e..2b9dd1d24 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -164,11 +164,30 @@ $conf['show_version'] = true;
// links : list of external links to add in the menu. An example is the best
// than a long explanation :
//
-// $conf['links'] = array(
-// 'http://phpwebgallery.net' => 'PWG website',
-// 'http://forum.phpwebgallery.net' => 'PWG forum',
-// 'http://phpwebgallery.net/doc' => 'PWG wiki'
-// );
+// Simple use:
+// for each link is associated a label
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => 'PWG website',
+// 'http://forum.phpwebgallery.net' => 'PWG forum',
+// 'http://phpwebgallery.net/doc' => 'PWG wiki'
+// );
+//
+// Advenced use:
+// You can also used special options. Instead to pass a string like parameter value
+// you can pass a array with different optional parameter values
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => array('label' => 'PWG website', 'new_window' => true, 'eval_visible' => 'return true;'),
+// 'http://forum.phpwebgallery.net' => array('label' => 'For ADMIN', 'new_window' => true, 'eval_visible' => 'return is_admin();'),
+// 'http://phpwebgallery.net/doc' => array('label' => 'For Guest', 'new_window' => true, 'eval_visible' => 'return $user[\'is_the_guest\'];'),
+// );
+//
+// Equivalence:
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => 'PWG website',
+// );
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => array('label' => 'PWG website', 'new_window' => false, 'visible' => 'return true;'),
+// );
//
// If the array is empty, the "Links" box won't be displayed on the main
// page.
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index 09d08a902..0fcaf1cbc 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -53,15 +53,32 @@ $template->assign_vars(
);
//-------------------------------------------------------------- external links
-foreach ($conf['links'] as $url => $label)
+foreach ($conf['links'] as $url => $url_data)
{
- $template->assign_block_vars(
- 'links.link',
- array(
- 'URL' => $url,
- 'LABEL' => $label
- )
- );
+ if (!is_array($url_data))
+ {
+ $url_data = array('label' => $url_data);
+ }
+
+ if
+ (
+ (!isset($url_data['eval_visible']))
+ or
+ (eval($url_data['eval_visible']))
+ )
+ {
+ $template->assign_block_vars(
+ 'links.link',
+ array(
+ 'URL' => $url,
+ 'LABEL' => $url_data['label']
+ )
+ );
+ if (isset($url_data['new_window']) and $url_data['new_window'])
+ {
+ $template->assign_block_vars('links.link.new_window', array('1'=>'1'));
+ }
+ }
}
//------------------------------------------------------------------------ filter
diff --git a/template/yoga/menubar.tpl b/template/yoga/menubar.tpl
index 4a2425ecd..37dcd6995 100644
--- a/template/yoga/menubar.tpl
+++ b/template/yoga/menubar.tpl
@@ -6,7 +6,14 @@
<dd>
<ul>
<!-- BEGIN link -->
- <li><a href="{links.link.URL}">{links.link.LABEL}</a></li>
+ <li>
+ <a href="{links.link.URL}"
+ <!-- BEGIN new_window -->
+ onclick="window.open(this.href, ''); return false;"
+ <!-- END new_window -->
+ >{links.link.LABEL}
+ </a>
+ </li>
<!-- END link -->
</ul>
</dd>