From: Matthias Schmidt Date: Thu, 7 Apr 2016 14:17:31 +0000 (+0200) Subject: Remove unused language server system X-Git-Tag: 3.0.0_Beta_1~1951^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e97294ab31003223224d4d153f55a48862ab0fbf;p=GitHub%2FWoltLab%2FWCF.git Remove unused language server system --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c829267a..b8a88ed7b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ * `wcf\action\AJAXProxyAction::getData()` removed. * Version system removed. * Support for query string based sessions in Frontend removed. +* Language server system removed. #### Documentation diff --git a/wcfsetup/install/files/acp/templates/languageServerAdd.tpl b/wcfsetup/install/files/acp/templates/languageServerAdd.tpl deleted file mode 100644 index a6ea772214..0000000000 --- a/wcfsetup/install/files/acp/templates/languageServerAdd.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{include file='header' pageTitle='wcf.acp.languageServer.'|concat:$action} - -
-

{lang}wcf.acp.languageServer.{$action}{/lang}

-
- -{include file='formError'} - -{if $success|isset} -

{lang}wcf.acp.languageServer.{$action}.success{/lang}

-{/if} - -
- -
- -
-
-

{lang}wcf.acp.languageServer.data{/lang}

- - -
-
- - {if $errorField == 'server'} - - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'notValid'}{lang}wcf.acp.languageServer.server.error.notValid{/lang}{/if} - - {/if} - {lang}wcf.acp.languageServer.server.description{/lang} -
- - - {event name='dataFields'} -
- - {event name='sections'} - -
- - {@SECURITY_TOKEN_INPUT_TAG} -
-
- -{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageServerList.tpl b/wcfsetup/install/files/acp/templates/languageServerList.tpl deleted file mode 100644 index 6f838b54fe..0000000000 --- a/wcfsetup/install/files/acp/templates/languageServerList.tpl +++ /dev/null @@ -1,77 +0,0 @@ -{include file='header' pageTitle='wcf.acp.languageServer.list'} - - - -
-

{lang}wcf.acp.languageServer.list{/lang}

-
- -
- {pages print=true assign=pagesLinks controller='LanguageServerList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"} - - -
- -{if !$languageServers|count} -

{lang}wcf.global.noItems{/lang}

-{else} -
- - - - - - - {event name='columnHeads'} - - - - {foreach from=$languageServers item=languageServer} - - - - - - {event name='columns'} - - {/foreach} - -
{lang}wcf.global.objectID{/lang}{lang}wcf.acp.languageServer.serverURL{/lang}
- - - - - - {event name='rowButtons'} - {@$languageServer->languageServerID} - {$languageServer->serverURL} -
-
- -
- {@$pagesLinks} - - -
-{/if} - -{include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php deleted file mode 100644 index 6dd5ca39df..0000000000 --- a/wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage acp.form - * @category Community Framework - */ -class LanguageServerAddForm extends AbstractForm { - /** - * @see \wcf\page\AbstractPage::$activeMenuItem - */ - public $activeMenuItem = 'wcf.acp.menu.link.language.server.add'; - - /** - * @see \wcf\page\AbstractPage::$neededPermissions - */ - public $neededPermissions = array('admin.language.canManageLanguage'); - - /** - * server url - * @var string - */ - public $server = ''; - - /** - * @see \wcf\form\IForm::readFormParameters() - */ - public function readFormParameters() { - parent::readFormParameters(); - - if (isset($_POST['server'])) $this->server = StringUtil::trim($_POST['server']); - } - - /** - * @see \wcf\form\IForm::validate() - */ - public function validate() { - parent::validate(); - - if (empty($this->server)) { - throw new UserInputException('server'); - } - - if (!PackageUpdateServer::isValidServerURL($this->server)) { - throw new UserInputException('server', 'notValid'); - } - } - - /** - * @see \wcf\form\IForm::save() - */ - public function save() { - parent::save(); - - // save server - $this->objectAction = new LanguageServerAction(array(), 'create', array('data' => array_merge($this->additionalFields, array( - 'serverURL' => $this->server - )))); - $this->objectAction->executeAction(); - $this->saved(); - - // reset values - $this->server = ''; - - // show success message - WCF::getTPL()->assign('success', true); - } - - /** - * @see \wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'server' => $this->server, - 'action' => 'add' - )); - } - - /** - * @see \wcf\page\IPage::assignVariables() - */ - public function show() { - // check master password - WCFACP::checkMasterPassword(); - - parent::show(); - } -} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php deleted file mode 100644 index 3212508fd2..0000000000 --- a/wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage acp.form - * @category Community Framework - */ -class LanguageServerEditForm extends LanguageServerAddForm { - /** - * @see \wcf\page\AbstractPage::$activeMenuItem - */ - public $activeMenuItem = 'wcf.acp.menu.link.language.server'; - - /** - * language server id - * @var integer - */ - public $languageServerID = 0; - - /** - * active language server - * @var \wcf\data\language\server\LanguageServer - */ - public $languageServer = null; - - /** - * @see \wcf\page\IPage::readParameters() - */ - public function readParameters() { - parent::readParameters(); - - if (isset($_REQUEST['id'])) $this->languageServerID = intval($_REQUEST['id']); - $this->languageServer = new LanguageServer($this->languageServerID); - if (!$this->languageServer->languageServerID) { - throw new IllegalLinkException(); - } - } - - /** - * @see \wcf\form\IForm::save() - */ - public function save() { - AbstractForm::save(); - - // save server - $this->objectAction = new LanguageServerAction(array($this->languageServerID), 'update', array('data' => array_merge($this->additionalFields, array( - 'serverURL' => $this->server - )))); - $this->objectAction->executeAction(); - $this->saved(); - - // show success message - WCF::getTPL()->assign('success', true); - } - - /** - * @see \wcf\page\IPage::readData() - */ - public function readData() { - parent::readData(); - - if (empty($_POST)) { - $this->server = $this->languageServer->serverURL; - } - } - - /** - * @see \wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'languageServerID' => $this->languageServerID, - 'languageServer' => $this->languageServer, - 'action' => 'edit' - )); - } -} diff --git a/wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php b/wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php deleted file mode 100644 index 03549f60d8..0000000000 --- a/wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage acp.page - * @category Community Framework - */ -class LanguageServerListPage extends SortablePage { - /** - * @see \wcf\page\AbstractPage::$activeMenuItem - */ - public $activeMenuItem = 'wcf.acp.menu.link.language.server.list'; - - /** - * @see \wcf\page\SortablePage::$defaultSortField - */ - public $defaultSortField = 'serverURL'; - - /** - * @see \wcf\page\AbstractPage::$neededPermissions - */ - public $neededPermissions = array('admin.language.canManageLanguage'); - - /** - * @see \wcf\page\MultipleLinkPage::$objectListClassName - */ - public $objectListClassName = 'wcf\data\language\server\LanguageServerList'; - - /** - * @see \wcf\page\SortablePage::$validSortFields - */ - public $validSortFields = array('languageServerID', 'serverURL'); - - /** - * @see \wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'languageServers' => $this->objectList->getObjects() - )); - } -} diff --git a/wcfsetup/install/files/lib/data/language/server/LanguageServer.class.php b/wcfsetup/install/files/lib/data/language/server/LanguageServer.class.php deleted file mode 100644 index bc0ef23102..0000000000 --- a/wcfsetup/install/files/lib/data/language/server/LanguageServer.class.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.language.server - * @category Community Framework - * - * @property-read integer $languageServerID - * @property-read string $serverURL - * @property-read integer $isDisabled - */ -class LanguageServer extends DatabaseObject { - /** - * @see \wcf\data\DatabaseObject::$databaseTableName - */ - protected static $databaseTableName = 'language_server'; - - /** - * @see \wcf\data\DatabaseObject::$databaseTableIndexName - */ - protected static $databaseTableIndexName = 'languageServerID'; -} diff --git a/wcfsetup/install/files/lib/data/language/server/LanguageServerAction.class.php b/wcfsetup/install/files/lib/data/language/server/LanguageServerAction.class.php deleted file mode 100644 index d41714e74e..0000000000 --- a/wcfsetup/install/files/lib/data/language/server/LanguageServerAction.class.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.language.server - * @category Community Framework - */ -class LanguageServerAction extends AbstractDatabaseObjectAction implements IToggleAction { - /** - * @see \wcf\data\AbstractDatabaseObjectAction::$className - */ - protected $className = 'wcf\data\language\server\LanguageServerEditor'; - - /** - * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsCreate - */ - protected $permissionsCreate = array('admin.language.canManageLanguage'); - - /** - * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete - */ - protected $permissionsDelete = array('admin.language.canManageLanguage'); - - /** - * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate - */ - protected $permissionsUpdate = array('admin.language.canManageLanguage'); - - /** - * @see \wcf\data\AbstractDatabaseObjectAction::$requireACP - */ - protected $requireACP = array('create', 'delete', 'toggle', 'update'); - - /** - * @see \wcf\data\IToggleAction::toggle() - */ - public function toggle() { - foreach ($this->objects as $serverEditor) { - $serverEditor->update(array( - 'isDisabled' => $serverEditor->isDisabled ? 0 : 1 - )); - } - } - - /** - * @see \wcf\data\IToggleAction::validateToggle() - */ - public function validateToggle() { - $this->validateUpdate(); - } -} diff --git a/wcfsetup/install/files/lib/data/language/server/LanguageServerEditor.class.php b/wcfsetup/install/files/lib/data/language/server/LanguageServerEditor.class.php deleted file mode 100644 index 8d8e895a95..0000000000 --- a/wcfsetup/install/files/lib/data/language/server/LanguageServerEditor.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.language.server - * @category Community Framework - */ -class LanguageServerEditor extends DatabaseObjectEditor { - /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass - */ - protected static $baseClass = 'wcf\data\language\server\LanguageServer'; -} diff --git a/wcfsetup/install/files/lib/data/language/server/LanguageServerList.class.php b/wcfsetup/install/files/lib/data/language/server/LanguageServerList.class.php deleted file mode 100644 index b650d486a2..0000000000 --- a/wcfsetup/install/files/lib/data/language/server/LanguageServerList.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data.language.server - * @category Community Framework - */ -class LanguageServerList extends DatabaseObjectList { - /** - * @see \wcf\data\DatabaseObjectList::$className - */ - public $className = 'wcf\data\language\server\LanguageServer'; -} diff --git a/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php b/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php deleted file mode 100644 index 4184c3ae86..0000000000 --- a/wcfsetup/install/files/lib/system/language/LanguageServerProcessor.class.php +++ /dev/null @@ -1,349 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.language - * @category Community Framework - */ -class LanguageServerProcessor extends SingletonFactory { - /** - * language object - * @var \wcf\data\language\Language - */ - protected $language = null; - - /** - * Imports language variables for a language from given language servers. - * - * @param \wcf\data\language\Language $language - * @param LanguageServer[] $languageServers - */ - public function import(Language $language, array $languageServers) { - if (empty($languageServers)) return; - $this->language = $language; - - // get package list - $packageList = $this->getPackageList(); - - foreach ($languageServers as $languageServer) { - $this->importLanguageFile($languageServer->serverURL, $packageList); - } - } - - /** - * Returns list of installed packages and their associated version. - * - * @return string[] - */ - protected function getPackageList() { - $sql = "SELECT package, packageVersion - FROM wcf".WCF_N."_package"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - - $packages = array(); - while ($row = $statement->fetchArray()) { - $packages[$row['package']] = $row['packageVersion']; - } - - return $packages; - } - - /** - * Downloads and imports a language file from a language server. - * - * @param string $location - * @param string[] $packageList - * @throws SystemException - */ - protected function importLanguageFile($location, array $packageList) { - // get proxy - $options = array(); - if (PROXY_SERVER_HTTP) { - $options['http']['proxy'] = PROXY_SERVER_HTTP; - $options['http']['request_fulluri'] = true; - } - - // parse url - $parsedURL = parse_url($location); - $port = ($parsedURL['scheme'] == 'https' ? 443 : 80); - $host = $parsedURL['host']; - $path = (isset($parsedURL['path']) ? $parsedURL['path'] : '/'); - - $remoteFile = new RemoteFile(($parsedURL['scheme'] == 'https' ? 'ssl://' : '').$host, $port, 30, $options); // the file to read. - if (!isset($remoteFile)) { - throw new SystemException("cannot connect to http host '".$host."'"); - } - - // build and send the http request - $request = "POST ".$path." HTTP/1.0\r\n"; - $request .= "User-Agent: HTTP.PHP (LanguageServerProcessor.class.php; WoltLab Community Framework/".WCF_VERSION."; ".WCF::getLanguage()->languageCode.")\r\n"; - $request .= "Accept: */*\r\n"; - $request .= "Accept-Language: ".WCF::getLanguage()->languageCode."\r\n"; - $request .= "Host: ".$host."\r\n"; - - // build post string - $postString = 'languageCode='.$this->language->languageCode; - foreach ($packageList as $package => $packageVersion) { - $postString .= '&packages['.urlencode($package).']='.urlencode($packageVersion); - } - - // send content type and length - $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $request .= "Content-Length: ".strlen($postString)."\r\n"; - // if it is a POST request, there MUST be a blank line before the POST data, but there MUST NOT be - // another blank line before, and of course there must be another blank line at the end of the request! - $request .= "\r\n"; - if (!empty($postString)) $request .= $postString."\r\n"; - // send close - $request .= "Connection: Close\r\n\r\n"; - - // send request - $remoteFile->puts($request); - - // define response vars - $header = $content = ''; - - // fetch the response. - while (!$remoteFile->eof()) { - $line = $remoteFile->gets(); - if (rtrim($line) != '') { - $header .= $line; - } else { - break; - } - } - while (!$remoteFile->eof()) { - $content .= $remoteFile->gets(); - } - - // clean up and return the server's response. - $remoteFile->close(); - - // get http status code / line - $httpStatusCode = 0; - $httpStatusLine = ''; - if (preg_match('%http/\d\.\d (\d{3})[^\n]*%i', $header, $match)) { - $httpStatusLine = trim($match[0]); - $httpStatusCode = $match[1]; - } - - // catch http 301 Moved Permanently - // catch http 302 Found - // catch http 303 See Other - if ($httpStatusCode == 301 || $httpStatusCode == 302 || $httpStatusCode == 303) { - // find location - if (preg_match('/location:([^\n]*)/i', $header, $match)) { - $newLocation = trim($match[1]); - if ($newLocation != $location) { - $this->importLanguageFile($location, $packageList); - return; - } - } - } - - $this->parseResponse($content); - } - - /** - * Parses XML response from language server. - * - * @param string $xmlResponse - */ - protected function parseResponse($xmlResponse) { - // parse xml - $xml = new XML(); - $xml->loadXML('languageServerResponse.xml', $xmlResponse); - $xpath = $xml->xpath(); - - // parse variables - $variables = array(); - $packages = $xpath->query('/ns:language/ns:package'); - foreach ($packages as $package) { - $packageName = $package->getAttribute('name'); - $variables[$packageName] = array(); - - $categories = $xpath->query('child::ns:category', $package); - foreach ($categories as $category) { - $categoryName = $category->getAttribute('name'); - $variables[$packageName][$categoryName] = array(); - - $items = $xpath->query('child::ns:item', $category); - foreach ($items as $item) { - $variables[$packageName][$categoryName][$item->getAttribute('name')] = $item->nodeValue; - } - } - } - - // try to resolve packages - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("package IN (?)", array(array_keys($variables))); - - $sql = "SELECT packageID, package - FROM wcf".WCF_N."_package - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - $packages = array(); - while ($row = $statement->fetchArray()) { - $packages[$row['package']] = $row['packageID']; - } - - // ignore variables if no package is known - if (empty($packages)) return; - - $this->importVariables($variables, $packages); - } - - /** - * Imports language variables and categories. - * - * @param array $variables - * @param integer[] $packages - */ - protected function importVariables(array $variables, array $packages) { - $categories = $this->importCategories($variables); - - $createItems = $updateItems = array(); - foreach ($packages as $package => $packageID) { - foreach ($variables[$package] as $category => $items) { - // get existing items - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("languageID = ?", array($this->language->languageID)); - $conditions->add("packageID = ?", array($packageID)); - $conditions->add("languageCategoryID = ?", array($categories[$category])); - $conditions->add("languageItem IN (?)", array(array_keys($items))); - - $sql = "SELECT languageItemID, languageItem - FROM wcf".WCF_N."_language_item - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - - $existingItemIDs = array(); - while ($row = $statement->fetchArray()) { - $existingItemIDs[$row['languageItem']] = $row['languageItemID']; - } - - foreach ($items as $itemName => $itemValue) { - if (isset($existingItemIDs[$itemName])) { - $updateItems[$existingItemIDs[$itemName]] = $itemValue; - } - else { - $createItems[] = array( - 'languageID' => $this->language->languageID, - 'languageItem' => $itemName, - 'languageItemValue'=> $itemValue, - 'languageItemOriginIsSystem' => 1, - 'languageCategoryID' => $categories[$category], - 'packageID' => $packageID - ); - } - } - } - } - - // create items - if (!empty($createItems)) { - $sql = "INSERT INTO wcf".WCF_N."_language_item - (languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID) - VALUES (?, ?, ?, ?, ?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - - foreach ($createItems as $item) { - $statement->execute(array( - $item['languageID'], - $item['languageItem'], - $item['languageItemValue'], - $item['languageItemOriginIsSystem'], - $item['languageCategoryID'], - $item['packageID'] - )); - } - } - - // update items - if (!empty($updateItems)) { - $sql = "UPDATE wcf".WCF_N."_language_item - SET languageItemValue = ? - WHERE languageItemID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - - foreach ($updateItems as $languageItemID => $languageItemValue) { - $statement->execute(array($languageItemID, $languageItemValue)); - } - } - } - - /** - * Imports new langage categories. - * - * @param array $variables - * @return array - */ - protected function importCategories(array $variables) { - // get categories - $categoryNames = array(); - foreach ($variables as $package => $dummy) { - $categoryNames = array_merge($categoryNames, array_keys($variables[$package])); - } - - // fetch existing categories - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("languageCategory IN (?)", array($categoryNames)); - - $sql = "SELECT languageCategoryID, languageCategory - FROM wcf".WCF_N."_language_category - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - - $existingCategories = array(); - while ($row = $statement->fetchArray()) { - $existingCategories[$row['languageCategory']] = $row['languageCategoryID']; - } - - // create non-existing categories - $createCategories = array_diff($categoryNames, array_keys($existingCategories)); - if (!empty($createCategories)) { - // use raw queries for better performance - $sql = "INSERT INTO wcf".WCF_N."_language_category - (languageCategory) - VALUES (?)"; - $statement = WCF::getDB()->prepareStatement($sql); - foreach ($createCategories as $category) { - $statement->execute(array($category)); - } - - // get ids for created categories - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("languageCategory IN (?)", array($createCategories)); - - $sql = "SELECT languageCategoryID, languageCategory - FROM wcf".WCF_N."_language_category - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - - while ($row = $statement->fetchArray()) { - $existingCategories[$row['languageCategory']] = $row['languageCategoryID']; - } - } - - return $existingCategories; - } -} diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index b47681c659..b0d106d2d0 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -513,13 +513,6 @@ CREATE TABLE wcf1_language_item ( KEY languageItemOriginIsSystem (languageItemOriginIsSystem) ); -DROP TABLE IF EXISTS wcf1_language_server; -CREATE TABLE wcf1_language_server ( - languageServerID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, - serverURL VARCHAR(255) NOT NULL DEFAULT '', - isDisabled TINYINT(1) NOT NULL DEFAULT 0 -); - DROP TABLE IF EXISTS wcf1_like; CREATE TABLE wcf1_like ( likeID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,