Add the elements from the model to the bridge for the current step

@param \MUtil_Model_Bridge_FormBridgeInterface $bridge
@param \MUtil_Model_ModelAbstract $model
@param int $step The current step
488479
protected function addStepElementsFor(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, $step) {
        $this->displayHeader($bridge, $this->_('Survey replace'), 'h1');

        // If we don't copy answers, we skip step 2
        if ($this->formData['copy_answers'] == 0 && $step > 1) {
            $step = $step + 1;
        }

        // To prevent confusion we show a progressbar that jumps from 25% to 50% or 75%
        $element = $bridge->getForm()->createElement('html', 'progress');
        $bridge->addElement($element);
        $element->div(array('class' => 'progress', 'renderClosingTag' => true))->div('', array(
            'class'            => 'progress-bar',
            'style'            => 'width: ' . $step / $this->getStepCount() * 100 . '%;',
            'renderClosingTag' => true));

        switch ($step) {
            case 0:
            case 1:
                $this->addStepElementsForStep1($bridge, $model);
                break;

            case 2:
                $this->addStepElementsForStep2($bridge, $model);
                break;

            case 3:
                $this->addStepElementsForStep3($bridge, $model);
                break;

            default:
                $this->addStepElementsForStep4($bridge, $model);
                break;
        }

        return;
    }
33358
public function addChild(Step $step)
    {
        if (!$this->children->contains($step)) {
            $this->children->add($step);
            $step->setParent($this);
        }

        return $this;
    }
1077238
def add_bridge(self, bridge):
        
        for group in bridge.groups:
            self._groups[group.name] = group
1229356
public function apply(Builder $builder, Model $model)
    {
        if (!$this->hasVersionJoin($builder, $model->getVersionTable())) {
            $builder->join($model->getVersionTable(), function($join) use ($model) {
                $join->on($model->getQualifiedKeyName(), '=', $model->getQualifiedVersionKeyName());
                $join->on($model->getQualifiedVersionColumn(), '=', $model->getQualifiedLatestVersionColumn());
            });
        }

        $this->extend($builder);
    }
