[4897] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2010 Pierrick LE GALL http://piwigo.org | |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 8 | // | it under the terms of the GNU General Public License as published by | |
---|
| 9 | // | the Free Software Foundation | |
---|
| 10 | // | | |
---|
| 11 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 14 | // | General Public License for more details. | |
---|
| 15 | // | | |
---|
| 16 | // | You should have received a copy of the GNU General Public License | |
---|
| 17 | // | along with this program; if not, write to the Free Software | |
---|
| 18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 19 | // | USA. | |
---|
| 20 | // +-----------------------------------------------------------------------+ |
---|
| 21 | |
---|
| 22 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 23 | { |
---|
| 24 | die ("Hacking attempt!"); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 28 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
| 29 | |
---|
| 30 | include_once(UPLOAD_FORM_PATH.'include/functions_upload.inc.php'); |
---|
| 31 | load_language('plugin.lang', UPLOAD_FORM_PATH); |
---|
| 32 | |
---|
| 33 | define( |
---|
| 34 | 'UPLOAD_FORM_BASE_URL', |
---|
| 35 | get_root_url().'admin.php?page=plugin&section=upload_form%2Fbase.php' |
---|
| 36 | ); |
---|
| 37 | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | // | Check Access and exit when user status is not ok | |
---|
| 40 | // +-----------------------------------------------------------------------+ |
---|
| 41 | |
---|
| 42 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 43 | |
---|
| 44 | // +-----------------------------------------------------------------------+ |
---|
| 45 | // | Load configuration | |
---|
| 46 | // +-----------------------------------------------------------------------+ |
---|
| 47 | |
---|
| 48 | // automatic fill of configuration parameters |
---|
| 49 | $upload_form_config = array( |
---|
| 50 | 'websize_resize' => array( |
---|
| 51 | 'default' => true, |
---|
| 52 | 'can_be_null' => false, |
---|
| 53 | ), |
---|
| 54 | |
---|
| 55 | 'websize_maxwidth' => array( |
---|
| 56 | 'default' => 800, |
---|
| 57 | 'min' => 100, |
---|
| 58 | 'max' => 1600, |
---|
| 59 | 'pattern' => '/^\d+$/', |
---|
| 60 | 'can_be_null' => true, |
---|
| 61 | 'error_message' => 'The websize maximum width must be a number between %d and %d', |
---|
| 62 | ), |
---|
| 63 | |
---|
| 64 | 'websize_maxheight' => array( |
---|
| 65 | 'default' => 600, |
---|
| 66 | 'min' => 100, |
---|
| 67 | 'max' => 1200, |
---|
| 68 | 'pattern' => '/^\d+$/', |
---|
| 69 | 'can_be_null' => true, |
---|
| 70 | 'error_message' => 'The websize maximum height must be a number between %d and %d', |
---|
| 71 | ), |
---|
| 72 | |
---|
| 73 | 'websize_quality' => array( |
---|
| 74 | 'default' => 95, |
---|
| 75 | 'min' => 50, |
---|
| 76 | 'max' => 100, |
---|
| 77 | 'pattern' => '/^\d+$/', |
---|
| 78 | 'can_be_null' => false, |
---|
| 79 | 'error_message' => 'The websize image quality must be a number between %d and %d', |
---|
| 80 | ), |
---|
| 81 | |
---|
| 82 | 'thumb_maxwidth' => array( |
---|
| 83 | 'default' => 128, |
---|
| 84 | 'min' => 50, |
---|
| 85 | 'max' => 300, |
---|
| 86 | 'pattern' => '/^\d+$/', |
---|
| 87 | 'can_be_null' => false, |
---|
| 88 | 'error_message' => 'The thumbnail maximum width must be a number between %d and %d', |
---|
| 89 | ), |
---|
| 90 | |
---|
| 91 | 'thumb_maxheight' => array( |
---|
| 92 | 'default' => 96, |
---|
| 93 | 'min' => 50, |
---|
| 94 | 'max' => 300, |
---|
| 95 | 'pattern' => '/^\d+$/', |
---|
| 96 | 'can_be_null' => false, |
---|
| 97 | 'error_message' => 'The thumbnail maximum height must be a number between %d and %d', |
---|
| 98 | ), |
---|
| 99 | |
---|
| 100 | 'thumb_quality' => array( |
---|
| 101 | 'default' => 95, |
---|
| 102 | 'min' => 50, |
---|
| 103 | 'max' => 100, |
---|
| 104 | 'pattern' => '/^\d+$/', |
---|
| 105 | 'can_be_null' => false, |
---|
| 106 | 'error_message' => 'The thumbnail image quality must be a number between %d and %d', |
---|
| 107 | ), |
---|
| 108 | ); |
---|
| 109 | |
---|
| 110 | $inserts = array(); |
---|
| 111 | |
---|
| 112 | foreach ($upload_form_config as $param_shortname => $param) |
---|
| 113 | { |
---|
| 114 | $param_name = 'upload_form_'.$param_shortname; |
---|
| 115 | |
---|
| 116 | if (!isset($conf[$param_name])) |
---|
| 117 | { |
---|
| 118 | $param_value = boolean_to_string($param['default']); |
---|
| 119 | |
---|
| 120 | array_push( |
---|
| 121 | $inserts, |
---|
| 122 | array( |
---|
| 123 | 'param' => $param_name, |
---|
| 124 | 'value' => $param_value, |
---|
| 125 | ) |
---|
| 126 | ); |
---|
| 127 | $conf[$param_name] = $param_value; |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | if (count($inserts) > 0) |
---|
| 132 | { |
---|
| 133 | mass_inserts( |
---|
| 134 | CONFIG_TABLE, |
---|
| 135 | array_keys($inserts[0]), |
---|
| 136 | $inserts |
---|
| 137 | ); |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | // +-----------------------------------------------------------------------+ |
---|
| 141 | // | Tabs | |
---|
| 142 | // +-----------------------------------------------------------------------+ |
---|
| 143 | |
---|
| 144 | $tabs = array( |
---|
| 145 | array( |
---|
| 146 | 'code' => 'upload', |
---|
| 147 | 'label' => 'Upload Photos', |
---|
| 148 | ), |
---|
| 149 | array( |
---|
| 150 | 'code' => 'settings', |
---|
| 151 | 'label' => 'Settings', |
---|
| 152 | ) |
---|
| 153 | ); |
---|
| 154 | |
---|
| 155 | $tab_codes = array_map( |
---|
| 156 | create_function('$a', 'return $a["code"];'), |
---|
| 157 | $tabs |
---|
| 158 | ); |
---|
| 159 | |
---|
| 160 | if (isset($_GET['tab']) and in_array($_GET['tab'], $tab_codes)) |
---|
| 161 | { |
---|
| 162 | $page['tab'] = $_GET['tab']; |
---|
| 163 | } |
---|
| 164 | else |
---|
| 165 | { |
---|
| 166 | $page['tab'] = $tabs[0]['code']; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | $tabsheet = new tabsheet(); |
---|
| 170 | foreach ($tabs as $tab) |
---|
| 171 | { |
---|
| 172 | $tabsheet->add( |
---|
| 173 | $tab['code'], |
---|
| 174 | l10n($tab['label']), |
---|
| 175 | UPLOAD_FORM_BASE_URL.'&tab='.$tab['code'] |
---|
| 176 | ); |
---|
| 177 | } |
---|
| 178 | $tabsheet->select($page['tab']); |
---|
| 179 | $tabsheet->assign(); |
---|
| 180 | |
---|
| 181 | // +-----------------------------------------------------------------------+ |
---|
| 182 | // | template init | |
---|
| 183 | // +-----------------------------------------------------------------------+ |
---|
| 184 | |
---|
| 185 | $template->set_filenames( |
---|
| 186 | array( |
---|
| 187 | 'plugin_admin_content' => dirname(__FILE__).'/'.$page['tab'].'.tpl' |
---|
| 188 | ) |
---|
| 189 | ); |
---|
| 190 | |
---|
| 191 | $template->append( |
---|
| 192 | 'head_elements', |
---|
| 193 | '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n" |
---|
| 194 | ); |
---|
| 195 | |
---|
| 196 | // +-----------------------------------------------------------------------+ |
---|
| 197 | // | Load the tab | |
---|
| 198 | // +-----------------------------------------------------------------------+ |
---|
| 199 | |
---|
| 200 | include(UPLOAD_FORM_PATH.$page['tab'].'.php'); |
---|
| 201 | ?> |
---|