[3396] | 1 | <?php |
---|
| 2 | /* ----------------------------------------------------------------------------- |
---|
| 3 | Plugin : LMT |
---|
| 4 | Author : Grum |
---|
| 5 | email : grum@piwigo.org |
---|
[4396] | 6 | website : http://photos.grum.fr |
---|
[3396] | 7 | |
---|
| 8 | << May the Little SpaceFrog be with you ! >> |
---|
| 9 | ------------------------------------------------------------------------------ |
---|
| 10 | See main.inc.php for release information |
---|
| 11 | |
---|
[4396] | 12 | LMT_AIP : classe to manage plugin admin pages |
---|
[3396] | 13 | |
---|
| 14 | --------------------------------------------------------------------------- */ |
---|
| 15 | |
---|
| 16 | include_once('lmt_root.class.inc.php'); |
---|
[5548] | 17 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
[7560] | 18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php'); |
---|
[5548] | 19 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php'); |
---|
[10974] | 20 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php'); |
---|
[3396] | 21 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
| 22 | |
---|
| 23 | class LMT_AIP extends LMT_root |
---|
| 24 | { |
---|
| 25 | protected $tabsheet; |
---|
| 26 | |
---|
[5548] | 27 | public function __construct($prefixeTable, $filelocation) |
---|
[3396] | 28 | { |
---|
| 29 | parent::__construct($prefixeTable, $filelocation); |
---|
[5548] | 30 | $this->loadConfig(); |
---|
| 31 | $this->initEvents(); |
---|
[3396] | 32 | |
---|
| 33 | $this->tabsheet = new tabsheet(); |
---|
| 34 | $this->tabsheet->add('list', |
---|
| 35 | l10n('lmt_list'), |
---|
[15341] | 36 | $this->getAdminLink()."-list"); |
---|
[3396] | 37 | $this->tabsheet->add('manage', |
---|
| 38 | l10n('lmt_manage'), |
---|
[15341] | 39 | $this->getAdminLink()."-manage"); |
---|
[3396] | 40 | $this->tabsheet->add('manageaut', |
---|
| 41 | l10n('lmt_manageaut'), |
---|
[15341] | 42 | $this->getAdminLink()."-manageaut"); |
---|
[7560] | 43 | $this->tabsheet->add('search', |
---|
| 44 | l10n('lmt_search'), |
---|
[15341] | 45 | $this->getAdminLink()."-search"); |
---|
[3396] | 46 | $this->tabsheet->add('config', |
---|
| 47 | l10n('lmt_config'), |
---|
[15341] | 48 | $this->getAdminLink()."-config"); |
---|
[3396] | 49 | $this->tabsheet->add('help', |
---|
| 50 | l10n('lmt_help'), |
---|
[15341] | 51 | $this->getAdminLink()."-help"); |
---|
[3396] | 52 | } |
---|
| 53 | |
---|
[5548] | 54 | public function __destruct() |
---|
| 55 | { |
---|
| 56 | unset($this->tabsheet); |
---|
| 57 | parent::__destruct(); |
---|
| 58 | } |
---|
| 59 | |
---|
[3396] | 60 | /* |
---|
| 61 | initialize events call for the plugin |
---|
| 62 | */ |
---|
[5548] | 63 | public function initEvents() |
---|
[3396] | 64 | { |
---|
[5548] | 65 | parent::initEvents(); |
---|
[7560] | 66 | |
---|
[15341] | 67 | if(isset($_GET['tab']) and $_GET['tab']=='search') |
---|
[7560] | 68 | { |
---|
| 69 | // load request builder JS only on the search page |
---|
| 70 | GPCRequestBuilder::loadJSandCSS(); |
---|
| 71 | } |
---|
| 72 | |
---|
[5548] | 73 | add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS')); |
---|
| 74 | add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS')); |
---|
[7560] | 75 | |
---|
| 76 | GPCCss::applyGpcCss(); |
---|
[3396] | 77 | } |
---|
| 78 | |
---|
| 79 | /* |
---|
| 80 | display administration page |
---|
| 81 | */ |
---|
| 82 | public function manage() |
---|
| 83 | { |
---|
| 84 | global $template; |
---|
| 85 | |
---|
| 86 | $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/lmt_admin.tpl"); |
---|
| 87 | |
---|
[15341] | 88 | if(!isset($_GET['tab'])) $_GET['tab']='list'; |
---|
[3396] | 89 | |
---|
[15341] | 90 | switch($_GET['tab']) |
---|
[3396] | 91 | { |
---|
| 92 | case 'list': |
---|
| 93 | $this->display_list_page(); |
---|
| 94 | break; |
---|
| 95 | case 'manage': |
---|
| 96 | $this->display_manage_page(); |
---|
| 97 | break; |
---|
| 98 | case 'manageaut': |
---|
| 99 | $this->display_manageaut_page(); |
---|
| 100 | break; |
---|
| 101 | case 'managedoc': |
---|
| 102 | $this->display_managedoc_page(); |
---|
| 103 | break; |
---|
[7560] | 104 | case 'search': |
---|
| 105 | $this->displaySearch(); |
---|
| 106 | break; |
---|
[3396] | 107 | case 'help': |
---|
| 108 | $this->display_help_page(); |
---|
| 109 | break; |
---|
| 110 | case 'config': |
---|
| 111 | $this->display_config_page(); |
---|
| 112 | break; |
---|
| 113 | } |
---|
| 114 | |
---|
[15341] | 115 | $this->tabsheet->select($_GET['tab']); |
---|
[3396] | 116 | $this->tabsheet->assign(); |
---|
| 117 | $selected_tab=$this->tabsheet->get_selected(); |
---|
| 118 | $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); |
---|
| 119 | |
---|
[5548] | 120 | $template_plugin["LMT_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('lmt_release').LMT_VERSION; |
---|
[15341] | 121 | $template_plugin["LMT_PAGE"] = $_GET['tab']; |
---|
[3396] | 122 | $template_plugin["LMT_TITLE"] = ""; |
---|
| 123 | |
---|
| 124 | $template->assign('plugin', $template_plugin); |
---|
| 125 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | /* |
---|
| 130 | manage display of config page & save config |
---|
| 131 | */ |
---|
| 132 | protected function display_config_page() |
---|
| 133 | { |
---|
| 134 | $languages=get_languages(); |
---|
[15341] | 135 | |
---|
| 136 | GPCCore::addHeaderJS('lmt.config', './plugins/lmt/js/lmtConfig.js', array('jquery')); |
---|
| 137 | GPCCore::addUI('inputNum,simpleTip'); |
---|
[3396] | 138 | if(!$this->adviser_abort()) |
---|
| 139 | { |
---|
| 140 | |
---|
| 141 | if(isset($_POST['submit_save_config'])) |
---|
| 142 | { |
---|
[5548] | 143 | foreach($this->config as $key => $val) |
---|
[3396] | 144 | { |
---|
| 145 | if(is_array($val)) |
---|
| 146 | { |
---|
| 147 | foreach($languages as $key2 => $val2) |
---|
| 148 | { |
---|
| 149 | if(isset($_REQUEST[str2url('f_'.$key.'_'.$key2)])) |
---|
| 150 | { |
---|
[5548] | 151 | $this->config[$key][$key2] = htmlspecialchars(stripslashes($_REQUEST[str2url('f_'.$key.'_'.$key2)]), ENT_QUOTES); |
---|
[3396] | 152 | } |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | else |
---|
| 156 | { |
---|
| 157 | if(isset($_REQUEST['f_'.$key])) |
---|
| 158 | { |
---|
[5548] | 159 | $this->config[$key] = $_REQUEST['f_'.$key]; |
---|
[3396] | 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | } |
---|
[5548] | 164 | $this->displayResult(l10n('lmt_save_config'), $this->saveConfig()); |
---|
[3396] | 165 | } |
---|
| 166 | } |
---|
| 167 | $this->display_config(); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | /* |
---|
[4396] | 172 | |
---|
[3396] | 173 | */ |
---|
| 174 | protected function display_help_page() |
---|
| 175 | { |
---|
| 176 | global $template; |
---|
| 177 | |
---|
| 178 | $template->set_filename('body_page', |
---|
[5548] | 179 | dirname($this->getFileLocation()).'/admin/plugin_admin_help.tpl'); |
---|
[3396] | 180 | |
---|
| 181 | $template->assign('imgdir', LMT_PATH."img/"); |
---|
| 182 | |
---|
| 183 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | /* |
---|
| 187 | */ |
---|
| 188 | protected function display_list_page() |
---|
| 189 | { |
---|
| 190 | global $template, $conf, $user; |
---|
| 191 | |
---|
| 192 | $template->set_filename('body_page', |
---|
[5548] | 193 | dirname($this->getFileLocation()).'/admin/plugin_admin_list.tpl'); |
---|
[3396] | 194 | |
---|
| 195 | if(!isset($_REQUEST['filter']) || |
---|
| 196 | !($_REQUEST['filter']=="BY" || |
---|
| 197 | $_REQUEST['filter']=="BY-SA" || |
---|
| 198 | $_REQUEST['filter']=="BY-ND" || |
---|
| 199 | $_REQUEST['filter']=="BY-NC-ND" || |
---|
| 200 | $_REQUEST['filter']=="BY-NC-SA" || |
---|
| 201 | $_REQUEST['filter']=="BY-NC" || |
---|
| 202 | $_REQUEST['filter']=="CRIGHT" || |
---|
[15341] | 203 | $_REQUEST['filter']=="CLEFT" || |
---|
[11342] | 204 | $_REQUEST['filter']=="CC0" || |
---|
| 205 | $_REQUEST['filter']=="PD" |
---|
[3396] | 206 | )) |
---|
| 207 | { |
---|
| 208 | $_REQUEST['filter']=''; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | $datas=array( |
---|
[7560] | 212 | "LMT_AJAX_URL_LIST" => $this->getAdminLink('ajax') |
---|
[3396] | 213 | ); |
---|
| 214 | |
---|
| 215 | $filter_list_selected = ''; |
---|
[7560] | 216 | $filter_list_values = array_slice(LMT_root::$licences,0,count(LMT_root::$licences)-1); |
---|
[3396] | 217 | $filter_list_labels = array(); |
---|
| 218 | foreach($filter_list_values as $key=>$val) |
---|
| 219 | { |
---|
| 220 | $filter_list_labels[] = "[".l10n("lmt_lbl_cc_s-".strtolower($val))."] ".l10n("lmt_lbl_cc-".strtolower($val)); |
---|
[4396] | 221 | if($val==$_REQUEST['filter']) |
---|
[3396] | 222 | { |
---|
| 223 | $filter_list_selected = $val; |
---|
| 224 | } |
---|
| 225 | } |
---|
[4396] | 226 | |
---|
[3396] | 227 | $filter_list_values = array_merge(array(''), $filter_list_values); |
---|
| 228 | $filter_list_labels = array_merge(array(l10n('lmt_nofilter')), $filter_list_labels); |
---|
[5548] | 229 | $default_licence = l10n("lmt_lbl_cc-".strtolower($this->config['lmt_licence_default'])); |
---|
| 230 | $default_licence_img =LMT_PATH."img/".strtolower($this->config['lmt_licence_default'])."_80x15.png"; |
---|
[3396] | 231 | |
---|
| 232 | $results=true; |
---|
| 233 | if(isset($_POST["submit_replace_caddie"])) |
---|
| 234 | { |
---|
| 235 | $sql="DELETE FROM ".CADDIE_TABLE." WHERE user_id='".$user['id']."'"; |
---|
| 236 | $result=pwg_query($sql); |
---|
| 237 | ($result)?$results=true:$results=false; |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | if(isset($_POST["submit_add_to_caddie"]) || isset($_POST["submit_replace_caddie"])) |
---|
| 241 | { |
---|
[3666] | 242 | |
---|
[4396] | 243 | $sql="REPLACE INTO ".CADDIE_TABLE." |
---|
| 244 | SELECT '".$user['id']."', it.id FROM ".IMAGES_TABLE." it, ".$this->tables["images"]." lmti |
---|
[3666] | 245 | WHERE it.id = lmti.image_id"; |
---|
| 246 | if($_REQUEST['filter']!="") |
---|
| 247 | { |
---|
| 248 | $sql.=" AND lmti.licence_type='".$_REQUEST['filter']."'"; |
---|
| 249 | } |
---|
| 250 | |
---|
[3396] | 251 | $result=pwg_query($sql); |
---|
| 252 | if((!$results)||(!$result)) |
---|
| 253 | { |
---|
[5548] | 254 | $this->displayResult(l10n("lmt_caddie_not_updated"), false); |
---|
[3396] | 255 | } |
---|
| 256 | else |
---|
| 257 | { |
---|
[5548] | 258 | $this->displayResult(l10n("lmt_caddie_updated"), true); |
---|
[3396] | 259 | } |
---|
| 260 | } |
---|
[4396] | 261 | |
---|
[3396] | 262 | $template->assign('datas', $datas); |
---|
| 263 | $template->assign('default_licence', $default_licence); |
---|
| 264 | $template->assign('default_licence_img', $default_licence_img); |
---|
| 265 | $template->assign('filter_list_values', $filter_list_values); |
---|
| 266 | $template->assign('filter_list_labels', $filter_list_labels); |
---|
| 267 | $template->assign('filter_list_selected', $filter_list_selected); |
---|
| 268 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | /* |
---|
| 273 | */ |
---|
| 274 | protected function display_manage_page() |
---|
| 275 | { |
---|
| 276 | global $template, $conf, $user; |
---|
| 277 | |
---|
| 278 | /* |
---|
| 279 | apply licence |
---|
| 280 | */ |
---|
| 281 | if(isset($_POST['submit_apply_licence'])) |
---|
| 282 | { |
---|
| 283 | $results=array("", ""); |
---|
| 284 | $lst=array(); |
---|
| 285 | foreach($_POST as $key => $val) |
---|
| 286 | { |
---|
| 287 | if((substr($key,0,2)=="fn")&&($val=="1")) $lst[]=substr($key,2); |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | if(count($lst)>0) |
---|
| 291 | { |
---|
| 292 | if($_POST['manage_caddie']!="napp_clear_selected") |
---|
| 293 | { |
---|
| 294 | if($_POST['licence']=='DEFAULT') |
---|
| 295 | { |
---|
[4396] | 296 | $sql="DELETE FROM ".$this->tables['images']." |
---|
[3396] | 297 | WHERE image_id IN (".implode(",", $lst).")"; |
---|
| 298 | } |
---|
| 299 | else |
---|
| 300 | { |
---|
[4396] | 301 | $sql="REPLACE INTO ".$this->tables['images']." |
---|
[3396] | 302 | SELECT id, '".$_POST['licence']."', '".$_POST['author']."' |
---|
[4396] | 303 | FROM ".IMAGES_TABLE." |
---|
[3396] | 304 | WHERE id IN (".implode(",", $lst).")"; |
---|
| 305 | } |
---|
| 306 | $result=pwg_query($sql); |
---|
| 307 | ($result)?$results[0].=l10n("lmt_add_licence_ok")."<br/>":$results[1].=l10n("lmt_add_licence_ko")."<br/>"; |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | switch($_POST['manage_caddie']) |
---|
| 311 | { |
---|
| 312 | case 'app_clear': |
---|
| 313 | $sql="DELETE FROM ".CADDIE_TABLE." WHERE user_id = '".$user['id']."'"; |
---|
| 314 | $result=pwg_query($sql); |
---|
| 315 | ($result)?$results[0].=l10n("lmt_clear_caddie_ok")."<br/>":$results[1].=l10n("lmt_clear_caddie_ko")."<br/>"; |
---|
| 316 | break; |
---|
| 317 | case 'app_clear_selected': |
---|
| 318 | case 'napp_clear_selected': |
---|
[4396] | 319 | $sql="DELETE FROM ".CADDIE_TABLE." |
---|
[3396] | 320 | WHERE user_id = '".$user['id']."' |
---|
| 321 | AND element_id IN (".implode(",", $lst).")"; |
---|
| 322 | $result=pwg_query($sql); |
---|
| 323 | ($result)?$results[0].=l10n("lmt_clear_si_caddie_ok")."<br/>":$results[1].=l10n("lmt_clear_si_caddie_ko")."<br/>"; |
---|
| 324 | break; |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | if($results[0]!="") |
---|
| 328 | { |
---|
[5548] | 329 | $this->displayResult($results[0], true); |
---|
[3396] | 330 | } |
---|
| 331 | |
---|
| 332 | if($results[1]!="") |
---|
| 333 | { |
---|
[5548] | 334 | $this->displayResult($results[1], false); |
---|
[3396] | 335 | } |
---|
| 336 | } |
---|
| 337 | else |
---|
| 338 | { |
---|
[5548] | 339 | $this->displayResult(l10n("lmt_no_element_selected"), false); |
---|
[3396] | 340 | } |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | $template->set_filename('body_page', |
---|
[5548] | 345 | dirname($this->getFileLocation()).'/admin/plugin_admin_manage.tpl'); |
---|
[3396] | 346 | |
---|
| 347 | $datas=array( |
---|
[7560] | 348 | "LMT_AJAX_URL_LIST" => $this->getAdminLink('ajax') |
---|
[3396] | 349 | ); |
---|
| 350 | |
---|
| 351 | if(!isset($_REQUEST['select'])) |
---|
| 352 | { |
---|
| 353 | $_REQUEST['select']="caddie"; |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | $sql="SELECT count(element_id) FROM ".CADDIE_TABLE." WHERE user_id = '".$user['id']."'"; |
---|
| 357 | $result=pwg_query($sql); |
---|
[5431] | 358 | $nbphotos=pwg_db_fetch_row($result); |
---|
[3396] | 359 | |
---|
| 360 | $author_list_values = array(0); |
---|
| 361 | $author_list_labels = array(l10n("lmt_no_author")); |
---|
| 362 | $sql="SELECT * FROM ".$this->tables["licence_author"]." ORDER BY id"; |
---|
| 363 | $result=pwg_query($sql); |
---|
| 364 | if($result) |
---|
| 365 | { |
---|
[5431] | 366 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 367 | { |
---|
| 368 | $author_list_values[]=$row['id']; |
---|
| 369 | $author_list_labels[]=$row['text1']." ".$row['text2']; |
---|
| 370 | } |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | $licences_list_values = array(); |
---|
[7560] | 374 | $licences_list_values = self::$licences; |
---|
[3396] | 375 | $licences_list_labels = array(); |
---|
| 376 | foreach($licences_list_values as $key=>$val) |
---|
| 377 | { |
---|
| 378 | $licences_list_labels[] = "[".l10n("lmt_lbl_cc_s-".strtolower($val))."] ".l10n("lmt_lbl_cc-".strtolower($val)); |
---|
| 379 | } |
---|
[4396] | 380 | |
---|
[3396] | 381 | /* $licences_list_values = array_merge(array('DEFAULT'), $licences_list_values); |
---|
| 382 | $licences_list_labels = array_merge(array(l10n('lmt_bydefault')), $licences_list_labels);*/ |
---|
| 383 | |
---|
| 384 | $selectlist_list_values=array("-", "all", "none", "invert"); |
---|
| 385 | $selectlist_list_values=array_merge($selectlist_list_values, $licences_list_values); |
---|
| 386 | |
---|
| 387 | $selectlist_list_labels=array( |
---|
[4396] | 388 | l10n("lmt_choose_select"), |
---|
| 389 | l10n("lmt_select_all"), |
---|
| 390 | l10n("lmt_select_none"), |
---|
| 391 | l10n("lmt_select_invert") |
---|
[3396] | 392 | ); |
---|
| 393 | $selectlist_list_labels=array_merge($selectlist_list_labels, $licences_list_labels); |
---|
| 394 | |
---|
| 395 | $template->assign('datas', $datas); |
---|
| 396 | $template->assign('nbphotos', $nbphotos[0]); |
---|
| 397 | $template->assign('selectlist_list_values', $selectlist_list_values); |
---|
| 398 | $template->assign('selectlist_list_labels', $selectlist_list_labels); |
---|
| 399 | $template->assign('filter_list_selected', ""); |
---|
| 400 | $template->assign('licences_list_values', $licences_list_values); |
---|
| 401 | $template->assign('licences_list_labels', $licences_list_labels); |
---|
| 402 | $template->assign('licences_list_selected', ""); |
---|
| 403 | $template->assign('author_list_values', $author_list_values); |
---|
| 404 | $template->assign('author_list_labels', $author_list_labels); |
---|
| 405 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | |
---|
| 409 | /* |
---|
| 410 | display config page |
---|
| 411 | */ |
---|
| 412 | protected function display_config() |
---|
| 413 | { |
---|
| 414 | global $template, $lang; |
---|
| 415 | |
---|
| 416 | $template->set_filename('body_page', |
---|
[5548] | 417 | dirname($this->getFileLocation()).'/admin/plugin_admin_config.tpl'); |
---|
[3396] | 418 | |
---|
[4396] | 419 | |
---|
[3396] | 420 | $datas=array( |
---|
| 421 | "img_directory" => LMT_PATH."img/" |
---|
| 422 | ); |
---|
[5548] | 423 | foreach($this->config as $key => $val) |
---|
[3396] | 424 | { |
---|
| 425 | if(!is_array($val)) |
---|
| 426 | { |
---|
| 427 | $datas[$key]=$val; |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | $lmt_yesno_values=array("y", "n"); |
---|
| 432 | $lmt_yesno_labels=array(l10n("lmt_yesno_y"), l10n("lmt_yesno_n")); |
---|
| 433 | |
---|
| 434 | $lmt_licence_logo_values=array("80x15", "88x31", "text"); |
---|
| 435 | $lmt_licence_logo_labels=array(l10n("lmt_icon_80x15"), l10n("lmt_icon_88x31"), l10n("lmt_icon_text")); |
---|
| 436 | |
---|
| 437 | $datas['lmt_redirect_urls']=array(); |
---|
[7560] | 438 | $lmt_licence_default_values = array_slice(self::$licences,0,count(self::$licences)-1); |
---|
[3396] | 439 | $lmt_licence_default_labels = array(); |
---|
| 440 | |
---|
[4396] | 441 | $tmp=array(); |
---|
[3396] | 442 | foreach($lmt_licence_default_values as $key=>$val) |
---|
| 443 | { |
---|
| 444 | $lmt_licence_default_labels[] = "[".l10n("lmt_lbl_cc_s-".strtolower($val))."] ".l10n("lmt_lbl_cc-".strtolower($val)); |
---|
| 445 | |
---|
| 446 | $tmp[]="'".str2url("ilmt_redirect_url-".strToLower($val))."'"; |
---|
| 447 | $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val))]=array( |
---|
| 448 | 'text' => l10n("lmt_lbl_cc_s-".strToLower($val)), |
---|
| 449 | 'langs' => array() |
---|
| 450 | ); |
---|
| 451 | } |
---|
| 452 | $datas['objnames2'] = implode(",", $tmp); |
---|
| 453 | |
---|
| 454 | |
---|
| 455 | //langs list & texts |
---|
| 456 | $datas['lmt_warning_texts']=array(); |
---|
| 457 | |
---|
| 458 | $lmt_language_list=array(); |
---|
| 459 | $lmt_language_list_values=array(); |
---|
| 460 | $lmt_language_list_labels=array(); |
---|
| 461 | $lmt_language_selected=str2url(get_default_language()); |
---|
| 462 | $languages=get_languages(); |
---|
| 463 | |
---|
| 464 | foreach($languages as $key => $val) |
---|
| 465 | { |
---|
| 466 | $lmt_language_list_values[]=str2url($key); |
---|
| 467 | $lmt_language_list_labels[]=$val; |
---|
| 468 | |
---|
| 469 | $datas['lmt_warning_texts'][]=array( |
---|
| 470 | 'lang' => str2url($key), |
---|
[5548] | 471 | 'text' => $this->config['lmt_warning_texts'][$key] |
---|
[3396] | 472 | ); |
---|
[4396] | 473 | |
---|
[3396] | 474 | foreach($lmt_licence_default_values as $key2 => $val2) |
---|
| 475 | { |
---|
| 476 | $datas['lmt_redirect_urls'][str2url('lmt_redirect_url-'.strToLower($val2))]['langs'][str2url($key)]= |
---|
[5548] | 477 | $this->config['lmt_redirect_url-'.strToLower($val2)][$key]; |
---|
[3396] | 478 | } |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | $lmt_licence_default_author_values=array(0); |
---|
| 482 | $lmt_licence_default_author_labels=array(l10n("lmt_no_author")); |
---|
| 483 | $sql="SELECT * FROM ".$this->tables['licence_author']." ORDER BY id"; |
---|
| 484 | $result=pwg_query($sql); |
---|
| 485 | if($result) |
---|
| 486 | { |
---|
[5431] | 487 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 488 | { |
---|
| 489 | $lmt_licence_default_author_values[]=$row['id']; |
---|
| 490 | $lmt_licence_default_author_labels[]=$row['text1']." ".$row['text2']; |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | $template->assign('datas', $datas); |
---|
| 495 | $template->assign('extended_code', $this->generate_js_licence_author()); |
---|
| 496 | $template->assign('lmt_yesno_values', $lmt_yesno_values); |
---|
| 497 | $template->assign('lmt_yesno_labels', $lmt_yesno_labels); |
---|
| 498 | $template->assign('lmt_licence_logo_values', $lmt_licence_logo_values); |
---|
| 499 | $template->assign('lmt_licence_logo_labels', $lmt_licence_logo_labels); |
---|
| 500 | $template->assign('lmt_licence_default_values', $lmt_licence_default_values); |
---|
| 501 | $template->assign('lmt_licence_default_labels', $lmt_licence_default_labels); |
---|
| 502 | $template->assign('lmt_licence_default_author_values', $lmt_licence_default_author_values); |
---|
| 503 | $template->assign('lmt_licence_default_author_labels', $lmt_licence_default_author_labels); |
---|
| 504 | $template->assign('lmt_language_list_values', $lmt_language_list_values); |
---|
| 505 | $template->assign('lmt_language_list_labels', $lmt_language_list_labels); |
---|
| 506 | $template->assign('lmt_language_selected', $lmt_language_selected); |
---|
| 507 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 508 | |
---|
| 509 | } //display_config |
---|
| 510 | |
---|
| 511 | |
---|
| 512 | |
---|
[7560] | 513 | /** |
---|
| 514 | * display the search page |
---|
| 515 | * |
---|
| 516 | */ |
---|
| 517 | protected function displaySearch() |
---|
| 518 | { |
---|
| 519 | global $template; |
---|
[3396] | 520 | |
---|
[7560] | 521 | $template->set_filename('body_page', |
---|
| 522 | dirname($this->getFileLocation()).'/admin/lmt_search.tpl'); |
---|
| 523 | |
---|
| 524 | $template->assign('lmt_search_page', GPCRequestBuilder::displaySearchPage($this->getPluginName())); |
---|
| 525 | |
---|
| 526 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | |
---|
[3396] | 531 | /* |
---|
| 532 | */ |
---|
| 533 | protected function display_manageaut_page() |
---|
| 534 | { |
---|
| 535 | global $template, $conf, $user; |
---|
| 536 | |
---|
| 537 | if(!isset($_REQUEST['action'])) |
---|
| 538 | { |
---|
| 539 | $_REQUEST['action']="list"; |
---|
| 540 | } |
---|
| 541 | if(!isset($_REQUEST['id'])) |
---|
| 542 | { |
---|
| 543 | $_REQUEST['id']=""; |
---|
| 544 | } |
---|
| 545 | |
---|
[10974] | 546 | |
---|
[3396] | 547 | /* ------------------------------------------------------------------------ |
---|
[4396] | 548 | * Add an author |
---|
[3396] | 549 | * ---------------------------------------------------------------------- */ |
---|
| 550 | if(isset($_POST['submit_add_author'])) |
---|
| 551 | { |
---|
| 552 | if($_POST["text1"]!="") |
---|
| 553 | { |
---|
[6703] | 554 | $sql="INSERT INTO ".$this->tables["licence_author"]." VALUES('', '". htmlspecialchars($_POST["text1"], ENT_QUOTES)."', '".htmlspecialchars($_POST["text2"], ENT_QUOTES)."')"; |
---|
[3396] | 555 | $result=pwg_query($sql); |
---|
| 556 | if($result) |
---|
| 557 | { |
---|
[5548] | 558 | $this->displayResult(l10n("lmt_author_added"), true); |
---|
[3396] | 559 | $_REQUEST['action']="list"; |
---|
| 560 | } |
---|
| 561 | else |
---|
| 562 | { |
---|
[5548] | 563 | $this->displayResult(l10n("lmt_cannot_add_author"), false); |
---|
[3396] | 564 | } |
---|
| 565 | } |
---|
| 566 | else |
---|
| 567 | { |
---|
[5548] | 568 | $this->displayResult(l10n("lmt_no_text"), false); |
---|
[3396] | 569 | } |
---|
| 570 | } |
---|
[4396] | 571 | |
---|
[3396] | 572 | /* ------------------------------------------------------------------------ |
---|
[4396] | 573 | * Modify an author |
---|
[3396] | 574 | * ---------------------------------------------------------------------- */ |
---|
| 575 | if(isset($_POST['submit_modify_author'])) |
---|
| 576 | { |
---|
| 577 | if($_POST["text1"]!="") |
---|
| 578 | { |
---|
[4396] | 579 | $sql="UPDATE ".$this->tables["licence_author"]." |
---|
[6703] | 580 | SET text1 = '". htmlspecialchars($_POST["text1"], ENT_QUOTES)."', |
---|
| 581 | text2 = '".htmlspecialchars($_POST["text2"], ENT_QUOTES)."' |
---|
[3396] | 582 | WHERE id = '".$_POST["id"]."'"; |
---|
| 583 | $result=pwg_query($sql); |
---|
| 584 | if($result) |
---|
| 585 | { |
---|
[5548] | 586 | $this->displayResult(l10n("lmt_author_modified"), true); |
---|
[3396] | 587 | $_REQUEST['action']="list"; |
---|
| 588 | } |
---|
| 589 | else |
---|
| 590 | { |
---|
[5548] | 591 | $this->displayResult(l10n("lmt_cannot_modify_author"), false); |
---|
[3396] | 592 | } |
---|
| 593 | } |
---|
| 594 | else |
---|
| 595 | { |
---|
[5548] | 596 | $this->displayResult(l10n("lmt_no_text"), false); |
---|
[3396] | 597 | } |
---|
| 598 | } |
---|
| 599 | |
---|
| 600 | /* ------------------------------------------------------------------------ |
---|
[4396] | 601 | * delete an author |
---|
[3396] | 602 | * ---------------------------------------------------------------------- */ |
---|
| 603 | if($_REQUEST['action']=="delete") |
---|
| 604 | { |
---|
| 605 | $sql="DELETE FROM ".$this->tables['licence_author']." WHERE id = '".$_REQUEST['id']."'"; |
---|
| 606 | $result=pwg_query($sql); |
---|
| 607 | if($result) |
---|
| 608 | { |
---|
[6701] | 609 | if(pwg_db_changes($result)==1) |
---|
[3396] | 610 | { |
---|
[5548] | 611 | $this->displayResult(l10n("lmt_author_deleted"), true); |
---|
[3396] | 612 | |
---|
[4396] | 613 | $sql="UPDATE ".$this->tables["images"]." SET author_id = NULL |
---|
[3396] | 614 | WHERE author_id = '".$_REQUEST['id']."'"; |
---|
| 615 | $result=pwg_query($sql); |
---|
| 616 | if($result) |
---|
| 617 | { |
---|
[6701] | 618 | $nbimages=pwg_db_changes($result); |
---|
[3396] | 619 | if($nbimages>0) |
---|
| 620 | { |
---|
[5548] | 621 | $this->displayResult($nbimages." ".l10n("lmt_author_nb_images_updated"), true); |
---|
[3396] | 622 | } |
---|
| 623 | } |
---|
| 624 | else |
---|
| 625 | { |
---|
[5548] | 626 | $this->displayResult(l10n("lmt_cannot_delete_author"), false); |
---|
[3396] | 627 | } |
---|
| 628 | } |
---|
| 629 | else |
---|
| 630 | { |
---|
[5548] | 631 | $this->displayResult(l10n("lmt_cannot_delete_author"), false); |
---|
[4396] | 632 | } |
---|
[3396] | 633 | } |
---|
| 634 | else |
---|
| 635 | { |
---|
[5548] | 636 | $this->displayResult(l10n("lmt_cannot_delete_author"), false); |
---|
[3396] | 637 | } |
---|
| 638 | $this->display_manageaut_page_list(); |
---|
| 639 | } |
---|
| 640 | elseif($_REQUEST['action']=="add") |
---|
| 641 | { |
---|
| 642 | $this->display_manageaut_page_add_modify("add"); |
---|
| 643 | } |
---|
| 644 | elseif($_REQUEST['action']=="edit") |
---|
| 645 | { |
---|
| 646 | $this->display_manageaut_page_add_modify("edit"); |
---|
| 647 | } |
---|
| 648 | else |
---|
| 649 | { |
---|
| 650 | // list |
---|
| 651 | $this->display_manageaut_page_list(); |
---|
| 652 | } |
---|
| 653 | } //display_manageaut |
---|
| 654 | |
---|
| 655 | protected function display_manageaut_page_list() |
---|
| 656 | { |
---|
| 657 | global $template; |
---|
| 658 | |
---|
| 659 | $template->set_filename('body_page', |
---|
[5548] | 660 | dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut.tpl'); |
---|
[3396] | 661 | |
---|
| 662 | $datas=array( |
---|
| 663 | "author_list" => array(), |
---|
| 664 | "img_directory" => LMT_PATH."img/", |
---|
[5548] | 665 | "default_licencepublished" => l10n("lmt_lbl_under-".strToLower($this->config['lmt_licence_default'])), |
---|
| 666 | "default_licenceL" => strToLower($this->config['lmt_licence_default']), |
---|
| 667 | "default_licenceU" => l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])), |
---|
| 668 | "lmt_licence_logo" => $this->config['lmt_licence_logo'], |
---|
[3396] | 669 | "nbauthor" => 0, |
---|
[15341] | 670 | "add_link" => $this->getAdminLink().'-manageaut&action=add' |
---|
[3396] | 671 | ); |
---|
| 672 | |
---|
| 673 | $sql="SELECT * FROM ".$this->tables['licence_author']." ORDER BY id"; |
---|
| 674 | $result=pwg_query($sql); |
---|
| 675 | if($result) |
---|
| 676 | { |
---|
[5431] | 677 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 678 | { |
---|
| 679 | $datas["author_list"][]=array( |
---|
| 680 | "id" => $row['id'], |
---|
| 681 | "text1" => $row['text1'], |
---|
| 682 | "text2" => $row['text2'], |
---|
[15341] | 683 | "lnk_delete" => $this->getAdminLink().'-manageaut&action=delete&id='.$row['id'], |
---|
| 684 | "lnk_edit" => $this->getAdminLink().'-manageaut&action=edit&id='.$row['id'] |
---|
[3396] | 685 | ); |
---|
| 686 | } |
---|
| 687 | $datas["nbauthor"] = count($datas["author_list"]); |
---|
| 688 | } |
---|
| 689 | |
---|
| 690 | $template->assign('datas', $datas); |
---|
| 691 | //$template->assign('extended_code', $this->generate_js_licence_author()); |
---|
| 692 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | protected function display_manageaut_page_add_modify() |
---|
| 696 | { |
---|
| 697 | global $template; |
---|
| 698 | |
---|
| 699 | $template->set_filename('body_page', |
---|
[5548] | 700 | dirname($this->getFileLocation()).'/admin/plugin_admin_manageaut_edit.tpl'); |
---|
[3396] | 701 | |
---|
| 702 | if($_REQUEST["action"]=="edit") |
---|
[4396] | 703 | { |
---|
[3396] | 704 | $sql="SELECT * FROM ".$this->tables['licence_author']." WHERE id = '".$_REQUEST['id']."'"; |
---|
| 705 | $result = pwg_query($sql); |
---|
| 706 | if($result) |
---|
| 707 | { |
---|
[6272] | 708 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 709 | { |
---|
| 710 | $datas=array( |
---|
| 711 | "action" => "modify", |
---|
| 712 | "id" => $_REQUEST['id'], |
---|
| 713 | "text1" => $row["text1"], |
---|
| 714 | "text2" => $row["text2"] |
---|
| 715 | ); |
---|
| 716 | } |
---|
| 717 | } |
---|
| 718 | else |
---|
| 719 | { |
---|
| 720 | $datas=array( |
---|
| 721 | "action" => "add", |
---|
| 722 | "id" => "", |
---|
| 723 | "text1" => "", |
---|
| 724 | "text2" => "", |
---|
| 725 | ); |
---|
| 726 | } |
---|
| 727 | } |
---|
| 728 | else |
---|
| 729 | { |
---|
| 730 | $datas=array( |
---|
| 731 | "action" => "add", |
---|
| 732 | "id" => "", |
---|
| 733 | "text1" => "", |
---|
| 734 | "text2" => "", |
---|
| 735 | ); |
---|
| 736 | } |
---|
| 737 | |
---|
[15341] | 738 | $datas["urllist"] = $this->getAdminLink().'-manageaut'; |
---|
[3396] | 739 | |
---|
| 740 | $template->assign('datas', $datas); |
---|
| 741 | //$template->assign('extended_code', $this->generate_js_licence_author()); |
---|
| 742 | $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page'); |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | |
---|
| 746 | /* |
---|
| 747 | manage adviser profile |
---|
| 748 | return true if user is adviser |
---|
| 749 | */ |
---|
| 750 | protected function adviser_abort() |
---|
| 751 | { |
---|
| 752 | if(is_adviser()) |
---|
| 753 | { |
---|
[5548] | 754 | $this->displayResult(l10n("lmt_adviser_not_allowed"), false); |
---|
[3396] | 755 | return(true); |
---|
| 756 | } |
---|
| 757 | return(false); |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | |
---|
| 761 | /* |
---|
[4396] | 762 | this function return a js to manage licence text |
---|
[3396] | 763 | */ |
---|
| 764 | protected function generate_js_licence_author() |
---|
| 765 | { |
---|
| 766 | $local_tpl = new Template(LMT_PATH."admin/", ""); |
---|
| 767 | $local_tpl->set_filename('body_page', |
---|
[5548] | 768 | dirname($this->getFileLocation()).'/admin/lmt_js.tpl'); |
---|
[3396] | 769 | |
---|
[7560] | 770 | $lmt_licence_default_values=array_slice(self::$licences,0,count(self::$licences)-1); |
---|
[3396] | 771 | $datas['shortlicencetext']=array(); |
---|
| 772 | foreach($lmt_licence_default_values as $key=>$val) |
---|
| 773 | { |
---|
| 774 | $datas['shortlicencetext'][$val] = array( |
---|
| 775 | "txt" => l10n("lmt_lbl_cc_s-".strtolower($val)), |
---|
| 776 | "published" => l10n("lmt_lbl_under-".strtolower($val)) |
---|
| 777 | ); |
---|
| 778 | } |
---|
| 779 | |
---|
| 780 | $local_tpl->assign("datas",$datas); |
---|
| 781 | |
---|
| 782 | return($local_tpl->parse('body_page', true)); |
---|
| 783 | } |
---|
| 784 | |
---|
| 785 | |
---|
| 786 | /* --------------------------------------------------------------------------- |
---|
| 787 | function to manage database manipulation |
---|
| 788 | --------------------------------------------------------------------------- */ |
---|
| 789 | |
---|
| 790 | } //class |
---|
| 791 | |
---|
[5548] | 792 | |
---|
[3396] | 793 | ?> |
---|