function get_content($node)
{
    $method = $node->getAttribute('method');
    //若沒有設定div id
    if ($node->getAttribute('divid') != "") {
        $divid = $node->getAttribute('divid');
    } else {
        $divid = "default";
    }
    //若沒有設定class
    if ($node->getAttribute('divclass') != "") {
        $divclass = $node->getAttribute('divclass');
    } else {
        $divclass = "default";
    }
    //$divclass = isset($node->getAttribute('divclass'))?$node->getAttribute('divclass'):"default";
    echo "\n<div id=\"{$divid}\" class=\"{$divclass}\">";
    //prepare myinclude
    global $cms;
    $templateUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . WEBROOT . $cms->nowtemplate;
    //echo $templateUrl;
    switch ($method) {
        case 'online':
            $file = CONTENTFOLDER . $node->getAttribute('filename');
            //myinclude($file,$templateUrl);
            ob_include($file);
            break;
        case 'include':
        default:
            $incurl = $node->getAttribute('includeurl');
            if (file_exists(SRVROOT . $incurl)) {
                //myinclude(SRVROOT.$incurl, $templateUrl);
                //print_r(SRVROOT.$incurl);
                ob_include(SRVROOT . $incurl);
            } else {
                echo "找不到檔案:{$incurl}";
            }
            break;
        case 'iframe':
            $iframeurl = $node->getAttribute('iframeurl');
            if (strpos($iframeurl, 'http://') !== false) {
                $file = $iframeurl;
            } else {
                $file = WEBROOT . $iframeurl;
            }
            $h = $node->getAttribute('iframe_h');
            if (!$h) {
                $h = 600;
            }
            $w = $node->getAttribute('iframe_w');
            if (!$w) {
                $w = '100%';
            }
            if ($node->getAttribute('autoheight') == 1) {
                echo "<script type=\"text/javascript\" src=\"" . LIBWEBROOT . "/js/iframe_autoHeight/autoHeight_contentHeight.js\"></script>";
                echo "<iframe src=\"{$file}\" height=\"{$h}\" width=\"{$w}\" frameborder=\"0\" class=\"autoHeight\"></iframe>";
            } else {
                echo "<iframe src=\"{$file}\" height=\"{$h}\" width=\"{$w}\" frameborder=\"0\"></iframe>";
            }
            break;
        case 'plugin':
            $addWay = $node->getAttribute('addWay');
            $folder = $node->getAttribute('folder');
            $incurl = $node->getAttribute('pluginUrl');
            $iframeurl = $node->getAttribute('pluginUrl');
            if ($addWay == 'include') {
                if (file_exists(SRVROOT . $incurl)) {
                    ob_include(SRVROOT . $incurl);
                } else {
                    echo "找不到檔案:{$incurl}";
                }
            } else {
                if ($addWay == 'iframe') {
                    if (strpos($iframeurl, 'http://') !== false) {
                        $file = $iframeurl;
                    } else {
                        $file = WEBROOT . $iframeurl;
                    }
                    $h = $node->getAttribute('iframe_h');
                    if (!$h) {
                        $h = 600;
                    }
                    $w = $node->getAttribute('iframe_w');
                    if (!$w) {
                        $w = '100%';
                    }
                    if ($node->getAttribute('autoheight') == 1) {
                        echo "<script type=\"text/javascript\" src=\"" . LIBWEBROOT . "/js/iframe_autoHeight/autoHeight_contentHeight.js\"></script>";
                        echo "<iframe src=\"{$file}\" height=\"{$h}\" width=\"{$w}\" frameborder=\"0\" class=\"autoHeight\" allowtransparency=\"1\"></iframe>";
                    } else {
                        echo "<iframe src=\"{$file}\" height=\"{$h}\" width=\"{$w}\" frameborder=\"0\" allowtransparency=\"1\"></iframe>";
                    }
                }
            }
            break;
    }
    echo "</div>";
}
예제 #2
0
<?php

require_once "cms/inc/config.inc.php";
$filename = basename(__FILE__);
if (!file_exists(SRVROOT . '/' . $filename)) {
    echo "file not find, go <a href=\"cms/install/install.php\">install</a>";
    exit;
}
if (!$cms) {
    $cms = new cmstree();
}
ob_include(SRVROOT . $cms->nowtemplate, $cms->nowtemplate);
/****************** ob_include 區 start ********************/
//include 的檔案不能比此階層高 換句話說,include 不得為此檔案的 parent
function ob_include($incfile, $tmpl = null)
{
    global $absPath;
    if (isset($tmpl)) {
        $nowSrvPath = str_replace('\\', '/', dirname(__FILE__));
        $nowWebPath = substr_replace($nowSrvPath, '', 0, strpos($nowSrvPath, $_SERVER['DOCUMENT_ROOT']) + strlen($_SERVER['DOCUMENT_ROOT']));
        $relativePath = str_replace($nowSrvPath, '', $incfile);
        $relativePath = dirname($relativePath);
        $relativePath = str_replace('.', '', $relativePath);
        $absPath = WEBROOT . $relativePath;
    }
    ob_start('ob_replace');
    include $incfile;
    ob_flush();
    ob_clean();
}
function ob_replace($buffer)