Created
July 17, 2015 14:09
-
-
Save rdeutz/dd6f7e4597f288a4628c to your computer and use it in GitHub Desktop.
Joomla CLI script for fixing **something**
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Cleanup Script | |
* | |
* @package ABITDIRTY | |
* @author Robert Deutz <[email protected]> | |
* | |
* @copyright 2015 Robert Deutz | |
* @license GNU General Public License version 2 or later | |
**/ | |
// Set flag that this is a parent file. | |
const _JEXEC = 1; | |
error_reporting(E_ALL | E_NOTICE); | |
ini_set('display_errors', 1); | |
// Load system defines | |
if (file_exists(dirname(__DIR__) . '/defines.php')) | |
{ | |
require_once dirname(__DIR__) . '/defines.php'; | |
} | |
if (!defined('_JDEFINES')) | |
{ | |
define('JPATH_BASE', dirname(__DIR__)); | |
require_once JPATH_BASE . '/includes/defines.php'; | |
} | |
require_once JPATH_LIBRARIES . '/import.legacy.php'; | |
require_once JPATH_LIBRARIES . '/cms.php'; | |
// Load the configuration | |
require_once JPATH_CONFIGURATION . '/configuration.php'; | |
// Load the JApplicationCli class | |
JLoader::import('joomla.application.cli'); | |
JLoader::import('joomla.application.component.helper'); | |
JLoader::import('cms.component.helper'); | |
/** | |
* This script will do some magic | |
* | |
* @since 0.0.1 | |
*/ | |
class MyCleanup extends JApplicationCli | |
{ | |
/** | |
* Entry point for the script | |
* | |
* @return mixed | |
*/ | |
public function doExecute() | |
{ | |
$db = JFactory::getDBO(); | |
$query = $db->getQuery(true); | |
$query->select('*') | |
->from('#__content') | |
; | |
$db->setQuery($query); | |
$results = $db->loadObjectList(); | |
foreach ($results as $result) | |
{ | |
echo 'Content-Id= ' . $result->id . "\n"; | |
// do whatever has to be done | |
} | |
return true; | |
} | |
} | |
JApplicationCli::getInstance('MyCleanup')->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment