Ahh, I see. I had a:
$modversion['hasComments'] = 1;
In xoops_version.php
I removed that and the preferences option went away.
Thanks for the lead...
Still waiting for a piece of sample admin code with smarty tags...
I went ahead and wrote the admin module in php/html. I'll post it here for others to see and learn from. Try not to laugh... It is a GIS app that forms a URL to a ESRI/Oracle map service. The result is the requested map comes up in a browser with the requested bounding box and attributes. Kind of like mapquest with more data behind the map. This is just the admin code (index.php) to set reasonable defaults. The rest of the app is at the bottom. I hope it's acceptable to post code here. Sample code is what I learn from so I hope someone can learn from mine. XOOPS is cool!
/////////////////////////////////////////////////////////
//
// admin/index.php
//
/////////////////////////////////////////////////////////
include '../../../include/cp_header.php';
if ( file_exists("../language/".$xoopsConfig['language']."/main.php") ) {
include "../language/".$xoopsConfig['language']."/main.php";
} else {
include "../language/english/main.php";
}
$op = "listdefaults";
if (isset($HTTP_GET_VARS)) {
foreach ($HTTP_GET_VARS as $k => $v) {
$$k = $v;
}
}
if (isset($HTTP_POST_VARS)) {
foreach ($HTTP_POST_VARS as $k => $v) {
$$k = $v;
}
}
if ($op == "listdefaults") {
xoops_cp_header();
///////////////////////////////////////////////////////////////////////////////
///
/// Displays and sets GIS extents for city, zip and lon/lat views
///
///////////////////////////////////////////////////////////////////////////////
$opts = 'SELECT * FROM '.$xoopsDB->prefix('gis_options').'';
$result = $xoopsDB->query($opts);
list($dum,$dum,$mapservice,$cityext,$zipext,$lonlatext) = $xoopsDB->fetchRow($result);
echo "
"._MM_CURRENT."
"._MM_EXTENT_HELP."
";
xoops_cp_footer();
exit();
}
if ($op == "setextents") {
$myts =& MyTextSanitizer::getInstance();
//
// Grab the numbers from the text gadgets above
//
$cityext = $HTTP_POST_VARS['cityext'];
$zipext = $HTTP_POST_VARS['zipext'];
$lonlatext = $HTTP_POST_VARS['lonlatext'];
//$mapservice = $HTTP_POST_VARS['mapservice'];
$mapservice = $myts->oopsAddSlashes(trim($HTTP_POST_VARS['mapservice']));
//
// Create a update query with the new values
//
$sql = "UPDATE ".$xoopsDB->prefix("gis_options")." set
opt_service='".$mapservice."',
opt_cityextent=".$cityext.",
opt_zipextent=".$zipext.",
opt_lonlatextent=".$lonlatext." WHERE opt_id=1";
//
// Update the gis_options table
//
if (!$xoopsDB->query($sql)) {
xoops_cp_header();
echo "Could not update GIS defaults, tell your System Administrator!";
xoops_cp_footer();
} else {
redirect_header("index.php?op=listdefaults",5,_MM_OPTSUCCESS);
}
}
?>
-----------------------------------------------------
And my mysql.sql file:
CREATE TABLE gis_zip (
zip_id int(15) unsigned NOT NULL auto_increment,
zip_zip varchar(255) NOT NULL default '',
zip_x float NOT NULL default '0.0',
zip_y float NOT NULL default '0.0',
PRIMARY KEY (zip_id)
) TYPE=MyISAM;
CREATE TABLE gis_city (
city_id int(15) unsigned NOT NULL auto_increment,
city_name varchar(255) NOT NULL default '',
city_state varchar(255) NOT NULL default '',
city_x float NOT NULL default '0.0',
city_y float NOT NULL default '0.0',
PRIMARY KEY (city_id)
) TYPE=MyISAM;
CREATE TABLE gis_sites (
site_id int(15) unsigned NOT NULL auto_increment,
site_name varchar(255) NOT NULL default '',
x1 float NOT NULL default '0.0',
y1 float NOT NULL default '0.0',
xx float NOT NULL default '0.0',
y2 float NOT NULL default '0.0',
PRIMARY KEY (site_id)
) TYPE=MyISAM;
#
# Fake data for testing
#
INSERT INTO gis_sites VALUES (1,"Knoxville",-77.43,41.95,-77.33,42.05);
INSERT INTO gis_sites VALUES (2,"Wilcox",-77.43,41.95,-77.33,42.05);
INSERT INTO gis_sites VALUES (3,"Roxbury",-77.43,41.95,-77.33,42.05);
INSERT INTO gis_sites VALUES (4,"West Boxford",-77.43,41.95,-77.33,42.05);
CREATE TABLE gis_options (
opt_id int(15) unsigned NOT NULL auto_increment,
opt_layers varchar(255) NOT NULL default '00000001100000110110010001',
opt_service varchar(255) NOT NULL default 'http://hqapp.oem.doe.gov/website/
us_detail_html',
opt_cityextent float NOT NULL default '0.15',
opt_zipextent float NOT NULL default '0.02',
opt_lonlatextent float NOT NULL default '0.05',
PRIMARY KEY (opt_id)
) TYPE=MyISAM;
INSERT INTO gis_options VALUES (1,"00000001100000110110010001","http://hqapp.oem
.doe.gov/website/us_detail_html",0.15,0.02,0.05);
CREATE TABLE gis_layers (
layer_id int(15) unsigned NOT NULL auto_increment,
layer_name varchar(255) NOT NULL default '',
PRIMARY KEY (layer_id)
) TYPE=MyISAM;
INSERT INTO gis_layers VALUES (1,"Locale");
INSERT INTO gis_layers VALUES (2,"Buildings");
INSERT INTO gis_layers VALUES (3,"");
INSERT INTO gis_layers VALUES (4,"");
INSERT INTO gis_layers VALUES (5,"Physicians");
INSERT INTO gis_layers VALUES (6,"Hospitals");
INSERT INTO gis_layers VALUES (7,"Recreation Areas");
INSERT INTO gis_layers VALUES (8,"Highways");
INSERT INTO gis_layers VALUES (9,"Streets");
INSERT INTO gis_layers VALUES (10,"");
INSERT INTO gis_layers VALUES (11,"Railroads");
INSERT INTO gis_layers VALUES (12,"");
INSERT INTO gis_layers VALUES (13,"DOE Site Buildings");
INSERT INTO gis_layers VALUES (14,"DOE Areas");
INSERT INTO gis_layers VALUES (15,"Zip Code Areas");
INSERT INTO gis_layers VALUES (16,"Counties");
INSERT INTO gis_layers VALUES (17,"Major Water");
INSERT INTO gis_layers VALUES (18,"Water Areas");
INSERT INTO gis_layers VALUES (19,"DOE Sites");
INSERT INTO gis_layers VALUES (20,"");
INSERT INTO gis_layers VALUES (21,"");
INSERT INTO gis_layers VALUES (22,"Airports");
INSERT INTO gis_layers VALUES (23,"Federal Land Areas");
INSERT INTO gis_layers VALUES (24,"Places");
INSERT INTO gis_layers VALUES (25,"Locale");
INSERT INTO gis_layers VALUES (26,"States");
OK here is the rest of the app: (index.php)
/////////////////////////////////////////////////////////
//
// index.php
//
/////////////////////////////////////////////////////////
include "../../mainfile.php";
$op = "form";
if ( isset($HTTP_POST_VARS['op']) && $HTTP_POST_VARS['op'] == "submit" ) {
$op = "submit";
}
if ( $op == "form" ) {
$xoopsOption['template_main'] = 'ecngis_searchform.html';
include XOOPS_ROOT_PATH."/header.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$sites_select = new XoopsFormSelect("","sites");
$sites_tray = new XoopsFormElementTray(_MM_SITE, " ");
$sites_tray->addElement($sites_select);
$sites_select->addOption("","");
//
// Grab bounding box from DB
//
$sql = 'SELECT site_name FROM '.$xoopsDB->prefix('gis_sites').'';
$result = $xoopsDB->query($sql);
while(list($site) = $xoopsDB->fetchRow($result)) {
$sites_select->addOption($site,$site);
}
$city_text = new XoopsFormText("", "city", 20, 60);
$city_tray = new XoopsFormElementTray(_MM_CITY, " ");
$city_tray->addElement($city_text);
$state_text = new XoopsFormText("", "state", 20, 60);
$state_tray = new XoopsFormElementTray(_MM_STATE, " ");
$state_tray->addElement($state_text);
//$county_text = new XoopsFormText("", "county", 20, 60);
//$county_tray = new XoopsFormElementTray(_MM_COUNTY, " ");
//$county_tray->addElement($county_text);
$zip_text = new XoopsFormText("", "zip", 20, 10);
$zip_tray = new XoopsFormElementTray(_MM_ZIP, " ");
$zip_tray->addElement($zip_text);
$lon_text = new XoopsFormText("", "lon", 20, 60);
$lon_tray = new XoopsFormElementTray(_MM_LON, " ");
$lon_tray->addElement($lon_text);
$lat_text = new XoopsFormText("", "lat", 20, 60);
$lat_tray = new XoopsFormElementTray(_MM_LAT, " ");
$lat_tray->addElement($lat_text);
$op_hidden = new XoopsFormHidden("op", "submit");
$submit_button = new XoopsFormButton("", "", "Search", "submit");
//
// "searchform" is referenced in template
//
$form = new XoopsThemeForm("", "searchform", "index.php");
$form->addElement($sites_tray);
$form->addElement($city_tray);
$form->addElement($state_tray);
$form->addElement($zip_tray);
$form->addElement($lon_tray);
$form->addElement($lat_tray);
$form->addElement($op_hidden);
$form->addElement($submit_button);
$form->assign($xoopsTpl);
$xoopsTpl->assign('lang_search', _MM_SEARCH);
$xoopsTpl->assign('lang_instructions', _MM_INSTRUCTIONS);
//$site_select->setExtra("");
//$site_select->setExtra("onchange='doSite()'");
}
if ( $op == "submit" ) {
$xoopsOption['template_main'] = 'ecngis_searchresults.html';
include XOOPS_ROOT_PATH."/header.php";
$myts =& MyTextSanitizer::getInstance();
$city = $HTTP_POST_VARS['city'];
$state = $HTTP_POST_VARS['state'];
$zip = $HTTP_POST_VARS['zip'];
$lon = $HTTP_POST_VARS['lon'];
$lat = $HTTP_POST_VARS['lat'];
$site = $HTTP_POST_VARS['sites'];
$xoopsTpl->assign('lang_search', _MM_SEARCH);
$xoopsTpl->assign('lang_results', _MM_RESULTS);
$xoopsTpl->assign('lang_city', _MM_CITY);
$xoopsTpl->assign('lang_state', _MM_STATE);
$xoopsTpl->assign('lang_site', _MM_SITE);
$xoopsTpl->assign('lang_zip', _MM_ZIP);
$xoopsTpl->assign('lang_lon', _MM_LON);
$xoopsTpl->assign('lang_lat', _MM_LAT);
$xoopsTpl->assign('lang_link', _MM_LINK);
if ( !empty($HTTP_POST_VARS['sites']) ) {
$opts = 'SELECT opt_service FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($service) = $xoopsDB->fetchRow($optsresult);
$site1 = rawurlencode($site);
$row = array();
$row['site'] = $site;
$row['url'] = "$service?ActiveLayer=19&Query=NAME%3D$site1$QueryZoom=Yes";
$xoopsTpl->append('row',$row);
$xoopsTpl->assign('type', "site");
$city = $state = $zip = "";
}
if(strlen($city) > 0 || strlen($state) > 0) {
$xoopsTpl->assign('type', "city");
//
// Generate a query based on what gadgets are filled in
//
if(strlen($city) > 0 && strlen($state) > 0) {
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_city').'
WHERE city_name LIKE "%'.$city.'%"
AND city_state LIKE "%'.$state.'%" ORDER BY city_name';
}
if(strlen($city) > 0 && strlen($state) == 0) {
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_city').'
WHERE city_name LIKE "%'.$city.'%" ORDER BY city_name';
}
if(strlen($city) == 0 && strlen($state) > 0) {
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_city').'
WHERE city_state LIKE "%'.$state.'%" ORDER BY city_name';
}
$result = $xoopsDB->query($sql);
//
// Grab bounding box from DB
//
$opts = 'SELECT opt_layers,opt_service,opt_cityextent FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($layers,$service,$extent) = $xoopsDB->fetchRow($optsresult);
//
// Now build url for GIS viewer
//
$row = array();
$count = 0;
while (list($dbid,$dbcity, $dbstate, $dblon, $dblat) = $xoopsDB->fetchRow($result)) {
//echo"$dbcity, $dbstate, $dblon, $dblat
";
$x1 = $dblon - $extent;
$y1 = $dblat - $extent;
$x2 = $dblon + $extent;
$y2 = $dblat + $extent;
$row['url'] = "$service/viewer.htm?box=$x1:$y1:$x2:$y2?layers=$layers";
$row['city'] = $dbcity;
$row['state'] = $dbstate;
$row['lon'] = $dblon;
$row['lat'] = $dblat;
$xoopsTpl->append('row',$row);
$count++;
}
$xoopsTpl->assign('count',$count);
}
if(strlen($zip) > 0) {
$xoopsTpl->assign('type', "zip");
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_zip').'
WHERE zip_zip LIKE "%'.$zip.'%" ORDER BY zip_zip';
//echo "$sql
";
$result = $xoopsDB->query($sql);
//
// Grab bounding box from DB
//
$opts = 'SELECT opt_layers,opt_service,opt_zipextent FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($layers,$service,$extent) = $xoopsDB->fetchRow($optsresult);
$row = array();
$count = 0;
while (list($dbid,$dbzip, $dblon, $dblat) = $xoopsDB->fetchRow($result)) {
//echo"$dbcity, $dbstate, $dblon, $dblat
";
$x1 = $dblon - $extent;
$y1 = $dblat - $extent;
$x2 = $dblon + $extent;
$y2 = $dblat + $extent;
$row['url'] = "$service/viewer.htm?box=$x1:$y1:$x2:$y2?layers=$layers";
$row['city'] = "";
$row['state'] = "";
$row['zip'] = $dbzip;
$row['lon'] = $dblon;
$row['lat'] = $dblat;
$xoopsTpl->append('row',$row);
$count++;
}
$xoopsTpl->assign('count',$count);
}
if(strlen($lon) > 0) {
$xoopsTpl->assign('type', "lon");
//
// Grab bounding box from DB
//
$opts = 'SELECT opt_layers,opt_service,opt_lonlatextent FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($layers,$service,$extent) = $xoopsDB->fetchRow($optsresult);
$row = array();
$count = 0;
//echo"$dbcity, $dbstate, $dblon, $dblat
";
$x1 = $lon - $extent;
$y1 = $lat - $extent;
$x2 = $lon + $extent;
$y2 = $lat + $extent;
$row['url'] = "$service/viewer.htm?box=$x1:$y1:$x2:$y2?layers=$layers";
$row['city'] = "";
$row['state'] = "";
$row['zip'] = "";
$row['lon'] = $lon;
$row['lat'] = $lat;
$xoopsTpl->append('row',$row);
$xoopsTpl->assign('count',$count);
}
}
include_once XOOPS_ROOT_PATH."/footer.php";
?>