CMS  Version 3.9
Section Class Reference

Section DataItem, defining the data model for sections within a site. More...

Inherits DataItem.

Public Member Functions

 SectionModuleXrefs ($constraint="ORDER BY position, sort_order")
 
 Modules ($constraint="ORDER BY position, sort_order")
 
 Content ($constraint="")
 
 Site ()
 
 getContentManager ()
 
 getContent ($identifier)
 
 getTemplateFile ($identifier)
 
 getRole ($identifier)
 
 getPermissions ($identifier)
 
 getModulesByPosition ($constraint="ORDER BY position, sort_order")
 
 clearModuleCache ()
 
 getSectionURL ()
 Returns the Section URL. More...
 
 getDefaultTemplate ()
 Loads the default template associated with this section. More...
 
 getDefaultPage ()
 Returns the path to the default page for this section. More...
 
 getPositions ()
 Retrieves an array of the position names defined in the template for this page. More...
 

Static Public Member Functions

static createFromIdentifier ($identifier)
 
static findSection ($section_name)
 

Public Attributes

 $primary_key = "section_id"
 
 $table = "section"
 
 $fields
 
 $relations
 
 $_content = array()
 

Detailed Description

Section DataItem, defining the data model for sections within a site.

Author
Andy Green

Definition at line 44 of file section.inc.

Member Function Documentation

◆ clearModuleCache()

Section::clearModuleCache ( )

Definition at line 188 of file section.inc.

189  {
190  Cache::invalidate("section_module_map_{$this->section_id}");
191  }

◆ Content()

Section::Content (   $constraint = "")

Definition at line 80 of file section.inc.

81  {
82  return $this->getRelatedList(SectionContent, "", $constraint);
83  }
$constraint

◆ createFromIdentifier()

static Section::createFromIdentifier (   $identifier)
static

Definition at line 95 of file section.inc.

