Prev | Current Page 251 | Next

Emilian Balanescu and Cristian Darie

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

The Smarty design template file (products_list.tpl) contains the layout to be
used when displaying products, and its presentation object file (presentation/products_list.php) gets the
correct list of products to display.
The constructor in products_list.php (the ProductsList class) creates a new instance of the business tier
object (Catalog) and retrieves DepartmentId, CategoryId, and Page from the query string, casting them to
int as a security measure. These values are used to decide which products to display:
// Class constructor
public function __construct()
{
// Get DepartmentId from query string casting it to int
if (isset ($_GET['DepartmentId']))
$this->_mDepartmentId = (int)$_GET['DepartmentId'];
// Get CategoryId from query string casting it to int
if (isset ($_GET['CategoryId']))
$this->_mCategoryId = (int)$_GET['CategoryId'];
// Get Page number from query string casting it to int
if (isset ($_GET['Page']))
$this->mPage = (int)$_GET['Page'];
if ($this->mPage < 1)
trigger_error('Incorrect Page value');
}
The init() method, which continues the constructor??™s job, starts by retrieving the requested list of products. It
decides what method of the business tier to call by analyzing the $_mCategoryId and $_mDepartmentId
members (which, thanks to the constructor, represent the values of the CategoryId and DepartmentId query
string parameters).


Pages:
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
włosy strony Pozycjonowanie konta oszczędnościowe kratki ściekowe