CMS  Version 3.9
SectionContent Class Reference

Inherits DataItem.

Public Member Functions

 Section ()
 
 SectionContentModuleXrefs ($constraint="ORDER BY position, sort_order")
 
 getModulesByPosition ($constraint="ORDER BY position, sort_order")
 
 getTemplate ()
 Loads the default template associated with this section. More...
 
 getPositions ()
 Retrieves an array of the position names defined in the template for this page. More...
 
 getBodyClass ()
 Returns any custom body CSS classes defined for this section content. More...
 
 addToSection ($section_folder)
 Add this SectionContent to the specified Section. More...
 

Static Public Member Functions

static getMappedContent ($identifier)
 

Public Attributes

 $primary_key = "section_content_id"
 
 $table = "section_content"
 
 $fields
 
 $relations
 

Detailed Description

Definition at line 250 of file section.inc.

Member Function Documentation

◆ addToSection()

SectionContent::addToSection (   $section_folder)

Add this SectionContent to the specified Section.

This is intended for newly created SectionContent and will throw an exception if the section_id field is already populated, or if there is already a SectionContent item with the same identifier mapped to the the target section

Parameters
string$section_folderthe folder identifying the target Section

Definition at line 387 of file section.inc.

388  {
389  if ($this->section_id)
390  {
391  throw new FakoliException("Attempt to map section content that is already mapped to a section");
392  }
393 
394  $section = Section::findSection($section_folder);
395  if (!$section)
396  {
397  throw new FakoliException("Unrecognized section '$section_folder'");
398  }
399 
400  if (SectionManager::isInSection($section_folder, $this->identifier)) return;
401 
402  $this->section_id = $section->section_id;
403  $this->save();
404  }
$section
Definition: event_form.inc:44
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static findSection($section_name)
Definition: section.inc:145
static isInSection($section_folder, $identifier)

◆ getBodyClass()

SectionContent::getBodyClass ( )

Returns any custom body CSS classes defined for this section content.

Definition at line 374 of file section.inc.

375  {
376  return $this->body_class ? $this->body_class : $this->Section()->default_body_class;
377  }

◆ getMappedContent()

static SectionContent::getMappedContent (   $identifier)
static

Definition at line 324 of file section.inc.

325  {
326  $content = Query::create(SectionContent, "WHERE identifier=:i")
327  ->bind(":i", $identifier)
328  ->execute();
329 
330  return $content;
331  }
$identifier
Definition: rss.inc:37
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24

◆ getModulesByPosition()

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

Definition at line 283 of file section.inc.

284  {
285  if (!$this->section_content_id)
286  {
287  // Mocked SectionContent object
288  return array();
289  }
290 
291  $modules = Cache::get("section_content_module_map_{$this->section_content_id}");
292  if (!$modules)
293  {
294  $join = new InnerJoin();
295  $join->add(Module);
296  $join->add(SectionContentModuleXref);
297 
298  $result = $join->groupedQuery("WHERE section_content_id={$this->section_content_id} $constraint", "SectionContentModuleXref.position");
299  $modules = extractGroupedJoinResults(Module, $result);
300 
301  if (count($modules) > 0)
302  {
303  // Merge in global modules
304  $globals = groupedQuery(Module, "WHERE global=1", "global_position");
305  foreach($globals as $position => $modulesAtPosition)
306  {
307  if (array_key_exists($position, $modules))
308  {
309  $modules[$position] = removeDuplicates(array_merge($modulesAtPosition, $modules[$position]));
310  }
311  else
312  {
313  $modules[$position] = $modulesAtPosition;
314  }
315  }
316  }
317 
318  Cache::put("section_module_map_{$this->section_id}", $modules);
319  }
320 
321  return $modules;
322  }
Defines the Module class.
Definition: module.inc:57
$result

◆ getPositions()

SectionContent::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 358 of file section.inc.

359  {
360  $template = $this->getTemplate();
361 
362  $positionMatches = array();
363 
364  preg_match_all("/\{position:(.*?)\}/", $template, $positionMatches, PREG_PATTERN_ORDER);
365 
366  $positions = $positionMatches[1];
367  sort($positions);
368  return $positions;
369  }
getTemplate()
Loads the default template associated with this section.
Definition: section.inc:338
$positions

◆ getTemplate()

SectionContent::getTemplate ( )

Loads the default template associated with this section.

Returns
string the contents of the template for this section.

Definition at line 338 of file section.inc.

339  {
340  global $config;
341 
342  if ($this->template)
343  {
344  $template = file_get_contents("{$config['homedir']}/templates/{$this->template}");
345  }
346  else
347  {
348  $template = $this->Section()->getDefaultTemplate();
349  }
350 
351  return $template;
352  }
global $config
Definition: import.inc:4

◆ Section()

SectionContent::Section ( )

Definition at line 272 of file section.inc.

273  {
274  return $this->getRelated(Section);
275  }
Section DataItem, defining the data model for sections within a site.
Definition: section.inc:45

◆ SectionContentModuleXrefs()

SectionContent::SectionContentModuleXrefs (   $constraint = "ORDER BY position, sort_order")

Definition at line 278 of file section.inc.

279  {
280  return $this->getRelatedList(SectionContentModuleXref, "", $constraint);
281  }
$constraint

Member Data Documentation

◆ $fields

SectionContent::$fields
Initial value:
= array("section_content_id" => Number,
"section_id" => String,
"identifier" => String,
"role" => String,
"permissions" => String,
"template" => String,
"body_class" => String,
"override_page_title" => String,
"use_SSL" => Boolean)

Definition at line 257 of file section.inc.

◆ $primary_key

SectionContent::$primary_key = "section_content_id"

Definition at line 252 of file section.inc.

◆ $relations

SectionContent::$relations
Initial value:
= array(
"Section" => Section,
"SectionContentModuleXrefs" => SectionContentModuleXref
)

Definition at line 267 of file section.inc.

◆ $table

SectionContent::$table = "section_content"

Definition at line 253 of file section.inc.


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