You are here: Foswiki>Tasks Web>Item5500 (22 Dec 2008, SvenDowideit)Edit Attach

Item5500: add css classes to actions that require change permission

pencil
Priority: Normal
Current State: Closed
Released In:
Target Release: n/a
Applies To: Engine
Component:
Branches:
Reported By: TWiki:Main.SvenDowideit
Waiting For:
Last Change By: SvenDowideit
That way, a skin can annotate them based on compound css classes..

 
$ svn diff templates/twiki.moveabletype.tmpl templates/viewtopicactionbuttons.tmpl pub/TWiki/MoveableTypeDesign/TWiki.css
Index: templates/twiki.moveabletype.tmpl
===================================================================
--- templates/twiki.moveabletype.tmpl    (revision 158)
+++ templates/twiki.moveabletype.tmpl    (working copy)
@@ -67,7 +67,7 @@
 
 %{ **************************************************************************************************************************************************************************** }%
 %{ ******************************************* }%
-%TMPL:DEF{"bodystart"}%<body class="layout-%TMPL:P{moveabletypecolumns}% %CONTEXT{escape}%">
+%TMPL:DEF{"bodystart"}%<body class="layout-%TMPL:P{moveabletypecolumns}% %CONTEXT{escape}% %IF{"'%BASEWEB%.%BASETOPIC%' allows 'change'" then="hasChangePermission"}%">
    <div id="container">
       <div id="container-inner" class="pkg">%TMPL:END%
 %{ ******************************************* }%
Index: templates/viewtopicactionbuttons.tmpl
===================================================================
--- templates/viewtopicactionbuttons.tmpl    (revision 158)
+++ templates/viewtopicactionbuttons.tmpl    (working copy)
@@ -1,17 +1,17 @@
 %TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"action_activatable_edit_or_create"}%%TMPL:P{"action_activatable_attach"}%%TMPL:P{"action_printable"}%%TMPL:P{"action_revisions"}%%TMPL:P{"action_backlinks_simple"}%%TMPL:P{"action_raw_or_view"}%%TMPL:P{"action_activatable_raw_edit"}%%TMPL:P{"activatable_more"}%%TMPL:END%
 
 
-%TMPL:DEF{"create_topic_link"}%<span><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Create new topic' accesskey='c'>&Create"}%</a></span>%TMPL:END%
+%TMPL:DEF{"create_topic_link"}%<span class="requiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Create new topic' accesskey='c'>&Create"}%</a></span>%TMPL:END%
 
 
-%TMPL:DEF{"edit_topic_link"}%<span><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" then="" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%</a></span>%TMPL:END%
+%TMPL:DEF{"edit_topic_link"}%<span class="requiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" then="" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%</a></span>%TMPL:END%
 
-%TMPL:DEF{"raw_edit_link"}%<span><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%;nowysiwyg=1' rel='nofollow' %MAKETEXT{"title='Raw Edit this topic text' accesskey='w'>Ra&w edit"}%</a></span>%TMPL:END%
+%TMPL:DEF{"raw_edit_link"}%<span class="requiresChangePermission"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%;nowysiwyg=1' rel='nofollow' %MAKETEXT{"title='Raw Edit this topic text' accesskey='w'>Ra&w edit"}%</a></span>%TMPL:END%
 
 %TMPL:DEF{"view_topic_link"}%<span><a href='%SCRIPTURL{"view"}%/%WEB%/%TOPIC%' rel='nofollow' %MAKETEXT{"title='View topic' accesskey='v'>&View topic"}%</a></span>%TMPL:END%
 
 
-%TMPL:DEF{"attach_link"}%<span><a href='%SCRIPTURLPATH{"attach"}%/%WEB%/%TOPIC%' rel='nofollow' %MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%</a></span>%TMPL:END%
+%TMPL:DEF{"attach_link"}%<span class="requiresChangePermission"><a href='%SCRIPTURLPATH{"attach"}%/%WEB%/%TOPIC%' rel='nofollow' %MAKETEXT{"title='Attach an image or document to this topic' accesskey='a'>&Attach"}%</a></span>%TMPL:END%
 
 
 %TMPL:DEF{"more_link"}%<span><a href='%SCRIPTURLPATH{"oops"}%/%WEB%/%TOPIC%?template=oopsmore&param1=%MAXREV%&param2=%CURRREV%' rel='nofollow' %MAKETEXT{"title='Delete or rename this topic; set parent topic; view and compare revisions' accesskey='m'>&More topic actions"}%</a></span>%TMPL:END%
@@ -30,9 +30,9 @@
 %TMPL:DEF{"backlinks_link"}%<span><a href='%SCRIPTURLPATH{"oops"}%/%WEB%/%TOPIC%?template=backlinksweb' rel='nofollow' %MAKETEXT{"title='Search the [_1] Web for topics that link to here' accesskey='b'>&Backlinks" args="<nop>%WEB%"}%</a></span>%TMPL:END%
 
 
