OSDN Git Service

sync with Rev1121,1132,1168
authorkimitake <kimitake@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Wed, 5 Sep 2007 07:40:59 +0000 (07:40 +0000)
committerkimitake <kimitake@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Wed, 5 Sep 2007 07:40:59 +0000 (07:40 +0000)
function doItemVar() added to the plugin class
JustPosted event
one lost bracket added

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/branches/branch-3-3@318 1ca29b6e-896d-4ea0-84a5-967f57386b96

utf8/nucleus/libs/PLUGIN.php

index 0550115..2c16918 100755 (executable)
@@ -17,8 +17,8 @@
         *
         * @license http://nucleuscms.org/license.txt GNU General Public License
         * @copyright Copyright (C) 2002-2007 The Nucleus Group
-        * @version $Id: PLUGIN.php,v 1.12 2007-04-20 08:43:25 kimitake Exp $
-        * $NucleusJP: PLUGIN.php,v 1.11 2007/04/06 19:36:29 kmorimatsu Exp $
+        * @version $Id: PLUGIN.php,v 1.12.2.1 2007-09-05 07:40:59 kimitake Exp $
+        * $NucleusJP: PLUGIN.php,v 1.12 2007/04/20 08:43:25 kimitake Exp $
         */
        class NucleusPlugin {
 
                /**
                  * Retrieves the current value for an option
                  */
-               function getOption($name){
-                       return $this->_getOption('global', 0, $name);
+               function getOption($name)
+               {
+                       // only request the options the very first time. On subsequent requests
+                       // the static collection is used to save SQL queries.
+                       if ($this->plugin_options == 0)
+                       {
+                               $this->plugin_options = array();
+                               $query = sql_query(
+                                        'SELECT d.oname as name, o.ovalue as value '.
+                                        'FROM '.
+                                        sql_table('plugin_option').' o, '.
+                                        sql_table('plugin_option_desc').' d '.
+                                        'WHERE d.opid='. intval($this->getID()).' AND d.oid=o.oid'
+                               );
+                               while ($row = mysql_fetch_object($query))
+                                       $this->plugin_options[strtolower($row->name)] = $row->value;
+                 }
+                 if (isset($this->plugin_options[strtolower($name)]))
+                               return $this->plugin_options[strtolower($name)];
+                 else
+                               return $this->_getOption('global', 0, $name);
                }
+
                function getBlogOption($blogid, $name) {
                        return $this->_getOption('blog', $blogid, $name);
                }
 
                        // retrieve the data and return
                        $q = 'SELECT otype, oextra FROM '.sql_table('plugin_option_desc').' WHERE oid = '.$oid;
-                       $query = mysql_query($q);
+                       $query = sql_query($q);
 
                        $o = mysql_fetch_array($query);
 
                                $orderby = 'ovalue';
                        }
                        $q = 'SELECT ovalue value, ocontextid id FROM '.sql_table('plugin_option').' WHERE oid = '.$oid.' ORDER BY '.$orderby.' '.$sort.' LIMIT 0,'.intval($amount);
-                       $query = mysql_query($q);
+                       $query = sql_query($q);
 
                        // create the array
                        $i = 0;
 
                        // update plugin_option
                        sql_query('DELETE FROM ' . sql_table('plugin_option') . ' WHERE oid='.intval($oid) . ' and ocontextid='. intval($contextid));
-                       @mysql_query('INSERT INTO ' . sql_table('plugin_option') . ' (ovalue, oid, ocontextid) VALUES (\''.addslashes($value).'\', '. intval($oid) . ', ' . intval($contextid) . ')');
+                       sql_query('INSERT INTO ' . sql_table('plugin_option') . ' (ovalue, oid, ocontextid) VALUES (\''.addslashes($value).'\', '. intval($oid) . ', ' . intval($contextid) . ')');
 
                        // update cache
                        $this->_aOptionValues[$oid . '_' . $contextid] = $value;
 
                                                        // delete the old value for the option
                                                        sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid='.intval($oid).' AND ocontextid='.intval($contextid));
-                                                       @mysql_query('INSERT INTO '.sql_table('plugin_option')." (oid, ocontextid, ovalue) VALUES (".intval($oid).",".intval($contextid).",'" . addslashes($value) . "')");
+                                                       sql_query('INSERT INTO '.sql_table('plugin_option')." (oid, ocontextid, ovalue) VALUES (".intval($oid).",".intval($contextid).",'" . addslashes($value) . "')");
                                                }
                                        }
                                }
-                       }
-                       // clear option value cache if the plugin object is already loaded
-                       if (is_object($o)) {
-                               $plugin=& $manager->pidLoaded($o->opid);
-                               if ($plugin) $plugin->clearOptionValueCache();
+                               // clear option value cache if the plugin object is already loaded
+                               if (is_object($o)) {
+                                       $plugin=& $manager->pidLoaded($o->opid);
+                                       if ($plugin) $plugin->clearOptionValueCache();
+                               }
                        }
                }
-
        }
 ?>