Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
content_type_nest_content.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/content_type/content_type.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  $this->_ser_attrs = TRUE;
44  parent::__construct($assetid);
45 
46  }//end constructor
47 
48 
56  function _getAllowedLinks()
57  {
58  return Array(
59  SQ_LINK_NOTICE => Array(
60  'asset' => Array(
61  'card' => 1,
62  'exclusive' => FALSE,
63  ),
64  ),
65  );
66 
67  }//end _getAllowedLinks()
68 
69 
76  function isEmpty()
77  {
78  $link = $GLOBALS['SQ_SYSTEM']->am->getLink($this->id, SQ_LINK_NOTICE, '', TRUE, 'nested_asset');
79  return empty($link);
80 
81  }//end isEmpty()
82 
83 
92  function describeLink($linkid)
93  {
94  $link = $GLOBALS['SQ_SYSTEM']->am->getLinkById($linkid);
95  if ($link['value'] == 'nested_asset') {
96  return translate('cms_ct_nest_content_link_desc');
97  }
98 
99  }//end describeLink()
100 
101 
108  function getContent()
109  {
110  return '';
111 
112  }//end getContent()
113 
114 
121  function setContent()
122  {
123  return FALSE;
124 
125  }//end setContent()
126 
127 
135  public function linksUpdated()
136  {
137  // Only generate the parent bodycopy content if the asset is not being cloned
138  if (!isset($this->_tmp['edit_fns'])) {
139  // this function is called, which mean the asset we are
140  // nesting is modified (deleted) update our content file
141  $bodycopy_div_id = array_keys($GLOBALS['SQ_SYSTEM']->am->getParents($this->id, 'bodycopy_div', TRUE));
142  if (!empty($bodycopy_div_id)) {
143  $bodycopy_div = $GLOBALS['SQ_SYSTEM']->am->getAsset($bodycopy_div_id[0]);
144  $bodycopy_div_edit_fns = $bodycopy_div->getEditFns();
145  $all_context = $GLOBALS['SQ_SYSTEM']->getAllContexts();
146  foreach ($all_context as $context_id => $info) {
147  $GLOBALS['SQ_SYSTEM']->changeContext($context_id);
148  $bodycopy_div_edit_fns->generateContentFile($bodycopy_div);
149  $GLOBALS['SQ_SYSTEM']->restoreContext();
150  }
151  }
152  }
153 
154  return parent::linksUpdated();
155 
156  }//end linksUpdated()
157 
158 
165  public function getSnippetInterface()
166  {
167  $edit_fns = $this->getEditFns();
168  $nested_asset = $edit_fns->_getNestedAsset($this);
169  $asset_link = $GLOBALS['SQ_SYSTEM']->am->getAssetURL($nested_asset->id);
170 
171  if (empty($asset_link)) {
172  $asset_link = strip_url(current_url(FALSE, TRUE)).'/?a='.$nested_asset->id;
173  }
174  $content = '<strong>'.translate('cms_ct_nest_content_nested_content').get_asset_tag_line($nested_asset->id).'</strong> <a href="'.$asset_link.'" id="sq_preview_new_window" target="_blank">'.translate('cms_ct_nest_content_click_to_preview').'</a>.';
175 
176  return $content;
177 
178  }//end getSnippetInterface()
179 
180 
181 }//end class
182 
183 ?>