[pLog-svn] r537 - in plog/trunk/class: action/admin dao locale plugin

oscar at devel.plogworld.net oscar at devel.plogworld.net
Sun Dec 19 00:44:10 GMT 2004


Author: oscar
Date: 2004-12-19 00:44:10 +0000 (Sun, 19 Dec 2004)
New Revision: 537

Modified:
   plog/trunk/class/action/admin/adminaction.class.php
   plog/trunk/class/dao/bloginfo.class.php
   plog/trunk/class/locale/locales.class.php
   plog/trunk/class/plugin/pluginmanager.class.php
Log:
Fixed a very strange bug that had something to do with plugins and the "edit posts" page (somehow the Locale object was being "transformed" into an Adodb_MySQL object... just like that!) It seemed like it had something to do with objects and references, and modifying the Locales::getLocale() object to return a reference to a Locale object instead of a copy of the desired locale seemed to do the trick...
Anyway, this is fixed now :)

Modified: plog/trunk/class/action/admin/adminaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaction.class.php	2004-12-19 00:21:38 UTC (rev 536)
+++ plog/trunk/class/action/admin/adminaction.class.php	2004-12-19 00:44:10 UTC (rev 537)
@@ -67,7 +67,7 @@
 			$this->_pm->setUserInfo( $this->_userInfo );
 
 			// fetch the site locale
-            $this->_locale = $this->getLocale();
+            $this->_locale =& $this->getLocale();
         }
 
         /**
@@ -94,12 +94,13 @@
         /**
          * sets the default locale, in case we want to send localized messages to the user.
          */
-        function getLocale()
+        function &getLocale()
         {
         	// don't like this so much...
         	if( $this->_blogInfo != "" ) {
         		$this->_blogSettings = $this->_blogInfo->getSettings();
-            	$locale =& Locales::getLocale( $this->_blogSettings->getValue("locale"));
+            	//$locale =& Locales::getLocale( $this->_blogSettings->getValue("locale"));
+				$locale =& $this->_blogInfo->getLocale();
             }
             else {
             	$locale =& Locales::getLocale( $this->_config->getValue("default_locale"));
@@ -120,7 +121,7 @@
 			parent::setCommonData( $copyFormValues );
 			
         	$this->_view->setValue( "user", $this->_userInfo );
-		$this->_view->setUserInfo( $this->_userInfo );
+			$this->_view->setUserInfo( $this->_userInfo );
             $this->_view->setValue( "blog", $this->_blogInfo );
             $this->_view->setValue( "blogsettings", $this->_blogInfo->getSettings());
             $this->_view->setValue( "op", $this->_actionInfo->_actionParamValue );

Modified: plog/trunk/class/dao/bloginfo.class.php
===================================================================
--- plog/trunk/class/dao/bloginfo.class.php	2004-12-19 00:21:38 UTC (rev 536)
+++ plog/trunk/class/dao/bloginfo.class.php	2004-12-19 00:44:10 UTC (rev 537)
@@ -383,11 +383,11 @@
 		 *
 		 * @param a Locale object
 		 */
-		function getLocale()
+		function &getLocale()
 		{
 			if( $this->_locale == null ) {
 				include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );	
-				$this->_locale = Locales::getLocale( $this->_settings->getValue( "locale" ), "en_UK" );
+				$this->_locale =& Locales::getLocale( $this->_settings->getValue( "locale" ), "en_UK" );
 			}
 			
 			return $this->_locale;

Modified: plog/trunk/class/locale/locales.class.php
===================================================================
--- plog/trunk/class/locale/locales.class.php	2004-12-19 00:21:38 UTC (rev 536)
+++ plog/trunk/class/locale/locales.class.php	2004-12-19 00:44:10 UTC (rev 537)
@@ -46,7 +46,7 @@
          * @return Returns a Locale object corresponding to the requested locale.
          * @see Locale
          */
-        function getLocale( $localeCode = null )
+        function &getLocale( $localeCode = null )
         {
         	// array to keep track of the locales that we have already loaded, so that
             // we don't have to fetch them from disk
@@ -83,7 +83,7 @@
 
                 $loadedLocales[$localeCode] = $locale;
             }
-
+			
             return $locale;
         }
 
@@ -148,17 +148,17 @@
             return in_array( $localeCode, $availableLocales );
         }
 
-	/**
-	 * returns whether a file has the corect name format
-	 *
-	 * @param fileName
-	 * @return true if format is correct or false otherwise
-	 */
-	function isValidLocaleFileName( $fileName )
-	{
-		$regexp = "/locale_([a-z]{2}_[A-Z]{2})\.php/";
-		return( preg_match( $regexp, $fileName ));
-	}
+		/**
+		* returns whether a file has the corect name format
+		 *
+		 * @param fileName
+		 * @return true if format is correct or false otherwise
+		 */
+		function isValidLocaleFileName( $fileName )
+		{
+			$regexp = "/locale_([a-z]{2}_[A-Z]{2})\.php/";
+			return( preg_match( $regexp, $fileName ));
+		}
 
         /**
          * Returns an array with all the locales available in the system.
@@ -217,10 +217,10 @@
 
             $fileName = $this->getLocaleFilename( $localeCode );
 
-		if( File::exists( $fileName )) {
+			if( File::exists( $fileName )) {
 	            if( !unlink( $fileName ))
         	    	return false;
-		}
+			}
 
             $availableLocales = $config->getValue( "locales" );
 

Modified: plog/trunk/class/plugin/pluginmanager.class.php
===================================================================
--- plog/trunk/class/plugin/pluginmanager.class.php	2004-12-19 00:21:38 UTC (rev 536)
+++ plog/trunk/class/plugin/pluginmanager.class.php	2004-12-19 00:44:10 UTC (rev 537)
@@ -33,7 +33,7 @@
         var $_filePattern;
         var $_blogInfo;
         var $_userInfo;
-	var $_pluginInstances;
+		var $_pluginInstances;
 
         /**
          * global variable to save the list of plugins registered so far
@@ -53,6 +53,8 @@
          */
         function PluginManager( $pluginDir = PLUGIN_MANAGER_DEFAULT_PLUGIN_FOLDER, $filePattern = PLUGIN_MANAGER_DEFAULT_PLUGIN_FILE_PATTERN )
         {
+			$this->Object();
+		
             $config =& Config::getConfig();
 			
             // initialize the arrays used to keep track of plugins and events
@@ -224,7 +226,8 @@
 
         function _loadPluginLocale( $pluginId, $locale )
         {
-            return Locales::getPluginLocale( $pluginId, $locale );
+			$this->log->debug("loading locale $locale for plugin $pluginId");
+            return( Locales::getPluginLocale( $pluginId, $locale ));
         }
 
         /**




More information about the pLog-svn mailing list