OSDN Git Service

CHANGE: NucleusPluginクラスの整理
[nucleus-jp/nucleus-next.git] / nucleus / libs / PLUGIN.php
index e21a013..ec81a95 100644 (file)
@@ -262,7 +262,7 @@ abstract class NucleusPlugin
                        $this->plugin_options = array();
                        
                        $query =  "SELECT d.oname as name, o.ovalue as value FROM %s o, %s d WHERE d.opid=%d AND d.oid=o.oid;";
-                       $query = sprintf($query, sql_table('plugin_option'), sql_table('plugin_option_desc'), (integer) $this->getID());
+                       $query = sprintf($query, sql_table('plugin_option'), sql_table('plugin_option_desc'), (integer) $this->plugid);
                        $result = sql_query($query);
                        while ( $row = sql_fetch_object($result) )
                        {
@@ -348,13 +348,30 @@ abstract class NucleusPlugin
        }
        
        /**
-        * Returns the plugin ID
-        *
-        * public
+        * NucleusPlugin::getID()
+        * get id for this plugin
+        * 
+        * @access      public
+        * @param       void
+        * @return      integer this plugid id
         */
        final public function getID()
        {
-               return $this->plugid;
+               return (integer) $this->plugid;
+       }
+       
+       /**
+        * NucleusPlugin::setID()
+        * set favorite id for this plugin
+        * 
+        * @access      public
+        * @param       integer $plugid favorite id for plugin
+        * @return      void
+        */
+       final public function setID($plugid)
+       {
+               $this->plugid = (integer) $plugid;
+               return;
        }
        
        /**
@@ -408,12 +425,10 @@ abstract class NucleusPlugin
        }
        
        // internal functions of the class starts here
-       
        protected $option_values;       // oid_contextid => value
-       protected $option_info; // context_name => array('oid' => ..., 'default' => ...)
+       protected $option_info;         // context_name => array('oid' => ..., 'default' => ...)
        protected $plugin_options;      // see getOption()
-       /* TODO: This should be protected member */
-       public $plugid;                 // plugin id
+       protected $plugid;                      // plugin id
        
        /**
         * Class constructor: Initializes some internal data
@@ -834,7 +849,7 @@ abstract class NucleusPlugin
         */
        public function subscribtionListIsUptodate()
        {
-               $res = sql_query('SELECT event FROM '.sql_table('plugin_event').' WHERE pid = '.$this->getID());
+               $res = sql_query('SELECT event FROM '.sql_table('plugin_event').' WHERE pid = '.$this->plugid);
                $ev = array();
                while( $a = sql_fetch_array($res) )
                {
@@ -854,26 +869,26 @@ abstract class NucleusPlugin
        }
        
        /**
-        * NucleusPlugin::_applyPluginOptions()
+        * NucleusPlugin::apply_plugin_options()
         * Update its entry in database table
         * 
         * @static
-        * @param       $aOptions: array ( 'oid' => array( 'contextid' => 'value'))
+        * @param       $options: array ( 'oid' => array( 'contextid' => 'value'))
         *                       (taken from request using requestVar())
         * @param       $newContextid: integer (accepts a contextid when it is for a new
         *                       contextid there was no id available at the moment of writing the
         *                        formcontrols into the page (by ex: itemOptions for new item)
         * @return void
         */
-       static public function _applyPluginOptions(&$aOptions, $newContextid = 0)
+       static public function apply_plugin_options(&$options, $newContextid = 0)
        {
                global $manager;
-               if ( !is_array($aOptions) )
+               if ( !is_array($options) )
                {
                        return;
                }
                
-               foreach ( $aOptions as $oid => $values )
+               foreach ( $options as $oid => $values )
                {
                        // get option type info
                        $query = "SELECT opid, oname, ocontext, otype, oextra, odef FROM %s WHERE oid=%d;";