Version: current

     1 <?php
     2 /**
     3  * @package subsites
     4  */
     5 class ControllerSubsites extends Extension {
     6     function controllerAugmentInit(){
     7         if($subsite = Subsite::currentSubsite()){
     8             if($theme = $subsite->Theme)
     9                 SSViewer::set_theme($theme);
    10         }
    11     }
    12
    13     function CurrentSubsite(){
    14         if($subsite = Subsite::currentSubsite()){
    15             return $subsite;
    16         }
    17     }
    18
    19     function Subsites($includeMain = false) {
    20         $subsites = DataObject::get('Subsite', '`IsPublic` = 1');
    21         if (!$subsites) $subsites = new DataObjectSet();
    22
    23         if ($includeMain) {
    24             $mainSite = new Subsite();
    25             $mainSite->Title = _t('Subsite.MainSiteTitle', 'Main site');
    26             $mainSite->PrimaryDomain = '/'; // FIXME неверно в случае если подсайты на разных доменах
    27             $mainSite->Language = Subsite::get_mainsite_language();
    28             $subsites->insertFirst($mainSite);
    29         }
    30
    31         $currID = Subsite::currentSubsiteID();
    32         foreach ($subsites as $item) {
    33             if ($item->ID == $currID) {
    34                 $item->IsCurrent = 1;
    35                 $item->LinkOrCurrent = 'current';
    36             }
    37             else {
    38                 $item->LinkOrCurrent = 'link';
    39             }
    40         }
    41         return $subsites;
    42     }
    43 }
    44

[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. -