Пример #1
0
 /**
  * @return TestPage
  */
 public static function getPage3()
 {
     $tp = new TestPage();
     $tp->setProjectPath("/../pages/page3/mysite");
     $tp->setConfig(new SiteConfig("page3", realpath(__DIR__ . $tp->projectpath)));
     $tp->setSSpage(new SilverstripePage($tp->config));
     return $tp;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Text', array(new ReadonlyField('Readonly', 'ReadonlyField'), new TextareaField('Textarea', 'TextareaField - 8 rows', 8), new TextField('Text', 'TextField'), new HtmlEditorField('HTMLField', 'HtmlEditorField'), new EmailField('Email', 'EmailField'), new PasswordField('Password', 'PasswordField'), new AjaxUniqueTextField('AjaxUniqueText', 'AjaxUniqueTextField', 'AjaxUniqueText', 'BasicFieldsTestPage')));
     $fields->addFieldsToTab('Root.Numeric', array(new NumericField('Number', 'NumericField'), new CurrencyField('Price', 'CurrencyField'), new PhoneNumberField('PhoneNumber', 'PhoneNumberField'), new CreditCardField('CreditCard', 'CreditCardField')));
     $fields->addFieldsToTab('Root.Option', array(new CheckboxField('Checkbox', 'CheckboxField'), new CheckboxSetField('CheckboxSet', 'CheckboxSetField', TestCategory::map()), new DropdownField('DropdownID', 'DropdownField', TestCategory::map()), new GroupedDropdownField('GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map())), new ListboxField('ListboxFieldID', 'ListboxField', TestCategory::map(), array(), 3), new OptionsetField('OptionSetID', 'OptionSetField', TestCategory::map())));
     // All these date/time fields generally have issues saving directly in the CMS
     $fields->addFieldsToTab('Root.DateTime', array($calendarDateField = new DateField('CalendarDate', 'DateField with calendar'), new DateField('Date', 'DateField'), $dmyDateField = new DateField('DMYDate', 'DateField with separate fields'), new TimeField('Time', 'TimeField'), $timeFieldDropdown = new TimeField('TimeDropdown', 'TimeField with dropdown'), new DatetimeField('DateTime', 'DateTime'), $dateTimeShowCalendar = new DatetimeField('DateTimeWithCalendar', 'DateTime with calendar')));
     $calendarDateField->setConfig('showcalendar', true);
     $dmyDateField->setConfig('dmyfields', true);
     $timeFieldDropdown->setConfig('showdropdown', true);
     $dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
     $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
     $fields->addFieldsToTab('Root.File', array(UploadField::create('File', 'FileUploadField'), UploadField::create('Image', 'ImageUploadField'), UploadField::create('HasManyFiles', 'HasManyFilesUploadField'), UploadField::create('ManyManyFiles', 'ManyManyFilesUploadField')));
     $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
     foreach ($tabs as $tab) {
         $tabObj = $fields->fieldByName($tab);
         foreach ($tabObj->FieldList() as $field) {
             $disabledField = $field->performDisabledTransformation();
             $disabledField->setTitle($disabledField->Title() . ' (disabled)');
             $disabledField->setName($disabledField->getName() . '_disabled');
             $tabObj->insertAfter($disabledField, $field->getName());
             $readonlyField = $field->performReadonlyTransformation();
             $readonlyField->setTitle($readonlyField->Title() . ' (readonly)');
             $readonlyField->setName($readonlyField->getName() . '_readonly');
             $tabObj->insertAfter($readonlyField, $field->getName());
         }
     }
     $fields->addFieldToTab('Root.Text', new TextField('Text_NoLabel', false, 'TextField without label'), 'Text_disabled');
     return $fields;
 }
 public function validate()
 {
     $result = parent::validate();
     if (!$this->Validated || $this->Validated < 1 || $this->Validated > 3) {
         $result->error('"Validated" field needs to be between 1 and 3');
     }
     return $result;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $tf = new TableListField('CompaniesTF', 'Company');
     $tf->setShowPagination(true);
     $ctf = new ComplexTableField($this, 'CompaniesCTF', 'Company');
     $fields->addFieldsToTab('Root.Fields', array($tf, $ctf));
     return $fields;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab('Root.Tree', array(TreeDropdownField::create('HasOnePage', 'HasOnePage', 'SiteTree'), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)));
     //		$fields->addFieldToTab("Root.Tests.ComplexTableField",
     //			new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     //		$fields->addFieldToTab("Root.Tests.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     return $fields;
 }
Пример #6
0
 public function testPage3()
 {
     $tp = TestPage::getPage3();
     $sspage = $tp->getSSpage();
     $projpath = $tp->getProjectPath();
     $this->assertEquals('3.1.10', $sspage->getVersion());
     $this->assertFalse($sspage->hasDefaultAdmin());
     $this->assertFalse($sspage->hasEmailLogging());
     $this->assertEquals('live', $sspage->getEnvironmentType());
     $this->assertEquals(realpath(__DIR__ . '/pages/' . $projpath . '/_config.php'), $sspage->getConfigPhpPath());
     $this->assertEquals(realpath(__DIR__ . '/pages/' . $projpath . '/_config/config.yml'), $sspage->getConfigYmlPath());
     $this->assertFalse($sspage->hasModule("/proj/"));
 }
Пример #7
0
 public function testFilterPagesByEnvironmentType()
 {
     $pages = array(TestPage::getPage1()->getSSpage(), TestPage::getPage2()->getSSpage(), TestPage::getPage3()->getSSpage());
     $filtered = Util::filterPagesByEnvironmentType($pages, "dev");
     /* @var $filtered \Selim\SilverstripePage[] */
     $this->assertCount(1, $filtered);
     $this->assertEquals($filtered[0]->getName(), "page1");
     $filtered = Util::filterPagesByEnvironmentType($pages, "test");
     $this->assertCount(0, $filtered);
     $filtered = Util::filterPagesByEnvironmentType($pages, "live");
     $this->assertEquals($filtered[0]->getName(), "page2");
     $this->assertEquals($filtered[1]->getName(), "page3");
     $this->assertCount(2, $filtered);
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $allFields = array();
     $checkboxFields = array(new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
     $allFields += $checkboxFields;
     $treeFields = array(TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'), TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true));
     $fields->addFieldsToTab('Root.Tree', $treeFields);
     $allFields += $treeFields;
     foreach ($allFields as $field) {
         $field->setDescription('This is <strong>bold</strong> help text')->addExtraClass('cms-help');
         // ->addExtraClass('cms-help cms-help-tooltip');
     }
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $grids = array();
     $config = new GridFieldConfig_RecordEditor();
     $grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
     $fields->addFieldToTab('Root.NoRelation', $grid);
     $grids[] = $grid;
     $config = new GridFieldConfig_RelationEditor();
     $grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config);
     $fields->addFieldToTab('Root.HasMany', $grid);
     $grids[] = $grid;
     $config = new GridFieldConfig_RelationEditor();
     $grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config);
     $fields->addFieldToTab('Root.ManyMany', $grid);
     $grids[] = $grid;
     foreach ($grids as $grid) {
         $grid->setDescription('This is <strong>bold</strong> help text');
         // ->addExtraClass('cms-description-tooltip');
     }
     return $fields;
 }
Пример #10
0
<?php

require_once dirname(__FILE__) . '/../anewt.lib.php';
anewt_include('page');
class TestPage extends AnewtPage
{
    function __construct()
    {
        parent::__construct();
        $this->set('blocks', array('header', 'main', 'footer'));
    }
    function build_header()
    {
        return ax_fragment(array(ax_p('Header line 1'), ax_p('Header line 2')));
    }
}
$p = new TestPage();
$p->title = 'Anewt Page test';
$p->default_block = 'main';
$p->add_stylesheet_href('1.css');
$p->add_stylesheet_href('2.css');
$p->add_stylesheet(ax_stylesheet_href('3.css'));
$p->add_stylesheet(ax_stylesheet_href_media('screen.css', 'screen'));
$p->add_stylesheet_href_media('print.css', 'print');
$p->add_javascript_content('function test() {alert("test");}');
$p->add_javascript_src('foo.js');
$p->append_to('main', ax_h1('Title'));
$p->append(ax_p('Test paragraph'));
$p->append(ax_p(ax_a_href('Click me!', 'javascript:test()')));
$p->append_to('footer', ax_p('This is the footer text'));
$p->flush();