Skip to content

Commit

Permalink
Merge pull request #106 from contao-estatemanager/develop
Browse files Browse the repository at this point in the history
Merge dev-master
  • Loading branch information
doishub authored Jun 8, 2020
2 parents 974442b + f855c27 commit 0f4ebd2
Show file tree
Hide file tree
Showing 106 changed files with 7,164 additions and 3,819 deletions.
56 changes: 56 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

$header = <<<EOF
This file is part of Contao EstateManager.
@link https://www.contao-estatemanager.com/
@source https://github.com/contao-estatemanager/core
@copyright Copyright (c) 2020 Oveleon GbR (https://www.oveleon.de)
EOF;

$finder = PhpCsFixer\Finder::create()
->exclude('Resources')
->in([__DIR__.'/src', __DIR__.'/tests'])
;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit60Migration:risky' => true,
'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'general_phpdoc_annotation_remove' => [
'expectedException',
'expectedExceptionMessage',
],
'header_comment' => ['header' => $header],
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'native_function_invocation' => [
'include' => ['@compiler_optimized'],
],
'no_null_property_initialization' => true,
'no_superfluous_elseif' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'strict_comparison' => true,
'strict_param' => true,
])
->setFinder($finder)
->setRiskyAllowed(true)
->setUsingCache(false)
;
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
<br/>
<p align="center"><img src="https://www.contao-estatemanager.com/files/theme/images/logo/logo_dunkel.png"></p>
<br/>
<p align="center">
<small>The Contao EstateManager is an open source extension for Contao CMS that allows you to import real estate assets from existing ecosystems, display them extensively or manage properties directly in Contao. Visit the <a href="https://www.contao-estatemanager.com" target="_blank">project website</a> for more information.</small>
</p>
<br/>
<p align="center">
<a href="https://www.oveleon.de"><img src="https://img.shields.io/badge/oveleon-maintained-83aa0e?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAUCAYAAABvVQZ0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA/xpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ1dWlkOjVEMjA4OTI0OTNCRkRCMTE5MTRBODU5MEQzMTUwOEM4IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM5MjZB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d8q8SavBOpl0rnxROadFugkFVoOJAx1h4rRJvw9e2b9u3ACrY9ENAZaD/L/E0aiHMbbfQc3v7bFxWAchqptHAAqN3HQrM0JcsXFohzzexWPYk5N+BBgAix5VyvzRZbwAAAAASUVORK5CYII=" alt="Oveleon"></a>
<a href="https://github.com/contao-estatemanager/core"><img src="https://img.shields.io/github/license/contao-estatemanager/core?color=1268cc&style=flat-square"/></a>
<!--<a href="https://github.com/contao-estatemanager/core"><img src="https://img.shields.io/github/package-json/v/contao-estatemanager/core?style=flat-square"/></a>
<a href="https://github.com/contao-estatemanager/core"><img src="https://img.shields.io/packagist/dt/contao-estatemanager/core?style=flat-square"/></a>-->
</p>

## Extensions
- [Extension catalogue][4]

# About
EstateManager is an Open Source Extension for Contao CMS, which allows you to import and extensively display real estate assets from existing ecosystems. Visit the [project website][1] for more information.
## Documentation
- [Documentation][2]
- [Help with documentation][3]

[1]: https://www.contao-estatemanager.com
## Support
- [Help with translation][5]
- [Report an issue][6]

