private function prettifyCriteria($alert_criteria) { $text = ''; if ($alert_criteria) { $criteria = explode(' ', $alert_criteria); $words = array(); $spokenby = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($alert_criteria)); foreach ($criteria as $c) { if (!preg_match('#^speaker:(\\d+)#', $c, $m)) { $words[] = $c; } } if ($spokenby && count($words)) { $text = implode(' or ', $spokenby) . ' mentions [' . implode(' ', $words) . ']'; } else { if (count($words)) { $text = '[' . implode(' ', $words) . ']' . ' is mentioned'; } else { if ($spokenby) { $text = implode(' or ', $spokenby) . " speaks"; } } } return $text; } return $text; }
public function criteria_pretty($html = false) { $criteria = explode(' ', $this->criteria); $spokenby = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($alert_criteria)); $words = array(); foreach ($criteria as $c) { if (!preg_match('#^speaker:(\\d+)#', $c, $m)) { $words[] = $c; } } $criteria = ''; if (count($words)) { $criteria .= ($html ? '<li>' : '* ') . 'Mentions of [' . join(' ', $words) . ']' . ($html ? '</li>' : '') . "\n"; } if ($spokenby) { $criteria .= ($html ? '<li>' : '* ') . "Things by {$spokenby}" . ($html ? '</li>' : '') . "\n"; } return $criteria; }