<?php
/*
* Copyright (c) 2003 gencon Ltd, all rights reserved.
*
* This file is part of v-creator.
*
* v-creator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* v-creator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @ingroup VCmodules
* @brief Module for VCMaintenance utilities and helpers.
*
* $Revision: 1.2 $ $Date: 2005-09-26 10:22:34 $
*
* @author Andrew 'Diddymus' Rolfe
*
* This module is for use in conjunction with VCMaintenance and
* provides utility and convenience methods.
*
*/
class maintenance {
/**
* @brief Function to setup defines.
*
* When called this function sets up the following
* defines for use with the maintenance module:
*
* <DL>
* <DT>MAINTENANCE_RETRIEVE
* <DD>Can be used to set retrieve mode.
* <DT>MAINTENANCE_NEW
* <DD>Can be used to set new mode.
* <DT>MAINTENANCE_UPDATE
* <DD>Can be used to set update mode.
* <DT>MAINTENANCE_DELETE
* <DD>Can be used to set delete mode.
* <DT>MAINTENANCE_ADD
* <DD>Can be used to set add mode.
* </DL>
*
* Setting the current mode can be achieved by assigning one of these
* defines to VCMaintenance_mode. For example:
*
* @code
* |{VCMaintenance_mode=MAINTENANCE_RETRIEVE}|
* @endcode
*
* @static
*/
function defines() {
if (!defined("MAINTENANCE_RETRIEVE")) {
define('MAINTENANCE_RETRIEVE', "Retrieve");
define('MAINTENANCE_NEW', "New");
define('MAINTENANCE_UPDATE', "Update");
define('MAINTENANCE_DELETE', "Delete");
define('MAINTENANCE_ADD', "Add");
}
}
/**
* @brief Function to check current VCMaintenance_mode mode.
*
* This is a utility method to make the checking of VCMaintenance_mode
* using the COND tag simple. This can aid the conditioning of processing
* and displaying of information based on the mode the user is currently
* using. An example of using this method is:
*
* @code
* |{maintenance:defines}|
* |{maintenance:checkMode}|
* Current Mode is:
* |{COND:maintenance_mode_add}| Add |{CEND}|
* |{COND:maintenance_mode_delete}| Delete |{CEND}|
* |{COND:maintenance_mode_update}| Update |{CEND}|
* |{COND:maintenance_mode_new}| New |{CEND}|
* |{COND:maintenance_mode_retrieve}| Retrieve |{CEND}|
* |{COND:maintenance_mode_add_or_update}| Add or Update |{CEND}|
* @endcode
*
* This will display the simple message followed by the current
* mode. For example:
*
* @code
* Current Mode is: Add
* @endcode
*
* By placing text, form elements or links between the COND and CEND tags
* content can be tailored depending on the current mode. This can be used
* to create a single form, for example, capable of operating in different
* modes instead of having to have a form for each mode.
*
* @static
*/
function checkMode() {
global $VC_data;
$mode = '';
if (isset($VC_data['VCMaintenance_mode'])) {
$mode = strtoupper($VC_data['VCMaintenance_mode']);
}
$VC_data['maintenance_mode_add'] = ($mode === 'ADD');
$VC_data['maintenance_mode_delete'] = ($mode === 'DELETE');
$VC_data['maintenance_mode_update'] = ($mode === 'UPDATE');
$VC_data['maintenance_mode_new'] = ($mode === 'NEW');
$VC_data['maintenance_mode_retrieve'] = ($mode === 'RETRIEVE');
$VC_data['maintenance_mode_add_or_update'] =
($mode === 'ADD' || $mode === 'UPDATE');
}
}