[2]: https://docs.contao-estatemanager.com
[3]: https://github.com/contao-estatemanager/docs/pulls
[4]: https://www.contao-estatemanager.com/store.html
[5]: https://www.transifex.com/oveleon/contao-estatemanager/
[6]: https://github.com/contao-estatemanager/core/issues
44 changes: 38 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
{
"name":"contao-estatemanager/core",
"type":"contao-bundle",
"description":"EstateManager for Contao - Manage real estate properties in Cotnao.",
"keywords":["contao","immo-manager","estate-manager","estate","real-estate","real estate","property"],
"description":"EstateManager for Contao - Manage real estate properties in Contao.",
"keywords":["contao", "immobilien", "manager", "property", "realestate"],
"homepage":"https://www.contao-estatemanager.com/",
"license":"AGPLv3",
"authors":[
{
"name":"Oveleon",
"homepage":"https://www.oveleon.de/",
"name":"Daniele Sciannimanica",
"homepage":"https://github.com/doishub",
"role":"Developer"
},
{
"name":"Fabian Ekert",
"homepage":"https://github.com/eki89",
"role":"Developer"
}
],
"require":{
"php":">=7.1",
"php":">=7.2",
"contao/core-bundle":"^4.4",
"menatwork/contao-multicolumnwizard-bundle": "^3.4"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
"contao/manager-plugin": "^2.0",
"friendsofphp/php-cs-fixer": "^2.12",
"phpunit/phpunit": "^5.7.26",
"symfony/phpunit-bridge": "^3.2"
},
"conflict": {
"contao/core": "*",
Expand All @@ -38,7 +46,31 @@
"src/Resources/contao/templates/"
]
},
"autoload-dev": {
"psr-4": {
"ContaoEstateManager\\EstateManager\\Tests\\": "tests/"
}
},
"extra":{
"contao-manager-plugin": "ContaoEstateManager\\EstateManager\\ContaoManager\\Plugin"
},
"support": {
"issues": "https://github.com/contao-estatemanager/core/issues",
"source": "https://github.com/contao-estatemanager/core",
"docs": "https://docs.contao-estatemanager.com/"
},
"suggest": {
"contao-estatemanager/watchlist": "Extends watchlist features",
"contao-estatemanager/reference": "Extends reference features",
"contao-estatemanager/googlemaps": "Extends Google-Maps",
"contao-estatemanager/locations": "Extends additional features for locations",
"contao-estatemanager/energy-pass": "Extends an energy certificate",
"contao-estatemanager/featured": "Extends highlighted real estates",
"contao-estatemanager/similar": "Extends lists for similar real estate",
"contao-estatemanager/video": "Extends video support",
"contao-estatemanager/virtual-tour": "Extends virtual-tour support",
"contao-estatemanager/project": "Extends projects with several residential units",
"contao-estatemanager/wib-import": "Extends WIB import interface",
"contao-estatemanager/skeleton-extension": "Create your own extension for the Contao EstateManager"
}
}
22 changes: 22 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.0/phpunit.xsd"
backupGlobals="false"
colors="true">
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Contao EstateManager">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
<exclude>
<directory>./src/Resources</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php

namespace ContaoEstateManager;
namespace ContaoEstateManager\EstateManager\Controller;

use Symfony\Component\HttpFoundation\JsonResponse;
use Contao\FilesModel;
use Contao\Frontend;
use Contao\Image;
use Contao\System;
use Contao\Validator;

