示例#1
0
文件: helpers.php 项目: gBokiau/kirby
/**
 * Embeds a snippet from the snippet folder
 *
 * @param string $file
 * @param mixed $data array or object
 * @param boolean $return
 * @return string
 */
function snippet($file, $data = array(), $return = false)
{
    if (is_object($data)) {
        $data = array('item' => $data);
    }
    return tpl::load(c::get('root.snippets') . DS . $file . '.php', $data, $return);
}
示例#2
0
/**
 * Embeds a snippet from the snippet folder
 *
 * @param string $file
 * @param mixed $data array or object
 * @param boolean $return
 * @return string
 */
function snippet($file, $data = array(), $return = false)
{
    if (is_object($data)) {
        $data = array('item' => $data);
    }
    return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.php', $data, $return);
}
示例#3
0
 /**
  * Renders the snippet with the given data 
  * 
  * @param string $name
  * @param array $data
  * @param boolean $return
  * @return string
  */
 public function render($name, $data = [], $return = false)
 {
     if (is_object($data)) {
         $data = ['item' => $data];
     }
     return tpl::load($this->kirby->registry->get('snippet', $name), $data, $return);
 }
示例#4
0
文件: author.php 项目: aizlewood/2016
 public function toHtml()
 {
     $snippet = kirby()->roots()->snippets() . DS . 'webmentions' . DS . 'author.php';
     if (!file_exists($snippet)) {
         $snippet = dirname(__DIR__) . DS . 'snippets' . DS . 'author.php';
     }
     return tpl::load($snippet, array('author' => $this, 'mention' => $this->mention));
 }
示例#5
0
 public function render()
 {
     $file = $this->_root . DS . str_replace('.', DS, $this->_file) . '.php';
     if (!file_exists($file)) {
         throw new Exception(l('view.error.invalid') . $file);
     }
     return tpl::load($file, $this->_data);
 }
示例#6
0
/**
 * Disqus plugin
 *
 * @author Bastian Allgeier <*****@*****.**>
 * @version 2.0.0
 */
function disqus($shortname, $params = array())
{
    $defaults = array('shortname' => $shortname, 'title' => page()->title(), 'identifier' => page()->disqussId()->or(page()->uri()), 'developer' => false, 'url' => url::current());
    $options = array_merge($defaults, $params);
    if (empty($options['shortname'])) {
        throw new Exception('Please provide a disqus shortname');
    }
    $options['title'] = addcslashes($options['title'], "'");
    $options['developer'] = $options['developer'] ? 'true' : 'false';
    return tpl::load(__DIR__ . DS . 'template.php', $options);
}
 public function getMonthBoard($month, $year)
 {
     // Calendar language
     date_default_timezone_set('UTC');
     $l = panel()->language();
     setlocale(LC_ALL, $l . '_' . str::upper($l));
     //setlocale(LC_ALL, 'us_US');
     // Calendar stuff
     $cal = new Calendarboard\calendar();
     $currentMonth = $cal->month($year, $month);
     return tpl::load(__DIR__ . DS . 'template.php', array('currentMonth' => $currentMonth, 'get_day_route_url' => purl($this->model(), 'field/' . $this->field()->name . '/calendarboard/get-day/'), 'calendarboard_url' => $this->model(), 'year_folder' => '/year-' . $year));
 }
示例#8
0
/**
 * imgsrc Plugin
 *
 * @author Marijn Tijhuis <*****@*****.**>
 * @author Jonathan van Wunnik <*****@*****.**>
 * @version 1.0.0
 */
