# README.TXT
# Amazon Media Manager 1.1
# WordPress-based blog tool
# 
# Denyerec 2004 All Rights Reserved
#		http://www.denyerec.co.uk
#   http://www.denyerec.co.uk/index.php?p=63
#
# NO RESPONSIBILITY WILL BE ACCEPTED FOR LOSS OF DATA (OR TIME) DUE TO USE OF THIS SCRIPT.
# If you wish to use the Amazon Media Script you do so AT YOUR OWN RISK.
#
# Thanks to Shadow from www.thebiggame.org for RegXp, File parsing and general assistance
# Thanks to Kitta of Kitta.net fame for her patience in testing it and suffering my documentation!

Installation or Upgrade:
------------------------

1)  Open amazonphp.php and at the top of the file, look for the following lines:

	DEFINE('ASSOCID','');
	DEFINE('CSUFF','co.uk');
    
    If you have an amazon associate ID, place it between the single quotes in the ASSOCID line, for example:
    
	DEFINE('ASSOCID','denyersphotog-21');
      
    Now change the next line to reflect which Amazon site to use as the default. For example if you
    wish to use the .com site as the default site the line should read:
    
      DEFINE('CSUFF','com');
    
    The acceptable suffixes are:
    
    Amazon.com		-	com
    Amazon.co.uk	-	co.uk
    Amazon.de		-	de
    Amazon.fr		-	fr
    Amazon.ca		-	ca
    Amazon.co.jp 	-	co.jp  
    
    NOTE: Data extraction does not work for japanese titles, but link generation and image extraction is OK.    
    
    If you do not have an associate ID and wish to use mine you are welcome to do so, just let me know
    so I can thank you!! My ID is:
    
    	denyersphotog-21
    	
   	IMPORTANT: Due to the regional nature of the Amazon Associate scheme, your Associate ID will ONLY be
   	attached to URLs from your selected default domain. For example, if you set .co.uk as your default 
	amazon site then all UK items will have your associate ID attached, but items extracted from 
	the .co.jp site will not.
    
2)  Open your site's menu.php file (located in the wp-admin folder) and add this line:
	$menu[0] = array(__('Amazon'), 10, 'amazonphp.php');
	
	Note the number [0] is the order of the menu item; if you want your AMM link to appear first in the menu, use 0 and 
	insert this line before the other entries, which look similar. Of course, you can use a higher number and insert it 
	farther down the list if you don't want it to be first. With a little experimentation you can make it a 
	sub-menu. For example, this will insert it under the "Links" menu:
	$submenu['link-manager.php'][7] = array(__('Amazon'), 10, 'amazonphp.php');
	
	The 10 is the minimum login level needed to to add, modify, or delete items. Change this value to whatever you want, 2-10. 
	Level 10 means that only the site admin can change the links; level 1 means that any registered user can. If your site 
	has open registration, it is recommended that you NOT set this value to 1, as that will let anyone modify your media links.
	
	You can change the name that appears in your admin menu by changing 'Amazon' to whatever you want.
	
	Upload the new version of menu.php to your site (remember, it goes in /wp-admin/).
	
3)  Copy the files amazoninfo.php and amazoninstall.php to the WordPress root directory.
    (The root directory is the folder containing your index.php file)
    
4)  In your web browser, enter the url to your website blog, but point to the amazoninstall.php file.
    EG:
          http://www.denyerec.co.uk/amazoninstall.php

    This will create a table in your MySQL database called 'ae_data'. If for some reason the table already
    exists the installer will halt and you'll have to remove the existing table manually before re-running
    the installation script. (As the table is simple, if it already exists it's most probably OK, so only
    remove it and re-install if the rest of the mod doesn't function correctly.) If you are upgrading, the 
    existing AE_DATA table is automatically modified.
	
	Note: If you get an error message that reads something like: 
	Warning: mysql_num_rows(): supplied argument is not a valid MySQL
	result resource in...
	Your installation will likely still work.

5)  When the installation script says it has created the ae_data table you may delete the amazoninstall.php script
    from your webspace as it is no longer required.

6) Open your index.php file (Your Wordpress Template) and look for the following line at the top:
				
	require_once('wp-blog-header.php');
		
	On the line below, enter the following:
		
	include('amazoninfo.php');
				
6a) If you are using the wp-hacks.php method of including hacks to your blog, you're free to alter things 
		to suit this method, though as I do not yet work with wp-hacks.php I do not intend to support it. Odds
		are if you've gone so far as to get the wp-hacks thing working, you're competant enough to fix it up for 
		yourself anyway ;)

7)  You are now ready to include the add-ins to your WordPress template.

Template Function:
-------------------

The get_media function is used to display data taken from the ae_data table.
The data is typically returned sorted in DATE order, thus returning the most recent entires.
It is called from your template as follows:

      <?php get_media($binswitch,$quan,$recom,$tbef,$taft,$tbet); ?>
	See below for the meaning of each argument.
	
If you are using lists for your sidebar (as most WP templates do), you can use this code:
	<li id="Amazon"><?php _e('Amazon:'); ?>
	<?php get_media(ARGUMENTS); ?>
	</li>
	By default, AMM will use a nested list to display your items (see below for customisation options).
	