/**
* EstateManager SDK.
* Abstract EstateManager Controller.
*
* @author Daniele Sciannimanica <https://github.com/doishub>
*/
class EstateManagerSDK extends \Frontend
class AbstractEstateManagerController extends Frontend
{
/** Method Contants */
const METHOD_GET = 'GET';
Expand All @@ -23,17 +27,14 @@ class EstateManagerSDK extends \Frontend
const STATUS_SUCCESS = 'OK';

/**
* SDK Constructor
* Constructor
*/
public function __construct()
{
// Load the user object before calling the parent constructor
$this->import('FrontendUser', 'User');
parent::__construct();

// Check whether a user is logged in
\define('BE_USER_LOGGED_IN', $this->getLoginStatus('BE_USER_AUTH'));
\define('FE_USER_LOGGED_IN', $this->getLoginStatus('FE_USER_AUTH'));
parent::__construct();
}

/**
Expand Down Expand Up @@ -89,9 +90,9 @@ protected function getImagePath($varSingleSrc, $imgSize)
{
if ($varSingleSrc)
{
if (!($varSingleSrc instanceof \FilesModel) && \Validator::isUuid($varSingleSrc))
if (!($varSingleSrc instanceof FilesModel) && Validator::isUuid($varSingleSrc))
{
$objModel = \FilesModel::findByUuid($varSingleSrc);
$objModel = FilesModel::findByUuid($varSingleSrc);
}
else
{
Expand All @@ -100,7 +101,7 @@ protected function getImagePath($varSingleSrc, $imgSize)

if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path))
{
return \Image::getPath(\System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $objModel->path, $imgSize)->getUrl(TL_ROOT));
return Image::getPath(System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $objModel->path, $imgSize)->getUrl(TL_ROOT));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/EstateManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ContaoEstateManager\EstateManager\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use ContaoEstateManager\EstateManagerRead;

Expand All @@ -11,7 +11,7 @@
*
* @author Daniele Sciannimanica <https://github.com/doishub>
*/
class EstateManagerController extends Controller
class EstateManagerController extends AbstractController
{
/**
* Runs the command scheduler. (READ)
Expand Down
36 changes: 36 additions & 0 deletions src/DependencyInjection/EstateManagerExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/**
* This file is part of Contao EstateManager.
*
* @link https://www.contao-estatemanager.com/
* @source https://github.com/contao-estatemanager/core
* @copyright Copyright (c) 2019 Oveleon GbR (https://www.oveleon.de)
* @license https://www.contao-estatemanager.com/lizenzbedingungen.html
*/

namespace ContaoEstateManager\EstateManager\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class EstateManagerExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__ . '/../Resources/config')
);

$loader->load('listener.yml');
$loader->load('services.yml');
}
}
88 changes: 88 additions & 0 deletions src/EventListener/InsertTagsListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

declare(strict_types=1);

/**
* This file is part of Contao EstateManager.
*
* @link https://www.contao-estatemanager.com/
* @source https://github.com/contao-estatemanager/core
* @copyright Copyright (c) 2019 Oveleon GbR (https://www.oveleon.de)
* @license https://www.contao-estatemanager.com/lizenzbedingungen.html
*/

namespace ContaoEstateManager\EstateManager\EventListener;

use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\Input;
use ContaoEstateManager\RealEstate;
use ContaoEstateManager\RealEstateModel;

/**
* @internal
*/
class InsertTagsListener
{
private const SUPPORTED_TAGS = [
'realestate'
];

/**
* @var ContaoFramework
*/
private $framework;

public function __construct(ContaoFramework $framework)
{
$this->framework = $framework;
}

/**
* @return string|false
*/
public function onReplaceInsertTags(string $tag, bool $useCache, $cacheValue, array $flags)
{
$elements = explode('::', $tag);
$key = strtolower($elements[0]);

if (\in_array($key, self::SUPPORTED_TAGS, true)) {
return $this->replaceRealEstateInsertTags($key, $elements, $flags);
}

return false;
}

private function replaceRealEstateInsertTags(string $insertTag, array $elements, array $flags): string
{
$this->framework->initialize();

/** @var RealEstateModel $adapter */
$adapter = $this->framework->getAdapter(RealEstateModel::class);

if (is_numeric($elements[1]))
{
if (null !== ($model = $adapter->findPublishedByIdOrAlias($elements[1])))
{
$elements[1] = $elements[2];
}
}
elseif (Input::get('items'))
{
$model = $adapter->findPublishedByIdOrAlias(Input::get('items'));
}

if ($model === null)
{
return '';
}

$realEstate = new RealEstate($model);

switch ($insertTag) {
case 'realestate':
return $realEstate->{$elements[1]} ?: '';
}

return '';
}
}
Loading

0 comments on commit 0f4ebd2

Please sign in to comment.