function bgimage($image = false, $options = array())
{
    if (!$image) {
        return;
    }
    // Default key values
    $defaults = array('width' => null, 'height' => null, 'crop' => null, 'cropratio' => null, 'class' => '', 'alt' => '', 'quality' => c::get('thumbs.quality', 92), 'lazyload' => c::get('lazyload', false));
    // Merge defaults and options
    $options = array_merge($defaults, $options);
    // Without resrc, maximize thumb width, for speedier loading of page!
    if (c::get('resrc') == false) {
        if (!isset($options['width'])) {
            $thumbwidth = c::get('thumbs.width.default', 800);
        } else {
            $thumbwidth = $options['width'];
        }
    } else {
        // If resrc is enabled, use original image width
        $thumbwidth = $image->width();
    }
    // If no crop variable is defined *and* no cropratio
    // is set, the crop variable is set to false
    if (!isset($options['crop']) && !isset($options['cropratio'])) {
        $options['crop'] = false;
    }
    // When a cropratio is set, calculate the ratio based height
    if (isset($options['cropratio'])) {
        // If cropratio is a fraction string (e.g. 1/2), convert to decimal
        if (strpos($options['cropratio'], '/') !== false) {
            list($numerator, $denominator) = str::split($options['cropratio'], '/');
            $options['cropratio'] = $numerator / $denominator;
        }
        // Calculate new thumb height based on cropratio
        $thumbheight = round($thumbwidth * $options['cropratio']);
        // If a cropratio is set, the crop variable is always set to true
        $options['crop'] = true;
        // Manual set (crop)ratio
        $ratio = $options['cropratio'];
    } else {
        // Intrinsic image's ratio
        $ratio = 1 / $image->ratio();
        // Max. height of image
        $thumbheight = round($thumbwidth * $ratio);
    }
    // Create thumb url (create a new thumb object)
    $options['thumburl'] = thumb($image, array('width' => $thumbwidth, 'height' => $thumbheight, 'quality' => $options['quality'], 'crop' => $options['crop']), false);
    // Add more values to options array, for use in template
    $options['customwidth'] = $options['width'];
    $options['customquality'] = $options['quality'];
    $options['ratio'] = $ratio;
    // Return template HTML
    return tpl::load(__DIR__ . DS . 'template/bgimage.php', $options);
}
示例#9
0
/**
 * Figure Plugin
 *
 * @author Marijn Tijhuis <*****@*****.**>
 * @author Jonathan van Wunnik <*****@*****.**>
 * @version 1.0.0
 */
function figure($image = false, $options = array())
{
    if (!$image) {
        return;
    }
    // default key values
    $defaults = array('crop' => null, 'cropratio' => null, 'class' => '', 'alt' => '', 'caption' => null, 'lazyload' => c::get('lazyload', false));
    // merge defaults and options
    $options = array_merge($defaults, $options);
    // without resrc, maximize thumb width, for speedier loading of page!
    if (c::get('resrc') == false) {
        $thumbwidth = c::get('thumb.dev.width', 800);
    } else {
        // with resrc use maximum (original) image width
        $thumbwidth = null;
    }
    // if no crop variable is defined *and* no cropratio
    // is set, the crop variable is set to false
    if (!isset($options['crop']) && !isset($options['cropratio'])) {
        $options['crop'] = false;
    }
    // when a cropratio is set, calculate the ratio based height
    if (isset($options['cropratio'])) {
        // if resrc is enabled (and therefor $thumbwidth is not set (e.g. `null`),
        // to use max width of image!), set thumbwidth to width of original image
        if (!isset($thumbwidth)) {
            $thumbwidth = $image->width();
        }
        // if cropratio is a fraction string (e.g. 1/2), convert to decimal
        // if(!is_numeric($options['cropratio'])) {
        if (strpos($options['cropratio'], '/') !== false) {
            list($numerator, $denominator) = str::split($options['cropratio'], '/');
            $options['cropratio'] = $numerator / $denominator;
        }
        // calculate new thumb height based on cropratio
        $thumbheight = round($thumbwidth * $options['cropratio']);
        // if a cropratio is set, the crop variable is always set to true
        $options['crop'] = true;
    } else {
        $thumbheight = null;
        // max height of image
    }
    // Create thumb url (create a new thumb object)
    $options['thumburl'] = thumb($image, array('width' => $thumbwidth, 'height' => $thumbheight, 'crop' => $options['crop']), false);
    // Add image object to options array, for use in template
    $options['image'] = $image;
    // Return template HTML
    return tpl::load(__DIR__ . DS . 'template.php', $options);
}
示例#10
0
 /**
  * Generate field content markup
  *
  * @return string
  */
 public function content()
 {
     $wrapper = new Brick('div');
     $wrapper->addClass('subpagelist');
     $children = $this->subpages();
     // add pagination to the subpages
     $limit = $this->limit() ? $this->limit() : 10000;
     $children = $children->paginate($limit, array('page' => get('page')));
     // use existing snippet to build the list
     // @see panel/app/controllers/views/pages.php
     $subpages = new Snippet('pages/sidebar/subpages', array('title' => l('pages.show.subpages.title'), 'page' => $this->page(), 'subpages' => $children, 'addbutton' => !api::maxPages($this, $this->subpages()->max()), 'pagination' => $children->pagination()));
     // use template with defined vars
     $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('subpages' => $subpages)));
     return $wrapper;
 }
