Skip to content

Commit

Permalink
Merge pull request #631 from ezsystems/leftmenu_enabled_tweaks
Browse files Browse the repository at this point in the history
Implement EZP-20959: Add admin.ini LeftMenu Enabled setting
  • Loading branch information
andrerom committed Jun 5, 2013
2 parents e9a5ebf + e5c09f4 commit c011882
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 48 deletions.
4 changes: 0 additions & 4 deletions design/admin/templates/parts/content/menu.tpl
Expand Up @@ -17,11 +17,7 @@
</div>
{/if}




{* DESIGN: Content END *}</div></div></div>

</div>

{* See parts/ini_menu.tpl and menu.ini for more info, or parts/setup/menu.tpl for full example *}
Expand Down
74 changes: 43 additions & 31 deletions design/admin/templates/parts/ini_menu.tpl
Expand Up @@ -32,10 +32,17 @@
{if ezini_hasvariable( $ini_section, 'Links', 'menu.ini' )}
{def $url_list = ezini( $ini_section, 'Links', 'menu.ini' )
$name_list = ezini( $ini_section, 'LinkNames', 'menu.ini' )
$menu_name = ezini( $ini_section, 'Name', 'menu.ini' )
$menu_name = ''
$check = array()
$has_access = true()
$item_name = ''}
$item_name = ''
$disabled = true()
$enabled_hash = hash()
$enabled_defaults = hash( 'default', 'true', 'edit', 'false', 'browse', 'false' )}

{if ezini_hasvariable( $ini_section, 'Name', 'menu.ini' )}
{set $menu_name = ezini( $ini_section, 'Name', 'menu.ini' )}
{/if}

{* Check access globally *}
{if ezini_hasvariable( $ini_section, 'PolicyList', 'menu.ini' )}
Expand All @@ -58,32 +65,35 @@

{if $has_access}
{* DESIGN: Header START *}<div class="box-header"><div class="box-ml">
<h4>{if is_set( $i18n_hash[ $menu_name ] )}{$i18n_hash[ $menu_name ]|wash}{else}{$menu_name|d18n($i18n_section)}{/if}</h4>
{if $menu_name}<h4>{if is_set( $i18n_hash[ $menu_name ] )}{$i18n_hash[ $menu_name ]|wash}{else}{$menu_name|d18n($i18n_section)}{/if}</h4>{/if}
{* DESIGN: Header END *}</div></div>

{* DESIGN: Content START *}<div class="box-bc"><div class="box-ml"><div class="box-content">

{if eq( $ui_context, 'edit' )}
<ul class="leftmenu-items">
{foreach $url_list as $link_key => $link_url}
{if is_set( $name_list[ $link_key ] )}
{set $item_name = $name_list[$link_key]|d18n($i18n_section)}
{else}
{set $item_name = first_set( $i18n_hash[ $link_key ], $link_key )|wash}
{/if}
<li><div><span class="disabled">{$item_name}</span></div></li>
{/foreach}
</ul>
{else}
<ul class="leftmenu-items">
{foreach $url_list as $link_key => $link_url}
{if is_set( $name_list[ $link_key ] )}
{set $item_name = $name_list[$link_key]|d18n($i18n_section)}
{else}
{set $item_name = first_set( $i18n_hash[ $link_key ], $link_key )|wash}
{/if}
<ul class="leftmenu-items">
{foreach $url_list as $link_key => $link_url}
{if is_set( $name_list[ $link_key ] )}
{set $item_name = $name_list[$link_key]|d18n($i18n_section)}
{else}
{set $item_name = first_set( $i18n_hash[ $link_key ], $link_key )|wash}
{/if}

{* Check if link should be disabled *}
{if ezini_hasvariable( $ini_section, concat( 'Enabled_', $link_key ), 'menu.ini' )}
{set $enabled_hash = $enabled_defaults|merge( ezini( $ini_section, concat( 'Enabled_', $link_key ), 'menu.ini' ) )}
{else}
{set $enabled_hash = $enabled_defaults}
{/if}

{if is_set( $enabled_hash[$ui_context] )}
{set $disabled = $enabled_hash[$ui_context]}
{else}
{set $disabled = $enabled_hash['default']|eq( 'false' )}
{/if}

