From 34bc0400de4955a4281da81c1aab1684ab6a2eda Mon Sep 17 00:00:00 2001 From: Nourmasrieh Date: Tue, 23 May 2023 09:50:34 +0200 Subject: [PATCH] ..... --- client/scss/_socialselement.scss | 18 ++++----- src/Cli/DeleteSocial.php | 8 +--- src/DataObjects/AllPosts.php | 3 ++ src/DataObjects/FacebookProvider.php | 6 ++- src/DataObjects/InstagramProvider.php | 7 +++- src/Elements/SocialsElement.php | 5 ++- src/ModelAdmins/SocialModelAdmin.php | 4 -- .../SocialWall/Includes/ElementStyleA.ss | 19 +++++++-- .../SocialWall/Includes/ElementStyleB.ss | 40 ++++++++++++++++--- 9 files changed, 77 insertions(+), 33 deletions(-) diff --git a/client/scss/_socialselement.scss b/client/scss/_socialselement.scss index 35b1bde..b146ab5 100644 --- a/client/scss/_socialselement.scss +++ b/client/scss/_socialselement.scss @@ -4,7 +4,7 @@ top: 1rem; right: 1rem; i{ - color: $White; + color: #fff; } } .username{ @@ -23,7 +23,7 @@ } } .card-footer { - background-color: $White; + background-color: #fff; & *{ color: $PrimaryColor !important; font-size: 16px !important; @@ -44,9 +44,9 @@ padding: 0; text-decoration: none; text-align: center; - color: $White; + color: #fff; font-weight: normal; - font-size: 22px; + font-size: 24px; line-height: 2; border-radius: 1.6875rem; transition: all 0.5s ease; @@ -54,12 +54,12 @@ margin-bottom: 0.25rem; background: $SecondaryColor; *{ - color: $White !important; + color: #fff !important; } &:hover{ color: $PrimaryColor !important; - background: $White; - border-color: $White; + background: #fff; + border-color: #fff; -webkit-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); @@ -69,8 +69,8 @@ } &:focus { color: $PrimaryColor !important; - background: $White; - border-color: $White; + background: #fff; + border-color: #fff; -webkit-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); diff --git a/src/Cli/DeleteSocial.php b/src/Cli/DeleteSocial.php index c0e07a3..6e9c94b 100644 --- a/src/Cli/DeleteSocial.php +++ b/src/Cli/DeleteSocial.php @@ -10,12 +10,8 @@ class DeleteSocial extends BuildTask protected $description = 'Delete Social(Facebook + Instagram)'; public function run($request) { - $listFacebookPosts = FacebookPosts::get(); - foreach($listFacebookPosts as $item) { - $item->delete(); - } - $listInstagramPosts = InstagramPosts::get(); - foreach($listInstagramPosts as $item) { + $listPosts = AllPosts::get(); + foreach($listPosts as $item) { $item->delete(); } } diff --git a/src/DataObjects/AllPosts.php b/src/DataObjects/AllPosts.php index 5f7e5d6..82923b0 100644 --- a/src/DataObjects/AllPosts.php +++ b/src/DataObjects/AllPosts.php @@ -10,6 +10,9 @@ class AllPosts extends DataObject { + private static $singular_name = 'Posts'; + private static $plural_name = 'Facebook und Instagram Posts'; + private static $table_name = 'SocialPosts'; private static $db = [ 'PlatformID' => 'Text', 'PlatformLink' => 'Text', diff --git a/src/DataObjects/FacebookProvider.php b/src/DataObjects/FacebookProvider.php index b1409e5..610cdf3 100644 --- a/src/DataObjects/FacebookProvider.php +++ b/src/DataObjects/FacebookProvider.php @@ -2,6 +2,7 @@ namespace NourAlmasrieh\SocialWall; +use SilverStripe\Dev\Debug; use SilverStripe\Assets\Image; use SilverStripe\Assets\Folder; use SilverStripe\ORM\DataObject; @@ -92,9 +93,10 @@ public function RequestFreshData() $file->publishFile(); $newpost->BildID = $fileID; } - $content = $posts['message']; + /*$content = $posts['message']; $content1 = preg_replace('/[^\p{L}\p{N}\s]/u', '', $content); - $newpost->Message = $content1; + $newpost->Message = $content1;*/ + $newpost->Message = $posts["message"]; $newpost->CreatedDate = $posts["updated_time"]; $newpost->UserName = $posts["username"]; $newpost->PlatformLink = $posts["permalink_url"]; diff --git a/src/DataObjects/InstagramProvider.php b/src/DataObjects/InstagramProvider.php index 446bef3..8b1eec3 100644 --- a/src/DataObjects/InstagramProvider.php +++ b/src/DataObjects/InstagramProvider.php @@ -2,6 +2,7 @@ namespace NourAlmasrieh\SocialWall; +use SilverStripe\Dev\Debug; use SilverStripe\Assets\Image; use SilverStripe\Assets\Folder; use SilverStripe\ORM\DataObject; @@ -102,9 +103,11 @@ public function RequestFreshData() $newpost->BildID = $fileID; } } - $content = $posts['caption']; + /*$content = $posts['caption']; $content1 = preg_replace('/[^\p{L}\p{N}\s]/u', '', $content); - $newpost->Message = $content1; + $newpost->Message = $content1;*/ + $newpost->Message = $posts["caption"]; + Debug::dump($newpost->Message);die; $newpost->CreatedDate = $posts["timestamp"]; $newpost->PlatformLink = $posts["permalink"]; $newpost->Platform = "instagram"; diff --git a/src/Elements/SocialsElement.php b/src/Elements/SocialsElement.php index 201ca43..58888ab 100644 --- a/src/Elements/SocialsElement.php +++ b/src/Elements/SocialsElement.php @@ -75,8 +75,9 @@ public function getCMSFields() $columns = array_keys($allFields); $fields->insertBefore('Title', DropdownField::create('PostsStyle', 'Posts', [ - 'mixed' => 'Zufällige Posts', + 'mixed' => 'Zufällige Posts (Neueste Post) angezeitgt wird', 'custom' => 'Spezielle Auswahl - Posts können individuell angepasst werden', + 'bothstyle' => 'Erste 4er-Reihe - die Neueste Post & Zweite 4er-Reihe - die besondere Post können angepasst werden', ])->setEmptyString('Auswählen')); $fields->addFieldsToTab('Root.Main', ColorField::create('BackgroundColor','Hintergrund Farbe')); $fields->addFieldsToTab('Root.Main', TextField::create('SubTitle', 'SubTitle'));; @@ -93,7 +94,7 @@ public function getCMSFields() $fields->addFieldToTab('Root.Main', CheckboxField::create('ShowOnInstagram', 'Sollen nur die Posts von Instagram angezeigt?')); $fields->addFieldToTab('Root.Main', CheckboxField::create('ShowOnMasonry', 'In Masonry angezeigt?')); - if ($this->PostsStyle == 'custom') { + if ($this->PostsStyle == 'custom' || $this->owner->PostsStyle == 'bothstyle') { $fields->addFieldsToTab('Root.Posts', GridField::create( 'SpeziellePosts', diff --git a/src/ModelAdmins/SocialModelAdmin.php b/src/ModelAdmins/SocialModelAdmin.php index ccbdc6e..9254175 100644 --- a/src/ModelAdmins/SocialModelAdmin.php +++ b/src/ModelAdmins/SocialModelAdmin.php @@ -7,17 +7,13 @@ class SocialModelAdmin extends ModelAdmin { - private static $managed_models = [ AllConfSocial::class, FacebookProvider::class, InstagramProvider::class, AllPosts::class, - FacebookPosts::class, - InstagramPosts::class, ]; private static $url_segment = 'socialadmin'; private static $menu_title = 'Social Admin'; private static $menu_icon_class = 'font-icon-thumbnails'; - } diff --git a/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleA.ss b/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleA.ss index 821ce72..08f1a59 100644 --- a/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleA.ss +++ b/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleA.ss @@ -1,7 +1,13 @@
- <% if $PostsStyle == custom %> + <% if $PostsStyle == 'mixed' %> + <% loop $getOnPosts.Sort('CreatedDate', 'DESC') %> +
+ <% include NourAlmasrieh\SocialWall\Includes\Slides %> +
+ <% end_loop %> + <% else_if $PostsStyle == 'custom' %> <% loop $SpeziellePosts.Sort('SortOrder', 'ASC') %> <% with $AllPosts %>
@@ -9,12 +15,19 @@
<% end_with %> <% end_loop %> - <% else %> - <% loop $getOnPosts.Sort('CreatedDate', 'DESC') %> + <% else_if $PostsStyle == 'bothstyle' %> + <% loop $getOnPosts.Sort('CreatedDate', 'DESC').Limit(4) %>
<% include NourAlmasrieh\SocialWall\Includes\Slides %>
<% end_loop %> + <% loop $SpeziellePosts.Sort('SortOrder', 'ASC').Limit(4) %> + <% with $AllPosts %> +
+ <% include NourAlmasrieh\SocialWall\Includes\Slides %> +
+ <% end_with %> + <% end_loop %> <% end_if %>
diff --git a/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleB.ss b/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleB.ss index a3bebd0..836d7bc 100644 --- a/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleB.ss +++ b/templates/NourAlmasrieh/SocialWall/Includes/ElementStyleB.ss @@ -1,6 +1,20 @@
data-masonry='{"percentPosition": true }'<% end_if %>> - <% if $PostsStyle == custom %> + <% if $PostsStyle == 'mixed' %> + <% if $ShowOnMasonry %> + <% loop $getOnPosts.Sort('CreatedDate', 'DESC') %> +
+ <% include NourAlmasrieh\SocialWall\Includes\Cards %> +
+ <% end_loop %> + <% else %> + <% loop $getOnPosts.Sort('CreatedDate', 'DESC') %> +
+ <% include NourAlmasrieh\SocialWall\Includes\Slides %> +
+ <% end_loop %> + <% end_if %> + <% else_if $PostsStyle == 'custom' %> <% if $ShowOnMasonry %> <% loop $SpeziellePosts.Sort('SortOrder', 'ASC') %> <% with $AllPosts %> @@ -18,23 +32,38 @@ <% end_with %> <% end_loop %> <% end_if %> - <% else %> + <% else_if $PostsStyle == 'bothstyle' %> <% if $ShowOnMasonry %> - <% loop $getOnPosts.Sort('CreatedDate', 'DESC') %> + <% loop $getOnPosts.Sort('CreatedDate', 'DESC').Limit(4) %>
<% include NourAlmasrieh\SocialWall\Includes\Cards %>
<% end_loop %> + <% loop $SpeziellePosts.Sort('SortOrder', 'ASC').Limit(4) %> + <% with $AllPosts %> +
+ <% include NourAlmasrieh\SocialWall\Includes\Cards %> +
+ <% end_with %> + <% end_loop %> <% else %> - <% loop $getOnPosts.Sort('CreatedDate', 'DESC') %> + <% loop $getOnPosts.Sort('CreatedDate', 'DESC').Limit(4) %>
<% include NourAlmasrieh\SocialWall\Includes\Slides %>
<% end_loop %> + <% loop $SpeziellePosts.Sort('SortOrder', 'ASC').Limit(4) %> + <% with $AllPosts %> +
+ <% include NourAlmasrieh\SocialWall\Includes\Slides %> +
+ <% end_with %> + <% end_loop %> <% end_if %> <% end_if %>
+<% if $ShowOnMasonry %> \ No newline at end of file + +<% end_if %> \ No newline at end of file