Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 28, 2024
1 parent bccf1f3 commit bdef1d0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export SECURITY_SALT="__SALT__"
#export CACHE_DEFAULT_URL="file://tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}"
#export CACHE_CAKECORE_URL="file://tmp/cache/persistent?prefix=${APP_NAME}_cake_core&serialize=true&duration=${CACHE_DURATION}"
#export CACHE_CAKEMODEL_URL="file://tmp/cache/models?prefix=${APP_NAME}_cake_model&serialize=true&duration=${CACHE_DURATION}"
#export CACHE_CAKEROUTE_URL="file://tmp/cache/routes?prefix=${APP_NAME}_cake_routes&serialize=true&duration=${CACHE_DURATION}"
#export CACHE_HTMLELEMENT_URL="file://tmp/cache/elements?prefix=${APP_NAME}_html_elements&serialize=true&duration=${CACHE_DURATION}"

# Uncomment these to define email transport configuration via environment variables.
#export EMAIL_TRANSPORT_DEFAULT_URL=""
Expand Down
11 changes: 11 additions & 0 deletions app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@
'duration' => '+1 years',
'url' => env('CACHE_CAKEROUTES_URL', null),
],
/**
* Configure the cache for html elements.
* Duration will be set to '+2 seconds' in bootstrap.php when debug = true
*/
'_html_elements' => [
'className' => 'Cake\Cache\Engine\FileEngine',
'prefix' => 'myapp_cake_elements_',
'duration' => '+1 week',
'probability' => 100,
'url' => env('CACHE_HTMLELEMENT_URL', null),
]
],

/**
Expand Down
4 changes: 3 additions & 1 deletion app/src/View/Helper/FieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ public function dateField(string $fieldName,
// ACTION VIEW
if($this->action == 'view') {
// return the date as plaintext
$element = $this->getView()->element('form/notSetDiv');
$element = $this->getView()->element('form/notSetDiv', [], [
'cache' => '_html_elements',
]);
if ($date_object !== null) {
// Adjust the time back to the user's timezone
$element = '<time>' . $date_object->i18nFormat($dateFormat) . '</time>';
Expand Down
23 changes: 16 additions & 7 deletions app/templates/element/form/nameDiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

use Cake\Utility\Inflector;

// $fieldName: parameter

$classes = '';

Expand All @@ -59,7 +58,7 @@
[$label, $desc] = $this->Field->calculateLabelAndDescription($fn);
$label = $vv_field_arguments['fieldLabel'] ?? $label;

// Override the default required behavior is the field has the required
// Override the default required behavior if the field has the required
// option set
$optionsRequired = isset($vv_field_arguments['fieldOptions']['required'])
&& $vv_field_arguments['fieldOptions']['required'];
Expand All @@ -73,25 +72,35 @@
<div class="field-name <?= $classes ?>">
<div class="field-title">
<!-- Will this work for accessibility? -->
<?php if((isset($vv_field_arguments['labelIsTextOnly']) && !$vv_field_arguments['labelIsTextOnly'])
&& $this->Field->getFieldType($fieldName) !== 'boolean'): ?>
<?php if(
(isset($vv_field_arguments['labelIsTextOnly']) && !$vv_field_arguments['labelIsTextOnly'])
&& $this->Field->getFieldType($fieldName) !== 'boolean'
):
?>
<?= $this->Form->label($fn, $label) ?>
<!-- We print the login checkbox along with the Identifier type. -->
<!-- As a result, the label is redundant -->
<?php elseif($fieldName != 'login'): ?>
<?= $label ?>
<?php endif; ?>
<?php
// Required Field

/*
* Required Span
*/
if($this->Field->isEditable()
&&
($this->Field->isReqField($fn) || $optionsRequired)
) {
print $this->element('form/requiredSpan');
print $this->element('form/requiredSpan', [], [
'cache' => '_html_elements',
]);
}
?>
</div>
<?php if(isset($desc)): ?>
<div class="field-desc"><?= $desc ?></div>
<div class="field-desc">
<?= $desc ?>
</div>
<?php endif; // description?>
</div>

0 comments on commit bdef1d0

Please sign in to comment.