-%TMPL:DEF{"history_rdiff_link"}%<span><a href='%SCRIPTURLPATH{"rdiff"}%/%WEB%/%TOPIC%?type=history' rel='nofollow' %MAKETEXT{"title='View total topic history' accesskey='h'>&History"}%</a></span>%TMPL:END%
+%TMPL:DEF{"history_rdiff_link"}%<span class="requiresChangePermission"><a href='%SCRIPTURLPATH{"rdiff"}%/%WEB%/%TOPIC%?type=history' rel='nofollow' %MAKETEXT{"title='View total topic history' accesskey='h'>&History"}%</a></span>%TMPL:END%
 
-%TMPL:DEF{"history_history_link"}%<span><a href='%SCRIPTURLPATH{"oops"}%/%WEB%/%TOPIC%?template=oopshistory' rel='nofollow' %MAKETEXT{"title='View total topic history' accesskey='h'>&History"}%</a></span>%TMPL:END%
+%TMPL:DEF{"history_history_link"}%<span class="requiresChangePermission"><a href='%SCRIPTURLPATH{"oops"}%/%WEB%/%TOPIC%?template=oopshistory' rel='nofollow' %MAKETEXT{"title='View total topic history' accesskey='h'>&History"}%</a></span>%TMPL:END%
 
 
 %TMPL:DEF{"raw_link"}%<span><a href='%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?raw=on%REVARG%' rel='nofollow' %MAKETEXT{"title='View raw text without formatting' accesskey='r'>&Raw View"}%</a></span>%TMPL:END%
@@ -107,4 +107,4 @@
 
 %TMPL:DEF{"action_revisions"}%%TMPL:P{"revisions"}%%TMPL:P{"sep"}%%TMPL:END%
 
-%TMPL:DEF{"revisions"}%<span>%TMPL:P{context="HistoryPluginEnabled" then="history_history" else="history_rdiff"}%: %TMPL:P{context="CompareRevisionsAddonPluginEnabled" then="revisions_compare" else="revisions_rdiff"}%</span>%TMPL:END%
\ No newline at end of file
+%TMPL:DEF{"revisions"}%<span>%TMPL:P{context="HistoryPluginEnabled" then="history_history" else="history_rdiff"}%: %TMPL:P{context="CompareRevisionsAddonPluginEnabled" then="revisions_compare" else="revisions_rdiff"}%</span>%TMPL:END%
Index: pub/TWiki/MoveableTypeWikiRingNetDesign/TWiki.css
===================================================================
--- pub/TWiki/MoveableTypeDesign/TWiki.css    (revision 158)
+++ pub/TWiki/MoveableTypeDesign/TWiki.css    (working copy)
@@ -1274,6 +1274,14 @@
     display:none;
 }
 
+/*don't show change topic actions if the user is not allowed to CHANGE*/
+.requiresChangePermission {
+    display:none;
+}
+.hasChangePermission .requiresChangePermission {
+    display:inline;
+}
+
 fieldset{
     border-width: 3px 1px;
     border-style: solid;
Index: data/TWiki/WebTopicViewTemplate.txt
===================================================================
--- data/TWiki/WebTopicViewTemplate.txt   (revision 158)
+++ data/TWiki/WebTopicViewTemplate.txt   (working copy)
@@ -23,5 +23,7 @@
 %ICON{arrowbright}% [[%SCRIPTURLPATH{"view"}%/%BASEWEB%/WebSearch?scope=topic;search=%BASETOPIC%][%MAKETEXT{"List more similar topic in this web"}%]] %BR% 
 %ICON{arrowbright}% [[%SCRIPTURLPATH{"view"}%/%BASEWEB%/WebSearch?scope=topic;web=all;search=%BASETOPIC%][%MAKETEXT{"Search similar topics in all public webs"}%]]
 
+<div  class="requiresChangePermission">
 ---+++ %MAKETEXT{"Do you wish to create the topic [_1]?" args="'%BASETOPIC%'"}%
 %ICON{arrowbright}% [[%SCRIPTURL{view}%/%BASEWEB%/%BASETOPIC%?create=on&newtopic=%BASETOPIC%&template=WebCreateNewTopic&topicparent=%URLPARAM{"topicparent"}%][%MAKETEXT{"Create '[_1]'" args="<nop>%BASETOPIC%"}%]]
+</div>





not sure if this is a 4.2.1 thing - though i'll be using it from now on.

-- TWiki:Main/SvenDowideit - 04 Apr 2008

BTW, this is somewhat related to my using %CONTEXT% to prime my html body's css classes, though I did add the extra IF because there is no 'hasChangePermission' etc context.

Yes, I'm contemplating adding those contexts.

-- TWiki:Main.SvenDowideit - 04 Apr 2008

To align the CSS class name, use prefix twiki: twikiRequiresChangePermission.

-- TWiki:Main.ArthurClemens - 04 Apr 2008

roight you are sir! :} thanks for the pointer.

-- TWiki:Main.SvenDowideit - 05 Apr 2008

ItemTemplate edit

Summary add css classes to actions that require change permission
ReportedBy TWiki:Main.SvenDowideit
Codebase
SVN Range TWiki-5.0.0, Thu, 03 Apr 2008, build 16612
AppliesTo Engine
Component
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:dbaec909aa9b
TargetRelease n/a
ReleasedIn
Topic revision: r6 - 22 Dec 2008, SvenDowideit
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy