Ok, this is my plugin: It creates an interface for users to add meta tags to thier gallery:
Heres the code base:
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2007 Coppermine Dev Team
v1.1 originally written by Gregory DEMAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3
as published by the Free Software Foundation.
********************************************
Coppermine version: 1.4.13
$Source$
$Revision: 3912 $
$Author: gaugau $
$Date: 2007-08-24 16:48:44 +0200 (Fr, 24 Aug 2007) $
**********************************************/
/***************************
META DATA PLUGIN
****************************
by - just_some_guy - mysimtractor.com
*************************************
version: 1.0
************************************/
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
require 'include/config.inc.php';
require 'include/init.inc.php';
// Add an install action
$thisplugin->add_action('plugin_install','meta_install');
// Add a configure action
$thisplugin->add_action('plugin_configure','meta_configure');
// Add menu button
$thisplugin->add_action('page_start','meta_page_start');
// Install function
// Checks if uid is 'foo' and pwd is 'bar'; If so, then install the plugin
function meta_install() {
// Install
if ($_POST['uid']=='foo' && $_POST['pwd']=='bar') {
return true;
// Loop again
} else {
return 1;
}
}
$result= mysql_query("ALTER TABLE {$CONFIG['TABLE_CONFIG']} CHANGE `value` `value` MEDIUMTEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL");
$result= mysql_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('meta_info', 'empty')");
// Display the config options
function meta_confiugure() {
echo <<< EOT
<strong><span style="text-decoration: underline">Meta Data Plugin</span></strong><br />
<br />
<?php echo $lang_plugin_meta_how[how]; ?>:<br />
<br />
<form method="post" action="{$_SERVER['PHP_SELF']}" >
<table style="width: 500px" >
<tr>
<td style="width: 206px">
<?php echo $lang_plugin_meta_menu[description]; ?> -</td>
<td style="width: 205px">
<input id="Description" type="text" /></td>
<td style="width: 250px">
<?php echo $lang_plugin_meta_describe[description_txt]; ?></td>
</tr>
<tr>
<td style="width: 206px">
<?php echo $lang_plugin_meta_menu[keyword]; ?> -</td>
<td style="width: 205px">
<input id="Keywords" type="text" /></td>
<td style="width: 250px">
<?php echo $lang_plugin_meta_describe[keyword_txt]; ?></td>
</tr>
<tr>
<td style="width: 206px; height: 21px">
<?php echo $lang_plugin_meta_menu[author]; ?></td>
<td style="width: 205px; height: 21px">
<input id="Author" type="text" /></td>
<td style="width: 250px; height: 21px">
</td>
</tr>
<tr>
<td style="width: 206px; height: 21px">
<?php echo $lang_plugin_meta_menu[robots]; ?> -</td>
<td style="width: 205px; height: 21px">
<input id="Robots" type="text" /></td>
<td style="width: 250px; height: 21px">
See <a href="http://www.robotstxt.org/wc/meta-user.html">here</a> for more info
on this meta tag.</td>
</tr>
<tr>
<td style="width: 206px; height: 21px">
<input id="Submit" type="submit" value="<?php echo $lang_plugin_meta_go[apply]; ?>" /></td>
</tr>
</table>
</form>
EOT;
}
// Create variables from the inputs
$description = "$_POST[Description]";
$keywords = "$_POST[Keywords]";
$author = "$_POST[Author]";
$robots = "$_POST[robots]";
// Update the table rows with the variables
$value = "<META name="Author" content="" . $_POST['Description'] . "">
<META name="keywords" content="" . $_POST['Keywords'] . "" />
<META name="description" content="" . $_POST['Author'] . " " />
<meta name="robots" content="" . $_POST['robots'] . " " />";
$result = mysql_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value='" . mysql_real_escape_string($value) . "'
WHERE name='meta_info'") or die(mysql_error());
EOT;
// add config button
function plugin_config_button($href,$title,$target,$link)
{
global $template_gallery_admin_menu;
$new_template = $template_gallery_admin_menu;
$button = template_extract_block($new_template,'documentation');
$params = array(
'{DOCUMENTATION_HREF}' => $href,
'{DOCUMENTATION_TITLE}' => $title,
'target="cpg_documentation"' => $target,
'{DOCUMENTATION_LNK}' => $link,
);
$new_button="<!-- BEGIN $link -->".template_eval($button,$params)."<!-- END $link -->\n";
template_extract_block($template_gallery_admin_menu,'documentation',"<!-- BEGIN documentation -->" . $button . "<!-- END documentation -->\n" . $new_button);
}
// add admin button to start of each page
function meta_data_page_start()
{
if (GALLERY_ADMIN_MODE) {
plugin_config_button('index.php?file=meta_data/meta_data',Meta Data,'',Meta Data);
}
}
?>
I would also like to thank the guys at the Dev Shed forum with the help in debugging some parts of the above.
Thanks Stramm.