Arguements Explained:
---------------------

      $binswitch -  This is used to detemine which media you wish you display. Valid values are 0 to 7,
                    and are explained as follows:

                    0 - Random
                    1 - Books
                    2 - Music
                    4 - DVD's
					8 - Games
										
                    If you wish to display 2 types of media, or all 3, simply add up the values shown
                    above and pass that to the function, thus:

                    3 - Books and Music  (1 + 2)
                    7 - Boosk, Music, and DVDs (1 + 2 + 4)
					15 - Books, Music DVD's and Games (1 + 2 + 4 + 8)  (Default)
                    5 - Books and DVD's

      $quan     - This is the number of each type of item you wish you display. If not passed,
                  it defaults to 0, which picks ONE item at random from the list.
      
      $recom    - 0: No filtering (Default)
                  1: Extract only items you have set as RECOMMENDED
                  2: Extract only items you have NOT set as recommended

      $tbef     - Text you wish to appear BEFORE each field (Title, author etc)
      $taft     - Text you wish to appear AFTER each field
      $tbet     - Text you wish to appear BETWEEN each entry (Between each full record).

                The default variables create a <ul><li></li></ul> structure and is usually adequate.
                If you wish to customise the output, do so "at your own risk".

    If no arguements are passed to the function, the default behaviour is to display the most recently
    added book, CD and DVD in a <ul></ul> framework.
                          
    E.G.  To display the 2 most recently added books and DVD's in the default list framework, we call the function
          as follows:
      
              get_media(5,2);
  
          To display a random item from each category, we use the following:
      
              get_media(7);
          
          (The default value for the $quan arguement is zero)
    
          To display your 3 most recent recommended books, you would use:
          
              get_media(1,3,1);
              
    If you wish you customise the output, the arguements $tbef, $taft and $tbet can be passed in, similar
    to the operation of many familiar WordPress template functions.
  
Customizing Using CSS:
---------------------
Four new CSS classes have been added to this version of AMM to allow you to further customize the appearance of your Amazon links:
#Amazon
Amazontitle
Amazonauthors
Amazoncomment

To customize the appearance of these elements, insert the following into your stylesheet (probably wp-layout.css or styles.css) as a starting point:
#Amazon {
}
.Amazonimage {
	border: 0px;
}
.Amazontitle {
	font-weight: bold;
}
.Amazonauthors {
	font-style: italic;
}
.Amazoncomment {
	font-size: .9em;
}
Of course, change the CSS to whatever you want.

Adding Media to the Medialist:
------------------------------

When you select the Media option from the toolbar after completing the above steps, the Media Management page will display. If you have not yet madeany entries, you will only see a small form asking for an ISBN or ASIN number. 
If you have previously made entries, then a table displaying all entries in date order will also appear.

To make an entry: 
        Simply copy and paste the ISBN (International Standard Book Number) or ASIN (Amazon Standard Item Number) into
        the textbox, select which Amazon site you wish to use from the dropdown (Your selected default site will be 
        highlighted to begin with) and press SUBMIT. The script will analyse the information from Amazon and display a 
        form allowing you to change the title and author (Should the Amazon entry be irregular. Normally you won't 
        need to make any changes). You are also able to enter a user-comment, such as a brief review or appraisal, 
        it's up to you!
		Note: The hyphen (-) at the beginning of the author name has been removed in this version. If you wish to have a hyphen
		or other character at the start of the author name, insert it manually in the author box, or edit amazoninfo.php
		near the end to insert a hyphen automatically.
        
        Once you are satisfied that the information is correct, press SUBMIT and the entry will be made. That's it!
        If you make a mistake, just use your back button or press cancel. If you accidentally submit the wrong book,
        don't worry...
        
To delete an entry:
        If there are items in your media list they will be displayed in a table on the main page. Simply press the DEL
        link next to the relevant entry. You'll be shown the information relating to the item you have selected, if
        this is the item you wish to delete press the DELETE button, if not, hit cancel.
        
To modify an entry:
        You can only modify the user comment for an entry to avoid inconsistency with Amazon's database information.
        To edit a comment, simply click the edit link next to the entry you wish to change. A form will appear where
        you are able to amend your comment. To save the comment, press SUBMIT, if you wish to abort the changes,
        press CANCEL.
        If you find you have entered the wrong ISBN or have issues with the stored data, delete the item and 
        re-add it.


Tips:
-----

The script is designed to take the most recent entries from the database (Unless operating in random mode).
If you wish for a book to re-appear at the top of your list you can EDIT the book (As outlined above) and 
select the "Update Date" checkbox. This will change the record's DateAdded field to reflect the current system date,
thus moving the entry to the top of a date ordered list.

Support:
--------

This system has not been extensively tested, though initial indications are promising. If you have any problems
with the installation, or bugs within the script please contact me at website@denyerec.co.uk
You can also view comments on the download page at:
http://www.denyerec.co.uk/index.php?p=63
to see if others have experience and resolved similar issues.
If you wish to contact me with a problem, PLEASE PLEASE PLEASE include a detailed account of what you were 
trying to do, the exact error messages that displayed, and the problems you encountered.
Emails received saying "It doesn't work" or "I can't install it because of a bug" will not make me like you.

I'll do what I can to help you with matters concerning the Amazon script, but assistance with general WordPress
issues is restricted by my spare time.