Commit f99f25084979697027ce45aa7013be1803b5fcdd
1 parent
33ce6308
Make browse/view actions a little more explicit.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5814 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
8 changed files
with
70 additions
and
12 deletions
browse.php
| ... | ... | @@ -89,6 +89,8 @@ $sectionName = "browse"; |
| 89 | 89 | |
| 90 | 90 | class BrowseDispatcher extends KTStandardDispatcher { |
| 91 | 91 | |
| 92 | + var $sName = 'ktcore.actions.folder.view'; | |
| 93 | + | |
| 92 | 94 | var $oFolder = null; |
| 93 | 95 | var $sSection = "browse"; |
| 94 | 96 | var $browse_mode = null; |
| ... | ... | @@ -174,7 +176,12 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 174 | 176 | $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, |
| 175 | 177 | KTBrowseUtil::breadcrumbsForFolder($oFolder)); |
| 176 | 178 | |
| 177 | - $portlet = new KTActionPortlet(_kt("Folder Actions")); | |
| 179 | + $portlet = new KTActionPortlet(sprintf(_kt('Info about "%s"'), $this->oFolder->getName())); | |
| 180 | + $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser); | |
| 181 | + $portlet->setActions($aActions,$this->sName); | |
| 182 | + $this->oPage->addPortlet($portlet); | |
| 183 | + | |
| 184 | + $portlet = new KTActionPortlet(sprintf(_kt('Actions on "%s"'), $this->oFolder->getName())); | |
| 178 | 185 | $aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $this->oUser); |
| 179 | 186 | $portlet->setActions($aActions,null); |
| 180 | 187 | $this->oPage->addPortlet($portlet); | ... | ... |
lib/actions/folderaction.inc.php
| ... | ... | @@ -98,6 +98,7 @@ class KTFolderAction extends KTStandardDispatcher { |
| 98 | 98 | $aInfo = array( |
| 99 | 99 | 'description' => $this->sDescription, |
| 100 | 100 | 'name' => $this->getDisplayName(), |
| 101 | + 'ns' => $this->sName, | |
| 101 | 102 | 'url' => $this->getURL(), |
| 102 | 103 | ); |
| 103 | 104 | return $this->customiseInfo($aInfo); |
| ... | ... | @@ -134,9 +135,14 @@ class KTFolderAction extends KTStandardDispatcher { |
| 134 | 135 | $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, |
| 135 | 136 | KTBrowseUtil::breadcrumbsForFolder($this->oFolder, $aOptions)); |
| 136 | 137 | |
| 137 | - $portlet = new KTActionPortlet(_kt("Folder Actions")); | |
| 138 | + $portlet = new KTActionPortlet(sprintf(_kt('Info about "%s"'), $this->oFolder->getName())); | |
| 139 | + $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser); | |
| 140 | + $portlet->setActions($aActions,$this->sName); | |
| 141 | + $this->oPage->addPortlet($portlet); | |
| 142 | + | |
| 143 | + $portlet = new KTActionPortlet(sprintf(_kt('Actions on "%s"'), $this->oFolder->getName())); | |
| 138 | 144 | $aActions = KTFolderActionUtil::getFolderActionsForFolder($this->oFolder, $this->oUser); |
| 139 | - $portlet->setActions($aActions,null); | |
| 145 | + $portlet->setActions($aActions,$this->sName); | |
| 140 | 146 | $this->oPage->addPortlet($portlet); |
| 141 | 147 | |
| 142 | 148 | if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $this->oFolder)) { |
| ... | ... | @@ -163,6 +169,10 @@ class KTFolderActionUtil { |
| 163 | 169 | $oRegistry =& KTActionRegistry::getSingleton(); |
| 164 | 170 | return $oRegistry->getActions('folderaction'); |
| 165 | 171 | } |
| 172 | + function getFolderInfoActions() { | |
| 173 | + $oRegistry =& KTActionRegistry::getSingleton(); | |
| 174 | + return $oRegistry->getActions('folderinfo'); | |
| 175 | + } | |
| 166 | 176 | function &getFolderActionsForFolder($oFolder, $oUser) { |
| 167 | 177 | $aObjects = array(); |
| 168 | 178 | foreach (KTFolderActionUtil::getFolderActions() as $aAction) { |
| ... | ... | @@ -176,6 +186,19 @@ class KTFolderActionUtil { |
| 176 | 186 | } |
| 177 | 187 | return $aObjects; |
| 178 | 188 | } |
| 189 | + function &getFolderInfoActionsForFolder($oFolder, $oUser) { | |
| 190 | + $aObjects = array(); | |
| 191 | + foreach (KTFolderActionUtil::getFolderInfoActions() as $aAction) { | |
| 192 | + list($sClassName, $sPath, $sPlugin) = $aAction; | |
| 193 | + $oRegistry =& KTPluginRegistry::getSingleton(); | |
| 194 | + $oPlugin =& $oRegistry->getPlugin($sPlugin); | |
| 195 | + if (!empty($sPath)) { | |
| 196 | + require_once($sPath); | |
| 197 | + } | |
| 198 | + $aObjects[] =& new $sClassName($oFolder, $oUser, $oPlugin); | |
| 199 | + } | |
| 200 | + return $aObjects; | |
| 201 | + } | |
| 179 | 202 | } |
| 180 | 203 | |
| 181 | 204 | ?> | ... | ... |
lib/templating/kt3template.inc.php
| ... | ... | @@ -39,7 +39,6 @@ require_once(KT_LIB_DIR . "/templating/templating.inc.php"); |
| 39 | 39 | require_once(KT_LIB_DIR . "/session/control.inc"); |
| 40 | 40 | |
| 41 | 41 | class KTPage { |
| 42 | - | |
| 43 | 42 | var $hide_section = false; |
| 44 | 43 | var $secondary_title = null; |
| 45 | 44 | |
| ... | ... | @@ -79,6 +78,8 @@ class KTPage { |
| 79 | 78 | var $contentType = 'text/html'; |
| 80 | 79 | var $charset = 'UTF-8'; |
| 81 | 80 | |
| 81 | + var $content_class; | |
| 82 | + | |
| 82 | 83 | /* further initialisation */ |
| 83 | 84 | function KTPage() { |
| 84 | 85 | /* default css files initialisation */ |
| ... | ... | @@ -212,6 +213,8 @@ class KTPage { |
| 212 | 213 | function setBreadcrumbDetails($sBreadcrumbDetails) { $this->breadcrumbDetails = $sBreadcrumbDetails; } |
| 213 | 214 | function setUser($oUser) { $this->user = $oUser; } |
| 214 | 215 | |
| 216 | + function setContentClass($sClass) { $this->content_class = $sClass; } | |
| 217 | + | |
| 215 | 218 | // FIXME refactor setSection to be generic, not an if-else. |
| 216 | 219 | // assume this is admin for now. |
| 217 | 220 | function setSection($sSection) { | ... | ... |
lib/widgets/portlet.inc.php
| ... | ... | @@ -38,6 +38,7 @@ require_once(KT_LIB_DIR . "/templating/templating.inc.php"); |
| 38 | 38 | class KTPortlet { |
| 39 | 39 | var $sTitle; |
| 40 | 40 | var $oPlugin; |
| 41 | + var $bActive = false; | |
| 41 | 42 | |
| 42 | 43 | function KTPortlet($title='') { |
| 43 | 44 | $this->sTitle = $title; |
| ... | ... | @@ -59,6 +60,10 @@ class KTPortlet { |
| 59 | 60 | function setDispatcher(&$oDispatcher) { |
| 60 | 61 | $this->oDispatcher =& $oDispatcher; |
| 61 | 62 | } |
| 63 | + | |
| 64 | + function getActive() { | |
| 65 | + return $this->bActive; | |
| 66 | + } | |
| 62 | 67 | } |
| 63 | 68 | |
| 64 | 69 | |
| ... | ... | @@ -98,15 +103,18 @@ class KTNavPortlet extends KTPortlet { |
| 98 | 103 | |
| 99 | 104 | class KTActionPortlet extends KTPortlet { |
| 100 | 105 | var $actions = array(); |
| 106 | + | |
| 107 | + var $bActive = true; | |
| 101 | 108 | |
| 102 | 109 | // current action is the one we are currently on. |
| 103 | 110 | function setActions($actions, $currentaction) { |
| 104 | 111 | foreach ($actions as $action) { |
| 105 | 112 | $aInfo = $action->getInfo(); |
| 106 | - | |
| 113 | + | |
| 107 | 114 | if ($aInfo !== null) { |
| 108 | - if ($aInfo["name"] == $currentaction) { | |
| 115 | + if ($aInfo["ns"] == $currentaction) { | |
| 109 | 116 | unset($aInfo["url"]); |
| 117 | + $aInfo['active'] = true; | |
| 110 | 118 | } |
| 111 | 119 | $this->actions[] = $aInfo; |
| 112 | 120 | } | ... | ... |
plugins/ktcore/KTFolderActions.php
| ... | ... | @@ -38,6 +38,21 @@ require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); |
| 38 | 38 | |
| 39 | 39 | require_once(KT_LIB_DIR . '/roles/Role.inc'); |
| 40 | 40 | |
| 41 | +// {{{ KTDocumentDetailsAction | |
| 42 | +class KTFolderViewAction extends KTFolderAction { | |
| 43 | + var $sName = 'ktcore.actions.folder.view'; | |
| 44 | + | |
| 45 | + function do_main() { | |
| 46 | + redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); | |
| 47 | + exit(0); | |
| 48 | + } | |
| 49 | + | |
| 50 | + function getDisplayName() { | |
| 51 | + return _kt('Display Details'); | |
| 52 | + } | |
| 53 | +} | |
| 54 | +// }}} | |
| 55 | + | |
| 41 | 56 | class KTFolderAddFolderAction extends KTFolderAction { |
| 42 | 57 | var $sName = 'ktcore.actions.folder.addFolder'; |
| 43 | 58 | ... | ... |
templates/kt3/portlets/actions_portlet.smarty
| 1 | 1 | <ul class="actionlist"> |
| 2 | 2 | {foreach item=action from=$context->actions } |
| 3 | -<li>{if ($action.url)}<a href="{$action.url}" | |
| 3 | +<li {if $action.active}class="active"{/if}>{if ($action.url)}<a href="{$action.url}" | |
| 4 | 4 | {if $action.description}title="{$action.description}"{/if} |
| 5 | 5 | >{$action.name}</a>{else}{$action.name}{/if}</li> |
| 6 | 6 | {/foreach} |
| 7 | -</ul> | |
| 8 | 7 | \ No newline at end of file |
| 8 | +</ul> | ... | ... |
templates/kt3/portlets/browsemodes_portlet.smarty
templates/kt3/standard_page.smarty
| ... | ... | @@ -127,16 +127,18 @@ |
| 127 | 127 | {foreach item=oPortlet from=$page->portlets} |
| 128 | 128 | {assign var=portlet_output value=$oPortlet->render() } |
| 129 | 129 | {if $portlet_output} |
| 130 | -<div class="portlet"> | |
| 131 | -<h4>{$oPortlet->getTitle()}</h4> | |
| 130 | +<div class="portlet {if $oPortlet->getActive()}expanded{/if}"> | |
| 131 | +<h4 onclick="toggleElementClass('expanded',this.parentNode)">{$oPortlet->getTitle()}</h4> | |
| 132 | +<div class="portletbody"> | |
| 132 | 133 | {$portlet_output} |
| 133 | 134 | </div> |
| 135 | +</div> | |
| 134 | 136 | {/if} |
| 135 | 137 | {/foreach} |
| 136 | 138 | |
| 137 | 139 | |
| 138 | 140 | </div> |
| 139 | -<div id="content"> | |
| 141 | +<div id="content" {if $page->content_class}class="{$page->content_class}"{/if}> | |
| 140 | 142 | {if (!$page->hide_section)} |
| 141 | 143 | <h1 class="{$page->componentClass}"><span class="fahrner">{$page->componentLabel}</span> |
| 142 | 144 | {if ($page->getHelpURL() != null)} <a class="ktHelp" href="{$page->getHelpURL()}">Help</a> {/if} | ... | ... |