From 4f3671837319ad210bfbbbcb2e529ddc2f9d692a Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 22 Feb 2013 23:03:23 +0100 Subject: [PATCH] Removed obsolete icon path --- .../install/files/acp/templates/styleAdd.tpl | 16 ---- .../files/acp/templates/styleExport.tpl | 5 -- .../files/lib/acp/form/StyleAddForm.class.php | 20 +---- .../lib/acp/form/StyleEditForm.class.php | 4 +- .../lib/acp/form/StyleExportForm.class.php | 18 +--- .../lib/data/style/StyleAction.class.php | 6 -- .../lib/data/style/StyleEditor.class.php | 90 +------------------ wcfsetup/install/lang/de.xml | 3 - wcfsetup/setup/db/install.sql | 1 - 9 files changed, 6 insertions(+), 157 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/styleAdd.tpl b/wcfsetup/install/files/acp/templates/styleAdd.tpl index 60da7a4eb1..022c13faef 100644 --- a/wcfsetup/install/files/acp/templates/styleAdd.tpl +++ b/wcfsetup/install/files/acp/templates/styleAdd.tpl @@ -262,22 +262,6 @@ {/hascontent} - -
-
- - {if $errorField == 'iconPath'} - - {if $errorType == 'empty'} - {lang}wcf.global.form.error.empty{/lang} - {else} - {lang}wcf.acp.style.error.iconPath.{$errorType}{/lang} - {/if} - - {/if} - {lang}wcf.acp.style.iconPath.description{/lang} -
-
diff --git a/wcfsetup/install/files/acp/templates/styleExport.tpl b/wcfsetup/install/files/acp/templates/styleExport.tpl index bdc7abd346..1da04bbfb3 100644 --- a/wcfsetup/install/files/acp/templates/styleExport.tpl +++ b/wcfsetup/install/files/acp/templates/styleExport.tpl @@ -22,11 +22,6 @@ {lang}wcf.acp.style.exportStyle.components{/lang} {lang}wcf.acp.style.exportStyle.components.description{/lang} -
-
- -
-
diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index da3a17f87f..7ca219682a 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -99,12 +99,6 @@ class StyleAddForm extends AbstractForm { */ public $globals = array(); - /** - * icon path - * @var string - */ - public $iconPath = 'icon/'; - /** * image path * @var string @@ -229,7 +223,6 @@ class StyleAddForm extends AbstractForm { if (isset($_POST['authorName'])) $this->authorName = StringUtil::trim($_POST['authorName']); if (isset($_POST['authorURL'])) $this->authorURL = StringUtil::trim($_POST['authorURL']); if (isset($_POST['copyright'])) $this->copyright = StringUtil::trim($_POST['copyright']); - if (isset($_POST['iconPath'])) $this->iconPath = StringUtil::trim($_POST['iconPath']); if (isset($_POST['imagePath'])) $this->imagePath = StringUtil::trim($_POST['imagePath']); if (isset($_POST['license'])) $this->license = StringUtil::trim($_POST['license']); if (isset($_POST['styleDate'])) $this->styleDate = StringUtil::trim($_POST['styleDate']); @@ -286,14 +279,6 @@ class StyleAddForm extends AbstractForm { } } - // ensure icon path is below WCF_DIR/icon/ - if ($this->iconPath) { - $relativePath = FileUtil::unifyDirSeperator(FileUtil::getRelativePath(WCF_DIR.'icon/', WCF_DIR.$this->iconPath)); - if (strpos($relativePath, '../') !== false) { - throw new UserInputException('iconPath', 'notValid'); - } - } - // ensure image path is below WCF_DIR/images/ if ($this->imagePath) { $relativePath = FileUtil::unifyDirSeperator(FileUtil::getRelativePath(WCF_DIR.'images/', WCF_DIR.$this->imagePath)); @@ -494,8 +479,7 @@ class StyleAddForm extends AbstractForm { 'copyright' => $this->copyright, 'license' => $this->license, 'authorName' => $this->authorName, - 'authorURL' => $this->authorURL, - 'iconPath' => $this->iconPath + 'authorURL' => $this->authorURL ), 'tmpHash' => $this->tmpHash, 'variables' => $this->variables @@ -518,7 +502,6 @@ class StyleAddForm extends AbstractForm { $this->authorName = $this->authorURL = $this->copyright = $this->fontFamily = $this->image = ''; $this->license = $this->styleDate = $this->styleDescription = $this->styleName = $this->styleVersion = ''; - $this->iconPath = 'icon/'; $this->imagePath = 'images/'; $this->templateGroupID = 0; @@ -545,7 +528,6 @@ class StyleAddForm extends AbstractForm { 'availableUnits' => $this->availableUnits, 'copyright' => $this->copyright, 'fontFamily' => $this->fontFamily, - 'iconPath' => $this->iconPath, 'imagePath' => $this->imagePath, 'license' => $this->license, 'styleDate' => $this->styleDate, diff --git a/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php index 4d61392d12..ba27ccdca1 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php @@ -80,7 +80,6 @@ class StyleEditForm extends StyleAddForm { $this->authorName = $this->style->authorName; $this->authorURL = $this->style->authorURL; $this->copyright = $this->style->copyright; - $this->iconPath = $this->style->iconPath; $this->imagePath = $this->style->imagePath; $this->license = $this->style->license; $this->styleDate = $this->style->styleDate; @@ -107,8 +106,7 @@ class StyleEditForm extends StyleAddForm { 'copyright' => $this->copyright, 'license' => $this->license, 'authorName' => $this->authorName, - 'authorURL' => $this->authorURL, - 'iconPath' => $this->iconPath + 'authorURL' => $this->authorURL ), 'tmpHash' => $this->tmpHash, 'variables' => $this->variables diff --git a/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php index 4d87c6e21f..aeb737343e 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleExportForm.class.php @@ -25,12 +25,6 @@ class StyleExportForm extends AbstractForm { */ public $activeMenuItem = 'wcf.acp.menu.link.style'; - /** - * true, if style has custom icons - * @var boolean - */ - public $canExportIcons = false; - /** * true, if style has custom images * @var boolean @@ -49,12 +43,6 @@ class StyleExportForm extends AbstractForm { */ public $exportAsPackage = false; - /** - * true, if icons should be exported - * @var boolean - */ - public $exportIcons = false; - /** * true, if images should be exported * @var boolean @@ -102,7 +90,6 @@ class StyleExportForm extends AbstractForm { throw new IllegalLinkException(); } - if ($this->style->iconPath && $this->style->iconPath != 'icon/') $this->canExportIcons = true; if ($this->style->imagePath && $this->style->imagePath != 'images/') $this->canExportImages = true; if ($this->style->templateGroupID) $this->canExportTemplates = true; } @@ -113,7 +100,6 @@ class StyleExportForm extends AbstractForm { public function readFormParameters() { parent::readFormParameters(); - if ($this->canExportIcons && isset($_POST['exportIcons'])) $this->exportIcons = true; if ($this->canExportImages && isset($_POST['exportImages'])) $this->exportImages = true; if ($this->canExportTemplates && isset($_POST['exportTemplates'])) $this->exportTemplates = true; @@ -167,7 +153,7 @@ class StyleExportForm extends AbstractForm { // export style $styleEditor = new StyleEditor($this->style); - $styleEditor->export($this->exportTemplates, $this->exportImages, $this->exportIcons, $this->packageName); + $styleEditor->export($this->exportTemplates, $this->exportImages, $this->packageName); // call saved event $this->saved(); @@ -182,11 +168,9 @@ class StyleExportForm extends AbstractForm { parent::assignVariables(); WCF::getTPL()->assign(array( - 'canExportIcons' => $this->canExportIcons, 'canExportImages' => $this->canExportImages, 'canExportTemplates' => $this->canExportTemplates, 'exportAsPackage' => $this->exportAsPackage, - 'exportIcons' => $this->exportIcons, 'exportImages' => $this->exportImages, 'exportTemplates' => $this->exportTemplates, 'packageName' => $this->packageName, diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index 5af04b76fc..1af9e58542 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -98,11 +98,6 @@ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction $count = parent::delete(); foreach ($this->objects as $style) { - // remove custom icons - if ($style->iconPath && $style->iconPath != 'icon/') { - $this->removeDirectory($style->iconPath); - } - // remove custom images if ($style->imagePath && $style->imagePath != 'images/') { $this->removeDirectory($style->imagePath); @@ -400,7 +395,6 @@ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction 'license' => $this->styleEditor->license, 'authorName' => $this->styleEditor->authorName, 'authorURL' => $this->styleEditor->authorURL, - 'iconPath' => $this->styleEditor->iconPath, 'imagePath' => $this->styleEditor->imagePath )); diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index bd2018f9b5..4caa4b9796 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -132,7 +132,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $data = array( 'name' => '', 'description' => array(), 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, 'license' => '', 'authorName' => '', 'authorURL' => '', 'templates' => '', 'images' => '', - 'variables' => '', 'date' => '0000-00-00', 'icons' => '', 'iconsPath' => '', 'imagesPath' => '' + 'variables' => '', 'date' => '0000-00-00', 'imagesPath' => '' ); $categories = $xpath->query('/ns:style/*'); @@ -391,67 +391,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject } } - // import icons - if (!empty($data['icons']) && $data['iconsPath'] != 'icon/') { - $iconsLocation = FileUtil::getRelativePath(WCF_DIR, self::getFileLocation($data['imagesPath'])); - $styleData['iconPath'] = $iconsLocation; - - $index = $tar->getIndexByFilename($data['icons']); - if ($index !== false) { - // extract icons tar - $destination = FileUtil::getTemporaryFilename('icons_'); - $tar->extract($index, $destination); - - // open icons tar and group icons by package - $iconsTar = new Tar($destination); - $contentList = $iconsTar->getContentList(); - $packageToIcons = array(); - foreach ($contentList as $val) { - if ($val['type'] == 'file') { - $folders = explode('/', $val['filename']); - $packageName = array_shift($folders); - if (!isset($packageToIcons[$packageName])) { - $packageToIcons[$packageName] = array(); - } - $packageToIcons[$packageName][] = array('index' => $val['index'], 'filename' => implode('/', $folders)); - } - } - - // copy icons - foreach ($packageToIcons as $package => $icons) { - // try to find package - $sql = "SELECT packageDir - FROM wcf".WCF_N."_package - WHERE package = ? - AND isApplication = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - $package, - 1 - )); - while ($row = $statement->fetchArray()) { - // get icon path - $iconDir = FileUtil::getRealPath(WCF_DIR.$row['packageDir']).$iconsLocation; - - // create icon path - if (!file_exists($iconDir)) { - @mkdir($iconDir, 0777, true); - @chmod($iconDir, 0777); - } - - // copy icons - foreach ($icons as $icon) { - $iconsTar->extract($icon['index'], $iconDir.$icon['filename']); - } - } - } - - // delete tmp file - $iconsTar->close(); - @unlink($destination); - } - } - // import templates if (!empty($data['templates'])) { $index = $tar->getIndexByFilename($data['templates']); @@ -488,7 +427,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject 1 )); while ($row = $statement->fetchArray()) { - // get icon path + // get template path $templatesDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$row['packageDir']).'templates/'.$templateGroupFolderName); // create template path @@ -616,10 +555,9 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject * * @param boolean $templates * @param boolean $images - * @param boolean $icons * @param string $packageName */ - public function export($templates = false, $images = false, $icons = false, $packageName = '') { + public function export($templates = false, $images = false, $packageName = '') { // create style tar $styleTarName = FileUtil::getTemporaryFilename('style_', '.tgz'); $styleTar = new TarWriter($styleTarName, true); @@ -673,7 +611,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $xml->writeElement('variables', 'variables.xml'); if ($templates) $xml->writeElement('templates', 'templates.tar'); if ($images) $xml->writeElement('images', 'images.tar', array('path' => $this->imagePath)); - if ($icons) $xml->writeElement('icons', 'icons.tar', array('path' => $this->iconPath)); $xml->endElement(); // append style info file to style tar @@ -755,27 +692,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject @unlink($imagesTarName); } - // export icons - if ($icons && ($this->iconPath && $this->iconPath != 'icon/')) { - // create icons tar - $iconsTarName = FileUtil::getTemporaryFilename('icons_', '.tar'); - $iconsTar = new TarWriter($iconsTarName); - @chmod($iconsTar, 0777); - - // append icons to tar - $path = FileUtil::addTrailingSlash(WCF_DIR.$this->iconPath); - if (file_exists($path) && is_dir($path)) { - $icons = glob($path.'*.svg'); - foreach ($icons as $icon) { - $iconsTar->add($icon, '', $path); - } - } - - $iconsTar->create(); - $styleTar->add($iconsTarName, 'icons.tar', $iconsTarName); - @unlink($iconsTarName); - } - // output file content $styleTar->create(); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index ed08fc6838..bab64458f6 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -589,7 +589,6 @@ styleName}“ wirklich löschen?]]> - iconPath})]]> imagePath})]]> @@ -608,8 +607,6 @@ - - diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index f1cba06078..792a334159 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -561,7 +561,6 @@ CREATE TABLE wcf1_style ( license VARCHAR(255) NOT NULL DEFAULT '', authorName VARCHAR(255) NOT NULL DEFAULT '', authorURL VARCHAR(255) NOT NULL DEFAULT '', - iconPath VARCHAR(255) NOT NULL DEFAULT '', imagePath VARCHAR(255) NOT NULL DEFAULT '' ); -- 2.20.1