Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
bodycopy_div.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/bodycopy/bodycopy_container/bodycopy_container.inc';
18 
31 {
32 
33 
40  function __construct($assetid=0)
41  {
42  $this->_ser_attrs = TRUE;
43  parent::__construct($assetid);
44 
45  }//end __construct()
46 
47 
60  protected function _createAdditional(Array &$link)
61  {
62  // grab the bodycopy data that we stored in the create() function
63  $bc_data = $this->_tmp['bodycopy_create_data'];
64  unset($this->_tmp['bodycopy_create_data']);
65 
66  if (!parent::_createAdditional($link)) return FALSE;
67 
68  // set the name to what they entered - if they entered anything, otherwise use a default unique name
69  if (isset($bc_data['attributes']['identifier']) && trim($bc_data['attributes']['identifier']) != '') {
70  $this->setAttrValue('name', $bc_data['attributes']['identifier']);
71  } else {
72  $this->setAttrValue('name', $this->attr('name').' '.$this->id);
73  }
74 
75  // create a content type based on the user selection in the popup
76  // If this isn't set, use the default content type
77  if (isset($bc_data['attributes']['content_type'])) {
78  $content_type = $bc_data['attributes']['content_type'];
79  } else {
80  $content_type = $GLOBALS['SQ_SYSTEM']->getUserPrefs('bodycopy_container', 'SQ_DEFAULT_CONTENT_TYPE');
81  }
82  $GLOBALS['SQ_SYSTEM']->am->includeAsset($content_type);
83  $wysiwyg = new $content_type();
84  $div_link = Array('asset' => &$this, 'link_type' => SQ_LINK_TYPE_2, 'value' => 'div_contents', 'sort_order' => 1, 'is_dependant' => 1, 'is_exclusive' => 1);
85  $wysiwyg->setAttrValue('name', 'DIV Content');
86  if (isset($bc_data['content']) && (trim($bc_data['content'] != ''))) {
87  $wysiwyg->setAttrValue('html', $bc_data['content']);
88  }
89  if (!$wysiwyg->create($div_link)) return FALSE;
90 
91  if (!($lock_status = $GLOBALS['SQ_SYSTEM']->am->acquireLock($this->id, 'attributes'))) {
92  return FALSE;
93  }
94 
95  $edit_fns = $this->getEditFns();
96 
97  // Use the specified Presentation Type if provided, otherwise use the default set in "Global Preferences"
98  if (!isset($bc_data['attributes']['layout_type'])) {
99  $default_layout_type = $GLOBALS['SQ_SYSTEM']->getUserPrefs('bodycopy_container', 'SQ_DEFAULT_PRESENTATION_TYPE');
100 
101  $attributes = $this->attr('attributes');
102 
103  $saved = $edit_fns->setAttribute($attributes, 'layout_type', $default_layout_type);
104  $this->setAttrValue('attributes', $attributes);
105  }
106 
107  if (!$this->saveAttributes() || !$edit_fns->generateContentFile($this)) {
108  return FALSE;
109  }
110 
111  if ($lock_status == 1) {
112  if (!$GLOBALS['SQ_SYSTEM']->am->releaseLock($this->id, 'attributes')) {
113  return FALSE;
114  }
115  }
116 
117  return TRUE;
118 
119  }//end _createAdditional()
120 
121 
129  public function _getAllowedLinks()
130  {
131  return Array(
132  SQ_LINK_TYPE_2 => Array(
133  'content_type' => Array(
134  'card' => '1',
135  'exclusive' => TRUE,
136  ),
137  ),
138  SQ_LINK_NOTICE => Array(
139  'asset' => Array(
140  'card' => 'M',
141  'exclusive' => FALSE,
142  ),
143  ),
144  );
145 
146  }//end _getAllowedLinks()
147 
148 
155  public function getContentType()
156  {
157  if (SQ_IN_BACKEND || SQ_IN_LIMBO || !isset($this->_tmp['content_type'])) {
158  unset($this->_tmp['content_type']);
159  $link = $GLOBALS['SQ_SYSTEM']->am->getLink($this->id, SQ_LINK_TYPE_2, 'content_type', FALSE, 'div_contents', 'major', TRUE);
160  if (!empty($link)) {
161  $this->_tmp['content_type'] = $GLOBALS['SQ_SYSTEM']->am->getAsset($link['minorid'], $link['minor_type_code']);
162  if (is_null($this->_tmp['content_type'])) {
163  echo translate('content_type_not_found', $link['minorid']);
164  }
165  } else {
166  $null = NULL;
167  $this->_tmp['content_type'] = $null;
168  }
169  }
170  return $this->_tmp['content_type'];
171 
172  }//end getContentType()
173 
174 
175 }//end class
176 
177 ?>