[5962] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 4 | |
---|
| 5 | global $template; |
---|
| 6 | |
---|
| 7 | load_language('plugin.lang', SQUARE_THUMB_PATH); |
---|
| 8 | |
---|
| 9 | // Insert param in DB if not exists |
---|
| 10 | if (!isset($conf['upload_form_thumb_square'])) |
---|
| 11 | { |
---|
| 12 | mass_inserts( |
---|
| 13 | CONFIG_TABLE, |
---|
| 14 | array('param', 'value'), |
---|
| 15 | array( |
---|
| 16 | array( |
---|
| 17 | 'param' => 'upload_form_thumb_square', |
---|
| 18 | 'value' => 'false' |
---|
| 19 | ) |
---|
| 20 | ) |
---|
| 21 | ); |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | // Update param on submit |
---|
| 25 | if (isset($_POST['submit'])) |
---|
| 26 | { |
---|
| 27 | $conf['upload_form_thumb_square'] = isset($_POST['square']); |
---|
| 28 | |
---|
| 29 | mass_updates( |
---|
| 30 | CONFIG_TABLE, |
---|
| 31 | array( |
---|
| 32 | 'primary' => array('param'), |
---|
| 33 | 'update' => array('value') |
---|
| 34 | ), |
---|
| 35 | array( |
---|
| 36 | array( |
---|
| 37 | 'param' => 'upload_form_thumb_square', |
---|
| 38 | 'value' => $conf['upload_form_thumb_square'] ? 'true':'false' |
---|
| 39 | ) |
---|
| 40 | ) |
---|
| 41 | ); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | // Template init |
---|
[9756] | 45 | $template->assign('SQUARE', @$conf['upload_form_thumb_square']); |
---|
[5962] | 46 | |
---|
| 47 | // Add prefilter |
---|
| 48 | $template->set_prefilter('photos_add', 'add_square_option'); |
---|
| 49 | |
---|
| 50 | function add_square_option($content, $smarty) |
---|
| 51 | { |
---|
| 52 | $search = '<legend>{\'Thumbnail\'|@translate}</legend> |
---|
| 53 | |
---|
| 54 | <table>'; |
---|
| 55 | |
---|
| 56 | $replacement = ' |
---|
| 57 | {html_head} |
---|
| 58 | {literal} |
---|
| 59 | <script type="text/javascript"> |
---|
| 60 | jQuery().ready(function(){ |
---|
| 61 | jQuery("input[name^=\'thumb_max\']").keyup(function(){ |
---|
| 62 | if(jQuery("#square").attr("checked")){ |
---|
| 63 | if (this.name == "thumb_maxwidth"){ |
---|
| 64 | jQuery("input[name=\'thumb_maxheight\']").attr("value", this.value); |
---|
| 65 | }else{ |
---|
| 66 | jQuery("input[name=\'thumb_maxwidth\']").attr("value", this.value); |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | }); |
---|
| 70 | jQuery("#square").click(function(){ |
---|
| 71 | if (this.checked) |
---|
| 72 | jQuery("input[name^=\'thumb_maxheight\']").attr("value", jQuery("input[name^=\'thumb_maxwidth\']").attr("value")); |
---|
| 73 | }); |
---|
| 74 | }); |
---|
| 75 | </script> |
---|
| 76 | {/literal} |
---|
| 77 | {/html_head} |
---|
| 78 | |
---|
| 79 | <legend>{\'Thumbnail\'|@translate}</legend> |
---|
| 80 | |
---|
| 81 | <table> |
---|
| 82 | <tr> |
---|
[9757] | 83 | <th><label for="square">{\'Square Thumbnails\'|@translate}</label></th> |
---|
[5962] | 84 | <td><input type="checkbox" name="square" id="square" {if $SQUARE}checked="checked"{/if}></td> |
---|
| 85 | </tr>'; |
---|
| 86 | |
---|
| 87 | return str_replace($search, $replacement, $content); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | ?> |
---|