Add extract cell functions.
authorMaxime Bourget <bmx007@gmail.com>
Mon, 6 May 2013 19:39:07 +0000 (20:39 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Mon, 6 May 2013 19:39:07 +0000 (20:39 +0100)
includes/order_lines.inc

index b02993a2274c31449ad08404d442badaec0bd232..54b2a7faec8eb4f309827d4492f7b8afe39f0f35 100644 (file)
@@ -1,5 +1,36 @@
 <?php
 include_once($path_to_root."/includes/ui/ui_input.inc");
+/* 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 {
+print_r('cacou');
+               return $td;
+       }
+}
+
+?>
+
+
 
 function update_extra_order_details() {
        if(!isset($_POST['Update']) || $_POST['Update'] != 'Update')  return;