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

Commit

Permalink
Merge branch 'release/3.0.0' of https://github.com/contao/core into r…
Browse files Browse the repository at this point in the history
…elease/3.0.0

Conflicts:
	system/modules/core/library/Contao/Database.php
	system/modules/core/library/Contao/System.php
  • Loading branch information
xchs committed Aug 18, 2012
2 parents f3dfcf7 + 8298172 commit cd0ac28
Show file tree
Hide file tree
Showing 22 changed files with 238 additions and 172 deletions.
2 changes: 1 addition & 1 deletion contao/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function welcomeScreen()
$objTotal = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_version" . (!$this->User->isAdmin ? " WHERE userid=?" : ""))
->execute($this->User->id);

$intPage = Input::get('page') ?: 1;
$intPage = Input::get('vp') ?: 1;
$intOffset = ($intPage - 1) * 30;
$intLast = ceil($objTotal->count / 30);

Expand Down
6 changes: 4 additions & 2 deletions system/modules/calendar/classes/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public function generateFeed($intId, $blnIsFeedId=false)
*/
public function generateFeeds()
{
$this->removeOldFeeds();
$this->import('Automator');
$this->Automator->purgeXmlFiles();

$objCalendar = \CalendarFeedModel::findAll();

if ($objCalendar !== null)
Expand Down Expand Up @@ -244,7 +246,7 @@ public function getSearchablePages($arrPages, $intRoot=0)

if ($intRoot > 0)
{
$arrRoot = $this->getChildRecords($intRoot, 'tl_page');
$arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
}

$arrProcessed = array();
Expand Down
2 changes: 1 addition & 1 deletion system/modules/calendar/dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public function getArticleAlias(DataContainer $dc)
foreach ($this->User->pagemounts as $id)
{
$arrPids[] = $id;
$arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page'));
$arrPids = array_merge($arrPids, $this->Database->getChildRecords($id, 'tl_page'));
}

if (empty($arrPids))
Expand Down
3 changes: 2 additions & 1 deletion system/modules/calendar/dca/tl_calendar_feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ public function checkFeedAlias($varValue, DataContainer $dc)
return $varValue;
}

$arrFeeds = $this->removeOldFeeds(true);
$this->import('Automator');
$arrFeeds = $this->Automator->purgeXmlFiles(true);

// Alias exists
if (array_search($varValue, $arrFeeds) !== false)
Expand Down
2 changes: 1 addition & 1 deletion system/modules/comments/dca/tl_comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ protected function isAllowedToEditComment($intParent, $strSource)
foreach ($this->User->pagemounts as $root)
{
$pagemounts[] = $root;
$pagemounts = array_merge($pagemounts, $this->getChildRecords($root, 'tl_page'));
$pagemounts = array_merge($pagemounts, $this->Database->getChildRecords($root, 'tl_page'));
}

$pagemounts = array_unique($pagemounts);
Expand Down
65 changes: 64 additions & 1 deletion system/modules/core/classes/Automator.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,77 @@ public function generateXmlFiles()
}


/**
* Remove old XML files from the share directory
*
* @param boolean $blnReturn If true, only return the finds and don't delete
*
* @return array An array of old XML files
*/
public function purgeXmlFiles($blnReturn=false)
{
$arrFeeds = array();

// XML sitemaps
$objFeeds = $this->Database->execute("SELECT sitemapName FROM tl_page WHERE type='root' AND createSitemap=1 AND sitemapName!=''");

while ($objFeeds->next())
{
$arrFeeds[] = $objFeeds->sitemapName;
}

// HOOK: preserve third party feeds
if (isset($GLOBALS['TL_HOOKS']['removeOldFeeds']) && is_array($GLOBALS['TL_HOOKS']['removeOldFeeds']))
{
foreach ($GLOBALS['TL_HOOKS']['removeOldFeeds'] as $callback)
{
$this->import($callback[0]);
$arrFeeds = array_merge($arrFeeds, $this->$callback[0]->$callback[1]());
}
}

// FIXME: is the "rootFiles" check still relevant now that the files are in a subfolder?
// Make sure the dcaconfig.php is loaded
@include TL_ROOT . '/system/config/dcaconfig.php';

// Add the root files
if (is_array($GLOBALS['TL_CONFIG']['rootFiles']))
{
foreach ($GLOBALS['TL_CONFIG']['rootFiles'] as $strFile)
{
$arrFeeds[] = str_replace('.xml', '', $strFile);
}
}

// Delete the old files
if (!$blnReturn)
{
foreach (scan(TL_ROOT . '/share') as $file)
{
$objFile = new \File('share/' . $file);

if ($objFile->extension == 'xml' && !in_array($objFile->filename, $arrFeeds) && !preg_match('/^sitemap/i', $objFile->filename))
{
$objFile->delete();
}

$objFile->close();
}
}

return $arrFeeds;
}


