Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_asset_listing_edit_fns.inc
1 <?php
18 require_once SQ_PACKAGES_PATH.'/cms/listing_engine/listing_engine_edit_fns.inc';
19 require_once SQ_LIB_PATH.'/html_form/html_form.inc';
20 
34 {
35 
36 
41  function __construct()
42  {
43  parent::__construct();
44 
45  }//end constructor
46 
47 
58  function paintLinkTypes(&$asset, &$o, $prefix)
59  {
60  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
61  $write_access = $asset->writeAccess('attributes');
62 
63  $current = $asset->attr('link_types');
64  $link_types = get_link_type_names();
65 
66  if ($write_access) {
67  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
68 
69  $selected = Array();
70  foreach ($link_types as $link_type => $link_type_name) {
71  if ($current & $link_type) {
72  $selected[] = $link_type;
73  }
74  }
75 
76  combo_box($prefix.'_link_types', $link_types, TRUE, $selected);
77  hidden_field($prefix.'_link_types_submitted', '1');
78  } else {
79  if (($current == 0) && ($asset->attr('subs_only'))){
80  echo '<p class="sq-backend-warning">'.translate('cms_listing_no_link_types_selected').'</p>';
81  } else {
82  echo '<ul>';
83  foreach ($link_types as $link_type => $link_type_name) {
84  if ($current & $link_type) {
85  echo '<li>'.$link_type_name.'</li>';
86  }
87  }
88  echo '</ul>';
89  }
90  }
91 
92  return $write_access;
93 
94  }//end paintLinkTypes()
95 
96 
107  function processLinkTypes(&$asset, &$o, $prefix)
108  {
109  // need to have write access to make any changes
110  if (!$asset->writeAccess('attributes')) return FALSE;
111  if (empty($_POST[$prefix.'_link_types_submitted'])) return FALSE;
112 
113  $link_types = 0;
114  if (isset($_POST[$prefix.'_link_types'])) {
115  foreach ($_POST[$prefix.'_link_types'] as $link_type) {
116  $link_types |= $link_type;
117  }
118  }
119 
120  return $asset->setAttrValue('link_types', $link_types);
121 
122  }//end processLinkTypes()
123 
124 
125 }//end class
126 
127 ?>