diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..ceb94dc09 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +# Debian version +ARG VARIANT="buster" +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} + +# Install PHP +RUN apt-get -y update +RUN apt-get -y install php php-xml php-mbstring php-curl php-zip php-xdebug + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install MySQL +RUN apt-get -y install mysql-server php-mysql + +# Xdebug +ADD resources/xdebug.ini /etc/php/8.1/apache2/conf.d/xdebug.ini + +# Configure Apache +RUN echo "Listen 8080" >> /etc/apache2/ports.conf && \ + a2enmod rewrite diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..d046885b7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,41 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/ubuntu +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04 + // Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon. + "args": { "VARIANT": "ubuntu-22.04" } + }, + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + "settings": { + // Allow Xdebug to listen to requests from remote (or container) + "remote.localPortHost": "allInterfaces" + }, + //"devPort": {}, + // Specify which VS Code extensions to install (List of IDs) + "extensions": ["xdebug.php-debug"] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [80, 9003], + + // Use 'postCreateCommand' to run commands after the container is created. + "postStartCommand": "bash .devcontainer/resources/setup.sh", + + "remoteEnv": { + "PHPBB__CODESPACESX12": "true" + }, + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "github-cli": "latest" + } +} diff --git a/.devcontainer/resources/phpbb-config.yml b/.devcontainer/resources/phpbb-config.yml new file mode 100644 index 000000000..75a70ea9a --- /dev/null +++ b/.devcontainer/resources/phpbb-config.yml @@ -0,0 +1,38 @@ +installer: + admin: + name: admin + password: adminadmin + email: admin@example.org + + board: + lang: en + name: My Board + description: My amazing new phpBB board (Titania) + + database: + dbms: mysqli + dbhost: 127.0.0.1 + dbport: 3306 + dbuser: phpbb + dbpasswd: phpbb + dbname: phpbb + table_prefix: phpbb_ + + email: + enabled: false + smtp_delivery : ~ + smtp_host: ~ + smtp_port: ~ + smtp_auth: ~ + smtp_user: ~ + smtp_pass: ~ + + server: + cookie_secure: false + server_protocol: http:// + force_server_vars: false + server_name: localhost + server_port: 80 + script_path: / + + extensions: ['phpbb/titania'] diff --git a/.devcontainer/resources/setup.sh b/.devcontainer/resources/setup.sh new file mode 100644 index 000000000..c88cdbe4b --- /dev/null +++ b/.devcontainer/resources/setup.sh @@ -0,0 +1,47 @@ +# Copy Apache configuration +# sudo rm /etc/apache2/sites-enabled/000-default.conf +# sudo cp .devcontainer/resources/phpbb-apache.conf /etc/apache2/sites-enabled/000-default.conf + +# Start MySQL +sudo service mysql start + +# Start Apache +sudo service apache2 start + +# Add SSH key +echo "$SSH_KEY" > /home/vscode/.ssh/id_rsa && chmod 600 /home/vscode/.ssh/id_rsa + +# Create a MySQL user to use +sudo mysql -u root< Server Settings -> Domain Name to match the Codespaces URL. Set the port to 443, copy the server name provided by GitHub automatically when the Codespace is created, and then set `Force server URL settings` to `Yes`. + ## Bug Tracker If you find a bug, please submit it to the [Customisations Database](https://github.com/phpbb/customisation-db/issues) bug tracker. diff --git a/attachment/plupload.php b/attachment/plupload.php index d30e46c1e..1820a10a2 100644 --- a/attachment/plupload.php +++ b/attachment/plupload.php @@ -26,7 +26,7 @@ public function configure_ext(\phpbb\titania\config\config $ext_config, \phpbb\t 'S_PLUPLOAD_EXT' => true, 'FILTERS' => $filters, 'CHUNK_SIZE' => $chunk_size, - 'S_PLUPLOAD_URL' => htmlspecialchars_decode($s_action), + 'S_PLUPLOAD_URL' => str_replace('http', 'https', htmlspecialchars_decode($s_action)), //TODO:fix this 'MAX_ATTACHMENTS' => $max_files, 'ATTACH_ORDER' => ($this->config['display_order']) ? 'asc' : 'desc', 'L_TOO_MANY_ATTACHMENTS' => $this->user->lang('TOO_MANY_ATTACHMENTS', $max_files), diff --git a/config/controllers.yml b/config/controllers.yml index 3b6bde8bb..9d95c826a 100644 --- a/config/controllers.yml +++ b/config/controllers.yml @@ -196,6 +196,8 @@ services: - '@phpbb.titania.attachment.uploader' - '@phpbb.titania.attachment.uploader' - '@phpbb.titania.subscriptions' + - '@text_formatter.parser' + - '@text_formatter.utils' phpbb.titania.controller.contrib.revision: class: phpbb\titania\controller\contribution\revision @@ -216,6 +218,8 @@ services: - '@phpbb.titania.attachment.uploader' - '@phpbb.titania.subscriptions' - '@phpbb.titania.message' + - '@text_formatter.parser' + - '@text_formatter.utils' phpbb.titania.controller.contrib.revision.edit: class: phpbb\titania\controller\contribution\revision_edit diff --git a/controller/contribution/manage.php b/controller/contribution/manage.php index a4ba5f753..82e949e0a 100644 --- a/controller/contribution/manage.php +++ b/controller/contribution/manage.php @@ -37,6 +37,12 @@ class manage extends base /** @var \phpbb\titania\subscriptions */ protected $subscriptions; + /** @var \phpbb\textformatter\s9e\parser */ + protected $parser; + + /** @var \phpbb\textformatter\s9e\utils */ + protected $utils; + /** @var bool */ protected $is_moderator; @@ -68,8 +74,10 @@ class manage extends base * @param \phpbb\titania\attachment\uploader $screenshots * @param \phpbb\titania\attachment\uploader $colorizeit_sample * @param \phpbb\titania\subscriptions $subscriptions + * @param \phpbb\textformatter\s9e\parser $parser + * @param \phpbb\textformatter\s9e\utils $utils */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\message\message $message, \phpbb\titania\attachment\uploader $screenshots, \phpbb\titania\attachment\uploader $colorizeit_sample, \phpbb\titania\subscriptions $subscriptions) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\message\message $message, \phpbb\titania\attachment\uploader $screenshots, \phpbb\titania\attachment\uploader $colorizeit_sample, \phpbb\titania\subscriptions $subscriptions, \phpbb\textformatter\s9e\parser $parser, \phpbb\textformatter\s9e\utils $utils) { parent::__construct($auth, $config, $db, $template, $user, $helper, $types, $request, $cache, $ext_config, $display, $access); @@ -77,6 +85,8 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config $this->screenshots = $screenshots; $this->colorizeit_sample = $colorizeit_sample; $this->subscriptions = $subscriptions; + $this->parser = $parser; + $this->utils = $utils; } /** @@ -490,6 +500,9 @@ protected function submit($authors, $old_settings) // Set custom field values. $this->contrib->set_custom_fields($this->settings['custom']); + // Parse the contrib name so emojis can be used + $this->contrib->contrib_name = $this->parser->parse($this->contrib->contrib_name); + // Create relations $this->contrib->put_contrib_in_categories( $this->settings['categories'], @@ -708,6 +721,10 @@ protected function assign_vars($error) $this->contrib->type->id ); } + + // Unparse the contrib name + $this->contrib->contrib_name = $this->utils->unparse($this->contrib->contrib_name); + $this->message->display(); $this->contrib->assign_details(); $this->display->assign_global_vars(); diff --git a/controller/contribution/revision.php b/controller/contribution/revision.php index f163ccd4a..c309988c5 100644 --- a/controller/contribution/revision.php +++ b/controller/contribution/revision.php @@ -53,6 +53,12 @@ class revision extends base /** @var bool */ private $skip_epv = false; + /** @var \phpbb\textformatter\s9e\parser */ + protected $parser; + + /** @var \phpbb\textformatter\s9e\utils */ + protected $utils; + /** * Constructor * @@ -71,8 +77,10 @@ class revision extends base * @param \phpbb\titania\attachment\uploader $uploader * @param \phpbb\titania\subscriptions $subscriptions * @param \phpbb\titania\message\message $message + * @param \phpbb\textformatter\s9e\parser $parser + * @param \phpbb\textformatter\s9e\utils $utils */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\attachment\uploader $uploader, \phpbb\titania\subscriptions $subscriptions, \phpbb\titania\message\message $message) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\attachment\uploader $uploader, \phpbb\titania\subscriptions $subscriptions, \phpbb\titania\message\message $message, \phpbb\textformatter\s9e\parser $parser, \phpbb\textformatter\s9e\utils $utils) { parent::__construct($auth, $config, $db, $template, $user, $helper, $types, $request, $cache, $ext_config, $display, $access); @@ -80,6 +88,9 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config $this->subscriptions = $subscriptions; $this->message = $message; + $this->parser = $parser; + $this->utils = $utils; + // Increase timeout when dealing with revisions @set_time_limit(90); } @@ -217,6 +228,9 @@ public function add($contrib_type, $contrib) // Load the revisions for this contribution $this->contrib->get_revisions(); + // Unparse the contrib name + $this->contrib->contrib_name = $this->utils->unparse($this->contrib->contrib_name); + if (sizeof($this->contrib->revisions)) { // Find out what the previous revision was, if this is a new revision to an existing contribution diff --git a/controller/helper.php b/controller/helper.php index c34845106..de6cc2afb 100644 --- a/controller/helper.php +++ b/controller/helper.php @@ -131,7 +131,9 @@ public function route($route, array $params = array(), $is_amp = true, $session_ { $route = parent::route($route, $params, $is_amp, $session_id, $reference_type); - return ($this->config->offsetGet('cookie_secure') && strpos($route, 'http://') === 0) ? 'https://' . substr($route, 7) : $route; + $full_route = ($this->config->offsetGet('cookie_secure') && strpos($route, 'http://') === 0) ? 'https://' . substr($route, 7) : $route; + + return $this->get_real_url($full_route); } /** diff --git a/controller/manage/manage.php b/controller/manage/manage.php index 33de24873..0d64e0d8a 100644 --- a/controller/manage/manage.php +++ b/controller/manage/manage.php @@ -29,7 +29,7 @@ public function base() { if ($page['auth']) { - redirect($page['url']); + redirect($page['url'], false, true); } } diff --git a/controller/manage/queue/item.php b/controller/manage/queue/item.php index f7451c6fe..f567959b3 100644 --- a/controller/manage/queue/item.php +++ b/controller/manage/queue/item.php @@ -85,6 +85,11 @@ public function display_item($id) return $this->helper->needs_auth(); } + // Create type link information for tags (e.g., make sure the tag hyperlinks back to the type) + $queue_type = $this->types->get($this->queue->queue_type); + $queue_type_name = $queue_type->name; + $queue_type_url = $queue_type->url; + // Display the main queue item $data = \queue_overlord::display_queue_item($this->id); @@ -96,11 +101,14 @@ public function display_item($id) $tag = $this->request->variable('tag', 0); + // Make sure the item category is added to the breadcrumb. + // If the user clicks on a tag (e.g., a tag like "New" or "All") + // then this part ensures it gets added to the navigation breadcrumbs if ($tag) { // Add tag to Breadcrumbs $this->display->generate_breadcrumbs(array( - $this->tags->get_tag_name($tag) => $this->queue->get_url(false, array('tag' => $tag)), + $this->tags->get_tag_name($tag) => $this->queue->get_url(false, array('tag' => $tag), [$queue_type_name => $queue_type_url]), )); } diff --git a/controller/manage/queue/queue.php b/controller/manage/queue/queue.php index 27c12c5de..2b14c6a11 100644 --- a/controller/manage/queue/queue.php +++ b/controller/manage/queue/queue.php @@ -90,6 +90,7 @@ public function display_queue($queue_type) // Add to Breadcrumbs $this->display->generate_breadcrumbs(array( + // This is where the type gets displayed $this->type->lang['lang'] => $this->get_queue_url($this->type->id), )); diff --git a/includes/objects/queue.php b/includes/objects/queue.php index ff7ad54ff..04e4020eb 100644 --- a/includes/objects/queue.php +++ b/includes/objects/queue.php @@ -668,20 +668,35 @@ public function get_queue_discussion_topic($check_only = false) * * @param bool|string $action Optional action to link to. * @param array $params Optional parameters to add to URL. + * @param array $tag Optional link to type if tags shown * * @return string Returns generated URL. */ - public function get_url($action = false, $params = array()) + public function get_url($action = false, $params = array(), $tag = false) { - $controller = 'phpbb.titania.queue.item'; - $params += array( - 'id' => $this->queue_id, - ); + if (!$tag) + { + $controller = 'phpbb.titania.queue.item'; + $params += array( + 'id' => $this->queue_id, + ); + + if ($action) + { + $controller .= '.action'; + $params['action'] = $action; + } + } - if ($action) + else { - $controller .= '.action'; - $params['action'] = $action; + // Link back to the correct type if the tag is shown + $type_name = array_key_first($tag); + + $controller = 'phpbb.titania.queue.type'; + $params += [ + 'queue_type' => $tag[$type_name], + ]; } return $this->controller_helper->route($controller, $params); diff --git a/styles/all/template/event/overall_header_head_append.html b/styles/all/template/event/overall_header_head_append.html index 4f9325206..72e6418af 100644 --- a/styles/all/template/event/overall_header_head_append.html +++ b/styles/all/template/event/overall_header_head_append.html @@ -1,5 +1,5 @@ {% if S_IN_TITANIA %} - {% INCLUDECSS '@phpbb_titania/stylesheet.css' %} + {% INCLUDECSS T_TITANIA_THEME_PATH ~ '/stylesheet.css' %} {% if S_PLUPLOAD_EXT %} {% INCLUDECSS T_THEME_PATH ~ '/plupload.css?assets_version=' ~ T_ASSETS_VERSION %} {% endif %} diff --git a/test1.php b/test1.php new file mode 100644 index 000000000..8dfaaa6a3 --- /dev/null +++ b/test1.php @@ -0,0 +1,5 @@ + \ No newline at end of file