1 <?php
2
3 4 5 6 7 8
9 class FaqAdmin extends LeftAndMain {
10
11 static $url_segment = 'faq';
12 static $url_rule = '/$Action/$ID';
13 static = 'FAQ';
14 static $tree_class = 'FaqSection';
15
16 public function init() {
17 parent::init();
18 Requirements::javascript("faq/javascript/FaqAdmin_left.js");
19 }
20
21 22 23 24 25
26 public function SiteTreeAsUL() {
27 $siteTree = "";
28 $objList = DataObject::get($this->stat('tree_class'));
29 if ($objList) {
30 foreach ($objList as $data) {
31 $siteTree .= "<li id=\"record-" . $data->ID . "\" class=\"" . $data->class . " " .
32 ($data->Locked ? " nodelete" : "") . "\" >" .
33 '<a href="admin/' . $this->stat('url_segment').'/show/'. $data->ID . '" >' . $data->Title . '</a>';
34 }
35 }
36 return '<ul id="sitetree" class="tree unformatted">'
37 . '<li id="record-0" class="Root nodelete">'
38 . '<a href="admin/' . $this->stat('url_segment') . '/show/start" ><strong>' . _t('FaqAdmin.WITHOUTANSWER', "Without Answers") . '</strong></a>'
39 . $siteTree . '</li></ul>';
40 }
41
42 43 44 45 46
47 function getEditForm($id) {
48
49 $id = (int)$id;
50 if ($id == 0) {
51 $filter = "`Answer` IS NULL";
52 } else {
53 $filter = "`SectionID` = {$id}";
54 }
55
56 $tablefield = new ComplexTableField(
57 $this,
58 'Questions',
59 'FaqQuestion',
60 array(
61 'Question' => 'Question',
62
63
64 'Email' => 'Email',
65 'Created' => _t('FaqQuestion.db_Created'),
66 'AnswerDate' => 'AnswerDate',
67 'PublishedTitle' => 'Published',
68 'SendAnswerTitle' => 'SendAnswer'
69 ),
70 'getCMSFields_forPopup',
71 $filter,
72 "`Created` DESC"
73
74 );
75
76 $permissions = array('view','delete','edit');
77 $tablefield->setPermissions($permissions);
78
79 $fields = new Fieldset($tablefield);
80 $actions = new FieldSet();
81 $form = new Form($this, "EditForm", $fields, $actions);
82 return $form;
83 }
84 }
85
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-