php in the presentation folder, and
add the following to it:
// Class that deals with categories admin
class AdminCategories
{
// Public variables available in smarty template
public $mCategoriesCount;
public $mCategories;
public $mErrorMessage;
public $mEditItem;
public $mDepartmentId;
public $mDepartmentName;
public $mLinkToDepartmentsAdmin;
public $mLinkToDepartmentCategoriesAdmin;
// Private members
private $_mAction;
private $_mActionedCategoryId;
// Class constructor
public function __construct()
{
if (isset ($_GET['DepartmentId']))
$this->mDepartmentId = (int)$_GET['DepartmentId'];
else
trigger_error('DepartmentId not set');
$department_details = Catalog::GetDepartmentDetails($this->mDepartmentId);
$this->mDepartmentName = $department_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_cat_1', '_') is 16 */
$last_underscore = strrpos($key, '_');
/* Get the scope of submit button
(e.g 'edit_cat' from 'submit_edit_cat_1') */
$this->_mAction = substr($key, strlen('submit_'),
$last_underscore - strlen('submit_'));
CHAPTER 10 ?– CATALOG ADMINISTRATION: DEPARTMENTS AND CATEGORIES 298
/* Get the category id targeted by submit button
(the number at the end of submit button name)
e.
Pages:
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418