CMS  Version 3.9
ComponentPage Class Reference

Inherits DataItem.

Public Member Functions

 Component ()
 
 Site ()
 
 ComponentPageModuleXrefs ($constraint="ORDER BY position, sort_order")
 
 Modules ($constraint="ORDER BY position, sort_order")
 
 getModulesByPosition ($constraint="ORDER BY position, sort_order")
 
 getTitle ()
 
 getBodyClass ()
 
 getTemplate ()
 Loads the template associated with this page. More...
 
 getPositions ()
 Retrieves an array of the position names defined in the template for this page. More...
 

Static Public Member Functions

static findByIdentifier ($identifier, $constraint="")
 

Public Attributes

 $primary_key = "component_page_id"
 
 $table = "component_page"
 
 $default_format = "{identifier}"
 
 $fields
 
 $relations
 

Detailed Description

Definition at line 41 of file component_page.inc.

Member Function Documentation

◆ Component()

ComponentPage::Component ( )

Definition at line 67 of file component_page.inc.

68  {
69  return Component::getComponent($this->component);
70  }
static getComponent($name)
Definition: component.inc:91

◆ ComponentPageModuleXrefs()

ComponentPage::ComponentPageModuleXrefs (   $constraint = "ORDER BY position, sort_order")

Definition at line 77 of file component_page.inc.

78  {
79  return $this->getRelatedList(ComponentPageModuleXref, "", $constraint);
80  }
$constraint

◆ findByIdentifier()

static ComponentPage::findByIdentifier (   $identifier,
  $constraint = "" 
)
static

Definition at line 232 of file component_page.inc.

233  {
234  $constraint = preg_replace("/^\s*WHERE\s+/i", "AND ", $constraint);
235 
236  $match = Query::create(ComponentPage, "WHERE identifier=:id $constraint")
237  ->bind(":id", $identifier)
238  ->executeSingle();
239 
240  return $match;
241  }
$identifier
Definition: rss.inc:37

◆ getBodyClass()

ComponentPage::getBodyClass ( )

Definition at line 148 of file component_page.inc.

149  {
151 
152  global $section;
153  if ($section)
154  {
155  $content = $section->getContent($this->identifier);
156  if ($content) return $content->body_class ? $content->body_class : $section->default_body_class;
157  }
158 
159  return "";
160  }
$section
Definition: event_form.inc:44
static $bodyClass
Override for the body class of the page currently being served.
Definition: core.inc:89
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24

◆ getModulesByPosition()

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

Definition at line 88 of file component_page.inc.

89  {
90  global $section;
91  global $identifier;
92 
93  $join = new InnerJoin();
94  $join->add(Module);
95  $join->add(ComponentPageModuleXref);
96 
97  $result = $join->groupedQuery("WHERE component_page_id={$this->component_page_id} $constraint", "ComponentPageModuleXref.position");
98  $modules = extractGroupedJoinResults(Module, $result);
99 
100  // If no modules have been set, use the section defaults
101  if (count($modules) == 0 && $section)
102  {
103  $content = $section->getContent($identifier);
104  if ($content) $modules = $content->getModulesByPosition($constraint);
105  }
106 
107  if (count($modules) == 0 && $section)
108  {
109  $modules = $section->getModulesByPosition($constraint);
110  }
111 
112  // Merge in global modules
113  $globals = groupedQuery(Module, "WHERE global=1", "global_position");
114  foreach($globals as $position => $modulesAtPosition)
115  {
116  if (array_key_exists($position, $modules))
117  {
118  $modules[$position] = removeDuplicates(array_merge($modulesAtPosition, $modules[$position]));
119  }
120  else
121  {
122  $modules[$position] = $modulesAtPosition;
123  }
124  }
125 
126  return $modules;
127  }
Defines the Module class.
Definition: module.inc:57
$result

◆ getPositions()

ComponentPage::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 219 of file component_page.inc.

220  {
221  $template = $this->getTemplate();
222 
223  $positionMatches = array();
224 
225  preg_match_all("/\{position:(.*?)\}/", $template, $positionMatches, PREG_PATTERN_ORDER);
226 
227  $positions = $positionMatches[1];
228  sort($positions);
229  return $positions;
230  }
getTemplate()
Loads the template associated with this page.
$positions

◆ getTemplate()

ComponentPage::getTemplate ( )

Loads the template associated with this page.

Returns
string the contents of the template for this page.

Definition at line 166 of file component_page.inc.

167  {
168  global $config;
169  global $section;
170 
171  $style = $_REQUEST["_style"];
172  $site = $this->Site();
173  if(!$site)
174  {
175  $site = Site::getSite();
176  }
177 
178  $templateFile = "";
179 
180  switch($style)
181  {
182  case 'print':
183  $templateFile = $site->print_template;
184  break;
185 
186  case 'popup':
187  $templateFile = $site->popup_template;
188  break;
189 
190  case 'mobile':
191  $templateFile = $site->mobile_template;
192 
193  case 'nude':
194  return "{var:script}\n{description}";
195  }
196 
197  if ($section)
198  {
199  if (!$templateFile) $templateFile = $section->getTemplateFile($this->identifier);
200  }
201 
202  if (!$templateFile) $templateFile = $this->template;
203  if (!$templateFile) $templateFile = $site->default_template;
204 
205  $templateFile = ComponentManager::fireEvent("OverrideTemplate", $templateFile);
206 
207  $base = $site->getThemeDirectory();
208  trace("{$base}/{$templateFile}", 3);
209  $template = file_get_contents("{$base}/{$templateFile}");
210 
211  return $template;
212  }
$base
Definition: delete.inc:45
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
static getSite()
Returns the Site object that describes the currently active site (i.e.
Definition: site.inc:103
global $config
Definition: import.inc:4

◆ getTitle()

ComponentPage::getTitle ( )

Definition at line 129 of file component_page.inc.

130  {
131  trace("TITLE: $this->page_title", 3);
132  global $section;
133 
135 
136  if ($section)
137  {
138  $content = $section->getContent($this->identifier);
139  if ($content && $content->override_page_title) $title = $content->override_page_title;
140  }
141 
142  if (!$title) $title = prettify($this->page->identifier);
143 
144  trace("TITLE: $title", 3);
145  return $title;
146  }
$tabs page

◆ Modules()

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

Definition at line 82 of file component_page.inc.

83  {
84  return $this->crossReference(Module, ComponentPageModuleXref, $constraint);
85  }

◆ Site()

ComponentPage::Site ( )

Definition at line 72 of file component_page.inc.

73  {
74  return $this->getRelated(Site);
75  }
Definition: site.inc:40

Member Data Documentation

◆ $default_format

ComponentPage::$default_format = "{identifier}"

Definition at line 46 of file component_page.inc.

◆ $fields

ComponentPage::$fields
Initial value:
= array("component_page_id" => Number,
"identifier" => String,
"server_path" => String,
"component" => String,
"page_title" => String,
"template" => String,
"role" => String,
"enabled" => Boolean,
"scanned" => Boolean,
"site_id" => Number
)

Definition at line 49 of file component_page.inc.

◆ $primary_key

ComponentPage::$primary_key = "component_page_id"

Definition at line 43 of file component_page.inc.

◆ $relations

ComponentPage::$relations
Initial value:
= array(
"Component" => Component,
"Site" => Site
)

Definition at line 62 of file component_page.inc.

◆ $table

ComponentPage::$table = "component_page"

Definition at line 44 of file component_page.inc.


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