Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/3.2.16' into release/3.4.0
Browse files Browse the repository at this point in the history
Conflicts:
	assets/contao/js/core.js
	system/docs/CHANGELOG.md
	system/modules/core/classes/Frontend.php
	system/modules/core/widgets/MetaWizard.php
  • Loading branch information
leofeyer committed Nov 17, 2014
2 parents 7dd83d9 + ac3a2c6 commit a88b541
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
27 changes: 24 additions & 3 deletions src/Resources/contao/classes/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ class Calendar extends \Frontend
/**
* Update a particular RSS feed
* @param integer
* @param boolean
*/
public function generateFeed($intId, $blnIsFeedId=false)
public function generateFeed($intId)
{
$objCalendar = $blnIsFeedId ? \CalendarFeedModel::findByPk($intId) : \CalendarFeedModel::findByCalendar($intId);
$objCalendar = \CalendarFeedModel::findByPk($intId);

if ($objCalendar === null)
{
Expand Down Expand Up @@ -89,6 +88,28 @@ public function generateFeeds()
}


/**
* Generate all feeds including a certain calendar
* @param integer
*/
public function generateFeedsByCalendar($intId)
{
$objFeed = \CalendarFeedModel::findByCalendar($intId);

if ($objFeed !== null)
{
while ($objFeed->next())
{
$objFeed->feedName = $objFeed->alias ?: 'calendar' . $objFeed->id;

// Update the XML file
$this->generateFiles($objFeed->row());
$this->log('Generated calendar feed "' . $objFeed->feedName . '.xml"', __METHOD__, TL_CRON);
}
}
}


/**
* Generate an XML file and save it to the root directory
* @param array
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/dca/tl_calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public function generateFeed()

foreach ($session as $id)
{
$this->Calendar->generateFeed($id);
$this->Calendar->generateFeedsByCalendar($id);
}

$this->import('Automator');
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/contao/dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public function generateFeed()

foreach ($session as $id)
{
$this->Calendar->generateFeed($id);
$this->Calendar->generateFeedsByCalendar($id);
}

$this->import('Automator');
Expand Down Expand Up @@ -1044,6 +1044,6 @@ public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null)
// Update the RSS feed (for some reason it does not work without sleep(1))
sleep(1);
$this->import('Calendar');
$this->Calendar->generateFeed(CURRENT_ID);
$this->Calendar->generateFeedsByCalendar(CURRENT_ID);
}
}
2 changes: 1 addition & 1 deletion src/Resources/contao/dca/tl_calendar_feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function generateFeed()

foreach ($session as $id)
{
$this->Calendar->generateFeed($id, true);
$this->Calendar->generateFeedsByCalendar($id);
}

$this->import('Automator');
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/contao/models/CalendarFeedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class CalendarFeedModel extends \Model
* @param integer $intId The calendar ID
* @param array $arrOptions An optional options array
*
* @return \Model|null The model or null if the calendar is not part of a feed
* @return \Model\Collection|null A collection of models or null if the calendar is not part of a feed
*/
public static function findByCalendar($intId, array $arrOptions=array())
{
$t = static::$strTable;
return static::findOneBy(array("$t.calendars LIKE '%\"" . intval($intId) . "\"%'"), null, $arrOptions);
return static::findBy(array("$t.calendars LIKE '%\"" . intval($intId) . "\"%'"), null, $arrOptions);
}


Expand Down

0 comments on commit a88b541

Please sign in to comment.