Cleaned up trailing whitespace

This commit is contained in:
Erik Thuning 2024-02-27 13:59:59 +01:00
parent deb47f94d3
commit c6a7af0639
17 changed files with 58 additions and 59 deletions

@ -80,7 +80,7 @@ class Attachment {
public function get_id() { public function get_id() {
return $this->id; return $this->id;
} }
public function get_product() { public function get_product() {
return new Product($this->product); return new Product($this->product);
} }

@ -1,7 +1,7 @@
<?php <?php
class Download extends Responder { class Download extends Responder {
private $attachment; private $attachment;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
if(isset($_GET['id'])) { if(isset($_GET['id'])) {

@ -1,7 +1,6 @@
<?php <?php
abstract class Entity { abstract class Entity {
protected function __construct() { protected function __construct() {
} }
abstract public function matches($term, $ldap); abstract public function matches($term, $ldap);

@ -2,7 +2,7 @@
class HistoryPage extends Page { class HistoryPage extends Page {
private $action = 'list'; private $action = 'list';
private $inventory = null; private $inventory = null;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
if(isset($_GET['action'])) { if(isset($_GET['action'])) {

@ -35,7 +35,7 @@ class Inventory {
} }
return new Inventory($result['id']); return new Inventory($result['id']);
} }
public function __construct($id) { public function __construct($id) {
$search = prepare('select `id` from `inventory` where `id`=?'); $search = prepare('select `id` from `inventory` where `id`=?');
bind($search, 'i', $id); bind($search, 'i', $id);
@ -87,7 +87,7 @@ class Inventory {
$this->products[] = $product->get_id(); $this->products[] = $product->get_id();
return true; return true;
} }
public function get_id() { public function get_id() {
return $this->id; return $this->id;
} }
@ -99,7 +99,7 @@ class Inventory {
public function get_endtime() { public function get_endtime() {
return $this->endtime; return $this->endtime;
} }
public function get_seen_products() { public function get_seen_products() {
$out = array(); $out = array();
foreach($this->seen_products as $prodid) { foreach($this->seen_products as $prodid) {

@ -1,7 +1,7 @@
<?php <?php
class InventoryPage extends Page { class InventoryPage extends Page {
private $inventory = null; private $inventory = null;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->inventory = Inventory::get_active(); $this->inventory = Inventory::get_active();

@ -1,7 +1,7 @@
<?php <?php
class Kvs { class Kvs {
private $items = array(); private $items = array();
public function __construct() { public function __construct() {
$get = prepare('select * from `kvs`'); $get = prepare('select * from `kvs`');
execute($get); execute($get);
@ -11,18 +11,18 @@ class Kvs {
$this->items[$key] = $value; $this->items[$key] = $value;
} }
} }
public function get_keys() { public function get_keys() {
return array_keys($this->items); return array_keys($this->items);
} }
public function get_value($key, $default=null) { public function get_value($key, $default=null) {
if(isset($this->items[$key])) { if(isset($this->items[$key])) {
return $this->items[$key]; return $this->items[$key];
} }
return $default; return $default;
} }
public function set_key($key, $value) { public function set_key($key, $value) {
$find = prepare('select * from `kvs` where `key`=?'); $find = prepare('select * from `kvs` where `key`=?');
bind($find, 's', $key); bind($find, 's', $key);
@ -38,7 +38,7 @@ class Kvs {
$this->items[$key] = $value; $this->items[$key] = $value;
return true; return true;
} }
public function remove_key($key) { public function remove_key($key) {
$find = prepare('select * from `kvs` where `key`=?'); $find = prepare('select * from `kvs` where `key`=?');
bind($find, 's', $key); bind($find, 's', $key);

@ -1,7 +1,7 @@
<?php <?php
class NewPage extends Page { class NewPage extends Page {
private $template = null; private $template = null;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
if(isset($_GET['template'])) { if(isset($_GET['template'])) {
@ -16,11 +16,11 @@ class NewPage extends Page {
} }
} }
} }
protected function render_body() { protected function render_body() {
print($this->build_new_page()); print($this->build_new_page());
} }
private function build_new_page() { private function build_new_page() {
$template = ''; $template = '';
$fields = ''; $fields = '';

@ -3,7 +3,7 @@ class Printer extends QR {
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
} }
public function render() { public function render() {
$label = replace(array('id' => $this->product->get_id(), $label = replace(array('id' => $this->product->get_id(),
'name' => $this->product->get_name(), 'name' => $this->product->get_name(),

@ -9,7 +9,7 @@ class Product extends Entity {
private $discardtime = null; private $discardtime = null;
private $info = array(); private $info = array();
private $tags = array(); private $tags = array();
public static function create_product( public static function create_product(
$brand, $brand,
$name, $name,
@ -41,7 +41,7 @@ class Product extends Entity {
throw $e; throw $e;
} }
} }
public function __construct($clue, $type = 'id') { public function __construct($clue, $type = 'id') {
parent::__construct(); parent::__construct();
$search = null; $search = null;
@ -76,7 +76,7 @@ class Product extends Entity {
$this->email_sender = $sender; $this->email_sender = $sender;
$this->email_subject_prefix = $email_subject_prefix; $this->email_subject_prefix = $email_subject_prefix;
} }
private function update_fields() { private function update_fields() {
$get = prepare('select * from `product` where `id`=?'); $get = prepare('select * from `product` where `id`=?');
bind($get, 'i', $this->id); bind($get, 'i', $this->id);
@ -90,7 +90,7 @@ class Product extends Entity {
$this->discardtime = $product['discardtime']; $this->discardtime = $product['discardtime'];
return true; return true;
} }
private function update_info() { private function update_info() {
$get = prepare('select * from `product_info` $get = prepare('select * from `product_info`
where `product`=? order by `field`'); where `product`=? order by `field`');
@ -103,7 +103,7 @@ class Product extends Entity {
} }
return true; return true;
} }
private function update_tags() { private function update_tags() {
$get = prepare('select * from `product_tag` $get = prepare('select * from `product_tag`
where `product`=? order by `tag`'); where `product`=? order by `tag`');
@ -367,11 +367,11 @@ EOF;
} }
return new Service($result['id']); return new Service($result['id']);
} }
public function get_brand() { public function get_brand() {
return $this->brand; return $this->brand;
} }
public function set_brand($newbrand) { public function set_brand($newbrand) {
$update = prepare('update `product` set `brand`=? where `id`=?'); $update = prepare('update `product` set `brand`=? where `id`=?');
bind($update, 'si', $newbrand, $this->id); bind($update, 'si', $newbrand, $this->id);
@ -379,11 +379,11 @@ EOF;
$this->brand = $newbrand; $this->brand = $newbrand;
return true; return true;
} }
public function get_name() { public function get_name() {
return $this->name; return $this->name;
} }
public function set_name($newname) { public function set_name($newname) {
$update = prepare('update `product` set `name`=? where `id`=?'); $update = prepare('update `product` set `name`=? where `id`=?');
bind($update, 'si', $newname, $this->id); bind($update, 'si', $newname, $this->id);
@ -391,11 +391,11 @@ EOF;
$this->name = $newname; $this->name = $newname;
return true; return true;
} }
public function get_invoice() { public function get_invoice() {
return $this->invoice; return $this->invoice;
} }
public function set_invoice($newinvoice) { public function set_invoice($newinvoice) {
$update = prepare('update `product` set `invoice`=? where `id`=?'); $update = prepare('update `product` set `invoice`=? where `id`=?');
bind($update, 'si', $newinvoice, $this->id); bind($update, 'si', $newinvoice, $this->id);
@ -403,11 +403,11 @@ EOF;
$this->invoice = $newinvoice; $this->invoice = $newinvoice;
return true; return true;
} }
public function get_serial() { public function get_serial() {
return $this->serial; return $this->serial;
} }
public function set_serial($newserial) { public function set_serial($newserial) {
$update = prepare('update `product` set `serial`=? where `id`=?'); $update = prepare('update `product` set `serial`=? where `id`=?');
bind($update, 'si', $newserial, $this->id); bind($update, 'si', $newserial, $this->id);
@ -415,11 +415,11 @@ EOF;
$this->serial = $newserial; $this->serial = $newserial;
return true; return true;
} }
public function get_info() { public function get_info() {
return $this->info; return $this->info;
} }
public function set_info($field, $value) { public function set_info($field, $value) {
if(!$value) { if(!$value) {
return true; return true;
@ -441,7 +441,7 @@ EOF;
$this->update_info(); $this->update_info();
return true; return true;
} }
public function remove_info($field) { public function remove_info($field) {
$find = prepare('select * from `product_info` $find = prepare('select * from `product_info`
where `product`=? and `field`=?'); where `product`=? and `field`=?');
@ -457,11 +457,11 @@ EOF;
$this->update_info(); $this->update_info();
return true; return true;
} }
public function get_tags() { public function get_tags() {
return $this->tags; return $this->tags;
} }
public function add_tag($tag) { public function add_tag($tag) {
if(!$tag) { if(!$tag) {
return true; return true;
@ -479,7 +479,7 @@ EOF;
} }
return true; return true;
} }
public function remove_tag($tag) { public function remove_tag($tag) {
$find = prepare('select * from `product_tag` $find = prepare('select * from `product_tag`
where `product`=? and `tag`=?'); where `product`=? and `tag`=?');

@ -2,7 +2,7 @@
class ProductPage extends Page { class ProductPage extends Page {
private $action = 'list'; private $action = 'list';
private $product = null; private $product = null;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
if(isset($_GET['action'])) { if(isset($_GET['action'])) {
@ -29,7 +29,7 @@ class ProductPage extends Page {
break; break;
} }
} }
protected function render_body() { protected function render_body() {
switch($this->action) { switch($this->action) {
case 'list': case 'list':
@ -42,7 +42,7 @@ class ProductPage extends Page {
break; break;
} }
} }
private function build_product_form() { private function build_product_form() {
$discarded = $this->product->get_discardtime(); $discarded = $this->product->get_discardtime();

@ -2,27 +2,27 @@
abstract class Responder { abstract class Responder {
protected $fragments = array(); protected $fragments = array();
protected $ldap = null; protected $ldap = null;
public function __construct() { public function __construct() {
global $language; global $language;
$this->fragments = get_fragments("./html/$language/fragments.html"); $this->fragments = get_fragments("./html/$language/fragments.html");
$this->ldap = new Ldap(); $this->ldap = new Ldap();
} }
final protected function escape_tags($tags) { final protected function escape_tags($tags) {
foreach($tags as $key => $tag) { foreach($tags as $key => $tag) {
$tags[$key] = $this->escape_string(strtolower($tag)); $tags[$key] = $this->escape_string(strtolower($tag));
} }
return $tags; return $tags;
} }
final protected function unescape_tags($tags) { final protected function unescape_tags($tags) {
foreach($tags as $key => $tag) { foreach($tags as $key => $tag) {
$tags[$key] = $this->unescape_string(strtolower($tag)); $tags[$key] = $this->unescape_string(strtolower($tag));
} }
return $tags; return $tags;
} }
final protected function escape_string($string) { final protected function escape_string($string) {
return str_replace(array("'", return str_replace(array("'",
'"'), '"'),

@ -3,7 +3,7 @@ class SearchPage extends Page {
private $terms = array(); private $terms = array();
private $product_hits = array(); private $product_hits = array();
private $user_hits = array(); private $user_hits = array();
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
unset($_GET['page']); unset($_GET['page']);
@ -22,7 +22,7 @@ class SearchPage extends Page {
} }
} }
} }
private function do_search() { private function do_search() {
$out = array(); $out = array();
if(!$this->terms) { if(!$this->terms) {
@ -165,7 +165,7 @@ class SearchPage extends Page {
} }
return $translated; return $translated;
} }
protected function render_body() { protected function render_body() {
$hidden = 'hidden'; $hidden = 'hidden';
$terms = ''; $terms = '';

@ -10,7 +10,7 @@ class Service extends Event {
commit_trans(); commit_trans();
return new Service($event_id); return new Service($event_id);
} }
public function __construct($id) { public function __construct($id) {
parent::__construct($id); parent::__construct($id);
$search = prepare('select * from `service` where `event`=?'); $search = prepare('select * from `service` where `event`=?');

@ -4,7 +4,7 @@ class Template {
private $name = ''; private $name = '';
private $fields = array(); private $fields = array();
private $tags = array(); private $tags = array();
public static function create_template( public static function create_template(
$name = '', $name = '',
$fields = array(), $fields = array(),
@ -44,7 +44,7 @@ class Template {
execute($delete); execute($delete);
return true; return true;
} }
public function __construct($clue, $type = 'id') { public function __construct($clue, $type = 'id') {
switch($type) { switch($type) {
case 'id': case 'id':
@ -81,7 +81,7 @@ class Template {
public function get_id() { public function get_id() {
return $this->id; return $this->id;
} }
public function get_name() { public function get_name() {
return ucfirst($this->name); return ucfirst($this->name);
} }
@ -93,7 +93,7 @@ class Template {
$this->name = $name; $this->name = $name;
return true; return true;
} }
private function update_fields() { private function update_fields() {
$get = prepare('select `field` from `template_info` $get = prepare('select `field` from `template_info`
where `template`=? order by `field`'); where `template`=? order by `field`');
@ -106,7 +106,7 @@ class Template {
$this->fields = $fields; $this->fields = $fields;
return true; return true;
} }
private function update_tags() { private function update_tags() {
$get = prepare('select * from `template_tag` $get = prepare('select * from `template_tag`
where `template`=? order by `tag`'); where `template`=? order by `tag`');
@ -138,7 +138,7 @@ class Template {
} }
return true; return true;
} }
public function remove_field($field) { public function remove_field($field) {
$find = prepare('select * from `template_info` $find = prepare('select * from `template_info`
where `template`=? and `field`=?'); where `template`=? and `field`=?');
@ -176,7 +176,7 @@ class Template {
} }
return true; return true;
} }
public function remove_tag($tag) { public function remove_tag($tag) {
$find = prepare('select * from `template_tag` $find = prepare('select * from `template_tag`
where `template`=? and `tag`=?'); where `template`=? and `tag`=?');

@ -2,7 +2,7 @@
class UserPage extends Page { class UserPage extends Page {
private $action = 'list'; private $action = 'list';
private $user = null; private $user = null;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
if(isset($_GET['action'])) { if(isset($_GET['action'])) {
@ -40,7 +40,7 @@ class UserPage extends Page {
break; break;
} }
} }
private function build_user_details() { private function build_user_details() {
$active_loans = $this->user->get_loans('active'); $active_loans = $this->user->get_loans('active');
$table_active = 'Inga aktuella lån.'; $table_active = 'Inga aktuella lån.';

@ -5,9 +5,9 @@ require_once('./include/translations.php');
/* /*
Takes an html file containing named fragments. Takes an html file containing named fragments.
Returns an associative array on the format array[name]=>fragment. Returns an associative array on the format array[name]=>fragment.
Fragments are delimited like this: Fragments are delimited like this:
¤¤ name 1 ¤¤ ¤¤ name 1 ¤¤
fragment 1 fragment 1
¤¤ name 2 ¤¤ ¤¤ name 2 ¤¤
@ -56,7 +56,7 @@ function try_adding($key, $value, $array, $filename) {
} else if($key === '') { } else if($key === '') {
throw new Exception('There is an unnamed fragment in '.$filename); throw new Exception('There is an unnamed fragment in '.$filename);
} }
$array[$key] = trim($value); $array[$key] = trim($value);
return $array; return $array;