OSDN Git Service

Subversion由来のタグを削除
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / libs / PLUGIN.php
index f819b97..ab0e0bc 100755 (executable)
@@ -1,24 +1,18 @@
 <?php
        /*
         * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
-        * Copyright (C) 2002-2011 The Nucleus Group
+        * Copyright (C) 2002-2012 The Nucleus Group
         *
         * This program is free software; you can redistribute it and/or
         * modify it under the terms of the GNU General Public License
         * as published by the Free Software Foundation; either version 2
         * of the License, or (at your option) any later version.
         * (see nucleus/documentation/index.html#license for more info)
-        */
-       /**
+        *
         * This is an (abstract) class of which all Nucleus Plugins must inherit
         *
         * for more information on plugins and how to write your own, see the
         * plugins.html file that is included with the Nucleus documenation
-        *
-        * @license http://nucleuscms.org/license.txt GNU General Public License
-        * @copyright Copyright (C) 2002-2011 The Nucleus Group
-        * @version $Id$
-        * $NucleusJP: PLUGIN.php,v 1.12.2.3 2007/12/03 02:22:42 kmorimatsu Exp $
         */
        class NucleusPlugin {
 
                        $args = func_get_args();
                        array_shift($args);
                        array_unshift($args, 'template');
-                       call_user_func_array(array(&$this,'doSkinVar'),$args);
+                       call_user_func_array(array($this,'doSkinVar'), $args);
                }
                function doTemplateCommentsVar(&$item, &$comment) {
                        $args = func_get_args();
                        array_shift($args);
                        array_shift($args);
                        array_unshift($args, 'template');
-                       call_user_func_array(array(&$this,'doSkinVar'),$args);
+                       call_user_func_array(array($this,'doSkinVar'), $args);
                }
                function doAction($type) { return _ERROR_PLUGIN_NOSUCHACTION; }
                function doIf($key,$value) { return false; }
                 */
                function _getOID($context, $name) {
                        $key = $context . '_' . $name;
-                       $info = $this->_aOptionToInfo[$key];
-                       if (is_array($info)) return $info['oid'];
+                       if (array_key_exists($key, $this->_aOptionToInfo)) {
+                               $info = $this->_aOptionToInfo[$key];
+                               if (is_array($info)) return $info['oid'];
+                       }
 
                        // load all OIDs for this plugin from the database
                        $this->_aOptionToInfo = array();
                        }
                        sql_free_result($res);
 
-                       return $this->_aOptionToInfo[$key]['oid'];
+                       if (array_key_exists($key, $this->_aOptionToInfo)) {
+                               return $this->_aOptionToInfo[$key]['oid'];
+                       } else {
+                               return null;
+                       }
                }
+               
                function _getDefVal($context, $name) {
                        $key = $context . '_' . $name;
                        $info = $this->_aOptionToInfo[$key];
                                                $meta = NucleusPlugin::getOptionMeta($o->oextra);
 
                                                // if the option is readonly or hidden it may not be saved
-                                               if (($meta['access'] != 'readonly') && ($meta['access'] != 'hidden')) {
+                                               if (!array_key_exists('access', $meta) || (($meta['access'] != 'readonly') && ($meta['access'] != 'hidden'))) {
 
                                                        $value = undoMagic($value);     // value comes from request
 
                                                        }
 
                                                        // check the validity of numerical options
-                                                       if (($meta['datatype'] == 'numerical') && (!is_numeric($value))) {
+                                                       if (array_key_exists('datatype', $meta) && ($meta['datatype'] == 'numerical') && (!is_numeric($value))) {
                                                                //the option must be numeric, but the it isn't
                                                                //use the default for this option
                                                                $value = $o->odef;
 
                                                        //trigger event PrePluginOptionsUpdate to give the plugin the
                                                        //possibility to change/validate the new value for the option
-                                                       $manager->notify('PrePluginOptionsUpdate',array('context' => $o->ocontext, 'plugid' => $o->opid, 'optionname' => $o->oname, 'contextid' => $contextid, 'value' => &$value));
+                                                       $param = array(
+                                                               'context'               =>  $o->ocontext,
+                                                               'plugid'                =>  $o->opid,
+                                                               'optionname'    =>  $o->oname,
+                                                               'contextid'             =>  $contextid,
+                                                               'value'                 => &$value
+                                                       );
+                                                       $manager->notify('PrePluginOptionsUpdate', $param);
 
                                                        // delete the old value for the option
                                                        sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid='.intval($oid).' AND ocontextid='.intval($contextid));