17 require_once SQ_CORE_PACKAGE_PATH.
'/page_templates/page_standard/page_standard.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/paint_layout/paint_layout_bodycopy/paint_layout_bodycopy.inc';
20 define(
'SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE',
'paint_layout_bodycopy');
21 define(
'SQ_PAINT_LAYOUT_REQUEST_VAR_ASSET',
'sqpa');
22 define(
'SQ_PAINT_LAYOUT_DEFAULT_FORMAT_NAME',
'default_format');
52 $this->_ser_attrs = TRUE;
53 parent::__construct($assetid);
70 if (!parent::_createAdditional($link, Array(
'content' =>
'%paint_layout%')))
return FALSE;
73 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE);
76 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'folder');
79 'type_formats' =>
'folder',
83 foreach ($sub_assets as $name => $type) {
85 $copy_link = Array(
'asset' => &$this,
'value' => $name ,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
87 $asset->setAttrValue(
'name', ucwords(str_replace(
'_',
' ', $name)));
88 if (!$asset->create($copy_link))
return FALSE;
90 if ($name ==
'type_formats') $type_formats = $asset;
92 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
97 $type_format_asset_type_code = SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE;
98 $asset =
new $type_format_asset_type_code();
101 'asset' => &$type_formats,
102 'value' => SQ_PAINT_LAYOUT_DEFAULT_FORMAT_NAME,
103 'link_type' => SQ_LINK_TYPE_2,
108 $asset->setAttrValue(
'name',
'Default Format');
110 return $asset->create($copy_link, Array(
'content' =>
'%asset_contents%'));
130 if ($name ==
'types' && !empty($value)) {
135 $orig_value = $value;
137 $levels = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($orig_value),
'lvl');
139 foreach ($levels as $type_code => $lvl) {
140 $value[$type_code] = $orig_value[$type_code];
145 return parent::setAttrValue($name, $value);
176 if (!isset($vars[
'keywords']))
return;
178 $parents = $GLOBALS[
'SQ_SYSTEM']->am->getParents($broadcaster->id);
184 if (is_null($folder))
return;
186 if (isset($parents[$folder->id])) {
187 $type_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($folder->id, SQ_LINK_TYPE_2, SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE);
189 foreach ($type_links as $link_info) {
190 if (isset($parents[$link_info[
'minorid']])) {
191 $type_code = $link_info[
'value'];
192 if ($type_code == SQ_PAINT_LAYOUT_DEFAULT_FORMAT_NAME) {
196 $type_format = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_info[
'minorid']);
197 if (!empty($type_format)) {
198 $type_format->getKeywordsDescription($vars[
'keywords'], $type_code);
207 $vars[
'keywords'][
'paint_layout'] =
'Paint Layout';
223 if (!empty($_REQUEST[SQ_PAINT_LAYOUT_REQUEST_VAR_ASSET])) {
224 $ret = $_REQUEST[SQ_PAINT_LAYOUT_REQUEST_VAR_ASSET];
242 if (!empty($assetid)) {
243 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
244 $this->
paint($asset);
261 if (!empty($asset)) {
263 if (is_null($bodycopy) || !$bodycopy->readAccess()) {
266 $keywords = $bodycopy->getKeywords();
268 $bodycopy->setKeywordReplacements($replacements);
269 $bodycopy->printBody();
289 if (in_array(
'paint_layout', $keywords)) {
290 $asset_type_code = $asset->type();
293 $ret[
'paint_layout'] = $bodycopy->paintAsset($asset);
314 $supported_types = $this->
attr(
'types');
317 foreach ($supported_types as $supported_type => $inherited) {
318 $supported_type_and_children = ($inherited) ? $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($supported_type, TRUE) : Array($supported_type);
319 if (in_array($asset_type_code, $supported_type_and_children)) {
320 $format_type = $supported_type;
327 if (!empty($format_type)) {
328 $format_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2, SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE, TRUE, $format_type);
331 $format_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2, SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE, TRUE, SQ_PAINT_LAYOUT_DEFAULT_FORMAT_NAME);
334 if (!empty($format_link)) {
335 $ret = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($format_link[
'minorid'], $format_link[
'minor_type_code']);
354 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_2,
'folder', TRUE, $type);
355 if (empty($link))
return $null;
357 $folder = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
358 if (is_null($folder))
return $null;
377 if (!isset($this->_tmp[
'formats'][$type])) {
379 $format_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($folder->id, SQ_LINK_TYPE_2, SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE, TRUE);
380 if (empty($format_links))
return Array();
383 foreach ($format_links as $link_data) {
384 $formats[$link_data[
'minorid']] = $link_data[
'value'];
386 $this->_tmp[
'formats'][$type] = $formats;
388 return $this->_tmp[
'formats'][$type];
408 $folder = $this->
getFolder(
'type_formats');
411 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2, SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE, TRUE, $new_type);
412 if (empty($current_link)) {
414 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
415 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
416 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE);
418 $copy_link = Array(
'asset' => &$folder,
'value' => $new_type,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
420 $type_format_asset_type_code = SQ_PAINT_LAYOUT_FORMAT_ASSET_TYPE;
421 $bodycopy =
new $type_format_asset_type_code();
422 $bodycopy->setAttrValue(
'name', $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($new_type,
'name').
' Format');
423 $bodycopy->setAttrValue(
'associated_asset_type', $type);
425 if ($bodycopy->create($copy_link)) {
426 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
429 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
431 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();