-
-
Notifications
You must be signed in to change notification settings - Fork 35
Update post.class.php #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
change from softdelete to harddelete
currently only in German ( but can easily changed ) and open per URL https://your-domain.com/cleanup_posts.php
add smiles to post: $emoji_map = [ ':smile:' => '😄', ':laugh:' => '😂', ':wink:' => '😉', ':heart:' => '❤️', ':broken_heart:' => '💔', ':fire:' => '🔥', ':star:' => '⭐', ':check:' => '✅', ':cross:' => '❌', ':thumbs_up:' => '👍', ':thumbs_down:' => '👎', ':clap:' => '👏', ':party:' => '🥳', ':thinking:' => '🤔', ':sweat:' => '😅', ':cry:' => '😢', ':sleep:' => '😴', ':rocket:' => '🚀', ':zap:' => '⚡', ':warning:' => '⚠️ ', ':tada:' => '🎉', ':coffee:' => '☕', ':cake:' => '🍰', ':sun:' => '☀️', ':moon:' => '🌙', ':cloud:' => '☁️', ':rainbow:' => '🌈', ':flower:' => '🌸', ':dog:' => '🐶', ':cat:' => '🐱', ]; foreach($emoji_map as $code => $emoji){ $data['text'] = str_replace($code, $emoji, $data['text']); }
more bbcode with Picker, Sticky Post, Emojis with Picker.
remove bbcode, added Markdown with Picker Bar, added HTML Syntax ( Withelisted ) with Picker Bar.
**A toggle button solution was created in the post based on the prior one: Show more, then show fewer!**
Readme Update
change simple colapse to Toggle-Button functionality
change simple colapse to Toggle-Button functionality
added collapse/ expand Animation and some other Animations
added Translation to all lang .ini ( Show Less = "Show Less" )
removed
`
[bbcode]
;bbtags[quote] = "<quote>{param}</quote>"
`
from config.ini
Added function to upload a maximum of 10 images.
Added a function to upload a maximum of 10 images.
Added a function to upload a maximum of 10 images.
Toggle "Show More" / "Show Less" was broken.
el-choco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bbcode replaced with markdown --> done!
multiple photos per post --> done! ( max. 10 Images per Upload or Drag and Drop )
bigger screens --> done max-width is now 1000px but still responsive!
and added some other functionality like HTML Picker Bar, Smilies etc., tell me what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request changes the post deletion mechanism from soft delete to hard delete, along with adding emoji support, UI improvements, and various configuration updates.
Key Changes
- Hard Delete Implementation: Posts are now permanently deleted from the database instead of being marked as deleted (status=5)
- Emoji Support: Added emoji shortcode conversion (
:smile:→ 😄) in post creation and editing - UI/UX Enhancements: Expanded layout widths, improved sticky post styling, multi-image gallery support, and collapsible text with "Show Less" functionality
Reviewed Changes
Copilot reviewed 24 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
app/post.class.php |
Implements hard delete, adds emoji mapping (with duplication issues), fixes indentation |
app/ajax.class.php |
Fixes spelling error, adds UTF-8 charset and emoji-safe JSON encoding |
ajax.php |
Refactors method calling to use static invocation, improves code formatting |
app/lang/*.ini |
Adds "Show Less" translations across all supported languages |
config.ini |
Uncomments SQLite database path, removes BBCode section |
docker-compose.yml |
Updates image source, timezone, and port mapping |
static/styles/*.css |
Extensive CSS changes for layout widths, sticky posts, galleries, and responsive design |
static/scripts/app.js |
Adds multi-image upload, sticky post toggle, collapsible text, and gallery features |
static/images/* |
New cover and profile images |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $emoji_map = [ | ||
| ':smile:' => '😄', | ||
| ':laugh:' => '😂', | ||
| ':wink:' => '😉', | ||
| ':heart:' => '❤️', | ||
| ':broken_heart:' => '💔', | ||
| ':fire:' => '🔥', | ||
| ':star:' => '⭐', | ||
| ':check:' => '✅', | ||
| ':cross:' => '❌', | ||
| ':thumbs_up:' => '👍', | ||
| ':thumbs_down:' => '👎', | ||
| ':clap:' => '👏', | ||
| ':party:' => '🥳', | ||
| ':thinking:' => '🤔', | ||
| ':sweat:' => '😅', | ||
| ':cry:' => '😢', | ||
| ':sleep:' => '😴', | ||
| ':rocket:' => '🚀', | ||
| ':zap:' => '⚡', | ||
| ':warning:' => '⚠️', | ||
| ':tada:' => '🎉', | ||
| ':coffee:' => '☕', | ||
| ':cake:' => '🍰', | ||
| ':sun:' => '☀️', | ||
| ':moon:' => '🌙', | ||
| ':cloud:' => '☁️', | ||
| ':rainbow:' => '🌈', | ||
| ':flower:' => '🌸', | ||
| ':dog:' => '🐶', | ||
| ':cat:' => '🐱', | ||
| ]; | ||
| foreach($emoji_map as $code => $emoji){ | ||
| $data['text'] = str_replace($code, $emoji, $data['text']); | ||
| } | ||
|
|
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The emoji mapping array is duplicated in both the insert() and update() methods (lines 129-164 and 183-217). This violates the DRY principle and makes maintenance harder. Consider extracting this to a private static method or class constant.
Example:
private static $emoji_map = [
':smile:' => '😄',
// ... rest of mappings
];
// Then in both methods:
foreach(self::$emoji_map as $code => $emoji){
$data['text'] = str_replace($code, $emoji, $data['text']);
}
app/post.class.php
Outdated
| ]; | ||
| foreach($emoji_map as $code => $emoji){ | ||
| $data['text'] = str_replace($code, $emoji, $data['text']); | ||
| } |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: The code uses spaces for indentation but line 163 appears to use tabs. Ensure consistent indentation (spaces vs tabs) throughout the file.
| } | |
| } |
app/post.class.php
Outdated
| ':rainbow:' => '🌈', | ||
| ':flower:' => '🌸', | ||
| ':dog:' => '🐶', | ||
| ':cat:' => '🐱', |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace on line 213 after :cat: mapping. Remove the tab/space character after the comma.
| ':cat:' => '🐱', | |
| ':cat:' => '🐱', |
app/post.class.php
Outdated
| public static function delete($r){ | ||
| self::login_protected(); | ||
| self::login_protected(); | ||
|
|
||
| DB::get_instance()->query(" | ||
| DELETE FROM `posts` | ||
| WHERE `id` = ? | ||
| ", $r["id"]); | ||
|
|
||
| return true; | ||
| } |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing from soft delete (UPDATE status=5) to hard delete (DELETE) is a breaking change with significant implications:
- Data Loss: Deleted posts cannot be recovered
- Referential Integrity: This could break foreign key constraints if other tables reference posts
- Audit Trail: There's no record that a post existed and was deleted
Consider implementing cascading deletes for related data or adding a confirmation mechanism. If this is intentional, ensure backups are in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is a breaking change that could be hidden behind a feature flag. Maybe in config you could set whether you want to have soft or hard delete.
Also when doing hard delete, we should also remove images (if referenced by the post).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would indeed be a great solution, using the feature flag and putting it in the config.ini file.
Regarding deleting images... I completely forgot about that, I'll get on it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added so much that I've lost track...
🎯 Summary
This PR introduces several major features and improvements:
- Multi-image upload (up to 12 images per post)
- German translations for all UI elements
- Trash/Recycle Bin system with restore functionality
- Sticky posts feature
- Improved mobile responsiveness
✨ Features Added
1. Multi-Image Gallery System
- Upload up to 12 images per post (previously 1)
- Support for drag & drop multi-upload
- Visual preview grid with remove buttons
- Responsive grid layout (4 columns desktop, 2 columns mobile)
- All images displayed in posts (no limit)
Files changed:
static/scripts/app.jsstatic/styles/custom1.css
2. German Language Support
- Added
__()translation function incommon.php - Created
lang/de.phpwith German translations - Translated all UI elements:
- "Show More" / "Show Less" → "Mehr Anzeigen" / "Weniger Anzeigen"
- "Delete Permanently" → "Endgültig Löschen"
- All modal dialogs and buttons
Files changed:
common.phplang/de.php(new file)index.phpstatic/scripts/app.js
3. Trash/Recycle Bin Management
- Soft delete posts to trash (configurable)
- Restore posts from trash
- Permanent delete from trash
- Trash count indicator
- Configurable via
config.php:SOFT_DELETE(default: true)HARD_DELETE_FILES(default: true)
Files changed:
classes/post.class.phpindex.phpstatic/scripts/app.js
4. Sticky Posts
- Pin important posts to top of timeline
- Visual indicator (📌 icon)
- Toggle sticky status via post menu
- Highlighted border for sticky posts
Files changed:
classes/post.class.phpstatic/scripts/app.jsstatic/styles/sticky_posts.css(new file)
5. Mobile Improvements
- Centered image galleries on mobile
- Uniform square image aspect ratio (1:1) on mobile
- Full-width gallery on small screens
- Fixed "Show More" toggle button
Files changed:
static/styles/custom1.css
📝 Files Changed
Modified Files:
-
common.php- Added translation function
__() - Added language detection
- Added translation function
-
classes/post.class.php- Added
delete(),permanent_delete(),restore(),list_trash() - Added
toggle_sticky()for sticky posts - Improved image deletion handling
- Added
-
index.php- Added German translations throughout
- Added trash view UI
- Added data attributes for JS translations
- Updated "Show More" button with translation
-
static/scripts/app.js- Changed
maxImagesfrom 10 to 12 - Fixed
updateImageCounter()to use variable - Added multi-file drag & drop support in
filedrop() - Added trash management functions
- Fixed toggle button to use PHP translations
- Fixed "Delete Permanently" dialog translations
- Changed
-
static/styles/custom1.css- Added layouts for 11 and 12 images
- Fixed mobile centering (
.b_contentoverflow: visible) - Added mobile responsive rules
- Force square aspect ratio on mobile
New Files:
lang/de.php- German translation stringsstatic/styles/sticky_posts.css- Sticky post styles
🔧 Configuration
Add to config.php:
// Soft delete (move to trash instead of permanent delete)
define('SOFT_DELETE', true);
// Delete image files when permanently deleting posts
define('HARD_DELETE_FILES', true);
---
# **and some other Stuff**
app/ajax.class.php
Outdated
| header('Content-Type: application/json'); | ||
| echo json_encode($this->_response); | ||
| header('Content-Type: application/json; charset=utf-8'); | ||
| // WICHTIG: JSON_UNESCAPED_UNICODE damit Emojis richtig übertragen werden |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment is in German while the rest of the codebase uses English comments. For consistency, consider:
// IMPORTANT: JSON_UNESCAPED_UNICODE ensures emojis are transmitted correctly| // WICHTIG: JSON_UNESCAPED_UNICODE damit Emojis richtig übertragen werden | |
| // IMPORTANT: JSON_UNESCAPED_UNICODE ensures emojis are transmitted correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it should be in EN.
changed hardcoded comments language to english
change from softdelete to harddelete