diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-29 13:57:26 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-29 13:57:26 +0100 |
| commit | 3d94c3dfe203edeb25b42466733672aff9fca89f (patch) | |
| tree | be8aaf92d49b2f825a1da88c847e9c013da2d71a /includes | |
| parent | 2fb898ce714e282f5dfca365fe52abc15437f7ef (diff) | |
| download | liberty-3d94c3dfe203edeb25b42466733672aff9fca89f.tar.gz liberty-3d94c3dfe203edeb25b42466733672aff9fca89f.tar.bz2 liberty-3d94c3dfe203edeb25b42466733672aff9fca89f.zip | |
BOM parts list support: xref template dispatch and LibertyXref fixes
- LibertyContent: add getXrefListTemplate(), getXrefRecordTemplate(),
getXrefEditTemplate() for package-aware template dispatch with liberty fallback
- LibertyXref: explicit xorder passthrough in verify(); fix start_date/end_date
to use time() instead of mDb->NOW() so BitDate::date() receives a timestamp
- add_xref.php, edit_xref.php: redirect to getEditUrl() after save/cancel
- list_xref.tpl: use getXrefRecordTemplate() instead of hardcoded liberty path
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/classes/LibertyContent.php | 37 | ||||
| -rw-r--r-- | includes/classes/LibertyXref.php | 7 |
2 files changed, 41 insertions, 3 deletions
diff --git a/includes/classes/LibertyContent.php b/includes/classes/LibertyContent.php index 99659e0..9f79e45 100755 --- a/includes/classes/LibertyContent.php +++ b/includes/classes/LibertyContent.php @@ -2155,6 +2155,43 @@ class LibertyContent extends LibertyBase implements BitCacheable { * @param number $pContentId a valid content id * @param array $pMixed a hash of params to add to the url */ + public function getXrefListTemplate( ?string $pTemplate = null ): string { + if( $pTemplate ) { + $package = $this->mType['handler_package'] ?? 'liberty'; + $pkgConst = strtoupper( $package ).'_PKG_PATH'; + if( defined( $pkgConst ) && file_exists( constant( $pkgConst ).'templates/list_xref_'.$pTemplate.'.tpl' ) ) { + return 'bitpackage:'.$package.'/list_xref_'.$pTemplate.'.tpl'; + } + } + return 'bitpackage:liberty/list_xref.tpl'; + } + + public function getXrefRecordTemplate( ?string $pTemplate = null ): string { + $pTemplate = $pTemplate ?: 'text'; + $package = $this->mType['handler_package'] ?? 'liberty'; + $pkgConst = strtoupper( $package ).'_PKG_PATH'; + if( defined( $pkgConst ) ) { + $pkgTpl = constant( $pkgConst ).'templates/view_xref_'.$pTemplate.'_record.tpl'; + if( file_exists( $pkgTpl ) ) { + return 'bitpackage:'.$package.'/view_xref_'.$pTemplate.'_record.tpl'; + } + } + return 'bitpackage:liberty/view_xref_'.$pTemplate.'_record.tpl'; + } + + public function getXrefEditTemplate( ?string $pTemplate = null ): string { + $pTemplate = $pTemplate ?: 'text'; + $package = $this->mType['handler_package'] ?? 'liberty'; + $pkgConst = strtoupper( $package ).'_PKG_PATH'; + if( defined( $pkgConst ) ) { + $pkgTpl = constant( $pkgConst ).'templates/edit_xref_'.$pTemplate.'.tpl'; + if( file_exists( $pkgTpl ) ) { + return 'bitpackage:'.$package.'/edit_xref_'.$pTemplate.'.tpl'; + } + } + return 'bitpackage:liberty/edit_xref.tpl'; + } + public function getEditUrl( $pContentId = null, $pMixed = null ){ global $gLibertySystem; $package = $gLibertySystem->mContentTypes[$this->mType['content_type_guid']]['handler_package']; diff --git a/includes/classes/LibertyXref.php b/includes/classes/LibertyXref.php index 5327351..2473507 100644 --- a/includes/classes/LibertyXref.php +++ b/includes/classes/LibertyXref.php @@ -92,7 +92,7 @@ class LibertyXref extends LibertyBase { $pParamHash['xref_store']['item'] = $this->mItem; $pParamHash['xref_store']['xorder'] = $this->mInfo['data']['xorder'] + 1; $pParamHash['xref_store']['content_id'] = $this->mContentId; - $pParamHash['start_date'] = $this->mDb->NOW(); + $pParamHash['start_date'] = time(); $pParamHash['ignore_end_date'] = 'on'; $pParamHash['xref_store']['xref'] = 0; $pParamHash['xref_store']['xkey'] = ''; @@ -100,6 +100,7 @@ class LibertyXref extends LibertyBase { $pParamHash['xref_store']['data'] = ''; } + if( isset( $pParamHash['xorder'] ) ) { $pParamHash['xref_store']['xorder'] = (int)$pParamHash['xorder']; } if( isset( $pParamHash['xref'] ) ) { $pParamHash['xref_store']['xref'] = $pParamHash['xref']; } if( isset( $pParamHash['xkey'] ) ) { $pParamHash['xref_store']['xkey'] = $pParamHash['xkey']; } if( isset( $pParamHash['xkey_ext'] ) ) { $pParamHash['xref_store']['xkey_ext'] = $pParamHash['xkey_ext']; } @@ -163,13 +164,13 @@ class LibertyXref extends LibertyBase { if( isset( $pParamHash["expunge"] ) ) { switch( $pParamHash["expunge"] ) { case 2: - $pParamHash['end_date'] = $this->mDb->NOW(); + $pParamHash['end_date'] = time(); $this->store( $pParamHash ); unset( $pParamHash['xref_id'] ); $pParamHash['fStepXref'] = 1; break; case 1: - $pParamHash['end_date'] = $this->mDb->NOW(); + $pParamHash['end_date'] = time(); break; default: $pParamHash['ignore_end_date'] = 'on'; |
