/** * @see PackageInstallationPlugin::uninstall() */ public function uninstall() { // call uninstall event EventHandler::fireAction($this, 'uninstall'); // get all style of this package $isDefault = false; require_once WCF_DIR . 'lib/data/style/StyleEditor.class.php'; $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_style\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID(); $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { // delete style $style = new StyleEditor(null, $row); $style->delete(); $isDefault = $isDefault || $style->isDefault; } // default style deleted if ($isDefault) { $sql = "SELECT\t\t*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_style\n\t\t\t\tORDER BY\tstyleID"; $row = WCF::getDB()->getFirstRow($sql); if (!empty($row['styleID'])) { $style = new StyleEditor(null, $row); $style->setAsDefault(); } } }
/** * @see Form::save() */ public function save() { parent::save(); foreach ($this->styleIDArray as $styleID) { $style = new StyleEditor($styleID); if ($style->styleID) { $style->writeStyleFile(); } } $this->saved(); WCF::getTPL()->assign('success', true); }
/** * @see Form::save() */ public function save() { AbstractForm::save(); // save style $finalVariables = $this->getFinalVariables(); $this->style = StyleEditor::create($this->styleName, $finalVariables, $this->templatePackID, $this->styleDescription, $this->styleVersion, $this->styleDate, $this->image, $this->copyright, $this->license, $this->authorName, $this->authorURL, intval(!$this->enableStyle)); // reset cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.style.php'); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::validate() */ public function validate() { parent::validate(); // upload xml file if ($this->xmlUpload && $this->xmlUpload['error'] != 4) { if ($this->xmlUpload['error'] != 0) { throw new UserInputException('xmlUpload', 'uploadFailed'); } try { $this->importedVariables = StyleEditor::readVariablesData(file_get_contents($this->xmlUpload['tmp_name'])); } catch (SystemException $e) { throw new UserInputException('xmlUpload', 'importFailed'); } } }
<?php /** * @author Marcel Werk * @copyright 2001-2007 WoltLab GmbH * @license WoltLab Burning Board License <http://www.woltlab.com/products/burning_board/license.php> */ $packageID = $this->installation->getPackageID(); // admin options $sql = "UPDATE \twcf" . WCF_N . "_group_option_value\r\n\tSET\toptionValue = 1\r\n\tWHERE\tgroupID = 4\r\n\t\tAND optionID IN (\r\n\t\t\tSELECT\toptionID\r\n\t\t\tFROM\twcf" . WCF_N . "_group_option\r\n\t\t\tWHERE\tpackageID IN (\r\n\t\t\t\t\tSELECT\tdependency\r\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\r\n\t\t\t\t\tWHERE\tpackageID = " . $packageID . "\r\n\t\t\t\t)\r\n\t\t)\r\n\t\tAND optionValue = '0'"; WCF::getDB()->sendQuery($sql); // mod options $sql = "UPDATE \twcf" . WCF_N . "_group_option_value\r\n\tSET\toptionValue = 1\r\n\tWHERE\tgroupID IN (5,6)\r\n\t\tAND optionID IN (\r\n\t\t\tSELECT\toptionID\r\n\t\t\tFROM\twcf" . WCF_N . "_group_option\r\n\t\t\tWHERE\toptionName LIKE 'mod.board.%'\r\n\t\t\t\tAND optionName <> 'mod.board.isSuperMod'\r\n\t\t\t\tAND packageID IN (\r\n\t\t\t\t\tSELECT\tdependency\r\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\r\n\t\t\t\t\tWHERE\tpackageID = " . $packageID . "\r\n\t\t\t\t)\r\n\t\t)\r\n\t\tAND optionValue = '0'"; WCF::getDB()->sendQuery($sql); // super mod option $sql = "UPDATE \twcf" . WCF_N . "_group_option_value\r\n\tSET\toptionValue = 1\r\n\tWHERE\tgroupID = 6\r\n\t\tAND optionID IN (\r\n\t\t\tSELECT\toptionID\r\n\t\t\tFROM\twcf" . WCF_N . "_group_option\r\n\t\t\tWHERE\toptionName = 'mod.board.isSuperMod'\r\n\t\t\t\tAND packageID IN (\r\n\t\t\t\t\tSELECT\tdependency\r\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\r\n\t\t\t\t\tWHERE\tpackageID = " . $packageID . "\r\n\t\t\t\t)\r\n\t\t)\r\n\t\tAND optionValue = '0'"; WCF::getDB()->sendQuery($sql); // list admin & mod groups on team page by default $sql = "UPDATE\twcf" . WCF_N . "_group\r\n\tSET\tshowOnTeamPage = 1\r\n\tWHERE\tgroupID IN (4,5,6)"; WCF::getDB()->sendQuery($sql); // delete obsolet language items $sql = "DELETE FROM\twcf" . WCF_N . "_language_item\r\n\tWHERE\t\tlanguageItem IN (\r\n\t\t\t\t'wcf.help.item.board.index', 'wcf.help.item.board.index.description',\r\n\t\t\t\t'wcf.help.item.board.postadd', 'wcf.help.item.board.postadd.description',\r\n\t\t\t\t'wcf.help.item.board.moderation', 'wcf.help.item.board.board.moderation.description',\r\n\t\t\t\t'wcf.help.item.board.wiw', 'wcf.help.item.board.wiw.description',\r\n\t\t\t\t'wcf.help.item.usercp.moderation', 'wcf.help.item.usercp.moderation.description'\r\n\t\t\t)\r\n\t\t\tAND packageID = " . $this->installation->getPackageID(); WCF::getDB()->sendQuery($sql); // refresh style files require_once WCF_DIR . 'lib/data/style/StyleEditor.class.php'; $sql = "SELECT * FROM wcf" . WCF_N . "_style"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $style = new StyleEditor(null, $row); $style->writeStyleFile(); }
/** * @see Form::validate() */ public function validate() { parent::validate(); if (!empty($this->filename)) { // import style $this->style = StyleEditor::import($this->filename, PACKAGE_ID, $this->destinationStyle !== null && $this->destinationStyle->styleID ? $this->destinationStyle : null); } else { // import destination if ($this->destinationStyle !== null && !$this->destinationStyle->styleID) { throw new UserInputException('destinationStyleID'); } // upload style if ($this->styleUpload && $this->styleUpload['error'] != 4) { if ($this->styleUpload['error'] != 0) { throw new UserInputException('styleUpload', 'uploadFailed'); } $this->newFilename = $this->styleUpload['tmp_name']; try { $this->styleData = StyleEditor::getStyleData($this->styleUpload['tmp_name']); } catch (SystemException $e) { throw new UserInputException('styleUpload', 'invalid'); } // copy file $newFilename = FileUtil::getTemporaryFilename('style_'); if (@move_uploaded_file($this->styleUpload['tmp_name'], $newFilename)) { $this->newFilename = $newFilename; } } else { if ($this->styleURL != 'http://') { if (StringUtil::indexOf($this->styleURL, 'http://') !== 0) { throw new UserInputException('styleURL', 'downloadFailed'); } try { $this->newFilename = FileUtil::downloadFileFromHttp($this->styleURL, 'style'); } catch (SystemException $e) { throw new UserInputException('styleURL', 'downloadFailed'); } try { $this->styleData = StyleEditor::getStyleData($this->newFilename); } catch (SystemException $e) { throw new UserInputException('styleURL', 'invalid'); } } else { throw new UserInputException('styleUpload'); } } } }
private static function parseAdditionalStyles(&$variables) { self::$variables = $variables; // fix images location if (!empty(self::$variables['global.images.location']) && !FileUtil::isURL(self::$variables['global.images.location']) && substr(self::$variables['global.images.location'], 0, 1) != '/') { self::$variables['global.images.location'] = '../' . self::$variables['global.images.location']; } // fix images location if (!empty(self::$variables['global.icons.location']) && !FileUtil::isURL(self::$variables['global.icons.location']) && substr(self::$variables['global.icons.location'], 0, 1) != '/') { self::$variables['global.icons.location'] = '../' . self::$variables['global.icons.location']; } // parse additional styles if (!empty($variables['user.additional.style.input1.use'])) { $variables['user.additional.style.input1.use'] = preg_replace_callback('/\\$([a-z0-9_\\-\\.]+)\\$/', array('self', 'parseAdditionalStylesCallback'), $variables['user.additional.style.input1.use']); } if (!empty($variables['user.additional.style.input2.use'])) { $variables['user.additional.style.input2.use'] = preg_replace_callback('/\\$([a-z0-9_\\-\\.]+)\\$/', array('self', 'parseAdditionalStylesCallback'), $variables['user.additional.style.input2.use']); } }
/** * Updates styles files of all styles. */ protected function updateStyleFiles() { require_once WCF_DIR . 'lib/data/style/StyleEditor.class.php'; // get all styles $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_style"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $style = new StyleEditor(null, $row); $style->writeStyleFile(); } }