17 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
40 parent::__construct($assetid);
53 $lock_types = parent::lockTypes();
54 $lock_types[
'link_url'] = ($lock_types[
'attributes'] | $lock_types[
'links']);
69 $page_links = parent::_getAllowedLinks();
70 $page_links[SQ_LINK_NOTICE][
'asset'] = Array(
'card' =>
'M',
'exclusive' =>
false);
89 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'',
true,
'link_asset');
95 return $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
110 if (!is_null($asset)) {
111 assert_is_a($asset,
'asset');
114 $old_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'',
true,
'link_asset');
115 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
116 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
117 if (empty($old_link)) {
119 if (is_null($asset)) {
120 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
121 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
126 }
else if (!is_null($asset) && $old_link[
'minorid'] == $asset->id) {
127 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
128 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
133 if (!$this->
deleteLink($old_link[
'linkid'])) {
134 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
135 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
140 if (!is_null($asset)) {
141 if (!$this->
createLink($asset, SQ_LINK_NOTICE,
'link_asset')) {
142 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
143 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
148 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
149 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
166 protected function _getName($short_name=FALSE, $contextid=NULL)
169 if ($contextid === NULL) {
170 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
174 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
175 if (empty($values) === TRUE) {
176 return parent::_getName($short_name, $contextid);
178 return $values[$this->id];
195 $GLOBALS[
'SQ_SYSTEM']->pm->startTimer($this);
198 if (($url = $this->
attr(
'link_url')) ==
'') {
200 if (!is_null($link_asset)) {
201 if (($url = $link_asset->getURL()) ==
'') {
202 $url = current_url().
'?a='.$link_asset->id;
208 $url .= trim($this->
attr(
'url_suffix'));
211 if ($this->
attr(
'show_headline')) {
212 if (!$url ==
'') echo
'<a href='.$url.
'>';
214 <h1><?php echo $this->
attr(
'name'); ?></h1>
216 if (!$url ==
'') echo
'</a>';
219 if ($this->
attr(
'show_summary')) {
221 <div
id=
"sq_news_summary">
222 <p><?php echo $this->
attr(
'summary'); ?></p>
227 if ($this->
attr(
'show_body')) {
229 <div
id=
"sq_news_body">
230 <p><?php echo $this->
attr(
'body'); ?></p>
235 if ($this->
attr(
'show_contact_name') || $this->
attr(
'show_contact_phone')) {
237 <div
id=
"sq_news_contact">
239 if ($this->
attr(
'show_contact_name')) {
241 <p><?php echo
'Contact: '.$this->attr(
'contact_name'); ?></p>
245 if ($this->
attr(
'show_contact_phone')) {
247 <p><?php echo
'Phone: '.$this->attr(
'contact_phone'); ?></p>
256 $GLOBALS[
'SQ_SYSTEM']->pm->stopTimer($this);
277 $res = parent::getAvailableKeywords();
278 $res[
'asset_name_linked_to_link_url'] =
'Asset name linked to link URL';
279 $res[
'link_url'] =
'The Link URL for this item';
296 return '<a href="'.$this->getURL().
'">'.$this->
attr(
'name').
'</a>';
298 return '<a href="'.$url.
'">'.$this->
attr(
'name').
'</a>';
314 if (is_null($link_asset)) {
315 $link_url = trim($this->
attr(
'link_url'));
316 if (!empty($link_url)) {
318 $suffix = $this->
attr(
'url_suffix');
319 if (!empty($suffix)) {
320 $url .=
'?'.trim($suffix);
324 $url = $link_asset->getURL();
326 $url = current_url().
'?a='.$link_asset->id;
343 return is_a($GLOBALS[
'SQ_SYSTEM']->user,
'user');
345 return parent::backendAccess();