Textpattern | PHP Cross Reference | Content Management Systems |
Description: Sections panel.
1 <?php 2 3 /* 4 * Textpattern Content Management System 5 * http://textpattern.com 6 * 7 * Copyright (C) 2005 Dean Allen 8 * Copyright (C) 2016 The Textpattern Development Team 9 * 10 * This file is part of Textpattern. 11 * 12 * Textpattern is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation, version 2. 15 * 16 * Textpattern is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with Textpattern. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 /** 26 * Sections panel. 27 * 28 * @package Admin\Section 29 */ 30 31 use Textpattern\Search\Filter; 32 33 if (!defined('txpinterface')) { 34 die('txpinterface is undefined.'); 35 } 36 37 if ($event == 'section') { 38 require_privs('section'); 39 40 global $all_pages, $all_styles; 41 $all_pages = safe_column("name", 'txp_page', "1 = 1 ORDER BY name"); 42 $all_styles = safe_column("name", 'txp_css', "1 = 1 ORDER BY name"); 43 44 $available_steps = array( 45 'section_change_pageby' => true, 46 'sec_section_list' => false, 47 'section_delete' => true, 48 'section_save' => true, 49 'section_edit' => false, 50 'section_multi_edit' => true, 51 'section_set_default' => true, 52 'section_toggle_option' => true, 53 ); 54 55 if ($step && bouncer($step, $available_steps)) { 56 $step(); 57 } else { 58 sec_section_list(); 59 } 60 } 61 62 /** 63 * The main panel listing all sections. 64 * 65 * So-named to avoid clashing with the <txp:section_list /> tag. 66 * 67 * @param string|array $message The activity message 68 */ 69 70 function sec_section_list($message = '') 71 { 72 global $event, $section_list_pageby; 73 74 pagetop(gTxt('tab_sections'), $message); 75 76 extract(gpsa(array( 77 'page', 78 'sort', 79 'dir', 80 'crit', 81 'search_method', 82 ))); 83 84 if ($sort === '') { 85 $sort = get_pref('section_sort_column', 'name'); 86 } else { 87 if (!in_array($sort, array('title', 'page', 'css', 'in_rss', 'on_frontpage', 'searchable', 'article_count'))) { 88 $sort = 'name'; 89 } 90 91 set_pref('section_sort_column', $sort, 'section', 2, '', 0, PREF_PRIVATE); 92 } 93 94 if ($dir === '') { 95 $dir = get_pref('section_sort_dir', 'desc'); 96 } else { 97 $dir = ($dir == 'asc') ? "asc" : "desc"; 98 set_pref('section_sort_dir', $dir, 'section', 2, '', 0, PREF_PRIVATE); 99 } 100 101 switch ($sort) { 102 case 'title': 103 $sort_sql = "title $dir"; 104 break; 105 case 'page': 106 $sort_sql = "page $dir"; 107 break; 108 case 'css': 109 $sort_sql = "css $dir"; 110 break; 111 case 'in_rss': 112 $sort_sql = "in_rss $dir"; 113 break; 114 case 'on_frontpage': 115 $sort_sql = "on_frontpage $dir"; 116 break; 117 case 'searchable': 118 $sort_sql = "searchable $dir"; 119 break; 120 case 'article_count': 121 $sort_sql = "article_count $dir"; 122 break; 123 default: 124 $sort_sql = "name $dir"; 125 break; 126 } 127 128 $switch_dir = ($dir == 'desc') ? 'asc' : 'desc'; 129 130 $search = new Filter($event, 131 array( 132 'name' => array( 133 'column' => 'txp_section.name', 134 'label' => gTxt('name'), 135 ), 136 'title' => array( 137 'column' => 'txp_section.title', 138 'label' => gTxt('title'), 139 ), 140 'page' => array( 141 'column' => 'txp_section.page', 142 'label' => gTxt('page'), 143 ), 144 'css' => array( 145 'column' => 'txp_section.css', 146 'label' => gTxt('css'), 147 ), 148 'on_frontpage' => array( 149 'column' => 'txp_section.on_frontpage', 150 'label' => gTxt('on_front_page'), 151 'type' => 'boolean', 152 ), 153 'in_rss' => array( 154 'column' => 'txp_section.in_rss', 155 'label' => gTxt('syndicate'), 156 'type' => 'boolean', 157 ), 158 'searchable' => array( 159 'column' => 'txp_section.searchable', 160 'label' => gTxt('include_in_search'), 161 'type' => 'boolean', 162 ), 163 ) 164 ); 165 166 $alias_yes = '1, Yes'; 167 $alias_no = '0, No'; 168 $search->setAliases('on_frontpage', array($alias_no, $alias_yes)); 169 $search->setAliases('in_rss', array($alias_no, $alias_yes)); 170 $search->setAliases('searchable', array($alias_no, $alias_yes)); 171 172 list($criteria, $crit, $search_method) = $search->getFilter(); 173 174 $search_render_options = array( 175 'placeholder' => 'search_sections', 176 ); 177 178 $total = safe_count('txp_section', $criteria); 179 180 echo n.'<div class="txp-layout">'. 181 n.tag( 182 hed(gTxt('tab_sections'), 1, array('class' => 'txp-heading')), 183 'div', array('class' => 'txp-layout-4col-alt') 184 ); 185 186 $searchBlock = 187 n.tag( 188 $search->renderForm('sec_section', $search_render_options), 189 'div', array( 190 'class' => 'txp-layout-4col-3span', 191 'id' => $event.'_control', 192 ) 193 ); 194 195 $createBlock = array(); 196 197 if (has_privs('section.edit')) { 198 $createBlock[] = 199 n.tag( 200 sLink('section', 'section_edit', gTxt('create_section'), 'txp-button'). 201 n.tag_start('form', array( 202 'class' => 'async', 203 'id' => 'default_section_form', 204 'name' => 'default_section_form', 205 'method' => 'post', 206 'action' => 'index.php', 207 )). 208 tag(gTxt('default_write_section'), 'label', array('for' => 'default_section')). 209 popHelp('section_default'). 210 section_select_list(). 211 eInput('section'). 212 sInput('section_set_default'). 213 n.tag_end('form'), 214 'div', array('class' => 'txp-control-panel') 215 ); 216 } 217 218 $contentBlockStart = n.tag_start('div', array( 219 'class' => 'txp-layout-1col', 220 'id' => $event.'_container', 221 )); 222 223 $createBlock = implode(n, $createBlock); 224 225 if ($total < 1) { 226 if ($criteria != 1) { 227 echo $searchBlock. 228 $contentBlockStart. 229 $createBlock. 230 graf( 231 span(null, array('class' => 'ui-icon ui-icon-info')).' '. 232 gTxt('no_results_found'), 233 array('class' => 'alert-block information') 234 ). 235 n.tag_end('div'). // End of .txp-layout-1col. 236 n.'</div>'; // End of .txp-layout. 237 } 238 239 return; 240 } 241 242 $limit = max($section_list_pageby, 15); 243 244 list($page, $offset, $numPages) = pager($total, $limit, $page); 245 246 echo $searchBlock.$contentBlockStart.$createBlock; 247 248 $rs = safe_rows_start( 249 "*, (SELECT COUNT(*) FROM ".safe_pfx_j('textpattern')." WHERE textpattern.Section = txp_section.name) AS article_count", 250 'txp_section', 251 "$criteria ORDER BY $sort_sql LIMIT $offset, $limit" 252 ); 253 254 if ($rs) { 255 echo n.tag( 256 toggle_box('section_detail'), 'div', array('class' => 'txp-list-options')). 257 n.tag_start('form', array( 258 'class' => 'multi_edit_form', 259 'id' => 'section_form', 260 'name' => 'longform', 261 'method' => 'post', 262 'action' => 'index.php', 263 )). 264 n.tag_start('div', array('class' => 'txp-listtables')). 265 n.tag_start('table', array('class' => 'txp-list')). 266 n.tag_start('thead'). 267 tr( 268 hCell( 269 fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), 270 '', ' class="txp-list-col-multi-edit" scope="col" title="'.gTxt('toggle_all_selected').'"' 271 ). 272 column_head( 273 'name', 'name', 'section', true, $switch_dir, $crit, $search_method, 274 (('name' == $sort) ? "$dir " : '').'txp-list-col-name' 275 ). 276 column_head( 277 'title', 'title', 'section', true, $switch_dir, $crit, $search_method, 278 (('title' == $sort) ? "$dir " : '').'txp-list-col-title' 279 ). 280 column_head( 281 'page', 'page', 'section', true, $switch_dir, $crit, $search_method, 282 (('page' == $sort) ? "$dir " : '').'txp-list-col-page' 283 ). 284 column_head( 285 'css', 'css', 'section', true, $switch_dir, $crit, $search_method, 286 (('css' == $sort) ? "$dir " : '').'txp-list-col-style' 287 ). 288 column_head( 289 'on_front_page', 'on_frontpage', 'section', true, $switch_dir, $crit, $search_method, 290 (('on_frontpage' == $sort) ? "$dir " : '').'txp-list-col-frontpage section_detail' 291 ). 292 column_head( 293 'syndicate', 'in_rss', 'section', true, $switch_dir, $crit, $search_method, 294 (('in_rss' == $sort) ? "$dir " : '').'txp-list-col-syndicate section_detail' 295 ). 296 column_head( 297 'include_in_search', 'searchable', 'section', true, $switch_dir, $crit, $search_method, 298 (('searchable' == $sort) ? "$dir " : '').'txp-list-col-searchable section_detail' 299 ). 300 column_head( 301 'articles', 'article_count', 'section', true, $switch_dir, $crit, $search_method, 302 (('article_count' == $sort) ? "$dir " : '').'txp-list-col-article_count section_detail' 303 ) 304 ). 305 n.tag_end('thead'). 306 n.tag_start('tbody'); 307 308 while ($a = nextRow($rs)) { 309 extract($a, EXTR_PREFIX_ALL, 'sec'); 310 311 $edit_url = array( 312 'event' => 'section', 313 'step' => 'section_edit', 314 'name' => $sec_name, 315 'sort' => $sort, 316 'dir' => $dir, 317 'page' => $page, 318 'search_method' => $search_method, 319 'crit' => $crit, 320 ); 321 322 if ($sec_name == 'default') { 323 $articles = $sec_searchable = $sec_in_rss = $sec_on_frontpage = '-'; 324 } else { 325 $sec_on_frontpage = asyncHref(yes_no($sec_on_frontpage), array( 326 'step' => 'section_toggle_option', 327 'thing' => $sec_name, 328 'property' => 'on_frontpage', 329 )); 330 331 $sec_in_rss = asyncHref(yes_no($sec_in_rss), array( 332 'step' => 'section_toggle_option', 333 'thing' => $sec_name, 334 'property' => 'in_rss', 335 )); 336 337 $sec_searchable = asyncHref(yes_no($sec_searchable), array( 338 'step' => 'section_toggle_option', 339 'thing' => $sec_name, 340 'property' => 'searchable', 341 )); 342 343 if ($sec_article_count > 0) { 344 $articles = href($sec_article_count, array( 345 'event' => 'list', 346 'search_method' => 'section', 347 'crit' => '"'.$sec_name.'"', 348 ), array( 349 'title' => gTxt('article_count', array('{num}' => $sec_article_count)), 350 )); 351 } else { 352 $articles = 0; 353 } 354 } 355 356 $sec_page = href(txpspecialchars($sec_page), array( 357 'event' => 'page', 358 'name' => $sec_page, 359 ), array('title' => gTxt('edit'))); 360 361 $sec_css = href(txpspecialchars($sec_css), array( 362 'event' => 'css', 363 'name' => $sec_css, 364 ), array('title' => gTxt('edit'))); 365 366 echo tr( 367 td( 368 fInput('checkbox', 'selected[]', $sec_name), '', 'txp-list-col-multi-edit' 369 ). 370 hCell( 371 href( 372 txpspecialchars($sec_name), $edit_url, array('title' => gTxt('edit')) 373 ). 374 span( 375 sp.span('|', array('role' => 'separator')). 376 sp.href(gTxt('view'), pagelinkurl(array('s' => $sec_name))), 377 array('class' => 'txp-option-link section_detail') 378 ), '', array( 379 'class' => 'txp-list-col-name', 380 'scope' => 'row', 381 ) 382 ). 383 td( 384 txpspecialchars($sec_title), '', 'txp-list-col-title' 385 ). 386 td( 387 $sec_page, '', 'txp-list-col-page' 388 ). 389 td( 390 $sec_css, '', 'txp-list-col-style' 391 ). 392 td( 393 $sec_on_frontpage, '', 'txp-list-col-frontpage section_detail' 394 ). 395 td( 396 $sec_in_rss, '', 'txp-list-col-syndicate section_detail' 397 ). 398 td( 399 $sec_searchable, '', 'txp-list-col-searchable section_detail' 400 ). 401 td( 402 $articles, '', 'txp-list-col-article_count section_detail' 403 ), 404 array('id' => 'txp_section_'.$sec_name) 405 ); 406 } 407 408 echo n.tag_end('tbody'). 409 n.tag_end('table'). 410 n.tag_end('div'). // End of .txp-listtables. 411 section_multiedit_form($page, $sort, $dir, $crit, $search_method). 412 tInput(). 413 n.tag_end('form'). 414 n.tag_start('div', array( 415 'class' => 'txp-navigation', 416 'id' => $event.'_navigation', 417 )). 418 pageby_form('section', $section_list_pageby). 419 nav_form('section', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit). 420 n.tag_end('div'); 421 } 422 423 echo n.tag_end('div'). // End of .txp-layout-1col. 424 n.'</div>'; // End of .txp-layout. 425 } 426 427 /** 428 * Renders and outputs the section editor panel. 429 */ 430 431 function section_edit() 432 { 433 global $event, $step, $all_pages, $all_styles; 434 435 require_privs('section.edit'); 436 437 extract(gpsa(array( 438 'page', 439 'sort', 440 'dir', 441 'crit', 442 'search_method', 443 'name', 444 ))); 445 446 $is_edit = ($name && $step == 'section_edit'); 447 $caption = gTxt('create_section'); 448 $is_default_section = false; 449 450 if ($is_edit) { 451 $rs = safe_row( 452 "*", 453 'txp_section', 454 "name = '".doSlash($name)."'" 455 ); 456 457 if ($name == 'default') { 458 $caption = gTxt('edit_default_section'); 459 $is_default_section = true; 460 } else { 461 $caption = gTxt('edit_section'); 462 } 463 } else { 464 // Pulls defaults for the new section from the 'default'. 465 $rs = safe_row( 466 "page, css, on_frontpage, in_rss, searchable", 467 'txp_section', 468 "name = 'default'" 469 ); 470 471 if ($rs) { 472 $rs['name'] = $rs['title'] = $rs['description'] = ''; 473 } 474 } 475 476 if (!$rs) { 477 sec_section_list(array(gTxt('unknown_section'), E_ERROR)); 478 479 return; 480 } 481 482 extract($rs, EXTR_PREFIX_ALL, 'sec'); 483 pagetop(gTxt('tab_sections')); 484 485 $out = array(); 486 487 $out[] = hed($caption, 2); 488 489 if ($is_default_section) { 490 $out[] = hInput('name', 'default'); 491 } else { 492 $out[] = inputLabel( 493 'section_name', 494 fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 495 'section_name', '', array('class' => 'txp-form-field edit-section-name') 496 ). 497 inputLabel( 498 'section_title', 499 fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 500 'section_longtitle', '', array('class' => 'txp-form-field edit-section-longtitle') 501 ); 502 } 503 504 $out[] = inputLabel( 505 'section_page', 506 selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 507 'uses_page', 'section_uses_page', array('class' => 'txp-form-field edit-section-uses-page') 508 ). 509 inputLabel( 510 'section_css', 511 selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 512 'uses_style', 'section_uses_css', array('class' => 'txp-form-field edit-section-uses-css') 513 ); 514 515 if (!$is_default_section) { 516 $out[] = inputLabel( 517 'on_front_page', 518 yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), 519 '', 'section_on_frontpage', array('class' => 'txp-form-field edit-section-on-frontpage') 520 ). 521 inputLabel( 522 'syndicate', 523 yesnoradio('in_rss', $sec_in_rss, '', $sec_name), 524 '', 'section_syndicate', array('class' => 'txp-form-field edit-section-syndicate') 525 ). 526 inputLabel( 527 'include_in_search', 528 yesnoradio('searchable', $sec_searchable, '', $sec_name), 529 '', 'section_searchable', array('class' => 'txp-form-field edit-section-searchable') 530 ); 531 } 532 533 $out[] = inputLabel( 534 'section_description', 535 '<textarea id="section_description" name="description" cols="'.INPUT_LARGE.'" rows="'.TEXTAREA_HEIGHT_SMALL.'">'.$sec_description.'</textarea>', 536 'description', 'section_description', array('class' => 'txp-form-field txp-form-field-textarea edit-section-description') 537 ); 538 539 $out[] = pluggable_ui('section_ui', 'extend_detail_form', '', $rs). 540 graf( 541 sLink('section', '', gTxt('cancel'), 'txp-button'). 542 fInput('submit', '', gTxt('save'), 'publish'), 543 array('class' => 'txp-edit-actions') 544 ). 545 eInput('section'). 546 sInput('section_save'). 547 hInput('old_name', $sec_name). 548 hInput('search_method', $search_method). 549 hInput('crit', $crit). 550 hInput('page', $page). 551 hInput('sort', $sort). 552 hInput('dir', $dir); 553 554 echo form(join('', $out), '', '', 'post', 'txp-edit', '', 'section_details'); 555 } 556 557 /** 558 * Saves a section. 559 */ 560 561 function section_save() 562 { 563 $in = array_map('assert_string', psa(array( 564 'name', 565 'title', 566 'description', 567 'old_name', 568 'section_page', 569 'css', 570 ))); 571 572 if (empty($in['title'])) { 573 $in['title'] = $in['name']; 574 } 575 576 // Prevent non-URL characters on section names. 577 $in['name'] = strtolower(sanitizeForUrl($in['name'])); 578 579 extract($in); 580 581 $in = doSlash($in); 582 extract($in, EXTR_PREFIX_ALL, 'safe'); 583 584 if ($name != strtolower($old_name)) { 585 if (safe_field("name", 'txp_section', "name = '$safe_name'")) { 586 // Invalid input. Halt all further processing (e.g. plugin event 587 // handlers). 588 $message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR); 589 // modal_halt($message); 590 sec_section_list($message); 591 592 return; 593 } 594 } 595 596 $ok = false; 597 if ($name == 'default') { 598 $ok = safe_update('txp_section', "page = '$safe_section_page', css = '$safe_css', description = '$safe_description'", "name = 'default'"); 599 } elseif ($name) { 600 extract(array_map('assert_int', psa(array('on_frontpage', 'in_rss', 'searchable')))); 601 602 if ($safe_old_name) { 603 $ok = safe_update('txp_section', " 604 name = '$safe_name', 605 title = '$safe_title', 606 page = '$safe_section_page', 607 css = '$safe_css', 608 description = '$safe_description', 609 on_frontpage = $on_frontpage, 610 in_rss = $in_rss, 611 searchable = $searchable 612 ", "name = '$safe_old_name'"); 613 614 // Manually maintain referential integrity. 615 if ($ok) { 616 $ok = safe_update('textpattern', "Section = '$safe_name'", "Section = '$safe_old_name'"); 617 } 618 } else { 619 $ok = safe_insert('txp_section', " 620 name = '$safe_name', 621 title = '$safe_title', 622 page = '$safe_section_page', 623 css = '$safe_css', 624 description = '$safe_description', 625 on_frontpage = $on_frontpage, 626 in_rss = $in_rss, 627 searchable = $searchable"); 628 } 629 } 630 631 if ($ok) { 632 update_lastmod('section_saved', compact('name', 'title', 'page', 'css', 'description', 'on_frontpage', 'in_rss', 'searchable')); 633 } 634 635 if ($ok) { 636 sec_section_list(gTxt(($safe_old_name ? 'section_updated' : 'section_created'), array('{name}' => $name))); 637 } else { 638 sec_section_list(array(gTxt('section_save_failed'), E_ERROR)); 639 } 640 } 641 642 /** 643 * Changes and saves the pageby value. 644 */ 645 646 function section_change_pageby() 647 { 648 event_change_pageby('section'); 649 sec_section_list(); 650 } 651 652 /** 653 * Toggles section yes/no parameters. 654 * 655 * This function requires three HTTP POST parameters: 'column', 'value' and 656 * 'name'. The 'value' is the new value, localised 'Yes' or 'No', 657 * 'name' is the section and the 'column' is the altered setting, 658 * either 'on_frontpage', 'in_rss' or 'searchable'. 659 * 660 * Outputs a text/plain response comprising the new displayable 661 * value for the toggled parameter. 662 */ 663 664 function section_toggle_option() 665 { 666 extract(psa(array( 667 'property', 668 'value', 669 'thing', 670 ))); 671 672 $value = (int) ($value === gTxt('no')); 673 674 if (in_array($property, array('on_frontpage', 'in_rss', 'searchable'))) { 675 if (safe_update('txp_section', "$property = $value", "name = '".doSlash($thing)."'")) { 676 echo yes_no($value); 677 678 return; 679 } 680 } 681 682 trigger_error(gTxt('section_save_failed'), E_USER_ERROR); 683 } 684 685 /** 686 * Sets a section as the default. 687 */ 688 689 function section_set_default() 690 { 691 extract(psa(array( 692 'default_section', 693 ))); 694 695 $exists = safe_row("name", 'txp_section', "name = '".doSlash($default_section)."'"); 696 697 if ($exists && set_pref('default_section', $default_section, 'section', PREF_HIDDEN)) { 698 send_script_response(announce(gTxt('default_section_updated'))); 699 700 return; 701 } 702 703 send_script_response(announce(gTxt('section_save_failed'), E_ERROR)); 704 } 705 706 /** 707 * Renders a 'default_section' <select> input listing all sections. 708 * 709 * Used for changing the default section. 710 * 711 * @return string HTML 712 */ 713 714 function section_select_list() 715 { 716 $val = get_pref('default_section'); 717 $sections = safe_rows("name, title", 'txp_section', "name != 'default' ORDER BY title, name"); 718 $vals = array(); 719 foreach ($sections as $row) { 720 $vals[$row['name']] = $row['title']; 721 } 722 723 return selectInput('default_section', $vals, $val, false, true, 'default_section'); 724 } 725 726 /** 727 * Processes delete actions sent using the multi-edit form. 728 */ 729 730 function section_delete() 731 { 732 $selectedList = ps('selected'); 733 $selected = join(',', quote_list($selectedList)); 734 $message = ''; 735 736 $sections = safe_column( 737 "name", 738 'txp_section', 739 "name != 'default' AND name IN ($selected) AND name NOT IN (SELECT Section FROM ".safe_pfx('textpattern').")" 740 ); 741 742 $sectionsNotDeleted = array_diff($selectedList, $sections); 743 744 if ($sections && safe_delete('txp_section', "name IN (".join(',', quote_list($sections)).")")) { 745 callback_event('sections_deleted', '', 0, $sections); 746 $message = gTxt('section_deleted', array('{name}' => join(', ', $sections))); 747 } 748 749 if ($sectionsNotDeleted) { 750 $severity = ($message) ? E_WARNING : E_ERROR; 751 $message = array(($message ? $message.n : '') . gTxt('section_delete_failure', array('{name}' => join(', ', $sectionsNotDeleted))), $severity); 752 } 753 754 sec_section_list($message); 755 } 756 757 /** 758 * Renders a multi-edit form widget. 759 * 760 * @param int $page The page number 761 * @param string $sort The current sorting value 762 * @param string $dir The current sorting direction 763 * @param string $crit The current search criteria 764 * @param string $search_method The current search method 765 * @return string HTML 766 */ 767 768 function section_multiedit_form($page, $sort, $dir, $crit, $search_method) 769 { 770 global $all_pages, $all_styles; 771 772 $methods = array( 773 'changepage' => array( 774 'label' => gTxt('uses_page'), 775 'html' => selectInput('uses_page', $all_pages, '', false), 776 ), 777 'changecss' => array( 778 'label' => gTxt('uses_style'), 779 'html' => selectInput('css', $all_styles, '', false), 780 ), 781 'changeonfrontpage' => array( 782 'label' => gTxt('on_front_page'), 783 'html' => yesnoRadio('on_frontpage', 1), 784 ), 785 'changesyndicate' => array( 786 'label' => gTxt('syndicate'), 787 'html' => yesnoRadio('in_rss', 1), 788 ), 789 'changesearchable' => array( 790 'label' => gTxt('include_in_search'), 791 'html' => yesnoRadio('searchable', 1), 792 ), 793 'delete' => gTxt('delete'), 794 ); 795 796 return multi_edit($methods, 'section', 'section_multi_edit', $page, $sort, $dir, $crit, $search_method); 797 } 798 799 /** 800 * Processes multi-edit actions. 801 */ 802 803 function section_multi_edit() 804 { 805 global $txp_user, $all_pages, $all_styles; 806 807 extract(psa(array( 808 'edit_method', 809 'selected', 810 ))); 811 812 if (!$selected || !is_array($selected)) { 813 return sec_section_list(); 814 } 815 816 $key = $val = ''; 817 818 switch ($edit_method) { 819 case 'delete': 820 return section_delete(); 821 break; 822 case 'changepage': 823 $val = ps('uses_page'); 824 if (in_array($val, $all_pages, true)) { 825 $key = 'page'; 826 } 827 break; 828 case 'changecss': 829 $val = ps('css'); 830 if (in_array($val, $all_styles, true)) { 831 $key = 'css'; 832 } 833 break; 834 case 'changeonfrontpage': 835 $key = 'on_frontpage'; 836 $val = (int) ps('on_frontpage'); 837 break; 838 case 'changesyndicate': 839 $key = 'in_rss'; 840 $val = (int) ps('in_rss'); 841 break; 842 case 'changesearchable': 843 $key = 'searchable'; 844 $val = (int) ps('searchable'); 845 break; 846 } 847 848 $sections = safe_column( 849 "name", 850 'txp_section', 851 "name IN (".join(',', quote_list($selected)).")" 852 ); 853 854 if ($key && $sections) { 855 if ( 856 safe_update( 857 'txp_section', 858 "$key = '".doSlash($val)."'", 859 "name IN (".join(',', quote_list($sections)).")" 860 ) 861 ) { 862 sec_section_list(gTxt('section_updated', array('{name}' => join(', ', $sections)))); 863 864 return; 865 } 866 } 867 868 sec_section_list(); 869 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title