[go: up one dir, main page]

Menu

[r3]: / doc / app / finder.inc.php  Maximize  Restore  History

Download this file

215 lines (149 with data), 6.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?
/********************************************************************
finder.inc.php
this file contains functions for the browse and find
modules
********************************************************************/
function createFindFunction($searchCount) {
$functionBar = null;
//searchCount, curPage, limitResults,
if ($searchCount > 0) {
$functionBar .= "&nbsp;&nbsp;";
$functionBar .= "<a href=\"javascript:void(0);\" >\"return moveObject();\">"._MOVE."</a>";
$functionBar .= "&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
if (!defined("RESTRICTED_DELETE") || bitset_compare(BITSET,ADMIN,null)) {
$functionBar .= "<a href=\"javascript:deleteObjects();\" >"._DELETE."</a>";
$functionBar .= "&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
}
}
return $functionBar;
}
function createBrowseFunction($searchCount,$view_parent) {
//can the user even create objects?
if (!bitset_compare(BITSET,INSERT_OBJECTS,ADMIN)) return false;
//make sure we can add objects at the root level
if (!$view_parent && defined("ADMIN_ROOTLEVEL") && !bitset_compare(BITSET,ADMIN,null)) return false;
//make sure the user has permissions to add objects here
if ( $view_parent &&
!bitset_compare(CUSTOM_BITSET,OBJ_EDIT,OBJ_ADMIN) &&
!bitset_compare(CUSTOM_BITSET,OBJ_MANAGE,OBJ_ADMIN)) return false;
$functionBar .= createObjectDropdown($view_parent);
//only show this if we have file results
if ($searchCount > 0) {
$functionBar .= "&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
$functionBar .= "<a href=\"javascript:void(0);\" >\"return moveObject();\">"._MOVE."</a>";
if (!defined("RESTRICTED_DELETE") || bitset_compare(BITSET,ADMIN,null)) {
$functionBar .= "&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
$functionBar .= "<a href=\"javascript:deleteObjects();\">"._DELETE."</a>";
}
$functionBar .= "&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
}
return $functionBar;
}
function createFindToolbar($searchString,$searchCount,$curPage,$timeCount) {
$limitResults = RESULTS_PER_PAGE;
if ($limitResults!==NULL) $numPages = $searchCount / $limitResults;
else $numPages = 1;
if (!$curPage) $curPage = 1;
$first = (($curPage - 1) * $limitResults) + 1;
$second = $curPage * $limitResults;
$toolBar = "<b>"._DISPLAYING.": </b>";
$toolBar .= _RESULTS." $first - $second "._OF." ".$searchCount." "._FOR." \"".stripsan($searchString)."\".";
$toolBar .= "&nbsp;&nbsp;"._SEARCH_TOOK." ".$timeCount." "._SECONDS.". ";
$toolBar .= "<a href=\"index.php?module=find&searchAgain=yes\" class=main>"._SEARCH_AGAIN."</a>.";
return $toolBar;
}
function createBrowseToolbar($searchCount,$curPage) {
//get out if disabled
if (!defined("PAGE_BROWSE_RESULTS")) return false;
$limitResults = RESULTS_PER_PAGE;
$numPages = $searchCount / $limitResults;
if (!$curPage) $curPage = 1;
$first = (($curPage - 1) * $limitResults) + 1;
$second = $curPage * $limitResults;
//show result string correctly when showing less than our increment
if ($second > $searchCount) $second = $searchCount;
$toolBar = _RESULTS." $first - $second "._OF." ".$searchCount;
return $toolBar;
}
//creates pages and arrows to navigate paginated results in the finder
function createFinderNav($searchCount,$curPage) {
//don't show anything if there's nothing here
if (!$searchCount) return false;
//init the number of pages we'll have and what page we're starting on
$numPages = $searchCount / RESULTS_PER_PAGE;
if (!$curPage) $curPage = 1;
$first = (($curPage - 1) * RESULTS_PER_PAGE) + 1;
$second = $curPage * RESULTS_PER_PAGE;
//show result string correctly when showing less than our increment
if ($second > $searchCount) $second = $searchCount;
if ($second>$searchCount) {
$num = $second - $searchCount;
$diff = RESULTS_PER_PAGE - $num;
$second = $first + $diff - 1;
}
if (strstr($numPages,".")) $numPages = intVal($numPages) + 1;
//if we have more pages than the config limit
if ($numPages > PAGE_RESULT_LIMIT) {
//start from the middle
$pageHalf = intVal(PAGE_RESULT_LIMIT / 2);
//figure out which page we are starting on and ending on
if ($curPage>$pageHalf) $pageBegin = $curPage - $pageHalf;
else $pageBegin = 1;
$pageEnd = $curPage + $pageHalf - 1;
//show num count on the last page
if ($pageEnd>$numPages) $pageEnd = $numPages;
//only show up to the limit if we have less pages than our increment count
if ($pageEnd < PAGE_RESULT_LIMIT) $pageEnd = PAGE_RESULT_LIMIT;
//if we have less pages than our limit
} else {
$pageBegin = 1;
$pageEnd = $numPages;
}
$pageBar = null;
$nextPage = $curPage + 1; //jump to the next page
$prevPage = $curPage - 1; //jump to the previous page
//setup the previous/first page arrows
if ($curPage>1 && $numPages > 1) {
$pageBar .= " <a href=\"javascript:jumpPage('1');\">
<img src=\"".THEME_PATH."/images/active_firstpage.gif\" border=0>
</a>
&nbsp;
<a href=\"javascript:jumpPage('".$prevPage."');\">
<img src=\"".THEME_PATH."/images/active_prevpage.gif\" border=0>
</a>
&nbsp;
";
} else {
$pageBar .= " <img src=\"".THEME_PATH."/images/inactive_firstpage.gif\" border=0>
&nbsp;
<img src=\"".THEME_PATH."/images/inactive_prevpage.gif\" border=0>
&nbsp;
";
}
//create the toolbar for jumping from page to page
for ($row=$pageBegin;$row<=$pageEnd;$row++) {
if ($row==$curPage) $pageBar .= "&nbsp;<b>".$row."</b>&nbsp;";
else $pageBar .= "&nbsp;<a href=\"javascript:jumpPage('".$row."');\" class=main>".$row."</a>&nbsp;";
}
$pageBar .= "&nbsp;";
//setup the next/last page arrows
if ($numPages > 1 && $curPage < $numPages) {
$pageBar .= " <a href=\"javascript:jumpPage('".$nextPage."');\">
<img src=\"".THEME_PATH."/images/active_nextpage.gif\" border=0>
</a>
&nbsp;
<a href=\"javascript:jumpPage('".$numPages."');\">
<img src=\"".THEME_PATH."/images/active_lastpage.gif\" border=0>
</a>
&nbsp;
";
} else {
$pageBar .= "&nbsp;<img src=\"".THEME_PATH."/images/inactive_nextpage.gif\" border=0>
&nbsp;
<img src=\"".THEME_PATH."/images/inactive_lastpage.gif\" border=0>
&nbsp;
";
}
return $pageBar;
}