<commit_before><?php

	Class extension_language_redirect extends Extension{

		public function about(){
			return array(
				'name' => 'Language Redirect',
				'version' => '1.0',
				'release-date' => '2011-01-31',
				'author' => array(
					'name' => '<NAME>',
					'website' => 'http://klaftertief.de',
					'email' => '<EMAIL>'
					)
				);
		}

		public function getSubscribedDelegates(){
			return array(
						array(
							'page' => '/system/preferences/',
							'delegate' => 'AddCustomPreferenceFieldsets',
							'callback' => 'appendPreferences'
						),

						array(
							'page' => '/system/preferences/',
							'delegate' => 'Save',
							'callback' => '__SavePreferences'
						),
			);
		}

		public function appendPreferences($context){
			$group = new XMLElement('fieldset');
			$group->setAttribute('class', 'settings');
			$group->appendChild(new XMLElement('legend', __('Language Redirect')));

			$label = Widget::Label(__('Language codes'));
			$label->appendChild(Widget::Input('settings[language_redirect][language_codes]', General::Sanitize(Symphony::Configuration()->get('language_codes', 'language_redirect'))));

			$group->appendChild($label);

			$group->appendChild(new XMLElement('p', __('Comma separated list of supported language codes. First language ist the default language. Leave empty to disable <code>.htaccess</code>-rules.'), array('class' => 'help')));

			$context['wrapper']->appendChild($group);
		}

		public function __SavePreferences($context){
			$languageCodes = $_POST['settings']['language_redirect']['language_codes'];

			return self::__updateRewriteRules('edit', $languageCodes);
		}

		public function install(){
			return self::__updateRewriteRules('create');
		}

		public function enable(){
			$languageCodes = Symphony::Configuration()->get('language_codes', 'language_redirect');

			return self::__updateRewriteRules('edit', $languageCodes);
		}

		public function disable(){
			return self::__updateRewriteRules('edit');
		}

		public function uninstall(){
			Symphony::Configuration()->remove('language_redirect');
			Administration::instance()->saveConfig();

			return self::__updateRewriteRules('remove');
		}

		private static function __updateRewriteRules($mode, $languageCodes = NULL){
			$htaccess = @file_get_contents(DOCROOT . '/.htaccess');<commit_msg>added update logic<commit_after><?php

	Class extension_language_redirect extends Extension{

		public function about(){
			return array(
				'name' => 'Language Redirect',
				'version' => '1.0',
				'release-date' => '2011-01-31',
				'author' => array(
					'name' => '<NAME>',
					'website' => 'http://klaftertief.de',
					'email' => '<EMAIL>'
					)
				);
		}

		public function getSubscribedDelegates(){
			return array(
						array(
							'page' => '/system/preferences/',
							'delegate' => 'AddCustomPreferenceFieldsets',
							'callback' => 'appendPreferences'
						),

						array(
							'page' => '/system/preferences/',
							'delegate' => 'Save',
							'callback' => '__SavePreferences'
						),
			);
		}

		public function appendPreferences($context){
			$group = new XMLElement('fieldset');
			$group->setAttribute('class', 'settings');
			$group->appendChild(new XMLElement('legend', __('Language Redirect')));

			$label = Widget::Label(__('Language codes'));
			$label->appendChild(Widget::Input('settings[language_redirect][language_codes]', General::Sanitize(Symphony::Configuration()->get('language_codes', 'language_redirect'))));

			$group->appendChild($label);

			$group->appendChild(new XMLElement('p', __('Comma separated list of supported language codes. First language ist the default language. Leave empty to disable <code>.htaccess</code>-rules.'), array('class' => 'help')));

			$context['wrapper']->appendChild($group);
		}

		public function __SavePreferences($context){
			$languageCodes = $_POST['settings']['language_redirect']['language_codes'];

			return self::__updateRewriteRules('edit', $languageCodes);
		}

		public function install(){
			return self::__updateRewriteRules('create');
		}

		public function enable(){
			$languageCodes = Symphony::Configuration()->get('language_codes', 'language_redirect');

			return self::__updateRewriteRules('edit', $languageCodes);
		}

		public function update($previousVersion){
			if (version_compare($previousVersion, '1.0', '<')) {
				$languageCodes = Symphony::Configuration()->get('languages', 'language_redirect');

				Symphony::Configuration()->remove('languages', 'language_redirect');
				Symphony::Configuration()->set('language_codes', $languageCodes, 'language_redirect');
				Administration::instance()->saveConfig();
			}
		}

		public function disable(){
			return self::__updateRewriteRules('edit');
		}

		public function uninstall(){
			Symphony::Configuration()->remove('language_redirect');
			Administration::instance()->saveConfig();

			return self::__updateRewriteRules('remove');
		}

		private static function __updateRewriteRules($mode, $languageCodes = NULL){
			$htaccess = @file_get_contents(DOCROOT . '/.htaccess');
{'fraction_non_alphanumeric': 0.1705014749262537, 'fraction_numerical': 0.004326450344149459, 'mean_word_length': 4.7274774774774775, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5790537', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1421, 'n_words': 274}