Completed
Push — master ( 63cfe4...886ab6 )
by Nicolaas
01:32
created

code/SiteMapPage.php (1 issue)

not multiple classes are defined in the same file.

Coding Style Compatibility Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
4
/**
5
 * @author Nicolaas [at] sunnysideup.co.nz
6
 *
7
 *
8
 **/
9
10
11
class SiteMapPage extends Page
12
{
13
    private static $db = array(
14
        "ShowAllPages" => "Boolean"
15
    );
16
17
    private static $description = "Sitemap Page: shows all the pages of a site in a tree format";
18
19
    private static $add_action = 'Site Map Page';
20
21
    private static $icon = 'sitemappage/images/treeicons/SiteMapPage';
22
23
    public function canCreate($member = null)
24
    {
25
        return ! SiteMapPage::get()->count();
26
    }
27
28
    public function getCMSFields()
29
    {
30
        $fields = parent::getCMSFields();
31
        $fields->addFieldToTab("Root.Display", new CheckboxField("ShowAllPages", "Show all pages from the start"));
32
        return $fields;
33
    }
34
}
35
36
class SiteMapPage_Controller extends Page_Controller
0 ignored issues
show
Coding Style Compatibility introduced by sunnysideup
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
37
{
38
    public function init()
39
    {
40
        parent::init();
41
        if (!$this->ShowAllPages) {
42
            Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
43
            Requirements::javascript('sitemappage/javascript/SiteMapPage.js');
44
            Requirements::themedCSS('SiteMapPage', "sitemappage");
45
        } else {
46
            Requirements::themedCSS('SiteMapPageOpen', "sitemappage");
47
        }
48
    }
49
50
    public function LevelOneSiteMapPages()
51
    {
52
        $homePage = SiteTree::get()->filter(array("ParentID" => 0))->first();
53
        return $homePage->SiteMapPages($noParent = true);
54
    }
55
}
56