From 31c177f3e664c1aa383be4c353c1aef0194d92fc Mon Sep 17 00:00:00 2001 From: doishub Date: Thu, 23 Jan 2020 10:20:50 +0100 Subject: [PATCH] Adding location field and translations --- src/Resources/contao/dca/tl_module.php | 2 +- .../contao/dca/tl_recommendation.php | 15 +- src/Resources/contao/languages/de/default.xlf | 4 + .../contao/languages/de/tl_recommendation.xlf | 4 + src/Resources/contao/languages/en/default.xlf | 12 ++ src/Resources/contao/languages/en/modules.xlf | 33 ++++ .../contao/languages/en/tl_module.xlf | 39 ++++ .../contao/languages/en/tl_recommendation.xlf | 177 ++++++++++++++++++ .../en/tl_recommendation_archive.xlf | 84 +++++++++ .../en/tl_recommendation_settings.xlf | 21 +++ src/Resources/contao/languages/en/tl_user.xlf | 21 +++ .../contao/languages/en/tl_user_group.xlf | 9 + .../contao/models/RecommendationModel.php | 1 + .../contao/modules/ModuleRecommendation.php | 17 +- .../recommendation/recommendation_full.html5 | 5 +- .../recommendation_latest.html5 | 5 +- 16 files changed, 434 insertions(+), 15 deletions(-) create mode 100644 src/Resources/contao/languages/en/default.xlf create mode 100644 src/Resources/contao/languages/en/modules.xlf create mode 100644 src/Resources/contao/languages/en/tl_module.xlf create mode 100644 src/Resources/contao/languages/en/tl_recommendation.xlf create mode 100644 src/Resources/contao/languages/en/tl_recommendation_archive.xlf create mode 100644 src/Resources/contao/languages/en/tl_recommendation_settings.xlf create mode 100644 src/Resources/contao/languages/en/tl_user.xlf create mode 100644 src/Resources/contao/languages/en/tl_user_group.xlf diff --git a/src/Resources/contao/dca/tl_module.php b/src/Resources/contao/dca/tl_module.php index f5b84db..f472b21 100644 --- a/src/Resources/contao/dca/tl_module.php +++ b/src/Resources/contao/dca/tl_module.php @@ -39,7 +39,7 @@ 'default' => array('date', 'author'), 'exclude' => true, 'inputType' => 'checkbox', - 'options' => array('date', 'author', 'rating'), + 'options' => array('date', 'author', 'rating', 'location'), 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array('multiple'=>true), 'sql' => "varchar(255) NOT NULL default ''" diff --git a/src/Resources/contao/dca/tl_recommendation.php b/src/Resources/contao/dca/tl_recommendation.php index a0dd8eb..bb8ef20 100644 --- a/src/Resources/contao/dca/tl_recommendation.php +++ b/src/Resources/contao/dca/tl_recommendation.php @@ -110,7 +110,7 @@ // Palettes 'palettes' => array ( - 'default' => '{title_legend},title,alias,author;{date_legend},date,time;{recommendation_legend},rating,text,imageUrl;{teaser_legend:hide},teaser;{expert_legend:hide},cssClass,featured;{publish_legend},published,start,stop' + 'default' => '{title_legend},title,alias;{date_legend},date,time;{recommendation_legend},author,location,text,imageUrl,rating;{teaser_legend:hide},teaser;{expert_legend:hide},cssClass,featured;{publish_legend},published,start,stop' ), // Fields @@ -147,7 +147,7 @@ 'exclude' => true, 'search' => true, 'inputType' => 'text', - 'eval' => array('rgxp'=>'alias', 'doNotCopy'=>true, 'unique'=>true, 'maxlength'=>128, 'tl_class'=>'w50 clr'), + 'eval' => array('rgxp'=>'alias', 'doNotCopy'=>true, 'unique'=>true, 'maxlength'=>128, 'tl_class'=>'w50'), 'save_callback' => array ( array('tl_recommendation', 'generateAlias') @@ -165,6 +165,17 @@ 'eval' => array('doNotCopy'=>true, 'mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'), 'sql' => "varchar(128) NOT NULL default ''" ), + 'location' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_recommendation']['location'], + 'exclude' => true, + 'search' => true, + 'sorting' => true, + 'flag' => 1, + 'inputType' => 'text', + 'eval' => array('doNotCopy'=>true, 'maxlength'=>128, 'tl_class'=>'w50'), + 'sql' => "varchar(128) NOT NULL default ''" + ), 'date' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_recommendation']['date'], diff --git a/src/Resources/contao/languages/de/default.xlf b/src/Resources/contao/languages/de/default.xlf index dc1c519..00bba05 100644 --- a/src/Resources/contao/languages/de/default.xlf +++ b/src/Resources/contao/languages/de/default.xlf @@ -5,6 +5,10 @@ Rating Bewertung + + Location + Ort + diff --git a/src/Resources/contao/languages/de/tl_recommendation.xlf b/src/Resources/contao/languages/de/tl_recommendation.xlf index eb0e6dd..5ec459d 100644 --- a/src/Resources/contao/languages/de/tl_recommendation.xlf +++ b/src/Resources/contao/languages/de/tl_recommendation.xlf @@ -21,6 +21,10 @@ Author Autor + + Location + Ort + Here you can change the author of the recommendation. Hier können Sie den Autor der Bewertung ändern. diff --git a/src/Resources/contao/languages/en/default.xlf b/src/Resources/contao/languages/en/default.xlf new file mode 100644 index 0000000..5b8ff3c --- /dev/null +++ b/src/Resources/contao/languages/en/default.xlf @@ -0,0 +1,12 @@ + + + + + Rating + + + Location + + + + diff --git a/src/Resources/contao/languages/en/modules.xlf b/src/Resources/contao/languages/en/modules.xlf new file mode 100644 index 0000000..50fa74f --- /dev/null +++ b/src/Resources/contao/languages/en/modules.xlf @@ -0,0 +1,33 @@ + + + + + Recommendations + + + Manage recommendations + + + Recommendation settings + + + Configure recommendation settings + + + Recommendations + + + Recommendationlist + + + Adds a list of recommendations to the page + + + Recommendationreader + + + Shows the details of a recommendation + + + + diff --git a/src/Resources/contao/languages/en/tl_module.xlf b/src/Resources/contao/languages/en/tl_module.xlf new file mode 100644 index 0000000..960eb81 --- /dev/null +++ b/src/Resources/contao/languages/en/tl_module.xlf @@ -0,0 +1,39 @@ + + + + + Recommendation archives + + + Please select one or more recommendation archives. + + + Featured items + + + Here you can choose how featured items are handled. + + + Meta fields + + + Here you can select the meta fields. + + + Recommendation template + + + Here you can select the recommendation template. + + + Show all recommendations + + + Show featured recommendation only + + + Skip featured recommendations + + + + diff --git a/src/Resources/contao/languages/en/tl_recommendation.xlf b/src/Resources/contao/languages/en/tl_recommendation.xlf new file mode 100644 index 0000000..d9376d0 --- /dev/null +++ b/src/Resources/contao/languages/en/tl_recommendation.xlf @@ -0,0 +1,177 @@ + + + + + Title + + + Please enter the recommendation title. + + + Recommendation alias + + + The recommendation alias is a unique reference to the recommendation which can be called instead of its numeric ID. + + + Author + + + Location + + + Here you can change the author of the recommendation. + + + Date + + + Please enter the date according to the global date format. + + + Time + + + Please enter the time according to the global time format. + + + Rating + + + Here you can enter a recommendation. + + + Recommendation teaser + + + The recommendation teaser can be shown in a recommendation list instead of the full text. A "read more …" link will be added automatically. + + + recommendation text + + + Here you can enter the recommendation text. + + + Image + + + Here you can enter a recommendation image. + + + CSS class + + + Here you can enter one or more classes. + + + Feature recommendation + + + Show the recommendation in a featured recommendation list. + + + Publish recommendation + + + Make the recommendation publicly visible on the website. + + + Show from + + + Do not show the recommendation on the website before this day. + + + Show until + + + Do not show the recommendation on the website on and after this day. + + + Revision date + + + Date and time of the latest revision + + + Title and author + + + Date and time + + + Recommendation + + + Teaser + + + Expert settings + + + Publish settings + + + New recommendation + + + Create a new recommendation + + + Recommendation details + + + Show the details of recommendation ID %s + + + Edit recommendation + + + Edit recommendation ID %s + + + Duplicate recommendation + + + Duplicate recommendation ID %s + + + Move recommendation + + + Move recommendation ID %s + + + Delete recommendation + + + Delete recommendation ID %s + + + Publish/unpublish recommendation + + + Publish/unpublish recommendation ID %s + + + Feature/unfeature recommendation + + + Feature/unfeature recommendation ID %s + + + Edit recommendation settings + + + Edit the recommendation settings + + + Paste into this recommendation archive + + + Paste after recommendation ID %s + + + + diff --git a/src/Resources/contao/languages/en/tl_recommendation_archive.xlf b/src/Resources/contao/languages/en/tl_recommendation_archive.xlf new file mode 100644 index 0000000..65cea85 --- /dev/null +++ b/src/Resources/contao/languages/en/tl_recommendation_archive.xlf @@ -0,0 +1,84 @@ + + + + + Title + + + Please enter a news archive title. + + + Redirect page + + + Please choose the recommendation reader page to which visitors will be redirected when clicking a recommendation. + + + Protect archive + + + Show recommendations to certain member groups only. + + + Allowed member groups + + + These groups will be able to see the recommendations in this archive. + + + Revision date + + + Date and time of the latest revision + + + Title and redirect page + + + Access protection + + + Settings + + + Recommendation settings + + + New archive + + + Create a new archive + + + Archive details + + + Show the details of archive ID %s + + + Edit archive + + + Edit archive ID %s + + + Edit archive + + + Edit the archive settings + + + Duplicate archive + + + Duplicate archive ID %s + + + Delete archive + + + Delete archive ID %s + + + + diff --git a/src/Resources/contao/languages/en/tl_recommendation_settings.xlf b/src/Resources/contao/languages/en/tl_recommendation_settings.xlf new file mode 100644 index 0000000..e4e3396 --- /dev/null +++ b/src/Resources/contao/languages/en/tl_recommendation_settings.xlf @@ -0,0 +1,21 @@ + + + + + Default image + + + The default image is displayed for recommendations that have not set their own image. + + + Color of active stars + + + Color value will be set as inline css style in the html code. + + + Settings + + + + diff --git a/src/Resources/contao/languages/en/tl_user.xlf b/src/Resources/contao/languages/en/tl_user.xlf new file mode 100644 index 0000000..26da2b3 --- /dev/null +++ b/src/Resources/contao/languages/en/tl_user.xlf @@ -0,0 +1,21 @@ + + + + + Allowed archives + + + Here you can grant access to one or more recommendation archives. + + + Recommendation permissions + + + Here you can define the recommendation permissions. + + + Recommendation permissions + + + + diff --git a/src/Resources/contao/languages/en/tl_user_group.xlf b/src/Resources/contao/languages/en/tl_user_group.xlf new file mode 100644 index 0000000..e79a5e2 --- /dev/null +++ b/src/Resources/contao/languages/en/tl_user_group.xlf @@ -0,0 +1,9 @@ + + + + + Recommendation permissions + + + + diff --git a/src/Resources/contao/models/RecommendationModel.php b/src/Resources/contao/models/RecommendationModel.php index 786fc9d..8a1e93c 100644 --- a/src/Resources/contao/models/RecommendationModel.php +++ b/src/Resources/contao/models/RecommendationModel.php @@ -15,6 +15,7 @@ * @property integer $pid * @property integer $tstamp * @property integer $author + * @property integer $location * @property string $alias * @property integer $date * @property integer $time diff --git a/src/Resources/contao/modules/ModuleRecommendation.php b/src/Resources/contao/modules/ModuleRecommendation.php index 6cb9029..1acd814 100644 --- a/src/Resources/contao/modules/ModuleRecommendation.php +++ b/src/Resources/contao/modules/ModuleRecommendation.php @@ -109,10 +109,12 @@ protected function parseRecommendation($objRecommendation, $objRecommendationArc // Add the meta information $objTemplate->addRating = array_key_exists('rating', $arrMeta); $objTemplate->addDate = array_key_exists('date', $arrMeta); - $objTemplate->date = $arrMeta['date']; + $objTemplate->datetime = date('Y-m-d\TH:i:sP', $objRecommendation->date); + $objTemplate->date = $arrMeta['date']; $objTemplate->addAuthor = array_key_exists('author', $arrMeta); - $objTemplate->author = $arrMeta['author']; - $objTemplate->datetime = date('Y-m-d\TH:i:sP', $objRecommendation->date); + $objTemplate->author = $arrMeta['author']; + $objTemplate->addLocation = array_key_exists('location', $arrMeta); + $objTemplate->location = $arrMeta['location']; // Add styles $color = unserialize(\Config::get('recommendationActiveColor'))[0]; @@ -221,13 +223,8 @@ protected function getMetaFields($objRecommendation) $return['date'] = \Date::parse($objPage->datimFormat, $objRecommendation->date); break; - case 'author': - $return['author'] = $objRecommendation->author; - break; - - case 'rating': - $return['rating'] = $objRecommendation->rating; - break; + default: + $return[ $field ] = $objRecommendation->{$field}; } } diff --git a/src/Resources/contao/templates/recommendation/recommendation_full.html5 b/src/Resources/contao/templates/recommendation/recommendation_full.html5 index 24b3bfc..dfa9021 100644 --- a/src/Resources/contao/templates/recommendation/recommendation_full.html5 +++ b/src/Resources/contao/templates/recommendation/recommendation_full.html5 @@ -13,11 +13,14 @@ - addAuthor || $this->addDate || $this->addRating): ?> + addAuthor || $this->addDate || $this->addRating || $this->addLocation): ?>
addAuthor): ?>

author ?>

+ addLocation): ?> +

location ?>

+ addDate): ?>

diff --git a/src/Resources/contao/templates/recommendation/recommendation_latest.html5 b/src/Resources/contao/templates/recommendation/recommendation_latest.html5 index 1eaaaf1..5bda689 100644 --- a/src/Resources/contao/templates/recommendation/recommendation_latest.html5 +++ b/src/Resources/contao/templates/recommendation/recommendation_latest.html5 @@ -14,11 +14,14 @@

headlineLink ?>

- addAuthor || $this->addDate || $this->addRating): ?> + addAuthor || $this->addDate || $this->addRating || $this->addLocation): ?>
addAuthor): ?>

author ?>

+ addLocation): ?> +

location ?>

+ addDate): ?>