Skip to content

Commit

Permalink
- Fix PHP warnings
Browse files Browse the repository at this point in the history
- When creating a new property, is directly directed to the new mask
- Added list overview link
- Added translations (en)
  • Loading branch information
doishub committed Nov 24, 2021
1 parent 6c3cb7a commit c2b58d7
Show file tree
Hide file tree
Showing 12 changed files with 311 additions and 39 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"php":"^7.4 || ^8.0",
"contao/core-bundle":">=4.9",
"oveleon/contao-be-field-dependency": ">=0.4",
"contao-estatemanager/core": "*"
"contao-estatemanager/core": ">=1.1"
},
"require-dev": {
"contao/manager-plugin": "^2.0",
Expand Down
14 changes: 8 additions & 6 deletions src/Controller/BackendModule/BackendModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Contao\Ajax;
use Contao\Controller;
use Contao\Environment;
use Contao\FilesModel;
use Contao\Input;
use Contao\Message;
use Contao\System;
Expand Down Expand Up @@ -89,28 +90,29 @@ public function __invoke($id): Response
Controller::reload();
}

// Get real estate object
$realEstate = new RealEstate($this->objRealEstate);
$objFile = FilesModel::findByUuid($this->objRealEstate->titleImageSRC);

// Render template
return new Response($this->twig->render(
'@EstateManagerBackendRealEstateManagement/be_real_estate_edit.html.twig',
[
'head' => [
'title' => $this->translator->trans('backend_real_estate_management.title', [$id], 'contao_default'),
'subtitle' => $realEstate->title,
'image' => $realEstate->generateMainImage([50, 50]),
'subtitle' => $this->objRealEstate->title,
'image' => RealEstate::parseImageTemplate($objFile, [50, 50]),
'message' => Message::generate(),
'classicLink' => '/contao?do=real_estate&act=edit&id='.$id.'&rt='.REQUEST_TOKEN,
'classicLabel' => $this->translator->trans('backend_real_estate_management.label_classic_link', [], 'contao_default'),
'classicLink' => '/contao?do=real_estate&act=edit&id='.$id.'&rt='.REQUEST_TOKEN,
'overviewLabel' => $this->translator->trans('backend_real_estate_management.label_overview_link', [], 'contao_default'),
'overviewLink' => '/contao?do=real_estate&rt='.REQUEST_TOKEN,
],
'form' => [
'id' => $id,
'rt' => REQUEST_TOKEN,
'palette' => $this->adapter->getPalette(),
'label' => $this->translator->trans('backend_real_estate_management.label_submit', [], 'contao_default'),
'content' => $htmlContent,
]
],
]
));
}
Expand Down
6 changes: 3 additions & 3 deletions src/LayoutBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
*
* $layout->addSection('sectionAlias');
* $layout->addHtml('<label>Hello World</label>');
* $layout->parse('sectionAlias'); // Returns => <label>Hello World</label>
* $layout->parse('sectionAlias'); // Returns => <label>Hello World</label>
*
* ---
*
* $layout->addSection('sectionAlias', 'div', ['class' => 'myClass']); // <- Set pointer to sectionAlias
* $layout->addSection('inputBag', 'nav'); // <- Set pointer to inputBag
* $layout->addSection('inputBag', 'nav'); // <- Set pointer to inputBag
*
* $layout->addHtml('<input type="text" value="Hello World">');
* $layout->append('sectionAlias')
* $layout->parse('sectionAlias'); // Returns: <div class="myClass"><nav><input type="text" value="Hello World"></nav></label>
* $layout->parse('sectionAlias'); // Returns: <div class="myClass"><nav><input type="text" value="Hello World"></nav></label>
*
* @author Daniele Sciannimanica <https://github.com/doishub>
*/
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
],
'geo' => [
'breitengrad',
'laengengrad'
'laengengrad',
],
],
'prices' => [
Expand Down Expand Up @@ -234,7 +234,7 @@
'gastroflaeche',
'gartenflaeche',
'kellerflaeche',
'teilbarAb'
'teilbarAb',
],
'quantity' => [
['column' => 'right'],
Expand Down Expand Up @@ -271,7 +271,7 @@
],
'area_commerce' => [
'flaechevon',
'flaechebis'
'flaechebis',
],
'area_investment' => [
['column' => 'right'],
Expand All @@ -283,8 +283,8 @@
'area_props' => [
['column' => 'right'],
'kubatur',
'ausnuetzungsziffer'
]
'ausnuetzungsziffer',
],
],
'texts' => [
'objTitle' => [
Expand Down Expand Up @@ -400,7 +400,7 @@
'extra' => [
'geschlecht',
'stromanschlusswert',
]
],
],
'parking' => [
'parking' => [
Expand Down Expand Up @@ -483,7 +483,7 @@
'energiepassHwbklasse',
'energiepassFgeewert',
'energiepassFgeeklasse',
]
],
],
'files' => [
'images' => [
Expand Down
42 changes: 23 additions & 19 deletions src/Resources/contao/dca/tl_real_estate.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,35 @@
*/

use Contao\BackendUser;
use Contao\Controller;
use Contao\Database;
use Contao\Environment;
use Contao\StringUtil;
use Contao\Image;
use Contao\StringUtil;

$strEditRoute = '/contao/realestate/edit/';

$GLOBALS['TL_DCA']['tl_real_estate']['list']['operations']['edit']['button_callback'] = static function(array $row, string $href, string $label, string $title, string $icon, string $attributes)
$onCreateCallback = static function ($table, $intId) use ($strEditRoute): void {
Database::getInstance()->prepare('UPDATE tl_real_estate SET tstamp=? WHERE id=?')->execute([time(), $intId]);
Controller::redirect($strEditRoute.$intId);
};

if (is_array($GLOBALS['TL_DCA']['tl_real_estate']['config']['oncreate_callback'] ?? null))
{
$GLOBALS['TL_DCA']['tl_real_estate']['config']['oncreate_callback'][] = $onCreateCallback;
}
else
{
$GLOBALS['TL_DCA']['tl_real_estate']['config']['oncreate_callback'] = [$onCreateCallback];
}

$GLOBALS['TL_DCA']['tl_real_estate']['list']['operations']['edit']['button_callback'] = static function (array $row, string $href, string $label, string $title, string $icon, string $attributes) use ($strEditRoute) {
$user = BackendUser::getInstance();
return $user->canEditFieldsOf('tl_real_estate') ? '<a href="/contao/realestate/edit/'.$row['id'].'" title="'.StringUtil::specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ' : Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';

return $user->canEditFieldsOf('tl_real_estate') ? '<a href="'.$strEditRoute.$row['id'].'" title="'.StringUtil::specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ' : Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
};

if (false !== strpos(Environment::get('requestUri'), '/contao/realestate/edit/'))
if (false !== strpos(Environment::get('requestUri'), $strEditRoute))
{
// Load backend css / js
$GLOBALS['TL_CSS'][] = 'bundles/estatemanagerbackendrealestatemanagement/css/backend.css';
Expand Down Expand Up @@ -76,18 +94,13 @@
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['zinsTyp']['dependsOn'] = ['objektart' => 'zinshaus_renditeobjekt'];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['landTyp']['dependsOn'] = ['objektart' => 'land_und_forstwirtschaft'];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['freizeitTyp']['dependsOn'] = ['objektart' => 'freizeitimmobilie_gewerblich'];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['breitbandArt']['dependsOn'] = ['breitbandZugang' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['breitbandGeschw']['dependsOn'] = ['breitbandZugang' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['weitergabePositiv']['dependsOn'] = ['weitergabeGenerell' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['weitergabeNegativ']['dependsOn'] = ['weitergabeGenerell' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['verkaufstatus']['dependsOn'] = ['vermarktungsartKauf' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['vermietet']['dependsOn'] = ['vermarktungsartMietePacht' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['laufzeit']['dependsOn'] = ['vermarktungsartErbpacht' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['kaufpreis']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['kaufpreisAufAnfrage']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['kaufpreisnetto']['dependsOn'] = [$marketingBuy];
Expand All @@ -96,35 +109,28 @@
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['provisionspflichtig']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['provisionTeilen']['dependsOn'] = ['provisionspflichtig' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['provisionTeilenWert']['dependsOn'] = ['provisionTeilen' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['innenCourtage']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['innenCourtageMwst']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['aussenCourtage']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['aussenCourtageMwst']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['courtageHinweis']['dependsOn'] = [$marketingBuy];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['nettorendite']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['nettorenditeSoll']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['nettorenditeIst']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['mieteinnahmenIst']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['mieteinnahmenIstPeriode']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['mieteinnahmenSoll']['dependsOn'] = [$marketingBuy];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['mieteinnahmenSollPeriode']['dependsOn'] = [$marketingBuy];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['warmmiete']['dependsOn'] = [$marketingRent];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['kaltmiete']['dependsOn'] = [$marketingRent];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['nettokaltmiete']['dependsOn'] = [$marketingRent];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['mietpreisProQm']['dependsOn'] = [$marketingRent];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['energiepassEnergieverbrauchkennwert']['dependsOn'] = ['energiepassEpart' => 'verbrauch'];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['energiepassMitwarmwasser']['dependsOn'] = ['energiepassEpart' => 'verbrauch'];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['energiepassEndenergiebedarf']['dependsOn'] = ['energiepassEpart' => 'bedarf'];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['breitbandGeschw']['dependsOn'] = ['breitbandZugang' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['breitbandArt']['dependsOn'] = ['breitbandZugang' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['branchen']['dependsOn'] = ['gewerblicheNutzung' => 1];

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['aktenzeichen']['dependsOn'] = ['zwangsversteigerung' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['zvtermin']['dependsOn'] = ['zwangsversteigerung' => 1];
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['zusatztermin']['dependsOn'] = ['zwangsversteigerung' => 1];
Expand All @@ -137,16 +143,14 @@
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['objekttitel']['eval']['tl_class'] .= ' long';
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['alias']['eval']['tl_class'] .= ' long';
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['metaDescription']['eval']['tl_class'] .= ' clr';

$GLOBALS['TL_DCA']['tl_real_estate']['fields']['bad']['eval']['tl_class'] = 'clr long';
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['angeschlGastronomie']['eval']['tl_class'] = 'clr long';
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['sicherheitstechnik']['eval']['tl_class'] = 'clr long';
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['ausstattKategorie']['eval']['tl_class'] = 'long';
$GLOBALS['TL_DCA']['tl_real_estate']['fields']['unterkellert']['eval']['tl_class'] = 'long';


// Clear checkbox widgets
$arrCheckboxes = ['wbsSozialwohnung','kartenMakro','kartenMikro','luftbildern','virtuelletour','hochhaus','denkmalgeschuetzt','gewerblicheNutzung','branchen','alsFerien','kabelSatTv','dvbt','dvVerkabelung','breitbandZugang','umtsEmpfang','kabelkanaele','telefonFerienimmobilie','nichtraucher','gaestewc','haustiere','raeumeVeraenderbar','wgGeeignet','abstellraum','dachboden','gartennutzung','fahrradraum','rolladen','bibliothek','klimatisiert','seniorengerecht','rollstuhlgerecht','barrierefrei','waschTrockenraum','kamin','sauna','swimmingpool','wintergarten','rampe','hebebuehne','kran','zulieferung','gastterrasse','kantineCafeteria','teekueche','brauereibindung','sporteinrichtungen','wellnessbereich'];
$arrCheckboxes = ['wbsSozialwohnung', 'kartenMakro', 'kartenMikro', 'luftbildern', 'virtuelletour', 'hochhaus', 'denkmalgeschuetzt', 'gewerblicheNutzung', 'branchen', 'alsFerien', 'kabelSatTv', 'dvbt', 'dvVerkabelung', 'breitbandZugang', 'umtsEmpfang', 'kabelkanaele', 'telefonFerienimmobilie', 'nichtraucher', 'gaestewc', 'haustiere', 'raeumeVeraenderbar', 'wgGeeignet', 'abstellraum', 'dachboden', 'gartennutzung', 'fahrradraum', 'rolladen', 'bibliothek', 'klimatisiert', 'seniorengerecht', 'rollstuhlgerecht', 'barrierefrei', 'waschTrockenraum', 'kamin', 'sauna', 'swimmingpool', 'wintergarten', 'rampe', 'hebebuehne', 'kran', 'zulieferung', 'gastterrasse', 'kantineCafeteria', 'teekueche', 'brauereibindung', 'sporteinrichtungen', 'wellnessbereich'];

foreach ($arrCheckboxes as $field)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@
<source>Classic view</source>
<target>Klassische Ansicht</target>
</trans-unit>
<trans-unit id="backend_real_estate_management.label_overview_link">
<source>Real Estate Overview</source>
<target>Immobilien-Übersicht</target>
</trans-unit>
<trans-unit id="backend_real_estate_management.label_submit">
<source>Save</source>
<target>Speichern</target>
Expand Down
Loading

0 comments on commit c2b58d7

Please sign in to comment.