]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Minor refactoring
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Fri, 21 Nov 2008 11:22:40 +0000 (11:22 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Fri, 21 Nov 2008 11:22:40 +0000 (11:22 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@170 b3834d28-1941-0410-a4f8-b48e95affb8f

index.php
services/servicefactory.php
services/templateservice.php

index 0a2b48391946c182f3edc278b3d1f5ef40882e49..d98006f4a1fa9ee141938a07f73da467eaa9fd4f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -68,13 +68,14 @@ $dtend = date('Y-m-d H:i:s', strtotime('tomorrow'));
 $tplVars['page'] = $page;
 $tplVars['start'] = $start;
 $tplVars['popCount'] = 30;
-//$tplVars['sidebar_blocks'] = array('search', 'users', 'linked', 'recent');
 $tplVars['sidebar_blocks'] = $GLOBALS["index_sidebar_blocks"];
 $tplVars['range'] = 'all';
 $tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
 $tplVars['subtitle'] = T_('All Bookmarks');
 $tplVars['bookmarkCount'] = $start + 1;
+
 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, 0, $dtend);
+
 $tplVars['total'] = $bookmarks['total'];
 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
 $tplVars['cat_url'] = createURL('bookmarks', '%1$s/%2$s');
index 7ff7f229f26a90e453c70599737bd524c93c7ff2..f4d6af7727b084ae3eec7551f710f564c6c10e2c 100644 (file)
@@ -1,35 +1,35 @@
 <?php
-/* Build services */
+/* Connect to the database and build services */
 
 class ServiceFactory {
-    function ServiceFactory(&$db, $serviceoverrules = array()) {    
-    }
-  
-    function &getServiceInstance($name, $servicedir = NULL) {
-        global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
-        static $instances = array();
-        static $db;
-        if (!isset($db)) {
-            require_once(dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php');
-            $db = new sql_db();
-            $db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist);
-            if(!$db->db_connect_id) {
-                message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
-            }
-        }
-        if (!isset($instances[$name])) {
-            if (isset($serviceoverrules[$name])) {
-                $name = $serviceoverrules[$name];
-            }
-            if (!class_exists($name)) {
-                if (!isset($servicedir)) {
-                    $servicedir = dirname(__FILE__) .'/';
-                }
-                require_once($servicedir . strtolower($name) . '.php');
-            }
-            $instances[$name] = call_user_func(array($name, 'getInstance'), $db);
-        }        
-        return $instances[$name];
-    }
+       function ServiceFactory(&$db, $serviceoverrules = array()) {
+       }
+
+       function &getServiceInstance($name, $servicedir = NULL) {
+               global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
+               static $instances = array();
+               static $db;
+               if (!isset($db)) {
+                       require_once(dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php');
+                       $db = new sql_db();
+                       $db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist);
+                       if(!$db->db_connect_id) {
+                               message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
+                       }
+               }
+               if (!isset($instances[$name])) {
+                       if (isset($serviceoverrules[$name])) {
+                               $name = $serviceoverrules[$name];
+                       }
+                       if (!class_exists($name)) {
+                               if (!isset($servicedir)) {
+                                       $servicedir = dirname(__FILE__) .'/';
+                               }
+                               require_once($servicedir . strtolower($name) . '.php');
+                       }
+                       $instances[$name] = call_user_func(array($name, 'getInstance'), $db);
+               }
+               return $instances[$name];
+       }
 }
 ?>
index 191ab8df67a0592204ad77dad903392c0d7966ff..05e494c646de3aaf3b39aa6885705f2868ccc250 100644 (file)
@@ -1,46 +1,46 @@
 <?php
 class TemplateService {
-    var $basedir;
-  
-    function &getInstance() {
-        static $instance;
-        if (!isset($instance))
-            $instance =& new TemplateService();
-        return $instance;
-    }
-  
-    function TemplateService() {
-        $this->basedir = $GLOBALS['TEMPLATES_DIR'];    
-    }
-  
-    function loadTemplate($template, $vars = NULL) {
-        if (substr($template, -4) != '.php')
-            $template .= '.php';
-        $tpl =& new Template($this->basedir .'/'. $template, $vars, $this);
-        $tpl->parse();
-        return $tpl;
-    }
+       var $basedir;
+
+       function &getInstance() {
+               static $instance;
+               if (!isset($instance))
+               $instance =& new TemplateService();
+               return $instance;
+       }
+
+       function TemplateService() {
+               $this->basedir = $GLOBALS['TEMPLATES_DIR'];
+       }
+
+       function loadTemplate($template, $vars = NULL) {
+               if (substr($template, -4) != '.php')
+               $template .= '.php';
+               $tpl =& new Template($this->basedir .'/'. $template, $vars, $this);
+               $tpl->parse();
+               return $tpl;
+       }
 }
 
 class Template {
-    var $vars = array();
-    var $file = '';
-    var $templateservice;
-  
-    function Template($file, $vars = NULL, &$templateservice) {
-        $this->vars = $vars;
-        $this->file = $file;
-        $this->templateservice = $templateservice; 
-    }
-  
-    function parse() {
-        if (isset($this->vars))
-            extract($this->vars);
-        include($this->file);
-    }
-  
-    function includeTemplate($name) {
-        return $this->templateservice->loadTemplate($name, $this->vars);
-    }
+       var $vars = array();
+       var $file = '';
+       var $templateservice;
+
+       function Template($file, $vars = NULL, &$templateservice) {
+               $this->vars = $vars;
+               $this->file = $file;
+               $this->templateservice = $templateservice;
+       }
+
+       function parse() {
+               if (isset($this->vars))
+               extract($this->vars);
+               include($this->file);
+       }
+
+       function includeTemplate($name) {
+               return $this->templateservice->loadTemplate($name, $this->vars);
+       }
 }
 ?>
\ No newline at end of file