Commit 0ce68764cbb7d32cbecb4d08a14f557dd5af7ae8
1 parent
47cbbe5f
Use the dispatcher check method to set up $oFolder on the dispatcher.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4041 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
24 additions
and
21 deletions
presentation/lookAndFeel/knowledgeTree/browse.php
| ... | ... | @@ -56,7 +56,23 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 56 | 56 | var $sSection = "browse"; |
| 57 | 57 | var $browseType; |
| 58 | 58 | |
| 59 | - | |
| 59 | + function check() { | |
| 60 | + // which folder. | |
| 61 | + $in_folder_id = KTUtil::arrayGet($_REQUEST, "fFolderId", 1); | |
| 62 | + $folder_id = (int) $in_folder_id; // conveniently, will be 0 if not possible. | |
| 63 | + if ($folder_id == 0) { | |
| 64 | + $folder_id = 1; | |
| 65 | + } | |
| 66 | + | |
| 67 | + // here we need the folder object to do the breadcrumbs. | |
| 68 | + $this->oFolder =& Folder::get($folder_id); | |
| 69 | + if (PEAR::isError($this->oFolder)) { | |
| 70 | + $this->oPage->addError("invalid folder"); | |
| 71 | + $folder_id = 1; | |
| 72 | + $this->oFolder =& Folder::get($folder_id); | |
| 73 | + } | |
| 74 | + return true; | |
| 75 | + } | |
| 60 | 76 | |
| 61 | 77 | function do_main() { |
| 62 | 78 | $collection = new DocumentCollection; |
| ... | ... | @@ -69,24 +85,11 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 69 | 85 | $collection->addColumn(new BrowseColumn("Test 3","test3")); |
| 70 | 86 | $collection->addColumn(new BrowseColumn("Test 4","test4")); |
| 71 | 87 | |
| 72 | - // which folder. | |
| 73 | - $in_folder_id = KTUtil::arrayGet($_REQUEST, "fFolderId", 1); | |
| 74 | - $folder_id = (int) $in_folder_id; // conveniently, will be 0 if not possible. | |
| 75 | - if ($folder_id == 0) { $folder_id = 1; } | |
| 76 | - | |
| 77 | - // here we need the folder object to do the breadcrumbs. | |
| 78 | - $oFolder =& Folder::get($folder_id); | |
| 79 | - if (PEAR::isError($oFolder)) { | |
| 80 | - $this->oPage->addError("invalid folder"); | |
| 81 | - $folder_id = 1; | |
| 82 | - $oFolder =& Folder::get($folder_id); | |
| 83 | - } | |
| 84 | - | |
| 85 | 88 | // do the breadcrumbs. |
| 86 | 89 | |
| 87 | 90 | // skip root. |
| 88 | - $folder_path_names = array_slice($oFolder->getPathArray(), 1); | |
| 89 | - $folder_path_ids = array_slice(explode(',', $oFolder->getParentFolderIds()), 1); | |
| 91 | + $folder_path_names = array_slice($this->oFolder->getPathArray(), 1); | |
| 92 | + $folder_path_ids = array_slice(explode(',', $this->oFolder->getParentFolderIds()), 1); | |
| 90 | 93 | |
| 91 | 94 | $parents = count($folder_path_ids); |
| 92 | 95 | |
| ... | ... | @@ -97,8 +100,8 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | 102 | // now add this folder, _if we aren't in 1_. |
| 100 | - if ($folder_id != 1) { | |
| 101 | - $this->aBreadcrumbs[] = array("name" => $oFolder->getName()); | |
| 103 | + if ($this->oFolder->getId() != 1) { | |
| 104 | + $this->aBreadcrumbs[] = array("name" => $this->oFolder->getName()); | |
| 102 | 105 | } |
| 103 | 106 | |
| 104 | 107 | // setup the folderside add actions |
| ... | ... | @@ -108,7 +111,7 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 108 | 111 | |
| 109 | 112 | // FIXME make a FolderActionUtil ... is it necessary? |
| 110 | 113 | |
| 111 | - $aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $$this->oUser); | |
| 114 | + $aActions = KTFolderActionUtil::getFolderActionsForFolder($this->oFolder, $$this->oUser); | |
| 112 | 115 | |
| 113 | 116 | $portlet->setActions($aActions,null); |
| 114 | 117 | |
| ... | ... | @@ -117,7 +120,7 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 117 | 120 | $batchPage = (int) KTUtil::arrayGet($_REQUEST, "page", 0); |
| 118 | 121 | $batchSize = 20; |
| 119 | 122 | |
| 120 | - $resultURL = "?fFolderId=" . $folder_id; | |
| 123 | + $resultURL = "?fFolderId=" . $this->oFolder->getId(); | |
| 121 | 124 | $collection->setBatching($resultURL, $batchPage, $batchSize); |
| 122 | 125 | |
| 123 | 126 | |
| ... | ... | @@ -130,7 +133,7 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 130 | 133 | $collection->setSorting($displayControl, $displayOrder); |
| 131 | 134 | |
| 132 | 135 | // add in the query object. |
| 133 | - $qObj = new BrowseQuery($folder_id); | |
| 136 | + $qObj = new BrowseQuery($this->oFolder->getId()); | |
| 134 | 137 | $collection->setQueryObject($qObj); |
| 135 | 138 | |
| 136 | 139 | // breadcrumbs | ... | ... |