Skip to content

Commit

Permalink
Fixed wrong use of empty() which made the plugin crash with older PHP…
Browse files Browse the repository at this point in the history
… versions. Small changes in the div and table snippets.
  • Loading branch information
mzur committed Jan 4, 2015
1 parent f7b80d3 commit 10ab3c5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions calendar/lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function __construct($event) {

$this->hasEnd = true;

$this->hasBeginTime = !empty(a::get($event, self::beginTimeKey));
$this->hasEndTime = !empty(a::get($event, self::endTimeKey));
$this->hasBeginTime = (bool) a::get($event, self::beginTimeKey);
$this->hasEndTime = (bool) a::get($event, self::endTimeKey);

$this->beginTimestamp = self::getTimestamp(
a::get($event, self::beginDateKey),
Expand Down Expand Up @@ -157,7 +157,7 @@ public static function filterPast($e) {
*/
private static function validate($event) {
$missingKeys = a::missing($event, self::$requiredKeys);
if (!empty($missingKeys)) {
if ($missingKeys) {
$message = "Event creation failed because of the following missing " .
"required fields:\n" . a::show($missingKeys, false);
throw new Exception($message, 1);
Expand Down
9 changes: 4 additions & 5 deletions snippets/calendar-div.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
$tmpDate = getdate(0);
$currentDate = getdate();
?>
<section class="calendar">

<?php
if (empty($calendar->getAllEvents())):
if (!$calendar->getAllEvents()):
echo l::get('calendar-no-entry');
else:
?>

<section class="calendar">
<div class="row head">
<div class="item"><?php echo l::get('date'); ?></div>
<?php foreach ($fields as $field): ?>
Expand Down Expand Up @@ -37,6 +36,6 @@
</div>
<?php $tmpDate = $date; ?>
<?php endforeach; ?>
</section>

<?php endif; ?>
<?php endif; ?>
</section>
17 changes: 9 additions & 8 deletions snippets/calendar-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
$currentDate = getdate();
?>

<?php
if (empty($calendar->getAllEvents())):
echo l::get('calendar-no-entry');
else:
?>

<table class="calendar">

<?php if (!$calendar->getAllEvents()): ?>

<tr><td><?php echo l::get('calendar-no-entry'); ?></td></tr>

<?php else: ?>

<thead>
<tr>
<th><?php echo l::get('date'); ?></th>
Expand Down Expand Up @@ -41,6 +42,6 @@
<?php $tmpDate = $date; ?>
<?php endforeach; ?>
</tbody>
</table>

<?php endif; ?>
<?php endif; ?>
</table>

0 comments on commit 10ab3c5

Please sign in to comment.