added functions needed to detect template and image dirs

This commit is contained in:
seek3r 2000-12-19 18:14:22 +00:00
parent ef0223f75b
commit e045c4236e
8 changed files with 108 additions and 46 deletions

View File

@ -12,18 +12,18 @@
/* $ Id $ */
{
echo "<p>\n";
$img = "/" . $appname . "/images/" . $appname .".gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img = $phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("addressbook")."/" . $appname .".gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("addressbook")."/" . $appname .".gif";
} else {
$img = "/" . $appname . "/images/navbar.gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img=$phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("addressbook")."/navbar.gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("addressbook")."/navbar.gif";
} else {
$img = "";
$imgpath = "";
}
}
section_start("Address Book",$img);
section_start("Address Book",$imgpath);
$pg = $phpgw->link($phpgw_info["server"]["webserver_url"]."/addressbook/preferences.php");
echo "<A href=".$pg.">" . lang("Addressbook preferences") . "</A>";

View File

@ -7,20 +7,21 @@
// $phpgw and $phpgwinfo are also in scope
// Find the icon to display
$img = "/" . $appname . "/images/" . $appname .".gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img = $phpgw_info["server"]["webserver_url"].$img;
echo "<p>\n";
$imgfile = $phpgw->common->get_image_dir("admin")."/" . $appname .".gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("admin")."/" . $appname .".gif";
} else {
$img = "/" . $appname . "/images/navbar.gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img=$phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("admin")."/navbar.gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("admin")."/navbar.gif";
} else {
$img = "";
$imgpath = "";
}
}
// Show the header for the section
section_start("Administration",$img);
section_start("Administration",$imgpath);
// actual items in this section

View File

@ -11,19 +11,21 @@
\**************************************************************************/
/* $ Id $ */
{
echo "<p>\n";
$img = "/" . $appname . "/images/" . $appname .".gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img = $phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("calendar")."/" . $appname .".gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("calendar")."/" . $appname .".gif";
} else {
$img = "/" . $appname . "/images/navbar.gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img=$phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("calendar")."/navbar.gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("calendar")."/navbar.gif";
} else {
$img = "";
$imgpath = "";
}
}
section_start("Calendar",$img);
section_start("Calendar",$imgpath);
$pg = $phpgw->link($phpgw_info["server"]["webserver_url"]."/calendar/preferences.php");
echo "<a href=".$pg.">" . lang("Calendar preferences") . "</a>";

View File