/**
* Generate the Google XML sitemaps
* @param integer
*/
public function generateSitemap($intId=0)
{
$time = time();
$this->removeOldFeeds();
$this->purgeXmlFiles();

// Only root pages should have sitemap names
$this->Database->execute("UPDATE tl_page SET createSitemap='', sitemapName='' WHERE type!='root'");
Expand Down
2 changes: 1 addition & 1 deletion system/modules/core/dca/tl_article.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public function checkPermission()
foreach ($this->User->pagemounts as $root)
{
$pagemounts[] = $root;
$pagemounts = array_merge($pagemounts, $this->getChildRecords($root, 'tl_page'));
$pagemounts = array_merge($pagemounts, $this->Database->getChildRecords($root, 'tl_page'));
}

$pagemounts = array_unique($pagemounts);
Expand Down
10 changes: 5 additions & 5 deletions system/modules/core/dca/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ public function checkPermission()
foreach ($this->User->pagemounts as $root)
{
$pagemounts[] = $root;
$pagemounts = array_merge($pagemounts, $this->getChildRecords($root, 'tl_page'));
$pagemounts = array_merge($pagemounts, $this->Database->getChildRecords($root, 'tl_page'));
}

$pagemounts = array_unique($pagemounts);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ public function getArticleAlias(DataContainer $dc)
foreach ($this->User->pagemounts as $id)
{
$arrPids[] = $id;
$arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page'));
$arrPids = array_merge($arrPids, $this->Database->getChildRecords($id, 'tl_page'));
}

if (empty($arrPids))
Expand Down Expand Up @@ -1073,7 +1073,7 @@ public function getAlias()
foreach ($this->User->pagemounts as $id)
{
$arrPids[] = $id;
$arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page'));
$arrPids = array_merge($arrPids, $this->Database->getChildRecords($id, 'tl_page'));
}

if (empty($arrPids))
Expand Down Expand Up @@ -1297,7 +1297,7 @@ public function getArticles(DataContainer $dc)
if ($objPage->numRows)
{
$objPage = $this->getPageDetails($objPage->pid);
$arrRoot = $this->getChildRecords($objPage->rootId, 'tl_page');
$arrRoot = $this->Database->getChildRecords($objPage->rootId, 'tl_page');
array_unshift($arrRoot, $objPage->rootId);
}

Expand All @@ -1316,7 +1316,7 @@ public function getArticles(DataContainer $dc)
}

$arrPids[] = $id;
$arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page'));
$arrPids = array_merge($arrPids, $this->Database->getChildRecords($id, 'tl_page'));
}

if (empty($arrPids))
Expand Down
7 changes: 4 additions & 3 deletions system/modules/core/dca/tl_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public function checkPermission()
$pagemounts[] = $root;
}

$pagemounts = array_merge($pagemounts, $this->getChildRecords($root, 'tl_page'));
$pagemounts = array_merge($pagemounts, $this->Database->getChildRecords($root, 'tl_page'));
}

$error = false;
Expand Down Expand Up @@ -1169,7 +1169,8 @@ public function checkFeedAlias($varValue, DataContainer $dc)
return $varValue;
}

$arrFeeds = $this->removeOldFeeds(true);
$this->import('Automator');
$arrFeeds = $this->Automator->purgeXmlFiles(true);

// Alias exists
if (array_search($varValue, $arrFeeds) !== false)
Expand Down Expand Up @@ -1551,7 +1552,7 @@ public function addAliasButton()

$ids = $session['CURRENT']['IDS'];
$ids = $this->eliminateNestedPages($ids);
$ids = $this->getChildRecords($ids, 'tl_page');
$ids = $this->Database->getChildRecords($ids, 'tl_page');

foreach ($ids as $id)
{
Expand Down
6 changes: 3 additions & 3 deletions system/modules/core/drivers/DC_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public function cut($blnDoNotRedirect=false)
// Avoid circular references when there is no parent table
if ($this->Database->fieldExists('pid', $this->strTable) && !strlen($this->ptable))
{
$cr = $this->getChildRecords($this->intId, $this->strTable);
$cr = $this->Database->getChildRecords($this->intId, $this->strTable);
$cr[] = $this->intId;
}

Expand Down Expand Up @@ -1315,7 +1315,7 @@ public function delete($blnDoNotRedirect=false)
// If there is a PID field but no parent table
if ($this->Database->fieldExists('pid', $this->strTable) && !strlen($this->ptable))
{
$delete[$this->strTable] = $this->getChildRecords($this->intId, $this->strTable);
$delete[$this->strTable] = $this->Database->getChildRecords($this->intId, $this->strTable);
array_unshift($delete[$this->strTable], $this->intId);
}
else
Expand Down Expand Up @@ -3227,7 +3227,7 @@ public function ajaxTreeView($id, $level)

for ($i=0; $i<count($arrIds); $i++)
{
$return .= ' ' . trim($this->generateTree($table, $arrIds[$i], array('p'=>$arrIds[($i-1)], 'n'=>$arrIds[($i+1)]), $hasSorting, $margin, ($blnClipboard ? $arrClipboard : false), ($id == $arrClipboard ['id'] || (is_array($arrClipboard ['id']) && in_array($id, $arrClipboard ['id'])) || (!$blnPtable && !is_array($arrClipboard['id']) && in_array($id, $this->getChildRecords($arrClipboard['id'], $table)))), $blnProtected));
$return .= ' ' . trim($this->generateTree($table, $arrIds[$i], array('p'=>$arrIds[($i-1)], 'n'=>$arrIds[($i+1)]), $hasSorting, $margin, ($blnClipboard ? $arrClipboard : false), ($id == $arrClipboard ['id'] || (is_array($arrClipboard ['id']) && in_array($id, $arrClipboard ['id'])) || (!$blnPtable && !is_array($arrClipboard['id']) && in_array($id, $this->Database->getChildRecords($arrClipboard['id'], $table)))), $blnProtected));
}

return $return;
Expand Down

0 comments on commit cd0ac28

Please sign in to comment.