33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-11-10 07:11:03 +00:00
patchtester/administrator/components/com_patchtester/controller.php

80 lines
1.6 KiB
PHP
Raw Normal View History

2011-10-11 13:02:57 +00:00
<?php
/**
2013-07-13 02:26:21 +00: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 13:02:57 +00:00
*/
defined('_JEXEC') or die;
/**
* PatchTester Controller
*
2012-06-12 18:42:45 +00:00
* @package PatchTester
2013-07-13 02:26:21 +00:00
* @since 1.0
2011-10-11 13:02:57 +00:00
*/
2012-09-09 01:53:44 +00:00
class PatchTesterController extends JControllerLegacy
2011-10-11 13:02:57 +00:00
{
/**
2013-07-13 02:26:21 +00:00
* The default view for the display method.
2011-10-11 13:02:57 +00:00
*
2013-07-13 02:26:21 +00:00
* @var string
* @since 1.0
2011-10-11 13:02:57 +00:00
*/
2013-07-13 02:26:21 +00:00
protected $default_view = 'pulls';
2013-07-14 19:34:29 +00: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 19:34:29 +00: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 19:34:29 +00:00
{
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_FAIL', $failures), 'error');
2013-07-14 19:34:29 +00:00
}
if ($successes > 0)
{
JFactory::getApplication()->enqueueMessage(JText::plural('COM_PATCHTESTER_PURGE_SUCCESS', $successes), 'message');
}
if ($failures == 0 && $successes == 0)
2013-07-14 19:34:29 +00:00
{
JFactory::getApplication()->enqueueMessage(JText::_('COM_PATCHTESTER_PURGE_NA'), 'message');
2013-07-14 19:34:29 +00:00
}
$this->setRedirect('index.php?option=com_patchtester&view=pulls');
2013-07-14 19:34:29 +00:00
}
2011-10-11 13:02:57 +00:00
}