18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
19 require_once SQ_FUDGE_PATH.
'/general/text.inc';
44 parent::__construct($assetid);
61 if (!parent::_createAdditional($link))
return FALSE;
64 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
66 $copy_link = Array(
'asset' => &$this,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
68 $bodycopy->setAttrValue(
'name',
'Page Contents');
69 if ($bodycopy->create($copy_link, $args)) {
70 $child_bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getLink($bodycopy->id, SQ_LINK_TYPE_2,
'bodycopy_div');
71 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($child_bodycopy[
'minorid'],
'attributes');
99 public function prepareLink(
Asset $asset, $side_of_link, &$link_type, &$value, &$sort_order, &$dependant, &$exclusive)
102 if ($side_of_link ==
'major' && ($asset instanceof
Bodycopy) && $dependant !=
'1') {
124 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'major', NULL,
'1',
'1');
125 if (!$GLOBALS[
'SQ_PURGING_TRASH'] && (!empty($bodycopy_link) && $bodycopy_link[0][
'linkid'] == $linkid)) {
126 return translate(
'core_error_bodycopy_link_cannot_delete');
129 return parent::isDeletableLink($linkid);
143 $page_links = parent::_getAllowedLinks();
144 $page_links[SQ_LINK_TYPE_1][
'calendar_event_single'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
145 $page_links[SQ_LINK_TYPE_1][
'calendar_event_recurring'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
146 $page_links[SQ_LINK_TYPE_2][
'calendar_event_single'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
147 $page_links[SQ_LINK_TYPE_2][
'calendar_event_recurring'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
148 $page_links[SQ_LINK_TYPE_2][
'bodycopy'] = Array(
'card' => 1,
'exclusive' => TRUE);
149 $page_links[SQ_LINK_NOTICE][
'calendar_event_single'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
150 $page_links[SQ_LINK_NOTICE][
'calendar_event_recurring'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
166 if (isset($_GET[
'sq_from_frontend'])) {
169 if (is_null($bodycopy)) {
170 trigger_localised_error(
'CORE0016', $this->name.
'"', E_USER_ERROR);
176 if (!isset($_SESSION[
'sq_nav_history'])) {
177 $_SESSION[
'sq_nav_history'] = Array();
180 $nav_pos = count($_SESSION[
'sq_nav_history']) - 1;
182 $_SESSION[
'sq_nav_history'][$nav_pos] = Array(
'assetid' => $this->
id,
'screen' =>
'details');
184 $bodycopy->paintBackend($o);
188 parent::paintBackend($o);
203 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this);
205 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
206 if ($contextid === 0) {
207 $cache_key =
'default';
209 $cache_key =
'default.'.$contextid;
212 $cm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cache_manager');
213 $cached_contents = $cm->loadFromCache($this->
id, $this->
type(), $cache_key);
217 if ($cached_contents === FALSE) {
219 if (is_null($bodycopy))
return;
222 $keywords = $bodycopy->getKeywords();
223 $replacements = Array();
224 foreach ($keywords as $word) {
227 $bodycopy->setKeywordReplacements($replacements);
229 $bodycopy->printBody();
230 $cm->saveToCache($this->
id, $this->
type(), $cache_key, ob_get_contents());
233 echo $cached_contents;
237 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this);
252 $lm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'layout_manager');
253 $screen = array_get_index($_REQUEST,
'asset_ei_screen',
'details');
256 $layout_pattern =
'layout::'.$this->type().
'::details';
258 $details_layout =
'';
259 foreach ($lookup_values as $values) {
260 foreach ($values as $look_key => $look_value) {
261 if (isset($look_value[
'value'])) {
262 $details_layout = $look_value[
'value'];
267 if (!empty($details_layout) && ($details_layout > 0)) {
269 }
else if ($lm->hasLayout($this, $screen)) {
274 if (!is_null($bodycopy)) {
275 $edit_interface = $bodycopy->getEI();
276 $available_screens = array_keys(array_merge($edit_interface->getScreens(), $edit_interface->_edit_fns->static_screens));
277 if (in_array($screen, $available_screens)) {
278 $GLOBALS[
'SQ_SYSTEM']->backend->out->addFormActionGetVar(
'assetid', $bodycopy->id);
279 $GLOBALS[
'SQ_SYSTEM']->backend->out->addHiddenField(
'backend_assetid', $bodycopy->id);
280 $bodycopy->initLimbo();
299 if (is_null($bodycopy))
return '';
300 $contents = $bodycopy->getRawBodycopyContent();
315 $lock_types = parent::lockTypes();
316 $lock_types[
'content'] = ($lock_types[
'attributes'] | $lock_types[
'links']);
333 if (!is_array($keywords) || empty($keywords)) {
336 if (!in_array(
'contents', $keywords))
return Array();
337 return Array(
'content');
351 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'',
'major');
352 if (empty($link))
return $null;
353 $bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
370 if (!is_array($keywords) || empty($keywords)) {
373 $print_commit_button = FALSE;
375 $replacements = Array();
376 foreach ($keywords as $keyword) {
380 if (is_null($bodycopy))
continue;
381 $edit = $bodycopy->getEditFns();
382 if (!$invoke_backend) {
383 $o = $GLOBALS[
'SQ_SYSTEM']->backend->out ;
385 require_once SQ_INCLUDE_PATH.
'/backend_outputter.inc';
389 if ($edit->paintBodycopy($bodycopy, $o, $bodycopy->getPrefix())) {
390 $print_commit_button = TRUE;
392 $replacements[$keyword] = ob_get_contents();
397 $replacements[$keyword] =
'';
402 return Array(
'replacements' => $replacements,
'print_commit_button' => $print_commit_button);
418 if (!is_array($keywords) || empty($keywords)) {
422 foreach ($keywords as $keyword) {
426 if (is_null($bodycopy))
continue;
427 $edit = $bodycopy->getEditFns();
428 $edit->processBodycopy($bodycopy, $GLOBALS[
'SQ_SYSTEM']->backend->out, $bodycopy->getPrefix());