summaryrefslogtreecommitdiff
path: root/edit.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-11 19:26:25 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-11 19:26:25 +0100
commit64aae1e41d9288a6d9709781af29b06fe6adb5ca (patch)
treed5d5e74420cee938d7e8ff90b9e6792d5f44cc77 /edit.php
parent27c615a0a26edb985543e520587e3043d91489f6 (diff)
downloadcontact-64aae1e41d9288a6d9709781af29b06fe6adb5ca.tar.gz
contact-64aae1e41d9288a6d9709781af29b06fe6adb5ca.tar.bz2
contact-64aae1e41d9288a6d9709781af29b06fe6adb5ca.zip
Introduce ContactPerson and ContactBusiness subclasses
Splits the Contact class into ContactPerson (content_type_guid='contactperson') and ContactBusiness (content_type_guid='contactbusiness'), each using 'contact' as the shared package-level xref schema. Replaces the $isPerson/$00 xref hack with proper class identity via instanceof. - ContactPerson.php, ContactBusiness.php: new subclasses - Contact.php: loadXrefTypeList() reads type tags directly from liberty_xref; getAvailableTypeItems() for edit form (schema-driven with pre-upgrade fallback); getDisplayUrl() now points to display_contact.php - Type item codes: P01/P02 (person), B01-B04 (business, B01=Service new) - list_people.php, list_businesses.php: separate list pages per type - list_contacts.php: combined display-layer merge of both types - 5.0.3.php: upgrade script migrating existing data to new content types and codes - Templates: isPerson flag from instanceof; horizontal type checkboxes; list.tpl accepts $listTitle; menu adds People/Businesses entries Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'edit.php')
-rwxr-xr-xedit.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/edit.php b/edit.php
index 6bea6aa..4b47446 100755
--- a/edit.php
+++ b/edit.php
@@ -73,15 +73,28 @@ if( empty( $formInfo ) ) {
$formInfo = &$gContent->mInfo;
}
-$isPerson = !empty( $gContent->mInfo['contact_types'][0]['content_id'] );
+$isPerson = $gContent instanceof \Bitweaver\Contact\ContactPerson;
$gContent->loadXrefInfo();
$gBitSmarty->assign( 'gXrefInfo', $gContent->mXrefInfo );
$gBitSmarty->assign( 'isPerson', $isPerson );
-$allTypes = $gContent->getXrefSourceList();
-$formInfo['contact_type_list'] = $isPerson
- ? []
- : array_values( array_filter( $allTypes, fn($t) => $t['item'] > '$01' ) );
+// Build type toggle list: available options from schema (or hard-coded pre-upgrade fallback),
+// checked state from contact_types (currently set items in liberty_xref).
+$setItems = [];
+foreach ( $gContent->mInfo['contact_types'] ?? [] as $ct ) {
+ if ( !empty( $ct['content_id'] ) ) {
+ $setItems[ $ct['item'] ] = true;
+ }
+}
+$typeToggle = [];
+foreach ( $gContent->getAvailableTypeItems() as $m ) {
+ $typeToggle[] = [
+ 'item' => $m['item'],
+ 'name' => $m['name'],
+ 'checked' => isset( $setItems[ $m['item'] ] ),
+ ];
+}
+$gContent->mInfo['contact_type_list'] = $typeToggle;
$gBitSmarty->assign( 'pageInfo', $formInfo );
$gBitSmarty->assign( 'errors', $gContent->mErrors );