You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.5 KiB

<?php
// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
/**
* \brief Smarty plugin to use wiki page as a template resource
* -------------------------------------------------------------
* File: resource.wiki.php
* Type: resource
* Name: wiki
* Purpose: Fetches a template from a wiki page
* -------------------------------------------------------------
*/
class Smarty_Resource_Wiki extends Smarty_Resource_Custom
{
protected function fetch($name, &$source, &$mtime)
{
/** @var \Smarty_Tiki $smarty */
$smarty = TikiLib::lib('smarty');
$info = $smarty->checkWikiPageTemplatePerms($name, $source);
if ($info) {
$source = TikiLib::lib('parser')->parse_data($info['data'], ['is_html' => $info['is_html'], 'print' => 'y', 'inside_pretty' => true]);
}
}
protected function fetchTimestamp($name)
{
global $tikilib;
$info = $tikilib->get_page_info($name);
if (empty($info)) {
return false;
}
if (
preg_match('/\{([A-z-Z0-9_]+) */', $info['data'])
|| preg_match('/\{\{.+\}\}/', $info['data'])
) { // there are some plugins - so it can be risky to cache the page
return $tikilib->now + 100; // future needed in case consecutive run of template;
}
return $info['lastModif'];
}
}