Commit bebcb295 authored by mose's avatar mose

added a way to use subdomain templates and styles

parent 6a8640df
......@@ -22,7 +22,7 @@ class cssLib extends TikiLib {
chdir ($path);
$handle = opendir('.');
while ($file = readdir($handle)) {
while ($file = basename(readdir($handle))) {
if ((substr($file, -4, 4) == ".css") and (ereg("^[-_a-zA-Z0-9\.]*$", $file))) {
$back[] = substr($file, 0, -4);
}
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/setup_smarty.php,v 1.23 2004-04-16 15:33:32 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/setup_smarty.php,v 1.24 2004-04-26 17:55:12 mose Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -33,10 +33,14 @@ class Smarty_TikiWiki extends Smarty {
}
function _smarty_include($params) {
global $style, $style_base;
global $style, $style_base, $tikidomain;
if (isset($style) && isset($style_base)) {
if (file_exists("templates/styles/$style_base/".$params['smarty_include_tpl_file'])) {
if ($tikidomain and file_exists("templates/$tikidomain/$style_base/".$params['smarty_include_tpl_file'])) {
$params['smarty_include_tpl_file'] = "$tikidomain/$style_base/".$params['smarty_include_tpl_file'];
} elseif ($tikidomain and file_exists("templates/$tikidomain/".$params['smarty_include_tpl_file'])) {
$params['smarty_include_tpl_file'] = "$tikidomain/".$params['smarty_include_tpl_file'];
} elseif (file_exists("templates/styles/$style_base/".$params['smarty_include_tpl_file'])) {
$params['smarty_include_tpl_file'] = "styles/$style_base/".$params['smarty_include_tpl_file'];
}
}
......@@ -44,10 +48,14 @@ class Smarty_TikiWiki extends Smarty {
}
function fetch($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null, $_smarty_display = false) {
global $language, $style, $style_base;
global $language, $style, $style_base, $tikidomain;
if (isset($style) && isset($style_base)) {
if (file_exists("templates/styles/$style_base/$_smarty_tpl_file")) {
if ($tikidomain and file_exists("templates/$tikidomain/styles/$style_base/$_smarty_tpl_file")) {
$_smarty_tpl_file = "$tikidomain/styles/$style_base/$_smarty_tpl_file";
} elseif ($tikidomain and file_exists("templates/$tikidomain/$_smarty_tpl_file")) {
$_smarty_tpl_file = "$tikidomain/$_smarty_tpl_file";
} elseif (file_exists("templates/styles/$style_base/$_smarty_tpl_file")) {
$_smarty_tpl_file = "styles/$style_base/$_smarty_tpl_file";
}
}
......@@ -79,10 +87,14 @@ class Smarty_TikiWiki extends Smarty {
return ereg_replace("^[ \t]*", "", $res);
}
function is_cached($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null) {
global $language, $style, $style_base;
global $language, $style, $style_base, $tikidomain;
if (isset($style) && isset($style_base)) {
if (file_exists("templates/styles/$style_base/$_smarty_tpl_file")) {
if ($tikidomain and file_exists("templates/$tikidomain/styles/$style_base/$_smarty_tpl_file")) {
$_smarty_tpl_file = "$tikidomain/styles/$style_base/$_smarty_tpl_file";
} elseif ($tikidomain and file_exists("templates/$tikidomain/$_smarty_tpl_file")) {
$_smarty_tpl_file = "$tikidomain/$_smarty_tpl_file";
} elseif (file_exists("templates/styles/$style_base/$_smarty_tpl_file")) {
$_smarty_tpl_file = "styles/$style_base/$_smarty_tpl_file";
}
}
......@@ -94,7 +106,11 @@ class Smarty_TikiWiki extends Smarty {
global $language, $style, $style_base;
if (isset($style) && isset($style_base) && isset($_smarty_tpl_file)) {
if (file_exists("templates/styles/$style_base/$_smarty_tpl_file")) {
if ($tikidomain and file_exists("templates/$tikidomain/styles/$style_base/$_smarty_tpl_file")) {
$_smarty_tpl_file = "$tikidomain/styles/$style_base/$_smarty_tpl_file";
} elseif ($tikidomain and file_exists("templates/$tikidomain/$_smarty_tpl_file")) {
$_smarty_tpl_file = "$tikidomain/$_smarty_tpl_file";
} elseif (file_exists("templates/styles/$style_base/$_smarty_tpl_file")) {
$_smarty_tpl_file = "styles/$style_base/$_smarty_tpl_file";
}
}
......
......@@ -3,9 +3,8 @@
<form method="post" action="tiki-edit_css.php">
{tr}Style Sheet{/tr} :
{if $action eq "edit"}
<b>{$editstyle}</b>
<input type="hidden" name="editstyle" value="{$editstyle|escape}" />
<input type="submit" name="save" value="{tr}save a custom copy{/tr}" />
<input type="text" name="editstyle" value="{$editstyle}" />
<input type="submit" name="save" value="{tr}Save{/tr}" />
<a href="tiki-edit_css.php?editstyle={$editstyle}" class="link">{tr}Cancel{/tr}</a>
<div style="padding:4px;border-bottom:1px solid #c3b3a3;">
<textarea name="data" rows="42" cols="80" wrap="virtual" style="padding:7px;padding-right:0;">{$data|escape}</textarea>
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_css.php,v 1.7 2004-03-28 07:32:23 mose Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_css.php,v 1.8 2004-04-26 17:55:12 mose Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-edit_css.php,v 1.7 2004-03-28 07:32:23 mose Exp $
// $Id: tiki-edit_css.php,v 1.8 2004-04-26 17:55:12 mose Exp $
include_once ("tiki-setup.php");
include_once ("lib/csslib.php");
......@@ -78,15 +78,21 @@ if (isset($_REQUEST["edit"])and $_REQUEST["edit"]) {
$action = 'edit';
// $data = implode("",file("$styledir/$editstyle.css"));
$data = load_css2_file("$styledir/$editstyle.css", $styledir);
if (isset($tikidomain) and is_file("$styledir/$tikidomain/$editstyle.css")) {
$data = load_css2_file("$styledir/$tikidomain/$editstyle.css", $styledir);
} else {
$data = load_css2_file("$styledir/$editstyle.css", $styledir);
}
} elseif (isset($_REQUEST["save"])and $_REQUEST["save"]) {
check_ticket('edit-css');
$action = 'display';
$data = '';
$file = str_replace("-$user", "", $editstyle);
$fp = fopen("$styledir/{$file}-$user.css", "w");
$editstyle = "{$file}-$user";
if (isset($tikidomain) and is_dir("$styledir/$tikidomain")) {
$fp = fopen("$styledir/$tikidomain/$editstyle.css", "w");
} else {
$fp = fopen("$styledir/$editstyle.css", "w");
}
if (!$fp) {
$smarty->assign('msg', tra("You dont have permission to write the style sheet"));
......@@ -106,8 +112,11 @@ if (isset($_REQUEST["edit"])and $_REQUEST["edit"]) {
$smarty->assign('action', $action);
$smarty->assign('data', $data);
$cssdata = $csslib->browse_css("$styledir/$editstyle.css");
if (isset($tikidomain) and is_file("$styledir/$tikidomain/$editstyle.css")) {
$cssdata = $csslib->browse_css("$styledir/$tikidomain/$editstyle.css");
} else {
$cssdata = $csslib->browse_css("$styledir/$editstyle.css");
}
if ((!$cssdata["error"]) and is_array($cssdata["content"])) {
$parsedcss = $csslib->parse_css($cssdata["content"]);
} else {
......@@ -124,6 +133,9 @@ if ($_REQUEST["try"]) {
}
$list = $csslib->list_css($styledir);
if (isset($tikidomain) and is_dir("$styledir/$tikidomain")) {
$list = array_unique(array_merge($list,$csslib->list_css("$styledir/$tikidomain")));
}
$smarty->assign('list', $list);
ask_ticket('edit-css');
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_templates.php,v 1.10 2004-03-28 07:32:23 mose Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-edit_templates.php,v 1.11 2004-04-26 17:55:12 mose Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -31,9 +31,8 @@ if (!isset($_REQUEST["mode"])) {
// Validate to prevent editing any file
if (isset($_REQUEST["template"])) {
if ((substr($_REQUEST["template"], 0, 10) != 'templates/') || (strstr($_REQUEST["template"], '..'))) {
if (strstr($_REQUEST["template"], '..')) {
$smarty->assign('msg', tra("You dont have permission to do that"));
$smarty->display('error.tpl');
die;
}
......@@ -41,12 +40,17 @@ if (isset($_REQUEST["template"])) {
if (isset($_REQUEST["save"])) {
check_ticket('edit-templates');
$fp = fopen($_REQUEST["template"], "w");
if (isset($tikidomain) and is_file($smarty->template_dir.$tikidomain.'/'.$style_base.'/'.$_REQUEST["template"])) {
$fp = fopen($smarty->template_dir.$tikidomain.'/'.$style_base.'/'.$_REQUEST["template"], "w");
} elseif (isset($tikidomain) and is_dir($smarty->template_dir.$tikidomain)) {
$fp = fopen($smarty->template_dir.$tikidomain.'/'.$_REQUEST["template"], "w");
} elseif (isset($tikidomain) and is_file($smarty->template_dir.'/'.$style_base.'/'.$_REQUEST["template"])) {
$fp = fopen($smarty->template_dir.'/'.$style_base.'/'.$_REQUEST["template"], "w");
} else {
$fp = fopen($smarty->template_dir.$_REQUEST["template"], "w");
}
if (!$fp) {
$smarty->assign('msg', tra("You dont have permission to write the template"));
$smarty->display("error.tpl");
die;
}
......@@ -57,17 +61,22 @@ if (isset($_REQUEST["save"])) {
if (isset($_REQUEST["template"])) {
$mode = 'editing';
$fp = fopen($_REQUEST["template"], "r");
if (isset($tikidomain) and is_file($smarty->template_dir.$tikidomain.'/'.$style_base.'/'.$_REQUEST["template"])) {
$file = $smarty->template_dir.$tikidomain.'/'.$style_base.'/'.$_REQUEST["template"];
} elseif (isset($tikidomain) and is_file($smarty->template_dir.$tikidomain.'/'.$_REQUEST["template"])) {
$file = $smarty->template_dir.$tikidomain.'/'.$_REQUEST["template"];
} elseif (is_file($smarty->template_dir.'/'.$style_base.'/'.$_REQUEST["template"])) {
$file = $smarty->template_dir.'/'.$style_base.'/'.$_REQUEST["template"];
} else {
$file = $smarty->template_dir.$_REQUEST["template"];
}
$fp = fopen($file,'r');
if (!$fp) {
$smarty->assign('msg', tra("You dont have permission to read the template"));
$smarty->display("error.tpl");
die;
}
$data = fread($fp, filesize($_REQUEST["template"]));
$data = fread($fp, filesize($file));
fclose ($fp);
$smarty->assign('data', $data);
$smarty->assign('template', $_REQUEST["template"]);
......@@ -77,32 +86,28 @@ $smarty->assign('mode', $mode);
// Get templates from the templates directory
$files = array();
$h = opendir("templates");
$h = opendir($smarty->template_dir);
while (($file = readdir($h)) !== false) {
if (strstr($file, '.tpl')) {
$files[] = "templates/" . $file;
if (substr($file,-4,4) == '.tpl') {
$files[] = $file;
}
}
closedir ($h);
$h = opendir("templates/modules/");
$h = opendir($smarty->template_dir."modules/");
while (($file = readdir($h)) !== false) {
if (strstr($file, '.tpl')) {
$files[] = "templates/modules/" . $file;
if (substr($file,-4,4) == '.tpl') {
$files[] = "modules/" . $file;
}
}
closedir ($h);
$h = opendir("templates/mail/");
$h = opendir($smarty->template_dir."mail/");
while (($file = readdir($h)) !== false) {
if (strstr($file, '.tpl')) {
$files[] = "templates/mail/" . $file;
if (substr($file,-4,4) == '.tpl') {
$files[] = "mail/" . $file;
}
}
closedir ($h);
sort ($files);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment