Changeset 333
- Timestamp:
- May 11, 2008 5:02:45 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/css/admin2.inc.css
r323 r333 74 74 width: 98%; 75 75 margin: 0 auto 10px; 76 background-color: # EEE;76 background-color: #fff; 77 77 border: 1px solid gray; 78 78 } … … 95 95 /* float: left; */ 96 96 width: 9em; 97 min-width: 9em; 97 98 margin: 0 0 10px 0; 98 99 padding: 0; … … 141 142 142 143 /*_____________________ CONTENT ____________________*/ 144 145 #content-table { 146 width: 100%; 147 } 148 143 149 #content { 144 150 /* width: 100%; */ -
trunk/lib/App.inc.php
r331 r333 1006 1006 1007 1007 /** 1008 * Return the URL set for the specified $id .1008 * Return the URL set for the specified $id, or an empty string if one isn't set. 1009 1009 * 1010 1010 * @param string $id An identification tag for this url. -
trunk/lib/Cart.inc.php
r317 r333 11 11 * Example of use: 12 12 --------------------------------------------------------------------- 13 ... 13 $cart = new Cart(); 14 15 switch (getFormData('op')) { 16 case 'add' : 17 // User clicks an "Add to cart" button. 18 if ($product_id = getFormData('product_id')) { 19 $qid = $db->query("SELECT * FROM product_tbl WHERE product_id = '" . $db->escapeString($product_id) . "'"); 20 if ($p = mysql_fetch_assoc($qid)) { 21 $cart->add($product_id, $p['price'], 1, array( 22 'title' => $p['title'], 23 'shipping' => $p['shipping'], 24 'weight' => $p['weight'], 25 )); 26 } 27 } 28 break; 29 30 case 'remove' : 31 // User clicks a "Remove item" button. 32 $cart->remove(getFormData('product_id')); 33 break; 34 35 case 'qty' : 36 // User changes the quantity of an item. 37 $cart->setQty(getFormData('product_id'), getFormData('qty')); 38 break; 39 40 case 'view' : 41 default : 42 // User views cart. 43 foreach ($cart->getList() as $item) { 44 printf("Item: %s\nQty: %s\nPrice: %s\n\n", $item['title'], $item['quantity'], $item['price']); 45 } 46 break; 47 } 14 48 --------------------------------------------------------------------- 15 49 */ … … 71 105 72 106 /* 73 * 107 * Add an item to the cart. If called twice for one item it will add the quantities together. 108 * 109 * @access public 110 * @param string $item_id A unique ID for the item 111 * @param float $price Price-per-quantity-unit for the item 112 * @param float $quantity Quantity of items (can be fractional unites?) 113 * @param array $specs An array of additional specifications (title, weight, etc) 114 * @return float The new adjusted quantity of this item. 115 * @author Quinn Comendant <quinn@strangecode.com> 116 * @version 1.0 117 * @since 11 Mar 2008 18:59:37 118 */ 119 function add($item_id, $price, $quantity=1, $specs=array()) 120 { 121 $app =& App::getInstance(); 122 123 // Include any previously added items in the total quantity. 124 $quantity += isset($_SESSION['_cart'][$this->_ns]['items'][$item_id]) ? $_SESSION['_cart'][$this->_ns]['items'][$item_id]['quantity'] : 0; 125 126 // Add item with adjusted quantity and merge in additional specs. 127 $_SESSION['_cart'][$this->_ns]['items'][$item_id] = array_merge($specs, array( 128 'quantity' => $quantity, 129 'price' => $price, 130 'extended_price' => $quantity * $price, 131 )); 132 133 $app->logMsg(sprintf('Added %s %s to cart (%s)', $quantity, $item_id, truncate(getDump($specs, true), 128, 'end')), LOG_DEBUG, __FILE__, __LINE__); 134 135 return $quantity; 136 } 137 138 /* 139 * Set the absolute quantity value of a specified item in a cart. 74 140 * 75 141 * @access public … … 78 144 * @author Quinn Comendant <quinn@strangecode.com> 79 145 * @version 1.0 80 * @since 11 Mar 2008 18:59:37 81 */ 82 function add($item_id, $quantity=1) 83 { 84 85 } 86 87 /* 88 * 89 * 90 * @access public 91 * @param 92 * @return 146 * @since 10 May 2008 16:42:25 147 */ 148 function setQty($item_id, $quantity) 149 { 150 if ($quantity <= 0) { 151 $this->remove($item_id); 152 } else { 153 if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id])) { 154 $item = $_SESSION['_cart'][$this->_ns]['items'][$item_id]; 155 $_SESSION['_cart'][$this->_ns]['items'][$item_id] = array_merge($item, array( 156 'quantity' => $quantity, 157 'extended_price' => $quantity * $item['price'], 158 )); 159 } 160 } 161 } 162 163 /* 164 * Remove an item from the cart. 165 * 166 * @access public 167 * @param string $item_id Item to remove from cart. 93 168 * @author Quinn Comendant <quinn@strangecode.com> 94 169 * @version 1.0 … … 97 172 function remove($item_id) 98 173 { 99 100 } 101 102 /* 103 * 104 * 105 * @access public 106 * @param 107 * @return 174 $app =& App::getInstance(); 175 176 if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id])) { 177 unset($_SESSION['_cart'][$this->_ns]['items'][$item_id]); 178 $app->logMsg(sprintf('Removed %s from cart', $item_id), LOG_DEBUG, __FILE__, __LINE__); 179 } 180 } 181 182 /* 183 * Return the value matching key for a specified item. 184 * 185 * @access public 186 * @param string $item_id The ID of the cart item to retrieve. 187 * @param string $spec_key The key of the value to return. 188 * @return mixed The value, or false if not found. 108 189 * @author Quinn Comendant <quinn@strangecode.com> 109 190 * @version 1.0 110 191 * @since 11 Mar 2008 18:59:55 111 192 */ 193 function get($item_id, $spec_key) 194 { 195 if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id][$spec_key])) { 196 return $_SESSION['_cart'][$this->_ns]['items'][$item_id][$spec_key]; 197 } 198 return false; 199 } 200 201 /* 202 * Return an array of the items in cart. 203 * 204 * @access public 205 * @return array Array of cart items. 206 * @author Quinn Comendant <quinn@strangecode.com> 207 * @version 1.0 208 * @since 11 Mar 2008 18:59:55 209 */ 112 210 function getList() 113 211 { 114 115 } 116 117 /* 118 * 119 * 120 * @access public 121 * @param 122 * @return 212 return $_SESSION['_cart'][$this->_ns]['items']; 213 } 214 215 /* 216 * Return the sum of the numeric values stored under the specified key for cart items. 217 * 0 will be returned if key is invalid or not filled with numeric values. 218 * 219 * @access public 220 * @param string $key The spec key to sum. 221 * @return float The total added by all the found values. 123 222 * @author Quinn Comendant <quinn@strangecode.com> 124 223 * @version 1.0 125 224 * @since 11 Mar 2008 19:00:12 126 225 */ 127 function getTotal() 128 { 129 226 function sum($key='extended_price') 227 { 228 switch ($key) { 229 case 'items' : 230 return sizeof($_SESSION['_cart'][$this->_ns]['items']); 231 232 default : 233 $sum = 0; 234 foreach ($_SESSION['_cart'][$this->_ns]['items'] as $item_id => $specs) { 235 $sum += isset($specs[$key]) && is_numeric($specs[$key]) ? $specs[$key] : 0; 236 } 237 return $sum; 238 } 130 239 } 131 240 -
trunk/lib/FormValidator.inc.php
r314 r333 163 163 if ($this->anyErrors()) { 164 164 ?><div class="sc-msg" id="sc-msg-formvalidator"><?php 165 $errors = $this->getErrorList(); 166 foreach ($errors as $e) { 165 foreach ($this->getErrorList() as $e) { 167 166 if ('' != $e['message'] && is_string($e['message'])) { 168 167 if (error_reporting() > 0 && $app->getParam('display_errors') && isset($e['file']) && isset($e['line'])) {
Note: See TracChangeset
for help on using the changeset viewer.