public function NewsIndex($strClass = '')
 {
     if ($strClass) {
         return NewsIndex::get()->filter('ClassName', $strClass)->first();
     }
     return NewsIndex::get()->first();
 }
 public function __construct($modelClass, $newsAdmin = null, $fields = null, $filters = null)
 {
     $fields = new FieldList(TextField::create('Title'), TextField::create('URLSegment'), DropdownField::create('ParentID', 'Parent page')->setSource(NewsIndex::get()->map('ID', 'Title')->toArray())->setEmptyString('Select'), HeaderField::create('DatesHeader', 'Dates')->setHeadingLevel(3), DateField::create('StartDate')->setTitle(null)->setAttribute('placeholder', 'Start Date'), DateField::create('EndDate')->setTitle(null)->setAttribute('placeholder', 'End Date'), CheckboxSetField::create('Types')->setSource(NewsSearchContext::GetNewsTypes($newsAdmin))->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Types']) ? $_REQUEST['q']['Types'] : null), TextField::create('Tags'), TextField::create('Summary'), TextField::create('Content'), TextField::create('Author'), CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray())->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Categories']) ? $_REQUEST['q']['Categories'] : null));
     $filters = array('Title' => new PartialMatchFilter('Title'), 'URLSegment' => new PartialMatchFilter('URLSegment'), 'ParentID' => new ExactMatchFilter('ParentID'), 'Tags' => new PartialMatchFilter('Tags'), 'Summary' => new PartialMatchFilter('Summary'), 'Content' => new PartialMatchFilter('Content'), 'Author' => new PartialMatchFilter('Author'), 'StartDate' => new GreaterThanOrEqualFilter('DateTime'), 'EndDate' => new LessThanOrEqualFilter('DateTime'));
     if ($newsAdmin) {
         $this->newsAdmin = $newsAdmin;
     }
     parent::__construct($modelClass, $fields, $filters);
 }
Пример #3
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if (!Config::inst()->get('NewsPost', 'pages_admin')) {
         $arrTypes = NewsPost::GetNewsTypes();
         if (count($arrTypes) > 1) {
             $arrDropDownSource = array();
             foreach ($arrTypes as $strType) {
                 $arrDropDownSource[$strType] = $strType;
             }
             $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName')->setSource($arrDropDownSource)->setTitle('Type'), 'Content');
         }
     }
     $fields->addFieldsToTab('Root.Main', array(DropdownField::create('ParentID')->setSource(NewsIndex::get()->map()->toArray())->setTitle('Parent Page'), DatetimeField::create('DateTime'), TextField::create('Tags'), TextField::create('Author'), HtmlEditorField::create('Summary')->setRows(5)), 'Content');
     if ($this->ID) {
         $fields->addFieldToTab('Root.Main', CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray()), 'Content');
         $fields->addFieldToTab('Root.RelatedArticles', GridField::create('RelatedArticles', 'Related Articles')->setList($this->RelatedArticles())->setConfig($relatedArticlesConfig = new GridFieldConfig_RelationEditor()));
     }
     $this->extend('updateNewsPostCMSFields', $fields);
     return $fields;
 }
 public function Link()
 {
     $page = NewsIndex::get()->first();
     return $page ? $page->Link('category/' . $this->ID) : '';
 }