A few hacks to make the 1.1 demo plugin work
authorDan
Mon, 04 Feb 2008 05:52:12 -0500
changeset 400 7eef739a5b81
parent 399 a3a9e463c62f
child 401 6ae6e387a0e3
A few hacks to make the 1.1 demo plugin work
install/includes/common.php
install/includes/sql_parse.php
plugins/admin/LangManager.php
--- a/install/includes/common.php	Mon Feb 04 05:19:20 2008 -0500
+++ b/install/includes/common.php	Mon Feb 04 05:52:12 2008 -0500
@@ -41,18 +41,21 @@
  
 // Determine Enano root directory
 
-$enano_root = dirname(dirname(dirname(__FILE__)));
-if ( preg_match('#/repo$#', $enano_root) && file_exists("$enano_root/../.enanodev") )
+if ( !defined('ENANO_ROOT') )
 {
-  $enano_root = preg_replace('#/repo$#', '', $enano_root);
+  $enano_root = dirname(dirname(dirname(__FILE__)));
+  if ( preg_match('#/repo$#', $enano_root) && file_exists("$enano_root/../.enanodev") )
+  {
+    $enano_root = preg_replace('#/repo$#', '', $enano_root);
+  }
+  
+  define('ENANO_ROOT', $enano_root);
 }
 
-define('ENANO_ROOT', $enano_root);
-
 chdir(ENANO_ROOT);
 
 // Determine our scriptPath
-if ( isset($_SERVER['REQUEST_URI']) )
+if ( isset($_SERVER['REQUEST_URI']) && !defined('scriptPath') )
 {
   // Use reverse-matching to determine where the REQUEST_URI overlaps the Enano root.
   $requri = $_SERVER['REQUEST_URI'];
@@ -86,23 +89,27 @@
   exit();
 }
 
-function microtime_float()
+if ( !function_exists('microtime_float') )
 {
-  list($usec, $sec) = explode(" ", microtime());
-  return ((float)$usec + (float)$sec);
+  function microtime_float()
+  {
+    list($usec, $sec) = explode(" ", microtime());
+    return ((float)$usec + (float)$sec);
+  }
 }
 
 define('IN_ENANO_INSTALL', 1);
 
-require(ENANO_ROOT . '/install/includes/ui.php');
-require(ENANO_ROOT . '/includes/functions.php');
-require(ENANO_ROOT . '/includes/json.php');
-require(ENANO_ROOT . '/includes/constants.php');
-require(ENANO_ROOT . '/includes/rijndael.php');
+require_once(ENANO_ROOT . '/install/includes/ui.php');
+require_once(ENANO_ROOT . '/includes/functions.php');
+require_once(ENANO_ROOT . '/includes/json.php');
+require_once(ENANO_ROOT . '/includes/constants.php');
+require_once(ENANO_ROOT . '/includes/rijndael.php');
+
 // If we have at least PHP 5, load json2
 if ( version_compare(PHP_VERSION, '5.0.0', '>=') )
 {
-  require(ENANO_ROOT . '/includes/json2.php');
+  require_once(ENANO_ROOT . '/includes/json2.php');
 }
 
 strip_magic_quotes_gpc();
--- a/install/includes/sql_parse.php	Mon Feb 04 05:19:20 2008 -0500
+++ b/install/includes/sql_parse.php	Mon Feb 04 05:52:12 2008 -0500
@@ -54,7 +54,7 @@
   
   public function __construct($sql)
   {
-    if ( strpos("\n", $sql) )
+    if ( strpos($sql, "\n") )
     {
       $this->sql_string = $sql;
     }
--- a/plugins/admin/LangManager.php	Mon Feb 04 05:19:20 2008 -0500
+++ b/plugins/admin/LangManager.php	Mon Feb 04 05:52:12 2008 -0500
@@ -95,12 +95,6 @@
         break;
       case 'modify_language':
         
-        if ( defined('ENANO_DEMO_MODE') )
-        {
-          echo '<div class="error-box">' . $lang->get('acplm_err_lang_install_demo') . '</div>';
-          break;
-        }
-        
         $lang_id =& $parms['lang_id'];
         if ( !is_int($lang_id) )
         {
@@ -108,7 +102,7 @@
           break;
         }
         
-        if ( isset($parms['finish']) && !empty($_POST['lang_name_native']) && !empty($_POST['lang_name_english']) )
+        if ( isset($parms['finish']) && !empty($_POST['lang_name_native']) && !empty($_POST['lang_name_english']) && !defined('ENANO_DEMO_MODE') )
         {
           // We just did validation above, it's safe to save.
           $name_native = $db->escape($_POST['lang_name_native']);
@@ -120,6 +114,10 @@
           
           echo '<div class="info-box">' . $lang->get('acplm_msg_basic_save_success') . '</div>';
         }
+        else if ( isset($parms['finish']) && defined('ENANO_DEMO_MODE') )
+        {
+          echo '<div class="error-box">' . $lang->get('acplm_err_lang_install_demo') . '</div>';
+        }
         
         // Select language data
         $q = $db->sql_query('SELECT lang_name_native, lang_name_default, lang_code FROM ' . table_prefix . "language WHERE lang_id = $lang_id;");
@@ -303,7 +301,6 @@
         else if ( isset($parms['save']) && defined('ENANO_DEMO_MODE') )
         {
           echo '<div class="error-box">' . $lang->get('acplm_err_lang_install_demo') . '</div>';
-          break;
         }
         
         acp_start_form();