CMS  Version 3.9
Site Class Reference

Inherits DataItem.

Public Member Functions

 Pages ($constraint="")
 
 Articles ($constraint="")
 
 Events ($constraint="")
 
 Fora ($constraint="")
 
 ForumSummaries ($constraint="")
 
 Sections ($constraint="")
 
 getThemeDirectory ()
 
 Site ()
 

Static Public Member Functions

static getSite ()
 Returns the Site object that describes the currently active site (i.e. More...
 
static getSites ()
 

Public Attributes

 $fields
 
 $relations
 

Detailed Description

Definition at line 39 of file site.inc.

Member Function Documentation

◆ Articles()

Site::Articles (   $constraint = "")

Definition at line 73 of file site.inc.

74  {
75  return $this->crossReference(Article, ArticleSiteXref, $constraint);
76  }
$constraint
Defines the Article class.
Definition: article.inc:45
Definition: article.inc:309

◆ Events()

Site::Events (   $constraint = "")

Definition at line 78 of file site.inc.

79  {
80  return $this->crossReference(Event, EventSiteXref, $constraint);
81  }
Defines the Event class.
Definition: event.inc:43

◆ Fora()

Site::Fora (   $constraint = "")

Definition at line 83 of file site.inc.

84  {
85  return $this->crossReference(Forum, ForumSiteXref, $constraint);
86  }
Definition: forum.inc:42

◆ ForumSummaries()

Site::ForumSummaries (   $constraint = "")

Definition at line 88 of file site.inc.

89  {
90  return $this->crossReference(ForumSummary, ForumSiteXref, $constraint);
91  }

◆ getSite()

static Site::getSite ( )
static

Returns the Site object that describes the currently active site (i.e.

the site associated with the domain the user is currently accessing).

Exceptions
FakoliException

Definition at line 103 of file site.inc.

104  {
105  global $config;
106 
107  if (Site::$currentSite)
108  {
109  return Site::$currentSite;
110  }
111 
112  $domain = $_SERVER['HTTP_HOST'];
113  trace("Accessed via domain: $domain", 3);
114 
115  $sites = Query::create(Site, "WHERE domain=:d and enabled=1 ORDER BY default_site DESC")
116  ->bind(":d", $domain)
117  ->execute();
118  if (count($sites) > 0)
119  {
120  trace("Matching Site record found", 3);
121  Site::$currentSite = $sites[0];
122 
123  // Store in $config
124  $config['http_host'] = $sites[0]->domain;
125 
126  return Site::$currentSite;
127  }
128 
129  $sites = Query::create(Site, "WHERE enabled=1 ORDER BY default_site DESC, site_name ASC")->execute();
130 
131  if (count($sites) > 0)
132  {
133  Site::$currentSite = $sites[0];
134  trace("Using default Site record with domain ".Site::$currentSite->domain, 3);
135  return Site::$currentSite;
136  }
137 
138  throw new FakoliException("No site defined");
139  }
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
Definition: site.inc:40
$sites
Definition: event_edit.inc:83
global $config
Definition: import.inc:4

◆ getSites()

static Site::getSites ( )
static

Definition at line 141 of file site.inc.

142  {
143  return Query::create(Site, "ORDER BY site_name")->execute();
144  }

◆ getThemeDirectory()

Site::getThemeDirectory ( )

Definition at line 146 of file site.inc.

147  {
148  return SiteManager::getThemeDirectory($this->theme);
149  }
static getThemeDirectory($theme="")

◆ Pages()

Site::Pages (   $constraint = "")

Definition at line 68 of file site.inc.

69  {
70  return $this->getRelatedList(Page, "", $constraint);
71  }
Definition: page.inc:43

◆ Sections()

Site::Sections (   $constraint = "")

Definition at line 93 of file site.inc.

94  {
95  return $this->getRelatedList(Section, "", $constraint);
96  }
Section DataItem, defining the data model for sections within a site.
Definition: section.inc:45

◆ Site()

Site::Site ( )

Definition at line 152 of file site.inc.

153  {
154  $this->primary_key = "site_id";
155  $this->table = "site";
156 
157  $this->default_format = "{site_name}";
158  $this->DataItem(func_get_args());
159  }

Member Data Documentation

◆ $fields

Site::$fields
Initial value:
= array("site_id" => Number,
"site_name" => String,
"domain" => String,
"home_page" => String,
"description" => Text,
"meta_tag_description" => Text,
"meta_tag_keyword" => String,
"theme" => String,
"default_template" => String,
"print_template" => String,
"popup_template" => String,
"mobile_template" => String,
"enabled" => Boolean,
"default_site" => Boolean)

Definition at line 44 of file site.inc.

◆ $relations

Site::$relations
Initial value:
= array( "Pages" => Page,
"Articles" => Article,
"Events" => Event,
"Fora" => Forum,
"ForumSummaries" => ForumSummary,
"Sections" => Section)

Definition at line 61 of file site.inc.


The documentation for this class was generated from the following file: