<commit_before><?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed');}
	$edit = $_GET['edit'];
	$enginename = false;
	$enginepath = false;
	// Handle adding/updating an engine
	if ($_REQUEST['action'] == 'delete' && isset($_REQUEST['engineid'])){
		ttsengines_delete_engine($_REQUEST['engineid']);
	}
	else if ($_POST['edit']){
		ttsengines_update_engine($_POST['engineid'], $_POST['enginename'], $_POST['enginepath']);
		redirect_standard();
	}
	else if ($_POST['addengine']){
		ttsengines_add_engine($_POST['enginename'], $_POST['enginepath']);
		redirect_standard();
	}

	$engines = ttsengines_get_all_engines();
	$info = show_help(_('On this page you can manage text to speech engines on your system. When you add an engine you give it a name, and the full path to the engine on your system. After doing this the engine will be available on the text to speech page.'));
	$heading = _('Text to Speech Engines');
	$delurl = '';
	$vars = array();
	if(isset($_REQUEST['view']) && $_REQUEST['view'] == 'form'){
		if(isset($edit)){
			$vars['data'] = \FreePBX::Ttsengines()->getEngine($edit);
			$data = $vars['data'];
			$vars['enginename'] = isset($data['name'])?$data['name']:'';
			$vars['enginepath'] = isset($data['path'])?$data['path']:'';
			$vars['delurl'] = '?display=ttsengines&delete=true&engineid='.$edit.'&edit='.$edit;
			$vars['edit'] = $edit;
		}
		$vars['all_engines'] = $engines;
		
		$content = load_view(__DIR__.'/views/form.php',$vars);<commit_msg>Fixing FREEPBX-19510 Delete TTS engine from main list and from edit option<commit_after><?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed');}
	$edit = $_GET['edit'];
	$enginename = false;
	$enginepath = false;
	// Handle adding/updating an engine
	if (((isset($_REQUEST['delete']) && $_REQUEST['delete']) || ($_REQUEST['action'] == 'delete'))
		&& isset($_REQUEST['engineid'])){
		ttsengines_delete_engine($_REQUEST['engineid']);
	}
	else if ($_POST['edit']){
		ttsengines_update_engine($_POST['engineid'], $_POST['enginename'], $_POST['enginepath']);
		redirect_standard();
	}
	else if ($_POST['addengine']){
		ttsengines_add_engine($_POST['enginename'], $_POST['enginepath']);
		redirect_standard();
	}

	$engines = ttsengines_get_all_engines();
	$info = show_help(_('On this page you can manage text to speech engines on your system. When you add an engine you give it a name, and the full path to the engine on your system. After doing this the engine will be available on the text to speech page.'));
	$heading = _('Text to Speech Engines');
	$delurl = '';
	$vars = array();
	if(isset($_REQUEST['view']) && $_REQUEST['view'] == 'form'){
		if(isset($edit)){
			$vars['data'] = \FreePBX::Ttsengines()->getEngine($edit);
			$data = $vars['data'];
			$vars['enginename'] = isset($data['name'])?$data['name']:'';
			$vars['enginepath'] = isset($data['path'])?$data['path']:'';
			$vars['delurl'] = '?display=ttsengines&delete=true&engineid='.$edit.'&edit='.$edit;
			$vars['edit'] = $edit;
		}
		$vars['all_engines'] = $engines;
		
		$content = load_view(__DIR__.'/views/form.php',$vars);
{'fraction_non_alphanumeric': 0.20739549839228297, 'fraction_numerical': 0.001607717041800643, 'mean_word_length': 6.054421768707483, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '875773', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1054, 'n_words': 240}