| Total Complexity | 156 |
| Total Lines | 1035 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like DisplayController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DisplayController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 12 | class DisplayController extends BaseController |
||
| 13 | { |
||
| 14 | public $controller_name = 'DisplayController'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Default method to render the controller according to the action parameter. |
||
| 18 | */ |
||
| 19 | public function render() |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Displays requested data. |
||
| 108 | * |
||
| 109 | * @param mixed $msg |
||
|
1 ignored issue
–
show
|
|||
| 110 | */ |
||
| 111 | public function doBrowse($msg = '') |
||
| 574 | } |
||
| 575 | |||
| 576 | /** |
||
| 577 | * Show confirmation of edit and perform actual update. |
||
| 578 | * |
||
| 579 | * @param mixed $confirm |
||
|
1 ignored issue
–
show
|
|||
| 580 | * @param mixed $msg |
||
|
1 ignored issue
–
show
|
|||
| 581 | */ |
||
| 582 | public function doEditRow($confirm, $msg = '') |
||
| 583 | { |
||
| 584 | $lang = $this->lang; |
||
| 585 | $data = $this->misc->getDatabaseAccessor(); |
||
| 586 | |||
| 587 | if (is_array($_REQUEST['key'])) { |
||
| 588 | $key = $_REQUEST['key']; |
||
| 589 | } else { |
||
| 590 | $key = unserialize(urldecode($_REQUEST['key'])); |
||
| 591 | } |
||
| 592 | |||
| 593 | if ($confirm) { |
||
| 594 | $this->printTrail($_REQUEST['subject']); |
||
| 595 | $this->printTitle($lang['streditrow']); |
||
| 596 | $this->printMsg($msg); |
||
| 597 | |||
| 598 | $attrs = $data->getTableAttributes($_REQUEST['table']); |
||
| 599 | $rs = $data->browseRow($_REQUEST['table'], $key); |
||
| 600 | |||
| 601 | if (('disable' != $conf['autocomplete'])) { |
||
| 602 | $fksprops = $this->misc->getAutocompleteFKProperties($_REQUEST['table']); |
||
| 603 | if (false !== $fksprops) { |
||
| 604 | echo $fksprops['code']; |
||
| 605 | } |
||
| 606 | } else { |
||
| 607 | $fksprops = false; |
||
| 608 | } |
||
| 609 | |||
| 610 | echo '<form action="' . \SUBFOLDER . '/src/views/display.php" method="post" id="ac_form">' . "\n"; |
||
| 611 | |||
| 612 | /*echo '<p>'; |
||
| 613 | if (!$error) { |
||
| 614 | echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$lang['strsave']}\" />" . "\n"; |
||
| 615 | } |
||
| 616 | |||
| 617 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />" . "\n"; |
||
| 618 | |||
| 619 | echo '</p>' . "\n";*/ |
||
| 620 | |||
| 621 | $elements = 0; |
||
| 622 | $error = true; |
||
| 623 | if (1 == $rs->recordCount() && $attrs->recordCount() > 0) { |
||
| 624 | echo '<table>' . "\n"; |
||
| 625 | |||
| 626 | // Output table header |
||
| 627 | echo "<tr><th class=\"data\">{$lang['strcolumn']}</th><th class=\"data\">{$lang['strtype']}</th>"; |
||
| 628 | echo "<th class=\"data\">{$lang['strformat']}</th>" . "\n"; |
||
| 629 | echo "<th class=\"data\">{$lang['strnull']}</th><th class=\"data\">{$lang['strvalue']}</th></tr>"; |
||
| 630 | |||
| 631 | $i = 0; |
||
| 632 | while (!$attrs->EOF) { |
||
| 633 | $attrs->fields['attnotnull'] = $data->phpBool($attrs->fields['attnotnull']); |
||
| 634 | $id = (0 == ($i % 2) ? '1' : '2'); |
||
| 635 | |||
| 636 | // Initialise variables |
||
| 637 | if (!isset($_REQUEST['format'][$attrs->fields['attname']])) { |
||
| 638 | $_REQUEST['format'][$attrs->fields['attname']] = 'VALUE'; |
||
| 639 | } |
||
| 640 | |||
| 641 | echo "<tr class=\"data{$id}\">" . "\n"; |
||
| 642 | echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>'; |
||
| 643 | echo '<td style="white-space:nowrap;">' . "\n"; |
||
| 644 | echo $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod'])); |
||
| 645 | echo '<input type="hidden" name="types[', htmlspecialchars($attrs->fields['attname']), ']" value="', |
||
| 646 | htmlspecialchars($attrs->fields['type']), '" /></td>'; |
||
| 647 | ++$elements; |
||
| 648 | echo '<td style="white-space:nowrap;">' . "\n"; |
||
| 649 | echo '<select name="format[' . htmlspecialchars($attrs->fields['attname']), ']">' . "\n"; |
||
| 650 | echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$lang['strvalue']}</option>" . "\n"; |
||
| 651 | $selected = ($_REQUEST['format'][$attrs->fields['attname']] == 'EXPRESSION') ? ' selected="selected"' : ''; |
||
| 652 | echo '<option value="EXPRESSION"' . $selected . ">{$lang['strexpression']}</option>" . "\n"; |
||
| 653 | echo "</select>\n</td>" . "\n"; |
||
| 654 | ++$elements; |
||
| 655 | echo '<td style="white-space:nowrap;">'; |
||
| 656 | // Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS) |
||
| 657 | if (!$attrs->fields['attnotnull']) { |
||
| 658 | // Set initial null values |
||
| 659 | if ('confeditrow' == $_REQUEST['action'] && null === $rs->fields[$attrs->fields['attname']]) { |
||
| 660 | $_REQUEST['nulls'][$attrs->fields['attname']] = 'on'; |
||
| 661 | } |
||
| 662 | echo "<label><span><input type=\"checkbox\" name=\"nulls[{$attrs->fields['attname']}]\"", |
||
| 663 | isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>' . "\n"; |
||
| 664 | ++$elements; |
||
| 665 | } else { |
||
| 666 | echo ' </td>'; |
||
| 667 | } |
||
| 668 | |||
| 669 | echo "<td id=\"row_att_{$attrs->fields['attnum']}\" style=\"white-space:nowrap;\">"; |
||
| 670 | |||
| 671 | $extras = []; |
||
| 672 | |||
| 673 | // If the column allows nulls, then we put a JavaScript action on the data field to unset the |
||
| 674 | // NULL checkbox as soon as anything is entered in the field. We use the $elements variable to |
||
| 675 | // keep track of which element offset we're up to. We can't refer to the null checkbox by name |
||
| 676 | // as it contains '[' and ']' characters. |
||
| 677 | if (!$attrs->fields['attnotnull']) { |
||
| 678 | $extras['onChange'] = 'elements[' . ($elements - 1) . '].checked = false;'; |
||
| 679 | } |
||
| 680 | |||
| 681 | if ((false !== $fksprops) && isset($fksprops['byfield'][$attrs->fields['attnum']])) { |
||
| 682 | $extras['id'] = "attr_{$attrs->fields['attnum']}"; |
||
| 683 | $extras['autocomplete'] = 'off'; |
||
| 684 | } |
||
| 685 | |||
| 686 | echo $data->printField("values[{$attrs->fields['attname']}]", $rs->fields[$attrs->fields['attname']], $attrs->fields['type'], $extras); |
||
| 687 | |||
| 688 | echo '</td>'; |
||
| 689 | ++$elements; |
||
| 690 | echo '</tr>' . "\n"; |
||
| 691 | ++$i; |
||
| 692 | $attrs->moveNext(); |
||
| 693 | } |
||
| 694 | echo '</table>' . "\n"; |
||
| 695 | |||
| 696 | $error = false; |
||
| 697 | } elseif (1 != $rs->recordCount()) { |
||
| 698 | echo "<p>{$lang['strrownotunique']}</p>" . "\n"; |
||
| 699 | } else { |
||
| 700 | echo "<p>{$lang['strinvalidparam']}</p>" . "\n"; |
||
| 701 | } |
||
| 702 | |||
| 703 | echo '<input type="hidden" name="action" value="editrow" />' . "\n"; |
||
| 704 | echo $this->misc->form; |
||
| 705 | if (isset($_REQUEST['table'])) { |
||
| 706 | echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . "\n"; |
||
| 707 | } |
||
| 708 | |||
| 709 | if (isset($_REQUEST['subject'])) { |
||
| 710 | echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . "\n"; |
||
| 711 | } |
||
| 712 | |||
| 713 | if (isset($_REQUEST['query'])) { |
||
| 714 | echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . "\n"; |
||
| 715 | } |
||
| 716 | |||
| 717 | if (isset($_REQUEST['count'])) { |
||
| 718 | echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . "\n"; |
||
| 719 | } |
||
| 720 | |||
| 721 | if (isset($_REQUEST['return'])) { |
||
| 722 | echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . "\n"; |
||
| 723 | } |
||
| 724 | |||
| 725 | echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . "\n"; |
||
| 726 | echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . "\n"; |
||
| 727 | echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . "\n"; |
||
| 728 | echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . "\n"; |
||
| 729 | echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />' . "\n"; |
||
| 730 | echo '<p>'; |
||
| 731 | if (!$error) { |
||
| 732 | echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$lang['strsave']}\" />" . "\n"; |
||
| 733 | } |
||
| 734 | |||
| 735 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />" . "\n"; |
||
| 736 | |||
| 737 | if (false !== $fksprops) { |
||
| 738 | if ('default off' != $conf['autocomplete']) { |
||
| 739 | echo "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$lang['strac']}</label>" . "\n"; |
||
| 740 | } else { |
||
| 741 | echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$lang['strac']}</label>" . "\n"; |
||
| 742 | } |
||
| 743 | } |
||
| 744 | |||
| 745 | echo '</p>' . "\n"; |
||
| 746 | echo '</form>' . "\n"; |
||
| 747 | } else { |
||
| 748 | if (!isset($_POST['values'])) { |
||
| 749 | $_POST['values'] = []; |
||
| 750 | } |
||
| 751 | |||
| 752 | if (!isset($_POST['nulls'])) { |
||
| 753 | $_POST['nulls'] = []; |
||
| 754 | } |
||
| 755 | |||
| 756 | $status = $data->editRow( |
||
| 757 | $_POST['table'], |
||
| 758 | $_POST['values'], |
||
| 759 | $_POST['nulls'], |
||
| 760 | $_POST['format'], |
||
| 761 | $_POST['types'], |
||
| 762 | $key |
||
| 763 | ); |
||
| 764 | if (0 == $status) { |
||
| 765 | $this->doBrowse($lang['strrowupdated']); |
||
| 766 | } elseif ($status == -2) { |
||
| 767 | $this->doEditRow(true, $lang['strrownotunique']); |
||
| 768 | } else { |
||
| 769 | $this->doEditRow(true, $lang['strrowupdatedbad']); |
||
| 770 | } |
||
| 771 | } |
||
| 772 | } |
||
| 773 | |||
| 774 | /** |
||
| 775 | * Show confirmation of drop and perform actual drop. |
||
| 776 | * |
||
| 777 | * @param mixed $confirm |
||
|
1 ignored issue
–
show
|
|||
| 778 | */ |
||
| 779 | public function doDelRow($confirm) |
||
| 780 | { |
||
| 781 | $lang = $this->lang; |
||
| 782 | $data = $this->misc->getDatabaseAccessor(); |
||
| 783 | |||
| 784 | if ($confirm) { |
||
| 785 | $this->printTrail($_REQUEST['subject']); |
||
| 786 | $this->printTitle($lang['strdeleterow']); |
||
| 787 | |||
| 788 | $rs = $data->browseRow($_REQUEST['table'], $_REQUEST['key']); |
||
| 789 | |||
| 790 | echo '<form action="' . \SUBFOLDER . '/src/views/display.php" method="post">' . "\n"; |
||
| 791 | echo $this->misc->form; |
||
| 792 | |||
| 793 | if (1 == $rs->recordCount()) { |
||
| 794 | echo "<p>{$lang['strconfdeleterow']}</p>" . "\n"; |
||
| 795 | |||
| 796 | $fkinfo = []; |
||
| 797 | echo '<table><tr>'; |
||
| 798 | $this->printTableHeaderCells($rs, false, true); |
||
| 799 | echo '</tr>'; |
||
| 800 | echo '<tr class="data1">' . "\n"; |
||
| 801 | $this->printTableRowCells($rs, $fkinfo, true); |
||
| 802 | echo '</tr>' . "\n"; |
||
| 803 | echo '</table>' . "\n"; |
||
| 804 | echo '<br />' . "\n"; |
||
| 805 | |||
| 806 | echo '<input type="hidden" name="action" value="delrow" />' . "\n"; |
||
| 807 | echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />" . "\n"; |
||
| 808 | echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />" . "\n"; |
||
| 809 | } elseif (1 != $rs->recordCount()) { |
||
| 810 | echo "<p>{$lang['strrownotunique']}</p>" . "\n"; |
||
| 811 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />" . "\n"; |
||
| 812 | } else { |
||
| 813 | echo "<p>{$lang['strinvalidparam']}</p>" . "\n"; |
||
| 814 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />" . "\n"; |
||
| 815 | } |
||
| 816 | if (isset($_REQUEST['table'])) { |
||
| 817 | echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . "\n"; |
||
| 818 | } |
||
| 819 | |||
| 820 | if (isset($_REQUEST['subject'])) { |
||
| 821 | echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . "\n"; |
||
| 822 | } |
||
| 823 | |||
| 824 | if (isset($_REQUEST['query'])) { |
||
| 825 | echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . "\n"; |
||
| 826 | } |
||
| 827 | |||
| 828 | if (isset($_REQUEST['count'])) { |
||
| 829 | echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . "\n"; |
||
| 830 | } |
||
| 831 | |||
| 832 | if (isset($_REQUEST['return'])) { |
||
| 833 | echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . "\n"; |
||
| 834 | } |
||
| 835 | |||
| 836 | echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . "\n"; |
||
| 837 | echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . "\n"; |
||
| 838 | echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . "\n"; |
||
| 839 | echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . "\n"; |
||
| 840 | echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />' . "\n"; |
||
| 841 | echo '</form>' . "\n"; |
||
| 842 | } else { |
||
| 843 | $status = $data->deleteRow($_POST['table'], unserialize(urldecode($_POST['key']))); |
||
| 844 | if (0 == $status) { |
||
| 845 | $this->doBrowse($lang['strrowdeleted']); |
||
| 846 | } elseif ($status == -2) { |
||
| 847 | $this->doBrowse($lang['strrownotunique']); |
||
| 848 | } else { |
||
| 849 | $this->doBrowse($lang['strrowdeletedbad']); |
||
| 850 | } |
||
| 851 | } |
||
| 852 | } |
||
| 853 | |||
| 854 | /** |
||
| 855 | * build & return the FK information data structure |
||
|
1 ignored issue
–
show
|
|||
| 856 | * used when deciding if a field should have a FK link or not. |
||
| 857 | * |
||
| 858 | * @return [type] [description] |
||
| 859 | */ |
||
| 860 | public function &getFKInfo() |
||
| 861 | { |
||
| 862 | $lang = $this->lang; |
||
| 863 | $data = $this->misc->getDatabaseAccessor(); |
||
| 864 | |||
| 865 | // Get the foreign key(s) information from the current table |
||
| 866 | $fkey_information = ['byconstr' => [], 'byfield' => []]; |
||
| 867 | |||
| 868 | if (isset($_REQUEST['table'])) { |
||
| 869 | $constraints = $data->getConstraintsWithFields($_REQUEST['table']); |
||
| 870 | if ($constraints->recordCount() > 0) { |
||
| 871 | $fkey_information['common_url'] = $this->misc->getHREF('schema') . '&subject=table'; |
||
| 872 | |||
| 873 | // build the FK constraints data structure |
||
| 874 | while (!$constraints->EOF) { |
||
| 875 | $constr = &$constraints->fields; |
||
| 876 | if ('f' == $constr['contype']) { |
||
| 877 | if (!isset($fkey_information['byconstr'][$constr['conid']])) { |
||
| 878 | $fkey_information['byconstr'][$constr['conid']] = [ |
||
| 879 | 'url_data' => 'table=' . urlencode($constr['f_table']) . '&schema=' . urlencode($constr['f_schema']), |
||
| 880 | 'fkeys' => [], |
||
| 881 | 'consrc' => $constr['consrc'], |
||
| 882 | ]; |
||
| 883 | } |
||
| 884 | |||
| 885 | $fkey_information['byconstr'][$constr['conid']]['fkeys'][$constr['p_field']] = $constr['f_field']; |
||
| 886 | |||
| 887 | if (!isset($fkey_information['byfield'][$constr['p_field']])) { |
||
| 888 | $fkey_information['byfield'][$constr['p_field']] = []; |
||
| 889 | } |
||
| 890 | |||
| 891 | $fkey_information['byfield'][$constr['p_field']][] = $constr['conid']; |
||
| 892 | } |
||
| 893 | $constraints->moveNext(); |
||
| 894 | } |
||
| 895 | } |
||
| 896 | } |
||
| 897 | |||
| 898 | return $fkey_information; |
||
| 899 | } |
||
| 900 | |||
| 901 | /** |
||
| 902 | * Print table header cells. |
||
| 903 | * |
||
| 904 | * @param $args - associative array for sort link parameters |
||
| 905 | * @param mixed $withOid |
||
|
1 ignored issue
–
show
|
|||
| 906 | */ |
||
| 907 | public function printTableHeaderCells(&$rs, $args, $withOid) |
||
| 908 | { |
||
| 909 | $lang = $this->lang; |
||
| 910 | $data = $this->misc->getDatabaseAccessor(); |
||
| 911 | $j = 0; |
||
| 912 | |||
| 913 | foreach ($rs->fields as $k => $v) { |
||
| 914 | if (($k === $data->id) && (!($withOid && $conf['show_oids']))) { |
||
| 915 | ++$j; |
||
| 916 | |||
| 917 | continue; |
||
| 918 | } |
||
| 919 | $finfo = $rs->fetchField($j); |
||
| 920 | |||
| 921 | if (false === $args) { |
||
| 922 | echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>' . "\n"; |
||
| 923 | } else { |
||
| 924 | $args['page'] = $_REQUEST['page']; |
||
| 925 | $args['sortkey'] = $j + 1; |
||
| 926 | // Sort direction opposite to current direction, unless it's currently '' |
||
| 927 | $args['sortdir'] = ( |
||
| 928 | 'asc' == $_REQUEST['sortdir'] |
||
| 929 | and $_REQUEST['sortkey'] == ($j + 1) |
||
| 930 | ) ? 'desc' : 'asc'; |
||
| 931 | |||
| 932 | $sortLink = http_build_query($args); |
||
| 933 | |||
| 934 | echo "<th class=\"data\"><a href=\"?{$sortLink}\">" |
||
| 935 | , $this->misc->printVal($finfo->name); |
||
| 936 | if ($_REQUEST['sortkey'] == ($j + 1)) { |
||
| 937 | if ('asc' == $_REQUEST['sortdir']) { |
||
| 938 | echo '<img src="' . $this->misc->icon('RaiseArgument') . '" alt="asc">'; |
||
| 939 | } else { |
||
| 940 | echo '<img src="' . $this->misc->icon('LowerArgument') . '" alt="desc">'; |
||
| 941 | } |
||
| 942 | } |
||
| 943 | echo '</a></th>' . "\n"; |
||
| 944 | } |
||
| 945 | ++$j; |
||
| 946 | } |
||
| 947 | |||
| 948 | reset($rs->fields); |
||
| 949 | } |
||
| 950 | |||
| 951 | // Print data-row cells |
||
| 952 | public function printTableRowCells(&$rs, &$fkey_information, $withOid) |
||
|
1 ignored issue
–
show
|
|||
| 953 | { |
||
| 954 | $lang = $this->lang; |
||
| 955 | $data = $this->misc->getDatabaseAccessor(); |
||
| 956 | $j = 0; |
||
| 957 | |||
| 958 | if (!isset($_REQUEST['strings'])) { |
||
| 959 | $_REQUEST['strings'] = 'collapsed'; |
||
| 960 | } |
||
| 961 | |||
| 962 | foreach ($rs->fields as $k => $v) { |
||
| 963 | $finfo = $rs->fetchField($j++); |
||
| 964 | |||
| 965 | if (($k === $data->id) && (!($withOid && $conf['show_oids']))) { |
||
| 966 | continue; |
||
| 967 | } |
||
| 968 | if (null !== $v && '' == $v) { |
||
| 969 | echo '<td> </td>'; |
||
| 970 | } else { |
||
| 971 | echo '<td style="white-space:nowrap;">'; |
||
| 972 | |||
| 973 | if ((null !== $v) && isset($fkey_information['byfield'][$k])) { |
||
| 974 | foreach ($fkey_information['byfield'][$k] as $conid) { |
||
| 975 | $query_params = $fkey_information['byconstr'][$conid]['url_data']; |
||
| 976 | |||
| 977 | foreach ($fkey_information['byconstr'][$conid]['fkeys'] as $p_field => $f_field) { |
||
| 978 | $query_params .= '&' . urlencode("fkey[{$f_field}]") . '=' . urlencode($rs->fields[$p_field]); |
||
| 979 | } |
||
| 980 | |||
| 981 | // $fkey_information['common_url'] is already urlencoded |
||
| 982 | $query_params .= '&' . $fkey_information['common_url']; |
||
| 983 | echo '<div style="display:inline-block;">'; |
||
| 984 | echo '<a class="fk fk_' . htmlentities($conid, ENT_QUOTES, 'UTF-8') . "\" href=\"display.php?{$query_params}\">"; |
||
| 985 | echo '<img src="' . $this->misc->icon('ForeignKey') . '" style="vertical-align:middle;" alt="[fk]" title="' |
||
| 986 | . htmlentities($fkey_information['byconstr'][$conid]['consrc'], ENT_QUOTES, 'UTF-8') |
||
| 987 | . '" />'; |
||
| 988 | echo '</a>'; |
||
| 989 | echo '</div>'; |
||
| 990 | } |
||
| 991 | echo $this->misc->printVal($v, $finfo->type, ['null' => true, 'clip' => ('collapsed' == $_REQUEST['strings']), 'class' => 'fk_value']); |
||
| 992 | } else { |
||
| 993 | echo $this->misc->printVal($v, $finfo->type, ['null' => true, 'clip' => ('collapsed' == $_REQUEST['strings'])]); |
||
| 994 | } |
||
| 995 | echo '</td>'; |
||
| 996 | } |
||
| 997 | } |
||
| 998 | } |
||
| 999 | |||
| 1000 | // Print the FK row, used in ajax requests |
||
| 1001 | public function doBrowseFK() |
||
| 1047 | } |
||
| 1048 | } |
||
| 1049 |