wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
resource.lib.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id: resource.lib.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 
20 /*
21  * Smarty plugin
22  * -------------------------------------------------------------
23  * File: resource.lib.php
24  * Type: resource
25  * Name: lib
26  * Purpose: Fetches templates from lib directories
27  * -------------------------------------------------------------
28  */
29 function smarty_resource_lib_source($tpl_name, &$tpl_source, &$smarty)
30 {
31  $file = get_path($tpl_name);
32  if (is_file($file))
33  {
34  $tpl_source = $smarty->_read_file($file);
35  return true;
36  }
37  return false;
38 }
39 
40 function smarty_resource_lib_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
41 {
42  $file = get_path($tpl_name);
43  if (is_file($file))
44  {
45  $tpl_timestamp = filemtime($file);
46  return true;
47  }
48  return false;
49 }
50 
51 function smarty_resource_lib_secure($tpl_name, &$smarty)
52 {
53  return true;
54 }
55 
56 function smarty_resource_lib_trusted($tpl_name, &$smarty)
57 {
58  return true;
59 }
60 
61 function get_path($path)
62 {
63  $parser = &InifileParser::getInstance();
64 
65  // check for overrides in templateDir first
66  $templateDir = $parser->getValue('templateDir', 'smarty');
67  $userTpl = realpath($templateDir."/".$path);
68  if (file_exists($userTpl))
69  return $userTpl;
70 
71  // use templates from libDir
72  if (($libDir = $parser->getValue('libDir', 'cms')) === false)
73  WCMFException::throwEx("No library path 'libDir' defined in ini section 'cms'.", __FILE__, __LINE__);
74  return realpath($libDir."/".$path);
75 }
76 ?>
smarty_resource_lib_secure($tpl_name, &$smarty)
throwEx($message, $file='', $line='')
smarty_resource_lib_trusted($tpl_name, &$smarty)
smarty_resource_lib_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
smarty_resource_lib_source($tpl_name, &$tpl_source, &$smarty)
get_path($path)