mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-20 08:44:34 +00:00
Implement watermark profile CRUD backend
This commit is contained in:
@@ -18,14 +18,10 @@ function bratonien_tools_create_default_watermark_profiles()
|
|||||||
|
|
||||||
if ((int)$count[0] === 0)
|
if ((int)$count[0] === 0)
|
||||||
{
|
{
|
||||||
mass_inserts(
|
mass_inserts($table, array('name','watermark_file','xpos','ypos','opacity','min_width','min_height','created'), array(
|
||||||
$table,
|
array('name'=>'Oeffentlich','watermark_file'=>'','xpos'=>90,'ypos'=>90,'opacity'=>35,'min_width'=>10,'min_height'=>10,'created'=>date('Y-m-d H:i:s')),
|
||||||
array('name', 'watermark_file', 'xpos', 'ypos', 'opacity', 'min_width', 'min_height', 'created'),
|
array('name'=>'Kein Wasserzeichen','watermark_file'=>'','xpos'=>90,'ypos'=>90,'opacity'=>0,'min_width'=>0,'min_height'=>0,'created'=>date('Y-m-d H:i:s')),
|
||||||
array(
|
));
|
||||||
array('name'=>'Oeffentlich', 'watermark_file'=>'', 'xpos'=>90, 'ypos'=>90, 'opacity'=>35, 'min_width'=>10, 'min_height'=>10, 'created'=>date('Y-m-d H:i:s')),
|
|
||||||
array('name'=>'Kein Wasserzeichen', 'watermark_file'=>'', 'xpos'=>90, 'ypos'=>90, 'opacity'=>0, 'min_width'=>0, 'min_height'=>0, 'created'=>date('Y-m-d H:i:s')),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,5 +33,49 @@ function bratonien_tools_get_watermark_profiles()
|
|||||||
|
|
||||||
function bratonien_tools_save_watermark_profile()
|
function bratonien_tools_save_watermark_profile()
|
||||||
{
|
{
|
||||||
throw new RuntimeException('Profilverwaltung ist vorbereitet, die Bearbeitungsoberflaeche folgt im naechsten Schritt.');
|
$table = bratonien_tools_table('watermark_profiles');
|
||||||
|
$id = (int)($_POST['profile_id'] ?? 0);
|
||||||
|
$data = array(
|
||||||
|
'name' => trim((string)($_POST['profile_name'] ?? '')),
|
||||||
|
'watermark_file' => (string)($_POST['profile_file'] ?? ''),
|
||||||
|
'xpos' => (int)($_POST['profile_xpos'] ?? 90),
|
||||||
|
'ypos' => (int)($_POST['profile_ypos'] ?? 90),
|
||||||
|
'opacity' => (int)($_POST['profile_opacity'] ?? 35),
|
||||||
|
'min_width' => (int)($_POST['profile_min_width'] ?? 10),
|
||||||
|
'min_height' => (int)($_POST['profile_min_height'] ?? 10),
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($data['name'] === '')
|
||||||
|
{
|
||||||
|
throw new RuntimeException('Profilname darf nicht leer sein.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
$updates = array();
|
||||||
|
foreach ($data as $key=>$value)
|
||||||
|
{
|
||||||
|
$updates[] = $key.' = \''.pwg_db_real_escape_string($value).'\'';
|
||||||
|
}
|
||||||
|
pwg_query('UPDATE '.$table.' SET '.implode(',', $updates).' WHERE id='.$id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['created'] = date('Y-m-d H:i:s');
|
||||||
|
mass_inserts($table, array_keys($data), array($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('message'=>'Wasserzeichenprofil gespeichert.');
|
||||||
|
}
|
||||||
|
|
||||||
|
function bratonien_tools_delete_watermark_profile()
|
||||||
|
{
|
||||||
|
$id = (int)($_POST['profile_id'] ?? 0);
|
||||||
|
if ($id <= 0)
|
||||||
|
{
|
||||||
|
throw new RuntimeException('Ungueltiges Profil.');
|
||||||
|
}
|
||||||
|
|
||||||
|
pwg_query('DELETE FROM '.bratonien_tools_table('watermark_profiles').' WHERE id='.$id);
|
||||||
|
return array('message'=>'Wasserzeichenprofil geloescht.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user