public function VersionsForm()
    {
        $id = $this->currentPageID();
        $page = $this->getRecord($id);
        $versionsHtml = '';

        $action = $this->getRequest()->param('Action');
        $versionID = $this->getRequest()->param('VersionID');
        $otherVersionID = $this->getRequest()->param('OtherVersionID');

        $showUnpublishedChecked = 0;
        $compareModeChecked = ($action == "compare");

        if ($page) {
            $versions = $page->allVersions();
            $versionID = (!$versionID) ? $page->Version : $versionID;

            if ($versions) {
                foreach ($versions as $k => $version) {
                    $active = false;

                    if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                        $active = true;

                        if (!$version->WasPublished) {
                            $showUnpublishedChecked = 1;
                        }
                    }

                    $version->Active = ($active);
                }
            }

            $vd = new ViewableData();

            $versionsHtml = $vd->customise(array(
                'Versions' => $versions
            ))->renderWith($this->getTemplatesWithSuffix('_versions'));
        }

        $fields = new FieldList(
            new CheckboxField(
                'ShowUnpublished',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'),
                $showUnpublishedChecked
            ),
            new CheckboxField(
                'CompareMode',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'),
                $compareModeChecked
            ),
            new LiteralField('VersionsHtml', $versionsHtml),
            $hiddenID = new HiddenField('ID', false, "")
        );

        $form = Form::create(
            $this,
            'VersionsForm',
            $fields,
            new FieldList()
        )->setHTMLID('Form_VersionsForm');
        $form->loadDataFrom($this->getRequest()->requestVars());
        $hiddenID->setValue($id);
        $form->unsetValidator();

        $form
            ->addExtraClass('cms-versions-form') // placeholder, necessary for $.metadata() to work
            ->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))
            ->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));

        return $form;
    }
public function VersionsForm()
    {
        $id = $this->currentPageID();
        $page = $this->getRecord($id);
        $versionsHtml = '';

        $action = $this->getRequest()->param('Action');
        $versionID = $this->getRequest()->param('VersionID');
        $otherVersionID = $this->getRequest()->param('OtherVersionID');

        $showUnpublishedChecked = 0;
        $compareModeChecked = ($action == "compare");

        if ($page) {
            $versions = $page->allVersions();
            $versionID = (!$versionID) ? $page->Version : $versionID;

            if ($versions) {
                foreach ($versions as $k => $version) {
                    $active = false;

                    if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                        $active = true;

                        if (!$version->WasPublished) {
                            $showUnpublishedChecked = 1;
                        }
                    }

                    $version->Active = ($active);
                }
            }

            $vd = new ViewableData();

            $versionsHtml = $vd->customise(array(
                'Versions' => $versions
            ))->renderWith($this->getTemplatesWithSuffix('_versions'));
        }

        $fields = new FieldList(
            new CheckboxField(
                'ShowUnpublished',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'),
                $showUnpublishedChecked
            ),
            new CheckboxField(
                'CompareMode',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'),
                $compareModeChecked
            ),
            new LiteralField('VersionsHtml', $versionsHtml),
            $hiddenID = new HiddenField('ID', false, "")
        );

        $form = Form::create(
            $this,
            'VersionsForm',
            $fields,
            new FieldList()
        )->setHTMLID('Form_VersionsForm');
        $form->loadDataFrom($this->getRequest()->requestVars());
        $hiddenID->setValue($id);
        $form->unsetValidator();

        $form
            ->addExtraClass('cms-versions-form') // placeholder, necessary for $.metadata() to work
            ->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))
            ->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));

        return $form;
    }
public function VersionsForm ( ) { $ id = $ this -> currentPageID ( ) ; $ page = $ this -> getRecord ( $ id ) ; $ versionsHtml = '' ; $ action = $ this -> getRequest ( ) -> param ( 'Action' ) ; $ versionID = $ this -> getRequest ( ) -> param ( 'VersionID' ) ; $ otherVersionID = $ this -> getRequest ( ) -> param ( 'OtherVersionID' ) ; $ showUnpublishedChecked = 0 ; $ compareModeChecked = ( $ action == "compare" ) ; if ( $ page ) { $ versions = $ page -> allVersions ( ) ; $ versionID = ( ! $ versionID ) ? $ page -> Version : $ versionID ; if ( $ versions ) { foreach ( $ versions as $ k => $ version ) { $ active = false ; if ( $ version -> Version == $ versionID || $ version -> Version == $ otherVersionID ) { $ active = true ; if ( ! $ version -> WasPublished ) { $ showUnpublishedChecked = 1 ; } } $ version -> Active = ( $ active ) ; } } $ vd = new ViewableData ( ) ; $ versionsHtml = $ vd -> customise ( array ( 'Versions' => $ versions ) ) -> renderWith ( $ this -> getTemplatesWithSuffix ( '_versions' ) ) ; } $ fields = new FieldList ( new CheckboxField ( 'ShowUnpublished' , _t ( 'SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.SHOWUNPUBLISHED' , 'Show unpublished versions' ) , $ showUnpublishedChecked ) , new CheckboxField ( 'CompareMode' , _t ( 'SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.COMPAREMODE' , 'Compare mode (select two)' ) , $ compareModeChecked ) , new LiteralField ( 'VersionsHtml' , $ versionsHtml ) , $ hiddenID = new HiddenField ( 'ID' , false , "" ) ) ; $ form = Form :: create ( $ this , 'VersionsForm' , $ fields , new FieldList ( ) ) -> setHTMLID ( 'Form_VersionsForm' ) ; $ form -> loadDataFrom ( $ this -> getRequest ( ) -> requestVars ( ) ) ; $ hiddenID -> setValue ( $ id ) ; $ form -> unsetValidator ( ) ; $ form -> addExtraClass ( 'cms-versions-form' ) // placeholder, necessary for $.metadata() to work -> setAttribute ( 'data-link-tmpl-compare' , Controller :: join_links ( $ this -> Link ( 'compare' ) , '%s' , '%s' , '%s' ) ) -> setAttribute ( 'data-link-tmpl-show' , Controller :: join_links ( $ this -> Link ( 'show' ) , '%s' , '%s' ) ) ; return $ form ; }
Version select form. Main interface between selecting versions to view
and comparing multiple versions.

Because we can reload the page directly to a compare view (history/compare/1/2/3)
this form has to adapt to those parameters as well.

@return Form
Version select form . Main interface between selecting versions to view and comparing multiple versions .