cmds['EditText'] = '';
$this->cmds['SaveText'] = 'ReturnHeader';
$this->cmds['AddonTextForm'] = '';
$this->cmds['SaveAddonText'] = 'ReturnHeader';
$cmd = \gp\tool::GetCommand();
$this->RunCommands($cmd);
}
public function AddonTextForm(){
global $langmessage,$config;
$addon = \gp\tool\Editing::CleanArg($_REQUEST['addon']);
$texts = $this->GetAddonTexts($addon);
//not set up correctly
if( $texts === false ){
$this->EditText();
return;
}
echo '
';
echo '';
echo '
';
}
public function AddonTextFields($array){
global $langmessage,$config;
echo '';
}
public function EditText(){
global $config, $langmessage;
if( !isset($_GET['key']) ){
message($langmessage['OOPS'].' (0)');
return;
}
$default = $value = $key = $_GET['key'];
if( isset($langmessage[$key]) ){
$default = $value = $langmessage[$key];
}else{
$default = $value = htmlspecialchars($key);
}
if( isset($config['customlang'][$key]) ){
$value = $config['customlang'][$key];
}else{
$value = htmlspecialchars($key);
}
echo '';
}
public function SaveText(){
global $config, $langmessage;
if( !isset($_POST['key']) ){
message($langmessage['OOPS'].' (0)');
return;
}
if( !isset($_POST['value']) ){
message($langmessage['OOPS'].' (1)');
return;
}
$default = $key = $_POST['key'];
if( isset($langmessage[$key]) ){
$default = $langmessage[$key];
}
$config['customlang'][$key] = $value = htmlspecialchars($_POST['value']);
if( ($value === $default) || (htmlspecialchars($default) == $value) ){
unset($config['customlang'][$key]);
}
$this->SaveConfig();
}
public function SaveAddonText(){
global $langmessage,$config;
$addon = \gp\tool\Editing::CleanArg($_REQUEST['addon']);
$texts = $this->GetAddonTexts($addon);
//not set up correctly
if( $texts === false ){
message($langmessage['OOPS'].' (0)');
return;
}
foreach($texts as $text){
if( !isset($_POST['values'][$text]) ){
continue;
}
$default = $text;
if( isset($langmessage[$text]) ){
$default = $langmessage[$text];
}
$value = htmlspecialchars($_POST['values'][$text]);
if( ($value === $default) || (htmlspecialchars($default) == $value) ){
unset($config['customlang'][$text]);
}else{
$config['customlang'][$text] = $value;
}
}
if( $this->SaveConfig() ){
$this->UpdateAddon($addon);
}
}
public function UpdateAddon($addon){
if( !function_exists('OnTextChange') ){
return;
}
\gp\tool\Plugins::SetDataFolder($addon);
OnTextChange();
\gp\tool\Plugins::ClearDataFolder();
}
public function GetAddonTexts($addon){
global $langmessage,$config;
$addon_config = \gp\tool\Plugins::GetAddonConfig($addon);
$addonDir = $addon_config['code_folder_full'];
if( !is_dir($addonDir) ){
return false;
}
//not set up correctly
if( !isset($config['addons'][$addon]['editable_text']) ){
return false;
}
$file = $addonDir.'/'.$config['addons'][$addon]['editable_text'];
if( !file_exists($file) ){
return false;
}
$texts = array();
include($file);
if( empty($texts) ){
return false;
}
return $texts;
}
}