From 679e44dc5178e57d95f8d563c41a6f579c6ec9aa Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 16 Mar 2019 22:41:35 +0100 Subject: [PATCH] cleanup --- ipf.php | 38 +------------------------------------- ipf/admin/app.php | 4 ++-- ipf/cli.php | 11 +++++++---- ipf/http/response.php | 7 +------ 4 files changed, 11 insertions(+), 49 deletions(-) diff --git a/ipf.php b/ipf.php index 9fb32bd..68e5125 100644 --- a/ipf.php +++ b/ipf.php @@ -11,6 +11,7 @@ final class IPF $container = new Container(); + $container['ipf_version'] = '0.7'; $container['settings'] = IPF::$settings; $container->register(new BootstrapProvider()); @@ -29,11 +30,6 @@ final class IPF } } - public static function version() - { - return '0.5 beta'; - } - /** @var IPF_Settings */ public static $settings = null; @@ -73,7 +69,6 @@ final class IPF 'upload_url' => '/media/upload/', 'static_url' => '/static/', 'session_cookie_id' => 'sessionid', - 'dir_permission' => 0777, 'file_permission' => 0666, 'time_zone' => 'America/Toronto', 'tmp' => '/tmp', @@ -97,37 +92,6 @@ final class IPF 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(); diff --git a/ipf/admin/app.php b/ipf/admin/app.php index 1cc936a..ffb64aa 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -81,8 +81,8 @@ class IPF_Admin_App extends IPF_Application 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), ); } diff --git a/ipf/cli.php b/ipf/cli.php index ad078be..f935246 100644 --- a/ipf/cli.php +++ b/ipf/cli.php @@ -35,7 +35,7 @@ class CliProvider implements ServiceProviderInterface $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; @@ -64,18 +64,21 @@ class CliProvider implements ServiceProviderInterface }; $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; } @@ -117,7 +120,7 @@ class IPF_Cli public function run() { - print "IPF command line tool. Version: " . \IPF::version() . "\n"; + print "IPF command line tool. Version: " . $this->version . "\n"; $args = $this->getArgs(); diff --git a/ipf/http/response.php b/ipf/http/response.php index 3ae3576..9c51a4c 100644 --- a/ipf/http/response.php +++ b/ipf/http/response.php @@ -83,11 +83,7 @@ class IPF_HTTP_Response 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); } } @@ -96,4 +92,3 @@ class IPF_HTTP_Response echo $this->content; } } - -- 2.49.0