+/* This utility function remove beginning <td> and </td> from a string
+ * generated by the above *_cell function.
+ * This is usefull to use the result of the function within a pager
+ * which already include the <td>...</td>
+ * However, for function which doesn't return a string
+ * but echo, we need to capture the output of the echo first.
+ */
+function start_extract_cell() {
+ // We need
+ ob_start();
+}
+
+function end_extract_cell() {
+ $content = ob_get_contents();
+ ob_end_clean();
+ return extract_cell($content);
+}
+
+function extract_cell($td) {
+ if(preg_match('/\s*<td>(.*)<\/td>\s*/s', $td, $matches)) {
+ return $matches[1];
+ }
+ else {
+ return $td;
+ }
+}
+
+/* remove unchecked data so each
+ * funcion doesn't to check what's been checked or not.
+ */
+function filter_data(&$data) {
+ if(!isset($data['detail'])) return;
+ $new_details = array();
+ foreach(@$data['detail'] as $detail_id => $values) {
+ if(@$values['check'] === 'on') $new_details[$detail_id]=$values;
+ }
+ $data['detail'] = $new_details;
+}
+
+function post_to_detail_ids() {
+ if(!isset($_POST['detail'])) return;
+ $detail_ids = array();
+ foreach($_POST['detail'] as $detail_id => $values) {
+ array_push($detail_ids, $detail_id);
+ }
+
+ return $detail_ids;
+}