Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
text.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_attribute.inc';
19 
20 
36 {
37 
38 
45  function Asset_Attribute_Text($attributeid=0, $value=null)
46  {
47  $this->Asset_Attribute($attributeid, $value, Array('max_length' => 0));
48 
49  // set default edit parameters
50  $this->_edit_params['width'] = 0;
51  $this->_edit_params['height'] = 1;
52 
53  }//end constructor
54 
55 
64  function paintEditParams($prefix, $write_access=false)
65  {
66  echo '<b>Text Attribute " '.ucwords(str_replace('_', ' ', $this->name)).' " ('.$this->name.')</b><br />';
67  ?>
68  <table class="sq-backend-table">
69  <tr>
70  <td class="sq-backend-section-heading" style="width: 100px;"><?php echo translate('width'); ?></td>
71  <td class="sq-backend-table-cell">
72  <?php
73  if ($write_access) {
74  text_box($prefix.'_'.$this->name.'_width', $this->_edit_params['width']);
75  } else {
76  echo $this->_edit_params['width'];
77  }
78  ?>
79  </td>
80  </tr>
81  <tr>
82  <td class="sq-backend-section-heading" style="width: 100px;"><?php echo translate('height'); ?></td>
83  <td class="sq-backend-table-cell">
84  <?php
85  if ($write_access) {
86  text_box($prefix.'_'.$this->name.'_height', $this->_edit_params['height']);
87  } else {
88  echo $this->_edit_params['height'];
89  }
90  ?>
91  </td>
92  </tr>
93  </table>
94  <?php
95 
96  }//end paintEditParams()
97 
98 
107  function processEditParams($prefix)
108  {
109  // reading submitted vars
110  if (!empty($_POST[$prefix.'_'.$this->name.'_width'])) {
111  $this->_edit_params['width'] = $_POST[$prefix.'_'.$this->name.'_width'];
112  }
113 
114  if (!empty($_POST[$prefix.'_'.$this->name.'_height'])) {
115  $this->_edit_params['height'] = $_POST[$prefix.'_'.$this->name.'_height'];
116  }
117 
118  $values = Array();
119  $values['width'] = $this->_edit_params['width'];
120  $values['height'] = $this->_edit_params['height'];
121 
122  return $values;
123 
124  }//end processEditParams()
125 
126 
136  function setEditParams(&$node)
137  {// TODO TOF TEST
138  if (!parent::setEditParams($node)) return false;
139 
140  if (isset($node->attributes()->width)) {
141  $this->_edit_params['width'] = (int) $node->attributes()->width;
142  }
143  if (isset($node->attributes()->height)) {
144  $this->_edit_params['height'] = (int) $node->attributes()->height;
145  }
146 
147  return true;
148 
149  }//end setEditParams()
150 
151 
161  function paint($prefix, $read_only=false)
162  {
163  if ($read_only) {
164  echo nl2br(htmlspecialchars($this->value));
165  return;
166  }
167 
168  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
169 
170  if ($this->_edit_params['height'] > 1) {
171  text_area($prefix, $this->value, $this->_edit_params['width'], $this->_edit_params['height'], $this->_params['max_length']);
172  } else {
173  text_box($prefix, $this->value, $this->_edit_params['width'], $this->_params['max_length']);
174  }
175 
176  }//end paint()
177 
178 
187  function process($prefix)
188  {
189  if (!isset($_REQUEST[$prefix])) return false;
190  $value = (string) $_REQUEST[$prefix];
191  if ($this->value !== $value && $this->setValue($value)) {
192  $this->processed = true;
193  } else {
194  $this->processed = false;
195  }
196 
197  }//end process()
198 
199 
208  function validateValue(&$value)
209  {
210  $new_value = (string) $value;
211  if ($new_value != $value) return false;
212  $value = $new_value;
213  return true;
214 
215  }//end validateValue()
216 
217 
218 }//end class
219 
220 ?>