Prev | Current Page 425 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

php in the presentation folder, and add
the following to it:
// Class that deals with products administration from a specific category
class AdminProducts
{
// Public variables available in smarty template
public $mProductsCount;
public $mProducts;
public $mErrorMessage;
CHAPTER 11 ?–  CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 322
public $mDepartmentId;
public $mCategoryId;
public $mCategoryName;
public $mLinkToDepartmentCategoriesAdmin;
public $mLinkToCategoryProductsAdmin;
// Private attributes
private $_mAction;
private $_mActionedProductId;
// Class constructor
public function __construct()
{
if (isset ($_GET['DepartmentId']))
$this->mDepartmentId = (int)$_GET['DepartmentId'];
else
trigger_error('DepartmentId not set');
if (isset ($_GET['CategoryId']))
$this->mCategoryId = (int)$_GET['CategoryId'];
else
trigger_error('CategoryId not set');
$category_details = Catalog::GetCategoryDetails($this->mCategoryId);
$this->mCategoryName = $category_details['name'];
foreach ($_POST as $key => $value)
// If a submit button was clicked ...
if (substr($key, 0, 6) == 'submit')
{
/* Get the position of the last '_' underscore from submit button name
e.g strtpos('submit_edit_prod_1', '_') is 17 */
$last_underscore = strrpos($key, '_');
/* Get the scope of submit button
(e.g 'edit_dep' from 'submit_edit_prod_1') */
$this->_mAction = substr($key, strlen('submit_'),
$last_underscore - strlen('submit_'));
/* Get the product id targeted by submit button
(the number at the end of submit button name)
e.


Pages:
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
noclegi hel tanie pensjonaty nad morzem Lokaty jednodniowe projekty domków letniskowych męskie skarpetki rowerowe