33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2025-01-26 16:48:29 +00:00

80 lines
1.6 KiB
PHP
Raw Normal View History

2011-10-11 09:02:57 -04:00
<?php
/**
2013-07-12 21:26:21 -05:00
* @package PatchTester
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
2011-10-11 09:02:57 -04:00
*/
defined('_JEXEC') or die;
/**
* PatchTester Controller
*
2012-06-12 13:42:45 -05:00
* @package PatchTester
2013-07-12 21:26:21 -05:00
* @since 1.0
2011-10-11 09:02:57 -04:00
*/
2012-09-08 20:53:44 -05:00
class PatchTesterController extends JControllerLegacy
2011-10-11 09:02:57 -04:00
{
/**
2013-07-12 21:26:21 -05:00
* The default view for the display method.
2011-10-11 09:02:57 -04:00
*
2013-07-12 21:26:21 -05:00
* @var string
* @since 1.0
2011-10-11 09:02:57 -04:00
*/
2013-07-12 21:26:21 -05:00
protected $default_view = 'pulls';
2013-07-14 14:34:29 -05:00
/**
* Method to purge the cache
*
* @return void
*
* @since 2.0
*/
public function purge()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
2013-07-14 14:34:29 -05:00
$failures = 0;
$successes = 0;
$cacheFiles = JFolder::files(JPATH_CACHE);
foreach ($cacheFiles as $file)
{
if (strpos($file, 'patchtester-page-') === 0)
{
if (!JFile::delete(JPATH_CACHE . '/' . $file))
{
$failures++;
}
else
{
$successes++;
}
}
}
if ($failures > 0)
2013-07-14 14:34:29 -05:00
{
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_FAIL', $failures), 'error');
2013-07-14 14:34:29 -05:00
}
if ($successes > 0)
{
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_SUCCESS', $successes), 'message');
}
if ($failures == 0 && $successes == 0)
2013-07-14 14:34:29 -05:00
{
JFactory::getApplication()->enqueueMessage(JText::_('COM_PATCHTESTER_PURGE_NA'), 'message');
2013-07-14 14:34:29 -05:00
}
$this->setRedirect('index.php?option=com_patchtester&view=pulls');
2013-07-14 14:34:29 -05:00
}
2011-10-11 09:02:57 -04:00
}