Merges from upstream Kabuki.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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']]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user