function.configvalue.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
12 
13 /*
14 * Smarty plugin
15 * -------------------------------------------------------------
16 * File: function.configvalue.php
17 * Type: function
18 * Name: configvalue
19 * Purpose: output a configuration value
20 * or assign it to a smarty variable
21 * Usage: e.g. {configvalue key="exportDir" section="cms"} or
22 * {configvalue key="exportDir" section="cms" varname="exportDir"}
23 * -------------------------------------------------------------
24 */
25 function smarty_function_configvalue($params, \Smarty_Internal_Template $template) {
26  $config = ObjectFactory::getInstance('configuration');
27  $value = $config->getValue($params['key'], $params['section'], false);
28  if (isset($params['varname'])) {
29  $template->assign($params['varname'], $value);
30  }
31  else {
32  echo $value;
33  }
34 }
35 ?>