* On-Demand loading of Lepton Modules * * Note: A method for modules to specify that they are required to load is * neccessary. Also a method for the module to report what classes it supports. * This could be something like; * * module::volatile(); // Mark as required * module::info('My Module'); // Describe module * module::provides('feature'); * module::requires('feature'); * */ class OnDemandModuleLoader implements IModuleLoader { private $database; public function __construct() { $this->database = new FsPrefs(base::appPath() . '/.modcache'); } // autoload will be directed to this method public function queryClass($classname) { } // using() will be directed to this method public function loadModule($modulename) { } } // spl_autoload_register(array('ModuleManager','queryClass'),true,true); modulemanager::setManager(new OnDemandModuleLoader());
/** * Calculates the time past since an event occured, f.ex. "2 days ago". * Taken from the php.net website. * * @author andypsv <*****@*****.**> */ function ago($time = null) { if ($time) { $d = new Timestamp($time); return $d->ago(); } $tm = $this->_time; $cur_tm = time(); $dif = $cur_tm - $tm; $pds = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade'); $pdsp = array('seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years', 'decades'); if (modulemanager::has('i18n')) { foreach ($pds as &$pd) { $pd = intl::str($pd); } foreach ($pdsp as &$pd) { $pd = intl::str($pd); } } $lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) { } if ($v < 0) { $v = 0; } $_tm = $cur_tm - $dif % $lngh[$v]; $no = floor($no); if ($no != 1) { $pds[$v] = $pdsp[$v]; } $x = sprintf("%d %s ", $no, $pds[$v]); // if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); return $x; }