head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2006.03.12.18.36.58;	author rse;	state Exp;
branches;
next	1.1;
commitid	Cqg9O1Jqq5I2hVor;

1.1
date	2006.03.09.19.00.25;	author rse;	state Exp;
branches;
next	;
commitid	VYsLD712fl94vxor;


desc
@@


1.2
log
@move diversion stuff into canvas-php.php and HTML template into a new canvas-html.php
@
text
@<script language="php">
##
##  Copyright (c) 2005-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
##  Copyright (c) 2005-2006 Ralf S. Engelschall <http://engelschall.com/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##
##  canvas-php.php: PHP reuseable components
##

#   diversion support
$div = array();
$div["name"] = "";
$div["data"] = array();
function divert_start ($name) {
    global $div;
    $div["name"] = $name;
    if (!isset($div["data"][$diversion_name])) {
        $div["data"][$diversion_name] = "";
    }
    ob_start();
}
function divert_end () {
    global $div;
    if ($div["name"] != "") {
        $div["data"][$div["name"]] .= ob_get_contents();
        ob_end_clean();
    }
}
function divert ($name) {
    global $div;
    if ($div["name"] != $name) {
        divert_end();
        divert_start($name);
    }
}
function undivert ($name) {
    global $div;
    if ($div["name"] == $name) {
        $div["data"][$div["name"]] .= ob_get_contents();
        ob_clean();
    }
    return $div["data"][$name];
}

</script>
@


1.1
log
@reuseable PHP code for consumer side
@
text
@a25 1
</script>
d27 31
a57 16
<script language="php">
    divert("html-head");
    echo "<script language=\"php\">";
</script>

#   scramble an email address/link somewhat to prevent
#   trivial address crawlers from picking it up
function email ($url, $link) {
    $html = $url;
    $html = preg_replace('/@@/',  '<!-- XXX -->&#64;<!-- XXX -->', $html);
    $html = preg_replace('/\./', '<!-- XXX -->&#46;<!-- XXX -->', $html);
    if ($link) {
        $href = $url;
        $href = preg_replace('/@@/', '&#64;', $href);
        $href = preg_replace('/\./', '&#46;', $href);
        $html = "<a href=\"mailto:$href\">$html</a>";
d59 1
a59 1
    echo $html;
a61 2
<script language="php">
    echo "</script>";
a62 1

@

