📄 modplugin.php
字号:
*/ function modGetDocImages() // Additional { return $this->modGetDocRoot() . 'plugins/' . $this->getPluginName() . '/images/'; } /** * returns the web directory includes reside in. * * @return directory osdate resides in. (ex. /osdate/) * * @access public */ function modGetDocIncludes() // Additional { return $this->modGetDocRoot() . 'plugins/' . $this->getPluginName() . '/includes/'; } /** * send an email * @param array $param an associative array with the following keys: <br><ul> * <li>message - can be a templated message using user parameters in # (i.e. #firstname#, #country#))</li> * <li>rcvuserid - userid of member to receive message.</li> * <li>snduserid - userid of member to seend message (optional).</li> * <li>subject - message subject.</li></ul> * * @return bool True on success. False on failure. * @access public */ function modSendMail( $param ) { $result = false; if ( isset($param['rcvuserid']) && isset($param['subject']) && isset($param['message']) ) { $udata = $this->modGetUser( array('userid' => $param['rcvuserid']) ); if ( ! $udata ) { $this->_setErrorMessage("Can't find reciever account for rcvuserid: " . $param['rcvuserid']); $result = false; } If ( isset($param['snduserid']) && ! $this->getErrorMessage() ) { $sdata = $this->modGetUser( array('userid' => $param['snduserid']) ); if ( ! $sdata ) { $this->_setErrorMessage("Can't find sender account for snduserid: " . $param['snduserid']); $result = false; } else { $udata['sendername'] = $sdata['username']; } } If ( ! $this->getErrorMessage() ) { $Subject = $param['subject']; $From = $this->modGetSetting(array('setting'=>'admin_email')); $To = $udata['email']; $udata['link'] = $this->modSiteUrl(); $udata['sitename'] = $this->modGetSetting('site_name'); $udata['adminname'] = $this->modGetSetting('admin_name'); $message = $param['message']; $message = $this->_fillTemplate($message, $udata); $result = mailSender($From, $To, $To, $Subject, $message); } } else { $result = false; $this->_setErrorMessage("rcvuserid, snduserid, subject and message are required"); } return $result; } /** * Returns all error messages * * @return array - associative array of messages * @access public */ function getErrorMessage() { return $this->_errorMessage; } /** * Clears all error messages * * @return void * @access public */ function clrErrorMessage() { $this->_errorMessage = array(); } /** * Returns the current template skin name * * @return string * @access public */ function modGetSkinName() { // Additional return $GLOBALS['config']['skin_name']; } /** * Returns the language phrase or the entire language array from class's language definitions. * * @param string|void $key1 If blank, returns the whole array. If a string, returns that phrase * @param string|void $key2 If a string, returns the second dimension of phrase * @return array|string * @access public */ function modGetLang($key1 = false, $key2 = false) { // Additional if ( ! $key1 ) { $lang = $this->lang; } elseif ( $key2 ) { $lang = $this->lang[$key1][$key2]; if ($lang == '') { $lang = get_lang($key1,$key2); }// $lang = get_lang($key1, $key2); } else { $lang = $this->lang[$key1]; if ($lang == '') { $lang = get_lang($key1); }// $lang = get_lang($key1); } return $lang; } /** * Returns the name of the plugin. * * @return string * @access public */ function getPluginName() { return $this->plugin_class_name; } /** * Returns the main directory for this plugin * * @return string * @access public */ function getPluginDir() { return PLUGIN_DIR . $this->getPluginName() . '/'; } /** * Returns the includes directory for this plugin * * @return string * @access public */ function getIncludeDir() { return $this->getPluginDir() . 'includes/'; } /** * Returns the images directory for this plugin * * @return string * @access public */ function getImagesDir() { return $this->getPluginDir() . 'images/'; } /** * Returns the language directory for this plugin * * @return string * @access public */ function getLanguageDir() { $language = $this->modGetLoadedLanguage(); return $this->getPluginDir() . 'language/lang_' . $language . '/'; } /** * Returns the libs directory for this plugin * * @return string * @access public */ function getLibsDir() { return $this->getPluginDir() . 'libs/'; } /** * Returns the user menu entry for a plugin. * * @return array * @access public */ function getUserMenuEntry() { $menu = array(); if ( $this->user_menu_appear ) { $menu = array( 'text' => $this->user_menu_text, 'href' => $this->modSiteUrl().'plugin.php?plugin=' . $this->getPluginName(), // The name of this class ); } return $menu; } /** * Returns the admin menu entry for a plugin. * * @return array * @access public */ function getAdminMenuEntry() { $menu = array(); if ( $this->admin_menu_appear ) { $menu = array( 'text' => $this->admin_menu_text, 'href' => $this->modSiteUrl().'admin/plugin.php?plugin=' . $this->getPluginName(), // The name of this class ); } return $menu; } /** * Returns the content that will appear in the left column of a page. Override this method in yor class if you have content that needs displayed in the left column. * * @return string - html that will be displayed * @access public */ function displayLeftCol() { } /** * Returns the content that will appear in the main content area of the page. This content will appear after the existing main content. Override this method in yor class if you have content that needs displayed in after the existing main content. * * @return string - html that will be displayed * @access public */ function displayMain() { } /** * Returns the content to display a custom user page. Override this method in your class if you need a new page for your plugin. * * @return string - html that will be displayed * @access public */ function displayPluginPage() { //$this->modSmartyAssign('lang', $this->modGetLang() ); // This is what makes the template display on the page // //return $this->modSmartyFetch('helloworld.tpl'); } /** * Returns the content to display a custom admin page. Override this method in your class if you need a new page for your plugin. * * @return string - html that will be displayed * @access public */ function displayPluginAdminPage() {// $this->modSmartyAssign('lang', $this->modGetLang() );//// // This is what makes the template display on the page// //// return $this->modSmartyFetch('admin/helloworld.tpl'); } /** * WARNING: USER IS NOT VALIDATED HERE. BE CAREFUL<br> * Returns all the html for a page. Override this method in your class if you need a page with only your content. Often used in downloads * * @return string - html that will be displayed * @access public */ function displayPluginContent() { return "hello world"; } /** * Returns the sql directory for this plugin * * @return string * @access public */ function getSqlDir() { return $this->getPluginDir() . 'sql/'; } /** * Returns the sql directory for this plugin * * @return string * @access public */ function getTemplatesDir() { $skin_name = $this->modGetSkinName(); if ($skin_name == '') $skin_name='default'; $templates_base = $this->getPluginDir() . 'templates/'; if ( ! file_exists($templates_base . $skin_name) ) { $skin_name = 'default'; } return $templates_base . $skin_name . '/'; } /** * Returns a parsed Smarty template from this plugins template directory * * @param string $filename the relative filename of the template file. * @return string * @access public */ function modSmartyFetch($filename) { // Additional $tplDir = $this->getTemplatesDir(); $filename = $tplDir . $filename; return $GLOBALS['t']->fetch($filename); } /** * Assigns a varible for use in smarty templates * * @param string $filename the relative filename of the template file. * @return string * @access public */ function modSmartyAssign($variable, $value) { // Additional $GLOBALS['t']->assign($variable, $value); } /** * Adds the Javascript tags to the header of the document * * @param string $filename the relative filename of the template file. * @return string * @access public */ function modSmartyJS($value) { // Additional $js = $GLOBALS['t']->get_template_vars('addtional_javascript'); $js .= $value; $GLOBALS['t']->assign('addtional_javascript', $js); } /** * Adds the CSS tags to the header of the document * * @param string $filename the relative filename of the template file. * @return string * @access public */ function modSmartyCSS($value) { // Additional $css = $GLOBALS['t']->get_template_vars('addtional_css'); $css .= $value; $GLOBALS['t']->assign('addtional_css', $css); } /** * Gets a record from the provided table using the search. The table * must belong to the plugin or this will return false. * * @param string $table the name of the table to retrieve * @param array $search keys are field names and the value is the value to match (ex. to find id of 5 use $search['id'] = 5) * * @return array * @access public */ function modGetRow($table, $search) { include_once(MODOSDATE_DIR . 'plugin_tables_data.php'); $tables = new pluginTablesData(); $result = false; $tsearch['name'] = DB_PREFIX . '_' . $table; $found = $tables->getRec($tsearch); if ($found ) { $sql = "SELECT * FROM ! WHERE " . $this->_where($search); $result = $GLOBALS['db']->getRow($sql, array($tsearch['name'])); } return $result; } /** * Deletes record(s) from the provided table using the search. The table * must belong to the plugin or this will return false. * * @param string $table the name of the table * @param array $search keys are field names and the value is the value to match (ex. to find id of 5 use $search['id'] = 5) * * @return array * @access public */ function modDeleteRows($table, $search) { include_once(MODOSDATE_DIR . 'plugin_tables_data.php'); $tables = new pluginTablesData(); $result = false; $tsearch['name'] = DB_PREFIX . '_' . $table; $found = $tables->getRec($tsearch); if ($found ) { $sql = "DELETE FROM ! WHERE " . $this->_where($search); $GLOBALS['db']->query($sql, array($tsearch['name'])); $result = true; } return $result; } /** * Gets all records from the provided table using the search. The table * must belong to the plugin or this will return false. * * @param string $table the name of the table to retrieve * @param array $search keys are field names and the value is the value to match (ex. to find id of 5 use $search['id'] = 5) * @param sting $order is the field by which the data in sorter * @param int $ordtype use 1 for sorting ascendent, and 2 for sorting descendent * * @return array - multidimensional array. The first level the index. Second level a associtive array of the records fields and values.<br> * * @
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -