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
[ticket/10620] Quote improvements #3623
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f02cc27
[ticket/10620] Implemented quote improvements
JoshyPHP c934b8f
[ticket/10620] Updated docblock
JoshyPHP 06936bd
[ticket/10620] Added enhanced quotes in topic review
JoshyPHP 129b337
[ticket/10620] Added enhanced quotes in pm history
JoshyPHP 4f1b257
[ticket/10620] Removed extraneous quotes from attribute values
JoshyPHP 7ce2d99
[ticket/10620] Added tests
JoshyPHP 4c9507e
[ticket/10620] Fixed some stylistic issues in JS
JoshyPHP 5a55ce3
[ticket/10620] Add more whitespace to long quotes in JS
JoshyPHP 1f6b9bc
[ticket/10620] Fixed functional tests to account for newlines
JoshyPHP 9d364ae
[ticket/10620] Moved quote's date to the upper corner
JoshyPHP File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* | ||
* This file is part of the phpBB Forum Software package. | ||
* | ||
* @copyright (c) phpBB Limited <https://www.phpbb.com> | ||
* @license GNU General Public License, version 2 (GPL-2.0) | ||
* | ||
* For full copyright and license information, please see | ||
* the docs/CREDITS.txt file. | ||
* | ||
*/ | ||
|
||
namespace phpbb\textformatter\s9e; | ||
|
||
class quote_helper | ||
{ | ||
/** | ||
* @var string Base URL for a post link, uses {POST_ID} as placeholder | ||
*/ | ||
protected $post_url; | ||
|
||
/** | ||
* @var string Base URL for a profile link, uses {USER_ID} as placeholder | ||
*/ | ||
protected $profile_url; | ||
|
||
/** | ||
* @var \phpbb\user | ||
*/ | ||
protected $user; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param \phpbb\user $user | ||
* @param string $root_path | ||
* @param string $php_ext | ||
*/ | ||
public function __construct(\phpbb\user $user, $root_path, $php_ext) | ||
{ | ||
$this->post_url = append_sid($root_path . 'viewtopic.' . $php_ext, 'p={POST_ID}#p{POST_ID}'); | ||
$this->profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=viewprofile&u={USER_ID}'); | ||
$this->user = $user; | ||
} | ||
|
||
/** | ||
* Inject dynamic metadata into QUOTE tags in given XML | ||
* | ||
* @param string $xml Original XML | ||
* @return string Modified XML | ||
*/ | ||
public function inject_metadata($xml) | ||
{ | ||
$post_url = $this->post_url; | ||
$profile_url = $this->profile_url; | ||
$user = $this->user; | ||
|
||
return \s9e\TextFormatter\Utils::replaceAttributes( | ||
$xml, | ||
'QUOTE', | ||
function ($attributes) use ($post_url, $profile_url, $user) | ||
{ | ||
if (isset($attributes['post_id'])) | ||
{ | ||
$attributes['post_url'] = str_replace('{POST_ID}', $attributes['post_id'], $post_url); | ||
} | ||
if (isset($attributes['time'])) | ||
{ | ||
$attributes['date'] = $user->format_date($attributes['time']); | ||
} | ||
if (isset($attributes['user_id'])) | ||
{ | ||
$attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $profile_url); | ||
} | ||
|
||
return $attributes; | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
idk what syntax you're using in the docblock but it isn't JSDoc
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 Googled "JSDoc type annotations" and got to this page: http://usejsdoc.org/tags-type.html
That looks like it. Do you want me to remove them or... ?
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.
Sorry, I had never seen the exclamation mark syntax before :)