summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2007-10-18 12:42:31 +0000
committerChristian Schneider2007-10-18 12:42:31 +0000
commit3aee6d57f18ae1d43d5f6b141fc9e5a22bea4f39 (patch)
tree9147b1619001c1d19a8164e4f88d70b677bad13a
parent3f1dbb8bc67b578266ca679e572eca0c90a23876 (diff)
downloaditools-3aee6d57f18ae1d43d5f6b141fc9e5a22bea4f39.tar.gz
itools-3aee6d57f18ae1d43d5f6b141fc9e5a22bea4f39.tar.bz2
itools-3aee6d57f18ae1d43d5f6b141fc9e5a22bea4f39.zip
Also support css files through ITools Joining Service(TM)
-rw-r--r--itjs.class31
-rw-r--r--itjs.php40
2 files changed, 46 insertions, 25 deletions
diff --git a/itjs.class b/itjs.class
index f54bb18..bbeb618 100644
--- a/itjs.class
+++ b/itjs.class
@@ -103,23 +103,24 @@ function encode($values)
function filenames($filelist)
{
$result = array();
-
- $files = array_flip(explode(",", it::replace(array('\?.*' => ""), $filelist)));
- $itools = array_flip(array("it.js", "loader.js", "state.js", "timer.js"));
- $plainfiles = array_flip(array("boot.js", "state.html", "error.gif"));
-
- if (isset($files['itools']))
+ $path = $GLOBALS['ULTRAHOME'] . "/itjs";
+ $itjs = "/www/server/phpinclude/itools/itjs";
+ $searchlib = "/www/lib.search.ch/doc";
+ $special = array(
+ "itools" => "$itjs/it.js,$itjs/loader.js,$itjs/state.js,$itjs/timer.js",
+ "boot.js" => "$itjs/boot.js",
+ "state.html" => "$itjs/state.html",
+ "error.gif" => "$itjs/error.gif",
+ "search.css" => "$searchlib/search.css",
+ "prettyprint.css" => "$searchlib/prettyprint.css",
+ );
+
+ foreach (explode(",", it::replace(array('\?.*' => ""), $filelist)) as $file)
{
- unset($files['itools']);
- $files = $itools + $files; # Order is important!
- }
+ $filenames = $special[$file] ? $special[$file] : "$path/$file";
- foreach (array_keys($files) as $file)
- {
- if (isset($itools[$file]) || isset($plainfiles[$file]))
- $result[] = "/www/server/phpinclude/itools/itjs/$file";
- else
- $result[] = $GLOBALS['ULTRAHOME'] . "/itjs/$file";
+ foreach (explode(",", $filenames) as $filename)
+ $result[] = $filename;
}
return $result;
diff --git a/itjs.php b/itjs.php
index 818f9b8..1332ead 100644
--- a/itjs.php
+++ b/itjs.php
@@ -2,15 +2,21 @@
/*
** $Id$
**
-** itjs.php - Delivers /itjs/ files through AliasMatch in httpd.conf
+** Copyright (C) 1995-2007 by the ITools Authors.
+** This file is part of ITools - the Internet Tools Library
**
-** ITools - the Internet Tools Library
+** ITools 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 3 of the License, or
+** (at your option) any later version.
**
-** Copyright (C) 1995-2003 by the ITools Authors.
-** This program is free software; you can redistribute it and/or
-** modify it under the terms of either the GNU General Public License
-** or the GNU Lesser General Public License, as published by the Free
-** Software Foundation. See http://www.gnu.org/licenses/ for details.
+** ITools 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, see <http://www.gnu.org/licenses/>.
*/
require "itools/itools.lib";
@@ -22,13 +28,27 @@ $data = "";
$files = itjs::filenames(basename($_SERVER['PHP_SELF']));
foreach ($files as $file)
- $data .= ereg('\.php|\.html$', $file) ? @include($file) : @file_get_contents($file);
+{
+ ob_start(); # Needs to capture inside loop to guarantee file order
+ $data .= it::replace(array('^1$' => ""), @include($file));
+ $data .= ob_get_clean();
+}
$checksum = strlen($data) . itjs::checksum($files);
-if (ereg('\.gif$', $file))
+if (it::match('\.gif$', $file))
+{
header("Content-Type: image/gif");
-else if (!ereg('\.html$', $file))
+}
+else if (it::match('\.css', $_SERVER['PHP_SELF']))
+{
+ header("Content-Type: text/css");
+ ob_start('ob_gzhandler');
+ $data .= "\n#it_boot_dom { display:none }\n"; # Append magic style for it_boot
+ if (!it::match('^devel', $GLOBALS['ULTRASERVERTYPE']))
+ $data = it::replace(array('[ \t]*([{};])[ \t]*' => '$1', '/\*.*?\*/'=> ""), $data);
+}
+else if (!it::match('\.html$', $file))
{
if ($_REQUEST['boot'] && !$_REQUEST['retry'])
ob_start('ob_gzhandler');