Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_multiple_page_page.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/bodycopy/bodycopy/bodycopy.inc';
19 require_once SQ_FUDGE_PATH.'/general/text.inc';
20 
33 {
34 
35 
42  function __construct($assetid=0)
43  {
44  parent::__construct($assetid);
45 
46  }//end constructor
47 
48 
56  function _getAllowedLinks()
57  {
58  $page_links = parent::_getAllowedLinks();
59  $page_links[SQ_LINK_TYPE_1]['page'] = Array('card' => 'M', 'exclusive' => FALSE);
60  $page_links[SQ_LINK_TYPE_1]['file'] = Array('card' => 'M', 'exclusive' => FALSE);
61  $page_links[SQ_LINK_TYPE_2]['container'] = Array('card' => 'M', 'exclusive' => FALSE);
62  $page_links[SQ_LINK_TYPE_2]['page'] = Array('card' => 'M', 'exclusive' => FALSE);
63  $page_links[SQ_LINK_TYPE_2]['file'] = Array('card' => 'M', 'exclusive' => FALSE);
64  $page_links[SQ_LINK_NOTICE]['asset'] = Array('card' => 'M', 'exclusive' => FALSE);
65  return $page_links;
66 
67  }//end _getAllowedLinks()
68 
69 
80  function _createAdditional(&$link)
81  {
82  if (!parent::_createAdditional($link)) return FALSE;
83 
84  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
85  $multi_page = $link['asset'];
86 
87  $new_page_number = strval($multi_page->getNumberOfPages());
88 
89  return $this->saveWebPaths(Array($new_page_number));
90 
91  }//end _createAdditional()
92 
93 
104  public function _getName($short_name=FALSE, $contextid=NULL)
105  {
106  // No context specified, using the current context
107  if ($contextid === NULL) {
108  $contextid = $GLOBALS['SQ_SYSTEM']->getContextId();
109  }//end if
110 
111  // Obtain the attribute value for Name from the specified Context
112  $values = $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName('name', $this->type(), Array($this->id), $contextid);
113  if (empty($values) === TRUE) {
114  return parent::_getName($short_name, $contextid);
115  } else {
116  return $values[$this->id];
117  }
118 
119  }//end _getName()
120 
121 
128  function printBody()
129  {
130  // We have to redirect to our parent, so that page numbers, and other stuff can be printed
131  $parent = $this->getMultiplePageAsset();
132  $parent->printPage($this);
133 
134  }//end printBody()
135 
136 
143  function getMultiplePageId()
144  {
145  if ($this->id != '0') {
146  $parents = $GLOBALS['SQ_SYSTEM']->am->getParents($this->id, 'page_multiple_page');
147  if (!empty($parents)) {
148  return current(array_keys($parents));
149  }
150  }
151  return '0';
152 
153  }//end getMultiplePageId()
154 
155 
163  {
164  $multi_id = $this->getMultiplePageId();
165  if ($multi_id != '0') {
166  return $GLOBALS['SQ_SYSTEM']->am->getAsset($multi_id);
167  }
168  $null_minder = NULL;
169  return $null_minder;
170 
171  }//end getMultiplePageAsset()
172 
173 
180  function getRawContent()
181  {
182  return parent::getRawBodycopyContent();
183 
184  }//end getRawContent()
185 
186 
193  function getContent()
194  {
195  ob_start();
196  parent::printBody();
197  $content = ob_get_contents();
198  ob_end_clean();
199 
200  return $content;
201 
202  }//end getContent()
203 
204 
212  {
213  $GLOBALS['SQ_SYSTEM']->am->includeAsset('page_multiple_page');
214  $parent = new Page_Multiple_Page();
215  return $parent->getAvailableKeywords();
216 
217  }//end getAvailableKeywords()
218 
219 
228  function getKeywordReplacement($value)
229  {
230  // Multiple page page has no metadata screen, so it should always use
231  // its parent's metadata
232  if (preg_match('|^asset_metadata_|', $value)) {
233  $replacement = '%'.$value.'%';
234  } else {
235  $replacement = parent::getKeywordReplacement($value);
236  }
237 
238  if ($replacement == '%'.$value.'%') {
239  $parent = $this->getMultiplePageAsset();
240  $replacement = $parent->getKeywordReplacement($value);
241  }
242 
243  return $replacement;
244 
245  }//end getKeywordReplacement()
246 
247 
257  function getCustomKeywordReplacements($keywords, $invoke_backend = FALSE)
258  {
259  if (!is_array($keywords) || empty($keywords)) {
260  return Array();
261  }
262  $print_commit_button = FALSE;
263 
264  $replacements = Array();
265  foreach ($keywords as $keyword) {
266  switch ($keyword) {
267  case 'contents' :
268  $edit = $this->getEditFns();
269  if (!$invoke_backend) {
270  $o = $GLOBALS['SQ_SYSTEM']->backend->out ;
271  } else {
272  require_once SQ_INCLUDE_PATH.'/backend_outputter.inc';
273  $o = new Backend_Outputter();
274  }
275  ob_start();
276  if ($edit->paintBodycopy($this, $o, $this->getPrefix())) {
277  $print_commit_button = TRUE;
278  }
279  $replacements[$keyword] = ob_get_contents();
280  ob_end_clean();
281  break;
282 
283  default:
284  $replacements[$keyword] = '';
285  break;
286  }//end switch
287  }//end foreach
288 
289  return Array('replacements' => $replacements, 'print_commit_button' => $print_commit_button);
290 
291  }//end getCustomKeywordReplacements()
292 
293 
303  function processCustomKeywords($keywords)
304  {
305  if (!is_array($keywords) || empty($keywords)) {
306  return Array();
307  }
308 
309  foreach ($keywords as $keyword) {
310  switch ($keyword) {
311  case 'contents' :
312  $edit = $this->getEditFns();
313  $edit->processBodycopy($this, $GLOBALS['SQ_SYSTEM']->backend->out, $this->getPrefix());
314  break;
315  }
316  }
317 
318  return TRUE;
319 
320  }//end processCustomKeywords()
321 
322 
323 }//end class
324 
325 ?>