Discuz! Tutorial on creating x plug-ins (iv) -- release plug-ins

Source: Internet
Author: User

I finally wrote my own great plug-in, And I hope others can use it too! What should I do if I want to publish this plug-in? Problems
However, we have just finished writing a plug-in, but the problems we are facing are just getting started. We need to consider a lot of things, including:
1. the language I use is UTF-8. I hope that webmasters who use GBK can also use my plug-in.
2. I may use a database to create the table I need. How can I create a table?
3. How can I describe my use regulations or installation Regulations?
4. How can I describe plug-ins for my plug-ins?
5. Do I have to pay for where my plug-ins are released?
Oh, my head is big! I have never thought about this question! How can I solve so many problems? Hey, this is the time to reflect my own values. Let's explain it slowly!
Language Encoding

To solve the problem of language encoding, we must first ensure that there are no Chinese characters in all our programs, and then we need to create a new file: data/plugindata/mtest. lang. php file, the written content is:

<? Php $ scriptlang ['mtest'] = array ('enabled' => 'enabled',); $ templatelang ['mtest'] = array ();?>

Then, before using your own program, use:

$mlang=$scriptlang['mtest'];

In this way, the $ mlang array stores the content you want to use.
Next, we need to create xml files encoded in different languages.
 
I believe that you must see the export button, and then an XML file that stores it under your plug-in directory. If you do not want to use multi-language-encoded plug-ins, you can directly package the plug-in directory in rar format. Your plug-in has been completed. Here, we also need the GBK webmaster, so we need to perform transcoding. First, we change the name of the discuz_plugin_mtest.xml file to discuz_plugin_mtest_ SC _UTF8.xml.
Here: SC stands for the UTF8 encoding method in simplified Chinese, and then uses the encoding conversion tool. After the XML file is transcoded, It is renamed as the corresponding name and placed in this directory. I recommend ConvertZ as the encoding conversion tool. You can search for it online. So far, our transformation is complete!
Use Database
I need to use a database. What should I do if my plug-in needs to create a new data table?

Do you still remember the XML file we just exported? We need to modify the content of this XML file to implement our operations. We need

<item id="DATA"></item>

Add the following code:

<item id="installfile"><![CDATA[install.php]]></item><item id="uninstallfile"><![CDATA[uninstall.php]]></item>

The above code indicates the files that will run when the plug-in is installed or uninstalled. Both files are placed in the plug-in directory. The following is an example:

<? Php

/*

Mguide for discuz x 1.0

Editor: monkee

Version: 1.0

*/

If (! Defined ('in _ discuz ')){

Exit ('Access denied ');

}

$ SQL = <EOF

Drop table if exists cdb_table_setting;

Create Table cdb_table_setting (

'Key' varchar (20) not null primary key,

'Value' text

) Engine = MyISAM default charset = dcharset;

EOF;



$ SQL = str_replace (Array ('cdb _ table_setting ', 'dcharset'), array (DB: Table ('mguide _ setting '), $ _ g ['charset'] = 'utf-8 '? 'Utf8': $ _ g ['charset']), $ SQL );


Foreach (explode (';', $ SQL) as $ item ){

If (! Empty ($ item ))

DB: Query ($ item );

}


$ Finish = true;

?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.