示例#11
0
function snippet_detect($file, $data = array(), $return = false)
{
    if (is_object($data)) {
        $data = array('item' => $data);
    }
    // If the session variable is not found, set the default value (e.g 'mobile')
    $device_class = s::get('device_class', 'mobile');
    // Embed the device class specific snippet
    if ($device_class == 'mobile') {
        // Embed the mobile snippet (`mobile` is the default snippet, without the device specific `.postfix`, e.g. footer.php)
        return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.php', $data, $return);
    } else {
        // Embed the device class specific snippet (e.g. `footer.desktop.php`)
        return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.' . $device_class . '.php', $data, $return);
    }
}
/**
 * Analytics plugin for Kirby
 *
 * @author Authorless
 * @version 1.0
 */
function analytics()
{
    if (c::get('analytics', false) === false) {
        return;
    }
    $id = c::get('analytics.id');
    if ($id === null) {
        return;
    }
    $anonymize = c::get('analytics.anonymize', false);
    if (is_bool($anonymize) === false) {
        $anonymize = false;
    }
    $templateData = compact('id', 'anonymize');
    return tpl::load(__DIR__ . DS . 'template.php', $templateData);
}
示例#13
0
 /**
  * Generate field content markup
  *
  * @return string
  */
 public function content()
 {
     $wrapper = new Brick('div');
     $wrapper->addClass('subpagelist');
     $children = $this->subpages();
     // add pagination to the subpages
     $limit = $this->limit() ? $this->limit() : 10000;
     $children = $children->paginated('sidebar');
     $pagination = new Snippet('pagination', array('pagination' => $children->pagination(), 'nextUrl' => $children->pagination()->nextPageUrl(), 'prevUrl' => $children->pagination()->prevPageUrl()));
     // use existing snippet to build the list
     // @see /panel/app/src/panel/models/page/sidebar.php
     $subpages = new Snippet('pages/sidebar/subpages', array('title' => $this->i18n($this->label), 'page' => $this->page(), 'subpages' => $children, 'addbutton' => $this->page->addButton(), 'pagination' => $pagination));
     // use template with defined vars
     $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('subpages' => $subpages)));
     return $wrapper;
 }
示例#14
0
 /**
  * Renders the template by page with the additional data
  * 
  * @param Page|string $template
  * @param array $data
  * @param boolean $return
  * @return string
  */
 public function render($template, $data = [], $return = true)
 {
     if ($template instanceof Page) {
         $page = $template;
         $file = $page->templateFile();
         $data = $this->data($page, $data);
     } else {
         $file = $template;
         $data = $this->data(null, $data);
     }
     // check for an existing template
     if (!file_exists($file)) {
         throw new Exception('The template could not be found');
     }
     // merge and register the template data globally
     tpl::$data = array_merge(tpl::$data, $data);
     // load the template
     return tpl::load($file, null, $return);
 }
示例#15
0
 /**
  * Render the edit comment form.
  *
  * @return  string
  */
 public function editForm()
 {
     return tpl::load(__DIR__ . DS . 'form.php', array('field' => $this));
 }
function disqus_footer($post)
{
    $html .= tpl::load(__DIR__ . DS . 'footer.php', array('disqus_shortname' => c::get('disqus-shortname')));
    return $html;
}
示例#17
0
 /**
  * Create input element.
  *
  * @since 1.0.0
  * @return \Brick
  */
 public function input()
 {
     // Set up modals
     $modals = tpl::load(__DIR__ . DS . 'partials' . DS . 'modals.php', ['field' => $this]);
     // Set up translation
     $translation = tpl::load(__DIR__ . DS . 'partials' . DS . 'translation.php', ['translations' => $this->translation]);
     // Set up textarea
     $input = parent::input();
     $input->tag('textarea');
     $input->removeAttr('type');
     $input->removeAttr('value');
     $input->html($this->value() ?: false);
     $input->data(['field' => 'markdownfield', 'toolbar' => $this->toolbar ? 'true' : 'false', 'tools' => implode(',', $this->tools), 'header1' => $this->header1, 'header2' => $this->header2, 'kirbytext' => c::get('panel.kirbytext', true) ? 'true' : 'false']);
     /*
        FIX: Prevent Google Chrome from trying to validate the underlying
        invisible textarea. the Panel will handle this instead.
     
        See: https://github.com/JonasDoebertin/kirby-visual-markdown/issues/42
     */
     $input->removeAttr('required');
     // Set up wrapping element
     $wrapper = new Brick('div', false);
     $wrapper->addClass('markdownfield-wrapper');
     $wrapper->addClass('markdownfield-field-' . $this->name);
     return $wrapper->append($modals)->append($translation)->append($input);
 }
