mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-06-05 21:59:25 +02:00
fix widget, wip on shortcut
This commit is contained in:
@ -24,10 +24,21 @@ class EventsListShortcut {
|
|||||||
), $atts
|
), $atts
|
||||||
);
|
);
|
||||||
|
|
||||||
$classNamePrefix = NAME;
|
$url = Settings::getUrl();
|
||||||
$eventsCount = $atts_with_overriden_defaults['events-count'];
|
$eventsCount = $atts_with_overriden_defaults['events-count'];
|
||||||
$groupName = $atts_with_overriden_defaults['group-name'];
|
$groupName = $atts_with_overriden_defaults['group-name'];
|
||||||
|
|
||||||
|
if ($groupName) {
|
||||||
|
$data = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName);
|
||||||
|
} else {
|
||||||
|
$data = GraphQlClient::get_upcoming_events($url, (int) $eventsCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
$classNamePrefix = NAME;
|
||||||
|
$locale = get_locale();
|
||||||
|
$isShortOffsetNameShown = Settings::isShortOffsetNameShown();
|
||||||
|
$timeZone = wp_timezone_string();
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
require dirname(__DIR__) . '/view/events-list.php';
|
require dirname(__DIR__) . '/view/events-list.php';
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
|
@ -25,17 +25,21 @@ class EventsListWidget extends \WP_Widget {
|
|||||||
echo $args['before_title'].apply_filters('widget_title', $options['title']).$args['after_title'];
|
echo $args['before_title'].apply_filters('widget_title', $options['title']).$args['after_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$classNamePrefix = NAME;
|
$url = Settings::getUrl();
|
||||||
$eventsCount = $options['eventsCount'];
|
$eventsCount = $options['eventsCount'];
|
||||||
$locale = str_replace('_', '-', get_locale()); // TODO _ is okay too.
|
|
||||||
$groupName = isset($options['groupName']) ? $options['groupName'] : '';
|
$groupName = isset($options['groupName']) ? $options['groupName'] : '';
|
||||||
|
|
||||||
if ($groupName) {
|
if ($groupName) {
|
||||||
$data = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName); // TODO wrap and put into shortcut as well
|
$data = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName);
|
||||||
} else {
|
} else {
|
||||||
$data = GraphQlClient::get_upcoming_events($url, (int) $eventsCount);
|
$data = GraphQlClient::get_upcoming_events($url, (int) $eventsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$classNamePrefix = NAME;
|
||||||
|
$locale = get_locale();
|
||||||
|
$isShortOffsetNameShown = Settings::isShortOffsetNameShown();
|
||||||
|
$timeZone = wp_timezone_string();
|
||||||
|
|
||||||
require dirname(__DIR__) . '/view/events-list.php';
|
require dirname(__DIR__) . '/view/events-list.php';
|
||||||
|
|
||||||
echo $args['after_widget'];
|
echo $args['after_widget'];
|
||||||
|
@ -99,7 +99,7 @@ final class GraphQlClient {
|
|||||||
// if (dataInCache !== null) {
|
// if (dataInCache !== null) {
|
||||||
// return Promise.resolve(dataInCache)
|
// return Promise.resolve(dataInCache)
|
||||||
// }
|
// }
|
||||||
$afterDatetime = date(DateTime::ISO8601);
|
$afterDatetime = date(\DateTime::ISO8601);
|
||||||
$data = self::query($endpoint, $query, ['afterDatetime'=> $afterDatetime, 'groupName' => $groupName, 'limit' => $limit]);
|
$data = self::query($endpoint, $query, ['afterDatetime'=> $afterDatetime, 'groupName' => $groupName, 'limit' => $limit]);
|
||||||
// return request(url, query, { afterDatetime, groupName, limit }).then(
|
// return request(url, query, { afterDatetime, groupName, limit }).then(
|
||||||
// (data) => {
|
// (data) => {
|
||||||
|
@ -4,16 +4,11 @@ if (!defined('ABSPATH')) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="<?php echo esc_attr($classNamePrefix); ?>_events-list"
|
<div class="<?php echo esc_attr($classNamePrefix); ?>_events-list">
|
||||||
data-maximum="<?php echo esc_attr($eventsCount); ?>"
|
|
||||||
data-group-name="<?php echo esc_attr($groupName); ?>"
|
|
||||||
data-time-zone="<?php echo esc_attr($timeZone); ?>"
|
|
||||||
<?php echo $isShortOffsetNameShown ? 'data-is-short-offset-name-shown' : ''; ?>>
|
|
||||||
<li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
|
<li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
|
||||||
<li style="display: none;"><?php esc_html_e('The group could not be found!', 'connector-mobilizon'); ?></li>
|
<li style="display: none;"><?php esc_html_e('The group could not be found!', 'connector-mobilizon'); ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<?php /*print_r($data);*/ ?>
|
|
||||||
<ul>
|
<ul>
|
||||||
<?php foreach($data['data']['events']['elements'] as $event) { ?>
|
<?php foreach($data['data']['events']['elements'] as $event) { ?>
|
||||||
<li>
|
<li>
|
||||||
|
@ -7,6 +7,11 @@ final class DateTimeWrapperTest extends TestCase {
|
|||||||
$this->assertEquals('24/12/2020', $d->getShortDate());
|
$this->assertEquals('24/12/2020', $d->getShortDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCanGetShortDateForUsualDateWithLocaleWithUnderscore(): void {
|
||||||
|
$d = new DateTimeWrapper('2020-12-24T16:45:00Z');
|
||||||
|
$this->assertEquals('24/12/2020', $d->getShortDate(), 'en_GB');
|
||||||
|
}
|
||||||
|
|
||||||
public function testCanGetShortDateForUsualDateWithTimezoneString(): void {
|
public function testCanGetShortDateForUsualDateWithTimezoneString(): void {
|
||||||
$d = new DateTimeWrapper('2020-12-24T16:45:00Z', 'en-GB', 'Europe/Rome');
|
$d = new DateTimeWrapper('2020-12-24T16:45:00Z', 'en-GB', 'Europe/Rome');
|
||||||
$this->assertEquals('24/12/2020', $d->getShortDate());
|
$this->assertEquals('24/12/2020', $d->getShortDate());
|
||||||
|
Reference in New Issue
Block a user