/** * @see Form::validate() */ public function save() { AbstractForm::save(); // update $this->userOption->update($this->userOption->optionName, $this->categoryName, $this->optionType, $this->defaultValue, $this->validationPattern, $this->selectOptions, '', $this->required, $this->askDuringRegistration, $this->editable, $this->visible, $this->getOutputClass(), $this->searchable, $this->showOrder); // update languages variables require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.' . $this->userOption->optionName => $this->optionName, 'wcf.user.option.' . $this->userOption->optionName . '.description' => $this->optionDescription), 0, PACKAGE_ID, array('wcf.user.option.' . $this->userOption->optionName => 1, 'wcf.user.option.' . $this->userOption->optionName . '.description' => 1)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::save() */ public function save() { ACPForm::save(); // save $this->category->update($this->category->categoryName, 'profile', $this->category->categoryIconS, $this->category->categoryIconM, $this->showOrder); // update language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.category.' . $this->category->categoryName => $this->categoryName), 0, PACKAGE_ID, array('wcf.user.option.category.' . $this->category->categoryName => 1)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see PackageInstallationPlugin::install() */ public function install() { $instructions = $this->installation->getInstructions(); $languages = $instructions['languages']; // Install each <language>-tag from package.xml foreach ($languages as $language) { if ($xml = $this->readLanguage($language)) { // check required attributes if (!isset($language['languagecode'])) { throw new SystemException("required 'languagecode' attribute for 'languages' tag is missing in '" . PackageArchive::INFO_FILE . "'", 13001); } // check language encoding if (!Language::isSupported($language['languagecode'])) { // unsupported encoding continue; } // Get language $language = LanguageEditor::getLanguageByCode($language['languagecode']); if ($language === null) { // unknown language continue; } // import xml // don't update language files if package is standalone $language->updateFromXML($xml, $this->installation->getPackageID(), !$this->installation->getPackage()->isStandalone()); // add language to this package. $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_language_to_packages\n\t\t\t\t\t\t\t\t(languageID, packageID)\n\t\t\t\t\tVALUES\t\t\t(" . $language->getLanguageID() . ", \n\t\t\t\t\t\t\t\t" . $this->installation->getPackageID() . ")"; WCF::getDB()->sendQuery($sql); } } }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['cache.clearCache']; if ($parameters['clearWCFCache']) { WCF::getCache()->clear(WCF_DIR . 'cache', '*.php', true); } if ($parameters['clearStandaloneCache']) { $sql = "SELECT packageDir FROM wcf" . WCF_N . "_package WHERE packageID = " . PACKAGE_ID; $row = WCF::getDB()->getFirstRow($sql); WCF::getCache()->clear($row['packageDir'] . 'cache', '*.php', true); } if ($parameters['clearTemplateCache']) { require_once WCF_DIR . 'lib/system/template/ACPTemplate.class.php'; ACPTemplate::deleteCompiledACPTemplates(); Template::deleteCompiledTemplates(); } if ($parameters['clearLanguageCache']) { LanguageEditor::deleteLanguageFiles('*', '*', '*'); } if ($parameters['clearStandaloneOptions']) { Options::resetCache(); Options::resetFile(); } $this->executed(); }
/** * @see Form::validate() */ public function validate() { parent::validate(); // query if (empty($this->query)) { throw new UserInputException('query'); } // test regex if ($this->useRegex) { try { preg_match('/' . $this->query . '/', ''); } catch (SystemException $e) { throw new UserInputException('query', 'invalidRegex'); } } if ($this->searchVariableName) { $this->replace = 0; } // get results $results = LanguageEditor::search($this->query, $this->replace ? $this->replaceBy : null, $this->languageID ? $this->languageID : null, $this->useRegex, $this->caseSensitive, $this->searchVariableName); if (count($results)) { $languageItems = array(); foreach ($results as $result) { if (!isset($languageItems[$result['languageID']])) { $languageItems[$result['languageID']] = array(); } $languageItems[$result['languageID']][] = $result; } WCF::getTPL()->assign(array('languageItems' => $languageItems, 'languages' => WCF::getCache()->get('languages', 'languages'))); WCF::getTPL()->display('languageSearchResult'); exit; } else { WCF::getTPL()->assign('noMatches', true); } }
/** * @see Action::execute() */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.language.canEditLanguage'); // delete language require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor($this->languageID); if (!$language->getLanguageID() || $language->isDefault()) { throw new IllegalLinkException(); } $language->makeDefault(); $this->executed(); // forward to list page HeaderUtil::redirect('index.php?page=LanguageList&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.help.canEditHelpItem'); // get help item $helpItem = new HelpItemEditor($this->helpItemID); if (!$helpItem->helpItemID) { throw new IllegalLinkException(); } // change language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.help.item.' . $helpItem->helpItem => $this->title), 0, PACKAGE_ID, array('wcf.help.item.' . $helpItem->helpItem => 1)); // reset cache WCF::getCache()->clearResource('help-' . PACKAGE_ID); $this->executed(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.language.canEditLanguage'); // export language require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor($this->languageID); if (!$language->getLanguageID()) { throw new IllegalLinkException(); } // send headers header('Content-Type: text/xml; charset=' . CHARSET); header('Content-Disposition: attachment; filename="' . $language->getLanguageCode() . '.xml"'); // export $language->export(); $this->executed(); }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.board.canEditBoard'); // check board title if (StringUtil::encodeHTML($this->board->title) != WCF::getLanguage()->get(StringUtil::encodeHTML($this->board->title))) { // change language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($this->board->title => $this->title), 0, PACKAGE_ID, array($this->board->title => 1)); } else { // change title $this->board->updateData(array('title' => $this->title)); } // reset cache WCF::getCache()->clearResource('board'); $this->executed(); }
/** * @see Form::save() */ public function save() { parent::save(); // save LanguageEditor::enableMultilingualism($this->enable == 1 ? $this->languageIDs : array()); // clear cache WCF::getCache()->clearResource('languages'); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * Updates the language items of a language category. * * @param array $items * @param integer $categoryID * @param integer $packageID * @param array $useCustom */ public function easyUpdateItems($categoryString, $items, $packageID = null) { $packageID = $packageID === null ? WCF::getPackageID('de.easy-coding.wcf.contest') : $packageID; $language = new LanguageEditor($this->languageID); $xmlString = '<?xml version="1.0" encoding="' . CHARSET . '"?> <language languagecode="' . $this->getLanguageCode() . '"> <category name="' . $categoryString . '">'; foreach ($items as $key => $val) { if ($val === null) { continue; } $xmlString .= '<item name="' . $key . '"><![CDATA[' . $val . ']]></item>'; } $xmlString .= ' </category> </language>'; $xml = new XML(); $xml->loadString($xmlString); $language->updateFromXML($xml, $packageID); }
/** * @see Form::save() */ public function save() { parent::save(); // create random name $name = "userOptionCategory" . time(); // save $userOptionCategory = UserOptionCategoryEditor::create($name, 'profile', '', '', $this->showOrder); // change name $userOptionCategory->update('userOptionCategory' . $userOptionCategory->categoryID, 'profile', '', '', $this->showOrder); // save name as language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.category.' . 'userOptionCategory' . $userOptionCategory->categoryID => $this->categoryName)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // reset values $this->categoryName = ''; $this->showOrder = 0; // show success message WCF::getTPL()->assign('success', true); }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.pageMenu.canEditPageMenuItem'); // get menu item $menuItem = new PageMenuItemEditor($this->menuItemID); if (!$menuItem->menuItemID) { throw new IllegalLinkException(); } // check menu item title if (StringUtil::encodeHTML($menuItem->menuItem) != WCF::getLanguage()->get(StringUtil::encodeHTML($menuItem->menuItem))) { // change language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($menuItem->menuItem => $this->title), 0, PACKAGE_ID, array($menuItem->menuItem => 1)); } else { $menuItem->update($this->title, $menuItem->link, $menuItem->iconS, $menuItem->iconM, $menuItem->showOrder, $menuItem->position, $menuItem->languageID); } // reset cache WCF::getCache()->clearResource('menu-' . PACKAGE_ID); $this->executed(); }
/** * @see OptionType::getFormElement() */ public function getFormElement(&$optionData) { if (!isset($optionData['optionValue'])) { if (isset($optionData['defaultValue'])) { $optionData['optionValue'] = $optionData['defaultValue']; } else { $optionData['optionValue'] = false; } } // get options $options = LanguageEditor::getLanguages(); WCF::getTPL()->assign(array('optionData' => $optionData, 'options' => $options)); return WCF::getTPL()->fetch('optionTypeSelect'); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.language.canDeleteLanguage'); // delete language variable require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; LanguageEditor::deleteVariable($this->languageItem); // delete empty categories $deletedCategories = LanguageEditor::deleteEmptyCategories(); $this->executed(); // forward to list page if ($this->languageID && $this->languageCategoryID && !isset($deletedCategories[$this->languageCategoryID])) { HeaderUtil::redirect('index.php?form=LanguageEdit&languageID=' . $this->languageID . '&languageCategoryID=' . $this->languageCategoryID . '&deletedVariable=' . $this->languageItem . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); } else { HeaderUtil::redirect('index.php?page=LanguageList&deletedVariable=' . $this->languageItem . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); } exit; }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['user.languagedefaults']; $condition = ''; if ($parameters['correctonly']) { $languages = array_keys(LanguageEditor::getLanguages()); foreach ($languages as $language) { if (!empty($condition)) { $condition .= ','; } $condition .= $language; } } $sql = "UPDATE wcf" . WCF_N . "_user\n\t\t\t\tSET languageID = " . $parameters['languageID'] . (!empty($condition) ? " WHERE languageID NOT IN(" . $condition . ")" : ""); WCF::getDB()->sendQuery($sql); $message = WCF::getLanguage()->get('wcf.acp.admintools.function.success', array('$functionName' => WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName']))); $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName'] . '.affectedUsers', array('$affectedUsers' => WCF::getDB()->getAffectedRows())); $this->setReturnMessage('success', $message); $this->executed(); }
/** * @see Form::save() */ public function save() { if (!$this->preview) { parent::save(); // get languages $languages = array(); $sql = "SELECT\tlanguageID\n\t\t\t\tFROM\twcf" . WCF_N . "_language\n\t\t\t\tWHERE\tlanguageID <> " . $this->sourceLanguageID; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $languages[] = $row['languageID']; } if (count($languages) > 0) { // add missing language items foreach ($languages as $languageID) { $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageCategoryID, packageID)\n\t\t\t\t\t\tSELECT\t\t\t" . $languageID . ", languageItem, languageItemValue, languageCategoryID, packageID\n\t\t\t\t\t\tFROM\t\t\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\tWHERE\t\t\tlanguageID = " . $this->sourceLanguageID . "\n\t\t\t\t\t\t\t\t\tAND languageItem NOT IN (\n\t\t\t\t\t\t\t\t\t\tSELECT\tlanguageItem\n\t\t\t\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t\t\t\t\tWHERE\tlanguageID = " . $languageID . "\n\t\t\t\t\t\t\t\t\t)"; WCF::getDB()->sendQuery($sql); $this->addedLanguageItems += WCF::getDB()->getAffectedRows(); } // remove obsolete language items $languageItemIDs = ''; $sql = "SELECT\tlanguageItemID \n\t\t\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\t\t\tWHERE\tlanguageID IN (" . implode(',', $languages) . ")\n\t\t\t\t\t\tAND languageItem NOT IN (\n\t\t\t\t\t\t\tSELECT\tlanguageItem\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t\tWHERE\tlanguageID = " . $this->sourceLanguageID . "\n\t\t\t\t\t\t)"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $languageItemIDs .= ',' . $row['languageItemID']; } $sql = "DELETE FROM\twcf" . WCF_N . "_language_item\n\t\t\t\t\tWHERE\t\tlanguageItemID IN (0" . $languageItemIDs . ")"; WCF::getDB()->sendQuery($sql); $this->deletedLanguageItems = WCF::getDB()->getAffectedRows(); } // delete language files LanguageEditor::deleteLanguageFiles(); $this->saved(); // show success message WCF::getTPL()->assign(array('success' => true, 'addedLanguageItems' => $this->addedLanguageItems, 'deletedLanguageItems' => $this->deletedLanguageItems)); } }
$msg->addError('LAST_LANGUAGE'); } if (!$msg->containsErrors()) { header('Location: language_delete.php?id=' . $_POST['id']); exit; } } else { if ($_POST['edit']) { header('Location: language_add_edit.php?id=' . $_POST['id']); exit; } else { if (isset($_POST['export'])) { $language =& $languageManager->getLanguage($lang_code); if ($language === FALSE) { $msg->addError('ITEM_NOT_FOUND'); } else { $languageEditor = new LanguageEditor($language); $languageEditor->export(); } } } } } if (isset($_POST['import']) && is_uploaded_file($_FILES['file']['tmp_name'])) { $languageManager->import($_FILES['file']['tmp_name']); header('Location: index.php'); exit; } // interface $savant->assign('rows', $languagesDAO->getAll()); $savant->display('language/index.tmpl.php');
/** * @see Action::execute() */ public function execute() { parent::execute(); // get session data $sessionData = WCF::getSession()->getVar('databaseImportData'); $filesize = $sessionData['filesize']; $isGzip = $sessionData['isGzip']; $extendedCommand = $sessionData['extendedCommand']; $offset = $sessionData['offset']; $charset = $sessionData['importCharset']; $ignoreErrors = $sessionData['ignoreErrors']; $importErrors = ''; $stepInfo = array(); // start export operations $loopStart = time(); $importFile = $sessionData['importFile']; if ($isGzip) { $file = new ZipFile($importFile, 'rb'); } else { $file = new File($importFile, 'rb'); } // import database operations (only up to $this->limit) $loopInfo = DatabaseDumper::import($file, $filesize, $isGzip, $this->limit, $loopStart, $offset, $charset, $extendedCommand, $ignoreErrors); $file->close(); // store charset if (!empty($loopInfo['charset']) && $loopInfo['charset'] != $sessionData['wcfCharset']) { $sessionData['importCharset'] = $loopInfo['charset']; } // delete aftereffected erros (no insert errors will be displayed if the table caused an error before) $tableErrors = $sessionData['tableErrors']; foreach ($loopInfo['errors']['messages'] as $key => $message) { if (preg_match("/CREATE TABLE `?(\\w+)`?/i", $message, $match)) { $tableErrors[] = $match[1]; } elseif (preg_match("/(INSERT|REPLACE).*?INTO `?(\\w+)`?/i", $message, $match)) { if (in_array($match[1], $tableErrors)) { unset($loopInfo['errors']['messages'][$key]); unset($loopInfo['errors']['errorDescriptions'][$key]); } else { $tableErrors[] = $match[1]; } } } // save errors $errors = array('messages' => array_merge($sessionData['errors']['messages'], $loopInfo['errors']['messages']), 'errorDescriptions' => array_merge($sessionData['errors']['errorDescriptions'], $loopInfo['errors']['errorDescriptions'])); $sessionData['errors'] = $errors; $sessionData['tableErrors'] = $tableErrors; // refresh session data $sessionData['extendedCommand'] = $loopInfo['extendedCommand']; $sessionData['offset'] = $loopInfo['offset']; $sessionData['remain'] -= $loopInfo['done']; $sessionData['commandCount'] += $loopInfo['commandCount']; // calculate progressbar $this->calcProgress($sessionData['count'] - $sessionData['remain'], $sessionData['count']); // show finish if ($sessionData['remain'] <= 0) { // reset charset for database connection if (!empty($sessionData['importCharset'])) { WCF::getDB()->setCharset($sessionData['wcfCharset']); } // cleanup session data WCF::getSession()->unregister('databaseImportData'); // delete imported upload/remote file if ($sessionData['isTmpFile']) { @unlink($importFile); } // clear all standalone caches // get standalone package directories $sql = "SELECT\tpackageDir \n\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\tWHERE\tstandalone = 1\n\t\t\t\t\tAND packageDir <> ''"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { // check if standalone package got cache directory $realPackageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $row['packageDir'])); if (file_exists($realPackageDir . 'cache')) { // delete all cache files WCF::getCache()->clear($realPackageDir . 'cache', '*.php', true); } } // clear wcf cache WCF::getCache()->clear(WCF_DIR . 'cache', '*.php', true); // delete all language files LanguageEditor::updateAll(); // set data for template WCF::getTPL()->assign(array('import' => true, 'success' => empty($errors['messages']) && $sessionData['commandCount'] > 0, 'commandCount' => $sessionData['commandCount'], 'errors' => $errors)); WCF::getTPL()->append('message', WCF::getTPL()->fetch('dbMessage')); // show finish template $title = 'wcf.acp.db.progress.finish'; $this->finish($title, 'index.php?form=DatabaseImport&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); } WCF::getSession()->register('databaseImportData', $sessionData); // next loop $title = 'wcf.acp.db.import.progress.working'; $this->nextLoop($title); }
/** * @see Form::save() */ public function save() { parent::save(); // create random name $name = "userOption" . time(); // save option $this->optionID = UserOptionEditor::create($name, $this->categoryName, $this->optionType, $this->defaultValue, $this->validationPattern, $this->selectOptions, '', $this->required, $this->askDuringRegistration, $this->editable, $this->visible, $this->getOutputClass(), $this->searchable, $this->showOrder); // change random name $name = "userOption" . $this->optionID; WCF::getDB()->sendQuery("UPDATE\t\twcf" . WCF_N . "_user_option\n\t\t\t\t\tSET\t\toptionName = '{$name}'\n\t\t\t\t\tWHERE \t\toptionID = " . $this->optionID); // save language variables require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array('wcf.user.option.' . $name => $this->optionName, 'wcf.user.option.' . $name . '.description' => $this->optionDescription)); // delete cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.user-option-*'); $this->saved(); // reset values $this->optionName = $this->optionDescription = $this->categoryName = $this->optionType = $this->defaultValue = $this->validationPattern = ''; $this->optionType = $this->selectOptions = ''; $this->required = $this->editable = $this->visible = $this->searchable = $this->showOrder = $this->askDuringRegistration = 0; // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::save() */ public function save() { AbstractForm::save(); $this->showOrder = $this->getShowOrder($this->showOrder, $this->parentMenuItem, 'parentMenuItem'); if ($this->useiFrame) { $sql = "UPDATE wcf" . WCF_N . "_admin_tools_iframe SET\n\t\t\t\t\t\turl = '" . $this->menuItemLink . "',\n\t\t\t\t\t\twidth = '" . escapeString($this->iframeWidth) . "',\n\t\t\t\t\t\theight = '" . escapeString($this->iframeWidth) . "',\n\t\t\t\t\t\tborderWidth = '" . escapeString($this->borderWidth) . "',\n\t\t\t\t\t\tborderColor = '" . escapeString($this->borderColor) . "',\n\t\t\t\t\t\tborderStyle = '" . escapeString($this->borderStyle) . "'\n\t\t\t\t\t\tWHERE iframeID = " . $this->iframeID; WCF::getDB()->sendQuery($sql); $this->menuItemLink = 'index.php?page=AdminToolsiFrame&iFrameID=' . $this->iframeID; } if ($this->createLangVar) { $menuItemID = WCF::getDB()->getInsertID(); $name = 'wcf.acp.menu.menuItem' . $menuItemID; $value = $this->menuItem; $languages = WCF::getLanguage()->getAvailableLanguages(); foreach ($languages as $language) { $langEdit = new LanguageEditor($language['languageID']); $langEdit->updateItems(array($name => $value)); } } $sql = "SELECT menuItem FROM wcf" . WCF_N . "_acp_menu_item\n \t\t\tWHERE menuItemID=" . $this->menuItemID; $row = WCF::getDB()->getFirstRow($sql); if ($row['menuItem'] != $this->menuItem) { // relink children $sql = "UPDATE wcf" . WCF_N . "_acp_menu_item\n\t\t\t\tSET parentMenuItem='" . escapeString($this->menuItem) . "'\n\t\t\t\tWHERE parentMenuItem='" . $row['menuItem'] . "'"; WCF::getDB()->sendQuery($sql); } //update the item $sql = "UPDATE IGNORE wcf" . WCF_N . "_acp_menu_item SET\n\t\t\t\t menuItem = '" . escapeString($this->menuItem) . "',\n\t\t\t\t menuItemLink = '" . escapeString($this->menuItemLink) . "',\n\t\t\t\t menuItemIcon ='" . escapeString($this->menuItemIcon) . "',\n\t\t\t\t permissions ='" . escapeString($this->permissions) . "',\n\t\t\t\t showOrder = " . $this->showOrder . ",\n\t\t\t\t parentMenuItem = '" . escapeString($this->parentMenuItem) . "'\n\t\t\t\t WHERE menuItemID=" . $this->menuItemID; WCF::getDB()->sendQuery($sql); $this->menuItem = $this->menuItemLink = $this->menuItemIcon = $this->parentMenuItem = $this->iframeHeight = $this->iframeWidth = $this->borderWidth = $this->borderColor = $this->borderStyle = ''; $this->permissions = array(); $this->showOrder = 0; WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.menu-*'); $this->saved(); WCF::getTPL()->assign(array('success' => true)); }
/** * Installs the selected languages. */ protected function installLanguage() { $this->initDB(); foreach (self::$selectedLanguages as $language) { // get language.xml file name $filename = TMP_DIR . TMP_FILE_PREFIX . $language . '.xml'; // check the file if (!file_exists($filename)) { throw new SystemException("unable to find language file '" . $filename . "'", 11002); } // open the file $xml = new XML($filename); // import xml LanguageEditor::importFromXML($xml, 0); } // set default language $language = LanguageEditor::getLanguageByCode(in_array(self::$selectedLanguageCode, self::$selectedLanguages) ? self::$selectedLanguageCode : self::$selectedLanguages[0]); $language->makeDefault(); // assign all languages to package id 0 $sql = "INSERT INTO\twcf" . WCF_N . "_language_to_packages\n\t\t\t\t\t(languageID, packageID)\n\t\t\tSELECT \t\tlanguageID, 0\n\t\t\tFROM\t\twcf" . WCF_N . "_language"; WCF::getDB()->sendQuery($sql); // rebuild language cache WCF::getCache()->clearResource('languages'); // go to next step $this->gotoNextStep('createUser'); }
/** * Creates permissions for this source */ public function createPermissions() { // determine position for next group option $sql = "SELECT\tIFNULL(MAX(showOrder), 0) + 1 AS showOrder\n\t\t\tFROM\twcf" . WCF_N . "_group_option\n\t\t\tWHERE\tcategoryName = 'user.source.dynamic'\n\t\t\tAND\tpackageID = " . PACKAGE_ID; $row = WCF::getDB()->getFirstRow($sql); $showOrder = $row['showOrder']; // create group option $sql = "INSERT INTO\twcf" . WCF_N . "_group_option\n\t\t\t\t\t(packageID, optionName, categoryName, optionType, defaultValue, showOrder, validationPattern, enableOptions, permissions, options, additionalData)\n\t\t\tVALUES\t\t(" . PACKAGE_ID . ",\n\t\t\t\t\t'user.source.dynamic.canUseSource" . $this->sourceID . "',\n\t\t\t\t\t'user.source.dynamic',\n\t\t\t\t\t'boolean',\n\t\t\t\t\t0,\n\t\t\t\t\t" . intval($showOrder) . ",\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t\t'" . serialize(array()) . "')"; WCF::getDB()->sendQuery($sql); $optionID = WCF::getDB()->getInsertID(); // insert new option and default value to each group // get all groupIDs // don't change values of existing options $sql = "SELECT\tgroupID\n\t\t\tFROM\twcf" . WCF_N . "_group"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_group_option_value\n\t\t\t\t\t\t\t(groupID, optionID, optionValue)\n\t\t\t\tVALUES\t\t\t(" . $row['groupID'] . ",\n\t\t\t\t\t\t\t " . $optionID . ",\n\t\t\t\t\t\t\t'0')"; WCF::getDB()->sendQuery($sql); } WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.group-option-*.php'); // get available languages $languageCodes = Language::getLanguageCodes(); // create language variables $sql = "SELECT\tlanguageID, languageItem, languageItemValue\n\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\tWHERE\tlanguageItem IN\n\t\t\t\t(\n\t\t\t\t\t'wcf.acp.group.option.user.source.dynamic.default',\n\t\t\t\t\t'wcf.acp.group.option.user.source.dynamic.default.description'\n\t\t\t\t)\n\t\t\tAND\tpackageID = " . PACKAGE_ID; $result = WCF::getDB()->sendQuery($sql); $languageData = array(); // create language variables for each language while ($row = WCF::getDB()->fetchArray($result)) { $key = 'option.user.source.dynamic.canUseSource' . $this->sourceID; if ($row['languageItem'] == 'wcf.acp.group.option.user.source.dynamic.default.description') { $key .= '.description'; } $value = str_replace('#sourceName#', $this->name, $row['languageItemValue']); $languageCode = $languageCodes[$row['languageID']]; $languageData[$languageCode]['wcf.acp.group'][$key] = $value; } // import language variables foreach ($languageData as $languageCode => $data) { //create XML string $xml = LanguagesXMLPIP::create(array($languageCode => $data), true); // parse xml $xmlObj = new XML(); $xmlObj->loadString($xml); // import language xml LanguageEditor::importFromXML($xmlObj, PACKAGE_ID); } }
/** * @see Form::save() */ public function save() { ACPForm::save(); // read variables $this->page->title = $this->title; $this->page->allowSpidersToIndexThisPage = $this->allowSpidersToIndexThisPage; $this->page->additionalHeadContent = $this->additionalHeadContent; $this->page->isPublic = $this->isPublic; $this->page->isDefaultPage = $this->isDefaultPage; // update $this->page->update(); // handle isDefaultPage checkbox if ($this->isDefaultPage) { $sql = "UPDATE\r\n\t\t\t\t\t\twcf" . WCF_N . "_page\r\n\t\t\t\t\tSET\r\n\t\t\t\t\t\tisDefaultPage = 0\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tpageID NOT IN (" . $this->page->pageID . ")"; WCF::getDB()->sendQuery($sql); } DynamicPageEditor::clearCache($this->page->pageID, $this->page->hostID); if ($this->menuEntry !== null) { // create language variable name $lang = 'wcf.header.menu.host' . $this->page->hostID . '.page' . $this->pageID; // get menu entry title $title = empty($this->menuItemTitle) ? $this->title : $this->menuItemTitle; // update menu entry $this->menuEntry->update($lang, $this->menuEntry->menuItemLink, $this->menuItemIconS, $this->menuItemIconM, $this->menuItemSortOrder, $this->menuItemPosition); // enable or disable entry $this->menuEntry->enable($this->isPublic); // update language require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($lang => $title)); // clear cache PageMenuItemEditor::clearCache(); } if ($this->createMenuItem) { // build language var $lang = 'wcf.header.menu.host' . $this->page->hostID . '.page' . $item->pageID; $title = empty($this->menuItemTitle) ? $this->title : $this->menuItemTitle; // create menu item $menuItem = PageMenuItemEditor::create($lang, 'index.php?page=CMS&pageID=' . $this->pageID, $this->menuItemIconS, $this->menuItemIconM, $this->menuItemSortOrder, $this->menuItemPosition); $menuItemID = $menuItem->menuItemID; // clear cache PageMenuItemEditor::clearCache(); // create language var require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; // save language variable $language = new LanguageEditor(WCF::getLanguage()->getLanguageID()); $language->updateItems(array($lang => $title)); // include host require_once WCF_DIR . 'lib/data/host/Host.class.php'; // remove menu item ID cache Host::removeMenuItemIDCache(); } // show success message WCF::getTPL()->assign('success', true); }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with WOT Game. If not, see <http://www.gnu.org/licenses/>. */ define('INSIDE', true); $ugamela_root_path = '../'; include $ugamela_root_path . 'extension.inc'; include $ugamela_root_path . 'common.' . $phpEx; if (!check_user()) { header("Location: login.php"); die; } require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; require_once WCF_DIR . 'lib/util/XML.class.php'; $std = 'english'; $languages = WCF::getCache()->get('languages'); foreach ($languages as $languageID => $languageArray) { $editor = new LanguageEditor($languageID); if (file_exists('lang/' . $languageArray['languageCode'] . '.xml')) { $xml = new XML('lang/' . $languageArray['languageCode'] . '.xml'); } else { $string = file_get_contents('lang/' . $std . '.xml'); $string = preg_replace('/languagecode="' . $std . '"/i', 'languagecode="' . $std . '"', $string, 1); $xml = new XML(); $xml->loadString($string); } $editor->updateFromXML($xml); }
/** * Clears relevant caches after package installation, update or uninstallation. */ protected function makeClear() { require_once WCF_DIR . 'lib/acp/option/Options.class.php'; require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; // get dependent (standalone) packages $sql = "SELECT\t\tpackage.packageID, packageDir\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = package_dependency.packageID)\n\t\t\tWHERE\t\tpackage_dependency.dependency = " . $this->packageID . "\n\t\t\t\t\tAND package.standalone = 1"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { // delete relevant language files LanguageEditor::deleteLanguageFiles('*', '*', $row['packageID']); if (!empty($row['packageDir'])) { // get real path $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $row['packageDir'])); // reset options.inc.php $filename = $packageDir . Options::FILENAME; if (file_exists($filename)) { @unlink($filename); } // clear application cache WCF::getCache()->clear($packageDir . 'cache', '*.php', true); } } // clear general options file @unlink(WCF_DIR . 'options.inc.php'); // clear general cache WCF::getCache()->clear(WCF_DIR . 'cache', '*.php', true); // delete compiled templates require_once WCF_DIR . 'lib/system/template/ACPTemplate.class.php'; ACPTemplate::deleteCompiledACPTemplates(); Template::deleteCompiledTemplates(); }
/** * @see Form::save() */ public function save() { parent::save(); $menuItemID = 0; // create dynamic page $item = DynamicPageEditor::create($this->title, $this->allowSpidersToIndexThisPage, $this->additionalHeadContent, $menuItemID, $this->isPublic, $this->isDefaultPage, $this->hostID); DynamicPageEditor::clearCache($item->pageID, $this->hostID); // create menu item if ($this->createMenuItem) { require_once WCF_DIR . 'lib/data/page/menu/PageMenuItemEditor.class.php'; // build language var $lang = 'wcf.header.menu.host' . $this->hostID . '.page' . $item->pageID; $title = empty($this->menuItemTitle) ? $this->title : $this->menuItemTitle; // create menu item $menuItem = PageMenuItemEditor::create($lang, 'index.php?page=CMS&pageID=' . $item->pageID, $this->menuItemIconS, $this->menuItemIconM, $this->menuItemSortOrder, $this->menuItemPosition); $menuItemID = $menuItem->menuItemID; // clear cache PageMenuItemEditor::clearCache(); // enable or disable entry $menuItem->enable($this->isPublic); // create language var require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; // save language variable $language = new LanguageEditor($this->host->languageID); $language->updateItems(array($lang => $title)); // include host require_once WCF_DIR . 'lib/data/host/Host.class.php'; // remove menu item ID cache Host::removeMenuItemIDCache(); } // update menu item id $item->menuItemID = $menuItemID; $item->update(); // write to property $this->newPage = $item; // send redirect headers HeaderUtil::redirect('index.php?form=DynamicPageEdit&pageID=' . $item->pageID . '&packageID=' . PACKAGE_ID . '&created=1' . SID_ARG_2ND_NOT_ENCODED); // call event $this->saved(); }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with WOT Game. If not, see <http://www.gnu.org/licenses/>. */ define('INSIDE', true); $ugamela_root_path = '../'; include $ugamela_root_path . 'extension.inc'; include $ugamela_root_path . 'common.' . $phpEx; if (!check_user()) { header("Location: login.php"); die; } require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; require_once WCF_DIR . 'lib/util/XML.class.php'; $std = 'de-informal'; $languageCache = WCF::getCache()->get('languages'); $languages = $languageCache['languages']; foreach ($languages as $languageID => $languageArray) { $editor = new LanguageEditor($languageID); if (file_exists('lang/' . $languageArray['languageCode'] . '.xml')) { $xml = new XML('lang/' . $languageArray['languageCode'] . '.xml'); } else { $string = file_get_contents('lang/' . $std . '.xml'); $string = preg_replace('/languagecode="' . $std . '"/i', 'languagecode="' . $std . '"', $string, 1); $xml = new XML(); $xml->loadString($string); } $editor->updateFromXML($xml, PACKAGE_ID); }
/** * @see Form::save() */ public function save() { parent::save(); // create new language category $languageCategoryID = $this->languageCategoryID; if (!empty($this->newLanguageCategory)) { $languageCategoryID = LanguageEditor::createCategory($this->newLanguageCategory); // clear language cache WCF::getCache()->clearResource('languages'); } // save item values foreach (array_keys($this->languages) as $languageID) { $language = new LanguageEditor($languageID); $language->updateItems(array($this->languageItemName => isset($this->languageItemValues[$languageID]) ? $this->languageItemValues[$languageID] : ''), $languageCategoryID); } // reset values //$this->languageCategoryID = 0; $this->newLanguageCategory = $this->languageItemName = ''; $this->languageItemValues = array(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }
/** * @see Form::validate() */ public function validate() { parent::validate(); // action if (!in_array($this->action, $this->availableActions)) { throw new UserInputException('action'); } // move to if ($this->action == 'move') { try { $board = Board::getBoard($this->moveTo); } catch (IllegalLinkException $e) { throw new UserInputException('moveTo'); } if (!$board->isBoard()) { throw new UserInputException('moveTo'); } } // validate new language if ($this->action == 'changeLanguage') { require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php'; $language = new LanguageEditor($this->newLanguageID); if (!$language->getLanguageID()) { throw new UserInputException('newLanguageID'); } } }