18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
19 require_once SQ_FUDGE_PATH.
'/general/text.inc';
44 parent::__construct($assetid);
61 if (!parent::_preCreateCheck($link))
return FALSE;
63 $name = trim($this->
attr(
'name'));
65 trigger_localised_error(
'CORE0083', E_USER_WARNING, $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->type(),
'name'));
98 protected function _getName($short_name=FALSE, $contextid=NULL)
101 if ($contextid === NULL) {
102 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
106 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
107 if (empty($values) === TRUE) {
108 return parent::_getName($short_name, $contextid);
110 return $values[$this->id];
124 $html = trim($this->
attr(
'html'));
138 return trim($this->
attr(
'html'));
173 $contents_changed = isset($this->_tmp[
'vars_set'][
'html']);
176 if ($contents_changed) {
178 $bc_container_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'bodycopy_container', FALSE,
'minor');
179 if (!empty($bc_container_link)) {
180 $container = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bc_container_link[0][
'majorid']);
181 $contextid = (int)$GLOBALS[
'SQ_SYSTEM']->getContextId();
182 $datapath = $container->data_path;
186 if($contextid === 0 && !empty($datapath)) {
187 $contextids = array_keys($GLOBALS[
'SQ_SYSTEM']->getAllContexts());
188 foreach ($contextids as $id) {
189 $file = $datapath.
'/content_file.'.$id.
'.php';
190 if(file_exists($file)) unlink($file);
195 $edit_fns = $container->getEditFns();
196 $edit_fns->generateContentFile($container);
200 $success = parent::saveAttributes($dont_run_updated);
202 if ($contents_changed && $success) {
203 $em = $GLOBALS[
'SQ_SYSTEM']->getEventManager();
204 $em->broadcastEvent($this,
'ContentsUpdated');
207 $top_level_parents = $GLOBALS[
'SQ_SYSTEM']->am-> getDependantParents($this->
id,
'', TRUE, FALSE);
208 foreach ($top_level_parents as $parentid) {
209 $parent = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($parentid);
210 $GLOBALS[
'SQ_SYSTEM']->broadcastTriggerEvent(
'trigger_event_asset_content_changed', $parent);
232 $am = $GLOBALS[
'SQ_SYSTEM']->am;
233 $bc_container_link = $am->getLink($this->
id, SQ_LINK_TYPE_2,
'bodycopy_container', FALSE, NULL,
'minor');
235 if (!empty($bc_container_link)) {
236 $bc_container = $am->getAsset($bc_container_link[
'majorid']);
237 $bc_link = $am->getLink($bc_container->id, SQ_LINK_TYPE_2,
'paint_layout_bodycopy', TRUE, NULL,
'minor');
239 if (!empty($bc_link)) {
240 $bodycopy = $am->getAsset($bc_link[
'majorid']);
241 $bodycopy->_updated();
256 $content_types = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeHierarchy(
'content_type');
258 if (isset($content_types[
'content_type_markdown'])) {
260 $disable_markdown = TRUE;
261 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
262 if (SQ_TOOL_MARKDOWN_ENABLED && is_file(SQ_TOOL_MARKDOWN_PATH)) {
263 include_once SQ_TOOL_MARKDOWN_PATH;
264 if (function_exists(
'Markdown')) {
265 $disable_markdown = FALSE;
268 if ($disable_markdown) {
269 unset($content_types[
'content_type_markdown']);
273 return $content_types;
291 $live_link_only = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'content_type_wysiwyg',
'SQ_LIVE_LINK_ONLY');
292 if ($live_link_only && $this->status == SQ_STATUS_LIVE && $name ===
'html') {
293 require_once SQ_FUDGE_PATH.
'/general/www.inc';
294 $outcome = check_non_live_link($value, $this->
id);
295 if ($outcome !== FALSE) $value = $outcome;
297 return parent::setAttrValue($name, $value);