示例#18
0
 /**
  * Template configuration
  *
  * @param Page $page
  * @param array $data
  * @return string
  */
 public function template(Page $page, $data = array())
 {
     // apply the basic template vars
     tpl::$data = array_merge(tpl::$data, array('kirby' => $this, 'site' => $this->site(), 'pages' => $this->site()->children(), 'page' => $page), $page->templateData(), $data, $this->controller($page, $data));
     if (!file_exists($page->templateFile())) {
         throw new Exception('The default template could not be found');
     }
     return tpl::load($page->templateFile());
 }
示例#19
0
 function load()
 {
     // initiate the site and make pages and page
     // globally available
     $pages = $this->pages;
     $page = $this->pages->active();
     // check for ssl
     if (c::get('ssl')) {
         // if there's no https in the url
         if (!server::get('https')) {
             go(str_replace('http://', 'https://', $page->url()));
         }
     }
     // check for index.php in rewritten urls and rewrite them
     if (c::get('rewrite') && preg_match('!index.php\\/!i', $this->uri->original)) {
         go($page->url());
     }
     // check for a misconfigured subfolder install
     if ($page->isErrorPage()) {
         // if you want to store subfolders in the homefolder for blog articles i.e. and you
         // want urls like http://yourdomain.com/article-title you can set
         // RedirectMatch 301 ^/home/(.*)$ /$1 in your htaccess file and those
         // next lines will take care of delivering the right pages.
         $uri = c::get('home') . '/' . $this->uri->path();
         if ($redirected = $this->pages()->find($uri)) {
             if ($redirected->uri() == $uri) {
                 $page = $redirected;
                 $this->pages->active = $page;
                 $this->uri = new uri($uri);
             }
         }
         // try to rewrite broken translated urls
         // this will only work for default uris
         if (c::get('lang.support')) {
             $path = $this->uri->path->toArray();
             $obj = $pages;
             $found = false;
             foreach ($path as $p) {
                 // first try to find the page by uid
                 $next = $obj->{'_' . $p};
                 if (!$next) {
                     // go through each translation for each child page
                     // and try to find the url_key or uid there
                     foreach ($obj as $child) {
                         foreach (c::get('lang.available') as $lang) {
                             $c = $child->content($lang);
                             // redirect to the url if a translated url has been found
                             if ($c && $c->url_key() == $p && !$child->isErrorPage()) {
                                 $next = $child;
                             }
                         }
                     }
                     if (!$next) {
                         break;
                     }
                 }
                 $found = $next;
                 $obj = $next->children();
             }
             if ($found && !$found->isErrorPage()) {
                 go($found->url());
             }
         }
     }
     // redirect file urls (file:image.jpg)
     if ($this->uri->param('file')) {
         // get the local file
         $file = $page->files()->find($this->uri->param('file'));
         if ($file) {
             go($file->url());
         }
     }
     // redirect /home to /
     if ($this->uri->path() == c::get('home')) {
         go(url());
     }
     // redirect tinyurls
     if ($this->uri->path(1) == c::get('tinyurl.folder') && c::get('tinyurl.enabled')) {
         $hash = $this->uri->path(2);
         if (!empty($hash)) {
             $resolved = $this->pages->findByHash($hash)->first();
             // redirect to the original page
             if ($resolved) {
                 go(url($resolved->uri));
             }
         }
     }
     // set the global template vars
     tpl::set('site', $this);
     tpl::set('pages', $pages);
     tpl::set('page', $page);
     $cacheID = $this->htmlCacheID();
     $cacheModified = time();
     $cacheData = null;
     if ($this->htmlCacheEnabled) {
         // check if the cache is disabled for some reason
         $this->htmlCacheEnabled = $page->isErrorPage() || in_array($page->uri(), c::get('cache.ignore', array())) ? false : true;
         // check for the last modified date of the cache file
         $cacheModified = cache::modified($cacheID);
         // check if the files have been modified
         // since the last html cache file has been written
         if ($this->htmlCacheEnabled && $cacheModified >= $this->modified) {
             $cacheData = cache::get($cacheID, true);
         }
     }
     // send a 404 header if this is the error page
     if ($page->isErrorPage() && c::get('404.header')) {
         header("HTTP/1.0 404 Not Found");
     }
     if (empty($cacheData)) {
         // load the main template
         $html = tpl::load($page->template(), array(), true);
         if ($this->htmlCacheEnabled) {
             cache::set($cacheID, (string) $html, true);
         }
     } else {
         $html = $cacheData;
     }
     die($html);
 }
