.
*
* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
* must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
*
* @copyright 2008-2009, KnowledgeTree Inc.
* @license GNU General Public License version 3
* @author KnowledgeTree Team
* @package Installer
* @version Version 0.1
*/
class stepAction {
/**
* Step class name
*
* @author KnowledgeTree Team
* @access protected
* @var string
*/
protected $stepName = '';
/**
* Step names for classes
*
* @author KnowledgeTree Team
* @access protected
* @var array
*/
protected $stepClassNames = array();
/**
* Flag if step needs confirmation
*
* @author KnowledgeTree Team
* @access protected
* @var boolean
*/
protected $displayConfirm = false;
/**
* Reference to session object
*
* @author KnowledgeTree Team
* @access protected
* @var object Session
*/
protected $session = null;
/**
* Reference to current step object
*
* @author KnowledgeTree Team
* @access protected
* @var object class Step
*/
protected $action = null;
/**
* Constructs step action object
*
* @author KnowledgeTree Team
* @access public
* @param string class name of the current step
*/
public function __construct($step) {
$this->stepName = $step;
}
/**
* Main control to handle the steps actions
*
* @author KnowledgeTree Team
* @param none
* @access public
* @return string
*/
public function doAction() {
if($this->stepName != '') {
$this->action = $this->createStep();
//secho $this->stepName;
$response = $this->action->doStep();
if($this->action->storeInSession()) { // Check if class values need to be stored in session
$this->loadStepToSession($this->stepName); // Send class to session
}
if ($response == 'error') {
$this->handleErrors(); // Send Errors to session
} else {
$this->clearErrors($this->stepName); // Send Errors to session
}
return $response;
} else {
die("Class Files Missing");
}
}
/**
* Instantiate a step.
*
* @author KnowledgeTree Team
* @param none
* @access public
* @return object Step
*/
public function createStep() {
require_once(STEP_DIR."{$this->stepName}.php");
$step_class = $this->makeCamelCase($this->stepName);
return new $step_class();
}
/**
* Converts string to camel case
*
* @author KnowledgeTree Team
* @param string
* @access public
* @return string
*/
public function makeCamelCase($str) {
$upper=ucwords($str);
$str=str_replace('_', '', $upper);
return $str;
}
/**
* Converts string to human readable heading
*
* @author KnowledgeTree Team
* @param string
* @access public
* @return string
*/
public function makeHeading($str) {
$str = str_replace('_', ' ', $str);
$str = ucwords($str);
return $str;
}
/**
* Sets steps class names in string format
*
* @author KnowledgeTree Team
* @param array
* @access public
* @return void
*/
public function setSteps($stepClassNames) {
$this->stepClassNames = $stepClassNames;
}
/**
* Sets steps in human readable string format
*
* @author KnowledgeTree Team
* @param array
* @access public
* @return void
*/
public function setStepNames($step_names) {
$this->step_names = $step_names;
}
/**
* Returns a message to display at the top of template
*
* @author KnowledgeTree Team
* @param none
* @access public
* @return string
*/
public function getTop() {
return ''.$this->getCurrentStepName().'';
}
/**
* Returns current step name
*
* @author KnowledgeTree Team
* @param none
* @access public
* @return string
*/
function getCurrentStepName() {
return$this->step_names[$this->stepName];
}
/**
* Returns left menu
*
* @author KnowledgeTree Team
* @param none
* @access public
* @return string
*/
public function getLeftMenu()
{
if($this->stepName == 'welcome'){
return '
';
}
$menu = '