summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-29 15:03:00 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-29 15:03:00 +0100
commitc401680a7cbe4ffffbcd496fa671e319a4967fc1 (patch)
tree0afb429c1bf01affd896fb3480dc3f18408410c0
parent3d94c3dfe203edeb25b42466733672aff9fca89f (diff)
downloadliberty-c401680a7cbe4ffffbcd496fa671e319a4967fc1.tar.gz
liberty-c401680a7cbe4ffffbcd496fa671e319a4967fc1.tar.bz2
liberty-c401680a7cbe4ffffbcd496fa671e319a4967fc1.zip
Standardise xref templates to _item naming; add value and group templates
- Rename all view_xref_*_record.tpl → view_xref_*_item.tpl throughout - LibertyContent: getXrefRecordTemplate/ListTemplate/EditTemplate use _item naming with three-level fallback (pkg/guid subdir → pkg root → liberty); getXrefRecordTemplate falls back to text_item if template file not found; getXrefEditTemplate checks liberty _item before generic edit_xref.tpl - list_xref.tpl: assign _rowTpl before method call to avoid Smarty section variable resolution issue inside PHP method call arguments - New templates: view_xref_value_item.tpl, edit_xref_value_item.tpl for simple numeric xref items (xkey field, not data) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-xincludes/classes/LibertyContent.php45
-rw-r--r--templates/edit_xref_value_item.tpl34
-rw-r--r--templates/list_xref.tpl3
-rw-r--r--templates/view_xref_address_item.tpl (renamed from templates/view_xref_address_record.tpl)0
-rw-r--r--templates/view_xref_bank_item.tpl (renamed from templates/view_xref_bank_record.tpl)0
-rw-r--r--templates/view_xref_contact_item.tpl (renamed from templates/view_xref_contact_record.tpl)0
-rw-r--r--templates/view_xref_date_item.tpl (renamed from templates/view_xref_date_record.tpl)0
-rw-r--r--templates/view_xref_image_item.tpl (renamed from templates/view_xref_image_record.tpl)0
-rw-r--r--templates/view_xref_inc_report_item.tpl (renamed from templates/view_xref_inc_report_record.tpl)0
-rw-r--r--templates/view_xref_key_seal_item.tpl (renamed from templates/view_xref_key_seal_record.tpl)0
-rw-r--r--templates/view_xref_locate_item.tpl (renamed from templates/view_xref_locate_record.tpl)0
-rw-r--r--templates/view_xref_phone_item.tpl (renamed from templates/view_xref_phone_record.tpl)0
-rw-r--r--templates/view_xref_sig_item.tpl (renamed from templates/view_xref_sig_record.tpl)0
-rw-r--r--templates/view_xref_text_item.tpl (renamed from templates/view_xref_text_record.tpl)0
-rw-r--r--templates/view_xref_value_item.tpl28
15 files changed, 97 insertions, 13 deletions
diff --git a/includes/classes/LibertyContent.php b/includes/classes/LibertyContent.php
index 9f79e45..58894be 100755
--- a/includes/classes/LibertyContent.php
+++ b/includes/classes/LibertyContent.php
@@ -2157,10 +2157,17 @@ class LibertyContent extends LibertyBase implements BitCacheable {
*/
public function getXrefListTemplate( ?string $pTemplate = null ): string {
if( $pTemplate ) {
- $package = $this->mType['handler_package'] ?? 'liberty';
+ $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';
+ if( defined( $pkgConst ) ) {
+ $base = constant( $pkgConst ).'templates/';
+ $file = 'view_xref_'.$pTemplate.'_group.tpl';
+ if( $this->mContentTypeGuid && file_exists( $base.$this->mContentTypeGuid.'/'.$file ) ) {
+ return 'bitpackage:'.$package.'/'.$this->mContentTypeGuid.'/'.$file;
+ }
+ if( file_exists( $base.$file ) ) {
+ return 'bitpackage:'.$package.'/'.$file;
+ }
}
}
return 'bitpackage:liberty/list_xref.tpl';
@@ -2168,26 +2175,40 @@ class LibertyContent extends LibertyBase implements BitCacheable {
public function getXrefRecordTemplate( ?string $pTemplate = null ): string {
$pTemplate = $pTemplate ?: 'text';
- $package = $this->mType['handler_package'] ?? 'liberty';
+ $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';
+ $base = constant( $pkgConst ).'templates/';
+ $file = 'view_xref_'.$pTemplate.'_item.tpl';
+ if( $this->mContentTypeGuid && file_exists( $base.$this->mContentTypeGuid.'/'.$file ) ) {
+ return 'bitpackage:'.$package.'/'.$this->mContentTypeGuid.'/'.$file;
+ }
+ if( file_exists( $base.$file ) ) {
+ return 'bitpackage:'.$package.'/'.$file;
}
}
- return 'bitpackage:liberty/view_xref_'.$pTemplate.'_record.tpl';
+ $libertyTpl = LIBERTY_PKG_PATH.'templates/view_xref_'.$pTemplate.'_item.tpl';
+ return file_exists( $libertyTpl )
+ ? 'bitpackage:liberty/view_xref_'.$pTemplate.'_item.tpl'
+ : 'bitpackage:liberty/view_xref_text_item.tpl';
}
public function getXrefEditTemplate( ?string $pTemplate = null ): string {
$pTemplate = $pTemplate ?: 'text';
- $package = $this->mType['handler_package'] ?? 'liberty';
+ $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';
+ $base = constant( $pkgConst ).'templates/';
+ $file = 'edit_xref_'.$pTemplate.'_item.tpl';
+ if( $this->mContentTypeGuid && file_exists( $base.$this->mContentTypeGuid.'/'.$file ) ) {
+ return 'bitpackage:'.$package.'/'.$this->mContentTypeGuid.'/'.$file;
}
+ if( file_exists( $base.$file ) ) {
+ return 'bitpackage:'.$package.'/'.$file;
+ }
+ }
+ if( file_exists( LIBERTY_PKG_PATH.'templates/edit_xref_'.$pTemplate.'_item.tpl' ) ) {
+ return 'bitpackage:liberty/edit_xref_'.$pTemplate.'_item.tpl';
}
return 'bitpackage:liberty/edit_xref.tpl';
}
diff --git a/templates/edit_xref_value_item.tpl b/templates/edit_xref_value_item.tpl
new file mode 100644
index 0000000..0418d1e
--- /dev/null
+++ b/templates/edit_xref_value_item.tpl
@@ -0,0 +1,34 @@
+{strip}
+<div class="edit liberty">
+ <div class="header">
+ <h1>{tr}Edit Value{/tr}: {$gContent->getTitle()|escape}</h1>
+ </div>
+ <div class="body">
+ {formfeedback error=$errors}
+ {form id="editXrefForm"}
+ <input type="hidden" name="content_id" value="{$xrefInfo.content_id|escape}" />
+ <input type="hidden" name="xref_id" value="{$xrefInfo.xref_id|escape}" />
+ <input type="hidden" name="item" value="{$xrefInfo.item|escape}" />
+
+ <div class="form-group">
+ {formlabel label="Type"}
+ {forminput}
+ <p class="form-control-static">{$xrefInfo.source_title|escape}</p>
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Value" for="xkey"}
+ {forminput}
+ <input type="text" class="form-control input-small" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" />
+ {/forminput}
+ </div>
+
+ <div class="form-group submit">
+ <input type="submit" class="btn btn-default" name="fCancel" value="{tr}Cancel{/tr}" />
+ <input type="submit" class="btn btn-primary" name="fSaveXref" value="{tr}Save{/tr}" />
+ </div>
+ {/form}
+ </div>
+</div>
+{/strip}
diff --git a/templates/list_xref.tpl b/templates/list_xref.tpl
index a670111..70183ce 100644
--- a/templates/list_xref.tpl
+++ b/templates/list_xref.tpl
@@ -21,8 +21,9 @@
</thead>
<tbody>
{section name=xref loop=$gContent->mInfo.$source}
+ {assign var=_rowTpl value=$gContent->mInfo.$source[xref].template}
<tr class="{cycle values="even,odd"}">
- {include file=$gContent->getXrefRecordTemplate($gContent->mInfo.$source[xref].template)}
+ {include file=$gContent->getXrefRecordTemplate($_rowTpl)}
</tr>
{sectionelse}
<tr class="norecords">
diff --git a/templates/view_xref_address_record.tpl b/templates/view_xref_address_item.tpl
index 21af596..21af596 100644
--- a/templates/view_xref_address_record.tpl
+++ b/templates/view_xref_address_item.tpl
diff --git a/templates/view_xref_bank_record.tpl b/templates/view_xref_bank_item.tpl
index 099ce6b..099ce6b 100644
--- a/templates/view_xref_bank_record.tpl
+++ b/templates/view_xref_bank_item.tpl
diff --git a/templates/view_xref_contact_record.tpl b/templates/view_xref_contact_item.tpl
index c89a8ae..c89a8ae 100644
--- a/templates/view_xref_contact_record.tpl
+++ b/templates/view_xref_contact_item.tpl
diff --git a/templates/view_xref_date_record.tpl b/templates/view_xref_date_item.tpl
index 099ce6b..099ce6b 100644
--- a/templates/view_xref_date_record.tpl
+++ b/templates/view_xref_date_item.tpl
diff --git a/templates/view_xref_image_record.tpl b/templates/view_xref_image_item.tpl
index 9effe61..9effe61 100644
--- a/templates/view_xref_image_record.tpl
+++ b/templates/view_xref_image_item.tpl
diff --git a/templates/view_xref_inc_report_record.tpl b/templates/view_xref_inc_report_item.tpl
index 6fc138f..6fc138f 100644
--- a/templates/view_xref_inc_report_record.tpl
+++ b/templates/view_xref_inc_report_item.tpl
diff --git a/templates/view_xref_key_seal_record.tpl b/templates/view_xref_key_seal_item.tpl
index 0fe0b18..0fe0b18 100644
--- a/templates/view_xref_key_seal_record.tpl
+++ b/templates/view_xref_key_seal_item.tpl
diff --git a/templates/view_xref_locate_record.tpl b/templates/view_xref_locate_item.tpl
index 099ce6b..099ce6b 100644
--- a/templates/view_xref_locate_record.tpl
+++ b/templates/view_xref_locate_item.tpl
diff --git a/templates/view_xref_phone_record.tpl b/templates/view_xref_phone_item.tpl
index 5c95005..5c95005 100644
--- a/templates/view_xref_phone_record.tpl
+++ b/templates/view_xref_phone_item.tpl
diff --git a/templates/view_xref_sig_record.tpl b/templates/view_xref_sig_item.tpl
index 099ce6b..099ce6b 100644
--- a/templates/view_xref_sig_record.tpl
+++ b/templates/view_xref_sig_item.tpl
diff --git a/templates/view_xref_text_record.tpl b/templates/view_xref_text_item.tpl
index c89a8ae..c89a8ae 100644
--- a/templates/view_xref_text_record.tpl
+++ b/templates/view_xref_text_item.tpl
diff --git a/templates/view_xref_value_item.tpl b/templates/view_xref_value_item.tpl
new file mode 100644
index 0000000..b289054
--- /dev/null
+++ b/templates/view_xref_value_item.tpl
@@ -0,0 +1,28 @@
+{strip}
+<td>{$gContent->mInfo.$source[xref].source_title|escape}</td>
+<td>&nbsp;</td>
+<td>{$gContent->mInfo.$source[xref].xkey|escape}</td>
+<td>{$gContent->mInfo.$source[xref].xkey_ext|escape}</td>
+<td>
+ {if $source ne 'history'}
+ {$gContent->mInfo.$source[xref].start_date|bit_short_date}
+ {else}
+ {$gContent->mInfo.$source[xref].end_date|bit_short_date}
+ {/if}
+</td>
+<td>{$gContent->mInfo.$source[xref].last_update_date|bit_short_date}</td>
+<td>
+ <span class="actionicon">
+ {if $xrefAllowEdit|default:true && $gContent->hasUpdatePermission() && $source ne 'history'}
+ {smartlink ititle="Edit" ipackage="liberty" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id}
+ {/if}
+ {if $xrefAllowEdit|default:true && $gContent->hasExpungePermission()}
+ {if $source eq 'history'}
+ {smartlink ititle="Restore" ipackage="liberty" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id expunge=-1}
+ {else}
+ {smartlink ititle="Delete" ipackage="liberty" ifile="edit_xref.php" booticon="icon-note-delete" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id expunge=1}
+ {/if}
+ {/if}
+ </span>
+</td>
+{/strip}