示例#20
0
<?php

$count = page('contact')->submissions()->toStructure()->count();
$items = page('contact')->submissions()->toStructure()->flip()->limit(4);
return ['title' => ['text' => 'Recent Enquiries', 'link' => 'pages/contact/edit'], 'options' => [['text' => 'View All (' . $count . ')', 'icon' => 'eye', 'link' => 'pages/contact/edit']], 'html' => function () use($items) {
    return \tpl::load(__DIR__ . DS . 'apex-contacts.html.php', ['submissions' => $items]);
}];
示例#21
0
 */
Pages::$methods['feed'] = function ($pages, $params = array()) {
    // set all default values
    $defaults = array('url' => url(), 'title' => 'Blog Feed', 'description' => 'Latest articles from the blog', 'link' => url(), 'datefield' => 'modified', 'textfield' => 'text', 'modified' => time(), 'excerpt' => false, 'generator' => kirby()->option('feed.generator', 'Kirby'), 'header' => true, 'snippet' => false);
    // merge them with the user input
    $options = array_merge($defaults, $params);
    // sort by date
    $items = $pages->sortBy($options['datefield'], 'desc');
    // add the items
    $options['items'] = $items;
    $options['link'] = url($options['link']);
    // fetch the modification date
    if ($options['datefield'] == 'modified') {
        $options['modified'] = $items->first()->modified();
    } else {
        $options['modified'] = $items->first()->date(false, $options['datefield']);
    }
    // send the xml header
    if ($options['header']) {
        header::type('text/xml');
    }
    // echo the doctype
    $html = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
    // custom snippet
    if ($options['snippet']) {
        $html .= snippet($options['snippet'], $options, true);
    } else {
        $html .= tpl::load(__DIR__ . DS . 'template.php', $options);
    }
    return $html;
};
示例#22
0
 public function view($name, $data = [])
 {
     return tpl::load(dirname(__DIR__) . DS . 'views' . DS . $name . '.php', $data);
 }
示例#23
0
 /**
  * Generate field content markup
  *
  * @since 1.0.0
  *
  * @return string
  */
 public function content()
 {
     $wrapper = new Brick('div');
     $wrapper->addClass('selector');
     $wrapper->data(array('field' => 'selector', 'name' => $this->name(), 'page' => $this->page(), 'mode' => $this->mode, 'autoselect' => $this->autoselect()));
     $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('field' => $this)));
     return $wrapper;
 }
示例#24
0
 /**
  * Template configuration
  *
  * @param Page $page
  * @param array $data
  * @return string
  */
 public function template(Page $page, $data = array())
 {
     // apply the basic template vars
     tpl::$data = array_merge(tpl::$data, array('kirby' => $this, 'site' => $this->site(), 'pages' => $this->site()->children(), 'page' => $page), $page->templateData(), $data, $this->controller($page, $data));
     return tpl::load($page->templateFile());
 }
示例#25
0
<?php

$user = site()->user();
return array('title' => array('text' => l('dashboard.index.account.title'), 'link' => purl($user, 'edit')), 'options' => array(array('text' => l('dashboard.index.account.edit'), 'icon' => 'pencil', 'link' => purl($user, 'edit'))), 'html' => function () use($user) {
    return tpl::load(__DIR__ . DS . 'account.html.php', array('user' => $user));
});
示例#26
0
    // load the custom config
    require $index . DS . 'site.php';
} else {
    // create a new kirby object
    $kirby = kirby();
}
// fix the base url for the kirby installation
if (!isset($kirby->urls->index)) {
    $kirby->urls->index = dirname($kirby->url());
}
// the default index directory
if (!isset($kirby->roots->index)) {
    $kirby->roots->index = $index;
}
// the default avatar directory
if (!isset($kirby->roots->avatars)) {
    $kirby->roots->avatars = $index . DS . 'assets' . DS . 'avatars';
}
// the default thumbs directory
if (!isset($kirby->roots->thumbs)) {
    $kirby->roots->thumbs = $index . DS . 'thumbs';
}
try {
    // create the panel object
    $panel = new Kirby\Panel($kirby, __DIR__);
    // launch the panel
    echo $panel->launch();
} catch (Exception $e) {
    // load the fatal screen
    echo tpl::load(__DIR__ . DS . 'app' . DS . 'layouts' . DS . 'fatal.php', array('css' => url::index() . '/assets/css/panel.css', 'content' => $e->getMessage()));
}
示例#27
0
 public function content()
 {
     return tpl::load(__DIR__ . DS . 'template.php', array('field' => $this));
 }