96  {
97  if (!$identifier) return null;
98 
99  $site = Site::getSite();
100 
101  try
102  {
103  return Query::create(Section, "WHERE section=:identifier AND site_id=:site")
104  ->bind(":identifier", $identifier, ":site", $site->site_id)
105  ->executeSingle();
106  }
107  catch(Exception $e)
108  {
109  ComponentManager::fireEvent("SectionNotFound", $identifier);
110  throw new FakoliException("Unknown or ambiguous section '$identifier'");
111  }
112  }
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
Section DataItem, defining the data model for sections within a site.
Definition: section.inc:45
static getSite()
Returns the Site object that describes the currently active site (i.e.
Definition: site.inc:103
$identifier
Definition: rss.inc:37

◆ findSection()

static Section::findSection (   $section_name)
static

Definition at line 145 of file section.inc.

146  {
147  $site = Site::getSite();
148 
149  $sections = Query::create(Section, "WHERE section=:section AND site_id=:site")
150  ->bind(":section", $section_name, ":site", $site->site_id)
151  ->execute();
152 
153  return (count($sections) > 0) ? $sections[0] : null;
154  }

◆ getContent()

Section::getContent (   $identifier)

Definition at line 116 of file section.inc.

117  {
118  if ($this->_content[$identifier]) return $this->_content[$identifier];
120 
121  return SectionContentManagerMap::getManager($this)->getContent($this, $identifier);
122  }
static getManager($section)
Retrieves the SectionContentManager object for the specified section.
static ensureContentManager()

◆ getContentManager()

Section::getContentManager ( )

Definition at line 90 of file section.inc.

91  {
93  }

◆ getDefaultPage()

Section::getDefaultPage ( )

Returns the path to the default page for this section.

Definition at line 226 of file section.inc.

227  {
228  $url = $this->getSectionURL();
229  return $url . $this->default_page;
230  }
getSectionURL()
Returns the Section URL.
Definition: section.inc:197
if(! $blog->published||! $blog->enable_rss_feed||!checkRole($blog->allow_read)) $url
Definition: rss.inc:58

◆ getDefaultTemplate()

Section::getDefaultTemplate ( )

Loads the default template associated with this section.

Returns
string the contents of the template for this section.

Definition at line 213 of file section.inc.

214  {
215  $directory = $this->Site()->getThemeDirectory();
216  $file = $directory . DIRECTORY_SEPARATOR . $this->default_template;
217  trace("Template File: $file", 3);
218  $template = file_get_contents($file);
219 
220  return $template;
221  }
$file
Definition: delete.inc:47
Site()
Definition: section.inc:85

◆ getModulesByPosition()

Section::getModulesByPosition (   $constraint = "ORDER BY position, sort_order")

Definition at line 156 of file section.inc.

157  {
158  $modules = Cache::get("section_module_map_{$this->section_id}");
159  if (!$modules)
160  {
161  $join = new InnerJoin();
162  $join->add(Module);
163  $join->add(SectionModuleXref);
164 
165  $result = $join->groupedQuery("WHERE section_id={$this->section_id} $constraint", "SectionModuleXref.position");
166  $modules = extractGroupedJoinResults(Module, $result);
167 
168  // Merge in global modules
169  $globals = groupedQuery(Module, "WHERE global=1", "global_position");
170  foreach($globals as $position => $modulesAtPosition)
171  {
172  if (array_key_exists($position, $modules))
173  {
174  $modules[$position] = removeDuplicates(array_merge($modulesAtPosition, $modules[$position]));
175  }
176  else
177  {
178  $modules[$position] = $modulesAtPosition;
179  }
180  }
181 
182  Cache::put("section_module_map_{$this->section_id}", $modules);
183  }
184 
185  return $modules;
186  }
Defines the Module class.
Definition: module.inc:57
$result

◆ getPermissions()

Section::getPermissions (   $identifier)

Definition at line 138 of file section.inc.

139  {
140  $content = is_object($identifier) ? $identifier : $this->getContent($identifier);
141  if ($content->permissions) return $content->permissions;
142  return $this->default_permissions;
143  }
getContent($identifier)
Definition: section.inc:116
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24

◆ getPositions()

Section::getPositions ( )

Retrieves an array of the position names defined in the template for this page.

Returns
array the positions defined in the template (sorted alphabetically)

Definition at line 236 of file section.inc.

237  {
238  $template = $this->getDefaultTemplate();
239 
240  $positionMatches = array();
241 
242  preg_match_all("/\{position:(.*?)\}/", $template, $positionMatches, PREG_PATTERN_ORDER);
243 
244  $positions = $positionMatches[1];
245  sort($positions);
246  return $positions;
247  }
getDefaultTemplate()
Loads the default template associated with this section.
Definition: section.inc:213
$positions

◆ getRole()

Section::getRole (   $identifier)

Definition at line 131 of file section.inc.

132  {
133  $content = is_object($identifier) ? $identifier : $this->getContent($identifier);
134  if ($content->role) return $content->role;
135  return $this->default_role;
136  }

◆ getSectionURL()

Section::getSectionURL ( )

Returns the Section URL.

Definition at line 197 of file section.inc.

198  {
199  global $config;
200 
201  $url = "http" . (($this->use_SSL) ? "s" : "") . "://{$config['http_host']}/";
202  if ($this->section != "/")
203  {
204  $url .= $this->section . "/";
205  }
206  return $url;
207  }
global $config
Definition: import.inc:4
$tabs section

◆ getTemplateFile()

Section::getTemplateFile (   $identifier)

Definition at line 124 of file section.inc.

125  {
126  $content = is_object($identifier) ? $identifier : $this->getContent($identifier);
127  if ($content->template) return $content->template;
128  return $this->default_template;
129  }

◆ Modules()

Section::Modules (   $constraint = "ORDER BY position, sort_order")

Definition at line 75 of file section.inc.

76  {
77  return $this->crossReference(Module, SectionModuleXref, $constraint);
78  }

◆ SectionModuleXrefs()

Section::SectionModuleXrefs (   $constraint = "ORDER BY position, sort_order")

Definition at line 70 of file section.inc.

71  {
72  return $this->getRelatedList(SectionModuleXref, "", $constraint);
73  }

◆ Site()

Section::Site ( )

Definition at line 85 of file section.inc.

86  {
87  return $this->getRelated(Site);
88  }
Definition: site.inc:40

Member Data Documentation

◆ $_content

Section::$_content = array()

Definition at line 114 of file section.inc.

◆ $fields

Section::$fields
Initial value:
= array("section_id" => Number,
"section" => String,
"section_title" => String,
"default_template" => String,
"default_role" => String,
"default_permissions" => String,
"default_page" => String,
"default_body_class" => String,
"site_id" => Number,
"use_SSL" => Boolean,
"section_type" => String
)

Definition at line 51 of file section.inc.

◆ $primary_key

Section::$primary_key = "section_id"

Definition at line 46 of file section.inc.

◆ $relations

Section::$relations
Initial value:
= array("SectionModuleXrefs" => SectionModuleXref,
"Modules" => Module,
"Content" => SectionContent,
"Site" => Site
)

Definition at line 64 of file section.inc.

◆ $table

Section::$table = "section"

Definition at line 47 of file section.inc.


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