예제 #1
0
<?php

/**
 * kvWebME A/B Testing plugin frontend
 *
 * PHP version 5.2
 *
 * @category None
 * @package  None
 * @author   Kae Verens <*****@*****.**>
 * @license  GPL 2.0
 * @link     http://kvsites.ie/
 */
$smarty = Core_smartySetup(USERBASE . '/ww.cache/pages');
if (!isset($_SESSION['ab_testing']['p' . $page->id]) || !file_exists(USERBASE . '/ww.cache/pages/template_ab_' . $page->id . '_0')) {
    if (!file_exists(USERBASE . '/ww.cache/pages/template_ab_' . $page->id . '_0')) {
        $vs = explode('<div>ABTESTINGDELIMITER</div>', $page->body);
        for ($i = 0; $i < count($vs); ++$i) {
            file_put_contents(USERBASE . '/ww.cache/pages/template_ab_' . $page->id . '_' . $i, $vs[$i]);
        }
    } else {
        $i = 0;
        do {
            $i++;
        } while (file_exists(USERBASE . '/ww.cache/pages/template_ab_' . $page->id . '_' . $i));
    }
    if (!isset($_SESSION['ab_testing'])) {
        $_SESSION['ab_testing'] = array();
    }
    $_SESSION['ab_testing']['p' . $page->id] = rand(0, $i - 1);
    if ($i > 1) {
예제 #2
0
파일: plugin.php 프로젝트: raylouis/kvwebme
/**
 * setup Smarty with Products-specific stuff
 *
 * @return object the Smarty object
 */
function Products_setupSmarty()
{
    global $Products_smartyInstance;
    if (!isset($Products_smartyInstance)) {
        $Products_smartyInstance = Core_smartySetup(USERBASE . '/ww.cache/products/templates_c');
    }
    $Products_smartyInstance->template_dir = '/ww.cache/products/templates';
    $Products_smartyInstance->assign('PAGEDATA', $GLOBALS['PAGEDATA']);
    if (isset($_SESSION['userdata'])) {
        $Products_smartyInstance->assign('USERDATA', $_SESSION['userdata']);
    }
    if (!isset($Products_smartyInstance->registered_plugins['modifier']['template'])) {
        $Products_smartyInstance->registerPlugin('modifier', 'template', 'Products_addTemplateToField');
    }
    return $Products_smartyInstance;
}
예제 #3
0
파일: plugin.php 프로젝트: raylouis/kvwebme
/**
 * get template
 *
 * @param string $templateString template
 *
 * @return array
 */
function ProtectedFiles_getTemplate($templateString)
{
    if (file_exists(THEME_DIR . '/' . THEME . '/h/' . $templateString . '.html')) {
        $template = THEME_DIR . '/' . THEME . '/h/' . $templateString . '.html';
    } elseif (file_exists(THEME_DIR . '/' . THEME . '/h/_default.html')) {
        $template = THEME_DIR . '/' . THEME . '/h/_default.html';
    } else {
        $d = array();
        $dir = new DirectoryIterator(THEME_DIR . '/' . THEME . '/h/');
        foreach ($dir as $f) {
            if ($f->isDot()) {
                continue;
            }
            $n = $f->getFilename();
            if (preg_match('/\\.html$/', $n)) {
                $d[] = preg_replace('/\\.html$/', '', $n);
            }
        }
        asort($d);
        $template = $d[0];
    }
    if ($template == '') {
        die('no template created. please create a template first');
    }
    require_once SCRIPTBASE . 'ww.incs/common.php';
    $smarty = Core_smartySetup(USERBASE . '/ww.cache/pages');
    $smarty->template_dir = THEME_DIR . '/' . THEME . '/h/';
    return array($smarty, str_replace('.html', '', $template));
}
예제 #4
0
파일: Page.php 프로젝트: raylouis/kvwebme
 /**
  * render a page template
  *
  * @return string rendered page
  */
 function render()
 {
     foreach ($GLOBALS['PLUGINS'] as $plugin) {
         if (isset($plugin['frontend']['body_override'])) {
             return $plugin['frontend']['body_override']($this);
         }
     }
     $smarty = Core_smartySetup(USERBASE . '/ww.cache/pages');
     global $_languages;
     $fname = USERBASE . '/ww.cache/pages/template_' . md5($this->id . '|' . join(',', $_languages));
     if (!file_exists($fname) || !filesize($fname)) {
         file_put_contents($fname, __FromJson(str_replace(array("\n", "\r"), ' ', $this->body)));
     }
     return $smarty->fetch($fname);
 }