244350
protected function addStepFileImport(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
    {
        // Reset the data
        $this->_session->importData = null;

        $this->displayHeader($bridge, $this->_('Upload a track definition file.'), 'h3');

        $this->addItems($bridge, 'trackFile', 'gtr_id_track');

        $element = $bridge->getForm()->getElement('trackFile');

        if ($element instanceof \Zend_Form_Element_File) {
            if (file_exists($this->_session->localfile)) {
                unlink($this->_session->localfile);
            }
            // Now add the rename filter, the localfile is known only once after loadFormData() has run
            $element->addFilter(new \Zend_Filter_File_Rename(array(
                'target'    => $this->_session->localfile,
                'overwrite' => true
                )));

            $uploadFileName = $element->getFileName();

            // Download the data oon post with filename
            if ($this->request->isPost() && $uploadFileName && $element->isValid(null)) {
                // \MUtil_Echo::track($element->getFileName(), $element->getFileSize());
                if (!$element->receive()) {
                    throw new \MUtil_Model_ModelException(sprintf(
                        $this->_("Error retrieving file '%s'."),
                        $element->getFileName()
                        ));
                }

                $this->_session->importData = null;
                $this->_session->uploadFileName = basename($uploadFileName);
                // \MUtil_Echo::track($this->_session->uploadFileName);
            }
        }
    }
869252
public function findCurrentModelState(ModelInterface $model, $processName, $stepName = null)
    {
        return $this->repository->findLatestModelState(
            $model->getWorkflowIdentifier(),
            $processName,
            $stepName
        );
    }
856854
public function afterInsert($model, $id)
    {
        if ($this->weak) {
            return;
        }

        $this->save_buffer[$this->foreign_field] =
            isset($this->join) ? $this->join->id : $id;

        $persistence = $this->persistence ?:
            $this->owner->persistence;

        $this->id = $persistence->insert(
            $model,
            $this->save_buffer,
            $this->foreign_table
        );
    }
734868
protected function getFormFor($step)
    {
        $baseform = $this->createForm();
        if ($this->trackEngine &&
                ($step == 4) &&
                (\MUtil_Bootstrap::enabled() !== true) &&
                ($baseform instanceof \MUtil_Form)) {
            $model = $this->getModel();
            $table = new \MUtil_Html_DivFormElement();
            $table->setAsFormLayout($baseform);

            $baseform->setAttrib('class', $this->class);

            $bridge = $model->getBridgeFor('form', $baseform);

            $this->_items = null;
            $this->initItems();

            $this->addFormElementsFor($bridge, $model, $step);

            return $baseform;
        } else {
            return parent::getFormFor($step);
        }
    }
1145911
protected function setCurrentStep($step)
    {
        $this->session->CurrentStepID = $step->ID;
        $step->setForm($this);

        return $this->session->write();
    }
1017842
protected function addServiceToBridge(Bridge $bridge, $service = null)
    {
        // Add a service if necessary.
        if (! is_null($service)) {
            $bridge->usingService($service);
        }

        return $bridge;
    }
588027
public function apply(Builder $builder, Model $model)
    {
        $column = $model->getQualifiedPublishedAtColumn();

        $builder->where($column, '=', 1);

        $this->addWithDrafts($builder);
    }
350916
public function apply(Builder $builder, Model $model) {
    $subclassTypes = array_keys($model->getSingleTableTypeMap());

    if (!empty($subclassTypes) ) {
      $builder->whereIn($model->getQualifiedSingleTableTypeColumn(), $subclassTypes);
    }
  }
715152
public function setModel(\Illuminate\Database\Eloquent\Model $model) {
        $this->model = $model;
        if ($this->model instanceof ResourceInterface) {
            $this->enableAutoEagerLoading = true;
        }
    }
293140
protected function addStepRoundMatch(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
    {
        $this->displayHeader($bridge, $this->_('Match the current track rounds to import rounds.'), 'h3');

        // Load the import data form settings
        $import = $this->loadImportData();

        $this->addExistingRoundsToModel($import, $model);

        $rounds = $model->getColNames('existingRound');

        if ($rounds) {
            $this->addItems($bridge, $rounds);
        } else {
            $bridge->addHtml('existingRound')->pInfo($this->_('No rounds in current track.'));
        }
    }
1001814
public function apply(Builder $builder, Model $model)
    {
        $columns = $model->getQualifiedOrderByColumns();

        foreach ($columns as $column => $direction) {

            $builder->orderBy($column, $direction);
        }

        $this->addUnordered($builder);
    }
1340668
protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
    {
        $this->mailElements->setForm($bridge->getForm());
        $this->initItems();
        $this->addItems($bridge, 'gct_name');
        $this->addItems($bridge, 'gct_id_template', 'gct_target');
        $this->addItems($bridge, 'gct_code');

        $bridge->getForm()->getElement('gct_target')->setAttrib('onchange', 'this.form.submit()');

        $defaultTab = $this->project->getLocaleDefault();
        $this->mailElements->addFormTabs($bridge, 'gctt', 'active', $defaultTab, 'tabcolumn', 'gctt_lang', 'selectedTabElement', 'send_language');

        $config = array(
        'extraPlugins' => 'bbcode,availablefields',
        'toolbar' => array(
            array('Source','-','Undo','Redo'),
            array('Find','Replace','-','SelectAll','RemoveFormat'),
            array('Link', 'Unlink', 'Image', 'SpecialChar'),
            '/',
            array('Bold', 'Italic','Underline'),
            array('NumberedList','BulletedList','-','Blockquote'),
            array('Maximize'),
            array('availablefields')
            )
        );


        $mailfields = $this->mailer->getMailFields();
        foreach($mailfields as $field => $value) {
            $mailfields[$field] = utf8_encode($value);
        }
        $config['availablefields'] = $mailfields;


        $config['availablefieldsLabel'] = $this->_('Fields');
        $this->view->inlineScript()->prependScript("
            CKEditorConfig = ".\Zend_Json::encode($config).";
            ");

        $bridge->addFakeSubmit('preview', array('label' => $this->_('Preview')));

        $bridge->addElement($this->mailElements->createEmailElement('to', $this->_('To (test)'), false));
        $bridge->addElement($this->mailElements->createEmailElement('from', $this->_('From'), false));

        //$bridge->addRadio('send_language', array('label' => $this->_('Test language'), 'multiOptions' => ))
        $bridge->addHidden('send_language');
        $bridge->addFakeSubmit('sendtest', array('label' => $this->_('Send (test)')));

        $bridge->addElement($this->getSaveButton($bridge->getForm()));

        $bridge->addElement($this->mailElements->createPreviewHtmlElement($this->_('Preview HTML')));
        $bridge->addElement($this->mailElements->createPreviewTextElement($this->_('Preview Text')));
        $bridge->addHtml('available_fields', array('label' => $this->_('Available fields')));
    }
96693
protected function addStepFileCheck(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
    {
        if ($this->onStartStep() && $this->isNextClicked()) {
            return;
        }
        $this->nextDisabled = true;

        $this->displayHeader($bridge, $this->_('Checking the content of the file.'), 'h3');

        $batch = $this->getImportCheckBatch();
        $form  = $bridge->getForm();

        $batch->setFormId($form->getId());
        $batch->autoStart = true;

        // \MUtil_Registry_Source::$verbose = true;
        if ($batch->run($this->request)) {
            exit;
        }

        $element = $form->createElement('html', $batch->getId());

        if ($batch->isFinished()) {
            $this->nextDisabled = $batch->getCounter('import_errors');
            $batch->autoStart   = false;

            // Keep the filename after $batch->getMessages(true) cleared the previous
            $this->addMessage($batch->getMessages(true));
            if ($this->nextDisabled) {
                $element->pInfo($this->_('Import errors occurred!'));
            } else {
                $element->h3($this->_('Import checks OK!'));
                $element->pInfo($this->_('Click the "Next" button to continue.'));
            }
        } else {
            $element->setValue($batch->getPanel($this->view, $batch->getProgressPercentage() . '%'));
        }

        $form->activateJQuery();
        $form->addElement($element);
    }