/** * Handles bubbled events. * This method mainly translate certain command events into * wizard-specific events. * @param mixed sender of the original command event * @param TEventParameter event parameter * @throws TInvalidDataValueException if a navigation command is associated with an invalid parameter */ public function bubbleEvent($sender, $param) { if ($param instanceof \Prado\Web\UI\TCommandEventParameter) { $command = $param->getCommandName(); if (strcasecmp($command, self::CMD_CANCEL) === 0) { $this->onCancelButtonClick($param); return true; } $type = $this->getStepType($this->getActiveStep()); $index = $this->getActiveStepIndex(); $navParam = new TWizardNavigationEventParameter($index); if ($sender instanceof \Prado\Web\UI\IButtonControl && $sender->getCausesValidation() && ($page = $this->getPage()) !== null && !$page->getIsValid()) { $navParam->setCancelNavigation(true); } $handled = false; $movePrev = false; $this->_activeStepIndexSet = false; if (strcasecmp($command, self::CMD_NEXT) === 0) { if ($type !== self::ST_START && $type !== self::ST_STEP) { throw new TInvalidDataValueException('wizard_command_invalid', self::CMD_NEXT); } if ($index < $this->getWizardSteps()->getCount() - 1) { $navParam->setNextStepIndex($index + 1); } $this->onNextButtonClick($navParam); $handled = true; } else { if (strcasecmp($command, self::CMD_PREVIOUS) === 0) { if ($type !== self::ST_FINISH && $type !== self::ST_STEP) { throw new TInvalidDataValueException('wizard_command_invalid', self::CMD_PREVIOUS); } $movePrev = true; if (($prevIndex = $this->getPreviousStepIndex(false)) >= 0) { $navParam->setNextStepIndex($prevIndex); } $this->onPreviousButtonClick($navParam); $handled = true; } else { if (strcasecmp($command, self::CMD_COMPLETE) === 0) { if ($type !== self::ST_FINISH) { throw new TInvalidDataValueException('wizard_command_invalid', self::CMD_COMPLETE); } if ($index < $this->getWizardSteps()->getCount() - 1) { $navParam->setNextStepIndex($index + 1); } $this->onCompleteButtonClick($navParam); $handled = true; } else { if (strcasecmp($command, self::CMD_MOVETO) === 0) { if ($this->_cancelNavigation) { // may be set in onSideBarButtonClick $navParam->setCancelNavigation(true); } $requestedStep = $param->getCommandParameter(); if (!is_numeric($requestedStep)) { $requestedIndex = -1; foreach ($this->getWizardSteps() as $index => $step) { if ($step->getId() === $requestedStep) { $requestedIndex = $index; break; } } if ($requestedIndex < 0) { throw new TConfigurationException('wizard_step_invalid'); } } else { $requestedIndex = TPropertyValue::ensureInteger($requestedStep); } $navParam->setNextStepIndex($requestedIndex); $handled = true; } } } } if ($handled) { if (!$navParam->getCancelNavigation()) { $nextStepIndex = $navParam->getNextStepIndex(); if (!$this->_activeStepIndexSet && $this->allowNavigationToStep($nextStepIndex)) { if ($movePrev) { $this->getPreviousStepIndex(true); } // pop out the previous move from history $this->setActiveStepIndex($nextStepIndex); } } else { $this->setActiveStepIndex($index); } return true; } } return false; }