/*
Copyright  2000 Ben O'Neill
newsPHP Howto
1.0.4
*/

1) Creating extensions [very complicated]
2) Creating language files
3) Using the mailling list feature.

///////////////////////////////////////
1) Creating extensions!
///////////////////////////////////////

This is what a very simple, extension file
would look like. They must be called
<extensionname>.npe. An example is in
this zip file called "example.npe".

I'm going to disect the following example,
all my comments will be like:

// my comment

or

/*
my comment
*/

Remember when you make an addon you must not
edit front part, only the end text inside
the quotes.

Make sure you change the "example" part to
the filename of your extension so they are
all different! e.g.

$Extensions["m00"][".....

## START
<?
// This text will appear on the toolbar, and on the mainpage.
$Extensions["example"]["ToolbarName"] = "Example";

/*
This is the value of $qstring it will use, e.g. nphp.php?<valuehere>

NOTE: You CANNOT use and qstrings that newsPHP uses, they will be
ignored by the script, so don't even try. =P
*/
$Extensions["example"]["QString"] = "exam";

// This appears on the mainpage as the description.
$Extensions["example"]["Description"] = "This has been added by the addons tool. This is an example.";

/*
Anyone with a level above this will be able to see your link.
If you want a passive extension set this high, e.g. 5
/*
$Extensions["example"]["ReqLevel"] = 1;

/*
The follow is saying this:

If the user goes to nphp.php?exam then
send the newsPHP head with Example as
the title, then write that little message
and then print the header. Then stop.

*/

if($qstring=="exam")
{
  htmlHeader("Example");

   print("This is an example extension. This means you have clicked on the Example link on the toolbar or main page. Or you have
          gone to nphp.php?exam");

  htmlFooter();
  exit;
}
?>
## END

You MUST have the "exit;" otherwise it is very likely
the script will then print the main page.

Some important variable you may need:

  $lvl = The level of the current user
  $mydetails = An array with some of
               the users details.

  $mydetails["uname"] = The users username
  $mydetails["id"]    = ID of the user (not used)
  $mydetails["email"] = The users email address
  $mydetails["lvl"]   = Same as $lvl
  $mydetails["pword"] = The encryped password.

  $nphpConfig = An array of the config file.

$NPConfig is a very important array, it loads
in every single line of the config file, and
assigns it inside a named array, eg:

TimeZone<~-~>BST
ConvertNL<~-~>1
ShowDateOnce<~-~>1
EnableBROption<~-~>0
ModifyPerPage<~-~>20
NewsCategorys<~-~>x0

Those lines from my config file would be 
usable from $NPConfig via:

$nphpConfig["TimeZone"]
$nphpConfig["ConvertNL"]
$nphpConfig["ShowDateOnce"]
$nphpConfig["EnableBROption"]
$nphpConfig["ModifyPerPage"]
$nphpConfig["NewsCategorys"]

The values would be:
BST
1
1
0
20
0

The <~-~> is removed.

If you want to add to the settings file
you do it like this:

  $nphpConfig["<setting_name>"] = "<value>";

Then tell the script to save it like this:

  SaveConfig($nphpConfig,$nphpUsers,$nphpPGlossary,$nphpCats);

You must do that exact line, or it may loose
all the user data and/or glossary info!

///////////////////////////////////////
2) Create additional language files
///////////////////////////////////////

We _really_ want people to make these and
email them to us so we can get them on the
site, send them to:

 sheepcow@planetunreal.com

They are easy to make. the file can be
called anything you like, but it must have
a ".npl" extension. It would be a lot nicer
if you could call them <language_name>.npl

[ an example language file is included
  in this zip file called "example.npl" ]

This is EXACTLY what the file should look 
like:


  Please look at example.npl


As you can see there is quite a lot to
translate. I'll now show you what to
translate, because some of that is needed
to stay in english.

 $Messages["Mainpage_Descriptions_SubmitNews"] = "Add a new news item to the database.";

That's the line I'll use in this example.
The part you need to translate is at the end,
this is what I mean:

 $Messages["Mainpage_Descriptions_SubmitNews"] = "<ENTER TRANSLATION HERE>";

Save the file into the same directory as
"nphp.php" and the script will auto
detect them. You can have as many .npl files
as you like!

///////////////////////////////////////
3) Using the mailling list feature
///////////////////////////////////////

The first thing to do is goto Settings
and set "EmailUpdates" to Yes and 
also setup the email date and format.

Now the newsPHP script is setup to handle
it. AutoBuilding must be on otherwise
emails will not be sent.

Now you need to add in the subscribing
and unsubscribing information onto
your web site. If you click on the 
"Email" option it gives some example
code.