diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index b91d7d0a..9accaa01 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -130,6 +130,7 @@ ( 'contactPerson' => '\\ContaoEstateManager\\ExposeModuleContactPerson', 'enquiryForm' => '\\ContaoEstateManager\\ExposeModuleEnquiryForm', + 'attachments' => '\\ContaoEstateManager\\ExposeModuleAttachments', 'share' => '\\ContaoEstateManager\\ExposeModuleShare', 'print' => '\\ContaoEstateManager\\ExposeModulePrint', 'html' => '\\ContaoEstateManager\\ExposeModuleHtml', diff --git a/src/Resources/contao/dca/tl_expose_module.php b/src/Resources/contao/dca/tl_expose_module.php index 3ac72da7..12726d23 100644 --- a/src/Resources/contao/dca/tl_expose_module.php +++ b/src/Resources/contao/dca/tl_expose_module.php @@ -92,7 +92,7 @@ // Palettes 'palettes' => array ( - '__selector__' => array('type', 'protected', 'addHeadings'), + '__selector__' => array('type', 'protected', 'addHeadings', 'attachmentType'), 'default' => '{title_legend},name,headline,type', 'title' => '{title_legend},name,headline,type;{settings_legend},fontSize;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID', 'address' => '{title_legend},name,headline,type;{settings_legend},forceFullAddress;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID', @@ -110,7 +110,8 @@ 'enquiryForm' => '{title_legend},name,headline,type;{settings_legend},form,hideOnReferences;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID', 'share' => '{title_legend},name,headline,type;{settings_legend},share;{template_legend:hide},customTpl,shareEmailTemplate;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID', 'print' => '{title_legend},name,headline,type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID', - 'html' => '{title_legend},name,headline,type;{settings_legend},html;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests' + 'html' => '{title_legend},name,headline,type;{settings_legend},html;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests', + 'attachments' => '{title_legend},name,headline,type;{settings_legend},attachmentType;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests' ), // Subpalettes @@ -118,6 +119,7 @@ ( 'protected' => 'groups', 'addHeadings' => 'fontSize', + 'attachmentType_documents' => 'allowedFileExtensions,forceDownload' ), // Fields @@ -485,7 +487,32 @@ 'options_callback' => array('tl_expose_module', 'getRealEstateTemplates'), 'eval' => array('tl_class'=>'w50'), 'sql' => "varchar(64) NOT NULL default ''" - ) + ), + 'attachmentType' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_expose_module']['attachmentType'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => array('documents', 'links'), + 'eval' => array('tl_class'=>'w50', 'mandatory'=>true, 'includeBlankOption'=>true, 'submitOnChange'=>true), + 'sql' => "varchar(64) NOT NULL default ''" + ), + 'allowedFileExtensions' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_expose_module']['allowedFileExtensions'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => array('tl_class'=>'w50'), + 'sql' => "varchar(255) NOT NULL default 'pdf'" + ), + 'forceDownload' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_expose_module']['forceDownload'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class'=>'w50 m12'), + 'sql' => "char(1) NOT NULL default ''" + ), ) ); diff --git a/src/Resources/contao/languages/de/modules.xlf b/src/Resources/contao/languages/de/modules.xlf index fd954894..95ab0eee 100644 --- a/src/Resources/contao/languages/de/modules.xlf +++ b/src/Resources/contao/languages/de/modules.xlf @@ -243,6 +243,14 @@ Enables the output of a form produced by the form generator. Ermöglicht die Ausgabe eines vom Formulargenerator erzeugten Formulars. + + Attachments + Anhänge + + + Outputs attachments of the real estate. + Liefert die Anhänge einer Immobilie aus. + Cover picture @@ -307,8 +315,8 @@ - Property description - Immobilienbeschreibung + Description + Beschreibung Furnishings @@ -327,8 +335,8 @@ Kurzbeschreibung - Property text - Immobilientext + Text + Text diff --git a/src/Resources/contao/languages/de/tl_expose_module.xlf b/src/Resources/contao/languages/de/tl_expose_module.xlf index 65ee8a22..c123f96e 100644 --- a/src/Resources/contao/languages/de/tl_expose_module.xlf +++ b/src/Resources/contao/languages/de/tl_expose_module.xlf @@ -156,8 +156,8 @@ Verwenden des im Anbieter hinterlegten Weiterleitungsmodus. Bei verwenden dieser Funktion, werden die Telefonnummer (Zentrale) sowie die E-Mail (Zentrale) ggf. überschrieben. - Gallery Modules - Galerie-Module + Gallery Categories + Galerie-Kategorien Select and sort the images that should be output by this module. @@ -196,20 +196,20 @@ Hier können Sie die Gesamtzahl der Elemente begrenzen. Geben Sie 0 ein, um alle anzuzeigen. - Detail blocks - Detail-Blöcke + Detail Categories + Detail-Kategorien Define the order and output of the details. Keep in mind that the sequence of the individual fields can be defined using the object types. Definieren Sie die Reihenfolge und Ausgabe der Details. Beachten Sie, dass die Reihenfolge der einzelnen Felder über die Objekttypen definiert werden können. - Summarize detail blocks - Detail-Blöcke zusammenfassen + Summarize detail categories + Detail-Kategorien zusammenfassen - Instead of individual blocks, the details are summarized in a list. - Statt einzelne Blöcke werden die Details in einer Liste zusammengefasst ausgegeben. + Instead of individual categories, the details are summarized in a list. + Statt einzelner Kategorien werden die Details in einer Liste zusammengefasst ausgegeben. Add real estate address @@ -288,8 +288,8 @@ Wählen Sie die welche Teilen-Optionen zur Verfügung stehen. - 'Send via e-mail' template - Via E-Mail versenden'-Template + Send via e-mail template + Via E-Mail versenden Template HTML code @@ -355,6 +355,30 @@ Open the full size image in a lightbox or open it in a new browser window. Großansicht des Bildes in einer Lightbox bzw. den Link in einem neuem Browserfenster öffnen. + + Attachment type + Anhang-Typ + + + Please select an attachment type. + Bitte wähle den Typen des Anhangs + + + Allowed file extensions + Erlaubte Dateiendungen + + + Please provide a comma-separated list of file extensions which should not be output. (e.g pdf,doc) + Bitte geben Sie eine durch Komma getrennte Liste von Dateierweiterungen an, die nicht ausgegeben werden sollen (z.B. pdf,doc). + + + Force download + Download erzwingen + + + Forces the download of the file + Erzwingt den Download und öffnet einen Download-Dialog. + \ No newline at end of file diff --git a/src/Resources/contao/languages/de/tl_filter_item.xlf b/src/Resources/contao/languages/de/tl_filter_item.xlf index db8179f8..6658396f 100644 --- a/src/Resources/contao/languages/de/tl_filter_item.xlf +++ b/src/Resources/contao/languages/de/tl_filter_item.xlf @@ -143,7 +143,7 @@ Ungenaue Suche erlauben - Eine ungenaue Suche erlauben. + Allow an inaccurate search. Eine ungenaue Suche erlauben. diff --git a/src/Resources/contao/languages/de/tl_module.xlf b/src/Resources/contao/languages/de/tl_module.xlf index 3a51b066..8851e4aa 100644 --- a/src/Resources/contao/languages/de/tl_module.xlf +++ b/src/Resources/contao/languages/de/tl_module.xlf @@ -21,6 +21,10 @@ Real estate Item Extensions Immobilien Erweiterung + + Provider + Anbieter + Sorting Sortierung @@ -49,6 +53,22 @@ Please choose the sort order. Bitte wählen Sie die Sortierreihenfolge aus. + + Filter by provider + Nach Anbieter filtern + + + Filter records by a specific provider. + Datensätze anhand eines spezifischen Anbieters filtern + + + Provider + Anbieter + + + Records will be filtered by the selected provider. + Datensätze werden anhand eines ausgewählten Anbieters gefiltert + Add sorting Sortierung hinzufügen diff --git a/src/Resources/contao/languages/de/tl_page.xlf b/src/Resources/contao/languages/de/tl_page.xlf index 9e981166..14abcde5 100644 --- a/src/Resources/contao/languages/de/tl_page.xlf +++ b/src/Resources/contao/languages/de/tl_page.xlf @@ -7,7 +7,7 @@ Here you can assign a location to the page which later can be accessed via modules or insert-tags. - Hier können Sie der Seite einen Standort zuweisen, auf den später über Module oder Insert-Tags zugegriffen werden kann. + Hier können Sie der Seite einen Standort zuweisen, auf den später über Module oder Insert-Tags zugegriffen werden kann Specify marketing type diff --git a/src/Resources/contao/languages/de/tl_real_estate_type.xlf b/src/Resources/contao/languages/de/tl_real_estate_type.xlf index 3793fbc2..4bd3cf34 100644 --- a/src/Resources/contao/languages/de/tl_real_estate_type.xlf +++ b/src/Resources/contao/languages/de/tl_real_estate_type.xlf @@ -190,12 +190,12 @@ Bitte geben Sie die Sortieroptionen an. - Primary fields - Primäre Felder + Primary details + Primäre Details - Please enter the primary fields. - Bitte geben Sie die primären Felder an. + Please enter the primary details. + Bitte geben Sie die primären Details an. Primary attributes diff --git a/src/Resources/contao/languages/de/tl_real_estate_value.xlf b/src/Resources/contao/languages/de/tl_real_estate_value.xlf index 06d1eb65..f4d4bd6d 100644 --- a/src/Resources/contao/languages/de/tl_real_estate_value.xlf +++ b/src/Resources/contao/languages/de/tl_real_estate_value.xlf @@ -389,7 +389,7 @@ Loft / Atelier (office) - Lost / Atiler (Büro) + Loft / Atelier (Büro) Facility (office) diff --git a/src/Resources/contao/languages/en/modules.xlf b/src/Resources/contao/languages/en/modules.xlf index f6ae11a1..487c3c27 100644 --- a/src/Resources/contao/languages/en/modules.xlf +++ b/src/Resources/contao/languages/en/modules.xlf @@ -184,6 +184,12 @@ Enables the output of a form produced by the form generator. + + Attachments + + + Outputs attachments of the real estate. + Cover picture @@ -233,7 +239,7 @@ - Property description + Description Furnishings @@ -248,7 +254,7 @@ Short description - Property text + Text diff --git a/src/Resources/contao/languages/en/tl_expose_module.xlf b/src/Resources/contao/languages/en/tl_expose_module.xlf index 4af27a5c..17778b4f 100644 --- a/src/Resources/contao/languages/en/tl_expose_module.xlf +++ b/src/Resources/contao/languages/en/tl_expose_module.xlf @@ -119,7 +119,7 @@ Use the forwarding mode stored in the provider. If you use this function, the telephone number (Headquarters) and e-mail (Headquarters) are overwritten if necessary. - Gallery Modules + Gallery Categories Select and sort the images that should be output by this module. @@ -149,16 +149,16 @@ Here you can limit the number of items. Set to 0 to show all. - Detail blocks + Detail Categories Define the order and output of the details. Keep in mind that the sequence of the individual fields can be defined using the object types. - Summarize detail blocks + Summarize detail categories - Instead of individual blocks, the details are summarized in a list. + Instead of individual categories, the details are summarized in a list. Add real estate address @@ -218,7 +218,7 @@ Select which share-options should be available. - 'Send via e-mail' template + Send via e-mail template HTML code @@ -268,6 +268,24 @@ Open the full size image in a lightbox or open it in a new browser window. + + Attachment type + + + Please select an attachment type. + + + Allowed file extensions + + + Please provide a comma-separated list of file extensions which should not be output. (e.g pdf,doc) + + + Force download + + + Forces the download of the file + \ No newline at end of file diff --git a/src/Resources/contao/languages/en/tl_real_estate_type.xlf b/src/Resources/contao/languages/en/tl_real_estate_type.xlf index 31b22418..d9930620 100644 --- a/src/Resources/contao/languages/en/tl_real_estate_type.xlf +++ b/src/Resources/contao/languages/en/tl_real_estate_type.xlf @@ -144,10 +144,10 @@ Please enter the sorting options. - Primary fields + Primary details - Please enter the primary fields. + Please enter the primary details. Primary attributes diff --git a/src/Resources/contao/languages/es/tl_real_estate_value.xlf b/src/Resources/contao/languages/es/tl_real_estate_value.xlf index 073e4413..9550045f 100644 --- a/src/Resources/contao/languages/es/tl_real_estate_value.xlf +++ b/src/Resources/contao/languages/es/tl_real_estate_value.xlf @@ -48,7 +48,7 @@ Business - Commercial + Comercio Investment diff --git a/src/Resources/contao/modules/ExposeModuleAttachments.php b/src/Resources/contao/modules/ExposeModuleAttachments.php new file mode 100644 index 00000000..c5a62246 --- /dev/null +++ b/src/Resources/contao/modules/ExposeModuleAttachments.php @@ -0,0 +1,194 @@ + + */ +class ExposeModuleAttachments extends ExposeModule +{ + /** + * Files object + * @var Collection|FilesModel + */ + protected $objDocuments; + + /** + * Link array + * @var array + */ + protected $arrLinks; + + /** + * Template + * @var string + */ + protected $strTemplate = 'expose_mod_attachments'; + + /** + * Do not display the module if there are no real estates + * + * @return string + */ + public function generate() + { + if (TL_MODE == 'BE') + { + $objTemplate = new \BackendTemplate('be_wildcard'); + $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['attachments'][0]) . ' ###'; + $objTemplate->title = $this->headline; + $objTemplate->id = $this->id; + $objTemplate->link = $this->name; + $objTemplate->href = 'contao/main.php?do=expose_module&act=edit&id=' . $this->id; + + return $objTemplate->parse(); + } + + switch($this->attachmentType) + { + case 'documents': + $arrDocuments = \StringUtil::deserialize($this->realEstate->documents); + + // Return if there are no files + if (empty($arrDocuments) && !\is_array($arrDocuments)) + { + return ''; + } + + // Get the file entries from the database + $this->objDocuments = \FilesModel::findMultipleByUuids($arrDocuments); + + if ($this->objDocuments === null) + { + return ''; + } + + $file = \Input::get('file', true); + + // Send the file to the browser (see #4632 and #8375) + if ($file != '' && (!isset($_GET['cid']) || \Input::get('cid') == $this->id)) + { + while ($this->objDocuments->next()) + { + if ($file == $this->objDocuments->path || \dirname($file) == $this->objDocuments->path) + { + \Controller::sendFileToBrowser($file, (bool) !$this->forceDownload); + } + } + + if (isset($_GET['cid'])) + { + throw new \PageNotFoundException('Invalid file name'); + } + + $this->objDocuments->reset(); + } + break; + case 'links': + $this->arrLinks = \StringUtil::deserialize($this->realEstate->links, true); + + // Return if there are no links + if (empty($this->arrLinks) && !\is_array($this->arrLinks)) + { + return ''; + } + + break; + } + + $strBuffer = parent::generate(); + + return $this->isEmpty ? '' : $strBuffer; + } + + /** + * Generate the module + */ + protected function compile() + { + $arrCollection = array(); + + switch($this->attachmentType) + { + case 'documents': + $allowedExtensions = \StringUtil::trimsplit(',', strtolower($this->allowedFileExtensions)); + + $objFiles = $this->objDocuments; + + // Get all files + while ($objFiles->next()) + { + // Continue if the files has been processed or does not exist + if (!file_exists(\System::getContainer()->getParameter('kernel.project_dir') . '/' . $objFiles->path)) + { + continue; + } + + $objFile = new \File($objFiles->path); + + if (!\in_array($objFile->extension, $allowedExtensions)) + { + continue; + } + + + $objAttachment = new \stdClass(); + + $objAttachment->title = \StringUtil::specialchars($objFile->filename); + $objAttachment->name = \StringUtil::specialchars($objFile->basename); + $objAttachment->filesize = $this->getReadableSize($objFile->filesize); + $objAttachment->mime = $objFile->mime; + $objAttachment->extension = $objFile->extension; + + $strHref = \Environment::get('request'); + + // Remove an existing file parameter (see #5683) + if (isset($_GET['file'])) + { + $strHref = preg_replace('/(&(amp;)?|\?)file=[^&]+/', '', $strHref); + } + + if (isset($_GET['cid'])) + { + $strHref = preg_replace('/(&(amp;)?|\?)cid=\d+/', '', $strHref); + } + + $strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFiles->path) . '&cid=' . $this->id; + + $objAttachment->href = $strHref; + + $arrCollection[] = $objAttachment; + } + + break; + case 'links': + foreach ($this->arrLinks as $link){ + $objAttachment = new \stdClass(); + $objAttachment->href = $link; + $objAttachment->extension = 'link'; + + $arrCollection[] = $objAttachment; + } + + break; + } + + if(empty($arrCollection)) + { + $this->isEmpty = true; + } + + $this->Template->attachments = $arrCollection; + } +} \ No newline at end of file diff --git a/src/Resources/contao/modules/ExposeModuleTexts.php b/src/Resources/contao/modules/ExposeModuleTexts.php index bffeff2a..d6f2eecf 100644 --- a/src/Resources/contao/modules/ExposeModuleTexts.php +++ b/src/Resources/contao/modules/ExposeModuleTexts.php @@ -25,7 +25,7 @@ class ExposeModuleTexts extends ExposeModule protected $strTemplate = 'expose_mod_texts'; /** - * Do not display the module if there are no real etates + * Do not display the module if there are no real estates * * @return string */ diff --git a/src/Resources/contao/templates/modules/expose_mod_attachments.html5 b/src/Resources/contao/templates/modules/expose_mod_attachments.html5 new file mode 100644 index 00000000..9fca20c8 --- /dev/null +++ b/src/Resources/contao/templates/modules/expose_mod_attachments.html5 @@ -0,0 +1,17 @@ +extend('block_unsearchable'); ?> + +block('content'); ?> + + + +endblock(); ?> \ No newline at end of file