示例#28
0
文件: kirby.php 项目: chrishiam/LVSL
 /**
  * Template configuration
  *
  * @param Page $page
  * @param array $data
  * @return string
  */
 public function template(Page $page, $data = array())
 {
     // set the timezone for all date functions
     date_default_timezone_set($this->options['timezone']);
     // load all language variables
     $this->localize();
     // load all extensions
     $this->extensions();
     // load all plugins
     $this->plugins();
     // apply the basic template vars
     tpl::$data = array_merge(array('kirby' => $this, 'site' => $this->site(), 'pages' => $this->site()->children(), 'page' => $page), $data, $this->controller($page, $data));
     return tpl::load($page->templateFile());
 }
示例#29
0
文件: site.php 项目: robeam/kirbycms
 function load()
 {
     // initiate the site and make pages and page
     // globally available
     $pages = $this->pages;
     $page = $this->pages->active();
     // check for ssl
     if (c::get('ssl')) {
         // if there's no https in the url
         if (!server::get('https')) {
             go(str_replace('http://', 'https://', $page->url()));
         }
     }
     // check for a misconfigured subfolder install
     if ($page->isErrorPage()) {
         // get the subfolder in which the site is running
         $subfolder = ltrim(dirname(server::get('script_name')), '/');
         // if it is running in a subfolder and it does not match the config
         // send an error with some explanations how to fix that
         if (!empty($subfolder) && c::get('subfolder') != $subfolder) {
             // this main url
             $url = 'http://' . server::get('http_host') . '/' . $subfolder;
             require_once c::get('root.kirby') . '/modals/subfolder.php';
             exit;
         }
     }
     // redirect file urls (file:image.jpg)
     if ($this->uri->param('file')) {
         // get the local file
         $file = $page->files()->find($this->uri->param('file'));
         if ($file) {
             go($file->url());
         }
     }
     // redirect /home to /
     if ($this->uri->path() == c::get('home')) {
         go(url());
     }
     // redirect tinyurls
     if ($this->uri->path(1) == c::get('tinyurl.folder') && c::get('tinyurl.enabled')) {
         $hash = $this->uri->path(2);
         if (!empty($hash)) {
             $resolved = $this->pages->findByHash($hash)->first();
             // redirect to the original page
             if ($resolved) {
                 go(url($resolved->uri));
             }
         }
     }
     // set the global template vars
     tpl::set('site', $this);
     tpl::set('pages', $pages);
     tpl::set('page', $page);
     $cacheID = $this->uri->toCacheID() . '.php';
     $cacheModified = time();
     $cacheData = null;
     if ($this->htmlCacheEnabled) {
         // check if the cache is disabled for some reason
         $this->htmlCacheEnabled = $page->isErrorPage() || in_array($page->uri(), c::get('cache.ignore', array())) ? false : true;
         // check for the last modified date of the cache file
         $cacheModified = cache::modified($cacheID);
         // check if the files have been modified
         // since the last html cache file has been written
         if ($this->htmlCacheEnabled && $cacheModified >= $this->modified) {
             $cacheData = cache::get($cacheID, true);
         }
     }
     if (empty($cacheData)) {
         // load the main template
         $html = tpl::load($page->template(), false, true);
         if ($this->htmlCacheEnabled) {
             cache::set($cacheID, (string) $html, true);
         }
     } else {
         $html = $cacheData;
     }
     die($html);
 }
示例#30
0
 protected function __getJS()
 {
     $script = 'siteURL="' . $this->site->url() . '";';
     $script .= 'currentURI="' . $this->page->uri() . '";';
     $script .= 'enhancedJS=' . (c::get('panelbar.enhancedJS', false) ? 'true' : 'false') . ';';
     $script .= tpl::load(__DIR__ . DS . 'assets' . DS . 'js' . DS . 'panelbar.min.js');
     return '<script>' . $script . '</script>';
 }