Skip to content

Instantly share code, notes, and snippets.

@dtbaker
Created March 28, 2015 11:12
Show Gist options
  • Save dtbaker/d9385a79d01965504752 to your computer and use it in GitHub Desktop.
Save dtbaker/d9385a79d01965504752 to your computer and use it in GitHub Desktop.
Regex the UCM task list before external/PDF generation
<?php
<?php
/*
* Upload this file to a new folder called:
* /custom/includes/plugin_invoice/template/invoice_task_list.php
* This file will get included instead of the default invoice_task_list.php file
* This file gets the default invoice task list generated HTML content and performs a regex on it
* Useful for some minor task list modifications without editing the entire task list file.
*/
ob_start();
include('includes/plugin_invoice/template/invoice_task_list.php');
$generated_task_list_html = ob_get_clean();
if(preg_match_all('#<td class="item_description">(.*)</td>#imsU',$generated_task_list_html,$matches)){
foreach($matches[1] as $key => $val){
$val = trim($val);
$val = preg_replace('#^(.*)(<em>.*</em>)?$#imsU','<strong>$1</strong>$2',$val);
$val = str_replace('<em>','<span>',$val);
$val = str_replace('</em>','</span>',$val);
$generated_task_list_html = str_replace($matches[0][$key],'<td class="item_description">'.$val.'</td>',$generated_task_list_html);
}
}
echo $generated_task_list_html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment