18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
44 $this->
Asset($assetid);
60 if (!parent::_preCreateCheck($link))
return FALSE;
62 $name = trim($this->
attr(
'name'));
64 trigger_localised_error(
'CORE0083', E_USER_WARNING, $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->type(),
'name'));
83 if (!parent::_createAdditional($link))
return FALSE;
86 $initial_path = strtolower($this->
attr(
'name'));
87 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
88 $valid_paths = make_valid_web_paths(Array($initial_path));
89 $good_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($link[
'asset'], $valid_paths, $this->
id, TRUE);
93 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
95 $copy_link = Array(
'asset' => &$this,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 0);
96 $bodycopy->setAttrValue(
'name',
'Page Contents');
97 if (!$bodycopy->create($copy_link))
return FALSE;
100 if (!empty($this->_tmp[
'pending_children'])) {
101 foreach ($this->_tmp[
'pending_children'] as $entry) {
102 if (!$entry[
'asset']->
create($entry[
'link'])) {
109 $this->short_name = $this->
_getName();
124 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
125 $return_value = TRUE;
129 $components = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($clone->id);
130 foreach ($components as $componentid => $component) {
132 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($componentid);
134 $initial_path = strtolower($asset->name);
135 $valid_paths = make_valid_web_paths(Array($initial_path));
136 $good_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($clone, $valid_paths, $asset->id, TRUE);
137 $GLOBALS[
'SQ_SYSTEM']->acquireLock($asset->id,
'all');
138 $return_value = $asset->saveWebPaths($good_paths);
139 $value = (!$return_value) ? FALSE : TRUE;
141 $return_value = $asset->updateLookups(FALSE);
142 $value = (!$return_value) ? FALSE : TRUE;
143 $GLOBALS[
'SQ_SYSTEM']->releaseLock($asset->id,
'all');
144 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
161 $allowed = parent::_getAllowedLinks();
162 $allowed[SQ_LINK_TYPE_1][
'folder'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
163 $allowed[SQ_LINK_TYPE_2][
'folder'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
164 $allowed[SQ_LINK_TYPE_3][
'calendar_event'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
165 $allowed[SQ_LINK_TYPE_2][
'calendar_event'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
166 $allowed[SQ_LINK_TYPE_2][
'bodycopy'] = Array(
'card' => 1,
'exclusive' => FALSE);
181 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
182 if ($contextid === 0) {
183 $cache_key =
'default';
185 $cache_key =
'default.'.$contextid;
188 $cm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cache_manager');
189 $cached_contents = $cm->loadFromCache($this->
id, $cache_key);
192 if ($cached_contents === FALSE) {
197 if (!is_null($bodycopy)) {
198 $bodycopy->printBody();
199 $cm->saveToCache($this->
id, $this->
type(), $cache_key, ob_get_contents());
203 echo $cached_contents;
217 return $this->
attr(
'short_date');
232 protected function _getName($short_name=FALSE, $contextid=NULL)
235 if ($contextid === NULL) {
236 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
240 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
241 if (empty($values) === TRUE) {
242 return parent::_getName($short_name, $contextid);
244 return $values[$this->id];
265 if ($name ==
'name') {
266 $this->_tmp[
'name_updated'] = TRUE;
268 if ($name ==
'short_date') {
269 $this->_tmp[
'short_date_updated'] = TRUE;
271 return parent::setAttrValue($name, $value);
285 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'',
'major');
286 if (empty($link))
return $null;
287 $bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
305 trigger_error(
'Cannot add pending child - parent is already created');
308 if (empty($this->_tmp[
'pending_children'])) {
309 $this->_tmp[
'pending_children'] = Array();
311 $this->_tmp[
'pending_children'][] = Array(
'asset' => $asset,
'link' => $link);
327 if (!is_array($keywords) || empty($keywords)) {
330 $print_commit_button = FALSE;
332 $replacements = Array();
333 foreach ($keywords as $keyword) {
337 if (is_null($bodycopy))
continue;
338 $edit = $bodycopy->getEditFns();
339 if (!$invoke_backend) {
340 $o = $GLOBALS[
'SQ_SYSTEM']->backend->out ;
342 require_once SQ_INCLUDE_PATH.
'/backend_outputter.inc';
346 if ($edit->paintBodycopy($bodycopy, $o, $bodycopy->getPrefix())) {
347 $print_commit_button = TRUE;
349 $replacements[$keyword] = ob_get_contents();
354 $replacements[$keyword] =
'';
359 return Array(
'replacements' => $replacements,
'print_commit_button' => $print_commit_button);
375 if (!is_array($keywords) || empty($keywords)) {
379 foreach ($keywords as $keyword) {
383 if (is_null($bodycopy))
continue;
384 $edit = $bodycopy->getEditFns();
385 $edit->processBodycopy($bodycopy, $GLOBALS[
'SQ_SYSTEM']->backend->out, $bodycopy->getPrefix());
406 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
409 if (!create_directory($this->data_path)) {
410 trigger_localised_error(
'CORE0049', E_USER_WARNING, $this->name);
414 switch ($new_status) {
415 case SQ_STATUS_EDITING:
417 if ($this->status == SQ_STATUS_LIVE) {
418 $child_events = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_3, Array(
'calendar_event_single',
'calendar_event_recurring'), FALSE);
419 file_put_contents($this->data_path.
'/.safe_edit_before', serialize($child_events));
420 file_put_contents($this->data_path.
'/.safe_edit_after', serialize($child_events));
424 if ($this->status == SQ_STATUS_EDITING) {
426 $before_safe_edit = Array();
427 $after_safe_edit = Array();
428 $before_safe_edit_string = file_to_string($this->data_path.
'/.safe_edit_before');
429 $after_safe_edit_string = file_to_string($this->data_path.
'/.safe_edit_after');
431 if (!empty($before_safe_edit_string)) {
432 $before_safe_edit = @unserialize($before_safe_edit_string);
434 if (!empty($after_safe_edit_string)) {
435 $after_safe_edit = @unserialize($after_safe_edit_string);
438 if (!empty($after_safe_edit)) {
439 foreach ($after_safe_edit as $active_link) {
440 if (!$this->
_compareLink($active_link, $before_safe_edit)) {
442 if (isset($active_link[
'linkid'])) {
444 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
446 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
456 if ($this->status == SQ_STATUS_EDITING_APPROVED) {
464 return parent::processStatusChange($new_status, $update_parents);
480 if (!isset($current_link[
'minorid'])) {
486 if (empty($before_links)){
490 foreach ($before_links as $before_link) {
491 if (isset($before_link[
'minorid'])) {
492 if ($before_link[
'minorid'] == $current_link[
'minorid']) {
513 if (file_exists($this->data_path.
'/.safe_edit_after')) {
514 unlink($this->data_path.
'/.safe_edit_after');
516 if (file_exists($this->data_path.
'/.safe_edit_before')) {
517 unlink($this->data_path.
'/.safe_edit_before');