Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_area_linked_css_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/designs/design_area/design_area_edit_fns.inc';
19 
32 {
33 
34 
39  function __construct()
40  {
41  parent::__construct();
42 
43  }//end constructor
44 
45 
56  public function paintAssetid(Design_Area_Linked_CSS $asset, Backend_Outputter $o, $prefix)
57  {
58  if ($asset->writeAccess('links')) {
59  $type_code_restrictions['design_css'] = 'D';
60  $type_code_restrictions['design_css_customisation'] = 'D';
61  asset_finder($prefix.'_assetid', $asset->getLinkedCSSInfo('minorid'), $type_code_restrictions);
62 
63  } else if ($asset->getLinkedCSSInfo('minorid')) {
64  $link_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($asset->getLinkedCSSInfo('minorid'));
65  if (!is_null($link_asset)) {
66  echo get_asset_tag_line($link_asset->id);
67  }
68 
69  }//end if
70 
71  return TRUE;
72 
73  }//end paintAssetid()
74 
75 
86  public function paintTagType(Design_Area_Linked_CSS $asset, Backend_Outputter $o, $prefix)
87  {
88  if ($asset->writeAccess('attributes')) {
89  $options = Array();
90  $options['link_tag'] = 'Link tag';
91  $options['import_tag'] = '@import tag';
92  combo_box($prefix.'_tag_type', $options, FALSE, $asset->attr('tag_type'));
93  } else {
94  switch ($asset->attr('tag_type')) {
95  case 'link_tag' :
96  echo 'Link Tag';
97  break;
98  case 'import_tag':
99  echo '@import tag';
100  break;
101  }
102  }//end if
103 
104  return TRUE;
105 
106  }//end paintTagType()
107 
108 
119  public function paintMedia(Design_Area_Linked_CSS $asset, Backend_Outputter $o, $prefix)
120  {
121  if ($asset->writeAccess('attributes')) {
122  $options = Array();
123  $options['all'] = 'All';
124  $options['aural'] = 'Aural';
125  $options['braille'] = 'Braille';
126  $options['embossed'] = 'Embossed';
127  $options['handheld'] = 'Handheld';
128  $options['print'] = 'Print';
129  $options['projection'] = 'Projection';
130  $options['screen'] = 'Screen';
131  $options['tty'] = 'TTY';
132  $options['tv'] = 'TV';
133  combo_box($prefix.'_media', $options, FALSE, $asset->attr('media'));
134  } else {
135  echo $asset->attr('media');
136  }//end if
137 
138  return TRUE;
139 
140  }//end paintMedia()
141 
142 
153  public function processTagType(Design_Area_Linked_CSS $asset, Backend_Outputter $o, $prefix)
154  {
155  $tag_type = (int) (isset($_POST[$prefix.'_tag_type'])) ? $_POST[$prefix.'_tag_type'] : '';
156  return $asset->setAttrValue('tag_type', $tag_type);
157 
158  }//end processTagType()
159 
160 
171  public function processMedia(Design_Area_Linked_CSS $asset, Backend_Outputter $o, $prefix)
172  {
173  $media = (int) (isset($_POST[$prefix.'_media'])) ? $_POST[$prefix.'_media'] : '';
174  return $asset->setAttrValue('media', $media);
175 
176  }//end processMedia()
177 
178 
189  public function processAssetid(Design_Area_Linked_CSS $asset, Backend_Outputter $o, $prefix)
190  {
191  if (!isset($_POST[$prefix.'_assetid']['assetid'])) {
192  return FALSE;
193  }
194 
195  if ($asset->getLinkedCSSInfo('minorid') == $_POST[$prefix.'_assetid']['assetid']) {
196  return FALSE;
197  }
198 
199  $assetid = (int) $_POST[$prefix.'_assetid']['assetid'];
200 
201  // open the transaction
202  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
203  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
204 
205  // remove the old link first
206  if ($old_linkid = $asset->getLinkedCSSInfo('linkid')) {
207  if (!$asset->deleteLink($old_linkid)) {
208  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
209  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
210  return FALSE;
211  }
212  }
213 
214  // now create the new link
215  if ($assetid) {
216  $link_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid);
217  if (is_null($link_asset)) {
218  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
219  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
220  return FALSE;
221  }
222  if (!$asset->createLink($link_asset, SQ_LINK_NOTICE, 'linked_css_asset')) {
223  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
224  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
225  return FALSE;
226  }
227  }
228 
229  // If we get this far, then it's all OK
230  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
231  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
232 
233  return TRUE;
234 
235  }//end processAssetid()
236 
237 
238 }//end class
239 ?>