Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
comment_edit_fns.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/page/page_edit_fns.inc';
18 
32 {
33 
34 
45  function paintName(&$asset, &$o, $prefix)
46  {
47  $write_access = $asset->writeAccess('attributes');
48  $size = $GLOBALS['SQ_SYSTEM']->getUserPrefs($asset->type(), 'SQ_COMMENT_INPUT_SIZE');
49 
50  if ($write_access) {
51  $name = isset($_REQUEST[$prefix.'_name']) ? $_REQUEST[$prefix.'_name'] : $asset->attr('name_raw');
52  text_box($prefix.'_name', $name, '', '', FALSE, 'style="width: '.$size['width'].';"');
53  } else {
54  echo $asset->attr('name');
55  }
56 
57  return TRUE;
58 
59  }//end paintName()
60 
61 
72  function processName(&$asset, &$o, $prefix)
73  {
74  $write_access = $asset->writeAccess('attributes');
75 
76  if ($write_access && isset($_REQUEST[$prefix.'_name']) === TRUE) {
77  $value = array_get_index($_REQUEST, $prefix.'_name');
78  $asset->setAttrValue('name', $value);
79  $asset->setAttrValue('short_name', $asset->attr('name'));
80 
81  }
82 
83  return TRUE;
84 
85  }//end processName()
86 
87 
98  function paintRating(&$asset, &$o, $prefix)
99  {
100  $write_access = $asset->writeAccess('attributes');
101 
102  $current_setting = $asset->attr('rating');
103  if ($current_setting != -1) {
104  $current_setting = $asset->_getRatingScaledInteger();
105  }
106 
107  if ($write_access) {
108  $max_rating = $asset->_getRatingLimit();
109 
110  $option_array[-1] = 'No Rating';
111  for ($i = 0; $i<=$max_rating; $i++) {
112  $option_array[$i] = $i;
113  }
114 
115  combo_box($prefix.'_rating', $option_array, FALSE, $current_setting);
116  } else {
117  echo $current_setting;
118  }
119 
120  return TRUE;
121 
122  }//end paintRating()
123 
124 
135  function processRating(&$asset, &$o, $prefix)
136  {
137  $write_access = $asset->writeAccess('attributes');
138 
139  if ($write_access && isset($_REQUEST[$prefix.'_rating']) === TRUE) {
140  $value = array_get_index($_REQUEST, $prefix.'_rating');
141 
142  if ($value != -1) {
143  $percent = $asset->_convertIntegerRatingToPercent($value);
144  $asset->setAttrValue('rating', $percent);
145  }
146  }
147 
148  return TRUE;
149 
150  }//end processRating()
151 
152 
163  function paintComment(&$asset, &$o, $prefix)
164  {
165  $write_access = $asset->writeAccess('attributes');
166 
167  $size = $GLOBALS['SQ_SYSTEM']->getUserPrefs($asset->type(), 'SQ_COMMENT_INPUT_SIZE');
168  $length = $GLOBALS['SQ_SYSTEM']->getUserPrefs($asset->type(), 'SQ_COMMENT_MAX_LENGTH');
169 
170  if ($write_access) {
171  $comment = isset($_REQUEST[$prefix.'_comment']) ? $_REQUEST[$prefix.'_comment'] : $asset->attr('comment_raw');
172  text_area($prefix.'_comment', $comment, 0, 0, $length, 'style="width: '.$size['width'].'; height: '.$size['height'].';"');
173  } else {
174  echo $asset->attr('comment');
175  }
176 
177  return TRUE;
178 
179  }//end paintComment()
180 
181 
192  function processComment(&$asset, &$o, $prefix)
193  {
194  $write_access = $asset->writeAccess('attributes');
195 
196  if ($write_access && isset($_REQUEST[$prefix.'_comment']) === TRUE) {
197  $comment = array_get_index($_REQUEST, $prefix.'_comment');
198  $asset->setAttrValue('comment', $comment);
199  }
200 
201  return TRUE;
202 
203  }//end processComment()
204 
205 
216  function paintAuthor(&$asset, &$o, $prefix)
217  {
218  if (!empty($asset->created_userid)) {
219  echo get_asset_tag_line($asset->created_userid, 'details');
220  } else {
221  echo isset($GLOBALS['SQ_SYSTEM']->user) ? $GLOBALS['SQ_SYSTEM']->user->name : '';
222  }
223  return TRUE;
224 
225  }//end paintAuthor()
226 
227 
228 }//end class
229 ?>