folderUI.inc
4.83 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
<?php
/**
* $Id$
*
* Common folder UI functions.
*
* Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @version $Revision$
* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
* @package foldermanagement
*/
/**
* Displays the passed path array as a link
*
* @param array containing the path to the folder (folder ids)
* @param string the page to link to (defaults to the page this is called from)
*/
function displayFolderPathLink($aPathArray, $aPathNameArray, $sLinkPage = "") {
global $default;
if (strlen($sLinkPage) == 0) {
$sLinkPage = $_SERVER["PHP_SELF"];
}
$default->log->debug("displayFolderPathLink: slinkPage=$sLinkPage");
// display a separate link to each folder in the path
for ($i=0; $i<count($aPathArray); $i++) {
$iFolderID = $aPathArray[$i];
// retrieve the folder name for this folder
$sFolderName = $aPathNameArray[$i];
// generate a link back to this page setting fFolderID
$sLink = generateLink($sLinkPage,
"fBrowseType=folder&fFolderID=$iFolderID",
$sFolderName);
$sPathLinks = (strlen($sPathLinks) > 0) ? $sPathLinks . " > " . $sLink : $sLink;
}
return $sPathLinks;
}
/**
* Displays the passed folder name as a link
*
* @param object the folder to link to
* @param string the page to link to (defaults to the page this is called from)
*/
function displayFolderLink($oFolder, $sLinkPage = "") {
global $default;
if (strlen($sLinkPage) == 0) {
$sLinkPage = $_SERVER["PHP_SELF"];
}
if (Folder::folderIsUnitRootFolder($oFolder->getID())) {
$sFolderIconPath = generateImage($default->graphicsUrl . "/widgets/dfolder_unit.gif");
} elseif ($oFolder->getIsPublic()) {
$sFolderIconPath = generateImage($default->graphicsUrl . "/widgets/dfolder_public.gif");
} else {
$sFolderIconPath = generateImage($default->graphicsUrl . "/widgets/dfolder.gif");
}
return generateLink($sLinkPage,
"fBrowseType=folder&fFolderID=" . $oFolder->getID(),
$sFolderIconPath .
$oFolder->getName());
}
function renderFolderPath($iFolderID, $sLinkURL, $bDisplayLinks = true) {
global $default;
$sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
$sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
if ($bDisplayLinks) {
$sFolderPath = displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), $sLinkURL);
} else {
$sFolderPath = implode(" > ", Folder::getFolderPathNamesAsArray($iFolderID));
}
return "<table border=\"0\" cellpadding=\"5\" width=\"100%\"><tr><td bgcolor=\"$sTDBGColour\">$sFolderPath</td></tr></table>\n";
}
/**
* Renders a the list of folders found in $iFolderID as
* and HTML table. &fFolderID=<folder_id> is automatically
* appended to the query string
*
* @return String HTML table
*/
function renderFolderList($iFolderID, $sLinkURL) {
global $default;
/*ok*/ $sQuery = array("SELECT F.id AS id, F.name AS name " .
"FROM $default->folders_table AS F " .
"WHERE F.parent_id = ? " .
"ORDER BY F.name ASC", $iFolderID);
$aColumns = array("name");
$aColumnTypes = array(3);
$aColumnHeaderNames = array("Folder");
$aDBColumns = array("id");
$aQueryStringVariableNames = array("fFolderID");
$aLinkURLs = array("$sLinkURL");
$aLinkURLs = array();
if ((strlen($default->rootUrl) > 0) && (!strstr($sLinkURL, $default->rootUrl))) {
$aLinkURLs = array("$default->rootUrl/$sLinkURL");
} else {
$aLinkURLs = array("$sLinkURL");
}
$oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaderNames, "100%", $aLinkURLs, $aDBColumns, $aQueryStringVariableNames);
$oPatternTableSqlQuery->setImageURL("$default->graphicsUrl/widgets/dfolder.gif");
$oPatternTableSqlQuery->setEmptyTableMessage(_("This folder contains no sub folders"));
return $oPatternTableSqlQuery->render();
}
?>