Пример #1
0
function PageMaker($xmlfile, $xslfile)
{
    global $options, $id, $df, $cacheLifeTime;
    # Инициализация системы кэширования
    // Подключаем класс вывода PEAR::Cache_Lite
    require_once 'cache/output.php';
    // Создаем объект класса Cache_Lite_Output
    $cache = new Cache_Lite_Output($options);
    // Устанавливаем время жизни кэша для данной части
    $cache->setLifeTime($cacheLifeTime[$id]);
    if (!$cache->start($id)) {
        # Передаем путь к запрошенному документу на вход модуля анализа и преобразования XML+XSLT,
        # формирующего на выходе запрошенный документ в XHTML-формате.
        require_once "inc/nstoxhtml.inc";
        require_once "inc/setformat.inc";
        require_once "inc/nocache.inc";
        $outputformat = 'xml';
        //if ($xslfile !== "xsl/rbcrss.xsl") $xslfile = "xsl/layout.xsl";
        $domxml = new DOMDocument();
        $domxml->substituteEntities = true;
        $domxml->load($xmlfile);
        @fclose($df);
        # Снимаем блокировку с файла *
        $domxsl = new DOMDocument();
        $domxsl->load($xslfile);
        setOutputFormat($domxsl, $outputformat);
        $xsl = new xsltProcessor();
        $xsl->importStylesheet($domxsl);
        $outdom = $xsl->transformtoDOC($domxml);
        $outdom = nstoxhtml($outdom);
        $outdom->formatoutput = true;
        nocache();
        $page = $outdom->saveXML();
        echo TrimStr($page);
        $cache->end();
    }
}
Пример #2
0
<?php

// Bench script of Cache_Lite_Output
// $Id: bench2.php,v 1.1 2009/03/26 18:56:29 mhoegh Exp $
require_once 'Cache/Lite/Output.php';
$options = array('caching' => true, 'cacheDir' => '/tmp/', 'lifeTime' => 10);
$cache = new Cache_Lite_Output($options);
if (!$cache->start('123')) {
    // Cache missed...
    for ($i = 0; $i < 1000; $i++) {
        // Making of the page...
        echo '0123456789';
    }
    $cache->end();
}
Пример #3
0
function articlePage($section, $filePath)
{
    // -----[ CACHE LITE ]-----
    // Cache Lite is optional but recommended as it rolls and stores the page as HTML
    // and avoids having to rebuild the page everytime it is called. You will need to clear
    // the cache if you update the page. You could create a seperate "clearcache.php" page.
    // See: "/site/orgile/clearcache.php".
    require_once 'Cache/Lite/Output.php';
    $options = array('cacheDir' => '/srv/www/' . SITEURL . '/www/site/ramcache/', 'lifeTime' => '604800');
    // Define cache directory and cache lifetime (168 hours).
    $cache = new Cache_Lite_Output($options);
    // Begin cache lite.
    if (!$cache->start($filePath)) {
        if (is_file($filePath)) {
            $fileData = file_get_contents($filePath, NULL, NULL, 0, 1000);
            // This reads the first 1000 chars for speed.
            // Pulls details from .org file header.
            $regex = '/^#\\+\\w*:(.*)/m';
            preg_match_all($regex, $fileData, $matches);
            $title = trim($matches[1][0]);
            $author = trim($matches[1][1]);
            $date = trim($matches[1][2]);
            $date = date('c', cleanDate($date));
            $description = trim($matches[1][3]);
            $description = strip_tags($description);
            // Create HTML header.
            $htmlHeader = htmlHeader($date, $author, $description, $title, dropDash($section));
            // Starts the object buffer.
            ob_start();
            pageHeader();
            print '<div id="columnX">';
            fetchOne($filePath, 'orgile');
            print '</div>';
            print '<div id="columnY">';
            print '<aside>';
            print '<div class="content">';
            print '<h2><a href="/' . spaceDash($section) . '/" title="' . spaceDash($section) . '">' . spaceDash($section) . '</a>:</h2>';
            print '<ul class="side">';
            fetchSome($section, 'list', '0', 'sort');
            // See function below.
            print '</ul><br>';
            print '</div>' . sideContent();
            print '</aside>';
            print '</div>';
            pageFooter();
            // End the object buffer.
            $content = ob_get_contents();
            ob_end_clean();
            $content = $htmlHeader . $content;
        }
        // End: is_file($filePath).
        print $content;
        // End cache.
        $cache->end();
    }
    // End: cache lite.
}