Skip to content

Instantly share code, notes, and snippets.

@markphi2013
Last active August 29, 2015 14:02
Show Gist options
  • Save markphi2013/e6c862ca594ba6430ae5 to your computer and use it in GitHub Desktop.
Save markphi2013/e6c862ca594ba6430ae5 to your computer and use it in GitHub Desktop.
public function checkFilterFields($filter)
{
$filterErrors = array();
$filter['filter_param'] = array_filter(
$filter['filter_param'],
function($filterParam) use (&$filterErrors) {
if (in_array("", $filterParam)) {
if ($filterParam[1] == "") {
$filterErrors[] = "first filter field is missing";
} else if ($filterParam[2] == "") {
$filterErrors[] = $filterParam[1];
} else {
//$filterErrors[] = $filterParam[1]." ".$filterParam[2];
$filterErrors[] = localizedValue($filterParam[1])." ".localizedValue($filterParam[2]);
}
return false; //will filter out
}
return true; // will keep this filter
});
$filterCheck['filter'] = $filter;
$filterCheck['filterErrors'] = $filterErrors;
return $filterCheck;
}
public function localizedValue(&$filterParam)
{
$t = array(
'not-with' => __('not with'),
'start-with' => __('start with'),
'phone' => __('phone'),
'tagged' => __('tagged'));
$localizedLabel = $t[$filterParam];
//print_r($localizedLabel);
//$checkedFilterErrorsValue = str_replace('-', ' ', $checkedFilterErrors);
return $localizedLabel;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment