22 * - create admin, plugin, view object.
24 * Extended classes don't call this automatically
25 * if those have Constructor
27 * @param string $plugin_name : Name of Plugin
30 function PlugManagement($plugin_name)
32 $this->p_admin = new PluginAdmin($plugin_name);
33 $this->plugin =& $this->p_admin->plugin;
34 $this->view = new PlugAdminView($this);
38 * returns reference of plugin object
47 * returns reference of view object
56 * returns reference of PluginAdmin object
59 function &getPluginAdmin()
61 return $this->p_admin;
65 * Function for not making action files
67 function doAction($action)
69 if (method_exists($this, 'action_'.$action)) {
70 call_user_func(array(&$this, 'action_'.$action));
72 $this->action_overview();
76 /***************************************************
77 init, dir/file/class settings (abstract)
78 ****************************************************/
81 // directory of action files (abs path)
82 function getActionDir()
84 return $this->plugin->getDirectory() . 'actions/';
87 // directory of template files (abs path)
88 function getTemplateDir()
90 return $this->plugin->getDirectory() . 'templates/';
93 // prefix of action file name
94 // default action file name is (action).php
95 function getActionFilePrefix() { return '';}
97 // prefix of action class name
98 function getActionClassPrefix()
100 return str_replace('np_', '', strtolower(get_class($this->plugin))) . '_';
104 function getDefaultAction() { return 'overview';}
107 /**********************************************
108 auth, error and exception
109 **********************************************/
111 * display error page with "disallowed" message.
115 $this->error(_ERROR_DISALLOWED);
119 * display error page.
120 * @pamam string $msg : message to show
124 $this->p_admin->start();
126 $dir=$this->plugin->getAdminURL();
129 <?php echo htmlspecialchars($msg);
131 echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
133 $this->p_admin->end();
139 * authenticate the member
140 * @pamam string $level : permitted authority level
141 * @param number $extra : blogid (This is necessary excluding "Admin". )
143 function memberAuth($level = 'Admin', $extra = '')
147 switch (strtolower($level)) {
149 $member->isAdmin() or $this->disallow();
153 $this->error('Missing 2nd argument ('.__LINE__.')');
155 $member->isBlogAdmin($extra) or $this->disallow();
159 $this->error('Missing 2nd argument ('.__LINE__.')');
161 $member->isTeamMember($extra) or $this->disallow();
167 /**********************************************
169 **********************************************/
171 * return popup help link
172 * @pamam string $url : url of popup help file
173 * @param string $anchor
175 function createPopupHelpLink($url, $anchor)
177 $link = '<a href="'.$url.'#'. $anchor . '" onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);">' . '<img src="documentation/icon-help.gif" width="15" height="15" alt="'._HELP_TT.'" /></a>';
184 class PlugAdminView extends PlugView
188 function PlugAdminView(&$p_manager)
190 $this->p_manager =& $p_manager;
193 function display($tpl)
195 $p_admin =& $this->p_manager->getPluginAdmin();
199 $file = $this->p_manager->getTemplateDir() . $tpl;
200 parent::display($file);