Browse Source

Use __construct for Template and Error Handler

Also, static keyword where appropriate
Andy 7 years ago
parent
commit
0b8d32da19

+ 1 - 1
class/error.class.php

@@ -39,7 +39,7 @@ class ErrorHandler {
      * @param  string $sTemplateFile Template containing the error template
      * @param  string $sTemplateFile Template containing the error template
      * @since 1.5.1
      * @since 1.5.1
      */
      */
-    function ErrorHandler(&$oTemplate, $sTemplateFile) {
+    function __construct(&$oTemplate, $sTemplateFile) {
 #        echo 'init error handler...';
 #        echo 'init error handler...';
         $this->TemplateName = $sTemplateFile;
         $this->TemplateName = $sTemplateFile;
         $this->Template =& $oTemplate;
         $this->Template =& $oTemplate;

+ 2 - 2
class/template/PHP_Template.class.php

@@ -47,14 +47,14 @@ class PHP_Template extends Template
       * @param string $template_id the template ID
       * @param string $template_id the template ID
       *
       *
       */
       */
-    function PHP_Template($template_id) {
+    function __construct($template_id) {
 //FIXME: find a way to test that this is ONLY ever called 
 //FIXME: find a way to test that this is ONLY ever called 
 //       from parent's construct_template() method (I doubt it
 //       from parent's construct_template() method (I doubt it
 //       is worth the trouble to parse the current stack trace)
 //       is worth the trouble to parse the current stack trace)
 //        if (???)
 //        if (???)
 //            trigger_error('Please do not use default PHP_Template() constructor.  Instead, use Template::construct_template().', E_USER_ERROR);
 //            trigger_error('Please do not use default PHP_Template() constructor.  Instead, use Template::construct_template().', E_USER_ERROR);
 
 
-        parent::Template($template_id);
+        parent::__construct($template_id);
 
 
     }
     }
 
 

+ 2 - 2
class/template/Smarty_Template.class.php

@@ -44,14 +44,14 @@ class Smarty_Template extends Template
       * @param string $template_id the template ID
       * @param string $template_id the template ID
       *
       *
       */
       */
-    function Smarty_Template($template_id) {
+    function __construct($template_id) {
 //FIXME: find a way to test that this is ONLY ever called 
 //FIXME: find a way to test that this is ONLY ever called 
 //       from parent's construct_template() method (I doubt it
 //       from parent's construct_template() method (I doubt it
 //       is worth the trouble to parse the current stack trace)
 //       is worth the trouble to parse the current stack trace)
 //        if (???)
 //        if (???)
 //            trigger_error('Please do not use default Smarty_Template() constructor.  Instead, use Template::construct_template().', E_USER_ERROR);
 //            trigger_error('Please do not use default Smarty_Template() constructor.  Instead, use Template::construct_template().', E_USER_ERROR);
 
 
-        parent::Template($template_id);
+        parent::__construct($template_id);
 
 
 
 
         // load smarty settings
         // load smarty settings

+ 10 - 10
class/template/Template.class.php

@@ -134,7 +134,7 @@ class Template
       * @param string $template_set_id the template ID
       * @param string $template_set_id the template ID
       *
       *
       */
       */
-    function Template($template_set_id) {
+    function __construct($template_set_id) {
 //FIXME: find a way to test that this is ONLY ever called
 //FIXME: find a way to test that this is ONLY ever called
 //       from the construct_template() method (I doubt it
 //       from the construct_template() method (I doubt it
 //       is worth the trouble to parse the current stack trace)
 //       is worth the trouble to parse the current stack trace)
@@ -159,7 +159,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function construct_template($template_set_id) {
+    static function construct_template($template_set_id) {
 
 
         $template = new Template($template_set_id);
         $template = new Template($template_set_id);
         $template->override_plugins();
         $template->override_plugins();
@@ -234,7 +234,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function get_fallback_template_set($default='default') {
+    static function get_fallback_template_set($default='default') {
 
 
 // FIXME: do we want to place any restrictions on the ID such as
 // FIXME: do we want to place any restrictions on the ID such as
 //        making sure no slashes included?
 //        making sure no slashes included?
@@ -285,7 +285,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function get_default_template_set($default='default') {
+    static function get_default_template_set($default='default') {
 
 
 // FIXME: do we want to place any restrictions on the ID such as
 // FIXME: do we want to place any restrictions on the ID such as
 //        making sure no slashes included?
 //        making sure no slashes included?
@@ -336,7 +336,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function get_rpc_template_set($default='default_rpc') {
+    static function get_rpc_template_set($default='default_rpc') {
 
 
 // FIXME: do we want to place any restrictions on the ID such as
 // FIXME: do we want to place any restrictions on the ID such as
 //        making sure no slashes included?
 //        making sure no slashes included?
@@ -475,7 +475,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function calculate_template_file_directory($template_set_id) {
+    static function calculate_template_file_directory($template_set_id) {
 
 
         return 'templates/' . $template_set_id . '/';
         return 'templates/' . $template_set_id . '/';
 
 
@@ -493,7 +493,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function calculate_template_images_directory($template_set_id) {
+    static function calculate_template_images_directory($template_set_id) {
 
 
         return 'templates/' . $template_set_id . '/images/';
         return 'templates/' . $template_set_id . '/images/';
 
 
@@ -592,7 +592,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function get_template_config($template_set_id, $setting,
+    static function get_template_config($template_set_id, $setting,
                                  $default=NULL, $live_config=FALSE) {
                                  $default=NULL, $live_config=FALSE) {
 
 
         sqGetGlobalVar('template_configuration_settings',
         sqGetGlobalVar('template_configuration_settings',
@@ -714,7 +714,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function cache_template_file_hierarchy($template_set_id,
+    static function cache_template_file_hierarchy($template_set_id,
                                            $regenerate_cache=FALSE,
                                            $regenerate_cache=FALSE,
                                            $additional_files=array()) {
                                            $additional_files=array()) {
 
 
@@ -793,7 +793,7 @@ class Template
       * @static
       * @static
       *
       *
       */
       */
-    function catalog_template_files($template_set_id, $file_list=array(), $directory='') {
+    static function catalog_template_files($template_set_id, $file_list=array(), $directory='') {
 
 
         $template_base_dir = SM_PATH
         $template_base_dir = SM_PATH
                            . Template::calculate_template_file_directory($template_set_id);
                            . Template::calculate_template_file_directory($template_set_id);