コード例 #1
0
 /**
  * Constructs a new step view
  * @param zibo\orm\builder\wizard\BuilderWizard $wizard
  */
 public function __construct(BuilderWizard $wizard, $fieldsAction)
 {
     parent::__construct(self::TEMPLATE);
     $modelTable = $wizard->getVariable(BuilderWizard::VARIABLE_MODEL_TABLE);
     $fields = $modelTable->getFields();
     $isFieldNameRequired = count($fields) <= 1;
     $this->set('wizard', $wizard);
     $this->set('isFieldNameRequired', $isFieldNameRequired);
     $this->addInlineJavascript('ziboOrmInitializeBuilderWizardField(' . ($isFieldNameRequired ? 'true' : 'false') . ', "' . $fieldsAction . '");');
 }
コード例 #2
0
 /**
  * Action to invoke the model wizard
  * @param string $action Name of the model to reset the wizard with, 'reset' to restart the wizard
  * @return null
  */
 public function indexAction($action = null, $actionArgument = null, $modelAction = null, $modelActionArgument = null)
 {
     $modelName = null;
     $fieldName = null;
     if ($action == self::ACTION_MODEL) {
         $modelName = $actionArgument;
         if ($modelAction == self::ACTION_FIELD) {
             if (!$modelActionArgument) {
                 $fieldName = true;
             } else {
                 $fieldName = $modelActionArgument;
             }
         }
     }
     $wizard = new BuilderWizard($this->request->getBasePath(), $modelName);
     if ($fieldName !== null) {
         $wizard->limitToField($fieldName);
     } elseif ($modelAction == self::ACTION_LIMIT) {
         switch ($modelActionArgument) {
             case BuilderWizard::LIMIT_MODEL:
                 $wizard->limitToModel();
                 break;
             case BuilderWizard::LIMIT_DATA_FORMAT:
                 $wizard->limitToDataFormats();
                 break;
             case BuilderWizard::LIMIT_INDEX:
                 $wizard->limitToIndex();
                 break;
         }
         $this->response->setRedirect($this->request->getBasePath());
         return;
     }
     $cancelUrl = $this->request->getBaseUrl() . '/' . Module::ROUTE_ADMIN;
     if (!$wizard->isNewModel()) {
         $modelTable = $wizard->getModelTable();
         $cancelUrl .= '/' . BuilderController::ACTION_DETAIL . '/' . $modelTable->getName();
     }
     $wizard->setCancelUrl($cancelUrl);
     if ($action == self::ACTION_RESET) {
         $wizard->reset();
         $this->response->setRedirect($this->request->getBasePath());
         return;
     }
     $wizard->invoke($this->request, $this->response);
     $view = $this->response->getView();
     if ($view instanceof HtmlView) {
         $view = new BuilderWizardView($view);
         $sidebar = $view->getSidebar();
         $sidebar->addPanel(new SidebarView($wizard));
         $sidebar->setInformation(self::TRANSLATION_INFORMATION, true);
     }
     $this->response->setView($view);
 }
コード例 #3
0
 /**
  * Construct a new model filter view
  * @param zibo\orm\builder\form\ModelFilterForm $filterForm
  * @return null
  */
 public function __construct(BuilderWizard $wizard)
 {
     parent::__construct(self::TEMPLATE);
     $translator = I18n::getInstance()->getTranslator();
     $modelTable = $wizard->getModelTable();
     $currentStep = $wizard->getCurrentStep();
     $steps = array();
     if ($modelTable) {
         $generalStep = $translator->translate(self::TRANSLATION_STEP_GENERAL_MODEL, array('model' => $modelTable->getName()));
     } else {
         $generalStep = $translator->translate(self::TRANSLATION_STEP_GENERAL);
     }
     $fieldNewStep = $translator->translate(self::TRANSLATION_STEP_FIELD_NEW);
     $dataFormatStep = $translator->translate(self::TRANSLATION_STEP_DATA_FORMAT);
     $indexStep = $translator->translate(self::TRANSLATION_STEP_INDEX);
     $finishStep = $translator->translate(self::TRANSLATION_STEP_FINISH);
     switch ($currentStep) {
         case ModelGeneralStep::NAME:
             $currentStep = $generalStep;
             break;
         case DataFormatStep::NAME:
             $currentStep = $dataFormatStep;
             break;
         case IndexStep::NAME:
             $currentStep = $indexStep;
             break;
         case FinishStep::NAME:
             $currentStep = $finishStep;
             break;
     }
     if ($wizard->isLimitedToModel()) {
         $steps[$generalStep] = false;
     } elseif ($wizard->isLimitedToDataFormats()) {
         $steps[$dataFormatStep] = false;
     } elseif ($wizard->isLimitedToIndex()) {
         $steps[$indexStep] = false;
     } else {
         $limitField = $wizard->getLimitField();
         if (!$limitField) {
             $steps[$generalStep] = false;
         }
         if ($limitField && $limitField !== true) {
             $step = $translator->translate(self::TRANSLATION_STEP_FIELD, array('field' => $limitField));
             if ($currentStep == FieldStep::NAME) {
                 $currentStep = $step;
             }
             $steps[$step] = false;
         } else {
             $isFieldStep = $currentStep == FieldStep::NAME;
             $currentFieldName = null;
             if ($isFieldStep) {
                 $currentFieldName = $wizard->getVariable(BuilderWizard::VARIABLE_FIELD);
                 $currentStep = null;
             }
             if ($modelTable) {
                 $fields = $modelTable->getFields();
                 foreach ($fields as $fieldName => $field) {
                     if ($fieldName == ModelTable::PRIMARY_KEY) {
                         continue;
                     }
                     $step = $translator->translate(self::TRANSLATION_STEP_FIELD, array('field' => $fieldName));
                     if ($fieldName == $currentFieldName) {
                         $currentStep = $step;
                     }
                     $steps[$step] = false;
                 }
             }
             if (!$currentStep) {
                 $currentStep = $fieldNewStep;
             }
             $steps[$fieldNewStep] = false;
         }
         if (!$limitField) {
             $steps[$dataFormatStep] = false;
             $steps[$indexStep] = false;
         }
     }
     $steps[$finishStep] = false;
     $this->set('currentStep', $currentStep);
     $this->set('steps', $steps);
 }