diff --git a/controllers/ManageErrors.php b/controllers/ManageErrors.php index b1e66c8..6e8d41f 100644 --- a/controllers/ManageErrors.php +++ b/controllers/ManageErrors.php @@ -19,6 +19,7 @@ class ManageErrors extends HTMLController { ErrorLog::flush(); header('Location: ' . BASEURL . '/manageerrors/'); + exit; } Session::resetSessionToken(); diff --git a/controllers/ManageUsers.php b/controllers/ManageUsers.php index 112d9f1..d7fadbd 100644 --- a/controllers/ManageUsers.php +++ b/controllers/ManageUsers.php @@ -93,10 +93,10 @@ class ManageUsers extends HTMLController 'sort_direction' => !empty($_GET['dir']) ? $_GET['dir'] : '', 'title' => 'Manage users', 'no_items_label' => 'No users meet the requirements of the current filter.', - 'items_per_page' => 15, + 'items_per_page' => 30, 'index_class' => 'floatleft', 'base_url' => BASEURL . '/manageusers/', - 'get_data' => function($offset = 0, $limit = 15, $order = '', $direction = 'down') { + 'get_data' => function($offset = 0, $limit = 30, $order = '', $direction = 'down') { if (!in_array($order, ['id_user', 'surname', 'first_name', 'slug', 'emailaddress', 'last_action_time', 'ip_address', 'is_admin'])) $order = 'id_user'; diff --git a/models/Asset.php b/models/Asset.php index f1ddec6..4ad4434 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -116,13 +116,6 @@ class Asset } } - public static function byPostId($id_post, $return_format = 'object') - { - $db = Registry::get('db'); - - // !!! TODO - } - public static function createNew(array $data, $return_format = 'object') { // Extract the data array. @@ -438,7 +431,19 @@ class Asset public function delete() { - return Registry::get('db')->query(' + $db = Registry::get('db'); + + if (!unlink(ASSETSDIR . '/' . $this->subdir . '/' . $this->filename)) + return false; + + $db->query(' + DELETE FROM assets_meta + WHERE id_asset = {int:id_asset}', + [ + 'id_asset' => $this->id_asset, + ]); + + return $db->query(' DELETE FROM assets WHERE id_asset = {int:id_asset}', [ @@ -481,7 +486,7 @@ class Asset public static function getCount() { - return $db->queryValue(' + return Registry::get('db')->queryValue(' SELECT COUNT(*) FROM assets'); } diff --git a/models/GenericTable.php b/models/GenericTable.php index 1a8ad71..9e89df6 100644 --- a/models/GenericTable.php +++ b/models/GenericTable.php @@ -114,15 +114,16 @@ class GenericTable extends PageIndex private function parseAllRows($rows, $options) { - // Parse all rows... - $i = 0; - foreach ($rows as $row) + foreach ($rows as $i => $row) { - $i ++; - $newRow = array( - 'class' => $i %2 == 1 ? 'odd' : 'even', - 'cells' => array(), - ); + $className = $i & 1 ? 'even' : 'odd'; + if (isset($options['row_classifier'])) + $className .= $options['row_classifier']($row); + + $newRow = [ + 'class' => $className, + 'cells' => [], + ]; foreach ($options['columns'] as $column) { @@ -154,7 +155,12 @@ class GenericTable extends PageIndex // timestamps: let's make them readable! case 'timestamp': - $pattern = !empty($column['parse']['data']['pattern']) && $column['parse']['data']['pattern'] == 'long' ? '%F %H:%M' : '%H:%M'; + if (empty($column['parse']['data']['pattern']) || $column['parse']['data']['pattern'] === 'long') + $pattern = '%F %H:%M'; + elseif ($column['parse']['data']['pattern'] === 'short') + $pattern = '%F'; + else + $pattern = $column['parse']['data']['pattern']; if (!is_numeric($row[$column['parse']['data']['timestamp']])) $timestamp = strtotime($row[$column['parse']['data']['timestamp']]); diff --git a/models/PageIndex.php b/models/PageIndex.php index f4be341..0f17c0e 100644 --- a/models/PageIndex.php +++ b/models/PageIndex.php @@ -9,10 +9,10 @@ class PageIndex { protected $page_index = []; - protected $current_page = 0; + protected $current_page = 1; protected $items_per_page = 0; protected $needsPageIndex = false; - protected $num_pages = 0; + protected $num_pages = 1; protected $recordCount = 0; protected $start = 0; protected $sort_order = null; diff --git a/templates/FormView.php b/templates/FormView.php index 3bad1e5..026698b 100644 --- a/templates/FormView.php +++ b/templates/FormView.php @@ -24,9 +24,7 @@ class FormView extends SubTemplate { if (!empty($this->title)) echo ' -
-

', $this->title, '

-
+

', $this->title, '

'; foreach ($this->_subtemplates as $template)