finally got the jQ DataTables to work with datetime (ranges)

parent 5db2bb05
......@@ -316,12 +316,15 @@ class ACP3_Date {
* @param string $format
* @return string
*/
public function period($start, $end, $format = 'long')
public function formatTimeRange($start, $end = '', $format = 'long')
{
if ($start >= $end) {
return sprintf(ACP3_CMS::$lang->t('system', 'since_date'), $this->format($start, $format));
$datetime_format = 'Y-m-d H:i';
if ($end === '' || $start >= $end) {
$title = $end === '' ? $this->format($start, $format) : sprintf(ACP3_CMS::$lang->t('system', 'date_published_since'), $this->format($start, $format));
return '<time datetime="' . $start . '" title="' . $title . '">' . $this->format($start, $datetime_format) . '</time>';
} else {
return sprintf(ACP3_CMS::$lang->t('system', 'from_start_to_end'), $this->format($start, $format), $this->format($end, $format));
$title = sprintf(ACP3_CMS::$lang->t('system', 'date_time_range'), $this->format($start, $format), $this->format($end, $format));
return '<time datetime="' . $start . '/' . $end . '" title="' . $title . '">' . $this->format($start, $datetime_format) . '&ndash;' . $this->format($end, $datetime_format) . '</time>';
}
}
......
......@@ -72,6 +72,7 @@
<item key="date_november">November</item>
<item key="date_oct">Okt</item>
<item key="date_october">Oktober</item>
<item key="date_published_since">Seit %s</item>
<item key="date_sat">Sa</item>
<item key="date_saturday">Samstag</item>
<item key="date_sep">Sep</item>
......@@ -80,6 +81,7 @@
<item key="date_sunday">Sonntag</item>
<item key="date_thu">Do</item>
<item key="date_thursday">Donnerstag</item>
<item key="date_time_range"><![CDATA[%1$s&ndash;%2$s]]></item>
<item key="date_tue">Di</item>
<item key="date_tuesday">Dienstag</item>
<item key="date_wed">Mi</item>
......@@ -123,7 +125,6 @@
<item key="flood_no_entry_possible">Sie können erst in %d Sekunden einen neuen Beitrag verfassen.</item>
<item key="form_already_submitted">Das Formular wurde bereits abgesendet.</item>
<item key="forward">Weiter</item>
<item key="from_start_to_end">%1$s bis %2$s</item>
<item key="general">Allgemeines</item>
<item key="general_settings">Allgemeine Einstellungen</item>
<item key="general_statements">Allgemeine Angaben</item>
......@@ -251,7 +252,6 @@
<item key="settings_error">Beim Bearbeiten der Einstellungen ist ein Fehler aufgetreten.</item>
<item key="settings_success">Die Einstellungen wurden erfolgreich aktualisiert.</item>
<item key="sidebar_entries_to_display">Anzuzeigende Sidebareinträge</item>
<item key="since_date">Seit %s</item>
<item key="sql_query">SQL Abfrage</item>
<item key="sql_tables">SQL-Tabellen</item>
<item key="start_date">Veröffentlichungsdatum</item>
......
......@@ -72,6 +72,7 @@
<item key="date_november">November</item>
<item key="date_oct">Oct</item>
<item key="date_october">October</item>
<item key="date_published_since">Since %s</item>
<item key="date_sat">Sat</item>
<item key="date_saturday">Saturday</item>
<item key="date_sep">Sep</item>
......@@ -80,6 +81,7 @@
<item key="date_sunday">Sunday</item>
<item key="date_thu">Thu</item>
<item key="date_thursday">Thursday</item>
<item key="date_time_range"><![CDATA[%1$s&ndash;%2$s]]></item>
<item key="date_tue">Tue</item>
<item key="date_tuesday">Tuesday</item>
<item key="date_wed">Wed</item>
......@@ -123,7 +125,6 @@
<item key="flood_no_entry_possible">You have to wait for %d seconds to submit a new entry.</item>
<item key="form_already_submitted">The form has been already submitted.</item>
<item key="forward">Forward</item>
<item key="from_start_to_end">From %1$s until %2$s</item>
<item key="general">General</item>
<item key="general_settings">General settings</item>
<item key="general_statements">General statements</item>
......@@ -251,7 +252,6 @@
<item key="settings_error">While editing the settings an error has occured.</item>
<item key="settings_success">The settings have been successfully edited.</item>
<item key="sidebar_entries_to_display">Sidebar entries to display</item>
<item key="since_date">Since %s</item>
<item key="start_date">Release date</item>
<item key="statements_in_byte">Statements in Byte.</item>
<item key="statements_in_pixel">Statements in Pixel.</item>
......
......@@ -25,7 +25,7 @@ if ($c_articles > 0) {
);
ACP3_CMS::setContent(datatable($config));
for ($i = 0; $i < $c_articles; ++$i) {
$articles[$i]['period'] = ACP3_CMS::$date->period($articles[$i]['start'], $articles[$i]['end']);
$articles[$i]['period'] = ACP3_CMS::$date->formatTimeRange($articles[$i]['start'], $articles[$i]['end']);
}
ACP3_CMS::$view->assign('articles', $articles);
ACP3_CMS::$view->assign('can_delete', $can_delete);
......
......@@ -46,7 +46,7 @@ if (ACP3_Validate::isNumber(ACP3_CMS::$uri->id) &&
if (!empty($comments[$i]['user_id']) && empty($comments[$i]['name'])) {
$comments[$i]['name'] = ACP3_CMS::$lang->t('users', 'deleted_user');
}
$comments[$i]['date'] = ACP3_CMS::$date->format($comments[$i]['date']);
$comments[$i]['date_formatted'] = ACP3_CMS::$date->formatTimeRange($comments[$i]['date']);
$comments[$i]['message'] = nl2p($comments[$i]['message']);
if ($emoticons_active === true) {
$comments[$i]['message'] = emoticonsReplace($comments[$i]['message']);
......
......@@ -28,7 +28,7 @@
{if $can_delete === true}
<td><input type="checkbox" name="entries[]" value="{$row.id}"></td>
{/if}
<td>{$row.date}</td>
<td>{$row.date_formatted}</td>
<td>{check_access mode="link" path="acp/comments/edit/id_`$row.id`" title=$row.name}</td>
<td>{$row.message}</td>
<td>{$row.ip}</td>
......
......@@ -19,11 +19,13 @@ if ($c_files > 0) {
$can_delete = ACP3_Modules::check('files', 'acp_delete');
$config = array(
'element' => '#acp-table',
'sort_col' => $can_delete === true ? 1 : 0,
'sort_dir' => 'desc',
'hide_col_sort' => $can_delete === true ? 0 : ''
);
ACP3_CMS::setContent(datatable($config));
for ($i = 0; $i < $c_files; ++$i) {
$files[$i]['period'] = ACP3_CMS::$date->period($files[$i]['start'], $files[$i]['end']);
$files[$i]['period'] = ACP3_CMS::$date->formatTimeRange($files[$i]['start'], $files[$i]['end']);
$files[$i]['size'] = !empty($files[$i]['size']) ? $files[$i]['size'] : ACP3_CMS::$lang->t('files', 'unknown_filesize');
}
ACP3_CMS::$view->assign('files', $files);
......
......@@ -19,11 +19,13 @@ if ($c_galleries > 0) {
$can_delete = ACP3_Modules::check('gallery', 'acp_delete');
$config = array(
'element' => '#acp-table',
'sort_col' => $can_delete === true ? 1 : 0,
'sort_dir' => 'desc',
'hide_col_sort' => $can_delete === true ? 0 : ''
);
ACP3_CMS::setContent(datatable($config));
for ($i = 0; $i < $c_galleries; ++$i) {
$galleries[$i]['period'] = ACP3_CMS::$date->period($galleries[$i]['start'], $galleries[$i]['end']);
$galleries[$i]['period'] = ACP3_CMS::$date->formatTimeRange($galleries[$i]['start'], $galleries[$i]['end']);
}
ACP3_CMS::$view->assign('galleries', $galleries);
ACP3_CMS::$view->assign('can_delete', $can_delete);
......
......@@ -12,14 +12,14 @@ if (defined('IN_ADM') === false)
getRedirectMessage();
$guestbook = ACP3_CMS::$db2->fetchAll('SELECT id, ip, date, name, message FROM ' . DB_PRE . 'guestbook ORDER BY id DESC');
$guestbook = ACP3_CMS::$db2->fetchAll('SELECT id, ip, date, name, message FROM ' . DB_PRE . 'guestbook ORDER BY date DESC');
$c_guestbook = count($guestbook);
if ($c_guestbook > 0) {
$can_delete = ACP3_Modules::check('guestbook', 'acp_delete');
$config = array(
'element' => '#acp-table',
'sort_col' => $can_delete === true ? 5 : 4,
'sort_col' => $can_delete === true ? 1 : 0,
'sort_dir' => 'desc',
'hide_col_sort' => $can_delete === true ? 0 : ''
);
......@@ -36,7 +36,7 @@ if ($c_guestbook > 0) {
}
for ($i = 0; $i < $c_guestbook; ++$i) {
$guestbook[$i]['date'] = ACP3_CMS::$date->format($guestbook[$i]['date']);
$guestbook[$i]['date_formatted'] = ACP3_CMS::$date->formatTimeRange($guestbook[$i]['date']);
$guestbook[$i]['message'] = nl2p($guestbook[$i]['message']);
if ($emoticons_active === true) {
$guestbook[$i]['message'] = emoticonsReplace($guestbook[$i]['message']);
......
......@@ -29,7 +29,7 @@
{if $can_delete === true}
<td><input type="checkbox" name="entries[]" value="{$row.id}"></td>
{/if}
<td>{$row.date}</td>
<td>{$row.date_formatted}</td>
<td>{check_access mode="link" path="acp/guestbook/edit/id_`$row.id`" title=$row.name}</td>
<td>{$row.message}</td>
<td>{$row.ip}</td>
......
......@@ -19,12 +19,14 @@ if ($c_news > 0) {
$can_delete = ACP3_Modules::check('news', 'acp_delete');
$config = array(
'element' => '#acp-table',
'sort_col' => $can_delete === true ? 1 : 0,
'sort_dir' => 'desc',
'hide_col_sort' => $can_delete === true ? 0 : ''
);
ACP3_CMS::setContent(datatable($config));
for ($i = 0; $i < $c_news; ++$i) {
$news[$i]['period'] = ACP3_CMS::$date->period($news[$i]['start'], $news[$i]['end']);
$news[$i]['period'] = ACP3_CMS::$date->formatTimeRange($news[$i]['start'], $news[$i]['end']);
}
ACP3_CMS::$view->assign('news', $news);
ACP3_CMS::$view->assign('can_delete', $can_delete);
......
......@@ -12,7 +12,7 @@ if (defined('IN_ADM') === false)
getRedirectMessage();
$newsletter = ACP3_CMS::$db2->fetchAll('SELECT id, date, title, status FROM ' . DB_PRE . 'newsletters ORDER BY id DESC');
$newsletter = ACP3_CMS::$db2->fetchAll('SELECT id, date, title, status FROM ' . DB_PRE . 'newsletters ORDER BY date DESC');
$c_newsletter = count($newsletter);
if ($c_newsletter > 0) {
......@@ -28,7 +28,7 @@ if ($c_newsletter > 0) {
$search = array('0', '1');
$replace = array(ACP3_CMS::$lang->t('newsletter', 'not_yet_sent'), ACP3_CMS::$lang->t('newsletter', 'already_sent'));
for ($i = 0; $i < $c_newsletter; ++$i) {
$newsletter[$i]['date'] = ACP3_CMS::$date->format($newsletter[$i]['date']);
$newsletter[$i]['date_formatted'] = ACP3_CMS::$date->formatTimeRange($newsletter[$i]['date']);
$newsletter[$i]['status'] = str_replace($search, $replace, $newsletter[$i]['status']);
}
ACP3_CMS::$view->assign('newsletter', $newsletter);
......
......@@ -16,7 +16,7 @@ $accounts = ACP3_CMS::$db2->fetchAll('SELECT id, mail, hash FROM ' . DB_PRE . 'n
$c_accounts = count($accounts);
if ($c_accounts > 0) {
$can_delete = ACP3_Modules::check('comments', 'acp_delete_account');
$can_delete = ACP3_Modules::check('newsletter', 'acp_delete_account');
$config = array(
'element' => '#acp-table',
'sort_col' => $can_delete === true ? 3 : 2,
......
......@@ -33,7 +33,7 @@
{if $can_delete === true}
<td><input type="checkbox" name="entries[]" value="{$row.id}"></td>
{/if}
<td>{$row.date}</td>
<td>{$row.date_formatted}</td>
<td>{check_access mode="link" path="acp/newsletter/edit/id_`$row.id`" title=$row.title}</td>
<td>{$row.status}</td>
{if $can_send}
......
......@@ -19,12 +19,14 @@ if ($c_polls > 0) {
$can_delete = ACP3_Modules::check('polls', 'acp_delete');
$config = array(
'element' => '#acp-table',
'sort_col' => $can_delete === true ? 1 : 0,
'sort_dir' => 'desc',
'hide_col_sort' => $can_delete === true ? 0 : ''
);
ACP3_CMS::setContent(datatable($config));
for ($i = 0; $i < $c_polls; ++$i) {
$polls[$i]['period'] = ACP3_CMS::$date->period($polls[$i]['start'], $polls[$i]['end']);
$polls[$i]['period'] = ACP3_CMS::$date->formatTimeRange($polls[$i]['start'], $polls[$i]['end']);
}
ACP3_CMS::$view->assign('polls', $polls);
ACP3_CMS::$view->assign('can_delete', $can_delete);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment