leon 01/10/26 17:07:20
Modified: freetrade2/modules/configuration global
freetrade2/modules/database/mysql department item
freetrade2/modules/navigation side
freetrade2/modules/screen department item quick_order
search_results
freetrade2/modules/utility standard_library
Log:
Added ability to use named departments and items
Revision Changes Path
1.11 +8 -0 freetrade/freetrade2/modules/configuration/global
Index: global
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/configuration/global,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- global 2001/10/26 20:47:32 1.10
+++ global 2001/10/27 00:07:19 1.11
@@ -2,12 +2,12 @@
/*
** File: global_settings
** Description: Sets a bunch of global variables
- ** Version: $Revision: 1.10 $
+ ** Version: $Revision: 1.11 $
** Created: 05/18/99
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:32 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
*/
@@ -229,6 +229,14 @@
//This is the number of invoices we'll list per page
//on the admin_invoice page.
define("MAX_INVOICES_PER_PAGE", 25);
+
+ //This constant controls whether links to departments
+ //use the name of the department instead of the ID.
+ define("USE_NAMED_DEPARTMENTS", TRUE);
+
+ //This constant controls whether links to items
+ //use the name of the item instead of the ID.
+ define("USE_NAMED_ITEMS", TRUE);
/*
1.8 +37 -25 freetrade/freetrade2/modules/database/mysql/department
Index: department
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/database/mysql/department,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- department 2001/03/23 18:11:10 1.7
+++ department 2001/10/27 00:07:19 1.8
@@ -6,35 +6,8 @@
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/03/23 18:11:10 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
**
- ** Log : $Log: department,v $
- ** Log : Revision 1.7 2001/03/23 18:11:10 leon
- ** Log : Changes submitted by Chris Mason.
- ** Log :
- ** Log : Revision 1.6 2000/11/08 00:54:28 leon
- ** Log : *** empty log message ***
- ** Log :
- ** Log : Revision 1.5 2000/07/06 22:55:38 leon
- ** Log : Fixed bug with selected options not working
- ** Log :
- ** Log : Revision 1.4 2000/06/12 21:49:07 leon
- ** Log : Moving SQL out of department-related action modules
- ** Log :
- ** Log : Revision 1.3 2000/06/02 06:46:26 dilinger
- ** Log : Used mysql_fetch_object() by accident
- ** Log :
- ** Log : Revision 1.2 2000/06/02 05:06:15 dilinger
- ** Log : created getDepartmentChildren(), which gets a list of subdepartments
from a parent department id
- ** Log :
- ** Log : Revision 1.1 2000/05/30 21:26:22 leon
- ** Log : Moving department into database directory
- ** Log :
- ** Log : Revision 1.4 2000/05/10 23:43:09 leon
- ** Log : Fixing bug in utility/item
- ** Log :
- **
- ** Copyright (c) 1999 Working Dogs. All rights reserved.
*/
@@ -164,6 +137,42 @@
}
return($department[$id]);
+ }
+
+ /*
+ ** Function: getDepartmentID
+ ** Input: INTEGER id
+ ** Output: ARRAY
+ ** Description: Returns the ID of a department given the name.
+ ** If departments have duplicate names, the one with the lower
+ ** DisplayPrecedence wins.
+ */
+ function getDepartmentID($name)
+ {
+ global $DatabaseLink;
+ static $department;
+
+ if(!is_array($department))
+ {
+ //pull department table into array
+ $Query = "SELECT ID, Name " .
+ "FROM department " .
+ "ORDER BY DisplayPrecedence DESC, Name DESC ";
+ if(!($DatabaseResult = mysql_query($Query, $DatabaseLink)))
+ {
+ addToLog("Couldn't get department IDs!",
+ LOG_EMERGENCY, __FILE__, __LINE__);
+
+ return(FALSE);
+ }
+
+ while($DatabaseRow = mysql_fetch_object($DatabaseResult))
+ {
+ $department[($DatabaseRow->Name)] = $DatabaseRow->ID;
+ }
+ }
+
+ return(intval($department[$name]));
}
1.30 +17 -4 freetrade/freetrade2/modules/database/mysql/item
Index: item
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/database/mysql/item,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- item 2001/10/26 20:47:32 1.29
+++ item 2001/10/27 00:07:19 1.30
@@ -2,12 +2,12 @@
/*
** File: item
** Description: functions needed for get info about items
- ** Version: $Revision: 1.29 $
+ ** Version: $Revision: 1.30 $
** Created: 6/10/1999
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:32 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
*/
include_once(DATABASE_MODULE . "attribute");
@@ -1281,12 +1281,25 @@
** Output: ARRAY
** Description: returns ID of the named item
*/
- function getItemID($name)
+ function getItemID($name, $department=0)
{
global $DatabaseLink;
- $Query = "SELECT ID FROM item ";
- $Query .= "WHERE Name = '" . addslashes($name) . "'";
+ $Query = "SELECT i.ID ";
+ if($department > 0)
+ {
+ $Query .= "FROM item i " .
+ "INNER JOIN department_item d ON (i.ID = d.Item) " .
+ "WHERE Name = '" . addslashes($name) . "' ";
+ }
+ else
+ {
+ $Query .= "FROM item i " .
+ "WHERE Name = '" . addslashes($name) . "' ";
+ }
+ $Query .= "ORDER BY i.DisplayPrecedence, i.Name ";
+
+
if(!($DatabaseResult = mysql_query($Query, $DatabaseLink)))
{
addToLog("couldn't find item ID!",
@@ -1388,7 +1401,7 @@
//get departments and items
$Query = "SELECT i.ID, di.Department, i.Name, d.Name AS
Department_Name, " .
- "i.Thumbnail, i.Keywords, i.Description " .
+ "i.Thumbnail, i.Keywords, i.Description, d.ID AS Department " .
"FROM department_item di LEFT JOIN " .
"department d ON d.ID = di.Department, item i " .
"WHERE di.Item = i.ID " .
1.8 +2 -1 freetrade/freetrade2/modules/navigation/side
Index: side
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/navigation/side,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- side 2001/10/26 20:47:33 1.7
+++ side 2001/10/27 00:07:19 1.8
@@ -2,12 +2,12 @@
/*
** File: side
** Description: side navigation
- ** Version: $Revision: 1.7 $
+ ** Version: $Revision: 1.8 $
** Created: 04/22/1999
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:33 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
**
*/
@@ -27,7 +27,8 @@
//mini search form
- print(StartForm("search_results", "POST", "", array("SearchType", "simple")));
+ print(StartForm("search_results", "POST", '', FALSE,
+ array("SearchType"=>"simple")));
printLine(textField("inputKeywords", "", 12), 1, FALSE);
print(getSubmit(L_NAV_SIDE_SEARCH));
endForm();
1.8 +59 -4 freetrade/freetrade2/modules/screen/department
Index: department
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/screen/department,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- department 2001/10/26 20:47:33 1.7
+++ department 2001/10/27 00:07:19 1.8
@@ -2,12 +2,12 @@
/*
** File: department
** Description: show departments and items contained in them
- ** Version: $Revision: 1.7 $
+ ** Version: $Revision: 1.8 $
** Created: 04/22/1999
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:33 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
*/
//get item functions, getDepartmentItemList()
@@ -16,6 +16,15 @@
// getDepartmentChildren()
include_once(DATABASE_MODULE . "department");
+ //the department variable can be an integer or the
+ //name of the department. The latter method won't
+ //work well if you have two department with the same
+ //name, of course. :) This bit of code looks up
+ //the department ID if necessary.
+ if(intval($department) <= 0)
+ {
+ $department = getDepartmentID($department);
+ }
//show sub-departments
if (! ($Departments = getDepartmentChildren($department)) )
@@ -27,6 +36,16 @@
for ($i = 0; $i < $Departments["NumRows"]; $i++)
{
+ //If using named departments, your URLs will look like
+ //department=Kitchenware instead of department=14
+ if(USE_NAMED_DEPARTMENTS)
+ {
+ $id = $Departments["Name"][$i];
+ }
+ else
+ {
+ $id = $Departments["ID"][$i];
+ }
//If the image is available, show it and make it link to the department
if(($Departments["Graphic"][$i]) AND
@@ -36,12 +55,12 @@
$image = getImage($Departments["Graphic"][$i], $size[0],
$size[1], "", 5, "left");
printLink($image, "department", 0,
- array("department"=>$Departments["ID"][$i]));
+ array("department"=>$id));
}
//Make a level-2 header with the name of the department link to it
printLink(getHeader($Departments["Name"][$i],2),
- "department", 0, array("department"=>$Departments["ID"][$i]));
+ "department", 0, array("department"=>$id));
printLine($Departments["Description"][$i], 2, TRUE, TRUE);
}
@@ -57,18 +76,54 @@
for ($i = 0; $i < $Items["NumRows"]; $i++)
{
+ //If using named items, your URLs will look like
+ //item=Blender instead of item=33
+ if(USE_NAMED_ITEMS)
+ {
+ $id = $Items["Name"][$i];
+ }
+ else
+ {
+ $id = $Items["ID"][$i];
+ }
+
if($Items["Thumbnail"][$i])
{
$size = getimagesize(IMAGES_DIR . "/" .
$Items["Thumbnail"][$i]);
$image = getImage($Items["Thumbnail"][$i], $size[0], $size[1],
"", 5, "left");
- printLink($image, "item", 0, array("item"=>$Items["ID"][$i]));
+ printLink($image, "item", 0, array("item"=>$id));
}
//Make a level-2 header with the name of the department link to it
printLink(getHeader($Items["Name"][$i],2),
- "item", 0, array("item"=>$Items["ID"][$i]));
+ "item", 0, array("department"=>$department, "item"=>$id));
printLine("", 2, TRUE, TRUE);
+ }
+
+ //Add link for returning to the parent department
+ if($department > 0)
+ {
+ $d = getDepartment($department);
+ if($d["Parent"] > 0)
+ {
+ $p = getDepartment($d["Parent"]);
+ }
+ else
+ {
+ $p["Name"] = "top";
+ }
+
+ if(USE_NAMED_DEPARTMENTS)
+ {
+ $id = $p["Name"];
+ }
+ else
+ {
+ $id = $d["Parent"];
+ }
+ printLink("Return to " . $p["Name"] . " Department", "department", 1,
+ array("department"=>$id));
}
?>
1.10 +35 -3 freetrade/freetrade2/modules/screen/item
Index: item
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/screen/item,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- item 2001/10/26 20:47:33 1.9
+++ item 2001/10/27 00:07:19 1.10
@@ -3,21 +3,36 @@
/*
** File: item
** Description: show details about an item
- ** Version: $Revision: 1.9 $
+ ** Version: $Revision: 1.10 $
** Created: 04/22/1999
** Author: Leon Atkinson, Shannon -jj Behrens,
** Email: [EMAIL PROTECTED], [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:33 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
*/
//get attribute functions
include_once(DATABASE_MODULE . "attribute");
-
include_once(DATABASE_MODULE . "item");
+ include_once(DATABASE_MODULE . "department");
+
+
+ //the department and item variables can be integers or
+ //names. The latter method won't work well if you have
+ //two departments (or items) with the same
+ //name, of course. :) This bit of code looks up
+ //the department ID if necessary.
+ if(intval($department) <= 0)
+ {
+ $department = getDepartmentID($department);
+ }
- //make sure we have a number, even if it's zero
- $department = intval($department);
+ //To help with duplicate item names, we'll pass the department
+ //ID, which probably uniquely identifies the item.
+ if(intval($item, $department) <= 0)
+ {
+ $item = getItemID($item);
+ }
function showRelationship($Item, $relationship, $description)
@@ -237,4 +252,21 @@
showRelationship($Item, 'Accessory', "Accessories:");
+ if($department > 0)
+ {
+ $d = getDepartment($department);
+
+ if(USE_NAMED_DEPARTMENTS)
+ {
+ $id = $d["Name"];
+ }
+ else
+ {
+ $id = $department;
+ }
+
+ printLine('');
+ printLink("Return to " . $d["Name"] . " Department", "department", 1,
+ array("department"=>$id));
+ }
?>
1.7 +23 -4 freetrade/freetrade2/modules/screen/quick_order
Index: quick_order
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/screen/quick_order,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- quick_order 2001/10/24 00:30:02 1.6
+++ quick_order 2001/10/27 00:07:19 1.7
@@ -4,12 +4,12 @@
** Description: list all SKUs organized by department and item, allow
** user to add any to basket. If a SKU has variations, then the user
** will be redirected to the item page in order to pick a variation.
- ** Version: $Revision: 1.6 $
+ ** Version: $Revision: 1.7 $
** Created: 08/09/1999
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/24 00:30:02 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
*/
//get item functions
@@ -56,10 +56,29 @@
$image = getImage($Item["Thumbnail"], $size[0], $size[1], "",
5, "left");
$label = $image . $Item["Name"]. ": " . $sku["Name"];
+ //has multi variations, so we have to go to the item page
if(count(getMultiAttributes($sku["ID"])))
{
- //has multi variations, so we have to go to the item
page
- $link = getLink($label, "item",
array("item"=>$itemInfo["ID"]));
+ if(USE_NAMED_DEPARTMENTS)
+ {
+ $deptID = $itemInfo["Department_Name"];
+ }
+ else
+ {
+ $deptID = $itemInfo["Department"];
+ }
+
+ if(USE_NAMED_ITEMS)
+ {
+ $itemID = $Item["Name"];
+ }
+ else
+ {
+ $itemID = $itemInfo["ID"];
+ }
+
+ $link = getLink($label, "item",
+ array("department"=>$deptID, "item"=>$itemID));
}
else
{
1.6 +35 -9 freetrade/freetrade2/modules/screen/search_results
Index: search_results
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/screen/search_results,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- search_results 2001/10/26 20:47:33 1.5
+++ search_results 2001/10/27 00:07:19 1.6
@@ -2,12 +2,12 @@
/*
** File: search_results
** Description: results of a search
- ** Version: $Revision: 1.5 $
+ ** Version: $Revision: 1.6 $
** Created: 06/10/1999
** Author: Leon Atkinson, Shannon -jj Behrens
** Email: [EMAIL PROTECTED], [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:33 $
+ ** Last Revised: $Date: 2001/10/27 00:07:19 $
**
*/
@@ -39,14 +39,41 @@
** Description: Once a matching item has been found, you may call this
** function to output the matching item's details.
*/
- function outputMatch($itemID, $itemName, $itemDescription,
- $itemThumbnail="")
+ function outputMatch($item)
{
- $size = getimagesize(IMAGES_DIR . "/" . $itemThumbnail);
- $image = getImage($itemThumbnail, $size[0], $size[1], "", 5, "left");
- $label = $image . getHeader($itemName, 2);
- printLink($label, "item", 0, array("item"=>$itemID));
- printLine($itemDescription, 1, FALSE, TRUE);
+ $label = getHeader($i["Name"], 2);
+
+ if($item["Thumbnail"] != "")
+ {
+
+ $size = getimagesize(IMAGES_DIR . "/" .
+ ITEM_IMAGES_DIR . "/" . $item["Thumbnail"]);
+ $image = getImage(ITEM_IMAGES_DIR . "/" . $item["Thumbnail"],
+ $size[0], $size[1], "", 5, "left");
+ $label = $image . $label;
+ }
+
+ if(USE_NAMED_DEPARTMENTS)
+ {
+ $deptID = $item["Department_Name"];
+ }
+ else
+ {
+ $deptID = $item["Department"];
+ }
+
+ if(USE_NAMED_ITEMS)
+ {
+ $itemID = $item["Name"];
+ }
+ else
+ {
+ $itemID = $item["ID"];
+ }
+
+ printLink($label, "item", 0,
+ array("department"=>$deptID, "item"=>$itemID));
+ printLine($item["Description"], 1, FALSE, TRUE);
}
@@ -111,8 +138,7 @@
$MatchedSomething = TRUE;
- outputMatch($i["ID"], $i["Name"], $i["Description"],
- ITEM_IMAGES_DIR . "/" . $i["Thumbnail"]);
+ outputMatch($i);
}
}
1.22 +11 -11 freetrade/freetrade2/modules/utility/standard_library
Index: standard_library
===================================================================
RCS file: /home/cvs/freetrade/freetrade2/modules/utility/standard_library,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- standard_library 2001/10/26 20:47:34 1.21
+++ standard_library 2001/10/27 00:07:20 1.22
@@ -6,12 +6,12 @@
** 75% of all page views. Most of these functions were in global_settings
** at one time.
**
- ** Version: $Revision: 1.21 $
+ ** Version: $Revision: 1.22 $
** Created: 10/4/99
** Author: Leon Atkinson
** Email: [EMAIL PROTECTED]
** CVS Author: $Author: leon $
- ** Last Revised: $Date: 2001/10/26 20:47:34 $
+ ** Last Revised: $Date: 2001/10/27 00:07:20 $
*/
@@ -275,28 +275,28 @@
/*
** opening form tag
*/
- $FormHead = "<FORM ACTION=\"$URL\" ";
- $FormHead .= "METHOD=\"$method\" ";
+ $FormHead = "<form action=\"$URL\" ";
+ $FormHead .= "method=\"$method\" ";
if($windowName != '')
{
- $FormHead .= "TARGET=\"$windowName\" ";
+ $FormHead .= "target=\"$windowName\" ";
}
if($encodingType != '')
{
- $FormHead .= "ENCTYPE=\"$encodingType\" ";
+ $FormHead .= "enctype=\"$encodingType\" ";
}
if($formName != '')
{
- $FormHead .= "NAME=\"$formName\" ";
+ $FormHead .= "name=\"$formName\" ";
}
if($onReset != '')
{
- $FormHead .= "ONRESET=\"$onReset\" ";
+ $FormHead .= "onreset=\"$onReset\" ";
}
if($onSubmit != '')
{
- $FormHead .= "ONSUBMIT=\"$onSubmit\" ";
+ $FormHead .= "onsubmit=\"$onSubmit\" ";
}
$FormHead .= ">\n";
@@ -306,21 +306,21 @@
*/
if((!USE_COOKIES) OR (!COOKIE_FOUND))
{
- $FormHead .= "<INPUT TYPE=\"hidden\" NAME=\"sid\"
VALUE=\"$sid\">\n";
+ $FormHead .= "<input type=\"hidden\" name=\"sid\"
value=\"$sid\">\n";
}
/*
** SCREEN
*/
- $FormHead .= "<INPUT TYPE=\"hidden\" NAME=\"SCREEN\"
VALUE=\"$screen\">\n";
+ $FormHead .= "<input type=\"hidden\" name=\"SCREEN\"
value=\"$screen\">\n";
/*
** ACTION
*/
if($action != '')
{
- $FormHead .= "<INPUT TYPE=\"hidden\" NAME=\"ACTION\"
VALUE=\"$action\">\n";
+ $FormHead .= "<input type=\"hidden\" name=\"ACTION\"
value=\"$action\">\n";
}
/*
@@ -330,7 +330,7 @@
{
for(reset($extra); $key=key($extra); next($extra))
{
- $FormHead .= "<INPUT TYPE=\"hidden\" NAME=\"$key\"
VALUE=\"";
+ $FormHead .= "<input type=\"hidden\" name=\"$key\"
value=\"";
$FormHead .= prepareText($extra[$key]) . "\">\n";
}
}
_______________________________________________
FreeTrade-dev mailing list
[EMAIL PROTECTED]
http://share.whichever.com/mailman/listinfo/freetrade-dev