$container = new Container();
+ $container['ipf_version'] = '0.7';
$container['settings'] = IPF::$settings;
$container->register(new BootstrapProvider());
}
}
- public static function version()
- {
- return '0.5 beta';
- }
-
/** @var IPF_Settings */
public static $settings = null;
'upload_url' => '/media/upload/',
'static_url' => '/static/',
'session_cookie_id' => 'sessionid',
- 'dir_permission' => 0777,
'file_permission' => 0666,
'time_zone' => 'America/Toronto',
'tmp' => '/tmp',
return self::$settings->get($name, $default);
}
- private static function include_existing($filename)
- {
- if (is_file($filename))
- include_once $filename;
- }
-
- public static function callFunction($function, array $args)
- {
- if (is_array($function)) {
- // object/class method
- $callable = $function;
- } elseif (preg_match('/^([\\\\\w]+)::(\w+)$/i', $function, $m)) {
- // static method
- $callable = array($m[1], $m[2]);
- } else {
- // plain function
- if (!function_exists($function)) {
- $elts = explode('_', $function);
- array_pop($elts);
- $file = '/' . strtolower(implode(DIRECTORY_SEPARATOR, $elts)).'.php';
-
- self::include_existing(self::$settings->get('project_root') . '/project' . $file);
-
- if (!function_exists($function))
- throw new IPF_Exception('Impossible to load the function: '.$function.' in '.$file);
- }
- $callable = $function;
- }
- return call_user_func_array($callable, $args);
- }
-
public static function getUploadPath()
{
return IPF::get('document_root') . IPF::getUploadUrl();
public function templateContext($request)
{
return array(
- 'IPF_VER' => IPF::version(),
- 'admin_title' => IPF::get('admin_title'),
+ 'IPF_VER' => $this->container['ipf_version'],
+ 'admin_title' => $this->container['settings']->get('admin_title'),
'app_list' => $this->appList($request),
);
}
$container['project_commands'] = function ($c) {
$commands = array();
- foreach (\IPF::get('commands', array()) as $cmd) {
+ foreach ($c['settings']->get('commands', array()) as $cmd) {
if (is_string($cmd))
$cmd = new $cmd;
$commands[] = $cmd;
};
$container['cli'] = function ($c) {
- return new IPF_Cli($c['cli_commands']);
+ return new IPF_Cli($c['ipf_version'], $c['cli_commands']);
};
}
}
class IPF_Cli
{
+ /** @var string */
+ private $version;
/** @var array */
private $commands;
- public function __construct(array $commands)
+ public function __construct($version, array $commands)
{
+ $this->version = $version;
$this->commands = $commands;
}
public function run()
{
- print "IPF command line tool. Version: " . \IPF::version() . "\n";
+ print "IPF command line tool. Version: " . $this->version . "\n";
$args = $this->getArgs();
header($header.': '.$ch);
}
foreach ($this->cookies as $cookie => $data) {
- setcookie($cookie, $data, time() + 31536000,
- IPF::get('cookie_path', '/'),
- IPF::get('cookie_domain', null),
- IPF::get('cookie_secure', false),
- IPF::get('cookie_httponly', true));
+ setcookie($cookie, $data, time() + 31536000, '/', null, false, true);
}
}
echo $this->content;
}
}
-