diff options
author | Cash Costello <cash.costello@gmail.com> | 2009-07-12 01:38:17 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2009-07-12 01:38:17 +0000 |
commit | 1a7960b6f99cde142c27f84225611fbae3b8617d (patch) | |
tree | 9ff3e6c52f8849b4d211e83d86bd8845cbc0c474 /lib/watermark.php | |
parent | 6f542ab26ea4bc65ae33a691802d233d8dafa592 (diff) | |
download | elgg-1a7960b6f99cde142c27f84225611fbae3b8617d.tar.gz elgg-1a7960b6f99cde142c27f84225611fbae3b8617d.tar.bz2 |
reorged the watermark code so easier to add gd and php imagick
Diffstat (limited to 'lib/watermark.php')
-rw-r--r-- | lib/watermark.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/watermark.php b/lib/watermark.php index b60bae88e..91e2a38f3 100644 --- a/lib/watermark.php +++ b/lib/watermark.php @@ -1,5 +1,27 @@ <?php +function tp_process_watermark_text($text, $owner) { + global $CONFIG; + + $text = str_replace("%username%", $owner->username, $text); + $text = str_replace("%sitename%", $CONFIG->sitename, $text); + + return $text; +} + +function tp_get_watermark_filename($text, $owner) { + global $CONFIG; + + $base = strtolower($text); + $base = preg_replace("/[^\w-]+/", "-", $base); + $base = trim($base, '-'); + + $filename = tp_get_img_dir(); + $filename .= strtolower($owner->username . "_" . $base . "_stamp"); + + return $filename; +} + function tp_gd_watermark($filename) { } @@ -7,7 +29,6 @@ function tp_imagick_watermark($filename) { } function tp_imagick_cmdline_watermark($filename) { - global $CONFIG; $watermark_text = get_plugin_setting('watermark_text', 'tidypics'); if (!$watermark_text) @@ -25,18 +46,12 @@ function tp_imagick_cmdline_watermark($filename) { $owner = get_loggedin_user(); + $watermark_text = tp_process_watermark_text($watermark_text, $owner); - $watermark_text = str_replace("%username%", $owner->username, $watermark_text); - $watermark_text = str_replace("%sitename%", $CONFIG->sitename, $watermark_text); - $ext = ".png"; - $watermark_filename = strtolower($watermark_text); - $watermark_filename = preg_replace("/[^\w-]+/", "-", $watermark_filename); - $watermark_filename = trim($watermark_filename, '-'); + $user_stamp_base = tp_get_watermark_filename($watermark_text, $owner); - $user_stamp_base = tp_get_img_dir(); - $user_stamp_base .= strtolower($owner->username . "_" . $watermark_filename . "_stamp"); if ( !file_exists( $user_stamp_base . $ext )) { //create the watermark if it doesn't exist $commands = array(); |