本文整理汇总了PHP中Package::writeConfigFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::writeConfigFile方法的具体用法?PHP Package::writeConfigFile怎么用?PHP Package::writeConfigFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::writeConfigFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
/**
* @see PackageInstallationPlugin::install()
*/
public function install()
{
parent::install();
$dir = $this->installation->getPackage()->getDir();
if (empty($dir)) {
if ($this->installation->getPackage()->getParentPackageID() > 0) {
// plugin
// use parents package dir
$dir = $this->installation->getPackage()->getParentPackage()->getDir();
} else {
if ($this->installation->getPackage()->isStandalone() == 1 && $this->installation->getPackage()->getPackage() != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') {
// standalone package
// prompt package dir
$dir = $this->promptPackageDir();
}
}
// save package dir
if (!empty($dir)) {
$sql = "UPDATE\twcf" . WCF_N . "_package\n\t\t\t\t\tSET\tpackageDir = '" . escapeString($dir) . "'\n\t\t\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID();
WCF::getDB()->sendQuery($sql);
$this->installation->getPackage()->setDir($dir);
}
}
// absolute path to package dir
$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $dir));
// extract files.tar to temp folder
$tag = $this->installation->getXMLTag('files');
$sourceFile = $this->installation->getArchive()->extractTar($tag['cdata'], 'files_');
// create file handler
$fileHandler = new FilesFileHandler($this->installation);
// extract content of files.tar
try {
$fileInstaller = $this->installation->extractFiles($packageDir, $sourceFile, $fileHandler);
} catch (SystemException $e) {
if (!@file_exists(WCF_DIR . 'acp/templates/packageInstallationFileInstallationFailed.tpl')) {
// workaround for wcf 1.0 to 1.1 update
throw $e;
} else {
WCF::getTPL()->assign(array('exception' => $e));
WCF::getTPL()->display('packageInstallationFileInstallationFailed');
exit;
}
}
// if this a standalone package, write config.inc.php for this package
if ($this->installation->getPackage()->isStandalone() == 1 && $this->installation->getPackage()->getPackage() != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') {
// touch file
$fileInstaller->touchFile(PackageInstallation::CONFIG_FILE);
// create file
Package::writeConfigFile($this->installation->getPackageID());
// log file
$sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t\t\t\t(packageID, filename)\n\t\t\t\tVALUES\t\t(" . $this->installation->getPackageID() . ", 'config.inc.php')";
WCF::getDB()->sendQuery($sql);
}
// delete temporary sourceArchive
@unlink($sourceFile);
// update acp style file
StyleUtil::updateStyleFile();
}
示例2: uninstallPackage
/**
* Removes package information from database.
*/
protected function uninstallPackage()
{
$this->makeClear();
// delete package
$sql = "DELETE FROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\t\tpackageID = " . $this->packageID;
WCF::getDB()->sendQuery($sql);
// update queue entry
$sql = "UPDATE\twcf" . WCF_N . "_package_installation_queue\n\t\t\tSET\tpackageID = 0\n\t\t\tWHERE\tqueueID = " . $this->queueID;
WCF::getDB()->sendQuery($sql);
// rebuild config.inc.php files if necessary
// check if this package requires a standalone package (except com.woltlab.wcf)
$configPackageIDs = array();
$sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tpackageID IN (\n\t\t\t\t\tSELECT\trequirement\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_requirement_map\n\t\t\t\t\tWHERE\tpackageID = " . $this->packageID . "\n\t\t\t\t)\n\t\t\t\tAND standalone = 1\n\t\t\t\tAND package <> 'com.woltlab.wcf'";
$row = WCF::getDB()->getFirstRow($sql);
if ($row['count'] > 0) {
// get all dependent standalone packages (except com.woltlab.wcf)
$sql = "SELECT\tpackageID\n\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\tWHERE\tpackageID IN (\n\t\t\t\t\t\tSELECT\tpackageID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\tWHERE\tdependency = " . $this->packageID . "\n\t\t\t\t\t)\n\t\t\t\t\tAND standalone = 1\n\t\t\t\t\tAND packageDir <> ''";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$configPackageIDs[] = $row['packageID'];
}
}
// delete requirements
$sql = "DELETE FROM\twcf" . WCF_N . "_package_requirement\n\t\t\tWHERE\t\tpackageID = " . $this->packageID;
WCF::getDB()->sendQuery($sql);
$sql = "DELETE FROM\twcf" . WCF_N . "_package_requirement_map\n\t\t\tWHERE\t\tpackageID = " . $this->packageID;
WCF::getDB()->sendQuery($sql);
// delete excluded packages
$sql = "DELETE FROM\twcf" . WCF_N . "_package_exclusion\n\t\t\tWHERE\t\tpackageID = " . $this->packageID;
WCF::getDB()->sendQuery($sql);
// reset package cache
WCF::getCache()->clearResource('packages');
// rebuild package dependencies
Package::rebuildParentPackageDependencies($this->packageID);
// delete dependencies
$sql = "DELETE FROM\twcf" . WCF_N . "_package_dependency\n\t\t\tWHERE\t\tpackageID = " . $this->packageID . "\n\t\t\t\t\tOR dependency = " . $this->packageID;
WCF::getDB()->sendQuery($sql);
// rebuild config.inc.php files if necessary
foreach ($configPackageIDs as $configPackageID) {
Package::writeConfigFile($configPackageID);
}
}
示例3: rebuildConfigFiles
/**
* Rebuilds config.inc.php files after package updates or plugin installations.
*/
protected function rebuildConfigFiles()
{
// rebuild config.inc.php files if necessary
// check if this package requires a standalone package (except com.woltlab.wcf)
$sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tpackageID IN (\n\t\t\t\t\tSELECT\trequirement\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_requirement_map\n\t\t\t\t\tWHERE\tpackageID = " . $this->packageID . "\n\t\t\t\t)\n\t\t\t\tAND standalone = 1\n\t\t\t\tAND package <> 'com.woltlab.wcf'";
$row = WCF::getDB()->getFirstRow($sql);
if ($row['count'] > 0) {
// get all dependent standalone packages (except com.woltlab.wcf)
$sql = "SELECT\tpackageID\n\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\tWHERE\tpackageID IN (\n\t\t\t\t\t\tSELECT\tpackageID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\tWHERE\tdependency = " . $this->packageID . "\n\t\t\t\t\t)\n\t\t\t\t\tAND standalone = 1\n\t\t\t\t\tAND packageDir <> ''";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
Package::writeConfigFile($row['packageID']);
}
}
}