Rev 684 | Rev 693 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 684 | Rev 692 | ||
---|---|---|---|
Line 436... | Line 436... | ||
436 | } |
436 | } |
437 | } |
437 | } |
438 | 438 | ||
439 | public function init($html=true) { |
439 | public function init($html=true) { |
440 | OIDplus::config()->prepareConfigKey('oobe_objects_done', '"Out Of Box Experience" wizard for OIDplusPagePublicObjects done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {}); |
440 | OIDplus::config()->prepareConfigKey('oobe_objects_done', '"Out Of Box Experience" wizard for OIDplusPagePublicObjects done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {}); |
- | 441 | OIDplus::config()->prepareConfigKey('oid_grid_show_weid', 'Show WEID/Base36 column in CRUD grid of OIDs?', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
|
- | 442 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
|
- | 443 | throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).')); |
|
- | 444 | } |
|
- | 445 | }); |
|
441 | } |
446 | } |
442 | 447 | ||
443 | public function gui($id, &$out, &$handled) { |
448 | public function gui($id, &$out, &$handled) { |
444 | if ($id === 'oidplus:system') { |
449 | if ($id === 'oidplus:system') { |
445 | $handled = true; |
450 | $handled = true; |
Line 810... | Line 815... | ||
810 | $result = OIDplus::db()->query("select o.*, r.ra_name " . |
815 | $result = OIDplus::db()->query("select o.*, r.ra_name " . |
811 | "from ###objects o " . |
816 | "from ###objects o " . |
812 | "left join ###ra r on r.email = o.ra_email " . |
817 | "left join ###ra r on r.email = o.ra_email " . |
813 | "where parent = ? " . |
818 | "where parent = ? " . |
814 | "order by ".OIDplus::db()->natOrder('id'), array($parent)); |
819 | "order by ".OIDplus::db()->natOrder('id'), array($parent)); |
- | 820 | ||
815 | $rows = array(); |
821 | $rows = array(); |
816 | if ($parentNS == 'weid') { |
- | |
817 | // Custom plugin for registry.frdl.de: |
- | |
818 | // Parent NS (oid:) is *NOT* equal to child NS (weid:) |
- | |
819 | $one_weid_available = true; |
- | |
820 | while ($row = $result->fetch_object()) { |
822 | while ($row = $result->fetch_object()) { |
821 | $obj = OIDplusObject::parse($row->id); |
823 | $obj = OIDplusObject::parse($row->id); |
822 | $rows[] = array($obj,$row); |
824 | $rows[] = array($obj,$row); |
823 | } |
825 | } |
824 | } else if (($parentNS == 'oid') && ($parent != 'oid:')) { |
- | |
825 | // TODO: The admin should be able to disable the "Base36" feature!!! |
- | |
826 | $one_weid_available = $objParent->isWeid(true); |
- | |
827 | while ($row = $result->fetch_object()) { |
- | |
828 | $obj = OIDplusObject::parse($row->id); |
- | |
829 | $rows[] = array($obj,$row); |
- | |
830 | if (!$one_weid_available) { |
- | |
831 | if ($obj->isWeid(true)) $one_weid_available = true; |
- | |
832 | } |
- | |
833 | } |
826 | |
834 | } else { |
- | |
835 | $one_weid_available = false; |
- | |
836 | while ($row = $result->fetch_object()) { |
- | |
837 | $obj = OIDplusObject::parse($row->id); |
827 | $enable_weid_presentation = OIDplus::config()->getValue('oid_grid_show_weid'); |
838 | $rows[] = array($obj,$row); |
- | |
839 | } |
- | |
840 | } |
- | |
841 | 828 | ||
842 | $output = ''; |
829 | $output = ''; |
843 | $output .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
830 | $output .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
844 | $output .= '<table class="table table-bordered table-striped">'; |
831 | $output .= '<table class="table table-bordered table-striped">'; |
845 | $output .= ' <tr>'; |
832 | $output .= ' <tr>'; |
846 | $output .= ' <th>'._L('ID').(($parentNS == 'gs1') ? ' '._L('(without check digit)') : '').'</th>'; |
833 | $output .= ' <th>'._L('ID').(($parentNS == 'gs1') ? ' '._L('(without check digit)') : '').'</th>'; |
- | 834 | if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) { |
|
847 | if ($one_weid_available) $output .= ' <th><abbr title="'._L('Binary-to-text encoding used for WEIDs').'">'._L('Base36').'</a></th>'; |
835 | $output .= ' <th><abbr title="'._L('Binary-to-text encoding used for WEIDs').'">'._L('Base36').'</abbr></th>'; |
- | 836 | } |
|
848 | if ($parentNS == 'oid') { |
837 | if ($parentNS == 'oid') { |
849 | if ($accepts_asn1) $output .= ' <th>'._L('ASN.1 IDs (comma sep.)').'</th>'; |
838 | if ($accepts_asn1) $output .= ' <th>'._L('ASN.1 IDs (comma sep.)').'</th>'; |
850 | if ($accepts_iri) $output .= ' <th>'._L('IRI IDs (comma sep.)').'</th>'; |
839 | if ($accepts_iri) $output .= ' <th>'._L('IRI IDs (comma sep.)').'</th>'; |
851 | } |
840 | } |
852 | $output .= ' <th>'._L('RA').'</th>'; |
841 | $output .= ' <th>'._L('RA').'</th>'; |
Line 883... | Line 872... | ||
883 | 872 | ||
884 | $date_created = explode(' ', $row->created)[0] == '0000-00-00' ? '' : explode(' ', $row->created)[0]; |
873 | $date_created = explode(' ', $row->created)[0] == '0000-00-00' ? '' : explode(' ', $row->created)[0]; |
885 | $date_updated = explode(' ', $row->updated)[0] == '0000-00-00' ? '' : explode(' ', $row->updated)[0]; |
874 | $date_updated = explode(' ', $row->updated)[0] == '0000-00-00' ? '' : explode(' ', $row->updated)[0]; |
886 | 875 | ||
887 | $output .= '<tr>'; |
876 | $output .= '<tr>'; |
888 | $output .= ' <td><a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.htmlentities($show_id).'</a></td>'; |
877 | $output .= ' <td><a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.htmlentities($show_id).'</a>'; |
889 | if ($objParent->userHasWriteRights()) { |
878 | if ($enable_weid_presentation && ($parentNS == 'oid') && $objParent->isRoot()) { |
890 | if ($one_weid_available) { |
879 | // To save space horizontal space, the WEIDs were written below the OIDs |
891 | if ($obj->isWeid(false)) { |
- | |
892 | $output .= ' <td>'.$obj->weidArc().'</td>'; |
880 | $output .= '<br>'.$obj->getWeidNotation(true); |
893 | } else { |
881 | } |
- | 882 | $output .= '</td>'; |
|
- | 883 | if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) { |
|
894 | $output .= ' <td>'._L('n/a').'</td>'; |
884 | $output .= ' <td>'.htmlentities($obj->weidArc()).'</td>'; |
895 | } |
- | |
896 | } |
885 | } |
- | 886 | if ($objParent->userHasWriteRights()) { |
|
897 | if ($parentNS == 'oid') { |
887 | if ($parentNS == 'oid') { |
898 | if ($accepts_asn1) $output .= ' <td><input type="text" id="asn1ids_'.$row->id.'" value="'.implode(', ', $asn1ids).'"></td>'; |
888 | if ($accepts_asn1) $output .= ' <td><input type="text" id="asn1ids_'.$row->id.'" value="'.implode(', ', $asn1ids).'"></td>'; |
899 | if ($accepts_iri) $output .= ' <td><input type="text" id="iris_'.$row->id.'" value="'.implode(', ', $iris).'"></td>'; |
889 | if ($accepts_iri) $output .= ' <td><input type="text" id="iris_'.$row->id.'" value="'.implode(', ', $iris).'"></td>'; |
900 | } |
890 | } |
901 | $output .= ' <td><input type="text" id="ra_email_'.$row->id.'" value="'.htmlentities($row->ra_email).'"></td>'; |
891 | $output .= ' <td><input type="text" id="ra_email_'.$row->id.'" value="'.htmlentities($row->ra_email).'"></td>'; |
Line 904... | Line 894... | ||
904 | $output .= ' <td><button type="button" name="update_'.$row->id.'" id="update_'.$row->id.'" class="btn btn-success btn-xs update" onclick="OIDplusPagePublicObjects.crudActionUpdate('.js_escape($row->id).', '.js_escape($parent).')">'._L('Update').'</button></td>'; |
894 | $output .= ' <td><button type="button" name="update_'.$row->id.'" id="update_'.$row->id.'" class="btn btn-success btn-xs update" onclick="OIDplusPagePublicObjects.crudActionUpdate('.js_escape($row->id).', '.js_escape($parent).')">'._L('Update').'</button></td>'; |
905 | $output .= ' <td><button type="button" name="delete_'.$row->id.'" id="delete_'.$row->id.'" class="btn btn-danger btn-xs delete" onclick="OIDplusPagePublicObjects.crudActionDelete('.js_escape($row->id).', '.js_escape($parent).')">'._L('Delete').'</button></td>'; |
895 | $output .= ' <td><button type="button" name="delete_'.$row->id.'" id="delete_'.$row->id.'" class="btn btn-danger btn-xs delete" onclick="OIDplusPagePublicObjects.crudActionDelete('.js_escape($row->id).', '.js_escape($parent).')">'._L('Delete').'</button></td>'; |
906 | $output .= ' <td>'.$date_created.'</td>'; |
896 | $output .= ' <td>'.$date_created.'</td>'; |
907 | $output .= ' <td>'.$date_updated.'</td>'; |
897 | $output .= ' <td>'.$date_updated.'</td>'; |
908 | } else { |
898 | } else { |
- | 899 | if ($parentNS == 'oid') { |
|
909 | if ($asn1ids == '') $asn1ids = '<i>'._L('(none)').'</i>'; |
900 | if ($asn1ids == '') $asn1ids = '<i>'._L('(none)').'</i>'; |
910 | if ($iris == '') $iris = '<i>'._L('(none)').'</i>'; |
901 | if ($iris == '') $iris = '<i>'._L('(none)').'</i>'; |
911 | if ($one_weid_available) { |
- | |
912 | if ($obj->isWeid(false)) { |
- | |
913 | $output .= ' <td>'.$obj->weidArc().'</td>'; |
- | |
914 | } else { |
- | |
915 | $output .= ' <td>'._L('n/a').'</td>'; |
- | |
916 | } |
- | |
917 | } |
- | |
918 | if ($parentNS == 'oid') { |
- | |
919 | $asn1ids_ext = array(); |
902 | $asn1ids_ext = array(); |
920 | foreach ($asn1ids as $asn1id) { |
903 | foreach ($asn1ids as $asn1id) { |
921 | $asn1ids_ext[] = '<a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.$asn1id.'</a>'; |
904 | $asn1ids_ext[] = '<a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.$asn1id.'</a>'; |
922 | } |
905 | } |
923 | if ($accepts_asn1) $output .= ' <td>'.implode(', ', $asn1ids_ext).'</td>'; |
906 | if ($accepts_asn1) $output .= ' <td>'.implode(', ', $asn1ids_ext).'</td>'; |
Line 932... | Line 915... | ||
932 | } |
915 | } |
933 | 916 | ||
934 | $result = OIDplus::db()->query("select * from ###objects where id = ?", array($parent)); |
917 | $result = OIDplus::db()->query("select * from ###objects where id = ?", array($parent)); |
935 | $parent_ra_email = $result->num_rows() > 0 ? $result->fetch_object()->ra_email : ''; |
918 | $parent_ra_email = $result->num_rows() > 0 ? $result->fetch_object()->ra_email : ''; |
936 | 919 | ||
- | 920 | // "Create OID" row |
|
937 | if ($objParent->userHasWriteRights()) { |
921 | if ($objParent->userHasWriteRights()) { |
938 | $output .= '<tr>'; |
922 | $output .= '<tr>'; |
939 | $prefix = is_null($objParent) ? '' : $objParent->crudInsertPrefix(); |
923 | $prefix = is_null($objParent) ? '' : $objParent->crudInsertPrefix(); |
940 | if ($parentNS == 'weid') { |
924 | if ($parentNS == 'guid') { |
- | 925 | if ($objParent->isRoot()) { |
|
- | 926 | // TODO: Should we give ObjectType plugins the ability to define such "Generate" links? (Via feature-interface?) |
|
941 | $output .= ' <td>'.$prefix.' <input oninput="OIDplusPagePublicObjects.frdl_oidid_change()" type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; |
927 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:275px"><br><a href="javascript:OIDplusPagePublicObjects.generateRandomGUID(false)">'._L('(Generate random GUID)').'</a></td>'; |
- | 928 | } else { |
|
942 | $output .= ' <td><input type="text" name="weid" id="weid" value="" oninput="OIDplusPagePublicObjects.frdl_weid_change()" style="width:100%;min-width:100px"></td>'; |
929 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:275px"></td>'; |
- | 930 | } |
|
- | 931 | } |
|
943 | } else if ($parentNS == 'oid') { |
932 | if ($parentNS == 'oid') { |
944 | // TODO: Idea: Give a class name, e.g. "OID" and then with a oid-specific CSS make the width individual. So, every plugin has more control over the appearance and widths of the input fields |
933 | // TODO: Idea: Give a class name, e.g. "OID" and then with a oid-specific CSS make the width individual. So, every plugin has more control over the appearance and widths of the input fields |
- | 934 | if ($objParent->nodeId() === 'oid:2.25') { |
|
- | 935 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:345px"><br><a href="javascript:OIDplusPagePublicObjects.generateRandomUUID(false)">'._L('(Generate random UUID OID)').'</a></td>'; |
|
- | 936 | if ($enable_weid_presentation) $output .= ' <td> </td>'; // For UUID-OIDs, you must generate a valid one. Don't be tempted to create one using the Base36 input! |
|
945 | if ($objParent->isWeid(false)) { |
937 | } else if ($objParent->isRoot()) { |
- | 938 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:345px"><br><a href="javascript:OIDplusPagePublicObjects.generateRandomUUID(true)">'._L('(Generate random UUID OID)').'</a></td>'; |
|
- | 939 | if ($enable_weid_presentation) $output .= ''; // WEID-editor not available for root nodes at the moment. For the moment you need to enter the OID (TODO: Create JavaScript WEID encoder/decoder) |
|
- | 940 | } else { |
|
- | 941 | if ($enable_weid_presentation) { |
|
946 | $output .= ' <td>'.$prefix.' <input oninput="OIDplusPagePublicObjects.frdl_oidid_change()" type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; |
942 | $output .= ' <td>'.$prefix.' <input oninput="OIDplusPagePublicObjects.frdl_oidid_change()" type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; |
947 | $output .= ' <td><input type="text" name="weid" id="weid" value="" oninput="OIDplusPagePublicObjects.frdl_weid_change()" style="width:100%;min-width:100px"></td>'; |
943 | $output .= ' <td><input type="text" name="weid" id="weid" value="" oninput="OIDplusPagePublicObjects.frdl_weid_change()" style="width:100%;min-width:100px"></td>'; |
948 | } else if ($objParent->nodeId() === 'oid:2.25') { |
- | |
949 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:340px"><a href="javascript:OIDplusPagePublicObjects.generateRandomUUID()">'._L('(Generate)').'</a></td>'; |
- | |
950 | if ($one_weid_available) $output .= ' <td></td>'; // WEID-editor not available for root nodes. Do it manually, please |
- | |
951 | } else { |
944 | } else { |
952 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:50px"></td>'; |
945 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; |
953 | if ($one_weid_available) $output .= ' <td></td>'; // WEID-editor not available for root nodes. Do it manually, please |
- | |
- | 946 | } |
|
954 | } |
947 | } |
955 | } else { |
948 | } else { |
956 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; |
949 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; |
957 | } |
950 | } |
958 | if ($accepts_asn1) $output .= ' <td><input type="text" id="asn1ids" value=""></td>'; |
951 | if ($accepts_asn1) $output .= ' <td><input type="text" id="asn1ids" value=""></td>'; |
Line 966... | Line 959... | ||
966 | $output .= ' <td></td>'; |
959 | $output .= ' <td></td>'; |
967 | $output .= '</tr>'; |
960 | $output .= '</tr>'; |
968 | } else { |
961 | } else { |
969 | if ($items_total-$items_hidden == 0) { |
962 | if ($items_total-$items_hidden == 0) { |
970 | $cols = ($parentNS == 'oid') ? 7 : 5; |
963 | $cols = ($parentNS == 'oid') ? 7 : 5; |
- | 964 | if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) { |
|
971 | if ($one_weid_available) $cols++; |
965 | $cols++; |
- | 966 | } |
|
972 | $output .= '<tr><td colspan="'.$cols.'">'._L('No items available').'</td></tr>'; |
967 | $output .= '<tr><td colspan="'.$cols.'">'._L('No items available').'</td></tr>'; |
973 | } |
968 | } |
974 | } |
969 | } |
975 | 970 | ||
976 | $output .= '</table>'; |
971 | $output .= '</table>'; |