{* Check access per link *}
{if $disabled|not()}
{set $has_access = true()}
{* Check access pr link *}
{if ezini_hasvariable( $ini_section, concat( 'PolicyList_', $link_key ), 'menu.ini' )}
{foreach ezini( $ini_section, concat( 'PolicyList_', $link_key ), 'menu.ini' ) as $policy}
{if $policy|contains('/')}
Expand All @@ -101,14 +111,16 @@
{/if}
{/foreach}
{/if}
{if $has_access}
<li{if $current_uri_string|begins_with( $link_url )} class="current"{/if}><div><a href={$link_url|ezurl}>{$item_name}</a></div></li>
{else}
<li class="disabled-no-access"><div><span class="disabled">{$item_name}</span></div></li>
{/if}
{/foreach}
</ul>
{/if}
{/if}
{if $disabled}
<li><div><span class="disabled">{$item_name}</span></div></li>
{elseif $has_access}
<li{if $current_uri_string|begins_with( $link_url )} class="current"{/if}><div><a href={$link_url|ezurl}>{$item_name}</a></div></li>
{else}
<li class="disabled-no-access"><div><span class="disabled">{$item_name}</span></div></li>
{/if}
{/foreach}
</ul>

{* DESIGN: Content END *}</div></div></div>
{/if}
Expand Down
2 changes: 0 additions & 2 deletions design/admin/templates/parts/media/menu.tpl
Expand Up @@ -21,11 +21,9 @@
{* DESIGN: Content END *}</div></div></div>
</div>


{* See parts/ini_menu.tpl and menu.ini for more info, or parts/setup/menu.tpl for full example *}
{include uri='design:parts/ini_menu.tpl' ini_section='Leftmenu_media'}


{* Left menu width control. *}
<div id="widthcontrol-links" class="widthcontrol">
<p>
Expand Down
18 changes: 7 additions & 11 deletions design/admin/templates/parts/user/menu.tpl
Expand Up @@ -45,16 +45,12 @@
</div>

{* Roles & policies *}
{if ne( $ui_context, 'browse')}

{* See parts/ini_menu.tpl and menu.ini for more info, or parts/setup/menu.tpl for full example *}
{include uri='design:parts/ini_menu.tpl' ini_section='Leftmenu_user' i18n_hash=hash(
'access_controll', 'Access control'|i18n( 'design/admin/parts/user/menu' ),
'roles_and_policies', 'Roles and policies'|i18n( 'design/admin/parts/user/menu' ),
'unactivated', 'Unactivated users'|i18n( 'design/admin/parts/user/menu' ),
)}

{/if}
{* See parts/ini_menu.tpl and menu.ini for more info, or parts/setup/menu.tpl for full example *}
{include uri='design:parts/ini_menu.tpl' ini_section='Leftmenu_user' i18n_hash=hash(
'access_controll', 'Access control'|i18n( 'design/admin/parts/user/menu' ),
'roles_and_policies', 'Roles and policies'|i18n( 'design/admin/parts/user/menu' ),
'unactivated', 'Unactivated users'|i18n( 'design/admin/parts/user/menu' ),
)}

{* Left menu width control. *}
<div id="widthcontrol-links" class="widthcontrol">
Expand Down Expand Up @@ -92,4 +88,4 @@
<div class="widthcontrol-grippy"></div>
</div>

{/if}
{/if}{* if ne( $ui_context, 'edit' ) *}
5 changes: 5 additions & 0 deletions doc/bc/5.2/changes-5.2.txt
Expand Up @@ -39,6 +39,11 @@ Change of behavior
The previous default value (true) led to X-Powered-By being set to 1 (true cast to integer).
From 5.2, the default value will be set to "eZ Publish".

- menu.ini\[Leftmenu_<menu>]

Links in left menu are now by default disabled in browse mode.
This can now be changed per item using the new Enabled_<link>[<ui_context>] setting.

Removed features
----------------

Expand Down
4 changes: 4 additions & 0 deletions settings/menu.ini
Expand Up @@ -270,6 +270,10 @@ Shown[browse]=true
# value an be either in "<node_id>" or "<module>/<function>" form
# Menu item is disabled (no link) if this returns false
#PolicyList_<Links_index>[]=<value>
# Enabled sets if menuitem is clickable in current ui_context or value 'default'
# By default 'default' is considered true and 'edit' + 'browse' is false
#Enabled_<Links_index>[browse]=false



# Uncomment the following to add a left menu to content area
Expand Down

0 comments on commit c011882

Please sign in to comment.