@ -33,6 +33,8 @@
exit;
}
*/
$phpgw_info["server"]["template_dir"] = $phpgw_info["server"]["api_dir"]."/templates/default";
$tmpl = new Template($phpgw_info["server"]["template_dir"]);
if (! $deny_login && ! $phpgw_info["server"]["show_domain_selectbox"]) {

View File

@ -190,8 +190,8 @@
$this->hooks = new hooks;
$sep = filesystem_separator();
$template_root = $phpgw_info["server"]["server_root"] . $sep . $phpgw_info["flags"]["currentapp"]
. $sep . "templates" . $sep . $phpgw_info["server"]["template_set"];
$template_root = $this->common->get_tpl_dir();
if (is_dir($template_root)) {
$this->template = new Template($template_root);
}

View File

@ -224,6 +224,64 @@
return $output_text;
}
function get_tpl_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if ($appname == "home" || $appname == "logout" || $appname == "login"){$appname = "phpgwapi";}
if (empty($phpgw_info["server"]["template_set"])){$phpgw_info["server"]["template_set"] = "default";}
$tpldir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"];
$tpldir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default";
if (is_dir ($tpldir)){
return $tpldir;
}elseif (is_dir ($tpldir_default)){
return $tpldir_default;
}else{
return False;
}
}
function get_image_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if (empty($phpgw_info["server"]["template_set"])){$phpgw_info["server"]["template_set"] = "default";}
$imagedir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"]."/images";
$imagedir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default/images";
$imagedir_olddefault = $phpgw_info["server"]["server_root"]."/".$appname."/images";
if (is_dir ($imagedir)){
return $imagedir;
}elseif (is_dir ($imagedir_default)){
return $imagedir_default;
}elseif (is_dir ($imagedir_olddefault)){
return $imagedir_olddefault;
}else{
return False;
}
}
function get_image_path($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if (empty($phpgw_info["server"]["template_set"])){$phpgw_info["server"]["template_set"] = "default";}
$imagedir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"]."/images";
$imagedir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default/images";
$imagedir_olddefault = $phpgw_info["server"]["server_root"]."/".$appname."/images";
if (is_dir ($imagedir)){
return $phpgw_info["server"]["webserver_url"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"]."/images";
}elseif (is_dir ($imagedir_default)){
return $phpgw_info["server"]["webserver_url"]."/".$appname."/templates/default/images";
}elseif (is_dir ($imagedir_olddefault)){
return $phpgw_info["server"]["webserver_url"]."/".$appname."/images";
}else{
return False;
}
}
function show_icon(&$tpl, $td_width, $appname, $description = "")
{
global $phpgw_info, $colspan, $phpgw;

View File

@ -31,10 +31,6 @@
$phpgw_info["server"]["template_set"] = "default";
}
if (empty($phpgw_info["server"]["template_dir"])){
$phpgw_info["server"]["template_dir"] = $phpgw_info["server"]["api_dir"]."/templates/".$phpgw_info["server"]["template_set"];
}
if (!isset($phpgw_domain)) { // make them fix their header
echo "The administration is required to upgrade the header.inc.php file before you can continue.";
exit;
@ -93,16 +89,19 @@
function phpgw_fillarray()
{
global $phpgw, $phpgw_info, $cd, $colspan;
if (!isset($phpgw_info["server"]["images_dir"])){
$phpgw_info["server"]["images_dir"] = $phpgw_info["server"]["webserver_url"] . "/phpgwapi/templates/".$phpgw_info["server"]["template_set"]."/images";
}
$phpgw_info["server"]["template_dir"] = $phpgw_info["server"]["api_dir"] . "/templates/"
. $phpgw_info["server"]["template_set"];
// if (!isset($phpgw_info["server"]["template_dir"])){
$phpgw_info["server"]["template_dir"] = $phpgw->common->get_tpl_dir("phpgwapi");
// }
// if (!isset($phpgw_info["server"]["images_dir"])){
$phpgw_info["server"]["images_dir"] = $phpgw->common->get_image_path("phpgwapi");
// }
$phpgw_info["server"]["app_root"] = $phpgw_info["server"]["server_root"]."/".$phpgw_info["flags"]["currentapp"];
$phpgw_info["server"]["app_inc"] = $phpgw_info["server"]["app_root"]."/inc";
$phpgw_info["server"]["app_images"] = $phpgw_info["server"]["webserver_url"]."/".$phpgw_info["flags"]["currentapp"]."/templates/".$phpgw_info["server"]["template_set"]."/images";
$phpgw_info["server"]["app_tpl"] = $phpgw_info["server"]["app_root"]."/templates/".$phpgw_info["server"]["template_set"];
$phpgw_info["server"]["app_images"] = $phpgw->common->get_image_path();
$phpgw_info["server"]["app_tpl"] = $phpgw->common->get_tpl_dir();
/* ********This sets the user variables******** */
$phpgw_info["user"]["private_dir"] = $phpgw_info["server"]["files_dir"] . "/users/"

View File

@ -12,18 +12,18 @@
/* $ Id $ */
{
echo "<p>\n";
$img = "/" . $appname . "/images/" . $appname .".gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img = $phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("preferences")."/" . $appname .".gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("preferences")."/" . $appname .".gif";
} else {
$img = "/" . $appname . "/images/navbar.gif";
if (file_exists($phpgw_info["server"]["server_root"].$img)) {
$img=$phpgw_info["server"]["webserver_url"].$img;
$imgfile = $phpgw->common->get_image_dir("preferences")."/navbar.gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("preferences")."/navbar.gif";
} else {
$img = "";
$imgpath = "";
}
}
section_start("Account Preferences",$img);
section_start("Account Preferences",$imgpath);
// Actual content