]> git.andy128k.dev Git - ipf.git/commitdiff
cleanup
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 16 Mar 2019 21:41:35 +0000 (22:41 +0100)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 16 Mar 2019 21:41:35 +0000 (22:41 +0100)
ipf.php
ipf/admin/app.php
ipf/cli.php
ipf/http/response.php

diff --git a/ipf.php b/ipf.php
index 9fb32bdb36b90e662e4dc8d68e721341dd20db6d..68e512549412ac6a3702a2e3c858e81cd5c1e563 100644 (file)
--- 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();
index 1cc936a114631e59224ad1fdc047d79dd87a018c..ffb64aac0697530b8f8409da87761fac8232e956 100644 (file)
@@ -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),
         );
     }
index ad078be3dc77b3d540a58320171828794a64b5b0..f935246497263ad0589109fd067a5de66c74c822 100644 (file)
@@ -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();
 
index 3ae357664ee13a8238541f3c9355d5dc74cf1fc9..9c51a4cdc25dd7b0607b640da91b50f1b48cd3e2 100644 (file)
@@ -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;
     }
 }
-