UI - WizardClass and PageObjects
Posted: Fri Jul 20, 2007 4:19 am
Hi,
at the moment I'm working hard on a wizardClass, which should task easy creating wizard. Accordingly, a pageobject should arrange the pages width methods: iscurrent | show | is valid
And now a new newswizard, as a kind of wizardBase
At the moment there are no pageobjects, and I've no idea who to build them and set the interaction ...
Tahnks for some brainstorming
Greetz
Rupo
at the moment I'm working hard on a wizardClass, which should task easy creating wizard. Accordingly, a pageobject should arrange the pages width methods: iscurrent | show | is valid
Code: Select all
abstract class wizardBase
{
protected $pages = array();
protected $currentpage;
protected $numpages;
protected $_npwValidationCandidates=array();
public function __construct()
{
if (isset($_SESSION['wizard']))
$this->wSession=$_SESSION['wizard'];
}
protected function addCurrentPage($currentpage)
{
$this->currentpage=$currentpage;
$this->showPage($this->currentpage);
}
protected function addPageArray($page)
{
foreach ($page AS $item)
$this->pages[]=$item;
$this->numpages=count($this->pages);
}
protected function addValidationCandidatesArray($array)
{
for($i=1;$i<=count($array);$i++)
$this->_npwValidationCandidates[$i]=$array[$i];
print_r($this->_npwValidationCandidates);
}
protected function gotoNextPage()
{
if (($this->currentpage < $this->numpages) && ($this->currentpage != $this->numpages))
{
$this->currentpage+=1;
$this->showPage($this->currentpage);
}
else
{
echo "niemals!";
}
}
protected function gotoPreviousPage()
{
}
/**
* cancel Wizard
* @return unset wizard-session-array
**/
protected function cancel()
{
unset($this->wSession);
header("Location: index.php/Hauptseite");
}
public function finish()
{
}
/**
* generate ToolbarButtons as a function of currentpage & numpages
*@ return buttonArray
**/
function showButtons()
{
$buttons['cancel']='enabled';
/* disable prevButton on 1st page */
if ($this->currentpage == '1')
$buttons['prev']='disabled';
/* disablenextButton on last page */
if ($this->currentpage == $this->numpages)
{
$buttons['next']='disabled';
$buttons['finish']='enabled';
}
else
{
$buttons['next']='enabled';
$buttons['finish']='disabled';
}
return $this->buttons=$buttons;
}
public function showPage($_npwCurrentPage)
{
global $wgOut;
$wgOut->setPageTitle(wfMsg('editing', $this->mTitle->mTextform));
$this->showPageIntro($_npwCurrentPage);
$this->showPageBody($_npwCurrentPage);
$this->showPageToolbarButtons($_npwCurrentPage);
}
public function errorMesage($mess)
{
}
}Code: Select all
<?php
class newPageWizard
extends wizardBase
{
private $_npwCurrentPage = NULL;
private $_npwPageArray = array();
public $_npwValidationCandidates=array();
public function __construct()
{
global $wgRequest, $wgTitle;
$this->mTitle=&$wgTitle;
/*initialize currentpage , pageArray */
$_npwCurrentPage='1';
if ($wgRequest->getVal('page'))
$_npwCurrentPage=$wgRequest->getVal('page');
$_npwPageArray=array
(
"setTitle",
"selectCat",
"selectPattern",
"saveNews"
);
$_npwValidationCandidates[1]=array
(
"news_title",
"news_topic"
);
$this->initialize($_npwCurrentPage, $_npwPageArray,$_npwValidationCandidates);
if ($wgRequest->getVal('news_cancel'))
parent::cancel();
if ($wgRequest->getVal('button_next'))
parent::getNextCard();
}
private function initialize($_npwCurrentPage, $_npwPageArray, $_npwValidationCandidates)
{
$this->addCurrentPage($_npwCurrentPage);
$this->addPageArray($_npwPageArray);
$this->addValidationCandidatesArray($_npwValidationCandidates);
}Tahnks for some brainstorming
Greetz
Rupo