Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

122 lines (103 sloc) 4.658 kb
<?php /*
ocPortal
Copyright (c) ocProducts, 2004-2012
See text/EN/licence.txt for full licencing information.
NOTE TO PROGRAMMERS:
Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
**** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
*/
/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package core
*/
/**
* A template has not been structurally cached, so compile it and store in the cache.
*
* @param ID_TEXT The theme the template is in the context of
* @param PATH The path to the template file
* @param ID_TEXT The codename of the template (e.g. foo)
* @param ID_TEXT The actual codename to use for the template (e.g. thin_foo)
* @param LANGUAGE_NAME The language the template is in the context of
* @param string File type suffix of template file
* @param ?ID_TEXT The theme to cache in (NULL: main theme)
* @return tempcode The compiled tempcode
*/
function _do_template($theme,$path,$codename,$_codename,$lang,$suffix,$theme_orig=NULL)
{
if (is_null($theme_orig)) $theme_orig=$theme;
$base_dir=((($theme=='default') && (($suffix!='.css') || (strpos($path,'/css_custom')===false)))?get_file_base():get_custom_file_base()).'/themes/';
global $CACHE_TEMPLATES,$FILE_ARRAY,$TEMPLATE_PREVIEW_OP,$MEM_CACHE;
if (isset($FILE_ARRAY))
{
$html=unixify_line_format(file_array_get('themes/'.$theme.$path.$codename.$suffix));
} else $html=unixify_line_format(file_get_contents($base_dir.filter_naughty($theme.$path.$codename).$suffix,FILE_TEXT));
if (strpos($html,'{$,Parser hint: pure}')!==false)
{
return make_string_tempcode(preg_replace('#\{\$,.*\}#U','/*no minify*/',$html));
}
if (($GLOBALS['SEMI_DEBUG_MODE']) && (strpos($html,'.innerHTML')!==false) && (strpos($html,'Parser hint: .innerHTML okay')===false))
{
require_code('site');
attach_message('Do not use the .innerHTML property in your Javascript because it will not work in true XHTML (when the browsers real XML parser is in action). Use ocPortal\'s global setInnerHTML/getInnerHTML functions.','warn');
}
// Strip off trailing final lines from single lines templates. Editors often put these in, and it causes annoying "visible space" issues
if ((substr($html,-1,1)==chr(10)) && (substr_count($html,chr(10))==1))
{
$html=substr($html,0,strlen($html)-1);
}
if ($TEMPLATE_PREVIEW_OP)
{
$test=post_param($codename,NULL);
if (!is_null($test)) $html=post_param($test.'_new');
}
$result=template_to_tempcode($html,0,false,$codename,$theme,$lang);
if (($CACHE_TEMPLATES) && (($suffix=='.tpl') || ($codename=='no_cache')))
{
if (!is_null($MEM_CACHE))
{
persistant_cache_set(array('TEMPLATE',$theme,$lang,$_codename),$result->to_assembly(),strpos($path,'default/templates/')!==false);
} else
{
$path2=get_custom_file_base().'/themes/'.$theme_orig.'/templates_cached/'.filter_naughty($lang).'/';
$myfile=@fopen($path2.filter_naughty($_codename).$suffix.'.tcd','wb');
if ($myfile===false)
{
if (@mkdir($path2,0777))
{
require_code('files');
fix_permissions($path2,0777);
} else
{
if (file_exists($path2.filter_naughty($_codename).$suffix.'.tcd'))
warn_exit(do_lang_tempcode('WRITE_ERROR',$path2.filter_naughty($_codename).$suffix.'.tcd'));
else
warn_exit(do_lang_tempcode('WRITE_ERROR_CREATE',$path2.filter_naughty($_codename).$suffix.'.tcd'));
}
} else
{
fwrite($myfile,$result->to_assembly($lang));
fclose($myfile);
fix_permissions($path2.filter_naughty($_codename).$suffix.'.tcd');
}
}
}
return $result;
}
/**
* Convert template text into tempcode format.
*
* @param string The template text
* @param integer The position we are looking at in the text
* @param boolean Whether this text is infact a directive, about to be put in the context of a wider template
* @param ID_TEXT The codename of the template (e.g. foo)
* @param ?ID_TEXT The theme it is for (NULL: current theme)
* @param ?ID_TEXT The language it is for (NULL: current language)
* @param boolean Whether to tolerate errors
* @return mixed The converted/compiled template as tempcode, OR if a directive, encoded directive information
*/
function template_to_tempcode(/*&*/$text,$symbol_pos=0,$inside_directive=false,$codename='',$theme=NULL,$lang=NULL,$tolerate_errors=false)
{
require_code('comcode_conversion');
return template_to_tempcode_static(/*&*/$text,$symbol_pos,$inside_directive,$codename,$theme,$lang);
}
Jump to Line
Something went wrong with that request. Please try again.