Merge branch 'test' into prod

This commit is contained in:
Erik Thuning 2024-02-21 16:33:08 +01:00
commit b14603c7fb
4 changed files with 15 additions and 15 deletions

@ -37,7 +37,7 @@ abstract class Page extends Responder {
$this->render_foot(); $this->render_foot();
} }
final private function render_head() { private function render_head() {
$headtitle = $this->title; $headtitle = $this->title;
$pagetitle = $this->title; $pagetitle = $this->title;
if($this->subtitle) { if($this->subtitle) {
@ -78,13 +78,13 @@ abstract class Page extends Responder {
return $menu; return $menu;
} }
final private function render_error() { private function render_error() {
print(replace(array('type' => 'error', print(replace(array('type' => 'error',
'message' => $this->error), 'message' => $this->error),
$this->fragments['message'])); $this->fragments['message']));
} }
final private function render_foot() { private function render_foot() {
print($this->template_parts['foot']); print($this->template_parts['foot']);
} }

@ -142,7 +142,7 @@ class Product extends Entity {
// If $key is a standard field, check against its value // If $key is a standard field, check against its value
$getter = $fields[$key]; $getter = $fields[$key];
$value = $this->$getter(); $value = $this->$getter();
if(match($term, $value)) { if(match_term($term, $value)) {
//Record a successful match //Record a successful match
$matches[$key] = $value; $matches[$key] = $value;
$matched = true; $matched = true;
@ -170,7 +170,7 @@ class Product extends Entity {
// First check basic fields // First check basic fields
foreach($fields as $field => $getter) { foreach($fields as $field => $getter) {
$value = $this->$getter(); $value = $this->$getter();
if(match($term, $value)) { if(match_term($term, $value)) {
$matches[$field] = $value; $matches[$field] = $value;
$matched = true; $matched = true;
} }
@ -189,7 +189,7 @@ class Product extends Entity {
} }
// Then custom fields // Then custom fields
foreach($this->get_info() as $field => $value) { foreach($this->get_info() as $field => $value) {
if(match($term, $value)) { if(match_term($term, $value)) {
//Record a successful match //Record a successful match
$matches[$field] = $value; $matches[$field] = $value;
$matched = true; $matched = true;
@ -202,7 +202,7 @@ class Product extends Entity {
if(isset($info[$key])) { if(isset($info[$key])) {
// If $key is a valid custom field on this product // If $key is a valid custom field on this product
$value = $info[$key]; $value = $info[$key];
if(match($term, $value)) { if(match_term($term, $value)) {
//Record a successful match //Record a successful match
$matches[$key] = $value; $matches[$key] = $value;
$matched = true; $matched = true;
@ -228,7 +228,7 @@ class Product extends Entity {
$tags = $this->get_tags(); $tags = $this->get_tags();
$matches = array(); $matches = array();
foreach($tags as $tag) { foreach($tags as $tag) {
if(match($term, $tag)) { if(match_term($term, $tag)) {
$matches[] = $tag; $matches[] = $tag;
} }
} }

@ -55,12 +55,12 @@ class User extends Entity {
case 'name': case 'name':
// If the key is name, check username and displayname // If the key is name, check username and displayname
$name = $this->get_name(); $name = $this->get_name();
if(match($term, $name)) { if(match_term($term, $name)) {
$matches['name'] = $name; $matches['name'] = $name;
$matched = true; $matched = true;
} }
$dname = $this->get_displayname($ldap); $dname = $this->get_displayname($ldap);
if(match($term, $dname)) { if(match_term($term, $dname)) {
$matches['displayname'] = $dname; $matches['displayname'] = $dname;
$matched = true; $matched = true;
} }
@ -68,14 +68,14 @@ class User extends Entity {
case 'note': case 'note':
// If the key is note, check it. // If the key is note, check it.
$note = $this->get_note(); $note = $this->get_note();
if($note && match($term, $note)) { if($note && match_term($term, $note)) {
$matches['note'] = $note; $matches['note'] = $note;
$matched = true; $matched = true;
} }
break; break;
case 'email': case 'email':
$email = $this->get_email($ldap, false); $email = $this->get_email($ldap, false);
if($email && match($term, $email)) { if($email && match_term($term, $email)) {
$matches['email'] = $email; $matches['email'] = $email;
$matched = true; $matched = true;
} }
@ -83,12 +83,12 @@ class User extends Entity {
case 'fritext': case 'fritext':
//Check everything if the key is fritext //Check everything if the key is fritext
$name = $this->get_name(); $name = $this->get_name();
if(match($term, $name)) { if(match_term($term, $name)) {
$matches['name'] = $name; $matches['name'] = $name;
$matched = true; $matched = true;
} }
$dname = $this->get_displayname($ldap); $dname = $this->get_displayname($ldap);
if(match($term, $dname)) { if(match_term($term, $dname)) {
$matches['displayname'] = $dname; $matches['displayname'] = $dname;
$matched = true; $matched = true;
} }

@ -253,7 +253,7 @@ function suggest_content($fieldname) {
return $out; return $out;
} }
function match($term, $subject) { function match_term($term, $subject) {
if(fnmatch('*'.$term->get_query().'*', $subject, FNM_CASEFOLD)) { if(fnmatch('*'.$term->get_query().'*', $subject, FNM_CASEFOLD)) {
return true; return true;
} }