Page 1 of 1

UI - WizardClass and PageObjects

Posted: Fri Jul 20, 2007 4:19 am
by Rupo
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

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)
        {
        }

    }
And now a new newswizard, as a kind of wizardBase

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);
        }
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

Posted: Fri Jul 20, 2007 5:05 pm
by feyd
I'm having a tough time figuring out the meat of your post. What's the point of the thread?

Posted: Fri Jul 20, 2007 5:11 pm
by Benjamin
I think he wants to know how to build and interact with pageobjects.

Posted: Fri Jul 20, 2007 5:13 pm
by Rupo
Well,

creating a wizardBaseClass, which allows to create several wizards. Which means creating UI-guided steps, to do some jobs, for instance to add new news to a wiki system (4-steps: selTitle|selCat|selPattern|saveText)

Therefore its the job to create pageobjects of each step. But I've at the moment no idea how to build them and which informations these Objects should contain and finally how to place an interaction.

so long
Rupo

Posted: Fri Jul 20, 2007 5:36 pm
by Rupo
astions wrote:I think he wants to know how to build and interact with pageobjects.
that' wright ... some hints?