Location: PHPKode > projects > YaCM Portal System > yacm-0.2/functions.php
<?php
/* File: $Id: functions.php 167 2006-02-18 15:15:51Z l_a_toth $ */

/**
 * Common functions: __autoload + Cache Control
 *
 * @package YaCM Portal System
 * @copyright (C) 2004,2005 László Attila Tóth
 * @license GPL {@link http://www.gnu.org/licenses/gpl.html}
 *
 * @subpackage core
 * @author László Attila Tóth
 */


/**
 * Automatically load classes if the file exists in the lib
 * directory. '_' characters are replaced by '/'.
 */
function __autoload($classname) {
  $fn_prefix =  Config::root_directory .'/lib/';
  $filename = str_replace('_', '/',strtolower($classname));
  
  if (is_readable($fn_prefix . $filename . '.php')) {
//	echo $fn_prefix . $filename . '.php<br/>';
      require_once($fn_prefix .$filename . '.php');
  } elseif ( strpos($filename,'module_') == 0 ) {
    if (is_readable($fn_prefix. $filename . '/class.php')) {
//	echo $fn_prefix . $filename . '/class.php<br/>';
      require_once($fn_prefix . $filename . '/class.php');
    } 
  }
}

/**
 * Let the proxies cache the site
 * @param int $interval time in seconds for caching
 */
function cache_novalidate( $interval = 60 ) {
  $now = time();
  $pretty_lmtime = gmdate('D, d M Y H:i:s', $now) . ' GMT';
  $pretty_extime = gmdate('D, d M Y H:i:s', $now + $interval) . ' GMT';
  // backward compatibility for UA HTTP/1.0
  header("Last Modified: $pretty_lmtime");
  header("Expires: $pretty_extime");
  // HTTP/1.1
  header("Cache-Control: public,max-age=$interval"); 
}

/**
 * Let the browsers (User Agents) cache the site
 * @param int $interval time in seconds for caching
 */
function cache_browser( $interval = 60 ) {
  $now = time();
  $pretty_lmtime = gmdate('D, d M Y H:i:s', $now) . ' GMT';
  $pretty_extime = gmdate('D, d M Y H:i:s', $now + $interval) . ' GMT';
  // backward compatibility for UA HTTP/1.0
  header("Last Modified: $pretty_lmtime");
  header("Expires: $pretty_extime");
  // HTTP/1.1
  header("Cache-Control: private,max-age=$interval"); 
}

/**
 * Disable caching the site
 */
function cache_nocache() {
  // backward compatibility for UA HTTP/1.0
  header("Expires: 0");
  header("Pragma: no-cache");
  // HTTP/1.1
  header("Cache-Control: no-cache,no-store,max-age=0,s-maxage=0,must-revalidate"); 
}

/** 
 * Wrapper of Lang::get
 * 
 * @param params Parameter array (used: params[str])
 * 
 * @return Returns with the translated string
 */
function Lang_Get_Wrapper($params) {
  if(empty($params['str'])) {
    return '';
  } else {
    return Lang::get($params['str']);
  }
}

?>
Return current item: YaCM Portal System