CMS  Version 3.9
Page Class Reference
+ Inheritance diagram for Page:
+ Collaboration diagram for Page:

Public Member Functions

 PageModuleXrefs ($constraint="ORDER BY position, sort_order")
 
 Modules ($constraint="ORDER BY position, sort_order")
 
 Site ()
 
 getModulesByPosition ($constraint="ORDER BY position, sort_order")
 
 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...
 
 getBodyClass ()
 
 Page ()
 
 search ($params, $range=null)
 DataItems must implement this method to provide search functionality. More...
 

Static Public Member Functions

static findByIdentifier ($identifier)
 

Public Attributes

 $fields
 
 $relations
 
 $versioned_fields = array("page_title", "description", "meta_tag_description", "meta_tag_keyword", "author")
 

Detailed Description

Definition at line 42 of file page.inc.

Member Function Documentation

◆ findByIdentifier()

static Page::findByIdentifier (   $identifier)
static

Definition at line 85 of file page.inc.

86  {
87  $match = Query::create(Page, "WHERE identifier=:id")
88  ->bind(":id", $identifier)
89  ->executeSingle();
90 
91  return $match;
92  }
Definition: page.inc:43
$identifier
Definition: rss.inc:37

◆ getBodyClass()

Page::getBodyClass ( )

Definition at line 204 of file page.inc.

205  {
207 
208  global $section;
209  if ($section)
210  {
211  $content = $section->getContent($this->identifier);
212  if ($content) return $content->body_class ? $content->body_class : $section->default_body_class;
213  }
214 
215  return "";
216  }
$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()

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

Definition at line 94 of file page.inc.

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

◆ getPositions()

Page::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 191 of file page.inc.

192  {
193  $template = $this->getTemplate();
194 
195  $positionMatches = array();
196 
197  preg_match_all("/\{position:(.*?)\}/", $template, $positionMatches, PREG_PATTERN_ORDER);
198 
199  $positions = $positionMatches[1];
200  sort($positions);
201  return $positions;
202  }
getTemplate()
Loads the template associated with this page.
Definition: page.inc:140
$positions

◆ getTemplate()

Page::getTemplate ( )

Loads the template associated with this page.

Returns
string the contents of the template for this page.

Definition at line 140 of file page.inc.

141  {
142  global $config;
143  global $section;
144 
145  $style = $_REQUEST["_style"];
146  $site = $this->Site();
147  if (!$site)
148  {
149  $site = Site::getSite();
150  }
151 
152  $templateFile = "";
153 
154  switch($style)
155  {
156  case 'print':
157  $templateFile = $site->print_template;
158  break;
159 
160  case 'popup':
161  $templateFile = $site->popup_template;
162  break;
163 
164  case 'mobile':
165  $templateFile = $site->mobile_template;
166 
167  case 'nude':
168  return "<h2>{page_title}</h2>{description}";
169  }
170 
171  if ($section)
172  {
173  if (!$templateFile) $templateFile = $section->getTemplateFile($this->identifier);
174  }
175 
176  if (!$templateFile) $templateFile = $this->template;
177  if (!$templateFile) $templateFile = $site->default_template;
178 
179  $templateFile = ComponentManager::fireEvent("OverrideTemplate", $templateFile);
180 
181  $base = $site->getThemeDirectory();
182  $template = file_get_contents("{$base}/{$templateFile}");
183 
184  return $template;
185  }
$base
Definition: delete.inc:45
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
Site()
Definition: page.inc:80
static getSite()
Returns the Site object that describes the currently active site (i.e.
Definition: site.inc:103
global $config
Definition: import.inc:4

◆ Modules()

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

Definition at line 75 of file page.inc.

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

◆ Page()

Page::Page ( )

Definition at line 232 of file page.inc.

233  {
234  $this->primary_key = "page_id";
235  $this->table = "page";
236 
237  $this->default_format = "{page_title}";
238 
239  $this->DataItem(func_get_args());
240  }

◆ PageModuleXrefs()

Page::PageModuleXrefs (   $constraint = "ORDER BY position, sort_order")

Definition at line 70 of file page.inc.

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

◆ search()

Page::search (   $params,
  $range = null 
)

DataItems must implement this method to provide search functionality.

Parameters
mixed$paramseither search text or a SearchParameters object
array$rangean array of primary key IDs to which the search must be constrained

Implements Searchable.

Definition at line 242 of file page.inc.

243  {
244  trace("Searching Pages", 3);
245 
246  if ($range)
247  {
248  $range = " AND {$this->primary_key} IN (".implode($range, ", ").")";
249  }
250 
251  if (is_object($params))
252  {
253  $search = clone $params;
254  $search->target = $this;
255  $search->remapField("title", "page_title");
256  $search->remapField("keywords", "meta_tag_keyword");
257  $search->remapField("publication_date", "created_date");
258 
259  if (!$search->get("text", "like"))
260  {
261  $search->secondaryFields("meta_tag_keyword", "description");
262  }
263 
264 
265  $constraint = $search->generateConstraint();
266  $constraint .= $constraint ? " AND published=1 AND exclude_from_search=0" : " WHERE published=1 AND exclude_from_search=0";
267  $constraint .= $range;
268 
269  $pages = Query::create(Page, $constraint)
270  ->execute();
271  }
272  else
273  {
274  $params = "%$params%";
275  $pages = Query::create(Page, "WHERE (page_title like :a OR description LIKE :b) AND published=1 AND exclude_from_search=0 $range")
276  ->bind(":a", $params, ":b", $params)
277  ->execute();
278  }
279 
281  }
$range
Definition: error_log.inc:13
static wrap($items, $resultClass)
$pages
Definition: export.inc:38

◆ Site()

Page::Site ( )

Definition at line 80 of file page.inc.

81  {
82  return $this->getRelated(Site);
83  }
Definition: site.inc:40

Member Data Documentation

◆ $fields

Page::$fields
Initial value:
= array("page_id" => Number,
"identifier" => String,
"page_title" => String,
"description" => HTML,
"site_id" => Number,
"template" => String,
"meta_tag_description" => Text,
"meta_tag_keyword" => String,
"php_code_file" => String,
"role" => String,
"published" => Boolean,
"exclude_from_search" => Boolean,
"created_date" => Date,
"edited_date" => Timestamp,
"author" => String
)

Definition at line 45 of file page.inc.

◆ $relations

Page::$relations
Initial value:
= array("PageModuleXrefs" => PageModuleXref,
"Modules" => Module,
"Site" => Site)

Definition at line 64 of file page.inc.

◆ $versioned_fields

Page::$versioned_fields = array("page_title", "description", "meta_tag_description", "meta_tag_keyword", "author")

Definition at line 68 of file page.inc.


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