[Typo3-shop] tt_prducts error message in Typo3.7
Franz Holzinger
franz at fholzinger.com
Wed Nov 10 13:17:20 CET 2004
Volker Graubaum schrieb:
> I think it`s a PHP/Windows thing. You have to be sure that functions and
> options are only one time in the class.
Hi Volker,
I am using the dummy-3.7.0.zip under Windows 2000.
I have compared the two files
S:\apachefriends\xampp\htdocs\shop\typo3conf\ext\tt_products\pi\class.tx_ttproducts.php
and
S:\apachefriends\xampp\htdocs\shop\typo3\ext\tt_products\pi\class.tx_ttproducts.php
There are a lot of differences, so I do not know which version I should
use. I always thought one file should only be a copy of the other.
Which documentation must I read for this?
Is it correct that only
S:\apachefriends\xampp\htdocs\shop\typo3conf\ext\tt_products\pi\class.tx_ttproducts.php
will be used? So I need to make changes here.
Line 84 of the error message:
// Internal: init():
var $templateCode=""; // In init(), set to the content of the
templateFile. Used by default in getBasket()
So why this error message?
"Fatal error: Cannot redeclare tx_ttproducts::$cObj in ... on line 84"
Franz
Here are the differences:
Comparer :
(<)S:\apachefriends\xampp\htdocs\shop\typo3\ext\tt_products\pi\class.tx_ttproducts.php
(65029 octets)
avec :
(>)S:\apachefriends\xampp\htdocs\shop\typo3conf\ext\tt_products\pi\class.tx_ttproducts.php
(66093 octets)
5,8c5,8
< * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY at typo3.com)
< * All rights reserved
< *
< * This script is part of the TYPO3 project. The TYPO3 project is
---
> * (c) 1999-2003 Kasper Skårhøj (kasper at typo3.com)
> * All rights reserved
> *
> * This script is part of the Typo3 project. The Typo3 project is
30c30
< * Creates a list of products for the shopping basket in TYPO3.
---
> * Creates a list of products for the shopping basket in Typo3.
37c37
< * @author Kasper Skårhøj <kasperYYYY at typo3.com>
---
> * @author Kasper Skårhøj <kasper at typo3.com>
84a84
> var $cObj=""; // Instance of class cObj, set in init()
102a103
> var $templateCode="";
136c138
< $this->tt_product_single = t3lib_div::_GET("tt_products");
---
> $this->tt_product_single = $GLOBALS["HTTP_GET_VARS"]["tt_products"];
224,225c226,227
< if (t3lib_div::_GP("tracking") || $admin) { // Tracking number must
be set
< $orderRow = $this->getOrderRecord("",t3lib_div::_GP("tracking"));
---
> if (t3lib_div::GPvar("tracking") || $admin) { // Tracking number
must be set
> $orderRow = $this->getOrderRecord("",t3lib_div::GPvar("tracking"));
255,259c257,261
< if (t3lib_div::_GP("products_info")) {
< $activity="products_info";
< } elseif (t3lib_div::_GP("products_payment")) {
< $activity="products_payment";
< } elseif (t3lib_div::_GP("products_finalize")) {
---
> if (t3lib_div::GPvar("products_info")) {
> $activity="products_info";
> } elseif (t3lib_div::GPvar("products_payment")) {
> $activity="products_payment";
> } elseif (t3lib_div::GPvar("products_finalize")) {
349,351c351,355
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_products',
'uid='.intval($this->tt_product_single).' AND pid IN
('.$this->pid_list.')'.$this->cObj->enableFields('tt_products'));
<
< if($this->config["displayCurrentRecord"] || $row =
$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
---
> $query = "SELECT * FROM tt_products WHERE
uid=".intval($this->tt_product_single)." AND pid IN
(".$this->pid_list.")".$this->cObj->enableFields("tt_products");
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
>
> if($this->config["displayCurrentRecord"] ||
$row=mysql_fetch_assoc($res)) {
363c367
< $wrappedSubpartArray["###LINK_ITEM###"]= array('<A
href="'.$this->getLinkUrl(t3lib_div::_GP("backPID")).'">','</A>');
---
> $wrappedSubpartArray["###LINK_ITEM###"]= array('<A
href="'.$this->getLinkUrl(t3lib_div::GPvar("backPID")).'">','</A>');
384,392c388,396
< $out=$this->cObj->substituteMarker($out, "###SWORDS###",
htmlspecialchars(t3lib_div::_GP("swords")));
< // Add to content
< $content.=$out;
< if (t3lib_div::_GP("swords")) {
< $where = $this->searchWhere(trim(t3lib_div::_GP("swords")));
< }
< }
< $begin_at=t3lib_div::intInRange(t3lib_div::_GP("begin_at"),0,100000);
< if (($theCode!="SEARCH" && !t3lib_div::_GP("swords")) || $where) {
---
> $out=$this->cObj->substituteMarker($out, "###SWORDS###",
htmlspecialchars(t3lib_div::GPvar("swords")));
> // Add to content
> $content.=$out;
> if (t3lib_div::GPvar("swords")) {
> $where = $this->searchWhere(trim(t3lib_div::GPvar("swords")));
> }
> }
>
$begin_at=t3lib_div::intInRange(t3lib_div::GPvar("begin_at"),0,100000);
> if (($theCode!="SEARCH" && !t3lib_div::GPvar("swords")) || $where) {
403,405c407,410
< $selectConf["selectFields"] = 'count(*)';
< $res = $this->cObj->exec_getQuery("tt_products",$selectConf);
< $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
---
> $query = eregi_replace("^[\t ]*SELECT.+FROM", "SELECT count(*)
FROM", $this->cObj->getQuery("tt_products",$selectConf));
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> $row = mysql_fetch_row($res);
412,420c417,425
< $selectConf['orderBy'] = 'pid,category,title';
< $selectConf['selectFields'] = '*';
< $selectConf['max'] = ($this->config['limit']+1);
< $selectConf['begin'] = $begin_at;
<
< $res = $this->cObj->exec_getQuery('tt_products',$selectConf);
<
< $productsArray=array();
< while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
---
> $selectConf["orderBy"] = "pid,category,title";
>
> $query = $this->cObj->getQuery("tt_products",$selectConf);
> $query.=" LIMIT ".$begin_at.",".($this->config["limit"]+1);
>
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> $productsArray=array();
> while($row=mysql_fetch_assoc($res)) {
552,554c557,561
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',
'tt_products_cat', '1=1'.$this->cObj->enableFields('tt_products_cat'));
< $this->categories = array();
< while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
---
> $query = "select * from tt_products_cat where
1=1".$this->cObj->enableFields("tt_products_cat");
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> $this->categories=array();
> while($row = mysql_fetch_assoc($res)) {
564,566c571,575
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('title,uid', 'pages',
'uid IN ('.$this->pid_list.')');
< $this->pageArray = array();
< while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
---
> $query="SELECT title,uid FROM pages WHERE uid IN(".$this->pid_list.")";
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> $this->pageArray=array();
> while($row=mysql_fetch_assoc($res)) {
574c583
< * $basket is the TYPO3 default shopping basket array from ses-data
---
> * $basket is the Typo3 default shopping basket array from ses-data
685c694
< $newId = 0;
---
> $newId=0;
689,710c698,715
< $advanceUid = 0;
< if ($this->conf["advanceOrderNumberWithInteger"]) {
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid',
'sys_products_orders', '', '', 'uid DESC', '1');
< list($prevUid) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
<
< $rndParts = explode(",",$this->conf["advanceOrderNumberWithInteger"]);
< $advanceUid =
$prevUid+t3lib_div::intInRange(rand(intval($rndParts[0]),intval($rndParts[1])),1);
< }
<
< $insertFields = array(
< 'pid' => $pid,
< 'tstamp' => time(),
< 'crdate' => time(),
< 'deleted' => 1
< );
< if ($advanceUid > 0) {
< $insertFields['uid'] = $advanceUid;
< }
<
< $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_products_orders',
$insertFields);
<
< $newId = $GLOBALS['TYPO3_DB']->sql_insert_id();
---
> $advanceUid=0;
> if ($this->conf["advanceOrderNumberWithInteger"]) {
> $query="SELECT uid FROM sys_products_orders ORDER BY uid DESC
LIMIT 1";
> $res = mysql(TYPO3_db,$query);
> list($prevUid) = mysql_fetch_row($res);
>
> $rndParts =
explode(",",$this->conf["advanceOrderNumberWithInteger"]);
>
$advanceUid=$prevUid+t3lib_div::intInRange(rand(intval($rndParts[0]),intval($rndParts[1])),1);
> #debug(array($prevUid,$advanceUid));
> }
> if ($advanceUid>0) {
> $query = "INSERT INTO sys_products_orders
(uid,pid,tstamp,crdate,deleted) values
(".$advanceUid.",".$pid.",".time().",".time().",1)";
> } else {
> $query = "INSERT INTO sys_products_orders
(pid,tstamp,crdate,deleted) values (".$pid.",".time().",".time().",1)";
> }
> $res = mysql(TYPO3_db,$query);
> $newId = mysql_insert_id();
> echo mysql_error();
724,725c729,732
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid',
'sys_products_orders', 'uid='.intval($orderUid).' AND deleted AND NOT
status'); // Checks if record exists, is marked deleted (all blank
orders are deleted by default) and is not finished.
< if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
---
> $query = "SELECT uid FROM sys_products_orders WHERE
uid=".$orderUid." AND deleted AND NOT status"; // Checks if record
exists, is marked deleted (all blank orders are deleted by default) and
is not finished.
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> if (!mysql_num_rows($res)) {
739,741c746,751
< function getOrderRecord($orderUid,$tracking='') {
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',
'sys_products_orders', ($tracking ?
'tracking_code="'.$GLOBALS['TYPO3_DB']->quoteStr($tracking,
'sys_products_orders').'"' : 'uid='.intval($orderUid)).' AND NOT deleted');
< return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
---
> function getOrderRecord($orderUid,$tracking="") {
> $selectClause= $tracking ? "tracking_code='".$tracking."'" :
"uid=".intval($orderUid);
> $query = "SELECT * FROM sys_products_orders WHERE ".$selectClause."
AND NOT deleted";
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> return mysql_fetch_assoc($res);
807c817,819
< $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_products_orders',
'uid='.intval($orderUid), $fieldsArray);
---
> $query="UPDATE sys_products_orders SET
".$this->getUpdateQuery($fieldsArray)." WHERE uid=".$orderUid;
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
815,816c827,829
<
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_products_orders_mm_tt_products',
'sys_products_orders_uid='.intval($orderUid));
<
---
> $query="DELETE FROM sys_products_orders_mm_tt_products WHERE
sys_products_orders_uid=".$orderUid;
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
820,826c833,839
< $insertFields = array(
< 'sys_products_orders_uid' => $orderUid,
< 'sys_products_orders_qty' => intval($itemInfo['count']),
< 'tt_products_uid' => intval($itemInfo['rec']['uid'])
< );
<
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_products_orders_mm_tt_products',
$insertFields);
< }
---
> // debug($itemInfo);
> $query="INSERT INTO sys_products_orders_mm_tt_products
(sys_products_orders_uid,sys_products_orders_qty,tt_products_uid) VALUES
('".$orderUid."','".intval($itemInfo["count"])."','".intval($itemInfo["rec"]["uid"])."')";
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> }
> // debug($this->calculatedBasket);
>
930,934c943,951
< * Generates a search where clause.
< */
< function searchWhere($sw) {
< $where=$this->cObj->searchWhere($sw, $this->searchFieldList,
'tt_products');
< return $where;
---
> * Takes an array with key/value pairs and returns it for use in an
UPDATE query.
> */
> function getUpdateQuery($Darray) {
> reset($Darray);
> $query=array();
> while(list($field,$data)=each($Darray)) {
> $query[]=$field."='".addslashes($data)."'";
> }
> return implode($query,",");
938,954c955,959
< * Returns a url for use in forms and links
< */
< function getLinkUrl($id="",$excludeList="") {
< $queryString=array();
< $queryString["id"] = ($id ? $id : $GLOBALS["TSFE"]->id);
< $queryString["type"]= $GLOBALS["TSFE"]->type ?
'type='.$GLOBALS["TSFE"]->type : "";
< $queryString["backPID"]= 'backPID='.$GLOBALS["TSFE"]->id;
< $queryString["begin_at"]= t3lib_div::_GP("begin_at") ?
'begin_at='.t3lib_div::_GP("begin_at") : "";
< $queryString["swords"]= t3lib_div::_GP("swords") ?
"swords=".rawurlencode(t3lib_div::_GP("swords")) : "";
<
< reset($queryString);
< while(list($key,$val)=each($queryString)) {
< if (!$val || ($excludeList && t3lib_div::inList($excludeList,$key))) {
< unset($queryString[$key]);
< }
< }
< return
$GLOBALS["TSFE"]->absRefPrefix.'index.php?'.implode($queryString,"&");
---
> * Generates a search where clause.
> */
> function searchWhere($sw) {
> $where=$this->cObj->searchWhere($sw,$this->searchFieldList);
> return $where;
958,961c963,979
< * Formatting a price
< */
< function priceFormat($double) {
< return
number_format($double,intval($this->conf["priceDec"]),$this->conf["priceDecPoint"],$this->conf["priceThousandPoint"]);
---
> * Returns a url for use in forms and links
> */
> function getLinkUrl($id="",$excludeList="") {
> $queryString=array();
> $queryString["id"] = ($id ? $id : $GLOBALS["TSFE"]->id);
> $queryString["type"]= $GLOBALS["TSFE"]->type ?
'type='.$GLOBALS["TSFE"]->type : "";
> $queryString["backPID"]= 'backPID='.$GLOBALS["TSFE"]->id;
> $queryString["begin_at"]= t3lib_div::GPvar("begin_at") ?
'begin_at='.t3lib_div::GPvar("begin_at") : "";
> $queryString["swords"]= t3lib_div::GPvar("swords") ?
"swords=".rawurlencode(stripslashes(t3lib_div::GPvar("swords"))) : "";
>
> reset($queryString);
> while(list($key,$val)=each($queryString)) {
> if (!$val || ($excludeList && t3lib_div::inList($excludeList,$key))) {
> unset($queryString[$key]);
> }
> }
> return
$GLOBALS["TSFE"]->absRefPrefix.'index.php?'.implode($queryString,"&");
965,973c983,986
< * Fills in all empty fields in the delivery info array
< */
< function mapPersonIntoToDelivery() {
< $infoFields =
explode(",","name,address,telephone,fax,email,company,city,zip,state,country");
< while(list(,$fName)=each($infoFields)) {
< if (!trim($this->deliveryInfo[$fName])) {
< $this->deliveryInfo[$fName] = $this->personInfo[$fName];
< }
< }
---
> * Formatting a price
> */
> function priceFormat($double) {
> return
number_format($double,intval($this->conf["priceDec"]),$this->conf["priceDecPoint"],$this->conf["priceThousandPoint"]);
977,986c990,996
< * Checks if required fields are filled in
< */
< function checkRequired() {
< $flag=1;
< if (trim($this->conf["requiredInfoFields"])) {
< $infoFields =
t3lib_div::trimExplode(",",$this->conf["requiredInfoFields"]);
< while(list(,$fName)=each($infoFields)) {
< if (!trim($this->personInfo[$fName])) {
< $flag=0;
< break;
---
> * Fills in all empty fields in the delivery info array
> */
> function mapPersonIntoToDelivery() {
> $infoFields =
explode(",","name,address,telephone,fax,email,company,city,zip,state,country");
> while(list(,$fName)=each($infoFields)) {
> if (!trim($this->deliveryInfo[$fName])) {
> $this->deliveryInfo[$fName] = $this->personInfo[$fName];
990a1000,1014
>
> /**
> * Checks if required fields are filled in
> */
> function checkRequired() {
> $flag=1;
> if (trim($this->conf["requiredInfoFields"])) {
> $infoFields =
t3lib_div::trimExplode(",",$this->conf["requiredInfoFields"]);
> while(list(,$fName)=each($infoFields)) {
> if (!trim($this->personInfo[$fName])) {
> $flag=0;
> break;
> }
> }
> }
1168,1174c1193,1201
< $this->calculatedBasket = array(); // array that holds the final
list of items, shipping and payment + total amounts
<
< // Get the products from the uid_list (initialized by the
initBasket function)
< $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_products',
'uid IN ('.$this->uid_list.') AND pid IN
('.$this->pid_list.')'.$this->cObj->enableFields('tt_products'));
< $productsArray = array();
< while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
< $productsArray[$row["pid"]][] = $row; // Fills this array with the
product records. Reason: Sorting them by category (based on the page,
they reside on)
---
> $this->calculatedBasket=array(); // array that holds the final
list of items, shipping and payment + total amounts
>
> // Get the products from the uid_list (initialized by the
initBasket function)
> $query = "SELECT * FROM tt_products WHERE uid IN
(".$this->uid_list.") AND pid IN
(".$this->pid_list.")".$this->cObj->enableFields("tt_products");
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> $productsArray=array();
> while($row=mysql_fetch_assoc($res)) {
> $productsArray[$row["pid"]][]=$row; // Fills this array with the
product records. Reason: Sorting them by category (based on the page,
they reside on)
1184,1186c1211,1213
< $t["basketFrameWork"] =
$this->cObj->substituteSubpart($t["basketFrameWork"],
"###BILLING_ADDRESS###", "");
< } else {
< $t["basketFrameWork"] =
$this->cObj->substituteSubpart($t["basketFrameWork"],
"###BILLING_ADDRESS_LOGIN###", "");
---
>
$t["basketFrameWork"]=$this->cObj->substituteSubpart($t["basketFrameWork"],
"###BILLING_ADDRESS###", "");
> } else {
>
$t["basketFrameWork"]=$this->cObj->substituteSubpart($t["basketFrameWork"],
"###BILLING_ADDRESS_LOGIN###", "");
1384c1411
< if (t3lib_div::_GP("update_code")==$this->conf["update_code"]) {
---
> if (t3lib_div::GPvar("update_code")==$this->conf["update_code"]) {
1417c1444
< $orderRecord = t3lib_div::_GP("orderRecord");
---
> $orderRecord = t3lib_div::GPvar("orderRecord");
1437,1440c1464,1467
< "comment" => $orderRecord["status_comment"]
< );
< if ($orderRow["email"] && $orderRow["email_notify"]) {
< $this->sendNotifyEmail($orderRow["email"], $status_log_element,
t3lib_div::_GP("tracking"),
$this->getOrderNumber($orderRow["uid"]),$templateCode);
---
> "comment" => stripslashes($orderRecord["status_comment"])
> );
> if ($orderRow["email"] && $orderRow["email_notify"]) {
> $this->sendNotifyEmail($orderRow["email"],
$status_log_element, t3lib_div::GPvar("tracking"),
$this->getOrderNumber($orderRow["uid"]),$templateCode);
1450,1455c1477,1484
<
< // Deletes any M-M relations between the tt_products table and
the order.
< // In the future this should maybe also automatically count
down the stock number of the product records. Else it doesn't make sense.
<
$GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_products_orders_mm_tt_products',
'sys_products_orders_uid='.intval($orderRow['uid']));
< }
< }
---
> // Deletes any M-M relations between the tt_products table and
the order.
> // In the future this should maybe also automatically count
down the stock number of the product records. Else it doesn't make sense.
> $query="DELETE FROM sys_products_orders_mm_tt_products WHERE
sys_products_orders_uid=".$orderRow["uid"];
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> }
> }
> // debug($fieldsArray);
1459,1462c1488,1492
< $fieldsArray["tstamp"] = time();
<
< $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_products_orders',
'uid='.intval($orderRow["uid"]), $fieldsArray);
<
---
> $fieldsArray["tstamp"]=time();
> $query="UPDATE sys_products_orders SET
".$this->getUpdateQuery($fieldsArray)." WHERE uid=".$orderRow["uid"];
> // debug($query);
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
1519,1520c1549,1552
< $res =
$GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,name,tracking_code,amount',
'sys_products_orders', 'NOT deleted AND status!=0 AND status<100', '',
'crdate');
< while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
---
> $query="SELECT uid,name,tracking_code,amount from
sys_products_orders WHERE NOT deleted AND status!=0 AND status<100 ORDER
BY crdate";
> $res = mysql(TYPO3_db,$query);
> echo mysql_error();
> while($row=mysql_fetch_assoc($res)) {
1532,1533c1564,1565
< $markerArray["###TRACKING_NUMBER###"] = t3lib_div::_GP("tracking");
< $markerArray["###UPDATE_CODE###"] = t3lib_div::_GP("update_code");
---
> $markerArray["###TRACKING_NUMBER###"] = t3lib_div::GPvar("tracking");
> $markerArray["###UPDATE_CODE###"] = t3lib_div::GPvar("update_code");
More information about the TYPO3-project-tt-products
mailing list