<commit_before><?php
namespace wcf\system\package\plugin;
use wcf\system\event\EventHandler;
use wcf\system\package\PackageInstallationDispatcher;
use wcf\system\WCF;

/**
 * Abstract implementation of a package installation plugin.
 * 
 * @author	<NAME>
 * @copyright	2001-2013 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.package.plugin
 * @category	Community Framework
 */
abstract class AbstractPackageInstallationPlugin implements IPackageInstallationPlugin {
	/**
	 * database table name
	 * @var	string
	 */
	public $tableName = '';
	
	/**
	 * active instance of PackageInstallationDispatcher
	 * @var	wcf\system\package\PackageInstallationDispatcher
	 */
	public $installation = null;
	
	/**
	 * install/update instructions
	 * @var	array
	 */
	public $instruction = array();
	
	/**
	 * Creates a new AbstractPackageInstallationPlugin object.
	 * 
	 * @param	wcf\system\package\PackageInstallationDispatcher	$installation
	 * @param	array		$instruction
	 */
	public function __construct(PackageInstallationDispatcher $installation, $instruction = array()) {
		$this->installation = $installation;
		$this->instruction = $instruction;
		
		// call 'construct' event
		EventHandler::getInstance()->fireAction($this, 'construct');
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::install()
	 */
	public function install() {
		// call 'install' event
		EventHandler::getInstance()->fireAction($this, 'install');
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::update()
	 */
	public function update() {
		// call 'update' event
		EventHandler::getInstance()->fireAction($this, 'update');
		
		return $this->install();
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::hasUninstall()
	 */
	public function hasUninstall() {
		// call 'hasUninstall' event
		EventHandler::getInstance()->fireAction($this, 'hasUninstall');
		
		$sql = "SELECT	COUNT(*) AS count
			FROM	wcf".WCF_N."_".$this->tableName."
			WHERE	packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->installation->getPackageID()));
		$installationCount = $statement->fetchArray();
		return $installationCount['count'];
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
	 */
	public function uninstall() {
		// call 'uninstall' event
		EventHandler::getInstance()->fireAction($this, 'uninstall');
		
		$sql = "DELETE FROM	wcf".WCF_N."_".$this->tableName."
			WHERE		packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->installation->getPackageID()));
	}
}<commit_msg>Added support to alternate table prefix within PIPs<commit_after><?php
namespace wcf\system\package\plugin;
use wcf\system\event\EventHandler;
use wcf\system\package\PackageInstallationDispatcher;
use wcf\system\WCF;

/**
 * Abstract implementation of a package installation plugin.
 * 
 * @author	<NAME>
 * @copyright	2001-2013 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.package.plugin
 * @category	Community Framework
 */
abstract class AbstractPackageInstallationPlugin implements IPackageInstallationPlugin {
	/**
	 * table application prefix
	 * @var	string
	 */
	public $application = 'wcf';
	
	/**
	 * database table name
	 * @var	string
	 */
	public $tableName = '';
	
	/**
	 * active instance of PackageInstallationDispatcher
	 * @var	wcf\system\package\PackageInstallationDispatcher
	 */
	public $installation = null;
	
	/**
	 * install/update instructions
	 * @var	array
	 */
	public $instruction = array();
	
	/**
	 * Creates a new AbstractPackageInstallationPlugin object.
	 * 
	 * @param	wcf\system\package\PackageInstallationDispatcher	$installation
	 * @param	array		$instruction
	 */
	public function __construct(PackageInstallationDispatcher $installation, $instruction = array()) {
		$this->installation = $installation;
		$this->instruction = $instruction;
		
		// call 'construct' event
		EventHandler::getInstance()->fireAction($this, 'construct');
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::install()
	 */
	public function install() {
		// call 'install' event
		EventHandler::getInstance()->fireAction($this, 'install');
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::update()
	 */
	public function update() {
		// call 'update' event
		EventHandler::getInstance()->fireAction($this, 'update');
		
		return $this->install();
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::hasUninstall()
	 */
	public function hasUninstall() {
		// call 'hasUninstall' event
		EventHandler::getInstance()->fireAction($this, 'hasUninstall');
		
		$sql = "SELECT	COUNT(*) AS count
			FROM	".$this->application.WCF_N."_".$this->tableName."
			WHERE	packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->installation->getPackageID()));
		$installationCount = $statement->fetchArray();
		return $installationCount['count'];
	}
	
	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
	 */
	public function uninstall() {
		// call 'uninstall' event
		EventHandler::getInstance()->fireAction($this, 'uninstall');
		
		$sql = "DELETE FROM	".$this->application.WCF_N."_".$this->tableName."
			WHERE		packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->installation->getPackageID()));
	}
}
{'fraction_non_alphanumeric': 0.14956736711990112, 'fraction_numerical': 0.0028253575843192654, 'mean_word_length': 4.591312931885489, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1895874', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1641, 'n_words': 329}