]> jfr.im git - z_archive/KronOS.git/commitdiff
Finished apps framework. Credits works properly now!
authorJohn Runyon <redacted>
Sun, 28 Oct 2012 23:16:50 +0000 (01:16 +0200)
committerJohn Runyon <redacted>
Sun, 28 Oct 2012 23:16:50 +0000 (01:16 +0200)
application/controllers/control.php
application/libraries/Core.php
application/models/msession.php [moved from application/models/session.php with 93% similarity]
kosapps/common.php
kosapps/core/credits.php [new file with mode: 0644]
public/js/application.js

index 3ee3685113217845a8814d0c81e8a55eb543506c..e6bcba6a2eb035e35ce60218633ee0891d8a2179 100644 (file)
@@ -7,7 +7,7 @@ class Control extends CI_Controller {
        public function __construct() {
                parent::__construct();
                $this->load->model('user');
-               $this->load->model('session');
+               $this->load->model('msession');
        }
 
        public function index() {
@@ -15,21 +15,21 @@ class Control extends CI_Controller {
 
        public function open($aid) {
                if ($this->user->is_logged_in()) {
-                       $instance = $this->session->openApp($aid);
+                       $instance = $this->msession->openApp($aid);
 
                        $repl = array('id' => $instance->iid(), 'name' => $instance->appName(), 'title' => $instance->windowTitle(), 'interior' => $instance->windowContents());
-                       $this->json->reply($this->user->is_logged_in());
+                       $this->json->reply($repl);
                } else {
                        $this->json->error('Not logged in.');
                }
        }
 
        public function act($iid, $action) {
-//             return $this->session->getAppInst($iid)->act($action);
+//             return $this->msession->getAppInst($iid)->act($action);
        }
 
        public function close($iid) {
-               $this->session->closeApp($iid);
+               $this->msession->closeApp($iid);
        }
 }
 ?>
index 09466f508e2aa033dd352e13031fea7a5c2911f8..1c872d34327a719b8b47b0a3ac7cbb0b2fece310 100644 (file)
@@ -25,10 +25,14 @@ class Core {
                elseif ($ulev == 'manager') $chklevel = "1"; // full access -> always true
                else $chklevel = "a.access = 'user'"; // fallback
 
-               $sql = 'SELECT c.catname AS category, a.appname AS appname, a.aid AS appid FROM categories AS c, apps AS a WHERE c.cid = a.parent AND ('.$chklevel.')';
+               $sql = 'SELECT a.parent AS catid, c.catname AS category, a.appname AS appname, a.aid AS appid FROM categories AS c, apps AS a WHERE c.cid = a.parent AND ('.$chklevel.')';
                $q = $this->CI->db->query($sql);
                foreach ($q->result() as $row) {
-                       $menu['Apps'][$row->category][$row->appname] = 'javascript:wos.openApp('.$row->appid.');void(0);';
+                       if ($row->category == 'System') {
+                               $menu['System'][$row->appname] = 'javascript:wos.openApp('.$row->appid.');void(0);';
+                       } else {
+                               $menu['Apps'][$row->category][$row->appname] = 'javascript:wos.openApp('.$row->appid.');void(0);';
+                       }
                }
 
                ksort($menu['Apps']);
@@ -38,12 +42,8 @@ class Core {
                        }
                }
 
-               $menu['System'] = array(
-                       'About KronOS'  => 'javascript:wos.credits();void(0);',
-//                     'About KronOS'  => 'javascript:wos.openCoreApp("credits");void(0);',
-                       'Preferences'   => 'javascript:wos.openCoreApp("account");void(0);',
-                       'Logout'        => 'javascript:wos.logout();void(0);',
-               );
+               ksort($menu['System']);
+               $menu['System']['Logout'] = 'javascript:wos.logout();void(0);';
 
                return $menu;
        }
similarity index 93%
rename from application/models/session.php
rename to application/models/msession.php
index 7e3c161bf663b329fda236a172b0a1ea4908a0c8..bccb549e383587efaf9078aaa5093fa77b9cfb1d 100644 (file)
@@ -1,6 +1,6 @@
 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
-class Session extends CI_Model {
+class Msession extends CI_Model {
        public function __construct() {
                $this->load->model('user');
 
@@ -22,11 +22,11 @@ class Session extends CI_Model {
                if (!is_file($this->config->item('app_prefix').$file)) {
                        return setError('App file does not exist');
                }
-               if (!(@include_once $this->config->item('app_prefix').$file)) {
+               if (!(include_once $this->config->item('app_prefix').$file)) {
                        return setError('Include error');
                }
 
-               return new ($class)($iid)
+               return new $class($iid);
        }
        public function getAppInst($iid) {
                if ($this->apps[$iid]) {
@@ -73,9 +73,9 @@ class Session extends CI_Model {
                        'aid' => $aid,
                );
                $this->db->insert('session_apps', $idata);
+               $iid = $this->db->insert_id();
 
-
-               $app = $this->getApp($aid, $this->db->insert_id(), $row->filename, $row->classname);
+               $app = $this->getApp($aid, $iid, $row->filename, $row->classname);
                if ($app) {
                        $app->opening();
                        $this->apps[$iid] = $app;
index 524b29b6a620f9bcc635f2632167f4678c56b41a..1720098c4a2afdc6a23d291ef826e5cd58311ae8 100644 (file)
@@ -1,14 +1,19 @@
 <?php
 
 abstract class KOS_App {
-       abstract function __construct($iid);
-       abstract public function iid();
+       function __construct($iid) {
+               $this->iid = $iid;
+       }
+       public function iid() {
+               return $this->iid;
+       }
+
        abstract public function appName();
        abstract public function windowTitle();
        abstract public function windowContents();
 
-       abstract public function opening();
-       abstract public function closing();
+       public function opening() { return; }
+       public function closing() { return; }
 
        abstract public function act($action);
 }
diff --git a/kosapps/core/credits.php b/kosapps/core/credits.php
new file mode 100644 (file)
index 0000000..bb62584
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+require_once('kosapps/common.php');
+
+class Credits extends KOS_App {
+       protected $iid;
+
+       public function appName() {
+               return "credits";
+       }
+       public function windowTitle() {
+               return "About KronOS";
+       }
+       public function windowContents() {
+               return <<<EOF
+<h4>Committers</h4>
+<ul>
+       <li>BiohZn</li>
+       <li>DimeCadmium</li>
+       <li>Oscar</li>
+       <li>hyster</li>
+       <li>DarkDevil</li>
+</ul>
+EOF;
+       }
+
+       public function act($action) {
+               return $action;
+       }
+}
+
+?>
index 382c1bb85d28bcb26228381cc18874c5da2ea8af..fc4fd4cc476beb9f7b167422a4b91ce472791761 100644 (file)
                        $.getJSON("/control/open/"+appid, function(resp) {
                                if (resp.success) {
                                        var repl = resp.contents
-                                       var target = 'div#'+repl.name;
+                                       var target = 'div#'+repl.name+repl.id;
 
-                                       if ($(target).length != 0) {
-                                               this.closeApp(target);
-                                       }
+                                       apps[repl.name] = {aid: appid, instance: repl.id, title: repl.title, target: target};
 
-                                       this.apps[repl.name] = {aid: appid, instance: repl.id, title: repl.title, target: target};
-
-                                       $('body').append('<div id="'+repl.name+'" class="modal hide fade"></div>');
+                                       $('body').append('<div id="'+repl.name+repl.id+'" class="app modal hide fade"></div>');
 
                                        $(target).append('<div class="modal-header"></div>');
                                        $(target).append('<div class="modal-body"></div>');
                                        $(target).append('<div class="modal-footer"></div>');
 
-                                       $(target+'>.modal-header').append('<button class="btn appclose" aria-hidden="true" onClick="wos.closeApp(\'#'+repl.name+'\');void(0);">&times;</button>');
+                                       $(target+'>.modal-header').append('<button type="button" class="close" aria-hidden="true" data-dismiss="modal" onClick="wos.closeApp(\'#'+repl.name+'\');void(0);">&times;</button>');
                                        $(target+'>.modal-header').append('<h3 class="appLabel">'+repl.title+'</h3>');
 
                                        $(target+'>.modal-body').append(repl.interior);
+
+                                       $(target).modal({ backdrop: false });
+                                       $(target).modal('show');
                                } else {
                                        throwError(resp.error, 'error', '#desktop');
                                }
 })( jQuery );
 
 $(function () {
+       apps = {}
        wos = $('document.body').pageConstruct();
 
        wos.buildPage();