-{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"WoltLab Suite 6.1 Documentation","text":""},{"location":"#introduction","title":"Introduction","text":"<p>This documentation explains the basic API functionality and the creation of own packages. It is expected that you are somewhat experienced with PHP, object-oriented programming and MySQL.</p> <p>Head over to the quick start tutorial to learn more.</p>"},{"location":"#about-woltlab-suite","title":"About WoltLab Suite","text":"<p>WoltLab Suite Core as well as most of the other packages are available on GitHub and are licensed under the terms of the GNU Lesser General Public License 2.1.</p>"},{"location":"getting-started/","title":"Creating a simple package","text":""},{"location":"getting-started/#setup-and-requirements","title":"Setup and Requirements","text":"<p>This guide will help you to create a simple package that provides a simple test page. It is nothing too fancy, but you can use it as the foundation for your next project.</p> <p>There are some requirements you should met before starting:</p> <ul> <li>Text editor with syntax highlighting for PHP, Notepad++ or Visual Studio Code are a solid pick</li> <li><code>*.php</code> and <code>*.tpl</code> should be encoded with ANSI/ASCII</li> <li><code>*.xml</code> are always encoded with UTF-8, but omit the BOM (byte-order-mark)</li> <li>An active installation of WoltLab Suite</li> <li>An application to create <code>*.tar</code> archives, e.g. 7-Zip on Windows</li> </ul>"},{"location":"getting-started/#the-packagexml-file","title":"The package.xml File","text":"<p>We want to create a simple page that will display the sentence \"Hello World\" embedded into the application frame. Create an empty directory in the workspace of your choice to start with.</p> <p>Create a new file called <code>package.xml</code> and insert the code below:</p> <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/package.xsd\" name=\"com.example.test\">\n <packageinformation>\n <!-- com.example.test -->\n <packagename>Simple Package</packagename>\n <packagedescription>A simple package to demonstrate the package system of WoltLab Suite Core</packagedescription>\n <version>1.0.0</version>\n <date>2023-09-15</date>\n </packageinformation>\n <authorinformation>\n <author>Your Name</author>\n <authorurl>http://www.example.com</authorurl>\n </authorinformation>\n <requiredpackages>\n <requiredpackage minversion=\"6.0.0\">com.woltlab.wcf</requiredpackage>\n </requiredpackages>\n <excludedpackages>\n <excludedpackage version=\"7.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n <instructions type=\"install\">\n <instruction type=\"file\" />\n <instruction type=\"template\" />\n <instruction type=\"page\" />\n </instructions>\n</package>\n</code></pre> <p>There is an entire chapter on the package system that explains what the code above does and how you can adjust it to fit your needs. For now we'll keep it as it is.</p>"},{"location":"getting-started/#the-php-class","title":"The PHP Class","text":"<p>The next step is to create the PHP class which will serve our page:</p> <ol> <li>Create the directory <code>files</code> in the same directory where <code>package.xml</code> is located</li> <li>Open <code>files</code> and create the directory <code>lib</code></li> <li>Open <code>lib</code> and create the directory <code>page</code></li> <li>Within the directory <code>page</code>, please create the file <code>TestPage.class.php</code></li> </ol> <p>Copy and paste the following code into the <code>TestPage.class.php</code>:</p> <pre><code><?php\nnamespace wcf\\page;\nuse wcf\\system\\WCF;\n\n/**\n * A simple test page for demonstration purposes.\n *\n * @author YOUR NAME\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n */\nclass TestPage extends AbstractPage {\n /**\n * @var string\n */\n protected $greet = '';\n\n /**\n * @inheritDoc\n */\n public function readParameters() {\n parent::readParameters();\n\n if (isset($_GET['greet'])) $this->greet = $_GET['greet'];\n }\n\n /**\n * @inheritDoc\n */\n public function readData() {\n parent::readData();\n\n if (empty($this->greet)) {\n $this->greet = 'World';\n }\n }\n\n /**\n * @inheritDoc\n */\n public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'greet' => $this->greet\n ]);\n }\n}\n</code></pre> <p>The class inherits from wcf\\page\\AbstractPage, the default implementation of pages without form controls. It defines quite a few methods that will be automatically invoked in a specific order, for example <code>readParameters()</code> before <code>readData()</code> and finally <code>assignVariables()</code> to pass arbitrary values to the template.</p> <p>The property <code>$greet</code> is defined as <code>World</code>, but can optionally be populated through a GET variable (<code>index.php?test/&greet=You</code> would output <code>Hello You!</code>). This extra code illustrates the separation of data processing that takes place within all sort of pages, where all user-supplied data is read from within a single method. It helps organizing the code, but most of all it enforces a clean class logic that does not start reading user input at random places, including the risk to only escape the input of variable <code>$_GET['foo']</code> 4 out of 5 times.</p> <p>Reading and processing the data is only half the story, now we need a template to display the actual content for our page. You don't need to specify it yourself, it will be automatically guessed based on your namespace and class name, you can read more about it later.</p> <p>Last but not least, you must not include the closing PHP tag <code>?></code> at the end, it can cause PHP to break on whitespaces and is not required at all.</p>"},{"location":"getting-started/#the-template","title":"The Template","text":"<p>Navigate back to the root directory of your package until you see both the <code>files</code> directory and the <code>package.xml</code>. Now create a directory called <code>templates</code>, open it and create the file <code>test.tpl</code>.</p> <pre><code>{include file='header'}\n\n<div class=\"section\">\n Hello {$greet}!\n</div>\n\n{include file='footer'}\n</code></pre> <p>Templates are a mixture of HTML and Smarty-like template scripting to overcome the static nature of raw HTML. The above code will display the phrase <code>Hello World!</code> in the application frame, just as any other page would render. The included templates <code>header</code> and <code>footer</code> are responsible for the majority of the overall page functionality, but offer a whole lot of customization abilities to influence their behavior and appearance.</p>"},{"location":"getting-started/#the-page-definition","title":"The Page Definition","text":"<p>The package now contains the PHP class and the matching template, but it is still missing the page definition. Please create the file <code>page.xml</code> in your project's root directory, thus on the same level as the <code>package.xml</code>.</p> <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/page.xsd\">\n <import>\n <page identifier=\"com.example.test.Test\">\n <controller>wcf\\page\\TestPage</controller>\n <name language=\"en\">Test Page</name>\n <pageType>system</pageType>\n </page>\n </import>\n</data>\n</code></pre> <p>You can provide a lot more data for a page, including logical nesting and dedicated handler classes for display in menus.</p>"},{"location":"getting-started/#building-the-package","title":"Building the Package","text":"<p>If you have followed the above guidelines carefully, your package directory should now look like this:</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u2514\u2500\u2500 page\n\u2502 \u2514\u2500\u2500 TestPage.class.php\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 page.xml\n\u2514\u2500\u2500 templates\n \u2514\u2500\u2500 test.tpl\n</code></pre> <p>Both files and templates are archive-based package components, that deploy their payload using tar archives rather than adding the raw files to the package file. Please create the archive <code>files.tar</code> and add the contents of the <code>files/*</code> directory, but not the directory <code>files/</code> itself. Repeat the same process for the <code>templates</code> directory, but this time with the file name <code>templates.tar</code>. Place both files in the root of your project.</p> <p>Last but not least, create the package archive <code>com.example.test.tar</code> and add all the files listed below.</p> <ul> <li><code>files.tar</code></li> <li><code>package.xml</code></li> <li><code>page.xml</code></li> <li><code>templates.tar</code></li> </ul> <p>The archive's filename can be anything you want, all though it is the general convention to use the package name itself for easier recognition.</p>"},{"location":"getting-started/#installation","title":"Installation","text":"<p>Open the Administration Control Panel and navigate to <code>Configuration > Packages > Install Package</code>, click on <code>Upload Package</code> and select the file <code>com.example.test.tar</code> from your disk. Follow the on-screen instructions until it has been successfully installed.</p> <p>Open a new browser tab and navigate to your newly created page. If WoltLab Suite is installed at <code>https://example.com/wsc/</code>, then the URL should read <code>https://example.com/wsc/index.php?test/</code>.</p> <p>Congratulations, you have just created your first package!</p>"},{"location":"getting-started/#developer-tools","title":"Developer Tools","text":"<p>The developer tools provide an interface to synchronize the data of an installed package with a bare repository on the local disk. You can re-import most PIPs at any time and have the changes applied without crafting a manual update. This process simulates a regular package update with a single PIP only, and resets the cache after the import has been completed.</p>"},{"location":"getting-started/#registering-a-project","title":"Registering a Project","text":"<p>Projects require the absolute path to the package directory, that is, the directory where it can find the <code>package.xml</code>. It is not required to install an package to register it as a project, but you have to install it in order to work with it. It does not install the package by itself!</p> <p>There is a special button on the project list that allows for a mass-import of projects based on a search path. Each direct child directory of the provided path will be tested and projects created this way will use the identifier extracted from the <code>package.xml</code>.</p>"},{"location":"getting-started/#synchronizing","title":"Synchronizing","text":"<p>The install instructions in the <code>package.xml</code> are ignored when offering the PIP imports, the detection works entirely based on the default filename for each PIP. On top of that, only PIPs that implement the interface <code>wcf\\system\\devtools\\pip\\IIdempotentPackageInstallationPlugin</code> are valid for import, as it indicates that importing the PIP multiple times will have no side-effects and that the result is deterministic regardless of the number of times it has been imported.</p> <p>Some built-in PIPs, such as <code>sql</code> or <code>script</code>, do not qualify for this step and remain unavailable at all times. However, you can still craft and perform an actual package update to have these PIPs executed.</p>"},{"location":"getting-started/#appendix","title":"Appendix","text":""},{"location":"getting-started/#template-guessing","title":"Template Guessing","text":"<p>The class name including the namespace is used to automatically determine the path to the template and its name. The example above used the page class name <code>wcf\\page\\TestPage</code> that is then split into four distinct parts:</p> <ol> <li><code>wcf</code>, the internal abbreviation of WoltLab Suite Core (previously known as WoltLab Community Framework)</li> <li><code>\\page\\</code> (ignored)</li> <li><code>Test</code>, the actual name that is used for both the template and the URL</li> <li><code>Page</code> (page type, ignored)</li> </ol> <p>The fragments <code>1.</code> and <code>3.</code> from above are used to construct the path to the template: <code><installDirOfWSC>/templates/test.tpl</code> (the first letter of <code>Test</code> is being converted to lower-case).</p>"},{"location":"javascript/code-snippets/","title":"Code Snippets - JavaScript API","text":"<p>This is a list of code snippets that do not fit into any of the other articles and merely describe how to achieve something very specific, rather than explaining the inner workings of a function.</p>"},{"location":"javascript/code-snippets/#imageviewer","title":"ImageViewer","text":"<p>The ImageViewer is available on all frontend pages by default, you can easily add images to the viewer by wrapping the thumbnails with a link with the CSS class <code>jsImageViewer</code> that points to the full version.</p> <pre><code><a href=\"http://example.com/full.jpg\" class=\"jsImageViewer\">\n <img src=\"http://example.com/thumbnail.jpg\">\n</a>\n</code></pre>"},{"location":"javascript/components_ckeditor5/","title":"CKEditor 5 - JavaScript API","text":"<p>WoltLab Suite 6.0 ships with a customized version of CKEditor 5 that is enriched by multiple plugins to integrate into the framework. The editor can be accessed through an abstraction layer and event system to interact with basic functionality and to alter its initialization process.</p>"},{"location":"javascript/components_ckeditor5/#the-ckeditor-api","title":"The <code>Ckeditor</code> API","text":"<p>The <code>WoltLabSuite/Core/Component/Ckeditor</code> API offers multiple helper methods to interface with CKEditor and to insert and extract content. You can get access to the instance using the <code>getCkeditor()</code> and <code>getCkeditorById()</code> methods once the editor has been initialized.</p> <p>Please refer to the typings of this component to learn about its API methods.</p>"},{"location":"javascript/components_ckeditor5/#the-event-system-for-ckeditor-5","title":"The Event System for CKEditor 5","text":"<p>The event system of CKEditor 5 was designed for actions from within the editor but not to interface with the \u201coutside world\u201d. In order to provide a deeper integration there is <code>WoltLabSuite/Core/Component/Ckeditor/Event</code> and its exported function <code>listenToCkeditor()</code>.</p> <p><code>listenToCkeditor()</code> expects the source element of the editor which usually is the <code><textarea></code> for the content. There is also <code>dispatchToCkeditor()</code> which is considered to be an internal API used from within the editor.</p>"},{"location":"javascript/components_ckeditor5/#lifecycle-of-ckeditor-5","title":"Lifecycle of CKEditor 5","text":"<p>The initialization of any CKEditor 5 instance is asynchronous and goes through multiple steps to collect the data needed to initialize the editor.</p> <ol> <li><code>setupFeatures()</code> is an override to disable the available features of this instance. The list of features becomes immutable after this event.</li> <li><code>setupConfiguration()</code> is called at the end of the configuration phase and allows changes to the <code>EditorConfig</code> before it is passed to CKEditor.</li> <li>The <code>ready()</code> is fired as soon as the editor has been fully initialized and provides the <code>Ckeditor</code> object to access the editor.</li> <li><code>collectMetaData()</code> is used in inline editors to request the injection of additional payloads that should be included in the server request.</li> <li><code>reset()</code> notifies that the editor is being fully reset and reliant components should perform a reset themselves.</li> <li><code>destroy()</code> signals that the editor has been destroyed and is no longer available.</li> </ol>"},{"location":"javascript/components_ckeditor5/#custom-bbcode-buttons-in-the-editor-toolbar","title":"Custom BBCode Buttons in the Editor Toolbar","text":"<p>Custom buttons in the editor can be injected by pushing them to the toolbar in <code>setupConfiguration()</code>. This is implicitly takes place for buttons that are registered through the BBCode system and are set to appear in the editor.</p> <pre><code>listenToCkeditor(element).setupConfiguration(({ configuration }) => {\n configuration.woltlabBbcode.push({\n icon: \"fire;false\",\n name: \"foo\",\n label: \"Button label for foo\",\n });\n});\n</code></pre> <p>Clicks on the buttons are forwarded through the <code>bbcode()</code> event. The only data passed to the callback is the name of the BBCode that was invoked.</p> <p>The default action of the custom buttons is to insert the BBCode into the editor, including the ability to wrap the selected text in the BBCode tags. Every event listener registered to this event MUST return a boolean to indicate if it wants to suppress the insertion of the text BBCode, for example to open a dialog or trigger another action.</p> <pre><code>listenToCkeditor(element).ready(({ ckeditor }) => {\n listenToCkeditor(element).bbcode(({ bbcode }) => {\n if (bbcode !== \"foo\") {\n return false;\n }\n\n // Do something when the button for `foo` was clicked.\n\n return true;\n });\n});\n</code></pre>"},{"location":"javascript/components_ckeditor5/#submit-the-editor-on-enter","title":"Submit the Editor on Enter","text":"<p>The editor supports the special feature flag <code>submitOnEnter</code> that can be enabled through <code>setupFeatures()</code>. Once enabled it changes the behavior of the Enter key to signal that the contents should be submitted to the server.</p> <pre><code>listenToCkeditor(element).setupFeatures(({ features }) => {\n features.submitOnEnter = true;\n});\n</code></pre> <p>You can subscribe to the <code>submitOnEnter()</code> to be notified when the Enter key was pressed and the editor is not empty. The contents of the editor is provided through the <code>html</code> key.</p> <p>This mode does not suppress the insertion of hard breaks through Shift + Enter.</p> <pre><code>listenToCkeditor(element).submitOnEnter(({ ckeditor, html }) => {\n // Do something with the resulting `html`.\n});\n</code></pre>"},{"location":"javascript/components_ckeditor5/#creating-plugins","title":"Creating Plugins","text":"<p>CKEditor 5 was designed to be compiled as a single bundle, relying a lot on identity checks to access and associate data. Any extra plugin that should be added to the editor must be built using the modules exposed through the <code>setupConfiguration()</code> event otherwise the identity checks will fail.</p> <pre><code>listenToCkeditor(element).setupConfiguration(({ configuration, CKEditor5 }) => {\n class FooPlugin extends CKEditor5.Core.Plugin {\n static get pluginName() {\n return \"FooPlugin\";\n }\n\n init(): void {\n // \u2026\n }\n }\n\n configuration.extraPlugins.push(FooPlugin);\n});\n</code></pre>"},{"location":"javascript/components_confirmation/","title":"Confirmation - JavaScript API","text":"<p>The purpose of confirmation dialogs is to prevent misclicks and to inform the user of potential consequences of their action. A confirmation dialog should always ask a concise question that includes a reference to the object the action is performed upon.</p> <p>You can exclude extra information or form elements in confirmation dialogs, but these should be kept as compact as possible.</p>"},{"location":"javascript/components_confirmation/#example","title":"Example","text":"<pre><code>import { confirmationFactory } from \"WoltLabSuite/Core/Component/Confirmation\";\n\nconst result = await confirmationFactory()\n .custom(\"Do you want a cookie?\")\n .withoutMessage();\nif (result) {\n // User has confirmed the dialog.\n}\n</code></pre> <p>Confirmation dialogs are a special type that use the <code>role=\"alertdialog\"</code> attribute and will always include a cancel button. The dialog itself will be limited to a width of 500px, the title can wrap into multiple lines and there will be no \u201cX\u201d button to close the dialog.</p>"},{"location":"javascript/components_confirmation/#when-to-use","title":"When to Use","text":"<p>Over the past few years the term \u201cConfirmation Fatique\u201d has emerged that describes the issue of having too many confirmation dialogs even there is no real need for them. A confirmation dialog should only be displayed when the action requires further inputs, for example, a soft delete that requires a reason, or when the action is destructive.</p>"},{"location":"javascript/components_confirmation/#proper-wording","title":"Proper Wording","text":"<p>The confirmation question should hint the severity of the action, in particular whether or not it is destructive. Destructive actions are those that cannot be undone and either cause a permanent mutation or that cause data loss. All questions should be phrased in one or two ways depending on the action.</p> <p>Destructive action:</p> <p>Are you sure you want to delete \u201cExample Object\u201d? (German) Wollen Sie \u201eBeispiel-Objekt\u201c wirklich l\u00f6schen?</p> <p>All other actions:</p> <p>Do you want to move \u201cExample Object\u201d to the trash bin? (German) M\u00f6chten Sie \u201eBeispiel-Objekt\u201c in den Papierkorb verschieben?</p>"},{"location":"javascript/components_confirmation/#available-presets","title":"Available Presets","text":"<p>WoltLab Suite 6.0 currently ships with three presets for common confirmation dialogs.</p> <p>All three presets have an optional parameter for the title of the related object as part of the question asked to the user. It is strongly recommended to provide the title if it exists, otherwise it can be omitted and an indeterminate variant is used instead.</p>"},{"location":"javascript/components_confirmation/#soft-delete","title":"Soft Delete","text":"<p>Soft deleting objects with an optional input field for a reason:</p> <pre><code>const askForReason = true;\nconst { result, reason } = await confirmationFactory().softDelete(\n theObjectName,\n askForReason\n);\nif (result) {\n console.log(\n \"The user has requested a soft delete, the following reason was provided:\",\n reason\n );\n}\n</code></pre> <p>The <code>reason</code> will always be a string, but with a length of zero if the <code>result</code> is <code>false</code> or if no reason was requested. You can simply omit the value if you do not use the reason.</p> <pre><code>const askForReason = false;\nconst { result } = await confirmationFactory().softDelete(\n theObjectName,\n askForReason\n);\nif (result) {\n console.log(\"The user has requested a soft delete.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#restore","title":"Restore","text":"<p>Restore a previously soft deleted object:</p> <pre><code>const result = await confirmationFactory().restore(theObjectName);\nif (result) {\n console.log(\"The user has requested to restore the object.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#delete","title":"Delete","text":"<p>Permanently delete an object, will inform the user that the action cannot be undone:</p> <pre><code>const result = await confirmationFactory().delete(theObjectName);\nif (result) {\n console.log(\"The user has requested to delete the object.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#custom-confirmation-prompts","title":"Custom Confirmation Prompts","text":"<p>The <code>custom()</code> permits a custom confirmation dialog with a user-defined dialog content.</p> <pre><code>const result = await confirmationFactory()\n .custom(theQuestionToAsk)\n .message(someLengthyExplanation);\nif (result) {\n console.log(\"The user has confirmed the dialog.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#use-custom-html-in-the-dialog-body","title":"Use Custom HTML in the Dialog Body","text":"<p>Some dialogs require additional input elements, for example, the prompt to remove an element has an optional text field for a reason.</p> <pre><code>const { result, dialog } = await confirmationFactory()\n .custom(theQuestionToAsk)\n .withFormElements((dialog) => {\n const p = document.createElement(\"p\");\n p.textContent = \"Hello World\";\n dialog.content.append(p);\n });\nif (result) {\n console.log(\"The user has confirmed the dialog.\");\n console.log(\n \"The DOM of the dialog can be accessed through `dialog.content`\",\n dialog.content\n );\n}\n</code></pre>"},{"location":"javascript/components_dialog/","title":"Dialogs - JavaScript API","text":"<p>Modal dialogs are a powerful tool to draw the viewer\u2019s attention to an important message, question or form. Dialogs naturally interrupt the workflow and prevent the navigation to other sections by making other elements on the page inert.</p> <p>WoltLab Suite 6.0 ships with four different types of dialogs.</p>"},{"location":"javascript/components_dialog/#quickstart","title":"Quickstart","text":"<p>There are four different types of dialogs that each fulfill their own specialized role and that provide built-in features to make the development much easier. Please see the following list to make a quick decision of what kind of dialog you need.</p> <ul> <li>Is this some kind of error message? Use an alert dialog.</li> <li>Are you asking the user to confirm an action? Use a confirmation dialog.</li> <li>Does the dialog contain form inputs that the user must fill in? Use a prompt dialog.</li> <li>Do you want to present information to the user without requiring any action? Use a dialog without controls.</li> </ul>"},{"location":"javascript/components_dialog/#dialogs-without-controls","title":"Dialogs Without Controls","text":"<p>Dialogs may contain just an explanation or extra information that should be presented to the viewer without requiring any further interaction. The dialog can be closed via the \u201cX\u201d button or by clicking the modal backdrop.</p> <pre><code>import { dialogFactory } from \"WoltLabSuite/Core/Component/Dialog\";\n\nconst dialog = dialogFactory().fromHtml(\"<p>Hello World</p>\").withoutControls();\ndialog.show(\"Greetings from my dialog\");\n</code></pre>"},{"location":"javascript/components_dialog/#when-to-use","title":"When to Use","text":"<p>The short answer is: Don\u2019t.</p> <p>Dialogs without controls are an anti-pattern because they only contain content that does not require the modal appearance of a dialog. More often than not dialogs are used for this kind of content because they are easy to use without thinking about better ways to present the content.</p> <p>If possible these dialogs should be avoided and the content is presented in a more suitable way, for example, as a flyout or by showing content on an existing or new page.</p>"},{"location":"javascript/components_dialog/#alerts","title":"Alerts","text":"<p>Alerts are designed to inform the user of something important that requires no further action by the user. Typical examples for alerts are error messages or warnings.</p> <p>An alert will only provide a single button to acknowledge the dialog and must not contain interactive content. The dialog itself will be limited to a width of 500px, the title can wrap into multiple lines and there will be no \u201cX\u201d button to close the dialog.</p> <pre><code>import { dialogFactory } from \"WoltLabSuite/Core/Component/Dialog\";\n\nconst dialog = dialogFactory()\n .fromHtml(\"<p>ERROR: Something went wrong!</p>\")\n .asAlert();\ndialog.show(\"Server Error\");\n</code></pre> <p>You can customize the label of the primary button to better explain what will happen next. This can be useful for alerts that will have a side-effect when closing the dialog, such as redirect to a different page.</p> <pre><code>const dialog = dialogFactory()\n .fromHtml(\"<p>Something went wrong, we cannot find your shopping cart.</p>\")\n .asAlert({\n primary: \"Back to the Store Page\",\n });\n\ndialog.addEventListener(\"primary\", () => {\n window.location.href = \"https://example.com/shop/\";\n});\n\ndialog.show(\"The shopping cart is missing\");\n</code></pre> <p>The <code>primary</code> event is triggered both by clicking on the primary button and by clicks on the modal backdrop.</p>"},{"location":"javascript/components_dialog/#when-to-use_1","title":"When to Use","text":"<p>Alerts are a special type of dialog that use the <code>role=\"alert\"</code> attribute to signal its importance to assistive tools. Use alerts sparingly when there is no other way to communicate that something did not work as expected.</p> <p>Alerts should not be used for cases where you expect an error to happen. For example, a form control that expectes an input to fall within a restricted range should show an inline error message instead of raising an alert.</p>"},{"location":"javascript/components_dialog/#confirmation","title":"Confirmation","text":"<p>Confirmation dialogs are supported through a separate factory function that provides a set of presets as well as a generic API. Please see the separate documentation for confirmation dialogs to learn more.</p>"},{"location":"javascript/components_dialog/#prompts","title":"Prompts","text":"<p>The most common type of dialogs are prompts that are similar to confirmation dialogs, but without the restrictions and with a regular title. These dialogs can be used universally and provide a submit and cancel button by default.</p> <p>In addition they offer an \u201cextra\u201d button that is placed to the left of the default buttons are can be used to offer a single additional action. A possible use case for an \u201cextra\u201d button would be a dialog that includes an instance of the WYSIWYG editor, the extra button could be used to trigger a message preview.</p>"},{"location":"javascript/components_dialog/#code-example","title":"Code Example","text":"<pre><code><button id=\"showMyDialog\">Show the dialog</button>\n\n<template id=\"myDialog\">\n <dl>\n <dt>\n <label for=\"myInput\">Title</label>\n </dt>\n <dd>\n <input type=\"text\" name=\"myInput\" id=\"myInput\" value=\"\" required />\n </dd>\n </dl>\n</template>\n</code></pre> <pre><code>import { dialogFactory } from \"WoltLabSuite/Core/Component/Dialog\";\n\ndocument.getElementById(\"showMyDialog\")!.addEventListener(\"click\", () => {\n const dialog = dialogFactory().fromId(\"myDialog\").asPrompt();\n\n dialog.addEventListener(\"primary\", () => {\n const myInput = document.getElementById(\"myInput\");\n\n console.log(\"Provided title:\", myInput.value.trim());\n });\n});\n</code></pre>"},{"location":"javascript/components_dialog/#custom-buttons","title":"Custom Buttons","text":"<p>The <code>asPrompt()</code> call permits some level of customization of the form control buttons.</p>"},{"location":"javascript/components_dialog/#customizing-the-primary-button","title":"Customizing the Primary Button","text":"<p>The <code>primary</code> option is used to change the default label of the primary button.</p> <pre><code>dialogFactory()\n .fromId(\"myDialog\")\n .asPrompt({\n primary: Language.get(\"wcf.dialog.button.primary\"),\n });\n</code></pre>"},{"location":"javascript/components_dialog/#adding-an-extra-button","title":"Adding an Extra Button","text":"<p>The extra button has no default label, enabling it requires you to provide a readable name.</p> <pre><code>const dialog = dialogFactory()\n .fromId(\"myDialog\")\n .asPrompt({\n extra: Language.get(\"my.extra.button.name\"),\n });\n\ndialog.addEventListener(\"extra\", () => {\n // The extra button does nothing on its own. If you want\n // to close the button after performing an action you\u2019ll\n // need to call `dialog.close()` yourself.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#interacting-with-dialogs","title":"Interacting with dialogs","text":"<p>Dialogs are represented by the <code><woltlab-core-dialog></code> element that exposes a set of properties and methods to interact with it.</p>"},{"location":"javascript/components_dialog/#opening-and-closing-dialogs","title":"Opening and Closing Dialogs","text":"<p>You can open a dialog through the <code>.show()</code> method that expects the title of the dialog as the only argument. Check the <code>.open</code> property to determine if the dialog is currently open.</p> <p>Programmatically closing a dialog is possibly through <code>.close()</code>.</p>"},{"location":"javascript/components_dialog/#accessing-the-content","title":"Accessing the Content","text":"<p>All contents of a dialog exists within a child element that can be accessed through the <code>content</code> property.</p> <pre><code>// Add some text to the dialog.\nconst p = document.createElement(\"p\");\np.textContent = \"Hello World\";\ndialog.content.append(p);\n\n// Find a text input inside the dialog.\nconst input = dialog.content.querySelector('input[type=\"text\"]');\n</code></pre>"},{"location":"javascript/components_dialog/#disabling-the-submit-button-of-a-dialog","title":"Disabling the Submit Button of a Dialog","text":"<p>You can prevent the dialog submission until a condition is met, allowing you to dynamically enable or disable the button at will.</p> <pre><code>dialog.incomplete = false;\n\nconst checkbox = dialog.content.querySelector('input[type=\"checkbox\"]')!;\ncheckbox.addEventListener(\"change\", () => {\n // Block the dialog submission unless the checkbox is checked.\n dialog.incomplete = !checkbox.checked;\n});\n</code></pre>"},{"location":"javascript/components_dialog/#managing-an-instance-of-a-dialog","title":"Managing an Instance of a Dialog","text":"<p>The old API for dialogs implicitly kept track of the instance by binding it to the <code>this</code> parameter as seen in calls like <code>UiDialog.open(this);</code>. The new implementation requires to you to keep track of the dialog on your own.</p> <pre><code>class MyComponent {\n #dialog?: WoltlabCoreDialogElement;\n\n constructor() {\n const button = document.querySelector(\".myButton\") as HTMLButtonElement;\n button.addEventListener(\"click\", () => {\n this.#showGreeting(button.dataset.name);\n });\n }\n\n #showGreeting(name: string | undefined): void {\n const dialog = this.#getDialog();\n\n const p = dialog.content.querySelector(\"p\")!;\n if (name === undefined) {\n p.textContent = \"Hello World\";\n } else {\n p.textContent = `Hello ${name}`;\n }\n\n dialog.show(\"Greetings!\");\n }\n\n #getDialog(): WoltlabCoreDialogElement {\n if (this.#dialog === undefined) {\n this.#dialog = dialogFactory()\n .fromHtml(\"<p>Hello from MyComponent</p>\")\n .withoutControls();\n }\n\n return this.#dialog;\n }\n}\n</code></pre>"},{"location":"javascript/components_dialog/#event-access","title":"Event Access","text":"<p>You can bind event listeners to specialized events to get notified of events and to modify its behavior.</p>"},{"location":"javascript/components_dialog/#afterclose","title":"<code>afterClose</code>","text":"<p>This event cannot be canceled.</p> <p>Fires when the dialog has closed.</p> <pre><code>dialog.addEventListener(\"afterClose\", () => {\n // Dialog was closed.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#close","title":"<code>close</code>","text":"<p>Fires when the dialog is about to close.</p> <pre><code>dialog.addEventListener(\"close\", (event) => {\n if (someCondition) {\n event.preventDefault();\n }\n});\n</code></pre>"},{"location":"javascript/components_dialog/#cancel","title":"<code>cancel</code>","text":"<p>Fires only when there is a \u201cCancel\u201d button and the user has either pressed that button or clicked on the modal backdrop. The dialog will close if the event is not canceled.</p> <pre><code>dialog.addEventListener(\"cancel\", (event) => {\n if (someCondition) {\n event.preventDefault();\n }\n});\n</code></pre>"},{"location":"javascript/components_dialog/#extra","title":"<code>extra</code>","text":"<p>This event cannot be canceled.</p> <p>Fires when an extra button is present and the button was clicked by the user. This event does nothing on its own and is supported for dialogs of type \u201cPrompt\u201d only.</p> <pre><code>dialog.addEventListener(\"extra\", () => {\n // The extra button was clicked.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#primary","title":"<code>primary</code>","text":"<p>This event cannot be canceled.</p> <p>Fires only when there is a primary action button and the user has either pressed that button or submitted the form through keyboard controls.</p> <pre><code>dialog.addEventListener(\"primary\", () => {\n // The primary action button was clicked or the\n // form was submitted through keyboard controls.\n //\n // The `validate` event has completed successfully.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#validate","title":"<code>validate</code>","text":"<p>Fires only when there is a form and the user has pressed the primary action button or submitted the form through keyboard controls. Canceling this event is interpreted as a form validation failure.</p> <pre><code>const input = document.createElement(\"input\");\ndialog.content.append(input);\n\ndialog.addEventListener(\"validate\", (event) => {\n if (input.value.trim() === \"\") {\n event.preventDefault();\n\n // Display an inline error message.\n }\n});\n</code></pre>"},{"location":"javascript/components_google_maps/","title":"Google Maps - JavaScript API","text":"<p>The Google Maps component is used to show a map using the Google Maps API.</p>"},{"location":"javascript/components_google_maps/#example","title":"Example","text":"<p>The component can be included directly as follows:</p> <pre><code><woltlab-core-google-maps\n id=\"id\"\n class=\"googleMap\"\n api-key=\"your_api_key\"\n></woltlab-core-google-maps>\n</code></pre> <p>Alternatively, the component can be included via a template that uses the API key from the configuration and also handles the user content:</p> <pre><code>{include file='googleMapsElement' googleMapsElementID=\"id\"}\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#id","title":"<code>id</code>","text":"<p>ID of the map instance.</p>"},{"location":"javascript/components_google_maps/#api-key","title":"<code>api-key</code>","text":"<p>Google Maps API key.</p>"},{"location":"javascript/components_google_maps/#zoom","title":"<code>zoom</code>","text":"<p>Defaults to <code>13</code>.</p> <p>Default zoom factor of the map.</p>"},{"location":"javascript/components_google_maps/#lat","title":"<code>lat</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Latitude of the default map position.</p>"},{"location":"javascript/components_google_maps/#lng","title":"<code>lng</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Longitude of the default map position.</p>"},{"location":"javascript/components_google_maps/#access-user-location","title":"<code>access-user-location</code>","text":"<p>If set, the map will try to center based on the user's current position.</p>"},{"location":"javascript/components_google_maps/#map-related-functions","title":"Map-related Functions","text":""},{"location":"javascript/components_google_maps/#addmarker","title":"<code>addMarker</code>","text":"<p>Adds a marker to the map.</p>"},{"location":"javascript/components_google_maps/#example_1","title":"Example","text":"<pre><code><script data-relocate=\"true\">\n require(['WoltLabSuite/Core/Component/GoogleMaps/Marker'], ({ addMarker }) => {\n void addMarker(document.getElementById('map_id'), 52.4505, 13.7546, 'Title', true);\n });\n</script>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_1","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#element","title":"<code>element</code>","text":"<p><code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#latitude","title":"<code>latitude</code>","text":"<p>Marker position (latitude)</p>"},{"location":"javascript/components_google_maps/#longitude","title":"<code>longitude</code>","text":"<p>Marker position (longitude)</p>"},{"location":"javascript/components_google_maps/#title","title":"<code>title</code>","text":"<p>Title of the marker.</p>"},{"location":"javascript/components_google_maps/#focus","title":"<code>focus</code>","text":"<p>Defaults to <code>false</code>.</p> <p>True, to focus the map on the position of the marker.</p>"},{"location":"javascript/components_google_maps/#adddraggablemarker","title":"<code>addDraggableMarker</code>","text":"<p>Adds a draggable marker to the map.</p>"},{"location":"javascript/components_google_maps/#example_2","title":"Example","text":"<pre><code><script data-relocate=\"true\">\n require(['WoltLabSuite/Core/Component/GoogleMaps/Marker'], ({ addDraggableMarker }) => {\n void addDraggableMarker(document.getElementById('map_id'), 52.4505, 13.7546);\n });\n</script>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_2","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#element_1","title":"<code>element</code>","text":"<p><code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#latitude_1","title":"<code>latitude</code>","text":"<p>Marker position (latitude)</p>"},{"location":"javascript/components_google_maps/#longitude_1","title":"<code>longitude</code>","text":"<p>Marker position (longitude)</p>"},{"location":"javascript/components_google_maps/#geocoding","title":"<code>Geocoding</code>","text":"<p>Enables the geocoding feature for a map.</p>"},{"location":"javascript/components_google_maps/#example_3","title":"Example","text":"<pre><code><input\n type=\"text\"\n data-google-maps-geocoding=\"map_id\"\n data-google-maps-marker\n data-google-maps-geocoding-store=\"prefix\"\n>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_3","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#data-google-maps-geocoding","title":"<code>data-google-maps-geocoding</code>","text":"<p>ID of the <code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#data-google-maps-marker","title":"<code>data-google-maps-marker</code>","text":"<p>If set, a movable marker is created that is coupled with the input field.</p>"},{"location":"javascript/components_google_maps/#data-google-maps-geocoding-store","title":"<code>data-google-maps-geocoding-store</code>","text":"<p>If set, the coordinates (latitude and longitude) are stored comma-separated in a hidden input field. Optionally, a value can be passed that is used as a prefix for the name of the input field.</p>"},{"location":"javascript/components_google_maps/#markerloader","title":"<code>MarkerLoader</code>","text":"<p>Handles a large map with many markers where markers are loaded via AJAX.</p>"},{"location":"javascript/components_google_maps/#example_4","title":"Example","text":"<pre><code><script data-relocate=\"true\">\n require(['WoltLabSuite/Core/Component/GoogleMaps/MarkerLoader'], ({ setup }) => {\n setup(document.getElementById('map_id'), 'action_classname', {});\n });\n</script>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_4","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#element_2","title":"<code>element</code>","text":"<p><code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#actionclassname","title":"<code>actionClassName</code>","text":"<p>Name of the PHP class that is called to retrieve the markers via AJAX.</p>"},{"location":"javascript/components_google_maps/#additionalparameters","title":"<code>additionalParameters</code>","text":"<p>Additional parameters that are transmitted when querying the markers via AJAX.</p>"},{"location":"javascript/components_notice/","title":"Notices - JavaScript API","text":"<p>The notice component can be used to show text notices for the user. The type of the notice can be controlled depending on the <code>type</code> parameter.</p>"},{"location":"javascript/components_notice/#example","title":"Example","text":"<pre><code><woltlab-core-notice type=\"info\">Hello World!</woltlab-core-notice>\n</code></pre>"},{"location":"javascript/components_notice/#parameters","title":"Parameters","text":""},{"location":"javascript/components_notice/#type","title":"<code>type</code>","text":"<p>Controls the type of a notice (color and displayed icon). The following values are available: <code>info</code>, <code>success</code>, <code>warning</code>, <code>error</code></p>"},{"location":"javascript/components_pagination/","title":"Pagination - JavaScript API","text":"<p>The pagination component is used to expose multiple pages to the end user. This component supports both static URLs and dynamic navigation using DOM events.</p>"},{"location":"javascript/components_pagination/#example","title":"Example","text":"<pre><code><woltlab-core-pagination page=\"1\" count=\"10\" url=\"https://www.woltlab.com\"></woltlab-core-pagination>\n</code></pre>"},{"location":"javascript/components_pagination/#parameters","title":"Parameters","text":""},{"location":"javascript/components_pagination/#page","title":"<code>page</code>","text":"<p>Defaults to <code>1</code>.</p> <p>The number of the currently displayed page.</p>"},{"location":"javascript/components_pagination/#count","title":"<code>count</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Number of available pages. Must be greater than <code>1</code> for the pagination to be displayed.</p>"},{"location":"javascript/components_pagination/#url","title":"<code>url</code>","text":"<p>Defaults to an empty string.</p> <p>If defined, static pagination links are created based on the URL with the <code>pageNo</code> parameter appended to it. Otherwise only the <code>switchPage</code> event will be fired if a user clicks on a pagination link.</p>"},{"location":"javascript/components_pagination/#events","title":"Events","text":""},{"location":"javascript/components_pagination/#switchpage","title":"<code>switchPage</code>","text":"<p>The <code>switchPage</code> event will be fired when the user clicks on a pagination link. The event detail will contain the number of the selected page. The event can be canceled to prevent navigation.</p>"},{"location":"javascript/components_pagination/#jumptopage","title":"<code>jumpToPage</code>","text":"<p>The <code>jumpToPage</code> event will be fired when the user clicks on one of the ellipsis buttons within the pagination.</p>"},{"location":"javascript/components_rpc_api/","title":"RPC API","text":"<p>The PHP RPC API has a companion implementation in TypeScript that greatly simplifies the communication with the server and provides helper methods to process responses.</p>"},{"location":"javascript/components_rpc_api/#implementing-the-api","title":"Implementing the API","text":""},{"location":"javascript/components_rpc_api/#naming-schema","title":"Naming Schema","text":"<p>The module should roughly map to the route parameters for simplicity, for example, <code>WoltLabSuite/Core/Api/Sessions/DeleteSession</code> maps to the <code>DELETE /sessions/:id</code> endpoint.</p>"},{"location":"javascript/components_rpc_api/#using-woltlabsuitecoreapiresult","title":"Using <code>WoltLabSuite/Core/Api/Result</code>","text":"<p>The <code>Result</code> module provides a consistent interface to interact with the API. A comprehensive implementation can be found in <code>WoltLabSuite/Core/Api/Comments/RenderComment.ts</code>:</p> <pre><code>import { prepareRequest } from \"WoltLabSuite/Core/Ajax/Backend\";\nimport { ApiResult, apiResultFromError, apiResultFromValue } from \"../Result\";\n\ntype Response = {\n template: string;\n response: string | undefined;\n};\n\nexport async function renderComment(\n commentId: number,\n responseId: number | undefined = undefined,\n messageOnly: boolean = false,\n objectTypeId: number | undefined = undefined\n): Promise<ApiResult<Response>> {\n const url = new URL(\n `${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/render`\n );\n url.searchParams.set(\"messageOnly\", messageOnly.toString());\n if (responseId !== undefined) {\n url.searchParams.set(\"responseID\", responseId.toString());\n }\n if (objectTypeId !== undefined) {\n url.searchParams.set(\"objectTypeID\", objectTypeId.toString());\n }\n\n let response: Response;\n try {\n response = (await prepareRequest(url).get().fetchAsJson()) as Response;\n } catch (e) {\n return apiResultFromError(e);\n }\n\n return apiResultFromValue(response);\n}\n</code></pre> <p>For <code>GET</code> and <code>DELETE</code> parameters it is possibly to provide additional parameters using the query string. You should use the native <code>URL</code> class to (conditionally) set those parameters as shown in the example above.</p>"},{"location":"javascript/components_rpc_api/#apiresult","title":"<code>ApiResult</code>","text":"<p>The type <code>ApiResult</code> represents the two possible states of the response, either an error or the actual result. The callee should evaluate the <code>ok</code> property to distinguish between the two cases to properly handle any rejections.</p> <p>Sometimes an action is infallible by design in which case the shortcut <code>.unwrap()</code> should be used. It will return the result value or fail hard when there is an actual error.</p>"},{"location":"javascript/components_rpc_api/#apiresultfromerrorerror-unknown","title":"<code>apiResultFromError(error: unknown)</code>","text":"<p>This function checks if the <code>error</code> represents a server response that is not in the 2xx range. Any network errors or other kind of client errors will fail hard.</p> <p>The returned value from the server will be attempted to be parsed into an <code>WoltLabSuite/Core/Api/Error</code> that represents the well-defined error response from the PHP RPC API. Validation errors can easily be detected through the <code>.getValidationError()</code> method of <code>ApiError</code> which returns <code>undefined</code> for all other error classes.</p>"},{"location":"javascript/general-usage/","title":"General JavaScript Usage","text":"<p>WoltLab Suite 5.4 introduced support for TypeScript, migrating all existing modules to TypeScript. The JavaScript section of the documentation is not yet updated to account for the changes, possibly explaining concepts that cannot be applied as-is when writing TypeScript. You can learn about basic TypeScript use in WoltLab Suite, such as consuming WoltLab Suite\u2019s types in own packages, within in the TypeScript section.</p>"},{"location":"javascript/general-usage/#the-history-of-the-legacy-api","title":"The History of the Legacy API","text":"<p>The WoltLab Suite 3.0 introduced a new API based on AMD-Modules with ES5-JavaScript that was designed with high performance and visible dependencies in mind. This was a fundamental change in comparison to the legacy API that was build many years before while jQuery was still a thing and we had to deal with ancient browsers such as Internet Explorer 9 that felt short in both CSS and JavaScript capabilities.</p> <p>Fast forward a few years, the old API is still around and most important, it is actively being used by some components that have not been rewritten yet. This has been done to preserve the backwards-compatibility and to avoid the significant amount of work that it requires to rewrite a component. The components invoked on page initialization have all been rewritten to use the modern API, but some deferred objects that are invoked later during the page runtime may still use the old API.</p> <p>However, the legacy API is deprecated and you should not rely on it for new components at all. It slowly but steadily gets replaced up until a point where its last bits are finally removed from the code base.</p>"},{"location":"javascript/general-usage/#embedding-javascript-inside-templates","title":"Embedding JavaScript inside Templates","text":"<p>The <code><script></code>-tags are extracted and moved during template processing, eventually placing them at the very end of the body element while preserving their order of appearance.</p> <p>This behavior is controlled through the <code>data-relocate=\"true\"</code> attribute on the <code><script></code> which is mandatory for almost all scripts, mostly because their dependencies (such as jQuery) are moved to the bottom anyway.</p> <pre><code><script data-relocate=\"true\">\n $(function() {\n // Code that uses jQuery (Legacy API)\n });\n</script>\n\n<!-- or -->\n\n<script data-relocate=\"true\">\n require([\"Some\", \"Dependencies\"], function(Some, Dependencies) {\n // Modern API\n });\n</script>\n</code></pre>"},{"location":"javascript/general-usage/#including-external-javascript-files","title":"Including External JavaScript Files","text":"<p>The AMD-Modules used in the new API are automatically recognized and lazy-loaded on demand, so unless you have a rather large and pre-compiled code-base, there is nothing else to worry about.</p>"},{"location":"javascript/general-usage/#debug-variants-and-cache-buster","title":"Debug-Variants and Cache-Buster","text":"<p>Your JavaScript files may change over time and you would want the users' browsers to always load and use the latest version of your files. This can be achieved by appending the special <code>LAST_UPDATE_TIME</code> constant to your file path. It contains the unix timestamp of the last time any package was installed, updated or removed and thus avoid outdated caches by relying on a unique value, without invalidating the cache more often that it needs to be.</p> <pre><code><script data-relocate=\"true\" src=\"{$__wcf->getPath('app')}js/App.js?t={LAST_UPDATE_TIME}\"></script>\n</code></pre> <p>For small scripts you can simply serve the full, non-minified version to the user at all times, the differences in size and execution speed are insignificant and are very unlikely to offer any benefits. They might even yield a worse performance, because you'll have to include them statically in the template, even if the code is never called.</p> <p>However, if you're including a minified build in your app or plugin, you should include a switch to load the uncompressed version in the debug mode, while serving the minified and optimized file to the average visitor. You should use the <code>ENABLE_DEBUG_MODE</code> constant to decide which version should be loaded.</p> <pre><code><script data-relocate=\"true\" src=\"{$__wcf->getPath('app')}js/App{if !ENABLE_DEBUG_MODE}.min{/if}.js?t={LAST_UPDATE_TIME}\"></script>\n</code></pre>"},{"location":"javascript/general-usage/#the-accelerated-guest-view-tiny-builds","title":"The Accelerated Guest View (\"Tiny Builds\")","text":"<p>You can learn more on the Accelerated Guest View in the migration docs.</p> <p>The \u201cAccelerated Guest View\u201d aims to decrease page size and to improve responsiveness by enabling a read-only mode for visitors. If you are providing a separate compiled build for this mode, you'll need to include yet another switch to serve the right version to the visitor.</p> <pre><code><script data-relocate=\"true\" src=\"{$__wcf->getPath('app')}js/App{if !ENABLE_DEBUG_MODE}{if VISITOR_USE_TINY_BUILD}.tiny{/if}.min{/if}.js?t={LAST_UPDATE_TIME}\"></script>\n</code></pre>"},{"location":"javascript/general-usage/#the-js-template-plugin","title":"The <code>{js}</code> Template Plugin","text":"<p>The <code>{js}</code> template plugin exists solely to provide a much easier and less error-prone method to include external JavaScript files.</p> <pre><code>{js application='app' file='App' hasTiny=true}\n</code></pre> <p>The <code>hasTiny</code> attribute is optional, you can set it to <code>false</code> or just omit it entirely if you do not provide a tiny build for your file.</p>"},{"location":"javascript/legacy-api/","title":"Legacy JavaScript API","text":""},{"location":"javascript/legacy-api/#introduction","title":"Introduction","text":"<p>The legacy JavaScript API is the original code that was part of the 2.x series of WoltLab Suite, formerly known as WoltLab Community Framework. It has been superseded for the most part by the ES5/AMD-modules API introduced with WoltLab Suite 3.0.</p> <p>Some parts still exist to this day for backwards-compatibility and because some less important components have not been rewritten yet. The old API is still supported, but marked as deprecated and will continue to be replaced parts by part in future releases, up until their entire removal, including jQuery support.</p> <p>This guide does not provide any explanation on the usage of those legacy components, but instead serves as a cheat sheet to convert code to use the new API.</p>"},{"location":"javascript/legacy-api/#classes","title":"Classes","text":""},{"location":"javascript/legacy-api/#singletons","title":"Singletons","text":"<p>Singleton instances are designed to provide a unique \"instance\" of an object regardless of when its first instance was created. Due to the lack of a <code>class</code> construct in ES5, they are represented by mere objects that act as an instance.</p> <pre><code>// App.js\nwindow.App = {};\nApp.Foo = {\n bar: function() {}\n};\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n return {\n bar: function() {}\n };\n});\n</code></pre>"},{"location":"javascript/legacy-api/#regular-classes","title":"Regular Classes","text":"<pre><code>// App.js\nwindow.App = {};\nApp.Foo = Class.extend({\n bar: function() {}\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {}\n };\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/legacy-api/#inheritance","title":"Inheritance","text":"<pre><code>// App.js\nwindow.App = {};\nApp.Foo = Class.extend({\n bar: function() {}\n});\nApp.Baz = App.Foo.extend({\n makeSnafucated: function() {}\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {}\n };\n\n return Foo;\n});\n\n// App/Baz.js\ndefine([\"Core\", \"./Foo\"], function(Core, Foo) {\n \"use strict\";\n\n function Baz() {};\n Core.inherit(Baz, Foo, {\n makeSnafucated: function() {}\n });\n\n return Baz;\n});\n</code></pre>"},{"location":"javascript/legacy-api/#ajax-requests","title":"Ajax Requests","text":"<pre><code>// App.js\nApp.Foo = Class.extend({\n _proxy: null,\n\n init: function() {\n this._proxy = new WCF.Action.Proxy({\n success: $.proxy(this._success, this)\n });\n },\n\n bar: function() {\n this._proxy.setOption(\"data\", {\n actionName: \"baz\",\n className: \"app\\\\foo\\\\FooAction\",\n objectIDs: [1, 2, 3],\n parameters: {\n foo: \"bar\",\n baz: true\n }\n });\n this._proxy.sendRequest();\n },\n\n _success: function(data) {\n // ajax request result\n }\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([\"Ajax\"], function(Ajax) {\n \"use strict\";\n\n function Foo() {}\n Foo.prototype = {\n bar: function() {\n Ajax.api(this, {\n objectIDs: [1, 2, 3],\n parameters: {\n foo: \"bar\",\n baz: true\n }\n });\n },\n\n // magic method!\n _ajaxSuccess: function(data) {\n // ajax request result\n },\n\n // magic method!\n _ajaxSetup: function() {\n return {\n actionName: \"baz\",\n className: \"app\\\\foo\\\\FooAction\"\n }\n }\n }\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/legacy-api/#phrases","title":"Phrases","text":"<pre><code><script data-relocate=\"true\">\n$(function() {\n WCF.Language.addObject({\n 'app.foo.bar': '{lang}app.foo.bar{/lang}'\n });\n\n console.log(WCF.Language.get(\"app.foo.bar\"));\n});\n</script>\n\n<!-- NEW API -->\n\n<script data-relocate=\"true\">\nrequire([\"Language\"], function(Language) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}'\n });\n\n console.log(Language.get(\"app.foo.bar\"));\n});\n</script>\n</code></pre>"},{"location":"javascript/legacy-api/#event-listener","title":"Event-Listener","text":"<pre><code><script data-relocate=\"true\">\n$(function() {\n WCF.System.Event.addListener(\"app.foo.bar\", \"makeSnafucated\", function(data) {\n console.log(\"Event was invoked.\");\n });\n\n WCF.System.Event.fireEvent(\"app.foo.bar\", \"makeSnafucated\", { some: \"data\" });\n});\n</script>\n\n<!-- NEW API -->\n\n<script data-relocate=\"true\">\nrequire([\"EventHandler\"], function(EventHandler) {\n EventHandler.add(\"app.foo.bar\", \"makeSnafucated\", function(data) {\n console.log(\"Event was invoked\");\n });\n\n EventHandler.fire(\"app.foo.bar\", \"makeSnafucated\", { some: \"data\" });\n});\n</script>\n</code></pre>"},{"location":"javascript/new-api_ajax/","title":"Ajax Requests - JavaScript API","text":""},{"location":"javascript/new-api_ajax/#promise-based-api-for-databaseobjectaction","title":"<code>Promise</code>-based API for <code>DatabaseObjectAction</code>","text":"<p>WoltLab Suite 5.5 introduces a new API for Ajax requests that uses <code>Promise</code>s to control the code flow. It does not rely on references to existing objects and does not use arbitrary callbacks to handle the setup and handling of the request.</p>"},{"location":"javascript/new-api_ajax/#usage","title":"Usage","text":"MyModule.ts<pre><code>import * as Ajax from \"./Ajax\";\n\ntype ResponseGetLatestFoo = {\n template: string;\n};\n\nexport class MyModule {\n private readonly bar: string;\n private readonly objectId: number;\n\n constructor(objectId: number, bar: string, buttonId: string) {\n this.bar = bar;\n this.objectId = objectId;\n\n const button = document.getElementById(buttonId);\n button?.addEventListener(\"click\", (event) => void this.click(event));\n }\n\n async click(event: MouseEvent): Promise<void> {\n event.preventDefault();\n\n const button = event.currentTarget as HTMLElement;\n if (button.classList.contains(\"disabled\")) {\n return;\n }\n button.classList.add(\"disabled\");\n\n try {\n const response = (await Ajax.dboAction(\"getLatestFoo\", \"wcf\\\\data\\\\foo\\\\FooAction\")\n .objectIds([this.objectId])\n .payload({ bar: this.bar })\n .dispatch()) as ResponseGetLatestFoo;\n\n document.getElementById(\"latestFoo\")!.innerHTML = response.template;\n } finally {\n button.classList.remove(\"disabled\");\n }\n }\n}\n\nexport default MyModule;\n</code></pre> <p>The actual code to dispatch and evaluate a request is only four lines long and offers full IDE auto completion support. This example uses a <code>finally</code> block to reset the button class once the request has finished, regardless of the result.</p> <p>If you do not handle the errors (or chose not to handle some errors), the global rejection handler will take care of this and show an dialog that informs about the failed request. This mimics the behavior of the <code>_ajaxFailure()</code> callback in the legacy API.</p>"},{"location":"javascript/new-api_ajax/#aborting-in-flight-requests","title":"Aborting in-flight requests","text":"<p>Sometimes new requests are dispatched against the same API before the response from the previous has arrived. This applies to either long running requests or requests that are dispatched in rapid succession, for example, looking up values when the user is actively typing into a search field.</p> RapidRequests.ts<pre><code>import * as Ajax from \"./Ajax\";\n\nexport class RapidRequests {\n private lastRequest: AbortController | undefined = undefined;\n\n constructor(inputId: string) {\n const input = document.getElementById(inputId) as HTMLInputElement;\n input.addEventListener(\"input\", (event) => void this.input(event));\n }\n\n async input(event: Event): Promise<void> {\n event.preventDefault();\n\n const input = event.currentTarget as HTMLInputElement;\n const value = input.value.trim();\n\n if (this.lastRequest) {\n this.lastRequest.abort();\n }\n\n if (value) {\n const request = Ajax.dboAction(\"getSuggestions\", \"wcf\\\\data\\\\bar\\\\BarAction\").payload({ value });\n this.lastRequest = request.getAbortController();\n\n const response = await request.dispatch();\n // Handle the response\n }\n }\n}\n\nexport default RapidRequests;\n</code></pre>"},{"location":"javascript/new-api_ajax/#ajax-inside-modules-legacy-api","title":"Ajax inside Modules (Legacy API)","text":"<p>The Ajax component was designed to be used from inside modules where an object reference is used to delegate request callbacks. This is acomplished through a set of magic methods that are automatically called when the request is created or its state has changed.</p>"},{"location":"javascript/new-api_ajax/#_ajaxsetup","title":"<code>_ajaxSetup()</code>","text":"<p>The lazy initialization is performed upon the first invocation from the callee, using the magic <code>_ajaxSetup()</code> method to retrieve the basic configuration for this and any future requests.</p> <p>The data returned by <code>_ajaxSetup()</code> is cached and the data will be used to pre-populate the request data before sending it. The callee can overwrite any of these properties. It is intended to reduce the overhead when issuing request when these requests share the same properties, such as accessing the same endpoint.</p> <pre><code>// App/Foo.js\ndefine([\"Ajax\"], function(Ajax) {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n one: function() {\n // this will issue an ajax request with the parameter `value` set to `1`\n Ajax.api(this);\n },\n\n two: function() {\n // this request is almost identical to the one issued with `.one()`, but\n // the value is now set to `2` for this invocation only.\n Ajax.api(this, {\n parameters: {\n value: 2\n }\n });\n },\n\n _ajaxSetup: function() {\n return {\n data: {\n actionName: \"makeSnafucated\",\n className: \"app\\\\data\\\\foo\\\\FooAction\",\n parameters: {\n value: 1\n }\n }\n }\n }\n };\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/new-api_ajax/#request-settings","title":"Request Settings","text":"<p>The object returned by the aforementioned <code>_ajaxSetup()</code> callback can contain these values:</p>"},{"location":"javascript/new-api_ajax/#data","title":"<code>data</code>","text":"<p>Defaults to <code>{}</code>.</p> <p>A plain JavaScript object that contains the request data that represents the form data of the request. The <code>parameters</code> key is recognized by the PHP Ajax API and becomes accessible through <code>$this->parameters</code>.</p>"},{"location":"javascript/new-api_ajax/#contenttype","title":"<code>contentType</code>","text":"<p>Defaults to <code>application/x-www-form-urlencoded; charset=UTF-8</code>.</p> <p>The request content type, sets the <code>Content-Type</code> HTTP header if it is not empty.</p>"},{"location":"javascript/new-api_ajax/#responsetype","title":"<code>responseType</code>","text":"<p>Defaults to <code>application/json</code>.</p> <p>The server must respond with the <code>Content-Type</code> HTTP header set to this value, otherwise the request will be treated as failed. Requests for <code>application/json</code> will have the return body attempted to be evaluated as JSON.</p> <p>Other content types will only be validated based on the HTTP header, but no additional transformation is performed. For example, setting the <code>responseType</code> to <code>application/xml</code> will check the HTTP header, but will not transform the <code>data</code> parameter, you'll still receive a string in <code>_ajaxSuccess</code>!</p>"},{"location":"javascript/new-api_ajax/#type","title":"<code>type</code>","text":"<p>Defaults to <code>POST</code>.</p> <p>The HTTP Verb used for this request.</p>"},{"location":"javascript/new-api_ajax/#url","title":"<code>url</code>","text":"<p>Defaults to an empty string.</p> <p>Manual override for the request endpoint, it will be automatically set to the Core API endpoint if left empty. If the Core API endpoint is used, the options <code>includeRequestedWith</code> and <code>withCredentials</code> will be force-set to true.</p>"},{"location":"javascript/new-api_ajax/#withcredentials","title":"<code>withCredentials</code>","text":"<p>Enabling this parameter for any domain other than the current will trigger a CORS preflight request.</p> <p>Defaults to <code>false</code>.</p> <p>Include cookies with this requested, is always true when <code>url</code> is (implicitly) set to the Core API endpoint.</p>"},{"location":"javascript/new-api_ajax/#autoabort","title":"<code>autoAbort</code>","text":"<p>Defaults to <code>false</code>.</p> <p>When set to <code>true</code>, any pending responses to earlier requests will be silently discarded when issuing a new request. This only makes sense if the new request is meant to completely replace the result of the previous one, regardless of its reponse body.</p> <p>Typical use-cases include input field with suggestions, where possible values are requested from the server, but the input changed faster than the server was able to reply. In this particular case the client is not interested in the result for an earlier value, auto-aborting these requests avoids implementing this logic in the requesting code.</p>"},{"location":"javascript/new-api_ajax/#ignoreerror","title":"<code>ignoreError</code>","text":"<p>Defaults to <code>false</code>.</p> <p>Any failing request will invoke the <code>failure</code>-callback to check if an error message should be displayed. Enabling this option will suppress the general error overlay that reports a failed request.</p> <p>You can achieve the same result by returning <code>false</code> in the <code>failure</code>-callback.</p>"},{"location":"javascript/new-api_ajax/#silent","title":"<code>silent</code>","text":"<p>Defaults to <code>false</code>.</p> <p>Enabling this option will suppress the loading indicator overlay for this request, other non-\"silent\" requests will still trigger the loading indicator.</p>"},{"location":"javascript/new-api_ajax/#includerequestedwith","title":"<code>includeRequestedWith</code>","text":"<p>Enabling this parameter for any domain other than the current will trigger a CORS preflight request.</p> <p>Defaults to <code>true</code>.</p> <p>Sets the custom HTTP header <code>X-Requested-With: XMLHttpRequest</code> for the request, it is automatically set to <code>true</code> when <code>url</code> is pointing at the WSC API endpoint.</p>"},{"location":"javascript/new-api_ajax/#failure","title":"<code>failure</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Optional callback function that will be invoked for requests that have failed for one of these reasons: 1. The request timed out. 2. The HTTP status is not <code>2xx</code> or <code>304</code>. 3. A <code>responseType</code> was set, but the response HTTP header <code>Content-Type</code> did not match the expected value. 4. The <code>responseType</code> was set to <code>application/json</code>, but the response body was not valid JSON.</p> <p>The callback function receives the parameter <code>xhr</code> (the <code>XMLHttpRequest</code> object) and <code>options</code> (deep clone of the request parameters). If the callback returns <code>false</code>, the general error overlay for failed requests will be suppressed.</p> <p>There will be no error overlay if <code>ignoreError</code> is set to <code>true</code> or if the request failed while attempting to evaluate the response body as JSON.</p>"},{"location":"javascript/new-api_ajax/#finalize","title":"<code>finalize</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Optional callback function that will be invoked once the request has completed, regardless if it succeeded or failed. The only parameter it receives is <code>options</code> (the request parameters object), but it does not receive the request's <code>XMLHttpRequest</code>.</p>"},{"location":"javascript/new-api_ajax/#success","title":"<code>success</code>","text":"<p>Defaults to <code>null</code>.</p> <p>This semi-optional callback function will always be set to <code>_ajaxSuccess()</code> when invoking <code>Ajax.api()</code>. It receives four parameters: 1. <code>data</code> - The request's response body as a string, or a JavaScript object if <code>contentType</code> was set to <code>application/json</code>. 2. <code>responseText</code> - The unmodified response body, it equals the value for <code>data</code> for non-JSON requests. 3. <code>xhr</code> - The underlying <code>XMLHttpRequest</code> object. 4. <code>requestData</code> - The request parameters that were supplied when the request was issued.</p>"},{"location":"javascript/new-api_ajax/#_ajaxsuccess","title":"<code>_ajaxSuccess()</code>","text":"<p>This callback method is automatically called for successful AJAX requests, it receives four parameters, with the first one containing either the response body as a string, or a JavaScript object for JSON requests.</p>"},{"location":"javascript/new-api_ajax/#_ajaxfailure","title":"<code>_ajaxFailure()</code>","text":"<p>Optional callback function that is invoked for failed requests, it will be automatically called if the callee implements it, otherwise the global error handler will be executed.</p>"},{"location":"javascript/new-api_ajax/#single-requests-without-a-module-legacy-api","title":"Single Requests Without a Module (Legacy API)","text":"<p>The <code>Ajax.api()</code> method expects an object that is used to extract the request configuration as well as providing the callback functions when the request state changes.</p> <p>You can issue a simple Ajax request without object binding through <code>Ajax.apiOnce()</code> that will destroy the instance after the request was finalized. This method is significantly more expensive for repeated requests and does not offer deriving modules from altering the behavior. It is strongly recommended to always use <code>Ajax.api()</code> for requests to the WSC API endpoint.</p> <pre><code><script data-relocate=\"true\">\n require([\"Ajax\"], function(Ajax) {\n Ajax.apiOnce({\n data: {\n actionName: \"makeSnafucated\",\n className: \"app\\\\data\\\\foo\\\\FooAction\",\n parameters: {\n value: 3\n }\n },\n success: function(data) {\n elBySel(\".some-element\").textContent = data.bar;\n }\n })\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_browser/","title":"Browser and Screen Sizes - JavaScript API","text":""},{"location":"javascript/new-api_browser/#uiscreen","title":"<code>Ui/Screen</code>","text":"<p>CSS offers powerful media queries that alter the layout depending on the screen sizes, including but not limited to changes between landscape and portrait mode on mobile devices.</p> <p>The <code>Ui/Screen</code> module exposes a consistent interface to execute JavaScript code based on the same media queries that are available in the CSS code already. It features support for unmatching and executing code when a rule matches for the first time during the page lifecycle.</p>"},{"location":"javascript/new-api_browser/#supported-aliases","title":"Supported Aliases","text":"<p>You can pass in custom media queries, but it is strongly recommended to use the built-in media queries that match the same dimensions as your CSS.</p> Alias Media Query <code>screen-xs</code> <code>(max-width: 544px)</code> <code>screen-sm</code> <code>(min-width: 545px) and (max-width: 768px)</code> <code>screen-sm-down</code> <code>(max-width: 768px)</code> <code>screen-sm-up</code> <code>(min-width: 545px)</code> <code>screen-sm-md</code> <code>(min-width: 545px) and (max-width: 1024px)</code> <code>screen-md</code> <code>(min-width: 769px) and (max-width: 1024px)</code> <code>screen-md-down</code> <code>(max-width: 1024px)</code> <code>screen-md-up</code> <code>(min-width: 769px)</code> <code>screen-lg</code> <code>(min-width: 1025px)</code>"},{"location":"javascript/new-api_browser/#onquery-string-callbacks-object-string","title":"<code>on(query: string, callbacks: Object): string</code>","text":"<p>Registers a set of callback functions for the provided media query, the possible keys are <code>match</code>, <code>unmatch</code> and <code>setup</code>. The method returns a randomly generated UUIDv4 that is used to identify these callbacks and allows them to be removed via <code>.remove()</code>.</p>"},{"location":"javascript/new-api_browser/#removequery-string-uuid-string","title":"<code>remove(query: string, uuid: string)</code>","text":"<p>Removes all callbacks for a media query that match the UUIDv4 that was previously obtained from the call to <code>.on()</code>.</p>"},{"location":"javascript/new-api_browser/#isquery-string-boolean","title":"<code>is(query: string): boolean</code>","text":"<p>Tests if the provided media query currently matches and returns true on match.</p>"},{"location":"javascript/new-api_browser/#scrolldisable","title":"<code>scrollDisable()</code>","text":"<p>Temporarily prevents the page from being scrolled, until <code>.scrollEnable()</code> is called.</p>"},{"location":"javascript/new-api_browser/#scrollenable","title":"<code>scrollEnable()</code>","text":"<p>Enables page scrolling again, unless another pending action has also prevented the page scrolling.</p>"},{"location":"javascript/new-api_browser/#environment","title":"<code>Environment</code>","text":"<p>The <code>Environment</code> module uses a mixture of feature detection and user agent sniffing to determine the browser and platform. In general, its results have proven to be very accurate, but it should be taken with a grain of salt regardless. Especially the browser checks are designed to be your last resort, please use feature detection instead whenever it is possible!</p> <p>Sometimes it may be necessary to alter the behavior of your code depending on the browser platform (e. g. mobile devices) or based on a specific browser in order to work-around some quirks.</p>"},{"location":"javascript/new-api_browser/#browser-string","title":"<code>browser(): string</code>","text":"<p>Attempts to detect browsers based on their technology and supported CSS vendor prefixes, and although somewhat reliable for major browsers, it is highly recommended to use feature detection instead.</p> <p>Possible values: - <code>chrome</code> (includes Opera 15+ and Vivaldi) - <code>firefox</code> - <code>safari</code> - <code>microsoft</code> (Internet Explorer and Edge) - <code>other</code> (default)</p>"},{"location":"javascript/new-api_browser/#platform-string","title":"<code>platform(): string</code>","text":"<p>Attempts to detect the browser platform using user agent sniffing.</p> <p>Possible values: - <code>ios</code> - <code>android</code> - <code>windows</code> (IE Mobile) - <code>mobile</code> (generic mobile device) - <code>desktop</code> (default)</p>"},{"location":"javascript/new-api_core/","title":"Core Modules and Functions - JavaScript API","text":"<p>A brief overview of common methods that may be useful when writing any module.</p>"},{"location":"javascript/new-api_core/#core","title":"<code>Core</code>","text":""},{"location":"javascript/new-api_core/#cloneobject-object-object","title":"<code>clone(object: Object): Object</code>","text":"<p>Creates a deep-clone of the provided object by value, removing any references on the original element, including arrays. However, this does not clone references to non-plain objects, these instances will be copied by reference.</p> <pre><code>require([\"Core\"], function(Core) {\n var obj1 = { a: 1 };\n var obj2 = Core.clone(obj1);\n\n console.log(obj1 === obj2); // output: false\n console.log(obj2.hasOwnProperty(\"a\") && obj2.a === 1); // output: true\n});\n</code></pre>"},{"location":"javascript/new-api_core/#extendbase-object-merge-object-object","title":"<code>extend(base: Object, ...merge: Object[]): Object</code>","text":"<p>Accepts an infinite amount of plain objects as parameters, values will be copied from the 2nd...nth object into the first object. The first parameter will be cloned and the resulting object is returned.</p> <pre><code>require([\"Core\"], function(Core) {\n var obj1 = { a: 2 };\n var obj2 = { a: 1, b: 2 };\n var obj = Core.extend({\n b: 1\n }, obj1, obj2);\n\n console.log(obj.b === 2); // output: true\n console.log(obj.hasOwnProperty(\"a\") && obj.a === 2); // output: false\n});\n</code></pre>"},{"location":"javascript/new-api_core/#inheritbase-object-target-object-merge-object","title":"<code>inherit(base: Object, target: Object, merge?: Object)</code>","text":"<p>Derives the second object's prototype from the first object, afterwards the derived class will pass the <code>instanceof</code> check against the original class.</p> <pre><code>// App.js\nwindow.App = {};\nApp.Foo = Class.extend({\n bar: function() {}\n});\nApp.Baz = App.Foo.extend({\n makeSnafucated: function() {}\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {}\n };\n\n return Foo;\n});\n\n// App/Baz.js\ndefine([\"Core\", \"./Foo\"], function(Core, Foo) {\n \"use strict\";\n\n function Baz() {};\n Core.inherit(Baz, Foo, {\n makeSnafucated: function() {}\n });\n\n return Baz;\n});\n</code></pre>"},{"location":"javascript/new-api_core/#isplainobjectobject-object-boolean","title":"<code>isPlainObject(object: Object): boolean</code>","text":"<p>Verifies if an object is a plain JavaScript object and not an object instance.</p> <pre><code>require([\"Core\"], function(Core) {\n function Foo() {}\n Foo.prototype = {\n hello: \"world\";\n };\n\n var obj1 = { hello: \"world\" };\n var obj2 = new Foo();\n\n console.log(Core.isPlainObject(obj1)); // output: true\n console.log(obj1.hello === obj2.hello); // output: true\n console.log(Core.isPlainObject(obj2)); // output: false\n});\n</code></pre>"},{"location":"javascript/new-api_core/#triggereventelement-element-eventname-string","title":"<code>triggerEvent(element: Element, eventName: string)</code>","text":"<p>Creates and dispatches a synthetic JavaScript event on an element.</p> <pre><code>require([\"Core\"], function(Core) {\n var element = elBySel(\".some-element\");\n Core.triggerEvent(element, \"click\");\n});\n</code></pre>"},{"location":"javascript/new-api_core/#language","title":"<code>Language</code>","text":""},{"location":"javascript/new-api_core/#addkey-string-value-string","title":"<code>add(key: string, value: string)</code>","text":"<p>Registers a new phrase.</p> <pre><code><script data-relocate=\"true\">\n require([\"Language\"], function(Language) {\n Language.add('app.foo.bar', '{jslang}app.foo.bar{/jslang}');\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_core/#addobjectobject-object","title":"<code>addObject(object: Object)</code>","text":"<p>Registers a list of phrases using a plain object.</p> <pre><code><script data-relocate=\"true\">\n require([\"Language\"], function(Language) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}'\n });\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_core/#getkey-string-parameters-object-string","title":"<code>get(key: string, parameters?: Object): string</code>","text":"<p>Retrieves a phrase by its key, optionally supporting basic template scripting with dynamic variables passed using the <code>parameters</code> object.</p> <pre><code>require([\"Language\"], function(Language) {\n var title = Language.get(\"app.foo.title\");\n var content = Language.get(\"app.foo.content\", {\n some: \"value\"\n });\n});\n</code></pre>"},{"location":"javascript/new-api_core/#stringutil","title":"<code>StringUtil</code>","text":""},{"location":"javascript/new-api_core/#escapehtmlstr-string-string","title":"<code>escapeHTML(str: string): string</code>","text":"<p>Escapes special HTML characters by converting them into an HTML entity.</p> Character Replacement <code>&</code> <code>&amp;</code> <code>\"</code> <code>&quot;</code> <code><</code> <code>&lt;</code> <code>></code> <code>&gt;</code>"},{"location":"javascript/new-api_core/#escaperegexpstr-string-string","title":"<code>escapeRegExp(str: string): string</code>","text":"<p>Escapes a list of characters that have a special meaning in regular expressions and could alter the behavior when embedded into regular expressions.</p>"},{"location":"javascript/new-api_core/#lcfirststr-string-string","title":"<code>lcfirst(str: string): string</code>","text":"<p>Makes a string's first character lowercase.</p>"},{"location":"javascript/new-api_core/#ucfirststr-string-string","title":"<code>ucfirst(str: string): string</code>","text":"<p>Makes a string's first character uppercase.</p>"},{"location":"javascript/new-api_core/#unescapehtmlstr-string-string","title":"<code>unescapeHTML(str: string): string</code>","text":"<p>Converts some HTML entities into their original character. This is the reverse function of <code>escapeHTML()</code>.</p>"},{"location":"javascript/new-api_dialogs/","title":"Dialogs - JavaScript API","text":"<p>This API has been deprecated in WoltLab Suite 6.0, please refer to the new dialog implementation.</p>"},{"location":"javascript/new-api_dialogs/#introduction","title":"Introduction","text":"<p>Dialogs are full screen overlays that cover the currently visible window area using a semi-opague backdrop and a prominently placed dialog window in the foreground. They shift the attention away from the original content towards the dialog and usually contain additional details and/or dedicated form inputs.</p>"},{"location":"javascript/new-api_dialogs/#_dialogsetup","title":"<code>_dialogSetup()</code>","text":"<p>The lazy initialization is performed upon the first invocation from the callee, using the magic <code>_dialogSetup()</code> method to retrieve the basic configuration for the dialog construction and any event callbacks.</p> <pre><code>// App/Foo.js\ndefine([\"Ui/Dialog\"], function(UiDialog) {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {\n // this will open the dialog constructed by _dialogSetup\n UiDialog.open(this);\n },\n\n _dialogSetup: function() {\n return {\n id: \"myDialog\",\n source: \"<p>Hello World!</p>\",\n options: {\n onClose: function() {\n // the fancy dialog was closed!\n }\n }\n }\n }\n };\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/new-api_dialogs/#id-string","title":"<code>id: string</code>","text":"<p>The <code>id</code> is used to identify a dialog on runtime, but is also part of the first- time setup when the dialog has not been opened before. If <code>source</code> is <code>undefined</code>, the module attempts to construct the dialog using an element with the same id.</p>"},{"location":"javascript/new-api_dialogs/#source-any","title":"<code>source: any</code>","text":"<p>There are six different types of value that <code>source</code> does allow and each of them changes how the initial dialog is constructed:</p> <ol> <li><code>undefined</code> The dialog exists already and the value of <code>id</code> should be used to identify the element.</li> <li><code>null</code> The HTML is provided using the second argument of <code>.open()</code>.</li> <li><code>() => void</code> If the <code>source</code> is a function, it is executed and is expected to start the dialog initialization itself.</li> <li><code>Object</code> Plain objects are interpreted as parameters for an Ajax request, in particular <code>source.data</code> will be used to issue the request. It is possible to specify the key <code>source.after</code> as a callback <code>(content: Element, responseData: Object) => void</code> that is executed after the dialog was opened.</li> <li><code>string</code> The string is expected to be plain HTML that should be used to construct the dialog.</li> <li><code>DocumentFragment</code> A new container <code><div></code> with the provided <code>id</code> is created and the contents of the <code>DocumentFragment</code> is appended to it. This container is then used for the dialog.</li> </ol>"},{"location":"javascript/new-api_dialogs/#options-object","title":"<code>options: Object</code>","text":"<p>All configuration options and callbacks are handled through this object.</p>"},{"location":"javascript/new-api_dialogs/#optionsbackdropcloseonclick-boolean","title":"<code>options.backdropCloseOnClick: boolean</code>","text":"<p>Defaults to <code>true</code>.</p> <p>Clicks on the dialog backdrop will close the top-most dialog. This option will be force-disabled if the option <code>closeable</code> is set to <code>false</code>.</p>"},{"location":"javascript/new-api_dialogs/#optionsclosable-boolean","title":"<code>options.closable: boolean</code>","text":"<p>Defaults to <code>true</code>.</p> <p>Enables the close button in the dialog title, when disabled the dialog can be closed through the <code>.close()</code> API call only.</p>"},{"location":"javascript/new-api_dialogs/#optionsclosebuttonlabel-string","title":"<code>options.closeButtonLabel: string</code>","text":"<p>Defaults to <code>Language.get(\"wcf.global.button.close\")</code>.</p> <p>The phrase that is displayed in the tooltip for the close button.</p>"},{"location":"javascript/new-api_dialogs/#optionscloseconfirmmessage-string","title":"<code>options.closeConfirmMessage: string</code>","text":"<p>Defaults to <code>\"\"</code>.</p> <p>Shows a confirmation dialog using the configured message before closing the dialog. The dialog will not be closed if the dialog is rejected by the user.</p>"},{"location":"javascript/new-api_dialogs/#optionstitle-string","title":"<code>options.title: string</code>","text":"<p>Defaults to <code>\"\"</code>.</p> <p>The phrase that is displayed in the dialog title.</p>"},{"location":"javascript/new-api_dialogs/#optionsonbeforeclose-id-string-void","title":"<code>options.onBeforeClose: (id: string) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>The callback is executed when the user clicks on the close button or, if enabled, on the backdrop. The callback is responsible to close the dialog by itself, the default close behavior is automatically prevented.</p>"},{"location":"javascript/new-api_dialogs/#optionsonclose-id-string-void","title":"<code>options.onClose: (id: string) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>The callback is notified once the dialog is about to be closed, but is still visible at this point. It is not possible to abort the close operation at this point.</p>"},{"location":"javascript/new-api_dialogs/#optionsonshow-content-element-void","title":"<code>options.onShow: (content: Element) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Receives the dialog content element as its only argument, allowing the callback to modify the DOM or to register event listeners before the dialog is presented to the user. The dialog is already visible at call time, but the dialog has not been finalized yet.</p>"},{"location":"javascript/new-api_dialogs/#settitleid-string-object-title-string","title":"<code>setTitle(id: string | Object, title: string)</code>","text":"<p>Sets the title of a dialog.</p>"},{"location":"javascript/new-api_dialogs/#setcallbackid-string-object-key-string-value-data-any-void-null","title":"<code>setCallback(id: string | Object, key: string, value: (data: any) => void | null)</code>","text":"<p>Sets a callback function after the dialog initialization, the special value <code>null</code> will remove a previously set callback. Valid values for <code>key</code> are <code>onBeforeClose</code>, <code>onClose</code> and <code>onShow</code>.</p>"},{"location":"javascript/new-api_dialogs/#rebuildid-string-object","title":"<code>rebuild(id: string | Object)</code>","text":"<p>Rebuilds a dialog by performing various calculations on the maximum dialog height in regards to the overflow handling and adjustments for embedded forms. This method is automatically invoked whenever a dialog is shown, after invoking the <code>options.onShow</code> callback.</p>"},{"location":"javascript/new-api_dialogs/#closeid-string-object","title":"<code>close(id: string | Object)</code>","text":"<p>Closes an open dialog, this will neither trigger a confirmation dialog, nor does it invoke the <code>options.onBeforeClose</code> callback. The <code>options.onClose</code> callback will always be invoked, but it cannot abort the close operation.</p>"},{"location":"javascript/new-api_dialogs/#getdialogid-string-object-object","title":"<code>getDialog(id: string | Object): Object</code>","text":"<p>This method returns an internal data object by reference, any modifications made do have an effect on the dialogs behavior and in particular no validation is performed on the modification. It is strongly recommended to use the <code>.set*()</code> methods only.</p> <p>Returns the internal dialog data that is attached to a dialog. The most important key is <code>.content</code> which holds a reference to the dialog's inner content element.</p>"},{"location":"javascript/new-api_dialogs/#isopenid-string-object-boolean","title":"<code>isOpen(id: string | Object): boolean</code>","text":"<p>Returns true if the dialog exists and is open.</p>"},{"location":"javascript/new-api_dom/","title":"Working with the DOM - JavaScript API","text":""},{"location":"javascript/new-api_dom/#domutil","title":"<code>Dom/Util</code>","text":""},{"location":"javascript/new-api_dom/#createfragmentfromhtmlhtml-string-documentfragment","title":"<code>createFragmentFromHtml(html: string): DocumentFragment</code>","text":"<p>Parses a HTML string and creates a <code>DocumentFragment</code> object that holds the resulting nodes.</p>"},{"location":"javascript/new-api_dom/#identifyelement-element-string","title":"<code>identify(element: Element): string</code>","text":"<p>Retrieves the unique identifier (<code>id</code>) of an element. If it does not currently have an id assigned, a generic identifier is used instead.</p>"},{"location":"javascript/new-api_dom/#outerheightelement-element-styles-cssstyledeclaration-number","title":"<code>outerHeight(element: Element, styles?: CSSStyleDeclaration): number</code>","text":"<p>Computes the outer height of an element using the element's <code>offsetHeight</code> and the sum of the rounded down values for <code>margin-top</code> and <code>margin-bottom</code>.</p>"},{"location":"javascript/new-api_dom/#outerwidthelement-element-styles-cssstyledeclaration-number","title":"<code>outerWidth(element: Element, styles?: CSSStyleDeclaration): number</code>","text":"<p>Computes the outer width of an element using the element's <code>offsetWidth</code> and the sum of the rounded down values for <code>margin-left</code> and <code>margin-right</code>.</p>"},{"location":"javascript/new-api_dom/#outerdimensionselement-element-height-number-width-number","title":"<code>outerDimensions(element: Element): { height: number, width: number }</code>","text":"<p>Computes the outer dimensions of an element including its margins.</p>"},{"location":"javascript/new-api_dom/#offsetelement-element-top-number-left-number","title":"<code>offset(element: Element): { top: number, left: number }</code>","text":"<p>Computes the element's offset relative to the top left corner of the document.</p>"},{"location":"javascript/new-api_dom/#setinnerhtmlelement-element-innerhtml-string","title":"<code>setInnerHtml(element: Element, innerHtml: string)</code>","text":"<p>Sets the inner HTML of an element via <code>element.innerHTML = innerHtml</code>. Browsers do not evaluate any embedded <code><script></code> tags, therefore this method extracts each of them, creates new <code><script></code> tags and inserts them in their original order of appearance.</p>"},{"location":"javascript/new-api_dom/#containselement-element-child-element-boolean","title":"<code>contains(element: Element, child: Element): boolean</code>","text":"<p>Evaluates if <code>element</code> is a direct or indirect parent element of <code>child</code>.</p>"},{"location":"javascript/new-api_dom/#unwrapchildnodeselement-element","title":"<code>unwrapChildNodes(element: Element)</code>","text":"<p>Moves all child nodes out of <code>element</code> while maintaining their order, then removes <code>element</code> from the document.</p>"},{"location":"javascript/new-api_dom/#domchangelistener","title":"<code>Dom/ChangeListener</code>","text":"<p>This class is used to observe specific changes to the DOM, for example after an Ajax request has completed. For performance reasons this is a manually-invoked listener that does not rely on a <code>MutationObserver</code>.</p> <pre><code>require([\"Dom/ChangeListener\"], function(DomChangeListener) {\n DomChangeListener.add(\"App/Foo\", function() {\n // the DOM may have been altered significantly\n });\n\n // propagate changes to the DOM\n DomChangeListener.trigger();\n});\n</code></pre>"},{"location":"javascript/new-api_events/","title":"Event Handling - JavaScript API","text":""},{"location":"javascript/new-api_events/#eventkey","title":"<code>EventKey</code>","text":"<p>This class offers a set of static methods that can be used to determine if some common keys are being pressed. Internally it compares either the <code>.key</code> property if it is supported or the value of <code>.which</code>.</p> <pre><code>require([\"EventKey\"], function(EventKey) {\n elBySel(\".some-input\").addEventListener(\"keydown\", function(event) {\n if (EventKey.Enter(event)) {\n // the `Enter` key was pressed\n }\n });\n});\n</code></pre>"},{"location":"javascript/new-api_events/#arrowdownevent-keyboardevent-boolean","title":"<code>ArrowDown(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2193</code> key.</p>"},{"location":"javascript/new-api_events/#arrowleftevent-keyboardevent-boolean","title":"<code>ArrowLeft(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2190</code> key.</p>"},{"location":"javascript/new-api_events/#arrowrightevent-keyboardevent-boolean","title":"<code>ArrowRight(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2192</code> key.</p>"},{"location":"javascript/new-api_events/#arrowupevent-keyboardevent-boolean","title":"<code>ArrowUp(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2191</code> key.</p>"},{"location":"javascript/new-api_events/#commaevent-keyboardevent-boolean","title":"<code>Comma(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>,</code> key.</p>"},{"location":"javascript/new-api_events/#enterevent-keyboardevent-boolean","title":"<code>Enter(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u21b2</code> key.</p>"},{"location":"javascript/new-api_events/#escapeevent-keyboardevent-boolean","title":"<code>Escape(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>Esc</code> key.</p>"},{"location":"javascript/new-api_events/#tabevent-keyboardevent-boolean","title":"<code>Tab(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u21b9</code> key.</p>"},{"location":"javascript/new-api_events/#eventhandler","title":"<code>EventHandler</code>","text":"<p>A synchronous event system based on string identifiers rather than DOM elements, similar to the PHP event system in WoltLab Suite. Any components can listen to events or trigger events itself at any time.</p>"},{"location":"javascript/new-api_events/#identifiying-events-with-the-developer-tools","title":"Identifiying Events with the Developer Tools","text":"<p>The Developer Tools offer an easy option to identify existing events that are fired while code is being executed. You can enable this watch mode through your browser's console using <code>Devtools.toggleEventLogging()</code>:</p> <pre><code>> Devtools.toggleEventLogging();\n< Event logging enabled\n< [Devtools.EventLogging] Firing event: bar @ com.example.app.foo\n< [Devtools.EventLogging] Firing event: baz @ com.example.app.foo\n</code></pre>"},{"location":"javascript/new-api_events/#addidentifier-string-action-string-callback-data-object-void-string","title":"<code>add(identifier: string, action: string, callback: (data: Object) => void): string</code>","text":"<p>Adding an event listeners returns a randomly generated UUIDv4 that is used to identify the listener. This UUID is required to remove a specific listener through the <code>remove()</code> method.</p>"},{"location":"javascript/new-api_events/#fireidentifier-string-action-string-data-object","title":"<code>fire(identifier: string, action: string, data?: Object)</code>","text":"<p>Triggers an event using an optional <code>data</code> object that is passed to each listener by reference.</p>"},{"location":"javascript/new-api_events/#removeidentifier-string-action-string-uuid-string","title":"<code>remove(identifier: string, action: string, uuid: string)</code>","text":"<p>Removes a previously registered event listener using the UUID returned by <code>add()</code>.</p>"},{"location":"javascript/new-api_events/#removeallidentifier-string-action-string","title":"<code>removeAll(identifier: string, action: string)</code>","text":"<p>Removes all event listeners registered for the provided <code>identifier</code> and <code>action</code>.</p>"},{"location":"javascript/new-api_events/#removeallbysuffixidentifier-string-suffix-string","title":"<code>removeAllBySuffix(identifier: string, suffix: string)</code>","text":"<p>Removes all event listeners for an <code>identifier</code> whose action ends with the value of <code>suffix</code>.</p>"},{"location":"javascript/new-api_ui/","title":"User Interface - JavaScript API","text":""},{"location":"javascript/new-api_ui/#uialignment","title":"<code>Ui/Alignment</code>","text":"<p>Calculates the alignment of one element relative to another element, with support for boundary constraints, alignment restrictions and additional pointer elements.</p>"},{"location":"javascript/new-api_ui/#setelement-element-referenceelement-element-options-object","title":"<code>set(element: Element, referenceElement: Element, options: Object)</code>","text":"<p>Calculates and sets the alignment of the element <code>element</code>.</p>"},{"location":"javascript/new-api_ui/#verticaloffset-number","title":"<code>verticalOffset: number</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Creates a gap between the element and the reference element, in pixels.</p>"},{"location":"javascript/new-api_ui/#pointer-boolean","title":"<code>pointer: boolean</code>","text":"<p>Defaults to <code>false</code>.</p> <p>Sets the position of the pointer element, requires an existing child of the element with the CSS class <code>.elementPointer</code>.</p>"},{"location":"javascript/new-api_ui/#pointeroffset-number","title":"<code>pointerOffset: number</code>","text":"<p>Defaults to <code>4</code>.</p> <p>The margin from the left/right edge of the element and is used to avoid the arrow from being placed right at the edge.</p> <p>Does not apply when aligning the element to the reference elemnent's center.</p>"},{"location":"javascript/new-api_ui/#pointerclassnames-string","title":"<code>pointerClassNames: string[]</code>","text":"<p>Defaults to <code>[]</code>.</p> <p>If your element uses CSS-only pointers, such as using the <code>::before</code> or <code>::after</code> pseudo selectors, you can specifiy two separate CSS class names that control the alignment:</p> <ul> <li><code>pointerClassNames[0]</code> is applied to the element when the pointer is displayed at the bottom.</li> <li><code>pointerClassNames[1]</code> is used to align the pointer to the right side of the element.</li> </ul>"},{"location":"javascript/new-api_ui/#refdimensionselement-element","title":"<code>refDimensionsElement: Element</code>","text":"<p>Defaults to <code>null</code>.</p> <p>An alternative element that will be used to determine the position and dimensions of the reference element. This can be useful if you reference element is contained in a wrapper element with alternating dimensions.</p>"},{"location":"javascript/new-api_ui/#horizontal-string","title":"<code>horizontal: string</code>","text":"<p>This value is automatically flipped for RTL (right-to-left) languages, <code>left</code> is changed into <code>right</code> and vice versa.</p> <p>Defaults to <code>\"left\"</code>.</p> <p>Sets the prefered alignment, accepts either <code>left</code> or <code>right</code>. The value <code>left</code> instructs the module to align the element with the left boundary of the reference element.</p> <p>The <code>horizontal</code> alignment is used as the default and a flip only occurs, if there is not enough space in the desired direction. If the element exceeds the boundaries in both directions, the value of <code>horizontal</code> is used.</p>"},{"location":"javascript/new-api_ui/#vertical-string","title":"<code>vertical: string</code>","text":"<p>Defaults to <code>\"bottom\"</code>.</p> <p>Sets the prefered alignment, accepts either <code>bottom</code> or <code>top</code>. The value <code>bottom</code> instructs the module to align the element below the reference element.</p> <p>The <code>vertical</code> alignment is used as the default and a flip only occurs, if there is not enough space in the desired direction. If the element exceeds the boundaries in both directions, the value of <code>vertical</code> is used.</p>"},{"location":"javascript/new-api_ui/#allowflip-string","title":"<code>allowFlip: string</code>","text":"<p>The value for <code>horizontal</code> is automatically flipped for RTL (right-to-left) languages, <code>left</code> is changed into <code>right</code> and vice versa. This setting only controls the behavior when violating space constraints, therefore the aforementioned transformation is always applied.</p> <p>Defaults to <code>\"both\"</code>.</p> <p>Restricts the automatic alignment flipping if the element exceeds the window boundaries in the instructed direction.</p> <ul> <li><code>both</code> - No restrictions.</li> <li><code>horizontal</code> - Element can be aligned with the left or the right boundary of the reference element, but the vertical position is fixed.</li> <li><code>vertical</code> - Element can be aligned below or above the reference element, but the vertical position is fixed.</li> <li><code>none</code> - No flipping can occur, the element will be aligned regardless of any space constraints.</li> </ul>"},{"location":"javascript/new-api_ui/#uicloseoverlay","title":"<code>Ui/CloseOverlay</code>","text":"<p>Register elements that should be closed when the user clicks anywhere else, such as drop-down menus or tooltips.</p> <pre><code>require([\"Ui/CloseOverlay\"], function(UiCloseOverlay) {\n UiCloseOverlay.add(\"App/Foo\", function() {\n // invoked, close something\n });\n});\n</code></pre>"},{"location":"javascript/new-api_ui/#addidentifier-string-callback-void","title":"<code>add(identifier: string, callback: () => void)</code>","text":"<p>Adds a callback that will be invoked when the user clicks anywhere else.</p>"},{"location":"javascript/new-api_ui/#uiconfirmation","title":"<code>Ui/Confirmation</code>","text":"<p>Prompt the user to make a decision before carrying out an action, such as a safety warning before permanently deleting content.</p> <pre><code>require([\"Ui/Confirmation\"], function(UiConfirmation) {\n UiConfirmation.show({\n confirm: function() {\n // the user has confirmed the dialog\n },\n message: \"Do you really want to continue?\"\n });\n});\n</code></pre>"},{"location":"javascript/new-api_ui/#showoptions-object","title":"<code>show(options: Object)</code>","text":"<p>Displays a dialog overlay with actions buttons to confirm or reject the dialog.</p>"},{"location":"javascript/new-api_ui/#cancel-parameters-object-void","title":"<code>cancel: (parameters: Object) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Callback that is invoked when the dialog was rejected.</p>"},{"location":"javascript/new-api_ui/#confirm-parameters-object-void","title":"<code>confirm: (parameters: Object) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Callback that is invoked when the user has confirmed the dialog.</p>"},{"location":"javascript/new-api_ui/#message-string","title":"<code>message: string</code>","text":"<p>Defaults to '\"\"'.</p> <p>Text that is displayed in the content area of the dialog, optionally this can be HTML, but this requires <code>messageIsHtml</code> to be enabled.</p>"},{"location":"javascript/new-api_ui/#messageishtml","title":"<code>messageIsHtml</code>","text":"<p>Defaults to <code>false</code>.</p> <p>The <code>message</code> option is interpreted as text-only, setting this option to <code>true</code> will cause the <code>message</code> to be evaluated as HTML.</p>"},{"location":"javascript/new-api_ui/#parameters-object","title":"<code>parameters: Object</code>","text":"<p>Optional list of parameter options that will be passed to the <code>cancel()</code> and <code>confirm()</code> callbacks.</p>"},{"location":"javascript/new-api_ui/#template-string","title":"<code>template: string</code>","text":"<p>An optional HTML template that will be inserted into the dialog content area, but after the <code>message</code> section.</p>"},{"location":"javascript/new-api_ui/#uinotification","title":"<code>Ui/Notification</code>","text":"<p>Displays a simple notification at the very top of the window, such as a success message for Ajax based actions.</p> <pre><code>require([\"Ui/Notification\"], function(UiNotification) {\n UiNotification.show(\n \"Your changes have been saved.\",\n function() {\n // this callback will be invoked after 2 seconds\n },\n \"success\"\n );\n});\n</code></pre>"},{"location":"javascript/new-api_ui/#showmessage-string-callback-void-cssclassname-string","title":"<code>show(message: string, callback?: () => void, cssClassName?: string)</code>","text":"<p>Shows the notification and executes the callback after 2 seconds.</p>"},{"location":"javascript/new-api_writing-a-module/","title":"Writing a Module - JavaScript API","text":""},{"location":"javascript/new-api_writing-a-module/#introduction","title":"Introduction","text":"<p>The new JavaScript-API was introduced with WoltLab Suite 3.0 and was a major change in all regards. The previously used API heavily relied on larger JavaScript files that contained a lot of different components with hidden dependencies and suffered from extensive jQuery usage for historic reasons.</p> <p>Eventually a new API was designed that solves the issues with the legacy API by following a few basic principles: 1. Vanilla ES5-JavaScript. It allows us to achieve the best performance across all platforms, there is simply no reason to use jQuery today and the performance penalty on mobile devices is a real issue. 2. Strict usage of modules. Each component is placed in an own file and all dependencies are explicitly declared and injected at the top.Eventually we settled with AMD-style modules using require.js which offers both lazy loading and \"ahead of time\"-compilatio with <code>r.js</code>. 3. No jQuery-based components on page init. Nothing is more annoying than loading a page and then wait for JavaScript to modify the page before it becomes usable, forcing the user to sit and wait. Heavily optimized vanilla JavaScript components offered the speed we wanted. 4. Limited backwards-compatibility. The new API should make it easy to update existing components by providing similar interfaces, while still allowing legacy code to run side-by-side for best compatibility and to avoid rewritting everything from the start.</p>"},{"location":"javascript/new-api_writing-a-module/#defining-a-module","title":"Defining a Module","text":"<p>The default location for modules is <code>js/</code> in the Core's app dir, but every app and plugin can register their own lookup path by providing the path using a template-listener on <code>requirePaths@headIncludeJavaScript</code>.</p> <p>For this example we'll assume the file is placed at <code>js/WoltLabSuite/Core/Ui/Foo.js</code>, the module name is therefore <code>WoltLabSuite/Core/Ui/Foo</code>, it is automatically derived from the file path and name.</p> <p>For further instructions on how to define and require modules head over to the RequireJS API.</p> <pre><code>define([\"Ajax\", \"WoltLabSuite/Core/Ui/Bar\"], function(Ajax, UiBar) {\n \"use strict\";\n\n function Foo() { this.init(); }\n Foo.prototype = {\n init: function() {\n elBySel(\".myButton\").addEventListener(WCF_CLICK_EVENT, this._click.bind(this));\n },\n\n _click: function(event) {\n event.preventDefault();\n\n if (UiBar.isSnafucated()) {\n Ajax.api(this);\n }\n },\n\n _ajaxSuccess: function(data) {\n console.log(\"Received response\", data);\n },\n\n _ajaxSetup: function() {\n return {\n data: {\n actionName: \"makeSnafucated\",\n className: \"wcf\\\\data\\\\foo\\\\FooAction\"\n }\n };\n }\n }\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/new-api_writing-a-module/#loading-a-module","title":"Loading a Module","text":"<p>Modules can then be loaded through their derived name:</p> <pre><code><script data-relocate=\"true\">\n require([\"WoltLabSuite/Core/Ui/Foo\"], function(UiFoo) {\n new UiFoo();\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_writing-a-module/#module-aliases","title":"Module Aliases","text":"<p>Some common modules have short-hand aliases that can be used to include them without writing out their full name. You can still use their original path, but it is strongly recommended to use the aliases for consistency.</p> Alias Full Path Ajax WoltLabSuite/Core/Ajax AjaxJsonp WoltLabSuite/Core/Ajax/Jsonp AjaxRequest WoltLabSuite/Core/Ajax/Request CallbackList WoltLabSuite/Core/CallbackList ColorUtil WoltLabSuite/Core/ColorUtil Core WoltLabSuite/Core/Core DateUtil WoltLabSuite/Core/Date/Util Devtools WoltLabSuite/Core/Devtools Dom/ChangeListener WoltLabSuite/Core/Dom/Change/Listener Dom/Traverse WoltLabSuite/Core/Dom/Traverse Dom/Util WoltLabSuite/Core/Dom/Util Environment WoltLabSuite/Core/Environment EventHandler WoltLabSuite/Core/Event/Handler EventKey WoltLabSuite/Core/Event/Key Language WoltLabSuite/Core/Language Permission WoltLabSuite/Core/Permission StringUtil WoltLabSuite/Core/StringUtil Ui/Alignment WoltLabSuite/Core/Ui/Alignment Ui/CloseOverlay WoltLabSuite/Core/Ui/CloseOverlay Ui/Confirmation WoltLabSuite/Core/Ui/Confirmation Ui/Dialog WoltLabSuite/Core/Ui/Dialog Ui/Notification WoltLabSuite/Core/Ui/Notification Ui/ReusableDropdown WoltLabSuite/Core/Ui/Dropdown/Reusable Ui/Screen WoltLabSuite/Core/Ui/Screen Ui/Scroll WoltLabSuite/Core/Ui/Scroll Ui/SimpleDropdown WoltLabSuite/Core/Ui/Dropdown/Simple Ui/TabMenu WoltLabSuite/Core/Ui/TabMenu Upload WoltLabSuite/Core/Upload User WoltLabSuite/Core/User"},{"location":"javascript/typescript/","title":"TypeScript","text":""},{"location":"javascript/typescript/#consuming-woltlab-suites-types","title":"Consuming WoltLab Suite\u2019s Types","text":"<p>To consume the types of WoltLab Suite, you will need to install the <code>@woltlab/wcf</code> npm package using a git URL that refers to the appropriate branch of WoltLab/WCF.</p> <p>A full <code>package.json</code> that includes WoltLab Suite, TypeScript, eslint and Prettier could look like the following.</p> package.json <pre><code>{\n \"devDependencies\": {\n \"@typescript-eslint/eslint-plugin\": \"^6.5.0\",\n \"@typescript-eslint/parser\": \"^6.5.0\",\n \"eslint\": \"^8.48.0\",\n \"eslint-config-prettier\": \"^9.0.0\",\n \"prettier\": \"^3.0.3\",\n \"typescript\": \"^5.2.2\"\n },\n \"dependencies\": {\n \"@woltlab/d.ts\": \"https://github.com/WoltLab/d.ts.git#51281749962192683d2b9d6a17388fb2298b4b62\"\n }\n}\n</code></pre> <p>After installing the types using npm, you will also need to configure <code>tsconfig.json</code> to take the types into account. To do so, you will need to add them to the <code>compilerOptions.paths</code> option. A complete <code>tsconfig.json</code> file that matches the configuration of WoltLab Suite could look like the following.</p> tsconfig.json <pre><code>{\n \"include\": [\n \"node_modules/@woltlab/d.ts/global.d.ts\",\n \"ts/**/*\"\n ],\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"amd\",\n \"rootDir\": \"ts/\",\n \"outDir\": \"files/js/\",\n \"lib\": [\n \"DOM\",\n \"DOM.Iterable\",\n \"ES2022\"\n ],\n \"strictNullChecks\": true,\n \"moduleResolution\": \"node\",\n \"esModuleInterop\": true,\n \"noImplicitThis\": true,\n \"strictBindCallApply\": true,\n \"baseUrl\": \".\",\n \"paths\": {\n \"*\": [\n \"node_modules/@woltlab/d.ts/*\"\n ]\n },\n \"importHelpers\": true,\n \"newLine\": \"lf\"\n }\n}\n</code></pre> <p>After this initial set-up, you would place your TypeScript source files into the <code>ts/</code> folder of your project. The generated JavaScript target files will be placed into <code>files/js/</code> and thus will be installed by the file PIP.</p> <p>To update the TypeScript types, the commit hash in <code>package.json</code> needs to be updated to an appropriate commit in the d.ts repository and <code>npm install</code> needs to be rerun.</p>"},{"location":"javascript/typescript/#additional-tools","title":"Additional Tools","text":"<p>WoltLab Suite uses additional tools to ensure the high quality and a consistent code style of the TypeScript modules. The current configuration of these tools is as follows. It is recommended to re-use this configuration as is.</p> .prettierrc <pre><code>trailingComma: all\nprintWidth: 120\n</code></pre> .eslintrc.js <pre><code>module.exports = {\n root: true,\n parser: \"@typescript-eslint/parser\",\n parserOptions: {\n tsconfigRootDir: __dirname,\n project: [\"./tsconfig.json\"]\n },\n plugins: [\"@typescript-eslint\"],\n extends: [\n \"eslint:recommended\",\n \"plugin:@typescript-eslint/recommended\",\n \"plugin:@typescript-eslint/recommended-type-checked\",\n \"plugin:@typescript-eslint/strict\",\n \"plugin:@typescript-eslint/strict-type-checked\",\n \"plugin:@typescript-eslint/stylistic\",\n \"plugin:@typescript-eslint/stylistic-type-checked\",\n \"prettier\"\n ],\n rules: {\n \"@typescript-eslint/no-non-null-assertion\": 0,\n \"@typescript-eslint/consistent-type-definitions\": 0,\n \"@typescript-eslint/prefer-nullish-coalescing\": 0,\n \"@typescript-eslint/no-unused-vars\": [\n \"error\", {\n \"argsIgnorePattern\": \"^_\"\n }\n ],\n \"@typescript-eslint/strict-boolean-expressions\": [\n \"error\", {\n \"allowNullableBoolean\": true\n }\n ],\n }\n};\n</code></pre> .eslintignore <pre><code>**/*.js\nvendor/**\n</code></pre> <p>This <code>.gitattributes</code> configuration will automatically collapse the generated JavaScript target files in GitHub\u2019s Diff view. You will not need it if you do not use git or GitHub.</p> .gitattributes <pre><code>files/js/**/*.js linguist-generated\n</code></pre>"},{"location":"javascript/typescript/#writing-a-simple-module","title":"Writing a simple module","text":"<p>After completing this initial set-up you can start writing your first TypeScript module. The TypeScript compiler can be launched in Watch Mode by running <code>npx tsc -w</code>.</p> <p>WoltLab Suite\u2019s modules can be imported using the standard ECMAScript module import syntax by specifying the full module name. The public API of the module can also be exported using the standard ECMAScript module export syntax.</p> ts/Example.ts <pre><code>import * as Language from \"WoltLabSuite/Core/Language\";\n\nexport function run() {\n alert(Language.get(\"wcf.foo.bar\"));\n}\n</code></pre> <p>This simple example module will compile to plain JavaScript that is compatible with the AMD loader that is used by WoltLab Suite.</p> files/js/Example.js <pre><code>define([\"require\", \"exports\", \"tslib\", \"WoltLabSuite/Core/Language\"], function (require, exports, tslib_1, Language) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.run = void 0;\n Language = tslib_1.__importStar(Language);\n function run() {\n alert(Language.get(\"wcf.foo.bar\"));\n }\n exports.run = run;\n});\n</code></pre> <p>Within templates it can be consumed as follows.</p> <pre><code><script data-relocate=\"true\">\n require([\"Example\"], (Example) => {\n Example.run(); // Alerts the contents of the `wcf.foo.bar` phrase.\n });\n</script>\n</code></pre>"},{"location":"migration/wcf21/css/","title":"WCF 2.1.x - CSS","text":"<p>The LESS compiler has been in use since WoltLab Community Framework 2.0, but was replaced with a SCSS compiler in WoltLab Suite 3.0. This change was motivated by SCSS becoming the de facto standard for CSS pre-processing and some really annoying shortcomings in the old LESS compiler.</p> <p>The entire CSS has been rewritten from scratch, please read the docs on CSS to learn what has changed.</p>"},{"location":"migration/wcf21/package/","title":"WCF 2.1.x - Package Components","text":""},{"location":"migration/wcf21/package/#packagexml","title":"package.xml","text":""},{"location":"migration/wcf21/package/#short-instructions","title":"Short Instructions","text":"<p>Instructions can now omit the filename, causing them to use the default filename if defined by the package installation plugin (in short: <code>PIP</code>). Unless overridden it will default to the PIP's class name with the first letter being lower-cased, e.g. <code>EventListenerPackageInstallationPlugin</code> implies the filename <code>eventListener.xml</code>. The file is always assumed to be in the archive's root, files located in subdirectories need to be explicitly stated, just as it worked before.</p> <p>Every PIP can define a custom filename if the default value cannot be properly derived. For example the <code>ACPMenu</code>-pip would default to <code>aCPMenu.xml</code>, requiring the class to explicitly override the default filename with <code>acpMenu.xml</code> for readability.</p>"},{"location":"migration/wcf21/package/#example","title":"Example","text":"<pre><code><instructions type=\"install\">\n <!-- assumes `eventListener.xml` -->\n <instruction type=\"eventListener\" />\n <!-- assumes `install.sql` -->\n <instruction type=\"sql\" />\n <!-- assumes `language/*.xml` -->\n <instruction type=\"language\" />\n\n <!-- exceptions -->\n\n <!-- assumes `files.tar` -->\n <instruction type=\"file\" />\n <!-- no default value, requires relative path -->\n <instruction type=\"script\">acp/install_com.woltlab.wcf_3.0.php</instruction>\n</instructions>\n</code></pre>"},{"location":"migration/wcf21/package/#exceptions","title":"Exceptions","text":"<p>These exceptions represent the built-in PIPs only, 3rd party plugins and apps may define their own exceptions.</p> PIP Default Value <code>acpTemplate</code> <code>acptemplates.tar</code> <code>file</code> <code>files.tar</code> <code>language</code> <code>language/*.xml</code> <code>script</code> (No default value) <code>sql</code> <code>install.sql</code> <code>template</code> <code>templates.tar</code>"},{"location":"migration/wcf21/package/#acpmenuxml","title":"acpMenu.xml","text":""},{"location":"migration/wcf21/package/#renamed-categories","title":"Renamed Categories","text":"<p>The following categories have been renamed, menu items need to be adjusted to reflect the new names:</p> Old Value New Value <code>wcf.acp.menu.link.system</code> <code>wcf.acp.menu.link.configuration</code> <code>wcf.acp.menu.link.display</code> <code>wcf.acp.menu.link.customization</code> <code>wcf.acp.menu.link.community</code> <code>wcf.acp.menu.link.application</code>"},{"location":"migration/wcf21/package/#submenu-items","title":"Submenu Items","text":"<p>Menu items can now offer additional actions to be accessed from within the menu using an icon-based navigation. This step avoids filling the menu with dozens of <code>Add \u2026</code> links, shifting the focus on to actual items. Adding more than one action is not recommended and you should at maximum specify two actions per item.</p>"},{"location":"migration/wcf21/package/#example_1","title":"Example","text":"<pre><code><!-- category -->\n<acpmenuitem name=\"wcf.acp.menu.link.group\">\n <parent>wcf.acp.menu.link.user</parent>\n <showorder>2</showorder>\n</acpmenuitem>\n\n<!-- menu item -->\n<acpmenuitem name=\"wcf.acp.menu.link.group.list\">\n <controller>wcf\\acp\\page\\UserGroupListPage</controller>\n <parent>wcf.acp.menu.link.group</parent>\n <permissions>admin.user.canEditGroup,admin.user.canDeleteGroup</permissions>\n</acpmenuitem>\n<!-- menu item action -->\n<acpmenuitem name=\"wcf.acp.menu.link.group.add\">\n <controller>wcf\\acp\\form\\UserGroupAddForm</controller>\n <!-- actions are defined by menu items of menu items -->\n <parent>wcf.acp.menu.link.group.list</parent>\n <permissions>admin.user.canAddGroup</permissions>\n <!-- required FontAwesome icon name used for display -->\n <icon>fa-plus</icon>\n</acpmenuitem>\n</code></pre>"},{"location":"migration/wcf21/package/#common-icon-names","title":"Common Icon Names","text":"<p>You should use the same icon names for the (logically) same task, unifying the meaning of items and making the actions predictable.</p> Meaning Icon Name Result Add or create <code>fa-plus</code> Search <code>fa-search</code> Upload <code>fa-upload</code>"},{"location":"migration/wcf21/package/#boxxml","title":"box.xml","text":"<p>The box PIP has been added.</p>"},{"location":"migration/wcf21/package/#cronjobxml","title":"cronjob.xml","text":"<p>Legacy cronjobs are assigned a non-deterministic generic name, the only way to assign them a name is removing them and then adding them again.</p> <p>Cronjobs can now be assigned a name using the name attribute as in <code><cronjob name=\"com.woltlab.wcf.refreshPackageUpdates\"></code>, it will be used to identify cronjobs during an update or delete.</p>"},{"location":"migration/wcf21/package/#eventlistenerxml","title":"eventListener.xml","text":"<p>Legacy event listeners are assigned a non-deterministic generic name, the only way to assign them a name is removing them and then adding them again.</p> <p>Event listeners can now be assigned a name using the name attribute as in <code><eventlistener name=\"sessionPageAccessLog\"></code>, it will be used to identify event listeners during an update or delete.</p>"},{"location":"migration/wcf21/package/#menuxml","title":"menu.xml","text":"<p>The menu PIP has been added.</p>"},{"location":"migration/wcf21/package/#menuitemxml","title":"menuItem.xml","text":"<p>The menuItem PIP has been added.</p>"},{"location":"migration/wcf21/package/#objecttypexml","title":"objectType.xml","text":"<p>The definition <code>com.woltlab.wcf.user.dashboardContainer</code> has been removed, it was previously used to register pages that qualify for dashboard boxes. Since WoltLab Suite 3.0, all pages registered through the <code>page.xml</code> are valid containers and therefore there is no need for this definition anymore.</p> <p>The definitions <code>com.woltlab.wcf.page</code> and <code>com.woltlab.wcf.user.online.location</code> have been superseded by the <code>page.xml</code>, they're no longer supported.</p>"},{"location":"migration/wcf21/package/#optionxml","title":"option.xml","text":"<p>The <code>module.display</code> category has been renamed into <code>module.customization</code>.</p>"},{"location":"migration/wcf21/package/#pagexml","title":"page.xml","text":"<p>The page PIP has been added.</p>"},{"location":"migration/wcf21/package/#pagemenuxml","title":"pageMenu.xml","text":"<p>The <code>pageMenu.xml</code> has been superseded by the <code>page.xml</code> and is no longer available.</p>"},{"location":"migration/wcf21/php/","title":"WCF 2.1.x - PHP","text":""},{"location":"migration/wcf21/php/#message-processing","title":"Message Processing","text":"<p>WoltLab Suite 3.0 finally made the transition from raw bbcode to bbcode-flavored HTML, with many new features related to message processing being added. This change impacts both message validation and storing, requiring slightly different APIs to get the job done.</p>"},{"location":"migration/wcf21/php/#input-processing-for-storage","title":"Input Processing for Storage","text":"<p>The returned HTML is an intermediate representation with a maximum of meta data embedded into it, designed to be stored in the database. Some bbcodes are replaced during this process, for example <code>[b]\u2026[/b]</code> becomes <code><strong>\u2026</strong></code>, while others are converted into a metacode tag for later processing.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->process($message, $messageObjectType, $messageObjectID);\n$html = $processor->getHtml();\n</code></pre> <p>The <code>$messageObjectID</code> can be zero if the element did not exist before, but it should be non-zero when saving an edited message.</p>"},{"location":"migration/wcf21/php/#embedded-objects","title":"Embedded Objects","text":"<p>Embedded objects need to be registered after saving the message, but once again you can use the processor instance to do the job.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->process($message, $messageObjectType, $messageObjectID);\n$html = $processor->getHtml();\n\n// at this point the message is saved to database and the created object\n// `$example` is a `DatabaseObject` with the id column `$exampleID`\n\n$processor->setObjectID($example->exampleID);\nif (\\wcf\\system\\message\\embedded\\object\\MessageEmbeddedObjectManager::getInstance()->registerObjects($processor)) {\n // there is at least one embedded object, this is also the point at which you\n // would set `hasEmbeddedObjects` to true (if implemented by your type)\n (new \\wcf\\data\\example\\ExampleEditor($example))->update(['hasEmbeddedObjects' => 1]);\n}\n</code></pre>"},{"location":"migration/wcf21/php/#rendering-the-message","title":"Rendering the Message","text":"<p>The output processor will parse the intermediate HTML and finalize the output for display. This step is highly dynamic and allows for bbcode evaluation and contextual output based on the viewer's permissions.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\output\\HtmlOutputProcessor();\n$processor->process($html, $messageObjectType, $messageObjectID);\n$renderedHtml = $processor->getHtml();\n</code></pre>"},{"location":"migration/wcf21/php/#simplified-output","title":"Simplified Output","text":"<p>At some point there can be the need of a simplified output HTML that includes only basic HTML formatting and reduces more sophisticated bbcodes into a simpler representation.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\output\\HtmlOutputProcessor();\n$processor->setOutputType('text/simplified-html');\n$processor->process(\u2026);\n</code></pre>"},{"location":"migration/wcf21/php/#plaintext-output","title":"Plaintext Output","text":"<p>The <code>text/plain</code> output type will strip down the simplified HTML into pure text, suitable for text-only output such as the plaintext representation of an email.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\output\\HtmlOutputProcessor();\n$processor->setOutputType('text/plain');\n$processor->process(\u2026);\n</code></pre>"},{"location":"migration/wcf21/php/#rebuilding-data","title":"Rebuilding Data","text":""},{"location":"migration/wcf21/php/#converting-from-bbcode","title":"Converting from BBCode","text":"<p>Enabling message conversion for HTML messages is undefined and yields unexpected results.</p> <p>Legacy message that still use raw bbcodes must be converted to be properly parsed by the html processors. This process is enabled by setting the fourth parameter of <code>process()</code> to <code>true</code>.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->process($html, $messageObjectType, $messageObjectID, true);\n$renderedHtml = $processor->getHtml();\n</code></pre>"},{"location":"migration/wcf21/php/#extracting-embedded-objects","title":"Extracting Embedded Objects","text":"<p>The <code>process()</code> method of the input processor is quite expensive, as it runs through the full message validation including the invocation of HTMLPurifier. This is perfectly fine when dealing with single messages, but when you're handling messages in bulk to extract their embedded objects, you're better of with <code>processEmbeddedContent()</code>. This method deconstructs the message, but skips all validation and expects the input to be perfectly valid, that is the output of a previous run of <code>process()</code> saved to storage.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->processEmbeddedContent($html, $messageObjectType, $messageObjectID);\n\n// invoke `MessageEmbeddedObjectManager::registerObjects` here\n</code></pre>"},{"location":"migration/wcf21/php/#breadcrumbs-page-location","title":"Breadcrumbs / Page Location","text":"<p>Breadcrumbs used to be added left to right, but parent locations are added from the bottom to the top, starting with the first ancestor and going upwards. In most cases you simply need to reverse the order.</p> <p>Breadcrumbs used to be a lose collection of arbitrary links, but are now represented by actual page objects and the control has shifted over to the <code>PageLocationManager</code>.</p> <pre><code><?php\n// before\n\\wcf\\system\\WCF::getBreadcrumbs()->add(new \\wcf\\system\\breadcrumb\\Breadcrumb('title', 'link'));\n\n// after\n\\wcf\\system\\page\\PageLocationManager::getInstance()->addParentLocation($pageIdentifier, $pageObjectID, $object);\n</code></pre>"},{"location":"migration/wcf21/php/#pages-and-forms","title":"Pages and Forms","text":"<p>The property <code>$activeMenuItem</code> has been deprecated for the front end and is no longer evaluated at runtime. Recognition of the active item is entirely based around the invoked controller class name and its definition in the page table. You need to properly register your pages for this feature to work.</p>"},{"location":"migration/wcf21/php/#search","title":"Search","text":""},{"location":"migration/wcf21/php/#isearchableobjecttype","title":"ISearchableObjectType","text":"<p>Added the <code>setLocation()</code> method that is used to set the current page location based on the search result.</p>"},{"location":"migration/wcf21/php/#searchindexmanager","title":"SearchIndexManager","text":"<p>The methods <code>SearchIndexManager::add()</code> and <code>SearchIndexManager::update()</code> have been deprecated and forward their call to the new method <code>SearchIndexManager::set()</code>.</p>"},{"location":"migration/wcf21/templates/","title":"WCF 2.1.x - Templates","text":""},{"location":"migration/wcf21/templates/#page-layout","title":"Page Layout","text":"<p>The template structure has been overhauled and it is no longer required nor recommended to include internal templates, such as <code>documentHeader</code>, <code>headInclude</code> or <code>userNotice</code>. Instead use a simple <code>{include file='header'}</code> that now takes care of of the entire application frame.</p> <ul> <li>Templates must not include a trailing <code></body></html></code> after including the <code>footer</code> template.</li> <li>The <code>documentHeader</code>, <code>headInclude</code> and <code>userNotice</code> template should no longer be included manually, the same goes with the <code><body></code> element, please use <code>{include file='header'}</code> instead.</li> <li>The <code>sidebarOrientation</code> variable for the <code>header</code> template has been removed and no longer works.</li> <li><code>header.boxHeadline</code> has been unified and now reads <code>header.contentHeader</code></li> </ul> <p>Please see the full example at the end of this page for more information.</p>"},{"location":"migration/wcf21/templates/#sidebars","title":"Sidebars","text":"<p>Sidebars are now dynamically populated by the box system, this requires a small change to unify the markup. Additionally the usage of <code><fieldset></code> has been deprecated due to browser inconsistencies and bugs and should be replaced with <code>section.box</code>.</p> <p>Previous markup used in WoltLab Community Framework 2.1 and earlier:</p> <pre><code><fieldset>\n <legend><!-- Title --></legend>\n\n <div>\n <!-- Content -->\n </div>\n</fieldset>\n</code></pre> <p>The new markup since WoltLab Suite 3.0:</p> <pre><code><section class=\"box\">\n <h2 class=\"boxTitle\"><!-- Title --></h2>\n\n <div class=\"boxContent\">\n <!-- Content -->\n </div>\n</section>\n</code></pre>"},{"location":"migration/wcf21/templates/#forms","title":"Forms","text":"<p>The input tag for session ids <code>SID_INPUT_TAG</code> has been deprecated and no longer yields any content, it can be safely removed. In previous versions forms have been wrapped in <code><div class=\"container containerPadding marginTop\">\u2026</div></code> which no longer has any effect and should be removed.</p> <p>If you're using the preview feature for WYSIWYG-powered input fields, you need to alter the preview button include instruction:</p> <pre><code>{include file='messageFormPreviewButton' previewMessageObjectType='com.example.foo.bar' previewMessageObjectID=0}\n</code></pre> <p>The message object id should be non-zero when editing.</p>"},{"location":"migration/wcf21/templates/#icons","title":"Icons","text":"<p>The old <code>.icon-<iconName></code> classes have been removed, you are required to use the official <code>.fa-<iconName></code> class names from FontAwesome. This does not affect the generic classes <code>.icon</code> (indicates an icon) and <code>.icon<size></code> (e.g. <code>.icon16</code> that sets the dimensions), these are still required and have not been deprecated.</p> <p>Before:</p> <pre><code><span class=\"icon icon16 icon-list\">\n</code></pre> <p>Now:</p> <pre><code><span class=\"icon icon16 fa-list\">\n</code></pre>"},{"location":"migration/wcf21/templates/#changed-icon-names","title":"Changed Icon Names","text":"<p>Quite a few icon names have been renamed, the official wiki lists the new icon names in FontAwesome 4.</p>"},{"location":"migration/wcf21/templates/#changed-classes","title":"Changed Classes","text":"<ul> <li><code>.dataList</code> has been replaced and should now read <code><ol class=\"inlineList commaSeparated\"></code> (same applies to <code><ul></code>)</li> <li><code>.framedIconList</code> has been changed into <code>.userAvatarList</code></li> </ul>"},{"location":"migration/wcf21/templates/#removed-elements-and-classes","title":"Removed Elements and Classes","text":"<ul> <li><code><nav class=\"jsClipboardEditor\"></code> and <code><div class=\"jsClipboardContainer\"></code> have been replaced with a floating button.</li> <li>The anchors <code>a.toTopLink</code> have been replaced with a floating button.</li> <li>Avatars should no longer receive the class <code>framed</code></li> <li>The <code>dl.condensed</code> class, as seen in the editor tab menu, is no longer required.</li> <li>Anything related to <code>sidebarCollapsed</code> has been removed as sidebars are no longer collapsible.</li> </ul>"},{"location":"migration/wcf21/templates/#simple-example","title":"Simple Example","text":"<p>The code below includes only the absolute minimum required to display a page, the content title is already included in the output.</p> <pre><code>{include file='header'}\n\n<div class=\"section\">\n Hello World!\n</div>\n\n{include file='footer'}\n</code></pre>"},{"location":"migration/wcf21/templates/#full-example","title":"Full Example","text":"<pre><code>{*\n The page title is automatically set using the page definition, avoid setting it if you can!\n If you really need to modify the title, you can still reference the original title with:\n {$__wcf->getActivePage()->getTitle()}\n*}\n{capture assign='pageTitle'}Custom Page Title{/capture}\n\n{*\n NOTICE: The content header goes here, see the section after this to learn more.\n*}\n\n{* you must not use `headContent` for JavaScript *}\n{capture assign='headContent'}\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"{lang}wcf.global.button.rss{/lang}\" href=\"\u2026\">\n{/capture}\n\n{* optional, content will be added to the top of the left sidebar *}\n{capture assign='sidebarLeft'}\n \u2026\n\n {event name='boxes'}\n{/capture}\n\n{* optional, content will be added to the top of the right sidebar *}\n{capture assign='sidebarRight'}\n \u2026\n\n {event name='boxes'}\n{/capture}\n\n{capture assign='headerNavigation'}\n <li><a href=\"#\" title=\"Custom Button\" class=\"jsTooltip\"><span class=\"icon icon16 fa-check\"></span> <span class=\"invisible\">Custom Button</span></a></li>\n{/capture}\n\n{include file='header'}\n\n{hascontent}\n <div class=\"paginationTop\">\n {content}\n {pages \u2026}\n {/content}\n </div>\n{/hascontent}\n\n{* the actual content *}\n<div class=\"section\">\n \u2026\n</div>\n\n<footer class=\"contentFooter\">\n {* skip this if you're not using any pagination *}\n {hascontent}\n <div class=\"paginationBottom\">\n {content}{@$pagesLinks}{/content}\n </div>\n {/hascontent}\n\n <nav class=\"contentFooterNavigation\">\n <ul>\n <li><a href=\"\u2026\" class=\"button\"><span class=\"icon icon16 fa-plus\"></span> <span>Custom Button</span></a></li>\n {event name='contentFooterNavigation'}\n </ul>\n </nav>\n</footer>\n\n<script data-relocate=\"true\">\n /* any JavaScript code you need */\n</script>\n\n{* do not include `</body></html>` here, the footer template is the last bit of code! *}\n{include file='footer'}\n</code></pre>"},{"location":"migration/wcf21/templates/#content-header","title":"Content Header","text":"<p>There are two different methods to set the content header, one sets only the actual values, but leaves the outer HTML untouched, that is generated by the <code>header</code> template. This is the recommended approach and you should avoid using the alternative method whenever possible.</p>"},{"location":"migration/wcf21/templates/#recommended-approach","title":"Recommended Approach","text":"<pre><code>{* This is automatically set using the page data and should not be set manually! *}\n{capture assign='contentTitle'}Custom Content Title{/capture}\n\n{capture assign='contentDescription'}Optional description that is displayed right after the title.{/capture}\n\n{capture assign='contentHeaderNavigation'}List of navigation buttons displayed right next to the title.{/capture}\n</code></pre>"},{"location":"migration/wcf21/templates/#alternative","title":"Alternative","text":"<pre><code>{capture assign='contentHeader'}\n <header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">Custom Content Title</h1>\n <p class=\"contentHeaderDescription\">Custom Content Description</p>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='CustomController'}{/link}\" class=\"button\"><span class=\"icon icon16 fa-plus\"></span> <span>Custom Button</span></a></li>\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n </header>\n{/capture}\n</code></pre>"},{"location":"migration/wsc30/css/","title":"Migrating from WSC 3.0 - CSS","text":""},{"location":"migration/wsc30/css/#new-style-variables","title":"New Style Variables","text":"<p>The new style variables are only applied to styles that have the compatibility set to WSC 3.1</p>"},{"location":"migration/wsc30/css/#wcfcontentcontainer","title":"wcfContentContainer","text":"<p>The page content is encapsulated in a new container that wraps around the inner content, but excludes the sidebars, header and page navigation elements.</p> <ul> <li><code>$wcfContentContainerBackground</code> - background color</li> <li><code>$wcfContentContainerBorder</code> - border color</li> </ul>"},{"location":"migration/wsc30/css/#wcfeditorbutton","title":"wcfEditorButton","text":"<p>These variables control the appearance of the editor toolbar and its buttons.</p> <ul> <li><code>$wcfEditorButtonBackground</code> - button and toolbar background color</li> <li><code>$wcfEditorButtonBackgroundActive</code> - active button background color</li> <li><code>$wcfEditorButtonText</code> - text color for available buttons</li> <li><code>$wcfEditorButtonTextActive</code> - text color for active buttons</li> <li><code>$wcfEditorButtonTextDisabled</code> - text color for disabled buttons</li> </ul>"},{"location":"migration/wsc30/css/#color-variables-in-alertscss","title":"Color Variables in <code>alert.scss</code>","text":"<p>The color values for <code><small class=\"innerError\"></code> used to be hardcoded values, but have now been changed to use the values for error messages (<code>wcfStatusError*</code>) instead.</p>"},{"location":"migration/wsc30/javascript/","title":"Migrating from WSC 3.0 - JavaScript","text":""},{"location":"migration/wsc30/javascript/#accelerated-guest-view-tiny-builds","title":"Accelerated Guest View / Tiny Builds","text":"<p>The new tiny builds are highly optimized variants of existing JavaScript files and modules, aiming for significant performance improvements for guests and search engines alike. This is accomplished by heavily restricting page interaction to read-only actions whenever possible, which in return removes the need to provide certain JavaScript modules in general.</p> <p>For example, disallowing guests to write any formatted messages will in return remove the need to provide the WYSIWYG editor at all. But it doesn't stop there, there are a lot of other modules that provide additional features for the editor, and by excluding the editor, we can also exclude these modules too.</p> <p>Long story short, the tiny mode guarantees that certain actions will never be carried out by guests or search engines, therefore some modules are not going to be needed by them ever.</p>"},{"location":"migration/wsc30/javascript/#code-templates-for-tiny-builds","title":"Code Templates for Tiny Builds","text":"<p>The following examples assume that you use the virtual constant <code>COMPILER_TARGET_DEFAULT</code> as a switch for the optimized code path. This is also the constant used by the official build scripts for JavaScript files.</p> <p>We recommend that you provide a mock implementation for existing code to ensure 3rd party compatibility. It is enough to provide a bare object or class that exposes the original properties using the same primitive data types. This is intended to provide a soft-fail for implementations that are not aware of the tiny mode yet, but is not required for classes that did not exist until now.</p>"},{"location":"migration/wsc30/javascript/#legacy-javascript","title":"Legacy JavaScript","text":"<pre><code>if (COMPILER_TARGET_DEFAULT) {\n WCF.Example.Foo = {\n makeSnafucated: function() {\n return \"Hello World\";\n }\n };\n\n WCF.Example.Bar = Class.extend({\n foobar: \"baz\",\n\n foo: function($bar) {\n return $bar + this.foobar;\n }\n });\n}\nelse {\n WCF.Example.Foo = {\n makeSnafucated: function() {}\n };\n\n WCF.Example.Bar = Class.extend({\n foobar: \"\",\n foo: function() {}\n });\n}\n</code></pre>"},{"location":"migration/wsc30/javascript/#requirejs-modules","title":"require.js Modules","text":"<pre><code>define([\"some\", \"fancy\", \"dependencies\"], function(Some, Fancy, Dependencies) {\n \"use strict\";\n\n if (!COMPILER_TARGET_DEFAULT) {\n var Fake = function() {};\n Fake.prototype = {\n init: function() {},\n makeSnafucated: function() {}\n };\n return Fake;\n }\n\n function MyAwesomeClass(niceArgument) { this.init(niceArgument); }\n MyAwesomeClass.prototype = {\n init: function(niceArgument) {\n if (niceArgument) {\n this.makeSnafucated();\n }\n },\n\n makeSnafucated: function() {\n console.log(\"Hello World\");\n }\n }\n\n return MyAwesomeClass;\n});\n</code></pre>"},{"location":"migration/wsc30/javascript/#including-tinified-builds-through-js","title":"Including tinified builds through <code>{js}</code>","text":"<p>The <code>{js}</code> template-plugin has been updated to include support for tiny builds controlled through the optional flag <code>hasTiny=true</code>:</p> <pre><code>{js application='wcf' file='WCF.Example' hasTiny=true}\n</code></pre> <p>This line generates a different output depending on the debug mode and the user login-state.</p>"},{"location":"migration/wsc30/javascript/#real-error-messages-for-ajax-responses","title":"Real Error Messages for AJAX Responses","text":"<p>The <code>errorMessage</code> property in the returned response object for failed AJAX requests contained an exception-specific but still highly generic error message. This issue has been around for quite a long time and countless of implementations are relying on this false behavior, eventually forcing us to leave the value unchanged.</p> <p>This problem is solved by adding the new property <code>realErrorMessage</code> that exposes the message exactly as it was provided and now matches the value that would be displayed to users in traditional forms.</p>"},{"location":"migration/wsc30/javascript/#example-code","title":"Example Code","text":"<pre><code>define(['Ajax'], function(Ajax) {\n return {\n // ...\n _ajaxFailure: function(responseData, responseText, xhr, requestData) {\n console.log(responseData.realErrorMessage);\n }\n // ...\n };\n});\n</code></pre>"},{"location":"migration/wsc30/javascript/#simplified-form-submit-in-dialogs","title":"Simplified Form Submit in Dialogs","text":"<p>Forms embedded in dialogs often do not contain the HTML <code><form></code>-element and instead rely on JavaScript click- and key-handlers to emulate a <code><form></code>-like submit behavior. This has spawned a great amount of nearly identical implementations that all aim to handle the form submit through the <code>Enter</code>-key, still leaving some dialogs behind.</p> <p>WoltLab Suite 3.1 offers automatic form submit that is enabled through a set of specific conditions and data attributes:</p> <ol> <li>There must be a submit button that matches the selector <code>.formSubmit > input[type=\"submit\"], .formSubmit > button[data-type=\"submit\"]</code>.</li> <li>The dialog object provided to <code>UiDialog.open()</code> implements the method <code>_dialogSubmit()</code>.</li> <li>Input fields require the attribute <code>data-dialog-submit-on-enter=\"true\"</code> to be set, the <code>type</code> must be one of <code>number</code>, <code>password</code>, <code>search</code>, <code>tel</code>, <code>text</code> or <code>url</code>.</li> </ol> <p>Clicking on the submit button or pressing the <code>Enter</code>-key in any watched input field will start the submit process. This is done automatically and does not require a manual interaction in your code, therefore you should not bind any click listeners on the submit button yourself.</p> <p>Any input field with the <code>required</code> attribute set will be validated to contain a non-empty string after processing the value with <code>String.prototype.trim()</code>. An empty field will abort the submit process and display a visible error message next to the offending field.</p>"},{"location":"migration/wsc30/javascript/#helper-function-for-inline-error-messages","title":"Helper Function for Inline Error Messages","text":"<p>Displaying inline error messages on-the-fly required quite a few DOM operations that were quite simple but also super repetitive and thus error-prone when incorrectly copied over. The global helper function <code>elInnerError()</code> was added to provide a simple and consistent behavior of inline error messages.</p> <p>You can display an error message by invoking <code>elInnerError(elementRef, \"Your Error Message\")</code>, it will insert a new <code><small class=\"innerError\"></code> and sets the given message. If there is already an inner error present, then the message will be replaced instead.</p> <p>Hiding messages is done by setting the 2nd parameter to <code>false</code> or an empty string:</p> <ul> <li><code>elInnerError(elementRef, false)</code></li> <li><code>elInnerError(elementRef, '')</code></li> </ul> <p>The special values <code>null</code> and <code>undefined</code> are supported too, but their usage is discouraged, because they make it harder to understand the intention by reading the code:</p> <ul> <li><code>elInnerError(elementRef, null)</code></li> <li><code>elInnerError(elementRef)</code></li> </ul>"},{"location":"migration/wsc30/javascript/#example-code_1","title":"Example Code","text":"<pre><code>require(['Language'], function(Language)) {\n var input = elBySel('input[type=\"text\"]');\n if (input.value.trim() === '') {\n // displays a new inline error or replaces the message if there is one already\n elInnerError(input, Language.get('wcf.global.form.error.empty'));\n }\n else {\n // removes the inline error if it exists\n elInnerError(input, false);\n }\n\n // the above condition is equivalent to this:\n elInnerError(input, (input.value.trim() === '' ? Language.get('wcf.global.form.error.empty') : false));\n}\n</code></pre>"},{"location":"migration/wsc30/package/","title":"Migrating from WSC 3.0 - Package Components","text":""},{"location":"migration/wsc30/package/#cronjob-scheduler-uses-server-timezone","title":"Cronjob Scheduler uses Server Timezone","text":"<p>The execution time of cronjobs was previously calculated based on the coordinated universal time (UTC). This was changed in WoltLab Suite 3.1 to use the server timezone or, to be precise, the default timezone set in the administration control panel.</p>"},{"location":"migration/wsc30/package/#exclude-pages-from-becoming-a-landing-page","title":"Exclude Pages from becoming a Landing Page","text":"<p>Some pages do not qualify as landing page, because they're designed around specific expectations that aren't matched in all cases. Examples include the user control panel and its sub-pages that cannot be accessed by guests and will therefore break the landing page for those. While it is somewhat to be expected from control panel pages, there are enough pages that fall under the same restrictions, but aren't easily recognized as such by an administrator.</p> <p>You can exclude these pages by adding <code><excludeFromLandingPage>1</excludeFromLandingPage></code> (case-sensitive) to the relevant pages in your <code>page.xml</code>.</p>"},{"location":"migration/wsc30/package/#example-code","title":"Example Code","text":"<pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/tornado/page.xsd\">\n <import>\n <page identifier=\"com.example.foo.Bar\">\n <!-- ... -->\n <excludeFromLandingPage>1</excludeFromLandingPage>\n <!-- ... -->\n </page>\n </import>\n</data>\n</code></pre>"},{"location":"migration/wsc30/package/#new-package-installation-plugin-for-media-providers","title":"New Package Installation Plugin for Media Providers","text":"<p>Please refer to the documentation of the <code>mediaProvider.xml</code> to learn more.</p>"},{"location":"migration/wsc30/package/#limited-forward-compatibility-for-plugins","title":"Limited Forward-Compatibility for Plugins","text":"<p>Please refer to the documentation of the <code><compatibility></code> tag in the <code>package.xml</code>.</p>"},{"location":"migration/wsc30/php/","title":"Migrating from WSC 3.0 - PHP","text":""},{"location":"migration/wsc30/php/#approval-system-for-comments","title":"Approval-System for Comments","text":"<p>Comments can now be set to require approval by a moderator before being published. This feature is disabled by default if you do not provide a permission in the manager class, enabling it requires a new permission that has to be provided in a special property of your manage implementation.</p> files/lib/system/comment/manager/ExampleCommentManager.class.php<pre><code><?php\nclass ExampleCommentManager extends AbstractCommentManager {\n protected $permissionAddWithoutModeration = 'foo.bar.example.canAddCommentWithoutModeration';\n}\n</code></pre>"},{"location":"migration/wsc30/php/#raw-html-in-user-activity-events","title":"Raw HTML in User Activity Events","text":"<p>User activity events were previously encapsulated inside <code><div class=\"htmlContent\">\u2026</div></code>, with impacts on native elements such as lists. You can now disable the class usage by defining your event as raw HTML:</p> files/lib/system/user/activity/event/ExampleUserActivityEvent.class.php<pre><code><?php\nclass ExampleUserActivityEvent {\n // enables raw HTML for output, defaults to `false`\n protected $isRawHtml = true;\n}\n</code></pre>"},{"location":"migration/wsc30/php/#permission-to-view-likes-of-an-object","title":"Permission to View Likes of an Object","text":"<p>Being able to view the like summary of an object was restricted to users that were able to like the object itself. This creates situations where the object type in general is likable, but the particular object cannot be liked by the current users, while also denying them to view the like summary (but it gets partly exposed through the footer note/summary!).</p> <p>Implement the interface <code>\\wcf\\data\\like\\IRestrictedLikeObjectTypeProvider</code> in your object provider to add support for this new permission check.</p> files/lib/data/example/LikeableExampleProvider.class.php<pre><code><?php\nclass LikeableExampleProvider extends ExampleProvider implements IRestrictedLikeObjectTypeProvider, IViewableLikeProvider {\n public function canViewLikes(ILikeObject $object) {\n // perform your permission checks here\n return true;\n }\n}\n</code></pre>"},{"location":"migration/wsc30/php/#developer-tools-sync-feature","title":"Developer Tools: Sync Feature","text":"<p>The synchronization feature of the newly added developer tools works by invoking a package installation plugin (PIP) outside of a regular installation, while simulating the basic environment that is already exposed by the API.</p> <p>However, not all PIPs qualify for this kind of execution, especially because it could be invoked multiple times in a row by the user. This is solved by requiring a special marking for PIPs that have no side-effects (= idempotent) when invoked any amount of times with the same arguments.</p> <p>There's another feature that allows all matching PIPs to be executed in a row using a single button click. In order to solve dependencies on other PIPs, any implementing PIP must also provide the method <code>getSyncDependencies()</code> that returns the dependent PIPs in an arbitrary order.</p> files/lib/data/package/plugin/ExamplePackageInstallationPlugin.class.php<pre><code><?php\nclass ExamplePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin implements IIdempotentPackageInstallationPlugin {\n public static function getSyncDependencies() {\n // provide a list of dependent PIPs in arbitrary order\n return [];\n }\n}\n</code></pre>"},{"location":"migration/wsc30/php/#media-providers","title":"Media Providers","text":"<p>Media providers were added through regular SQL queries in earlier versions, but this is neither convenient, nor did it offer a reliable method to update an existing provider. WoltLab Suite 3.1 adds a new <code>mediaProvider</code>-PIP that also offers a <code>className</code> parameter to off-load the result evaluation and HTML generation.</p>"},{"location":"migration/wsc30/php/#example-implementation","title":"Example Implementation","text":"mediaProvider.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/tornado/mediaProvider.xsd\">\n <import>\n <provider name=\"example\">\n <title>Example Provider</title>\n <regex>https?://example.com/watch?v=(?P<ID>[a-zA-Z0-9])</regex>\n <className>wcf\\system\\bbcode\\media\\provider\\ExampleBBCodeMediaProvider</className>\n </provider>\n </import>\n</data>\n</code></pre>"},{"location":"migration/wsc30/php/#php-callback","title":"PHP Callback","text":"<p>The full match is provided for <code>$url</code>, while any capture groups from the regular expression are assigned to <code>$matches</code>.</p> <pre><code><?php\nclass ExampleBBCodeMediaProvider implements IBBCodeMediaProvider {\n public function parse($url, array $matches = []) {\n return \"final HTML output\";\n }\n}\n</code></pre>"},{"location":"migration/wsc30/php/#re-evaluate-html-messages","title":"Re-Evaluate HTML Messages","text":"<p>You need to manually set the disallowed bbcodes in order to avoid unintentional bbcode evaluation. Please see this commit for a reference implementation inside worker processes.</p> <p>The HtmlInputProcessor only supported two ways to handle an existing HTML message:</p> <ol> <li>Load the string through <code>process()</code> and run it through the validation and sanitation process, both of them are rather expensive operations and do not qualify for rebuild data workers.</li> <li>Detect embedded content using <code>processEmbeddedContent()</code> which bypasses most tasks that are carried out by <code>process()</code> which aren't required, but does not allow a modification of the message.</li> </ol> <p>The newly added method <code>reprocess($message, $objectType, $objectID)</code> solves this short-coming by offering a full bbcode and text re-evaluation while bypassing any input filters, assuming that the input HTML was already filtered previously.</p>"},{"location":"migration/wsc30/php/#example-usage","title":"Example Usage","text":"<pre><code><?php\n// rebuild data workers tend to contain code similar to this:\nforeach ($this->objectList as $message) {\n // ...\n if (!$message->enableHtml) {\n // ...\n }\n else {\n // OLD:\n $this->getHtmlInputProcessor()->processEmbeddedContent($message->message, 'com.example.foo.message', $message->messageID);\n\n // REPLACE WITH:\n $this->getHtmlInputProcessor()->reprocess($message->message, 'com.example.foo.message', $message->messageID);\n $data['message'] = $this->getHtmlInputProcessor()->getHtml();\n }\n // ...\n}\n</code></pre>"},{"location":"migration/wsc30/templates/","title":"Migrating from WSC 3.0 - Templates","text":""},{"location":"migration/wsc30/templates/#comment-system-overhaul","title":"Comment-System Overhaul","text":"<p>Unfortunately, there has been a breaking change related to the creation of comments. You need to apply the changes below before being able to create new comments.</p>"},{"location":"migration/wsc30/templates/#adding-comments","title":"Adding Comments","text":"<p>Existing implementations need to include a new template right before including the generic <code>commentList</code> template.</p> <pre><code><ul id=\"exampleCommentList\" class=\"commentList containerList\" data-...>\n {include file='commentListAddComment' wysiwygSelector='exampleCommentListAddComment'}\n {include file='commentList'}\n</ul>\n</code></pre>"},{"location":"migration/wsc30/templates/#redesigned-acp-user-list","title":"Redesigned ACP User List","text":"<p>Custom interaction buttons were previously added through the template event <code>rowButtons</code> and were merely a link-like element with an icon inside. This is still valid and supported for backwards-compatibility, but it is recommend to adapt to the new drop-down-style options using the new template event <code>dropdownItems</code>.</p> <pre><code><!-- button for usage with the `rowButtons` event -->\n<span class=\"icon icon16 fa-list jsTooltip\" title=\"Button Title\"></span>\n\n<!-- new drop-down item for the `dropdownItems` event -->\n<li><a href=\"#\" class=\"jsMyButton\">Button Title</a></li>\n</code></pre>"},{"location":"migration/wsc30/templates/#sidebar-toogle-buttons-on-mobile-device","title":"Sidebar Toogle-Buttons on Mobile Device","text":"<p>You cannot override the button label for sidebars containing navigation menus.</p> <p>The page sidebars are automatically collapsed and presented as one or, when both sidebar are present, two condensed buttons. They use generic sidebar-related labels when open or closed, with the exception of embedded menus which will change the button label to read \"Show/Hide Navigation\".</p> <p>You can provide a custom label before including the sidebars by assigning the new labels to a few special variables:</p> <pre><code>{assign var='__sidebarLeftShow' value='Show Left Sidebar'}\n{assign var='__sidebarLeftHide' value='Hide Left Sidebar'}\n{assign var='__sidebarRightShow' value='Show Right Sidebar'}\n{assign var='__sidebarRightHide' value='Hide Right Sidebar'}\n</code></pre>"},{"location":"migration/wsc31/form-builder/","title":"Migrating from WSC 3.1 - Form Builder","text":""},{"location":"migration/wsc31/form-builder/#example-two-text-form-fields","title":"Example: Two Text Form Fields","text":"<p>As the first example, the pre-WoltLab Suite Core 5.2 versions of the forms to add and edit persons from the first part of the tutorial series will be updated to the new form builder API. This form is the perfect first examples as it is very simple with only two text fields whose only restriction is that they have to be filled out and that their values may not be longer than 255 characters each.</p> <p>As a reminder, here are the two relevant PHP files and the relevant template file:</p> files/lib/acp/form/PersonAddForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractForm;\nuse wcf\\system\\exception\\UserInputException;\nuse wcf\\system\\WCF;\nuse wcf\\util\\StringUtil;\n\n/**\n * Shows the form to create a new person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonAddForm extends AbstractForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.add';\n\n /**\n * first name of the person\n * @var string\n */\n public $firstName = '';\n\n /**\n * last name of the person\n * @var string\n */\n public $lastName = '';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'action' => 'add',\n 'firstName' => $this->firstName,\n 'lastName' => $this->lastName\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function readFormParameters() {\n parent::readFormParameters();\n\n if (isset($_POST['firstName'])) $this->firstName = StringUtil::trim($_POST['firstName']);\n if (isset($_POST['lastName'])) $this->lastName = StringUtil::trim($_POST['lastName']);\n }\n\n /**\n * @inheritDoc\n */\n public function save() {\n parent::save();\n\n $this->objectAction = new PersonAction([], 'create', [\n 'data' => array_merge($this->additionalFields, [\n 'firstName' => $this->firstName,\n 'lastName' => $this->lastName\n ])\n ]);\n $this->objectAction->executeAction();\n\n $this->saved();\n\n // reset values\n $this->firstName = '';\n $this->lastName = '';\n\n // show success message\n WCF::getTPL()->assign('success', true);\n }\n\n /**\n * @inheritDoc\n */\n public function validate() {\n parent::validate();\n\n // validate first name\n if (empty($this->firstName)) {\n throw new UserInputException('firstName');\n }\n if (mb_strlen($this->firstName) > 255) {\n throw new UserInputException('firstName', 'tooLong');\n }\n\n // validate last name\n if (empty($this->lastName)) {\n throw new UserInputException('lastName');\n }\n if (mb_strlen($this->lastName) > 255) {\n throw new UserInputException('lastName', 'tooLong');\n }\n }\n}\n</code></pre> files/lib/acp/form/PersonEditForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractForm;\nuse wcf\\system\\exception\\IllegalLinkException;\nuse wcf\\system\\WCF;\n\n/**\n * Shows the form to edit an existing person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonEditForm extends PersonAddForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person';\n\n /**\n * edited person object\n * @var Person\n */\n public $person = null;\n\n /**\n * id of the edited person\n * @var integer\n */\n public $personID = 0;\n\n /**\n * @inheritDoc\n */\n public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'action' => 'edit',\n 'person' => $this->person\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function readData() {\n parent::readData();\n\n if (empty($_POST)) {\n $this->firstName = $this->person->firstName;\n $this->lastName = $this->person->lastName;\n }\n }\n\n /**\n * @inheritDoc\n */\n public function readParameters() {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) $this->personID = intval($_REQUEST['id']);\n $this->person = new Person($this->personID);\n if (!$this->person->personID) {\n throw new IllegalLinkException();\n }\n }\n\n /**\n * @inheritDoc\n */\n public function save() {\n AbstractForm::save();\n\n $this->objectAction = new PersonAction([$this->person], 'update', [\n 'data' => array_merge($this->additionalFields, [\n 'firstName' => $this->firstName,\n 'lastName' => $this->lastName\n ])\n ]);\n $this->objectAction->executeAction();\n\n $this->saved();\n\n // show success message\n WCF::getTPL()->assign('success', true);\n }\n}\n</code></pre> acptemplates/personAdd.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.'|concat:$action}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.{$action}{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonList'}{/link}\" class=\"button\"><span class=\"icon icon16 fa-list\"></span> <span>{lang}wcf.acp.menu.link.person.list{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{include file='formError'}\n\n{if $success|isset}\n <p class=\"success\">{lang}wcf.global.success.{$action}{/lang}</p>\n{/if}\n\n<form method=\"post\" action=\"{if $action == 'add'}{link controller='PersonAdd'}{/link}{else}{link controller='PersonEdit' object=$person}{/link}{/if}\">\n <div class=\"section\">\n <dl{if $errorField == 'firstName'} class=\"formError\"{/if}>\n <dt><label for=\"firstName\">{lang}wcf.person.firstName{/lang}</label></dt>\n <dd>\n <input type=\"text\" id=\"firstName\" name=\"firstName\" value=\"{$firstName}\" required autofocus maxlength=\"255\" class=\"long\">\n {if $errorField == 'firstName'}\n <small class=\"innerError\">\n {if $errorType == 'empty'}\n {lang}wcf.global.form.error.empty{/lang}\n {else}\n {lang}wcf.acp.person.firstName.error.{$errorType}{/lang}\n {/if}\n </small>\n {/if}\n </dd>\n </dl>\n\n <dl{if $errorField == 'lastName'} class=\"formError\"{/if}>\n <dt><label for=\"lastName\">{lang}wcf.person.lastName{/lang}</label></dt>\n <dd>\n <input type=\"text\" id=\"lastName\" name=\"lastName\" value=\"{$lastName}\" required maxlength=\"255\" class=\"long\">\n {if $errorField == 'lastName'}\n <small class=\"innerError\">\n {if $errorType == 'empty'}\n {lang}wcf.global.form.error.empty{/lang}\n {else}\n {lang}wcf.acp.person.lastName.error.{$errorType}{/lang}\n {/if}\n </small>\n {/if}\n </dd>\n </dl>\n\n {event name='dataFields'}\n </div>\n\n {event name='sections'}\n\n <div class=\"formSubmit\">\n <input type=\"submit\" value=\"{lang}wcf.global.button.submit{/lang}\" accesskey=\"s\">\n {@SECURITY_TOKEN_INPUT_TAG}\n </div>\n</form>\n\n{include file='footer'}\n</code></pre> <p>Updating the template is easy as the complete form is replace by a single line of code:</p> acptemplates/personAdd.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.'|concat:$action}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.{$action}{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonList'}{/link}\" class=\"button\"><span class=\"icon icon16 fa-list\"></span> <span>{lang}wcf.acp.menu.link.person.list{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{@$form->getHtml()}\n\n{include file='footer'}\n</code></pre> <p><code>PersonEditForm</code> also becomes much simpler: only the edited <code>Person</code> object must be read:</p> files/lib/acp/form/PersonEditForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\exception\\IllegalLinkException;\n\n/**\n * Shows the form to edit an existing person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonEditForm extends PersonAddForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person';\n\n /**\n * @inheritDoc\n */\n public function readParameters() {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) {\n $this->formObject = new Person(intval($_REQUEST['id']));\n if (!$this->formObject->personID) {\n throw new IllegalLinkException();\n }\n }\n }\n}\n</code></pre> <p>Most of the work is done in <code>PersonAddForm</code>:</p> files/lib/acp/form/PersonAddForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\container\\FormContainer;\nuse wcf\\system\\form\\builder\\field\\TextFormField;\n\n/**\n * Shows the form to create a new person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonAddForm extends AbstractFormBuilderForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.add';\n\n /**\n * @inheritDoc\n */\n public $formAction = 'create';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public $objectActionClass = PersonAction::class;\n\n /**\n * @inheritDoc\n */\n protected function createForm() {\n parent::createForm();\n\n $dataContainer = FormContainer::create('data')\n ->appendChildren([\n TextFormField::create('firstName')\n ->label('wcf.person.firstName')\n ->required()\n ->maximumLength(255),\n\n TextFormField::create('lastName')\n ->label('wcf.person.lastName')\n ->required()\n ->maximumLength(255)\n ]);\n\n $this->form->appendChild($dataContainer);\n }\n}\n</code></pre> <p>But, as you can see, the number of lines almost decreased by half. All changes are due to extending <code>AbstractFormBuilderForm</code>:</p> <ul> <li><code>$formAction</code> is added and set to <code>create</code> as the form is used to create a new person. In the edit form, <code>$formAction</code> has not to be set explicitly as it is done automatically if a <code>$formObject</code> is set.</li> <li><code>$objectActionClass</code> is set to <code>PersonAction::class</code> and is the class name of the used <code>AbstractForm::$objectAction</code> object to create and update the <code>Person</code> object.</li> <li><code>AbstractFormBuilderForm::createForm()</code> is overridden and the form contents are added: a form container representing the <code>div.section</code> element from the old version and the two form fields with the same ids and labels as before. The contents of the old <code>validate()</code> method is put into two method calls: <code>required()</code> to ensure that the form is filled out and <code>maximumLength(255)</code> to ensure that the names are not longer than 255 characters.</li> </ul>"},{"location":"migration/wsc31/like/","title":"Migrating from WSC 3.1 - Like System","text":""},{"location":"migration/wsc31/like/#introduction","title":"Introduction","text":"<p>With version 5.2 of WoltLab Suite Core the like system was completely replaced by the new reactions system. This makes it necessary to make some adjustments to existing code so that your plugin integrates completely into the new system. However, we have kept these adjustments as small as possible so that it is possible to use the reaction system with slight restrictions even without adjustments. </p>"},{"location":"migration/wsc31/like/#limitations-if-no-adjustments-are-made-to-the-existing-code","title":"Limitations if no adjustments are made to the existing code","text":"<p>If no adjustments are made to the existing code, the following functions are not available: * Notifications about reactions/likes * Recent Activity Events for reactions/likes</p>"},{"location":"migration/wsc31/like/#migration","title":"Migration","text":""},{"location":"migration/wsc31/like/#notifications","title":"Notifications","text":""},{"location":"migration/wsc31/like/#mark-notification-as-compatible","title":"Mark notification as compatible","text":"<p>Since there are no more likes with the new version, it makes no sense to send notifications about it. Instead of notifications about likes, notifications about reactions are now sent. However, this only changes the notification text and not the notification itself. To update the notification, we first add the interface <code>\\wcf\\data\\reaction\\object\\IReactionObject</code> to the <code>\\wcf\\data\\like\\object\\ILikeObject</code> object (e.g. in WoltLab Suite Forum we added the interface to the class <code>\\wbb\\data\\post\\LikeablePost</code>). After that the object is marked as \"compatible with WoltLab Suite Core 5.2\" and notifications about reactions are sent again. </p>"},{"location":"migration/wsc31/like/#language-variables","title":"Language Variables","text":"<p>Next, to display all reactions for the current notification in the notification text, we include the trait <code>\\wcf\\system\\user\\notification\\event\\TReactionUserNotificationEvent</code> in the user notification event class (typically named like <code>*LikeUserNotificationEvent</code>). These trait provides a new function that reads out and groups the reactions. The result of this function must now only be passed to the language variable. The name \"reactions\" is typically used as the variable name for the language variable. </p> <p>As a final step, we only need to change the language variables themselves. To ensure a consistent usability, the same formulations should be used as in the WoltLab Suite Core. </p>"},{"location":"migration/wsc31/like/#english","title":"English","text":"<p><code>{prefix}.like.title</code> <pre><code>Reaction to a {objectName}\n</code></pre></p> <p><code>{prefix}.like.title.stacked</code></p> <pre><code>{#$count} users reacted to your {objectName}\n</code></pre> <p><code>{prefix}.like.message</code> <pre><code>{@$author->getAnchorTag()} reacted to your {objectName} ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre></p> <p><code>{prefix}.like.message.stacked</code></p> <pre><code>{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} others{/if} reacted to your {objectName} ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre> <p><code>wcf.user.notification.{objectTypeName}.like.notification.like</code> <pre><code>Notify me when someone reacted to my {objectName}\n</code></pre></p>"},{"location":"migration/wsc31/like/#german","title":"German","text":"<p><code>{prefix}.like.title</code> <pre><code>Reaktion auf einen {objectName}\n</code></pre></p> <p><code>{prefix}.like.title.stacked</code></p> <pre><code>{#$count} Benutzern haben auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert\n</code></pre> <p><code>{prefix}.like.message</code> <pre><code>{@$author->getAnchorTag()} hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre></p> <p><code>{prefix}.like.message.stacked</code></p> <pre><code>{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere{/if} haben auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre> <p><code>wcf.user.notification.{object_type_name}.like.notification.like</code> <pre><code>Jemandem hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert\n</code></pre></p>"},{"location":"migration/wsc31/like/#recent-activity","title":"Recent Activity","text":"<p>To adjust entries in the Recent Activity, only three small steps are necessary. First we pass the concrete reaction to the language variable, so that we can use the reaction object there. To do this, we add the following variable to the text of the <code>\\wcf\\system\\user\\activity\\event\\IUserActivityEvent</code> object: <code>$event->reactionType</code>. Typically we name the variable <code>reactionType</code>. In the second step, we mark the event as compatible. Therefore we set the parameter <code>supportsReactions</code> in the <code>objectType.xml</code> to <code>1</code>. So for example the entry looks like this:</p> objectType.xml<pre><code><type>\n <name>com.woltlab.example.likeableObject.recentActivityEvent</name>\n <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>\n <classname>wcf\\system\\user\\activity\\event\\LikeableObjectUserActivityEvent</classname>\n <supportsReactions>1</supportsReactions>\n</type>\n</code></pre> <p>Finally we modify our language variable. To ensure a consistent usability, the same formulations should be used as in the WoltLab Suite Core.</p>"},{"location":"migration/wsc31/like/#english_1","title":"English","text":"<p><code>wcf.user.recentActivity.{object_type_name}.recentActivityEvent</code> <pre><code>Reaction ({objectName})\n</code></pre></p> <p>Your language variable for the recent activity text <pre><code>Reacted with <span title=\"{$reactionType->getTitle()}\" class=\"jsTooltip\">{@$reactionType->renderIcon()}</span> to the {objectName}.\n</code></pre></p>"},{"location":"migration/wsc31/like/#german_1","title":"German","text":"<p><code>wcf.user.recentActivity.{objectTypeName}.recentActivityEvent</code> <pre><code>Reaktion ({objectName})\n</code></pre></p> <p>Your language variable for the recent activity text <pre><code>Hat mit <span title=\"{$reactionType->getTitle()}\" class=\"jsTooltip\">{@$reactionType->renderIcon()}</span> auf {objectName} reagiert.\n</code></pre></p>"},{"location":"migration/wsc31/like/#comments","title":"Comments","text":"<p>If comments send notifications, they must also be updated. The language variables are changed in the same way as described in the section Notifications / Language. After that comment must be marked as compatible. Therefore we set the parameter <code>supportsReactions</code> in the <code>objectType.xml</code> to <code>1</code>. So for example the entry looks like this: </p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.objectComment.response.like.notification</name>\n <definitionname>com.woltlab.wcf.notification.objectType</definitionname>\n <classname>wcf\\system\\user\\notification\\object\\type\\LikeUserNotificationObjectType</classname>\n <category>com.woltlab.example</category>\n <supportsReactions>1</supportsReactions>\n</type>\n</code></pre>"},{"location":"migration/wsc31/like/#forward-compatibility","title":"Forward Compatibility","text":"<p>So that these changes also work in older versions of WoltLab Suite Core, the used classes and traits were backported with WoltLab Suite Core 3.0.22 and WoltLab Suite Core 3.1.10.</p>"},{"location":"migration/wsc31/php/","title":"Migrating from WSC 3.1 - PHP","text":""},{"location":"migration/wsc31/php/#form-builder","title":"Form Builder","text":"<p>WoltLab Suite Core 5.2 introduces a new, simpler and quicker way of creating forms: form builder. You can find examples of how to migrate existing forms to form builder here.</p> <p>In the near future, to ensure backwards compatibility within WoltLab packages, we will only use form builder for new forms or for major rewrites of existing forms that would break backwards compatibility anyway.</p>"},{"location":"migration/wsc31/php/#like-system","title":"Like System","text":"<p>WoltLab Suite Core 5.2 replaced the like system with the reaction system. You can find the migration guide here.</p>"},{"location":"migration/wsc31/php/#user-content-providers","title":"User Content Providers","text":"<p>User content providers help the WoltLab Suite to find user generated content. They provide a class with which you can find content from a particular user and delete objects.</p>"},{"location":"migration/wsc31/php/#php-class","title":"PHP Class","text":"<p>First, we create the PHP class that provides our interface to provide the data. The class must implement interface <code>wcf\\system\\user\\content\\provider\\IUserContentProvider</code> in any case. Mostly we process data which is based on <code>wcf\\data\\DatabaseObject</code>. In this case, the WoltLab Suite provides an abstract class <code>wcf\\system\\user\\content\\provider\\AbstractDatabaseUserContentProvider</code> that can be used to automatically generates the standardized classes to generate the list and deletes objects via the DatabaseObjectAction. For example, if we would create a content provider for comments, the class would look like this: </p> files/lib/system/user/content/provider/CommentUserContentProvider.class.php<pre><code><?php\nnamespace wcf\\system\\user\\content\\provider;\nuse wcf\\data\\comment\\Comment;\n\n/**\n * User content provider for comments.\n *\n * @author Joshua Ruesweg\n * @copyright 2001-2018 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\User\\Content\\Provider\n * @since 5.2\n */\nclass CommentUserContentProvider extends AbstractDatabaseUserContentProvider {\n /**\n * @inheritdoc\n */\n public static function getDatabaseObjectClass() {\n return Comment::class;\n }\n}\n</code></pre>"},{"location":"migration/wsc31/php/#object-type","title":"Object Type","text":"<p>Now the appropriate object type must be created for the class. This object type must be from the definition <code>com.woltlab.wcf.content.userContentProvider</code> and include the previous created class as FQN in the parameter <code>classname</code>. Also the following parameters can be used in the object type: </p>"},{"location":"migration/wsc31/php/#nicevalue","title":"<code>nicevalue</code>","text":"<p>Optional</p> <p>The nice value is used to determine the order in which the remove content worker are execute the provider. Content provider with lower nice values are executed first.</p>"},{"location":"migration/wsc31/php/#hidden","title":"<code>hidden</code>","text":"<p>Optional</p> <p>Specifies whether or not this content provider can be actively selected in the Content Remove Worker. If it cannot be selected, it will not be executed automatically! </p>"},{"location":"migration/wsc31/php/#requiredobjecttype","title":"<code>requiredobjecttype</code>","text":"<p>Optional</p> <p>The specified list of comma-separated object types are automatically removed during content removal when this object type is being removed. Attention: The order of removal is undefined by default, specify a <code>nicevalue</code> if the order is important.</p>"},{"location":"migration/wsc31/php/#php-database-api","title":"PHP Database API","text":"<p>WoltLab Suite 5.2 introduces a new way to update the database scheme: database PHP API.</p>"},{"location":"migration/wsc52/libraries/","title":"Migrating from WoltLab Suite 5.2 - Third Party Libraries","text":""},{"location":"migration/wsc52/libraries/#scss-compiler","title":"SCSS Compiler","text":"<p>WoltLab Suite Core 5.3 upgrades the bundled SCSS compiler from <code>leafo/scssphp</code> 0.7.x to <code>scssphp/scssphp</code> 1.1.x. With the updated composer package name the SCSS compiler also received updated namespaces. WoltLab Suite Core adds a compatibility layer that maps the old namespace to the new namespace. The classes themselves appear to be drop-in compatible. Exceptions cannot be mapped using this compatibility layer, any <code>catch</code> blocks catching a specific Exception within the <code>Leafo</code> namespace will need to be adjusted.</p> <p>More details can be found in the Pull Request WoltLab/WCF#3415.</p>"},{"location":"migration/wsc52/libraries/#guzzle","title":"Guzzle","text":"<p>WoltLab Suite Core 5.3 ships with a bundled version of Guzzle 6. Going forward using Guzzle is the recommended way to perform HTTP requests. The <code>\\wcf\\util\\HTTPRequest</code> class should no longer be used and transparently uses Guzzle under the hood.</p> <p>Use <code>\\wcf\\system\\io\\HttpFactory</code> to retrieve a correctly configured <code>GuzzleHttp\\ClientInterface</code>.</p> <p>Please note that it is recommended to explicitely specify a <code>sink</code> when making requests, due to a PHP / Guzzle bug. Have a look at the implementation in WoltLab/WCF for an example.</p>"},{"location":"migration/wsc52/php/","title":"Migrating from WoltLab Suite 5.2 - PHP","text":""},{"location":"migration/wsc52/php/#comments","title":"Comments","text":"<p>The <code>ICommentManager::isContentAuthor(Comment|CommentResponse): bool</code> method was added. A default implementation that always returns <code>false</code> is available when inheriting from <code>AbstractCommentManager</code>.</p> <p>It is strongly recommended to implement <code>isContentAuthor</code> within your custom comment manager. An example implementation can be found in <code>ArticleCommentManager</code>.</p>"},{"location":"migration/wsc52/php/#event-listeners","title":"Event Listeners","text":"<p>The <code>AbstractEventListener</code> class was added. <code>AbstractEventListener</code> contains an implementation of <code>execute()</code> that will dispatch the event handling to dedicated methods based on the <code>$eventName</code> and, in case of the event object being an <code>AbstractDatabaseObjectAction</code>, the action name.</p> <p>Find the details of the dispatch behavior within the class comment of <code>AbstractEventListener</code>.</p>"},{"location":"migration/wsc52/php/#email-activation","title":"Email Activation","text":"<p>Starting with WoltLab Suite 5.3 the user activation status is independent of the email activation status. A user can be activated even though their email address has not been confirmed, preventing emails being sent to these users. Going forward the new <code>User::isEmailConfirmed()</code> method should be used to check whether sending automated emails to this user is acceptable. If you need to check the user's activation status you should use the new method <code>User::pendingActivation()</code> instead of relying on <code>activationCode</code>. To check, which type of activation is missing, you can use the new methods <code>User::requiresEmailActivation()</code> and <code>User::requiresAdminActivation()</code>.</p>"},{"location":"migration/wsc52/php/#addform","title":"<code>*AddForm</code>","text":"<p>WoltLab Suite 5.3 provides a new framework to allow the administrator to easily edit newly created objects by adding an edit link to the success message. To support this edit link two small changes are required within your <code>*AddForm</code>.</p> <ol> <li> <p>Update the template.</p> <p>Replace: <pre><code>{include file='formError'}\n\n{if $success|isset}\n <p class=\"success\">{lang}wcf.global.success.{$action}{/lang}</p>\n{/if}\n</code></pre></p> <p>With: <pre><code>{include file='formNotice'}\n</code></pre></p> </li> <li> <p>Expose <code>objectEditLink</code> to the template.</p> <p>Example (<code>$object</code> being the newly created object): <pre><code>WCF::getTPL()->assign([\n 'success' => true,\n 'objectEditLink' => LinkHandler::getInstance()->getControllerLink(ObjectEditForm::class, ['id' => $object->objectID]),\n]);\n</code></pre></p> </li> </ol>"},{"location":"migration/wsc52/php/#user-generated-links","title":"User Generated Links","text":"<p>It is recommended by search engines to mark up links within user generated content using the <code>rel=\"ugc\"</code> attribute to indicate that they might be less trustworthy or spammy.</p> <p>WoltLab Suite 5.3 will automatically sets that attribute on external links during message output processing. Set the new <code>HtmlOutputProcessor::$enableUgc</code> property to <code>false</code> if the type of message is not user-generated content, but restricted to a set of trustworthy users. An example of such a type of message would be official news articles.</p> <p>If you manually generate links based off user input you need to specify the attribute yourself. The <code>$isUgc</code> attribute was added to <code>StringUtil::getAnchorTag(string, string, bool, bool): string</code>, allowing you to easily generate a correct anchor tag.</p> <p>If you need to specify additional HTML attributes for the anchor tag you can use the new <code>StringUtil::getAnchorTagAttributes(string, bool): string</code> method to generate the anchor attributes that are dependent on the target URL. Specifically the attributes returned are the <code>class=\"externalURL\"</code> attribute, the <code>rel=\"\u2026\"</code> attribute and the <code>target=\"\u2026\"</code> attribute.</p> <p>Within the template the <code>{anchorAttributes}</code> template plugin is newly available.</p>"},{"location":"migration/wsc52/php/#resource-management-when-scaling-images","title":"Resource Management When Scaling Images","text":"<p>It was discovered that the code holds references to scaled image resources for an unnecessarily long time, taking up memory. This becomes especially apparent when multiple images are scaled within a loop, reusing the same variable name for consecutive images. Unless the destination variable is explicitely cleared before processing the next image up to two images will be stored in memory concurrently. This possibly causes the request to exceed the memory limit or ImageMagick's internal resource limits, even if sufficient resources would have been available to scale the current image.</p> <p>Starting with WoltLab Suite 5.3 it is recommended to clear image handles as early as possible. The usual pattern of creating a thumbnail for an existing image would then look like this:</p> <pre><code><?php\nforeach ([ 200, 500 ] as $size) {\n $adapter = ImageHandler::getInstance()->getAdapter();\n $adapter->loadFile($src);\n $thumbnail = $adapter->createThumbnail(\n $size,\n $size,\n true\n );\n $adapter->writeImage($thumbnail, $destination);\n // New: Clear thumbnail as soon as possible to free up the memory.\n $thumbnail = null;\n}\n</code></pre> <p>Refer to WoltLab/WCF#3505 for additional details.</p>"},{"location":"migration/wsc52/php/#toggle-for-accelerated-mobile-pages-amp","title":"Toggle for Accelerated Mobile Pages (AMP)","text":"<p>Controllers delivering AMP versions of pages have to check for the new option <code>MODULE_AMP</code> and the templates of the non-AMP versions have to also check if the option is enabled before outputting the <code><link rel=\"amphtml\" /></code> element.</p>"},{"location":"migration/wsc52/templates/","title":"Migrating WoltLab Suite 5.2 - Templates and Languages","text":""},{"location":"migration/wsc52/templates/#jslang","title":"<code>{jslang}</code>","text":"<p>Starting with WoltLab Suite 5.3 the <code>{jslang}</code> template plugin is available. <code>{jslang}</code> works like <code>{lang}</code>, with the difference that the result is automatically encoded for use within a single quoted JavaScript string.</p> <p>Before:</p> <pre><code><script>\nrequire(['Language', /* \u2026 */], function(Language, /* \u2026 */) {\n Language.addObject({\n 'app.foo.bar': '{lang}app.foo.bar{/lang}',\n });\n\n // \u2026\n});\n</script>\n</code></pre> <p>After:</p> <pre><code><script>\nrequire(['Language', /* \u2026 */], function(Language, /* \u2026 */) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}',\n });\n\n // \u2026\n});\n</script>\n</code></pre>"},{"location":"migration/wsc52/templates/#template-plugins","title":"Template Plugins","text":"<p>The <code>{anchor}</code>, <code>{plural}</code>, and <code>{user}</code> template plugins have been added.</p>"},{"location":"migration/wsc52/templates/#notification-language-items","title":"Notification Language Items","text":"<p>In addition to using the new template plugins mentioned above, language items for notifications have been further simplified.</p> <p>As the whole notification is clickable now, all <code>a</code> elements have been replaced with <code>strong</code> elements in notification messages.</p> <p>The template code to output reactions has been simplified by introducing helper methods:</p> <pre><code>{* old *}\n{implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}\n{* new *}\n{@$__wcf->getReactionHandler()->renderInlineList($reactions)}\n\n{* old *}\n<span title=\"{$like->getReactionType()->getTitle()}\" class=\"jsTooltip\">{@$like->getReactionType()->renderIcon()}</span>\n{* new *}\n{@$like->render()}\n</code></pre> <p>Similarly, showing labels is now also easier due to the new <code>render</code> method:</p> <pre><code>{* old *}\n<span class=\"label badge{if $label->getClassNames()} {$label->getClassNames()}{/if}\">{$label->getTitle()}</span>\n{* new *}\n{@$label->render()}\n</code></pre> <p>The commonly used template code</p> <pre><code>{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count != 1}{if $count == 2 && !$guestTimesTriggered} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3}{if !$guestTimesTriggered} and {else}, {/if} {@$authors[2]->getAnchorTag()}{/if}{/if}{if $guestTimesTriggered} and {if $guestTimesTriggered == 1}a guest{else}guests{/if}{/if}{else}{@$authors[0]->getAnchorTag()}{if $guestTimesTriggered},{else} and{/if} {#$others} other users {if $guestTimesTriggered}and {if $guestTimesTriggered == 1}a guest{else}guests{/if}{/if}{/if}\n</code></pre> <p>in stacked notification messages can be replaced with a new language item:</p> <pre><code>{@'wcf.user.notification.stacked.authorList'|language}\n</code></pre>"},{"location":"migration/wsc52/templates/#popovers","title":"Popovers","text":"<p>Popovers provide additional information of the linked object when a user hovers over a link. We unified the approach for such links:</p> <ol> <li>The relevant DBO class implements <code>wcf\\data\\IPopoverObject</code>.</li> <li>The relevant DBO action class implements <code>wcf\\data\\IPopoverAction</code> and the <code>getPopover()</code> method returns an array with popover content.</li> <li>Globally available, <code>WoltLabSuite/Core/Controller/Popover</code> is initialized with the relevant data.</li> <li>Links are created with the <code>anchor</code> template plugin with an additional <code>class</code> attribute whose value is the return value of <code>IPopoverObject::getPopoverLinkClass()</code>.</li> </ol> <p>Example:</p> files/lib/data/foo/Foo.class.php<pre><code>class Foo extends DatabaseObject implements IPopoverObject {\n public function getPopoverLinkClass() {\n return 'fooLink';\n }\n}\n</code></pre> files/lib/data/foo/FooAction.class.php<pre><code>class FooAction extends AbstractDatabaseObjectAction implements IPopoverAction {\n public function validateGetPopover() {\n // \u2026\n }\n\n public function getPopover() {\n return [\n 'template' => '\u2026',\n ];\n }\n}\n</code></pre> <pre><code>require(['WoltLabSuite/Core/Controller/Popover'], function(ControllerPopover) {\n ControllerPopover.init({\n className: 'fooLink',\n dboAction: 'wcf\\\\data\\\\foo\\\\FooAction',\n identifier: 'com.woltlab.wcf.foo'\n });\n});\n</code></pre> <pre><code>{anchor object=$foo class='fooLink'}\n</code></pre>"},{"location":"migration/wsc53/javascript/","title":"Migrating from WoltLab Suite 5.3 - TypeScript and JavaScript","text":""},{"location":"migration/wsc53/javascript/#typescript","title":"TypeScript","text":"<p>WoltLab Suite 5.4 introduces TypeScript support. Learn about consuming WoltLab Suite\u2019s types in the TypeScript section of the JavaScript API documentation.</p> <p>The JavaScript API documentation will be updated to properly take into account the changes that came with the new TypeScript support in the future. Existing AMD based modules have been migrated to TypeScript, but will expose the existing and known API.</p> <p>It is recommended that you migrate your custom packages to make use of TypeScript. It will make consuming newly written modules that properly leverage TypeScript\u2019s features much more pleasant and will also ease using existing modules due to proper autocompletion and type checking.</p>"},{"location":"migration/wsc53/javascript/#replacements-for-deprecated-components","title":"Replacements for Deprecated Components","text":"<p>The helper functions in <code>wcf.globalHelper.js</code> should not be used anymore but replaced by their native counterpart:</p> Function Native Replacement <code>elCreate(tag)</code> <code>document.createElement(tag)</code> <code>elRemove(el)</code> <code>el.remove()</code> <code>elShow(el)</code> <code>DomUtil.show(el)</code> <code>elHide(el)</code> <code>DomUtil.hide(el)</code> <code>elIsHidden(el)</code> <code>DomUtil.isHidden(el)</code> <code>elToggle(el)</code> <code>DomUtil.toggle(el)</code> <code>elAttr(el, \"attr\")</code> <code>el.attr</code> or <code>el.getAttribute(\"attr\")</code> <code>elData(el, \"data\")</code> <code>el.dataset.data</code> <code>elDataBool(element, \"data\")</code> <code>Core.stringToBool(el.dataset.data)</code> <code>elById(id)</code> <code>document.getElementById(id)</code> <code>elBySel(sel)</code> <code>document.querySelector(sel)</code> <code>elBySel(sel, el)</code> <code>el.querySelector(sel)</code> <code>elBySelAll(sel)</code> <code>document.querySelectorAll(sel)</code> <code>elBySelAll(sel, el)</code> <code>el.querySelectorAll(sel)</code> <code>elBySelAll(sel, el, callback)</code> <code>el.querySelectorAll(sel).forEach((el) => callback(el));</code> <code>elClosest(el, sel)</code> <code>el.closest(sel)</code> <code>elByClass(class)</code> <code>document.getElementsByClassName(class)</code> <code>elByClass(class, el)</code> <code>el.getElementsByClassName(class)</code> <code>elByTag(tag)</code> <code>document.getElementsByTagName(tag)</code> <code>elByTag(tag, el)</code> <code>el.getElementsByTagName(tag)</code> <code>elInnerError(el, message, isHtml)</code> <code>DomUtil.innerError(el, message, isHtml)</code> <p>Additionally, the following modules should also be replaced by their native counterpart:</p> Module Native Replacement <code>WoltLabSuite/Core/Dictionary</code> <code>Map</code> <code>WoltLabSuite/Core/List</code> <code>Set</code> <code>WoltLabSuite/Core/ObjectMap</code> <code>WeakMap</code> <p>For event listeners on click events, <code>WCF_CLICK_EVENT</code> is deprecated and should no longer be used. Instead, use <code>click</code> directly:</p> <pre><code>// before\nelement.addEventListener(WCF_CLICK_EVENT, this._click.bind(this));\n\n// after\nelement.addEventListener('click', (ev) => this._click(ev));\n</code></pre>"},{"location":"migration/wsc53/javascript/#wcfactiondelete-and-wcfactiontoggle","title":"<code>WCF.Action.Delete</code> and <code>WCF.Action.Toggle</code>","text":"<p><code>WCF.Action.Delete</code> and <code>WCF.Action.Toggle</code> were used for buttons to delete or enable/disable objects via JavaScript. In each template, <code>WCF.Action.Delete</code> or <code>WCF.Action.Toggle</code> instances had to be manually created for each object listing.</p> <p>With version 5.4 of WoltLab Suite, we have added a CSS selector-based global TypeScript module that only requires specific CSS classes to be added to the HTML structure for these buttons to work. Additionally, we have added a new <code>{objectAction}</code> template plugin, which generates these buttons reducing the amount of boilerplate template code.</p> <p>The required base HTML structure is as follows:</p> <ol> <li>A <code>.jsObjectActionContainer</code> element with a <code>data-object-action-class-name</code> attribute that contains the name of PHP class that executes the actions.</li> <li><code>.jsObjectActionObject</code> elements within <code>.jsObjectActionContainer</code> that represent the objects for which actions can be executed. Each <code>.jsObjectActionObject</code> element must have a <code>data-object-id</code> attribute with the id of the object.</li> <li><code>.jsObjectAction</code> elements within <code>.jsObjectActionObject</code> for each action with a <code>data-object-action</code> attribute with the name of the action. These elements can be generated with the <code>{objectAction}</code> template plugin for the <code>delete</code> and <code>toggle</code> action.</li> </ol> <p>Example:</p> <pre><code><table class=\"table jsObjectActionContainer\" {*\n *}data-object-action-class-name=\"wcf\\data\\foo\\FooAction\">\n <thead>\n <tr>\n {* \u2026 *}\n </tr>\n </thead>\n\n <tbody>\n {foreach from=$objects item=foo}\n <tr class=\"jsObjectActionObject\" data-object-id=\"{$foo->getObjectID()}\">\n <td class=\"columnIcon\">\n {objectAction action=\"toggle\" isDisabled=$foo->isDisabled}\n {objectAction action=\"delete\" objectTitle=$foo->getTitle()}\n {* \u2026 *}\n </td>\n {* \u2026 *}\n </tr>\n {/foreach}\n </tbody>\n</table>\n</code></pre> <p>Please refer to the documentation in <code>ObjectActionFunctionTemplatePlugin</code> for details and examples on how to use this template plugin.</p> <p>The relevant TypeScript module registering the event listeners on the object action buttons is <code>Ui/Object/Action</code>. When an action button is clicked, an AJAX request is sent using the PHP class name and action name. After the successful execution of the action, the page is either reloaded if the action button has a <code>data-object-action-success=\"reload\"</code> attribute or an event using the <code>EventHandler</code> module is fired using <code>WoltLabSuite/Core/Ui/Object/Action</code> as the identifier and the object action name. <code>Ui/Object/Action/Delete</code> and <code>Ui/Object/Action/Toggle</code> listen to these events and update the user interface depending on the execute action by removing the object or updating the toggle button, respectively.</p> <p>Converting from <code>WCF.Action.*</code> to the new approach requires minimal changes per template, as shown in the relevant pull request #4080.</p>"},{"location":"migration/wsc53/javascript/#wcftableemptytablehandler","title":"<code>WCF.Table.EmptyTableHandler</code>","text":"<p>When all objects in a table or list are deleted via their delete button or clipboard actions, an empty table or list can remain. Previously, <code>WCF.Table.EmptyTableHandler</code> had to be explicitly used in each template for these tables and lists to reload the page. As a TypeScript-based replacement for <code>WCF.Table.EmptyTableHandler</code> that is only initialized once globally, <code>WoltLabSuite/Core/Ui/Empty</code> was added. To use this new module, you only have to add the CSS class <code>jsReloadPageWhenEmpty</code> to the relevant HTML element. Once this HTML element no longer has child elements, the page is reloaded. To also cover scenarios in which there are fixed child elements that should not be considered when determining if there are no child elements, the <code>data-reload-page-when-empty=\"ignore\"</code> can be set for these elements.</p> <p>Examples:</p> <pre><code><table class=\"table\">\n <thead>\n <tr>\n {* \u2026 *}\n </tr>\n </thead>\n\n <tbody class=\"jsReloadPageWhenEmpty\">\n {foreach from=$objects item=object}\n <tr>\n {* \u2026 *}\n </tr>\n {/foreach}\n </tbody>\n</table>\n</code></pre> <pre><code><div class=\"section tabularBox messageGroupList\">\n <ol class=\"tabularList jsReloadPageWhenEmpty\">\n <li class=\"tabularListRow tabularListRowHead\" data-reload-page-when-empty=\"ignore\">\n {* \u2026 *}\n </li>\n\n {foreach from=$objects item=object}\n <li>\n {* \u2026 *}\n </li>\n {/foreach}\n </ol>\n</div>\n</code></pre>"},{"location":"migration/wsc53/libraries/","title":"Migrating from WoltLab Suite 5.3 - Third Party Libraries","text":""},{"location":"migration/wsc53/libraries/#guzzle","title":"Guzzle","text":"<p>The bundled Guzzle version was updated to Guzzle 7. No breaking changes are expected for simple uses. A detailed Guzzle migration guide can be found in the Guzzle documentation.</p> <p>The explicit <code>sink</code> that was recommended in the migration guide for WoltLab Suite 5.2 can now be removed, as the Guzzle issue #2735 was fixed in Guzzle 7.</p>"},{"location":"migration/wsc53/libraries/#emogrifier-css-inliner","title":"Emogrifier / CSS Inliner","text":"<p>The Emogrifier library was updated from version 2.2 to 5.0. This update comes with a breaking change, as the <code>Emogrifier</code> class was removed. With the updated Emogrifier library, the <code>CssInliner</code> class must be used instead.</p> <p>No compatibility layer was added for the <code>Emogrifier</code> class, as the Emogrifier library's purpose was to be used within the email subsystem of WoltLab Suite. In case you use Emogrifier directly within your own code, you will need to adjust the usage. Refer to the Emogrifier CHANGELOG and WoltLab/WCF #3738 if you need help making the necessary adjustments.</p> <p>If you only use Emogrifier indirectly by sending HTML mail via the email subsystem then you might notice unexpected visual changes due to the improved CSS support. Double check your CSS declarations and particularly the specificity of your selectors in these cases.</p>"},{"location":"migration/wsc53/libraries/#scssphp","title":"scssphp","text":"<p>scssphp was updated from version 1.1 to 1.4.</p> <p>If you interact with scssphp only by deploying <code>.scss</code> files, then you should not experience any breaking changes, except when the improved SCSS compatibility interprets your SCSS code differently.</p> <p>If you happen to directly use scssphp in your PHP code, you should be aware that scssphp deprecated the use of output formatters in favor of a simple output style enum.</p> <p>Refer to WoltLab/WCF #3851 and the scssphp releases for details.</p>"},{"location":"migration/wsc53/libraries/#constant-time-encoder","title":"Constant Time Encoder","text":"<p>WoltLab Suite 5.4 ships the <code>paragonie/constant_time_encoding</code> library. It is recommended to use this library to perform encoding and decoding of secrets to prevent leaks via cache timing attacks. Refer to the library author\u2019s blog post for more background detail.</p> <p>For the common case of encoding the bytes taken from a CSPRNG in hexadecimal form, the required change would look like the following:</p> <p>Previously:</p> <pre><code><?php\n$encoded = hex2bin(random_bytes(16));\n</code></pre> <p>Now:</p> <pre><code><?php\nuse ParagonIE\\ConstantTime\\Hex;\n\n// For security reasons you should add the backslash\n// to ensure you refer to the `random_bytes` function\n// within the global namespace and not a function\n// defined in the current namespace.\n$encoded = Hex::encode(\\random_bytes(16));\n</code></pre> <p>Please refer to the documentation and source code of the <code>paragonie/constant_time_encoding</code> library to learn how to use the library with different encodings (e.g. base64).</p>"},{"location":"migration/wsc53/php/","title":"Migrating from WoltLab Suite 5.3 - PHP","text":""},{"location":"migration/wsc53/php/#minimum-requirements","title":"Minimum requirements","text":"<p>The minimum requirements have been increased to the following:</p> <ul> <li>PHP: 7.2.24</li> <li>MySQL: 5.7.31 or 8.0.19</li> <li>MariaDB: 10.1.44</li> </ul> <p>Most notably PHP 7.2 contains usable support for scalar types by the addition of nullable types in PHP 7.1 and parameter type widening in PHP 7.2.</p> <p>It is recommended to make use of scalar types and other newly introduced features whereever possible. Please refer to the PHP documentation for details.</p>"},{"location":"migration/wsc53/php/#flood-control","title":"Flood Control","text":"<p>To prevent users from creating massive amounts of contents in short periods of time, i.e., spam, existing systems already use flood control mechanisms to limit the amount of contents created within a certain period of time. With WoltLab Suite 5.4, we have added a general API that manages such rate limiting. Leveraging this API is easily done.</p> <ol> <li>Register an object type for the definition <code>com.woltlab.wcf.floodControl</code>: <code>com.example.foo.myContent</code>.</li> <li>Whenever the active user creates content of this type, call <pre><code>FloodControl::getInstance()->registerContent('com.example.foo.myContent');\n</code></pre> You should only call this method if the user creates the content themselves. If the content is automatically created by the system, for example when copying / duplicating existing content, no activity should be registered.</li> <li> <p>To check the last time when the active user created content of the relevant type, use <pre><code>FloodControl::getInstance()->getLastTime('com.example.foo.myContent');\n</code></pre> If you want to limit the number of content items created within a certain period of time, for example within one day, use <pre><code>$data = FloodControl::getInstance()->countContent('com.example.foo.myContent', new \\DateInterval('P1D'));\n// number of content items created within the last day\n$count = $data['count'];\n// timestamp when the earliest content item was created within the last day\n$earliestTime = $data['earliestTime'];\n</code></pre> The method also returns <code>earliestTime</code> so that you can tell the user in the error message when they are able again to create new content of the relevant type.</p> <p>Flood control entries are only stored for 31 days and older entries are cleaned up daily.</p> </li> </ol> <p>The previously mentioned methods of <code>FloodControl</code> use the active user and the current timestamp as reference point. <code>FloodControl</code> also provides methods to register content or check flood control for other registered users or for guests via their IP address. For further details on these methods, please refer to the documentation in the FloodControl class.</p> <p>Do not interact directly with the flood control database table but only via the <code>FloodControl</code> class!</p>"},{"location":"migration/wsc53/php/#databasepackageinstallationplugin","title":"DatabasePackageInstallationPlugin","text":"<p><code>DatabasePackageInstallationPlugin</code> is a new idempotent package installation plugin (thus it is available in the sync function in the devtools) to update the database schema using the PHP-based database API. <code>DatabasePackageInstallationPlugin</code> is similar to <code>ScriptPackageInstallationPlugin</code> by requiring a PHP script that is included during the execution of the script. The script is expected to return an array of <code>DatabaseTable</code> objects representing the schema changes so that in contrast to using <code>ScriptPackageInstallationPlugin</code>, no <code>DatabaseTableChangeProcessor</code> object has to be created. The PHP file must be located in the <code>acp/database/</code> directory for the devtools sync function to recognize the file.</p>"},{"location":"migration/wsc53/php/#php-database-api","title":"PHP Database API","text":"<p>The PHP API to add and change database tables during package installations and updates in the <code>wcf\\system\\database\\table</code> namespace now also supports renaming existing table columns with the new <code>IDatabaseTableColumn::renameTo()</code> method:</p> <pre><code>PartialDatabaseTable::create('wcf1_test')\n ->columns([\n NotNullInt10DatabaseTableColumn::create('oldName')\n ->renameTo('newName')\n ]);\n</code></pre> <p>Like with every change to existing database tables, packages can only rename columns that they installed.</p>"},{"location":"migration/wsc53/php/#captcha","title":"Captcha","text":"<p>The reCAPTCHA v1 implementation was completely removed. This includes the <code>\\wcf\\system\\recaptcha\\RecaptchaHandler</code> class (not to be confused with the one in the <code>captcha</code> namespace).</p> <p>The reCAPTCHA v1 endpoints have already been turned off by Google and always return a HTTP 404. Thus the implementation was completely non-functional even before this change.</p> <p>See WoltLab/WCF#3781 for details.</p>"},{"location":"migration/wsc53/php/#search","title":"Search","text":"<p>The generic implementation in the <code>AbstractSearchEngine::parseSearchQuery()</code> method was dangerous, because it did not have knowledge about the search engine\u2019s specifics. The implementation was completely removed: <code>AbstractSearchEngine::parseSearchQuery()</code> now always throws a <code>\\BadMethodCallException</code>.</p> <p>If you implemented a custom search engine and relied on this method, you can inline the previous implementation to preserve existing behavior. You should take the time to verify the rewritten queries against the manual of the search engine to make sure it cannot generate malformed queries or security issues.</p> <p>See WoltLab/WCF#3815 for details.</p>"},{"location":"migration/wsc53/php/#styles","title":"Styles","text":"<p>The <code>StyleCompiler</code> class is marked <code>final</code> now. The internal SCSS compiler object being stored in the <code>$compiler</code> property was a design issue that leaked compiler state across multiple compiled styles, possibly causing misgenerated stylesheets. As the removal of the <code>$compiler</code> property effectively broke compatibility within the <code>StyleCompiler</code> and as the <code>StyleCompiler</code> never was meant to be extended, it was marked final.</p> <p>See WoltLab/WCF#3929 for details.</p>"},{"location":"migration/wsc53/php/#tags","title":"Tags","text":"<p>Use of the <code>wcf1_tag_to_object.languageID</code> column is deprecated. The <code>languageID</code> column is redundant, because its value can be derived from the <code>tagID</code>. With WoltLab Suite 5.4, it will no longer be part of any indices, allowing more efficient index usage in the general case.</p> <p>If you need to filter the contents of <code>wcf1_tag_to_object</code> by language, you should perform an <code>INNER JOIN wcf1_tag tag ON tag.tagID = tag_to_object.tagID</code> and filter on <code>wcf1_tag.languageID</code>.</p> <p>See WoltLab/WCF#3904 for details.</p>"},{"location":"migration/wsc53/php/#avatars","title":"Avatars","text":"<p>The <code>ISafeFormatAvatar</code> interface was added to properly support fallback image types for use in emails. If your custom <code>IUserAvatar</code> implementation supports image types without broad support (i.e. anything other than PNG, JPEG, and GIF), then you should implement the <code>ISafeFormatAvatar</code> interface to return a fallback PNG, JPEG, or GIF image.</p> <p>See WoltLab/WCF#4001 for details.</p>"},{"location":"migration/wsc53/php/#linebreakseparatedtext-option-type","title":"<code>lineBreakSeparatedText</code> Option Type","text":"<p>Currently, several of the (user group) options installed by our packages use the <code>textarea</code> option type and split its value by linebreaks to get a list of items, for example for allowed file extensions. To improve the user interface when setting up the value of such options, we have added the <code>lineBreakSeparatedText</code> option type as a drop-in replacement where the individual items are explicitly represented as distinct items in the user interface.</p>"},{"location":"migration/wsc53/php/#ignoring-of-users","title":"Ignoring of Users","text":"<p>WoltLab Suite 5.4 distinguishes between blocking direct contact only and hiding all contents when ignoring users. To allow for detecting the difference, the <code>UserProfile::getIgnoredUsers()</code> and <code>UserProfile::isIgnoredUser()</code> methods received a new <code>$type</code> parameter. Pass either <code>UserIgnore::TYPE_BLOCK_DIRECT_CONTACT</code> or <code>UserIgnore::TYPE_HIDE_MESSAGES</code> depending on whether the check refers to a non-directed usage or content.</p> <p>See WoltLab/WCF#4064 and WoltLab/WCF#3981 for details.</p>"},{"location":"migration/wsc53/php/#databaseprepare","title":"<code>Database::prepare()</code>","text":"<p><code>Database::prepare(string $statement, int $limit = 0, int $offset = 0): PreparedStatement</code> works the same way as <code>Database::prepareStatement()</code> but additionally also replaces all occurences of <code>app1_</code> with <code>app{WCF_N}_</code> for all installed apps. This new method makes it superfluous to use <code>WCF_N</code> when building queries.</p>"},{"location":"migration/wsc53/session/","title":"Migrating from WoltLab Suite 5.3 - Session Handling and Authentication","text":"<p>WoltLab Suite 5.4 includes a completely refactored session handling. As long as you only interact with sessions via <code>WCF::getSession()</code>, especially when you perform read-only accesses, you should not notice any breaking changes.</p> <p>You might appreciate some of the new session methods if you process security sensitive data.</p>"},{"location":"migration/wsc53/session/#summary-and-concepts","title":"Summary and Concepts","text":"<p>Most of the changes revolve around the removal of the legacy persistent login functionality and the assumption that every user has a single session only. Both aspects are related to each other.</p>"},{"location":"migration/wsc53/session/#legacy-persistent-login","title":"Legacy Persistent Login","text":"<p>The legacy persistent login was rather an automated login. Upon bootstrapping a session, it was checked whether the user had a cookie pair storing the user\u2019s <code>userID</code> and (a single BCrypt hash of) the user\u2019s password. If such a cookie pair exists and the BCrypt hash within the cookie matches the user\u2019s password hash when hashed again, the session would immediately <code>changeUser()</code> to the respective user.</p> <p>This legacy persistent login was completely removed. Instead, any sessions that belong to an authenticated user will automatically be long-lived. These long-lived sessions expire no sooner than 14 days after the last activity, ensuring that the user continously stays logged in, provided that they visit the page at least once per fortnight.</p>"},{"location":"migration/wsc53/session/#multiple-sessions","title":"Multiple Sessions","text":"<p>To allow for a proper separation of these long-lived user sessions, WoltLab Suite now allows for multiple sessions per user. These sessions are completely unrelated to each other. Specifically, they do not share session variables and they expire independently.</p> <p>As the existing <code>wcf1_session</code> table is also used for the online lists and location tracking, it will be maintained on a best effort basis. It no longer stores any private session data.</p> <p>The actual sessions storing security sensitive information are in an unrelated location. They must only be accessed via the PHP API exposed by the <code>SessionHandler</code>.</p>"},{"location":"migration/wsc53/session/#merged-acp-and-frontend-sessions","title":"Merged ACP and Frontend Sessions","text":"<p>WoltLab Suite 5.4 shares a single session across both the frontend, as well as the ACP. When a user logs in to the frontend, they will also be logged into the ACP and vice versa.</p> <p>Actual access to the ACP is controlled via the new reauthentication mechanism.</p> <p>The session variable store is scoped: Session variables set within the frontend are not available within the ACP and vice versa.</p>"},{"location":"migration/wsc53/session/#improved-authentication-and-reauthentication","title":"Improved Authentication and Reauthentication","text":"<p>WoltLab Suite 5.4 ships with multi-factor authentication support and a generic re-authentication implementation that can be used to verify the account owner\u2019s presence.</p>"},{"location":"migration/wsc53/session/#additions-and-changes","title":"Additions and Changes","text":""},{"location":"migration/wsc53/session/#password-hashing","title":"Password Hashing","text":"<p>WoltLab Suite 5.4 includes a new object-oriented password hashing framework that is modeled after PHP\u2019s <code>password_*</code> API. Check <code>PasswordAlgorithmManager</code> and <code>IPasswordAlgorithm</code> for details.</p> <p>The new default password hash is a standard BCrypt hash. All newly generated hashes in <code>wcf1_user.password</code> will now include a type prefix, instead of just passwords imported from other systems.</p>"},{"location":"migration/wsc53/session/#session-storage","title":"Session Storage","text":"<p>The <code>wcf1_session</code> table will no longer be used for session storage. Instead, it is maintained for compatibility with existing online lists.</p> <p>The actual session storage is considered an implementation detail and you must not directly interact with the session tables. Future versions might support alternative session backends, such as Redis.</p> <p>Do not interact directly with the session database tables but only via the <code>SessionHandler</code> class!</p>"},{"location":"migration/wsc53/session/#reauthentication","title":"Reauthentication","text":"<p>For security sensitive processing, you might want to ensure that the account owner is actually present instead of a third party accessing a session that was accidentally left logged in.</p> <p>WoltLab Suite 5.4 ships with a generic reauthentication framework. To request reauthentication within your controller you need to:</p> <ol> <li>Use the <code>wcf\\system\\user\\authentication\\TReauthenticationCheck</code> trait.</li> <li>Call: <pre><code>$this->requestReauthentication(LinkHandler::getInstance()->getControllerLink(static::class, [\n /* additional parameters */\n]));\n</code></pre></li> </ol> <p><code>requestReauthentication()</code> will check if the user has recently authenticated themselves. If they did, the request proceeds as usual. Otherwise, they will be asked to reauthenticate themselves. After the successful authentication, they will be redirected to the URL that was passed as the first parameter (the current controller within the example).</p> <p>Details can be found in WoltLab/WCF#3775.</p>"},{"location":"migration/wsc53/session/#multi-factor-authentication","title":"Multi-factor Authentication","text":"<p>To implement multi-factor authentication securely, WoltLab Suite 5.4 implements the concept of a \u201cpending user change\u201d. The user will not be logged in (i.e. <code>WCF::getUser()->userID</code> returns <code>null</code>) until they authenticate themselves with their second factor.</p> <p>Requesting multi-factor authentication is done on an opt-in basis for compatibility reasons. If you perform authentication yourself and do not trust the authentication source to perform multi-factor authentication itself, you will need to adjust your logic to request multi-factor authentication from WoltLab Suite:</p> <p>Previously:</p> <pre><code>WCF::getSession()->changeUser($targetUser);\n</code></pre> <p>Now:</p> <pre><code>$isPending = WCF::getSession()->changeUserAfterMultifactorAuthentication($targetUser);\nif ($isPending) {\n // Redirect to the authentication form. The user will not be logged in.\n // Note: Do not use `getControllerLink` to support both the frontend as well as the ACP.\n HeaderUtil::redirect(LinkHandler::getInstance()->getLink('MultifactorAuthentication', [\n 'url' => /* Return To */,\n ]));\n exit;\n}\n// Proceed as usual. The user will be logged in.\n</code></pre>"},{"location":"migration/wsc53/session/#adding-multi-factor-methods","title":"Adding Multi-factor Methods","text":"<p>Adding your own multi-factor method requires the implementation of a single object type:</p> objectType.xml<pre><code><type>\n <name>com.example.multifactor.foobar</name>\n <definitionname>com.woltlab.wcf.multifactor</definitionname>\n <icon><!-- Font Awesome 4 Icon Name goes here. --></icon>\n <priority><!-- Determines the sort order, higher priority will be preferred for authentication. --></priority>\n <classname>wcf\\system\\user\\multifactor\\FoobarMultifactorMethod</classname>\n</type>\n</code></pre> <p>The given classname must implement the <code>IMultifactorMethod</code> interface.</p> <p>As a self-contained example, you can find the initial implementation of the email multi-factor method in WoltLab/WCF#3729. Please check the version history of the PHP class to make sure you do not miss important changes that were added later.</p> <p>Multi-factor authentication is security sensitive. Make sure to carefully read the remarks in <code>IMultifactorMethod</code> for possible issues. Also make sure to carefully test your implementation against all sorts of incorrect input and consider attack vectors such as race conditions. It is strongly recommended to generously check the current state by leveraging assertions and exceptions.</p>"},{"location":"migration/wsc53/session/#enforcing-multi-factor-authentication","title":"Enforcing Multi-factor Authentication","text":"<p>To enforce Multi-factor Authentication within your controller you need to:</p> <ol> <li>Use the <code>wcf\\system\\user\\multifactor\\TMultifactorRequirementEnforcer</code> trait.</li> <li>Call: <code>$this->enforceMultifactorAuthentication();</code></li> </ol> <p><code>enforceMultifactorAuthentication()</code> will check if the user is in a group that requires multi-factor authentication, but does not yet have multi-factor authentication enabled. If they did, the request proceeds as usual. Otherwise, a <code>NamedUserException</code> is thrown.</p>"},{"location":"migration/wsc53/session/#deprecations-and-removals","title":"Deprecations and Removals","text":""},{"location":"migration/wsc53/session/#sessionhandler","title":"SessionHandler","text":"<p>Most of the changes with regard to the new session handling happened in <code>SessionHandler</code>. Most notably, <code>SessionHandler</code> now is marked <code>final</code> to ensure proper encapsulation of data.</p> <p>A number of methods in <code>SessionHandler</code> are now deprecated and result in a noop. This change mostly affects methods that have been used to bootstrap the session, such as <code>setHasValidCookie()</code>.</p> <p>Additionally, accessing the following keys on the session is deprecated. They directly map to an existing method in another class and any uses can easily be updated: - <code>ipAddress</code> - <code>userAgent</code> - <code>requestURI</code> - <code>requestMethod</code> - <code>lastActivityTime</code></p> <p>Refer to the implementation for details.</p>"},{"location":"migration/wsc53/session/#acp-sessions","title":"ACP Sessions","text":"<p>The database tables related to ACP sessions have been removed. The PHP classes have been preserved due to being used within the class hierarchy of the legacy sessions.</p>"},{"location":"migration/wsc53/session/#cookies","title":"Cookies","text":"<p>The <code>_userID</code>, <code>_password</code>, <code>_cookieHash</code> and <code>_cookieHash_acp</code> cookies will no longer be created nor consumed.</p>"},{"location":"migration/wsc53/session/#virtual-sessions","title":"Virtual Sessions","text":"<p>The virtual session logic existed to support multiple devices per single session in <code>wcf1_session</code>. Virtual sessions are no longer required with the refactored session handling.</p> <p>Anything related to virtual sessions has been completely removed as they are considered an implementation detail. This removal includes PHP classes and database tables.</p>"},{"location":"migration/wsc53/session/#security-token-constants","title":"Security Token Constants","text":"<p>The security token constants are deprecated. Instead, the methods of <code>SessionHandler</code> should be used (e.g. <code>->getSecurityToken()</code>). Within templates, you should migrate to the <code>{csrfToken}</code> tag in place of <code>{@SECURITY_TOKEN_INPUT_TAG}</code>. The <code>{csrfToken}</code> tag is a drop-in replacement and was backported to WoltLab Suite 5.2+, allowing you to maintain compatibility across a broad range of versions.</p>"},{"location":"migration/wsc53/session/#passwordutil-and-double-bcrypt-hashes","title":"PasswordUtil and Double BCrypt Hashes","text":"<p>Most of the methods in PasswordUtil are deprecated in favor of the new password hashing framework.</p>"},{"location":"migration/wsc53/templates/","title":"Migrating from WoltLab Suite 5.3 - Templates and Languages","text":""},{"location":"migration/wsc53/templates/#csrftoken","title":"<code>{csrfToken}</code>","text":"<p>Going forward, any uses of the <code>SECURITY_TOKEN_*</code> constants should be avoided. To reference the CSRF token (\u201cSecurity Token\u201d) within templates, the <code>{csrfToken}</code> template plugin was added.</p> <p>Before:</p> <pre><code>{@SECURITY_TOKEN_INPUT_TAG}\n{link controller=\"Foo\"}t={@SECURITY_TOKEN}{/link}\n</code></pre> <p>After:</p> <pre><code>{csrfToken}\n{link controller=\"Foo\"}t={csrfToken type=url}{/link} {* The use of the CSRF token in URLs is discouraged.\n Modifications should happen by means of a POST request. *}\n</code></pre> <p>The <code>{csrfToken}</code> plugin was backported to WoltLab Suite 5.2 and higher, allowing compatibility with a large range of WoltLab Suite branches. See WoltLab/WCF#3612 for details.</p>"},{"location":"migration/wsc53/templates/#rss-feed-links","title":"RSS Feed Links","text":"<p>Prior to version 5.4 of WoltLab Suite, all RSS feed links contained the access token for logged-in users so that the feed shows all contents the specific user has access to. With version 5.4, links with the CSS class <code>rssFeed</code> will open a dialog when clicked that offers the feed link with the access token for personal use and an anonymous feed link that can be shared with others.</p> <pre><code>{* before *}\n<li>\n <a rel=\"alternate\" {*\n *}href=\"{if $__wcf->getUser()->userID}{link controller='ArticleFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleFeed'}{/link}{/if}\" {*\n *}title=\"{lang}wcf.global.button.rss{/lang}\" {*\n *}class=\"jsTooltip\"{*\n *}>\n <span class=\"icon icon16 fa-rss\"></span>\n <span class=\"invisible\">{lang}wcf.global.button.rss{/lang}</span>\n </a>\n</li>\n\n{* after *}\n<li>\n <a rel=\"alternate\" {*\n *}href=\"{if $__wcf->getUser()->userID}{link controller='ArticleFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleFeed'}{/link}{/if}\" {*\n *}title=\"{lang}wcf.global.button.rss{/lang}\" {*\n *}class=\"rssFeed jsTooltip\"{*\n *}>\n <span class=\"icon icon16 fa-rss\"></span>\n <span class=\"invisible\">{lang}wcf.global.button.rss{/lang}</span>\n </a>\n</li>\n</code></pre>"},{"location":"migration/wsc54/deprecations_removals/","title":"Migrating from WoltLab Suite 5.4 - Deprecations and Removals","text":"<p>With version 5.5, we have deprecated certain components and removed several other components that have been deprecated for many years.</p>"},{"location":"migration/wsc54/deprecations_removals/#deprecations","title":"Deprecations","text":""},{"location":"migration/wsc54/deprecations_removals/#php","title":"PHP","text":""},{"location":"migration/wsc54/deprecations_removals/#classes","title":"Classes","text":"<ul> <li><code>filebase\\system\\file\\FileDataHandler</code> (use <code>filebase\\system\\cache\\runtime\\FileRuntimeCache</code>)</li> <li><code>wcf\\action\\AbstractAjaxAction</code> (use PSR-7 responses, WoltLab/WCF#4437)</li> <li><code>wcf\\data\\IExtendedMessageQuickReplyAction</code> (WoltLab/WCF#4575)</li> <li><code>wcf\\form\\SearchForm</code> (see WoltLab/WCF#4605)</li> <li><code>wcf\\page\\AbstractSecurePage</code> (WoltLab/WCF#4515)</li> <li><code>wcf\\page\\SearchResultPage</code> (see WoltLab/WCF#4605)</li> <li><code>wcf\\system\\database\\table\\column\\TUnsupportedDefaultValue</code> (do not implement <code>IDefaultValueDatabaseTableColumn</code>, see WoltLab/WCF#4733)</li> <li><code>wcf\\system\\exception\\ILoggingAwareException</code> (WoltLab/WCF#4547)</li> <li><code>wcf\\system\\io\\FTP</code> (directly use the FTP extension)</li> <li><code>wcf\\system\\search\\AbstractSearchableObjectType</code> (use <code>AbstractSearchProvider</code> instead, see WoltLab/WCF#4605)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchException</code></li> <li><code>wcf\\system\\search\\ISearchableObjectType</code> (use <code>ISearchProvider</code> instead, see WoltLab/WCF#4605)</li> <li><code>wcf\\util\\PasswordUtil</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#methods","title":"Methods","text":"<ul> <li><code>wcf\\action\\MessageQuoteAction::markForRemoval()</code> (WoltLab/WCF#4452)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatarAction::fetchRemoteAvatar()</code> (WoltLab/WCF#4744)</li> <li><code>wcf\\data\\user\\notification\\UserNotificationAction::getOutstandingNotifications()</code> (WoltLab/WCF#4603)</li> <li><code>wcf\\data\\moderation\\queue\\ModerationQueueAction::getOutstandingQueues()</code> (WoltLab/WCF#4603)</li> <li><code>wcf\\system\\message\\QuickReplyManager::setTmpHash()</code> (WoltLab/WCF#4575)</li> <li><code>wcf\\system\\request\\Request::isExecuted()</code> (WoltLab/WCF#4485)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::query()</code></li> <li><code>wcf\\system\\session\\Session::getDeviceIcon()</code> (WoltLab/WCF#4525)</li> <li><code>wcf\\system\\user\\authentication\\password\\algorithm\\TPhpass::hash()</code> (WoltLab/WCF#4602)</li> <li><code>wcf\\system\\user\\authentication\\password\\algorithm\\TPhpass::needsRehash()</code> (WoltLab/WCF#4602)</li> <li><code>wcf\\system\\WCF::getAnchor()</code> (WoltLab/WCF#4580)</li> <li><code>wcf\\util\\MathUtil::getRandomValue()</code> (WoltLab/WCF#4280)</li> <li><code>wcf\\util\\StringUtil::encodeJSON()</code> (WoltLab/WCF#4645)</li> <li><code>wcf\\util\\StringUtil::endsWith()</code> (WoltLab/WCF#4509)</li> <li><code>wcf\\util\\StringUtil::getHash()</code> (WoltLab/WCF#4279)</li> <li><code>wcf\\util\\StringUtil::split()</code> (WoltLab/WCF#4513)</li> <li><code>wcf\\util\\StringUtil::startsWith()</code> (WoltLab/WCF#4509)</li> <li><code>wcf\\util\\UserUtil::isAvailableEmail()</code> (WoltLab/WCF#4602)</li> <li><code>wcf\\util\\UserUtil::isAvailableUsername()</code> (WoltLab/WCF#4602)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#properties","title":"Properties","text":"<ul> <li><code>wcf\\acp\\page\\PackagePage::$compatibleVersions</code> (WoltLab/WCF#4371)</li> <li><code>wcf\\system\\io\\GZipFile::$gzopen64</code> (WoltLab/WCF#4381)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#constants","title":"Constants","text":"<ul> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::DELETE</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::GET</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::POST</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::PUT</code></li> <li><code>wcf\\system\\visitTracker\\VisitTracker::DEFAULT_LIFETIME</code> (WoltLab/WCF#4757)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#functions","title":"Functions","text":"<ul> <li>The global <code>escapeString</code> helper (WoltLab/WCF#4506)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#options","title":"Options","text":"<ul> <li><code>HTTP_SEND_X_FRAME_OPTIONS</code> (WoltLab/WCF#4474)</li> <li><code>ELASTICSEARCH_ALLOW_LEADING_WILDCARD</code></li> <li><code>WBB_MODULE_IGNORE_BOARDS</code> (The option will be always on with WoltLab Suite Forum 5.5 and will be removed with a future version.)</li> <li><code>ENABLE_DESKTOP_NOTIFICATIONS</code> (WoltLab/WCF#4806)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#javascript","title":"JavaScript","text":"<ul> <li><code>WCF.Message.Quote.Manager.markQuotesForRemoval()</code> (WoltLab/WCF#4452)</li> <li><code>WCF.Search.Message.KeywordList</code> (WoltLab/WCF#4402)</li> <li><code>SECURITY_TOKEN</code> (use <code>Core.getXsrfToken()</code>, WoltLab/WCF#4523)</li> <li><code>WCF.Dropdown.Interactive.Handler</code> (WoltLab/WCF#4603)</li> <li><code>WCF.Dropdown.Interactive.Instance</code> (WoltLab/WCF#4603)</li> <li><code>WCF.User.Panel.Abstract</code> (WoltLab/WCF#4603)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#database-tables","title":"Database Tables","text":"<ul> <li><code>wcf1_package_compatibility</code> (WoltLab/WCF#4371)</li> <li><code>wcf1_package_update_compatibility</code> (WoltLab/WCF#4385)</li> <li><code>wcf1_package_update_optional</code> (WoltLab/WCF#4432)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#templates","title":"Templates","text":""},{"location":"migration/wsc54/deprecations_removals/#template-plugins","title":"Template Plugins","text":"<ul> <li><code>|encodeJSON</code> (WoltLab/WCF#4645)</li> <li><code>{fetch}</code> (WoltLab/WCF#4891)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#template-events","title":"Template Events","text":"<ul> <li><code>pageNavbarTop::navigationIcons</code></li> <li><code>search::queryOptions</code></li> <li><code>search::authorOptions</code></li> <li><code>search::periodOptions</code></li> <li><code>search::displayOptions</code></li> <li><code>search::generalFields</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#miscellaneous","title":"Miscellaneous","text":"<ul> <li>The global option to set a specific style with a request parameter (<code>$_REQUEST['styleID']</code>) is deprecated (WoltLab/WCF@0c0111e946)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#removals","title":"Removals","text":""},{"location":"migration/wsc54/deprecations_removals/#php_1","title":"PHP","text":""},{"location":"migration/wsc54/deprecations_removals/#classes_1","title":"Classes","text":"<ul> <li><code>gallery\\util\\ExifUtil</code></li> <li><code>wbb\\action\\BoardQuickSearchAction</code></li> <li><code>wbb\\data\\thread\\NewsList</code></li> <li><code>wbb\\data\\thread\\News</code></li> <li><code>wcf\\action\\PollAction</code> (WoltLab/WCF#4662)</li> <li><code>wcf\\form\\RecaptchaForm</code> (WoltLab/WCF#4289)</li> <li><code>wcf\\system\\background\\job\\ElasticSearchIndexBackgroundJob</code></li> <li><code>wcf\\system\\cache\\builder\\TemplateListenerCacheBuilder</code> (WoltLab/WCF#4297)</li> <li><code>wcf\\system\\log\\modification\\ModificationLogHandler</code> (WoltLab/WCF#4340)</li> <li><code>wcf\\system\\recaptcha\\RecaptchaHandlerV2</code> (WoltLab/WCF#4289)</li> <li><code>wcf\\system\\search\\SearchKeywordManager</code> (WoltLab/WCF#4313)</li> <li>The SCSS compiler\u2019s <code>Leafo</code> class aliases (WoltLab/WCF#4343, Migration Guide from 5.2 to 5.3)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#methods_1","title":"Methods","text":"<ul> <li><code>wbb\\data\\board\\BoardCache::getLabelGroups()</code></li> <li><code>wbb\\data\\post\\PostAction::jumpToExtended()</code> (this method always threw a <code>BadMethodCallException</code>)</li> <li><code>wbb\\data\\thread\\ThreadAction::countReplies()</code></li> <li><code>wbb\\data\\thread\\ThreadAction::validateCountReplies()</code></li> <li><code>wcf\\acp\\form\\UserGroupOptionForm::verifyPermissions()</code> (WoltLab/WCF#4312)</li> <li><code>wcf\\data\\conversation\\message\\ConversationMessageAction::jumpToExtended()</code> (WoltLab/com.woltlab.wcf.conversation#162)</li> <li><code>wcf\\data\\moderation\\queue\\ModerationQueueEditor::markAsDone()</code> (WoltLab/WCF#4317)</li> <li><code>wcf\\data\\tag\\TagCloudTag::getSize()</code> (WoltLab/WCF#4325)</li> <li><code>wcf\\data\\tag\\TagCloudTag::setSize()</code> (WoltLab/WCF#4325)</li> <li><code>wcf\\data\\user\\User::getSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::getSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::saveSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::validateGetSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::validateSaveSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\avatar\\DefaultAvatar::canCrop()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\data\\user\\avatar\\DefaultAvatar::getCropImageTag()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatar::canCrop()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatar::getCropImageTag()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\system\\bbcode\\BBCodeHandler::setAllowedBBCodes()</code> (WoltLab/WCF#4319)</li> <li><code>wcf\\system\\bbcode\\BBCodeParser::validateBBCodes()</code> (WoltLab/WCF#4319)</li> <li><code>wcf\\system\\breadcrumb\\Breadcrumbs::add()</code> (WoltLab/WCF#4298)</li> <li><code>wcf\\system\\breadcrumb\\Breadcrumbs::remove()</code> (WoltLab/WCF#4298)</li> <li><code>wcf\\system\\breadcrumb\\Breadcrumbs::replace()</code> (WoltLab/WCF#4298)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::create()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::validateAttribute()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::validateClass()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::validateId()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\field\\IAttributeFormField::validateFieldAttribute()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\field\\dependency\\IFormFieldDependency::create()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\field\\validation\\IFormFieldValidator::validateId()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\message\\embedded\\object\\MessageEmbeddedObjectManager::parseTemporaryMessage()</code> (WoltLab/WCF#4299)</li> <li><code>wcf\\system\\package\\PackageArchive::getPhpRequirements()</code> (WoltLab/WCF#4311)</li> <li><code>wcf\\system\\search\\ISearchIndexManager::add()</code> (Removal from Interface, see WoltLab/WCF#4508)</li> <li><code>wcf\\system\\search\\ISearchIndexManager::update()</code> (Removal from Interface, see WoltLab/WCF#4508)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::_add()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::_delete()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::add()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::bulkAdd()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::bulkDelete()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::delete()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::update()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchIndexManager::add()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchIndexManager::update()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchEngine::parseSearchQuery()</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#properties_1","title":"Properties","text":"<ul> <li><code>wcf\\data\\category\\Category::$permissions</code> (WoltLab/WCF#4303)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchIndexManager::$bulkTypeName</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#constants_1","title":"Constants","text":"<ul> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::HEAD</code></li> <li><code>wcf\\system\\tagging\\TagCloud::MAX_FONT_SIZE</code> (WoltLab/WCF#4325)</li> <li><code>wcf\\system\\tagging\\TagCloud::MIN_FONT_SIZE</code> (WoltLab/WCF#4325)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#options_1","title":"Options","text":"<ul> <li><code>ENABLE_CENSORSHIP</code> (always call <code>Censorship::test()</code>, see WoltLab/WCF#4567)</li> <li><code>MODULE_SYSTEM_RECAPTCHA</code> (WoltLab/WCF#4305)</li> <li><code>PROFILE_MAIL_USE_CAPTCHA</code> (WoltLab/WCF#4399)</li> <li>The <code>may</code> value for <code>MAIL_SMTP_STARTTLS</code> (WoltLab/WCF#4398)</li> <li><code>SEARCH_USE_CAPTCHA</code> (see WoltLab/WCF#4605)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#files","title":"Files","text":"<ul> <li><code>acp/dereferrer.php</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#javascript_1","title":"JavaScript","text":"<ul> <li><code>Blog.Entry.QuoteHandler</code> (use <code>WoltLabSuite/Blog/Ui/Entry/Quote</code>)</li> <li><code>Calendar.Event.QuoteHandler</code> (use <code>WoltLabSuite/Calendar/Ui/Event/Quote</code>)</li> <li><code>WBB.Board.IgnoreBoards</code> (use <code>WoltLabSuite/Forum/Ui/Board/Ignore</code>)</li> <li><code>WBB.Board.MarkAllAsRead</code> (use <code>WoltLabSuite/Forum/Ui/Board/MarkAllAsRead</code>)</li> <li><code>WBB.Board.MarkAsRead</code> (use <code>WoltLabSuite/Forum/Ui/Board/MarkAsRead</code>)</li> <li><code>WBB.Post.QuoteHandler</code> (use <code>WoltLabSuite/Forum/Ui/Post/Quote</code>)</li> <li><code>WBB.Thread.LastPageHandler</code> (use <code>WoltLabSuite/Forum/Ui/Thread/LastPageHandler</code>)</li> <li><code>WBB.Thread.MarkAsRead</code> (use <code>WoltLabSuite/Forum/Ui/Thread/MarkAsRead</code>)</li> <li><code>WBB.Thread.SimilarThreads</code> (use <code>WoltLabSuite/Forum/Ui/Thread/SimilarThreads</code>)</li> <li><code>WBB.Thread.WatchedThreadList</code> (use <code>WoltLabSuite/Forum/Controller/Thread/WatchedList</code>)</li> <li><code>WCF.ACP.Style.ImageUpload</code> (WoltLab/WCF#4323)</li> <li><code>WCF.ColorPicker</code> (see migration guide for <code>WCF.ColorPicker</code>)</li> <li><code>WCF.Conversation.Message.QuoteHandler</code> (use <code>WoltLabSuite/Core/Conversation/Ui/Message/Quote</code>, see WoltLab/com.woltlab.wcf.conversation#155)</li> <li><code>WCF.Like.js</code> (WoltLab/WCF#4300)</li> <li><code>WCF.Message.UserMention</code> (WoltLab/WCF#4324)</li> <li><code>WCF.Poll.Manager</code> (WoltLab/WCF#4662)</li> <li><code>WCF.UserPanel</code> (WoltLab/WCF#4316)</li> <li><code>WCF.User.Panel.Moderation</code> (WoltLab/WCF#4603)</li> <li><code>WCF.User.Panel.Notification</code> (WoltLab/WCF#4603)</li> <li><code>WCF.User.Panel.UserMenu</code> (WoltLab/WCF#4603)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#phrases","title":"Phrases","text":"<ul> <li><code>wbb.search.boards.all</code></li> <li><code>wcf.global.form.error.greaterThan.javaScript</code> (WoltLab/WCF#4306)</li> <li><code>wcf.global.form.error.lessThan.javaScript</code> (WoltLab/WCF#4306)</li> <li><code>wcf.search.type.keywords</code></li> <li><code>wcf.acp.option.search_use_captcha</code></li> <li><code>wcf.search.query.description</code></li> <li><code>wcf.search.results.change</code></li> <li><code>wcf.search.results.description</code></li> <li><code>wcf.search.general</code></li> <li><code>wcf.search.query</code></li> <li><code>wcf.search.error.noMatches</code></li> <li><code>wcf.search.error.user.noMatches</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#templates_1","title":"Templates","text":""},{"location":"migration/wsc54/deprecations_removals/#templates_2","title":"Templates","text":"<ul> <li><code>searchResult</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#template-events_1","title":"Template Events","text":"<ul> <li><code>search::tabMenuTabs</code></li> <li><code>search::sections</code></li> <li><code>tagSearch::tabMenuTabs</code></li> <li><code>tagSearch::sections</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#miscellaneous_1","title":"Miscellaneous","text":"<ul> <li>Object specific VisitTracker lifetimes (WoltLab/WCF#4757)</li> </ul>"},{"location":"migration/wsc54/forum_subscriptions/","title":"Migrating from WoltLab Suite 5.4 - WoltLab Suite Forum","text":""},{"location":"migration/wsc54/forum_subscriptions/#subscriptions","title":"Subscriptions","text":"<p>With WoltLab Suite Forum 5.5 we have introduced a new system for subscribing to threads and boards, which also offers the possibility to ignore threads and boards. You can learn more about this feature in our blog. The new system uses a separate mechanism to track the subscribed forums as well as the subscribed threads. The previously used object type <code>com.woltlab.wcf.user.objectWatch</code> is now discontinued, because the object watch system turned out to be too limited for the complex logic behind thread and forum subscriptions.</p>"},{"location":"migration/wsc54/forum_subscriptions/#subscribe-to-threads","title":"Subscribe to Threads","text":"<p>Previously:</p> <pre><code>$action = new UserObjectWatchAction([], 'subscribe', [\n 'data' => [\n 'objectID' => $threadID,\n 'objectType' => 'com.woltlab.wbb.thread',\n ]\n]);\n$action->executeAction();\n</code></pre> <p>Now:</p> <pre><code>ThreadStatusHandler::saveSubscriptionStatus(\n $threadID,\n ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING\n);\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#filter-ignored-threads","title":"Filter Ignored Threads","text":"<p>To filter ignored threads from a given <code>ThreadList</code>, you can use the method <code>ThreadStatusHandler::addFilterForIgnoredThreads()</code> to append the filter for ignored threads. The <code>ViewableThreadList</code> filters out ignored threads by default.</p> <p>Example:</p> <pre><code>$user = new User(123);\n$threadList = new ThreadList();\nThreadStatusHandler::addFilterForIgnoredThreads(\n $threadList,\n // This parameter specifies the target user. Defaults to the current user if the parameter\n // is omitted or `null`.\n $user\n);\n$threadList->readObjects();\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#filter-ignored-users","title":"Filter Ignored Users","text":"<p>Avoid issuing notifications to users that have ignored the target thread by filtering those out.</p> <pre><code>$userIDs = [1, 2, 3];\n$users = ThreadStatusHandler::filterIgnoredUserIDs(\n $userIDs,\n $thread->threadID\n);\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#subscribe-to-boards","title":"Subscribe to Boards","text":"<p>Previously:</p> <pre><code>$action = new UserObjectWatchAction([], 'subscribe', [\n 'data' => [\n 'objectID' => $boardID,\n 'objectType' => 'com.woltlab.wbb.board',\n ]\n]);\n$action->executeAction();\n</code></pre> <p>Now:</p> <pre><code>BoardStatusHandler::saveSubscriptionStatus(\n $boardID,\n ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING\n);\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#filter-ignored-boards","title":"Filter Ignored Boards","text":"<p>Similar to ignored threads you will also have to avoid issuing notifications for boards that a user has ignored.</p> <pre><code>$userIDs = [1, 2, 3];\n$users = BoardStatusHandler::filterIgnoredUserIDs(\n $userIDs,\n $board->boardID\n);\n</code></pre>"},{"location":"migration/wsc54/javascript/","title":"Migrating from WoltLab Suite 5.4 - TypeScript and JavaScript","text":""},{"location":"migration/wsc54/javascript/#ajaxdboaction","title":"<code>Ajax.dboAction()</code>","text":"<p>We have introduced a new <code>Promise</code> based API for the interaction with <code>wcf\\data\\DatabaseObjectAction</code>. It provides full IDE autocompletion support and transparent error handling, but is designed to be used with <code>DatabaseObjectAction</code> only.</p> <p>See the documentation for the new API and WoltLab/WCF#4585 for details.</p>"},{"location":"migration/wsc54/javascript/#wcfcolorpicker","title":"<code>WCF.ColorPicker</code>","text":"<p>We have replaced the old jQuery-based color picker <code>WCF.ColorPicker</code> with a more lightweight replacement <code>WoltLabSuite/Core/Ui/Color/Picker</code>, which uses the build-in <code>input[type=color]</code> field. To support transparency, which <code>input[type=color]</code> does not, we also added a slider to set the alpha value. <code>WCF.ColorPicker</code> has been adjusted to internally use <code>WoltLabSuite/Core/Ui/Color/Picker</code> and it has been deprecated.</p> <p>Be aware that the new color picker requires the following new phrases to be available in the TypeScript/JavaScript code:</p> <ul> <li><code>wcf.style.colorPicker.alpha</code>,</li> <li><code>wcf.style.colorPicker.color</code>,</li> <li><code>wcf.style.colorPicker.error.invalidColor</code>,</li> <li><code>wcf.style.colorPicker.hexAlpha</code>,</li> <li><code>wcf.style.colorPicker.new</code>.</li> </ul> <p>See WoltLab/WCF#4353 for details.</p>"},{"location":"migration/wsc54/javascript/#codemirror","title":"CodeMirror","text":"<p>The bundled version of CodeMirror was updated and should be loaded using the AMD loader going forward.</p> <p>See the third party libraries migration guide for details.</p>"},{"location":"migration/wsc54/javascript/#new-user-menu","title":"New User Menu","text":"<p>The legacy implementation <code>WCF.User.Panel.Abstract</code> was based on jQuery and has now been retired in favor of a new lightweight implementation that provides a clean interface and improved accessibility. You are strongly encouraged to migrate your existing implementation to integrate with existing menus.</p> <p>Please use <code>WoltLabSuite/Core/Ui/User/Menu/Data/ModerationQueue.ts</code> as a template for your own implementation, it contains only strictly the code you will need. It makes use of the new <code>Ajax.dboAction()</code> (see above) for improved readability and flexibility.</p> <p>You must update your trigger button to include the <code>role</code>, <code>tabindex</code> and ARIA attributes! Please take a look at the links in <code>pageHeaderUser.tpl</code> to see these four attributes in action.</p> <p>See WoltLab/WCF#4603 for details.</p>"},{"location":"migration/wsc54/libraries/","title":"Migrating from WoltLab Suite 5.4 - Third Party Libraries","text":""},{"location":"migration/wsc54/libraries/#symfony-php-polyfills","title":"Symfony PHP Polyfills","text":"<p>WoltLab Suite 5.5 ships with Symfony's PHP 7.3, 7.4, and 8.0 polyfills. These polyfills allow you to reliably use some of the PHP functions only available in PHP versions that are newer than the current minimum of PHP 7.2. Notable mentions are <code>str_starts_with</code>, <code>str_ends_with</code>, <code>array_key_first</code>, and <code>array_key_last</code>.</p> <p>Refer to the documentation within the symfony/polyfill repository for details.</p>"},{"location":"migration/wsc54/libraries/#scssphp","title":"scssphp","text":"<p>scssphp was updated from version 1.4 to 1.10.</p> <p>If you interact with scssphp only by deploying <code>.scss</code> files, then you should not experience any breaking changes, except when the improved SCSS compatibility interprets your SCSS code differently.</p> <p>If you happen to directly use scssphp in your PHP code, you should be aware that scssphp deprecated the use of the <code>compile()</code> method, non-UTF-8 processing and also adjusted the handling of pure PHP values for variable handling.</p> <p>Refer to WoltLab/WCF#4345 and the scssphp releases for details.</p>"},{"location":"migration/wsc54/libraries/#emogrifier-css-inliner","title":"Emogrifier / CSS Inliner","text":"<p>The Emogrifier library was updated from version 5.0 to 6.0.</p>"},{"location":"migration/wsc54/libraries/#codemirror","title":"CodeMirror","text":"<p>CodeMirror, the code editor we use for editing templates and SCSS, for example, has been updated to version 5.61.1 and we now also deliver all supported languages/modes. To properly support all languages/modes, CodeMirror is now loaded via the AMD module loader, which requires the original structure of the CodeMirror package, i.e. <code>codemirror.js</code> being in a <code>lib</code> folder. To preserve backward-compatibility, we also keep copies of <code>codemirror.js</code> and <code>codemirror.css</code> in version 5.61.1 directly in <code>js/3rdParty/codemirror</code>. These files are, however, considered deprecated and you should migrate to using <code>require()</code> (see <code>codemirror</code> ACP template).</p> <p>See WoltLab/WCF#4277 for details.</p>"},{"location":"migration/wsc54/libraries/#zendprogressbar","title":"Zend/ProgressBar","text":"<p>The old bundled version of Zend/ProgressBar was replaced by a current version of laminas-progressbar.</p> <p>Due to laminas-zendframework-bridge this update is a drop-in replacement. Existing code should continue to work as-is.</p> <p>It is recommended to cleanly migrate to laminas-progressbar to allow for a future removal of the bridge. Updating the <code>use</code> imports should be sufficient to switch to the laminas-progressbar.</p> <p>See WoltLab/WCF#4460 for details.</p>"},{"location":"migration/wsc54/php/","title":"Migrating from WoltLab Suite 5.4 - PHP","text":""},{"location":"migration/wsc54/php/#initial-psr-7-support","title":"Initial PSR-7 support","text":"<p>WoltLab Suite will incrementally add support for object oriented request/response handling based off the PSR-7 and PSR-15 standards in the upcoming versions.</p> <p>WoltLab Suite 5.5 adds initial support by allowing to define the response using objects implementing the PSR-7 <code>ResponseInterface</code>. If a controller returns such a response object from its <code>__run()</code> method, this response will automatically emitted to the client.</p> <p>Any PSR-7 implementation is supported, but WoltLab Suite 5.5 ships with laminas-diactoros as the recommended \u201cbatteries included\u201d implementation of PSR-7.</p> <p>Support for PSR-7 requests and PSR-15 middlewares is expected to follow in future versions.</p> <p>See WoltLab/WCF#4437 for details.</p>"},{"location":"migration/wsc54/php/#recommended-changes-for-woltlab-suite-55","title":"Recommended changes for WoltLab Suite 5.5","text":"<p>With the current support in WoltLab Suite 5.5 it is recommended to migrate the <code>*Action</code> classes to make use of PSR-7 responses. Control and data flow is typically fairly simple in <code>*Action</code> classes with most requests ending up in either a redirect or a JSON response, commonly followed by a call to <code>exit;</code>.</p> <p>Experimental support for <code>*Page</code> and <code>*Form</code> is available. It is recommended to wait for a future version before migrating these types of controllers.</p>"},{"location":"migration/wsc54/php/#migrating-redirects","title":"Migrating Redirects","text":"<p>Previously:</p> lib/action/ExampleRedirectAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse wcf\\system\\request\\LinkHandler;\nuse wcf\\util\\HeaderUtil;\n\nfinal class ExampleRedirectAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n // Redirect to the landing page.\n HeaderUtil::redirect(\n LinkHandler::getInstance()->getLink()\n );\n\n exit;\n }\n}\n</code></pre> <p>Now:</p> lib/action/ExampleRedirectAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse Laminas\\Diactoros\\Response\\RedirectResponse;\nuse wcf\\system\\request\\LinkHandler;\n\nfinal class ExampleRedirectAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n // Redirect to the landing page.\n return new RedirectResponse(\n LinkHandler::getInstance()->getLink()\n );\n }\n}\n</code></pre>"},{"location":"migration/wsc54/php/#migrating-json-responses","title":"Migrating JSON responses","text":"<p>Previously:</p> lib/action/ExampleJsonAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse wcf\\util\\JSON;\n\nfinal class ExampleJsonAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n \\header('Content-type: application/json; charset=UTF-8');\n\n echo JSON::encode([\n 'foo' => 'bar',\n ]);\n\n exit;\n }\n}\n</code></pre> <p>Now:</p> lib/action/ExampleJsonAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse Laminas\\Diactoros\\Response\\JsonResponse;\n\nfinal class ExampleJsonAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n return new JsonResponse([\n 'foo' => 'bar',\n ]);\n }\n}\n</code></pre>"},{"location":"migration/wsc54/php/#events","title":"Events","text":"<p>Historically, events were tightly coupled with a single class, with the event object being an object of this class, expecting the event listener to consume public properties and method of the event object. The <code>$parameters</code> array was introduced due to limitations of this pattern, avoiding moving all the values that might be of interest to the event listener into the state of the object. Events were still tightly coupled with the class that fired the event and using the opaque parameters array prevented IDEs from assisting with autocompletion and typing.</p> <p>WoltLab Suite 5.5 introduces the concept of dedicated, reusable event classes. Any newly introduced event will receive a dedicated class, implementing the <code>wcf\\system\\event\\IEvent</code> interface. These event classes may be fired from multiple locations, making them reusable to convey that a conceptual action happened, instead of a specific class doing something. An example for using the new event system could be a user logging in: Instead of listening on a the login form being submitted and the Facebook login action successfully running, an event <code>UserLoggedIn</code> might be fired whenever a user logs in, no matter how the login is performed.</p> <p>Additionally, these dedicated event classes will benefit from full IDE support. All the relevant values may be stored as real properties on the event object.</p> <p>Event classes should not have an <code>Event</code> suffix and should be stored in an <code>event</code> namespace in a matching location. Thus, the <code>UserLoggedIn</code> example might have a FQCN of <code>\\wcf\\system\\user\\authentication\\event\\UserLoggedIn</code>.</p> <p>Event listeners for events implementing <code>IEvent</code> need to follow PSR-14, i.e. they need to be callable. In practice, this means that the event listener class needs to implement <code>__invoke()</code>. No interface has to be implemented in this case.</p> <p>Previously:</p> <pre><code>$parameters = [\n 'value' => \\random_int(1, 1024),\n];\n\nEventHandler::getInstance()->fireAction($this, 'valueAvailable', $parameters);\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\form\\ValueForm;\n\nfinal class ValueDumpListener implements IParameterizedEventListener\n{\n /**\n * @inheritDoc\n * @param ValueForm $eventObj\n */\n public function execute($eventObj, $className, $eventName, array &$parameters)\n {\n var_dump($parameters['value']);\n }\n}\n</code></pre> <p>Now:</p> <pre><code>EventHandler::getInstance()->fire(new ValueAvailable(\\random_int(1, 1024)));\n</code></pre> lib/system/foo/event/ValueAvailable.class.php<pre><code><?php\n\nnamespace wcf\\system\\foo\\event;\n\nuse wcf\\system\\event\\IEvent;\n\nfinal class ValueAvailable implements IEvent\n{\n /**\n * @var int\n */\n private $value;\n\n public function __construct(int $value)\n {\n $this->value = $value;\n }\n\n public function getValue(): int\n {\n return $this->value;\n }\n}\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\system\\foo\\event\\ValueAvailable;\n\nfinal class ValueDumpListener\n{\n public function __invoke(ValueAvailable $event): void\n {\n \\var_dump($event->getValue());\n }\n}\n</code></pre> <p>See WoltLab/WCF#4000 and WoltLab/WCF#4265 for details.</p>"},{"location":"migration/wsc54/php/#authentication","title":"Authentication","text":"<p>The <code>UserLoggedIn</code> event was added. You should fire this event if you implement a custom login process (e.g. when adding additional external authentication providers).</p> <p>Example:</p> <pre><code>EventHandler::getInstance()->fire(\n new UserLoggedIn($user)\n);\n</code></pre> <p>See WoltLab/WCF#4356 for details.</p>"},{"location":"migration/wsc54/php/#embedded-objects-in-comments","title":"Embedded Objects in Comments","text":"<p>WoltLab/WCF#4275 added support for embedded objects like mentions for comments and comment responses. To properly render embedded objects whenever you are using comments in your packages, you have to use <code>ViewableCommentList</code>/<code>ViewableCommentResponseList</code> in these places or <code>ViewableCommentRuntimeCache</code>/<code>ViewableCommentResponseRuntimeCache</code>.</p>"},{"location":"migration/wsc54/php/#emails","title":"Emails","text":""},{"location":"migration/wsc54/php/#mailbox","title":"Mailbox","text":"<p>The <code>Mailbox</code> and <code>UserMailbox</code> classes no longer store the passed <code>Language</code> and <code>User</code> objects, but the respective ID instead. This change reduces the size of the serialized email when stored in the background queue.</p> <p>If you inherit from the <code>Mailbox</code> or <code>UserMailbox</code> classes, you might experience issues if you directly access the <code>$this->language</code> or <code>$this->user</code> properties. Adjust your class to use composition instead of inheritance if possible. Use the <code>getLanguage()</code> or <code>getUser()</code> getters if using composition is not possible.</p> <p>See WoltLab/WCF#4389 for details.</p>"},{"location":"migration/wsc54/php/#smtp","title":"SMTP","text":"<p>The <code>SmtpEmailTransport</code> no longer supports a value of <code>may</code> for the <code>$starttls</code> property.</p> <p>Using the <code>may</code> value is unsafe as it allows for undetected MITM attacks. The use of <code>encrypt</code> is recommended, unless it is certain that the SMTP server does not support TLS.</p> <p>See WoltLab/WCF#4398 for details.</p>"},{"location":"migration/wsc54/php/#search","title":"Search","text":""},{"location":"migration/wsc54/php/#search-form","title":"Search Form","text":"<p>After the overhaul of the search form, search providers are no longer bound to <code>SearchForm</code> and <code>SearchResultPage</code>. The interface <code>ISearchObjectType</code> and the abstract implementation <code>AbstractSearchableObjectType</code> have been replaced by <code>ISearchProvider</code> and <code>AbstractSearchProvider</code>.</p> <p>Please use <code>ArticleSearch</code> as a template for your own implementation</p> <p>See WoltLab/WCF#4605 for details.</p>"},{"location":"migration/wsc54/php/#exceptions","title":"Exceptions","text":"<p>A new <code>wcf\\system\\search\\exception\\SearchFailed</code> exception was added. This exception should be thrown when executing the search query fails for (mostly) temporary reasons, such as a network partition to a remote service. It is not meant as a blanket exception to wrap everything. For example it must not be returned obvious programming errors, such as an access to an undefined variable (<code>ErrorException</code>).</p> <p>Catching the <code>SearchFailed</code> exception allows consuming code to gracefully handle search requests that are not essential for proceeding, without silencing other types of error.</p> <p>See WoltLab/WCF#4476 and WoltLab/WCF#4483 for details.</p>"},{"location":"migration/wsc54/php/#package-installation-plugins","title":"Package Installation Plugins","text":""},{"location":"migration/wsc54/php/#database","title":"Database","text":"<p>WoltLab Suite 5.5 changes the factory classes for common configurations of database columns within the PHP-based DDL API to contain a private constructor, preventing object creation.</p> <p>This change affects the following classes:</p> <ul> <li><code>DefaultFalseBooleanDatabaseTableColumn</code></li> <li><code>DefaultTrueBooleanDatabaseTableColumn</code></li> <li><code>NotNullInt10DatabaseTableColumn</code></li> <li><code>NotNullVarchar191DatabaseTableColumn</code></li> <li><code>NotNullVarchar255DatabaseTableColumn</code></li> <li> <p><code>ObjectIdDatabaseTableColumn</code></p> </li> <li> <p><code>DatabaseTablePrimaryIndex</code></p> </li> </ul> <p>The static <code>create()</code> method never returned an object of the factory class, but instead in object of the base type (e.g. <code>IntDatabaseTableColumn</code> for <code>NotNullInt10DatabaseTableColumn</code>). Constructing an object of these factory classes is considered a bug, as the class name implies a specific column configuration, that might or might not hold if the object is modified afterwards.</p> <p>See WoltLab/WCF#4564 for details.</p> <p>WoltLab Suite 5.5 adds the <code>IDefaultValueDatabaseTableColumn</code> interface which is used to check whether specifying a default value is legal. For backwards compatibility this interface is implemented by <code>AbstractDatabaseTableColumn</code>. You should explicitly add this interface to custom table column type classes to avoid breakage if the interface is removed from <code>AbstractDatabaseTableColumn</code> in a future version. Likewise you should explicitly check for the interface before attempting to access the methods related to the default value of a column.</p> <p>See WoltLab/WCF#4733 for details.</p>"},{"location":"migration/wsc54/php/#file-deletion","title":"File Deletion","text":"<p>Three new package installation plugins have been added to delete ACP templates with acpTemplateDelete, files with fileDelete, and templates with templateDelete.</p>"},{"location":"migration/wsc54/php/#language","title":"Language","text":"<p>WoltLab/WCF#4261 has added support for deleting existing phrases with the <code>language</code> package installation plugin.</p> <p>The current structure of the language XML files</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\" languagename=\"English\" countrycode=\"gb\">\n <category name=\"wcf.foo\">\n <item name=\"wcf.foo.bar\"><![CDATA[Bar]]></item>\n </category>\n</language>\n</code></pre> <p>is deprecated and should be replaced with the new structure with an explicit <code><import></code> element like in the other package installation plugins:</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\" languagename=\"English\" countrycode=\"gb\">\n <import>\n <category name=\"wcf.foo\">\n <item name=\"wcf.foo.bar\"><![CDATA[Bar]]></item>\n </category>\n </import>\n</language>\n</code></pre> <p>Additionally, to now also support deleting phrases with this package installation plugin, support for a <code><delete></code> element has been added:</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\" languagename=\"English\" countrycode=\"gb\">\n <import>\n <category name=\"wcf.foo\">\n <item name=\"wcf.foo.bar\"><![CDATA[Bar]]></item>\n </category>\n </import>\n <delete>\n <item name=\"wcf.foo.barrr\"/>\n </delete>\n</language>\n</code></pre> <p>Note that when deleting phrases, the category does not have to be specified because phrase identifiers are unique globally.</p> <p>Mixing the old structure and the new structure is not supported and will result in an error message during the import!</p>"},{"location":"migration/wsc54/php/#board-and-thread-subscriptions","title":"Board and Thread Subscriptions","text":"<p>WoltLab Suite Forum 5.5 updates the subscription logic for boards and threads to properly support the ignoring of threads. See the dedicated migration guide for details.</p>"},{"location":"migration/wsc54/php/#miscellaneous-changes","title":"Miscellaneous Changes","text":""},{"location":"migration/wsc54/php/#view-counters","title":"View Counters","text":"<p>With WoltLab Suite 5.5 it is expected that view/download counters do not increase for disabled content.</p> <p>See WoltLab/WCF#4374 for details.</p>"},{"location":"migration/wsc54/php/#form-builder","title":"Form Builder","text":"<ul> <li><code>ValueIntervalFormFieldDependency</code></li> <li><code>ColorFormField</code></li> <li><code>MultipleBoardSelectionFormField</code></li> </ul>"},{"location":"migration/wsc54/templates/","title":"Migrating from WoltLab Suite 5.4 - Templates","text":""},{"location":"migration/wsc54/templates/#content-interaction-buttons","title":"Content Interaction Buttons","text":"<p>Content interactions buttons are a new way to display action buttons at the top of the page. They are intended to replace the icons in <code>pageNavigationIcons</code> for better accessibility while reducing the amount of buttons in <code>contentHeaderNavigation</code>.</p> <p>As a rule of thumb, there should be at most only one button in <code>contentHeaderNavigation</code> (primary action on this page) and three buttons in <code>contentInteractionButtons</code> (important actions on this page). Use <code>contentInteractionDropdownItems</code> for all other buttons.</p> <p>The template <code>contentInteraction</code> is included in the header and the corresponding placeholders are thus available on every page.</p> <p>See WoltLab/WCF#4315 for details.</p>"},{"location":"migration/wsc54/templates/#phrase-modifier","title":"Phrase Modifier","text":"<p>The <code>|language</code> modifier was added to allow the piping of the phrase through other functions. This has some unwanted side effects when used with plain strings that should not support variable interpolation. Another difference to <code>{lang}</code> is the evaluation on runtime rather than at compile time, allowing the phrase to be taken from a variable instead.</p> <p>We introduces the new modifier <code>|phrase</code> as a thin wrapper around <code>\\wcf\\system::WCF::getLanguage()->get()</code>. Use <code>|phrase</code> instead of <code>|language</code> unless you want to explicitly allow template scripting on a variable's output.</p> <p>See WoltLab/WCF#4657 for details.</p>"},{"location":"migration/wsc55/deprecations_removals/","title":"Migrating from WoltLab Suite 5.5 - Deprecations and Removals","text":"<p>With version 6.0, we have deprecated certain components and removed several other components that have been deprecated for many years.</p>"},{"location":"migration/wsc55/deprecations_removals/#deprecations","title":"Deprecations","text":""},{"location":"migration/wsc55/deprecations_removals/#php","title":"PHP","text":""},{"location":"migration/wsc55/deprecations_removals/#classes","title":"Classes","text":"<ul> <li><code>wcf\\action\\AbstractDialogAction</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\SensitiveArgument</code> (WoltLab/WCF#4802)</li> <li><code>wcf\\system\\cli\\command\\IArgumentedCLICommand</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\template\\plugin\\DateModifierTemplatePlugin</code> (WoltLab/WCF#5459)</li> <li><code>wcf\\system\\template\\plugin\\TimeModifierTemplatePlugin</code> (WoltLab/WCF#5459)</li> <li><code>wcf\\system\\template\\plugin\\PlainTimeModifierTemplatePlugin</code> (WoltLab/WCF#5459)</li> <li><code>wcf\\util\\CronjobUtil</code> (WoltLab/WCF#4923)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#methods","title":"Methods","text":"<ul> <li><code>wcf\\data\\cronjob\\CronjobAction::executeCronjobs()</code> (WoltLab/WCF#5171)</li> <li><code>wcf\\data\\package\\update\\server\\PackageUpdateServer::attemptSecureConnection()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\data\\package\\update\\server\\PackageUpdateServer::isValidServerURL()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\data\\page\\Page::setAsLandingPage()</code> (WoltLab/WCF#4842)</li> <li><code>wcf\\data\\style\\Style::getRelativeFavicon()</code> (WoltLab/WCF#5201)</li> <li><code>wcf\\system\\cli\\command\\CLICommandHandler::getCommands()</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\io\\RemoteFile::disableSSL()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\system\\io\\RemoteFile::supportsSSL()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\system\\request\\RequestHandler::inRescueMode()</code> (WoltLab/WCF#4831)</li> <li><code>wcf\\system\\session\\SessionHandler::getLanguageIDs()</code> (WoltLab/WCF#4839)</li> <li><code>wcf\\system\\user\\multifactor\\webauthn\\Challenge::getOptionsAsJson()</code></li> <li><code>wcf\\system\\WCF::getActivePath()</code> (WoltLab/WCF#4827)</li> <li><code>wcf\\system\\WCF::getFavicon()</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\system\\WCF::useDesktopNotifications()</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\util\\CryptoUtil::validateSignedString()</code> (WoltLab/WCF#5083)</li> <li><code>wcf\\util\\Diff::__construct()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::__toString()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::getLCS()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::getRawDiff()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::getUnixDiff()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\StringUtil::convertEncoding()</code> (WoltLab/WCF#4800)</li> <li><code>wcf\\system\\bbcode\\AttachmentBBCode::setAttachmentList()</code> (WoltLab/WCF#5587)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#properties","title":"Properties","text":""},{"location":"migration/wsc55/deprecations_removals/#constants","title":"Constants","text":"<ul> <li><code>wcf\\system\\condition\\UserAvatarCondition::GRAVATAR</code> (WoltLab/WCF#4929)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#functions","title":"Functions","text":""},{"location":"migration/wsc55/deprecations_removals/#options","title":"Options","text":""},{"location":"migration/wsc55/deprecations_removals/#javascript","title":"JavaScript","text":"<ul> <li><code>WCF.Comment</code> (WoltLab/WCF#5210)</li> <li><code>WCF.Location</code> (WoltLab/WCF#4972)</li> <li><code>WCF.Message.Share.Content</code> (WoltLab/WCF/commit/624b9db73daf8030aa1c3e49d4ffc785760a283f)</li> <li><code>WCF.User.ObjectWatch.Subscribe</code> (WoltLab/WCF#4962)</li> <li><code>WCF.User.List</code> (WoltLab/WCF#5039)</li> <li><code>WoltLabSuite/Core/Controller/Map/Route/Planner</code> (WoltLab/WCF#4972)</li> <li><code>WoltLabSuite/Core/NumberUtil</code> (WoltLab/WCF#5071)</li> <li><code>WoltLabSuite/Core/Ui/User/List</code> (WoltLab/WCF#5039)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#database-tables","title":"Database Tables","text":""},{"location":"migration/wsc55/deprecations_removals/#templates","title":"Templates","text":"<ul> <li><code>__commentJavaScript</code> (WoltLab/WCF#5210)</li> <li><code>commentListAddComment</code> (WoltLab/WCF#5210)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-modifiersfunctions","title":"Template Modifiers/Functions","text":"<ul> <li><code>|date</code> (WoltLab/WCF#5459)</li> <li><code>|time</code> (WoltLab/WCF#5459)</li> <li><code>|plainTime</code> (WoltLab/WCF#5459)</li> <li><code>{pages}</code> (WoltLab/WCF#5158)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-events","title":"Template Events","text":""},{"location":"migration/wsc55/deprecations_removals/#miscellaneous","title":"Miscellaneous","text":""},{"location":"migration/wsc55/deprecations_removals/#removals","title":"Removals","text":""},{"location":"migration/wsc55/deprecations_removals/#php_1","title":"PHP","text":""},{"location":"migration/wsc55/deprecations_removals/#classes_1","title":"Classes","text":"<ul> <li><code>calendar\\data\\CALENDARDatabaseObject</code></li> <li><code>calendar\\system\\image\\EventDataHandler</code></li> <li><code>gallery\\data\\GalleryDatabaseObject</code></li> <li><code>gallery\\system\\image\\ImageDataHandler</code></li> <li><code>wbb\\system\\user\\object\\watch\\BoardUserObjectWatch</code> and the corresponding object type</li> <li><code>wbb\\system\\user\\object\\watch\\ThreadUserObjectWatch</code> and the corresponding object type</li> <li><code>wcf\\acp\\form\\ApplicationEditForm</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\action\\GravatarDownloadAction</code> (WoltLab/WCF#4929)</li> <li><code>wcf\\data\\user\\avatar\\Gravatar</code> (WoltLab/WCF#4929)</li> <li><code>wcf\\system\\bbcode\\highlighter\\*Highlighter</code> (WoltLab/WCF#4926)</li> <li><code>wcf\\system\\bbcode\\highlighter\\Highlighter</code> (WoltLab/WCF#4926)</li> <li><code>wcf\\system\\cache\\source\\MemcachedCacheSource</code> (WoltLab/WCF#4928)</li> <li><code>wcf\\system\\cli\\command\\CLICommandNameCompleter</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\cli\\command\\CommandsCLICommand</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\cli\\command\\CronjobCLICommand</code> (WoltLab/WCF#5171)</li> <li><code>wcf\\system\\cli\\command\\HelpCLICommand</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\cli\\command\\PackageCLICommand</code> (WoltLab/WCF#4946)</li> <li><code>wcf\\system\\cli\\DatabaseCLICommandHistory</code> (WoltLab/WCF#5058)</li> <li><code>wcf\\system\\database\\table\\column/\\UnsupportedDefaultValue</code> (WoltLab/WCF#5012)</li> <li><code>wcf\\system\\exception\\ILoggingAwareException</code> (and associated functionality) (WoltLab/WCF#5086)</li> <li><code>wcf\\system\\mail\\Mail</code> (WoltLab/WCF#4941)</li> <li><code>wcf\\system\\option\\DesktopNotificationApplicationSelectOptionType</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchException</code></li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#methods_1","title":"Methods","text":"<ul> <li>The <code>$forceHTTP</code> parameter of <code>wcf\\data\\package\\update\\server\\PackageUpdateServer::getListURL()</code> (WoltLab/WCF#4790)</li> <li>The <code>$forceHTTP</code> parameter of <code>wcf\\system\\package\\PackageUpdateDispatcher::getPackageUpdateXML()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\data\\bbcode\\BBCodeCache::getHighlighters()</code> (WoltLab/WCF#4926)</li> <li><code>wcf\\data\\conversation\\ConversationAction::getMixedConversationList()</code> (WoltLab/com.woltlab.wcf.conversation#176)</li> <li><code>wcf\\data\\moderation\\queue\\ModerationQueueAction::getOutstandingQueues()</code> (WoltLab/WCF#4944)</li> <li><code>wcf\\data\\package\\installation\\queue\\PackageInstallationQueueAction::prepareQueue()</code> (WoltLab/WCF#4997)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatarAction::enforceDimensions()</code> (WoltLab/WCF#5007)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatarAction::fetchRemoteAvatar()</code> (WoltLab/WCF#5007)</li> <li><code>wcf\\data\\user\\notification\\UserNotificationAction::getOustandingNotifications()</code> (WoltLab/WCF#4944)</li> <li><code>wcf\\data\\user\\UserRegistrationAction::validatePassword()</code> (WoltLab/WCF#5244)</li> <li><code>wcf\\system\\bbcode\\BBCodeParser::getRemoveLinks()</code> (WoltLab/WCF#4986)</li> <li><code>wcf\\system\\bbcode\\HtmlBBCodeParser::setRemoveLinks()</code> (WoltLab/WCF#4986)</li> <li><code>wcf\\system\\html\\output\\node\\AbstractHtmlOutputNode::setRemoveLinks()</code> (WoltLab/WCF#4986)</li> <li><code>wcf\\system\\package\\PackageArchive::downloadArchive()</code> (WoltLab/WCF#5006)</li> <li><code>wcf\\system\\package\\PackageArchive::filterUpdateInstructions()</code> (WoltLab/WCF#5129)</li> <li><code>wcf\\system\\package\\PackageArchive::getAllExistingRequirements()</code> (WoltLab/WCF#5125)</li> <li><code>wcf\\system\\package\\PackageArchive::getInstructions()</code> (WoltLab/WCF#5120)</li> <li><code>wcf\\system\\package\\PackageArchive::getUpdateInstructions()</code> (WoltLab/WCF#5129)</li> <li><code>wcf\\system\\package\\PackageArchive::isValidInstall()</code> (WoltLab/WCF#5125)</li> <li><code>wcf\\system\\package\\PackageArchive::isValidUpdate()</code> (WoltLab/WCF#5126)</li> <li><code>wcf\\system\\package\\PackageArchive::setPackage()</code> (WoltLab/WCF#5120)</li> <li><code>wcf\\system\\package\\PackageArchive::unzipPackageArchive()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::checkPackageInstallationQueue()</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::completeSetup()</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::convertShorthandByteValue()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::functionExists()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::openQueue()</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::validatePHPRequirements()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationNodeBuilder::insertNode()</code> (WoltLab/WCF#4997)</li> <li><code>wcf\\system\\package\\PackageUpdateDispatcher::prepareInstallation()</code> (WoltLab/WCF#4997)</li> <li><code>wcf\\system\\request\\Request::execute()</code> (WoltLab/WCF#4820)</li> <li><code>wcf\\system\\request\\Request::getPageType()</code> (WoltLab/WCF#4822)</li> <li><code>wcf\\system\\request\\Request::getPageType()</code> (WoltLab/WCF#4822)</li> <li><code>wcf\\system\\request\\Request::isExecuted()</code></li> <li><code>wcf\\system\\request\\Request::setIsLandingPage()</code></li> <li><code>wcf\\system\\request\\RouteHandler::getDefaultController()</code> (WoltLab/WCF#4832)</li> <li><code>wcf\\system\\request\\RouteHandler::loadDefaultControllers()</code> (WoltLab/WCF#4832)</li> <li><code>wcf\\system\\search\\AbstractSearchEngine::getFulltextMinimumWordLength()</code> (WoltLab/WCF#4933)</li> <li><code>wcf\\system\\search\\AbstractSearchEngine::parseSearchQuery()</code> (WoltLab/WCF#4933)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchEngine::getFulltextMinimumWordLength()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::query()</code></li> <li><code>wcf\\system\\search\\SearchIndexManager::add()</code> (WoltLab/WCF#4925)</li> <li><code>wcf\\system\\search\\SearchIndexManager::update()</code> (WoltLab/WCF#4925)</li> <li><code>wcf\\system\\session\\SessionHandler::getStyleID()</code> (WoltLab/WCF#4837)</li> <li><code>wcf\\system\\session\\SessionHandler::setStyleID()</code> (WoltLab/WCF#4837)</li> <li><code>wcf\\system\\CLIWCF::checkForUpdates()</code> (WoltLab/WCF#5058)</li> <li><code>wcf\\system\\WCFACP::checkMasterPassword()</code> (WoltLab/WCF#4977)</li> <li><code>wcf\\system\\WCFACP::getFrontendMenu()</code> (WoltLab/WCF#4812)</li> <li><code>wcf\\system\\WCFACP::initPackage()</code> (WoltLab/WCF#4794)</li> <li><code>wcf\\util\\CryptoUtil::randomBytes()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\CryptoUtil::randomInt()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\CryptoUtil::secureCompare()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\FileUtil::downloadFileFromHttp()</code> (WoltLab/WCF#4942)</li> <li><code>wcf\\util\\PasswordUtil::secureCompare()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\PasswordUtil::secureRandomNumber()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\StringUtil::encodeJSON()</code> (WoltLab/WCF#5073)</li> <li><code>wcf\\util\\StyleUtil::updateStyleFile()</code> (WoltLab/WCF#4977)</li> <li><code>wcf\\util\\UserRegistrationUtil::isSecurePassword()</code> (WoltLab/WCF#4977)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#properties_1","title":"Properties","text":"<ul> <li><code>wcf\\acp\\form\\PageAddForm::$isLandingPage</code> (WoltLab/WCF#4842)</li> <li><code>wcf\\system\\appliation\\ApplicationHandler::$isMultiDomain</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\system\\package\\PackageArchive::$package</code> (WoltLab/WCF#5129)</li> <li><code>wcf\\system\\request\\RequestHandler::$inRescueMode</code> (WoltLab/WCF#4831)</li> <li><code>wcf\\system\\request\\RouteHandler::$defaultControllers</code> (WoltLab/WCF#4832)</li> <li><code>wcf\\system\\template\\TemplateScriptingCompiler::$disabledPHPFunctions</code> (WoltLab/WCF#4788)</li> <li><code>wcf\\system\\template\\TemplateScriptingCompiler::$enterpriseFunctions</code> (WoltLab/WCF#4788)</li> <li><code>wcf\\system\\WCF::$forceLogout</code> (WoltLab/WCF#4799)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#events","title":"Events","text":"<ul> <li><code>beforeArgumentParsing@wcf\\system\\CLIWCF</code> (WoltLab/WCF#5058)</li> <li><code>afterArgumentParsing@wcf\\system\\CLIWCF</code> (WoltLab/WCF#5058)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#constants_1","title":"Constants","text":"<ul> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::DELETE</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::GET</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::POST</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::PUT</code></li> <li><code>PACKAGE_NAME</code> (WoltLab/WCF#5006)</li> <li><code>PACKAGE_VERSION</code> (WoltLab/WCF#5006)</li> <li><code>SECURITY_TOKEN_INPUT_TAG</code> (WoltLab/WCF#4934)</li> <li><code>SECURITY_TOKEN</code> (WoltLab/WCF#4934)</li> <li><code>WSC_API_VERSION</code> (WoltLab/WCF#4943)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#functions_1","title":"Functions","text":"<ul> <li>The global <code>escapeString</code> helper (WoltLab/WCF#5085)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#options_1","title":"Options","text":"<ul> <li><code>CACHE_SOURCE_MEMCACHED_HOST</code> (WoltLab/WCF#4928)</li> <li><code>DESKTOP_NOTIFICATION_PACKAGE_ID</code> (WoltLab/WCF#4785)</li> <li><code>GRAVATAR_DEFAULT_TYPE</code> (WoltLab/WCF#4929)</li> <li><code>HTTP_SEND_X_FRAME_OPTIONS</code> (WoltLab/WCF#4786)</li> <li><code>MODULE_GRAVATAR</code> (WoltLab/WCF#4929)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#files","title":"Files","text":"<ul> <li>The <code>scss.inc.php</code> compatibility include. (WoltLab/WCF#4932)</li> <li>The <code>config.inc.php</code> in app directories. (WoltLab/WCF#5006)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#javascript_1","title":"JavaScript","text":"<ul> <li><code>Blog.Blog.Archive</code></li> <li><code>Blog.Category.MarkAllAsRead</code></li> <li><code>Blog.Entry.Delete</code></li> <li><code>Blog.Entry.Preview</code></li> <li><code>Blog.Entry.QuoteHandler</code></li> <li><code>Calendar.Category.MarkAllAsRead</code> (WoltLab/com.woltlab.calendar#169)</li> <li><code>Calendar.Event.Coordinates</code></li> <li><code>Calendar.Event.Date.FullDay</code> (WoltLab/com.woltlab.calendar#171)</li> <li><code>Calendar.Event.Date.Participation.RemoveParticipant</code></li> <li><code>Calendar.Event.Preview</code></li> <li><code>Calendar.Event.QuoteHandler</code></li> <li><code>Calendar.Event.Share</code></li> <li><code>Calendar.Event.TabMenu</code></li> <li><code>Calendar.Event.Thread.ShowParticipants</code></li> <li><code>Calendar.Map</code></li> <li><code>Calendar.UI.Calendar</code></li> <li><code>Calendar/Ui/Event/Date/Cancel.js</code></li> <li><code>Calendar.Export.iCal</code></li> <li><code>Filebase.Category.MarkAllAsRead</code></li> <li><code>Filebase.File.MarkAsRead</code></li> <li><code>Filebase.File.Preview</code></li> <li><code>Filebase.File.Share</code></li> <li><code>flexibleArea.js</code> (WoltLab/WCF#4945)</li> <li><code>Gallery.Album.Share</code></li> <li><code>Gallery.Category.MarkAllAsRead</code></li> <li><code>Gallery.Image.Delete</code></li> <li><code>Gallery.Image.Share</code></li> <li><code>Gallery.Map.LargeMap</code></li> <li><code>Gallery.Map.InfoWindowImageListDialog</code></li> <li><code>jQuery.browser.smartphone</code> (WoltLab/WCF#4945)</li> <li><code>Prism.wscSplitIntoLines</code> (WoltLab/WCF#4940)</li> <li><code>SID_ARG_2ND</code> (WoltLab/WCF#4998)</li> <li><code>WBB.Board.Collapsible</code></li> <li><code>WBB.Board.IgnoreBoards</code></li> <li><code>WBB.Post.IPAddressHandler</code></li> <li><code>WBB.Post.Preview</code></li> <li><code>WBB.Post.QuoteHandler</code></li> <li><code>WBB.Thread.LastPageHandler</code></li> <li><code>WBB.Thread.SimilarThreads</code></li> <li><code>WBB.Thread.UpdateHandler.Thread</code></li> <li><code>WBB.Thread.WatchedThreadList</code></li> <li><code>WCF.Action.Scroll</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Comment</code> (WoltLab/WCF@00d46429)</li> <li><code>WCF.Conversation.MarkAllAsRead</code></li> <li><code>WCF.Conversation.MarkAsRead</code></li> <li><code>WCF.Conversation.Message.QuoteHandler</code></li> <li><code>WCF.Conversation.Preview</code></li> <li><code>WCF.Conversation.RemoveParticipant</code></li> <li><code>WCF.Date.Picker</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Date.Util</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Dropdown.Interactive.Handler</code> (WoltLab/WCF#4944)</li> <li><code>WCF.Dropdown.Interactive.Instance</code> (WoltLab/WCF#4944)</li> <li><code>WCF.Label.ACPList</code></li> <li><code>WCF.Message.Share.Page</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Message.Smilies</code> (WoltLab/WCF#4945)</li> <li><code>WCF.ModeratedUserGroup.AddMembers</code></li> <li><code>WCF.Moderation.Queue.MarkAllAsRead</code></li> <li><code>WCF.Moderation.Queue.MarkAsRead</code></li> <li><code>WCF.Poll</code> (WoltLab/WCF#5465)</li> <li><code>WCF.Search.Message.KeywordList</code> (WoltLab/WCF#4945)</li> <li><code>WCF.System.FlexibleMenu</code> (WoltLab/WCF#4945)</li> <li><code>WCF.System.Fullscreen</code> (WoltLab/WCF#4945)</li> <li><code>WCF.System.PageNavigation</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Template</code> (WoltLab/WCF#5070)</li> <li><code>WCF.ToggleOptions</code> (WoltLab/WCF#4945)</li> <li><code>WCF.User.LikeLoader</code></li> <li><code>WCF.User.Panel.Abstract</code> (WoltLab/WCF#4944)</li> <li><code>WCF.User.ProfilePreview</code></li> <li><code>WCF.User.Registration.Validation.Password</code> (WoltLab/WCF#5244)</li> <li><code>window.shuffle()</code> (WoltLab/WCF#4945)</li> <li><code>WSC_API_VERSION</code> (WoltLab/WCF#4943)</li> <li><code>WCF.Infraction.Warning.ShowDetails</code></li> <li><code>WoltLabSuite/Core/Ui/Comment/Add</code> (WoltLab/WCF#5210)</li> <li><code>WoltLabSuite/Core/Ui/Comment/Edit</code> (WoltLab/WCF#5210)</li> <li><code>WoltLabSuite/Core/Ui/Response/Comment/Add</code> (WoltLab/WCF#5210)</li> <li><code>WoltLabSuite/Core/Ui/Response/Comment/Edit</code> (WoltLab/WCF#5210)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#database","title":"Database","text":"<ul> <li><code>wcf1_cli_history</code> (WoltLab/WCF#5058)</li> <li><code>wcf1_package_compatibility</code> (WoltLab/WCF#4992)</li> <li><code>wcf1_package_update_compatibility</code> (WoltLab/WCF#5005)</li> <li><code>wcf1_package_update_optional</code> (WoltLab/WCF#5005)</li> <li><code>wcf1_user_notification_to_user</code> (WoltLab/WCF#5005)</li> <li><code>wcf1_user.enableGravatar</code> (WoltLab/WCF#4929)</li> <li><code>wcf1_user.gravatarFileExtension</code> (WoltLab/WCF#4929)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#templates_1","title":"Templates","text":""},{"location":"migration/wsc55/deprecations_removals/#templates_2","title":"Templates","text":"<ul> <li><code>conversationListUserPanel</code> (WoltLab/com.woltlab.wcf.conversation#176)</li> <li><code>moderationQueueList</code> (WoltLab/WCF#4944)</li> <li><code>notificationListUserPanel</code> (WoltLab/WCF#4944)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-plugins","title":"Template Plugins","text":"<ul> <li><code>{fetch}</code> (WoltLab/WCF#4892)</li> <li><code>|encodeJSON</code> (WoltLab/WCF#5073)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-events_1","title":"Template Events","text":"<ul> <li><code>headInclude::javascriptInclude</code> (WoltLab/WCF#4801)</li> <li><code>headInclude::javascriptInit</code> (WoltLab/WCF#4801)</li> <li><code>headInclude::javascriptLanguageImport</code> (WoltLab/WCF#4801)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-variables","title":"Template Variables","text":"<ul> <li><code>$__sessionKeepAlive</code> (WoltLab/WCF#5055)</li> <li><code>$__wcfVersion</code> (WoltLab/WCF#4927)</li> <li><code>$tpl.cookie</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.env</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.get</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.now</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.post</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.server</code> (WoltLab/WCF@7cfd5578ede22e)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#miscellaneous_1","title":"Miscellaneous","text":"<ul> <li>The use of a non-<code>1</code> <code>WCF_N</code> in WCFSetup. (WoltLab/WCF#4791)</li> <li>The global option to set a specific style with a request parameter (<code>$_REQUEST['styleID']</code>) is removed. (WoltLab/WCF#4533)</li> <li>Using non-standard ports for package servers is no longer supported. (WoltLab/WCF#4790)</li> <li>Using the insecure <code>http://</code> scheme for package servers is no longer supported. The use of <code>https://</code> is enforced. (WoltLab/WCF#4790)</li> <li>The support for AMP pages was removed. (WoltLab/WCF#5425)</li> <li>The support for style API version was removed. All styles are treated as if they are fully compatible with the latest version. (WoltLab/WCF#5036)</li> </ul>"},{"location":"migration/wsc55/dialogs/","title":"Migrating from WoltLab Suite 5.5 - Dialogs","text":""},{"location":"migration/wsc55/dialogs/#the-state-of-dialogs-in-woltlab-suite-55-and-earlier","title":"The State of Dialogs in WoltLab Suite 5.5 and earlier","text":"<p>In the past dialogs have been used for all kinds of purposes, for example, to provide more details. Dialogs make it incredibly easy to add extra information or forms to an existing page without giving much thought: A simple button is all that it takes to show a dialog.</p> <p>This has lead to an abundance of dialogs that have been used in a lot of places where dialogs are not the right choice, something we are guilty of in a lot of cases. A lot of research has gone into the accessibility of dialogs and the general recommendations towards their usage and the behavior.</p> <p>One big issue of dialogs have been their inconsistent appearance in terms of form buttons and their (lack of) keyboard support for input fields. WoltLab Suite 6.0 provides a completely redesigned API that strives to make the process of creating dialogs much easier and features a consistent keyboard support out of the box.</p>"},{"location":"migration/wsc55/dialogs/#conceptual-changes","title":"Conceptual Changes","text":"<p>Dialogs are a powerful tool, but as will all things, it is easy to go overboard and eventually one starts using dialogs out of convenience rather than necessity. In general dialogs should only be used when you need to provide information out of flow, for example, for urgent error messages.</p> <p>A common misuse that we are guilty of aswell is the use of dialogs to present content. Dialogs completely interrupt whatever the user is doing and can sometimes even hide contextual relevant content on the page. It is best to embed information into regular pages and either use deep links to refer to them or make use of flyovers to present the content in place.</p> <p>Another important change is the handling of form inputs. Previously it was required to manually craft the form submit buttons, handle button clicks and implement a proper validation. The new API provides the \u201cprompt\u201d type which implements all this for you and exposing JavaScript events to validate, submit and cancel the dialog.</p> <p>Last but not least there have been updates to the visual appearance of dialogs. The new dialogs mimic the appearance on modern desktop operating systems as well as smartphones by aligning the buttons to the bottom right. In addition the order of buttons has been changed to always show the primary button on the rightmost position. These changes were made in an effort to make it easier for users to adopt an already well known control concept and to improve the overall accessibility.</p>"},{"location":"migration/wsc55/dialogs/#migrating-to-the-dialogs-of-woltlab-suite-60","title":"Migrating to the Dialogs of WoltLab Suite 6.0","text":"<p>The old dialogs are still fully supported and have remained unchanged apart from a visual update to bring them in line with the new dialogs. We do recommend that you use the new dialog API exclusively for new components and migrate the existing dialogs whenever you see it fit, we\u2019ll continue to support the legacy dialog API for the entire 6.x series at minimum.</p>"},{"location":"migration/wsc55/dialogs/#comparison-of-the-apis","title":"Comparison of the APIs","text":"<p>The legacy API relied on implicit callbacks to initialize dialogs and to handle the entire lifecycle. The <code>_dialogSetup()</code> method was complex, offered subpar auto completition support and generally became very bloated when utilizing the events.</p>"},{"location":"migration/wsc55/dialogs/#source","title":"<code>source</code>","text":"<p>The source of a dialog is provided directly through the fluent API of <code>dialogFactory()</code> which provides methods to spawn dialogs using elements, HTML strings or completely empty.</p> <p>The major change is the removal of the AJAX support as the content source, you should use <code>dboAction()</code> instead and then create the dialog.</p>"},{"location":"migration/wsc55/dialogs/#optionsonsetupcontent-htmlelement","title":"<code>options.onSetup(content: HTMLElement)</code>","text":"<p>You can now access the content element directly, because everything happens in-place.</p> <pre><code>const dialog = dialogFactory().fromHtml(\"<p>Hello World!</p>\").asAlert();\n\n// Do something with `dialog.content` or bind event listeners.\n\ndialog.show(\"My Title\");\n</code></pre>"},{"location":"migration/wsc55/dialogs/#optionsonshowcontent-htmlelement","title":"<code>options.onShow(content: HTMLElement)</code>","text":"<p>There is no equivalent in the new API, because you can simply store a reference to your dialog and access the <code>.content</code> property at any time.</p>"},{"location":"migration/wsc55/dialogs/#_dialogsubmit","title":"<code>_dialogSubmit()</code>","text":"<p>This is the most awkward feature of the legacy dialog API: Poorly documented and cumbersome to use. Implementing it required a dedicated form submit button and the keyboard interaction required the <code>data-dialog-submit-on-enter=\"true\"</code> attribute to be set on all input elements that should submit the form through <code>Enter</code>.</p> <p>The new dialog API takes advantage of the <code>form[method=\"dialog\"]</code> functionality which behaves similar to regular forms but will signal the form submit to the surrounding dialog. As a developer you only need to listen for the <code>validate</code> and the <code>primary</code> event to implement your logic.</p> <pre><code>const dialog = dialogFactory()\n .fromId(\"myComplexDialogWithFormInputs\")\n .asPrompt();\n\ndialog.addEventListener(\"validate\", (event) => {\n // Validate the form inputs in `dialog.content`.\n\n if (validationHasFailed) {\n event.preventDefault();\n }\n});\n\ndialog.addEventListener(\"primary\", () => {\n // The dialog has been successfully validated\n // and was submitted by the user.\n // You can access form inputs through `dialog.content`.\n});\n</code></pre>"},{"location":"migration/wsc55/dialogs/#changes-to-the-template","title":"Changes to the Template","text":"<p>Both the old and the new API support the use of existing elements to create dialogs. It is recommended to use <code><template></code> in this case which will never be rendered and has a well-defined role.</p> <pre><code><!-- Previous -->\n<div id=\"myDialog\" style=\"display: none\">\n <!-- \u2026 -->\n</div>\n\n<!-- Use instead -->\n<template id=\"myDialog\">\n <!-- \u2026 -->\n</template>\n</code></pre> <p>Dialogs have historically been using the same HTML markup that regular pages do, including but not limited to the use of sections. For dialogs that use only a single container it is recommend to drop the section entirely.</p> <p>If your dialog contain multiple sections it is recommended to skip the title of the first section.</p>"},{"location":"migration/wsc55/dialogs/#formsubmit","title":"<code>.formSubmit</code>","text":"<p>Form controls are no longer defined through the template, instead those are implicitly generated by the new dialog API. Please see the explanation on the four different dialog types to learn more about form controls.</p>"},{"location":"migration/wsc55/dialogs/#migration-by-example","title":"Migration by Example","text":"<p>There is no universal pattern that fits every case, because dialogs vary greatly between each other and the required functionality causes the actual implementation to be different.</p> <p>As an example we have migrated the dialog to create a new box to use the new API. It uses a prompt dialog that automagically adds form controls and fires an event once the user submits the dialog. You can find the commit 3a9210f229f6a2cf5e800c2c4536c9774d02fc86 on GitHub.</p> <p>The changes can be summed up as follows:</p> <ol> <li>Use a <code><template></code> element for the dialog content.</li> <li>Remove the <code>.formSubmit</code> section from the HTML.</li> <li>Unwrap the contents by stripping the <code>.section</code>.</li> <li>Create and store the reference to the dialog in a property for later re-use.</li> <li>Interact with the dialog\u2019s <code>.content</code> property and make use of an event listener to handle the user interaction.</li> </ol>"},{"location":"migration/wsc55/dialogs/#creating-a-dialog-using-an-id","title":"Creating a Dialog Using an ID","text":"<pre><code>_dialogSetup() {\n return {\n // \u2026\n id: \"myDialog\",\n };\n}\n</code></pre> <p>New API</p> <pre><code>dialogFactory().fromId(\"myDialog\").withoutControls();\n</code></pre>"},{"location":"migration/wsc55/dialogs/#using-source-to-provide-the-dialog-html","title":"Using <code>source</code> to Provide the Dialog HTML","text":"<pre><code>_dialogSetup() {\n return {\n // \u2026\n source: \"<p>Hello World</p>\",\n };\n}\n</code></pre> <p>New API</p> <pre><code>dialogFactory().fromHtml(\"<p>Hello World</p>\").withoutControls();\n</code></pre>"},{"location":"migration/wsc55/dialogs/#updating-the-html-when-the-dialog-is-shown","title":"Updating the HTML When the Dialog Is Shown","text":"<pre><code>_dialogSetup() {\n return {\n // \u2026\n options: {\n // \u2026\n onShow: (content) => {\n content.querySelector(\"p\")!.textContent = \"Hello World\";\n },\n },\n };\n}\n</code></pre> <p>New API</p> <pre><code>const dialog = dialogFactory().fromHtml(\"<p></p>\").withoutControls();\n\n// Somewhere later in the code\n\ndialog.content.querySelector(\"p\")!.textContent = \"Hello World\";\n\ndialog.show(\"Some Title\");\n</code></pre>"},{"location":"migration/wsc55/dialogs/#specifying-the-title-of-a-dialog","title":"Specifying the Title of a Dialog","text":"<p>The title was previously fixed in the <code>_dialogSetup()</code> method and could only be changed on runtime using the <code>setTitle()</code> method.</p> <pre><code>_dialogSetup() {\n return {\n // \u2026\n options: {\n // \u2026\n title: \"Some Title\",\n },\n };\n}\n</code></pre> <p>The title is now provided whenever the dialog should be opened, permitting changes in place.</p> <pre><code>const dialog = dialogFactory().fromHtml(\"<p></p>\").withoutControls();\n\n// Somewhere later in the code\n\ndialog.show(\"Some Title\");\n</code></pre>"},{"location":"migration/wsc55/icons/","title":"Migrating from WoltLab Suite 5.5 - Icons","text":"<p>WoltLab Suite 6.0 introduces Font Awesome 6.0 which is a major upgrade over the previously used Font Awesome 4.7 icon library. The new version features not only many hundreds of new icons but also focused a lot more on icon consistency, namely the proper alignment of icons within the grid.</p> <p>The previous implementation of Font Awesome 4 included shims for Font Awesome 3 that was used before, the most notable one being the <code>.icon</code> notation instead of <code>.fa</code> as seen in Font Awesome 4 and later. In addition, Font Awesome 5 introduced the concept of different font weights to separate icons which was further extended in Font Awesome 6.</p> <p>In WoltLab Suite 6.0 we have made the decision to make a clean cut and drop support for the Font Awesome 3 shim as well as a Font Awesome 4 shim in order to dramatically reduce the CSS size and to clean up the implementation. Brand icons had been moved to a separate font in Font Awesome 5, but since more and more fonts are being added we have stepped back from relying on that font. We have instead made the decision to embed brand icons using inline SVGs which are much more efficient when you only need a handful of brand icons instead of loading a 100kB+ font just for a few icons.</p>"},{"location":"migration/wsc55/icons/#misuse-of-icons-as-buttons","title":"Misuse of Icons as Buttons","text":"<p>One pattern that could be found every here and then was the use of icons as buttons. Using icons in buttons is fine, as long as there is a readable title and that they are properly marked as buttons.</p> <p>A common misuse looks like this:</p> <pre><code><span class=\"icon icon16 fa-times pointer jsMyDeleteButton\" data-some-object-id=\"123\"></span>\n</code></pre> <p>This example has a few problems, for starters it is not marked as a button which would require both <code>role=\"button\"</code> and <code>tabindex=\"0\"</code> to be recognized as such. Additionally there is no title which leaves users clueless about what the option does, especially visually impaired users are possibly unable to identify the icon.</p> <p>WoltLab Suite 6.0 addresses this issue by removing all default styling from <code><button></code> elements, making them the ideal choice for button type elements.</p> <pre><code><button class=\"jsMyDeleteButton\" data-some-object-id=\"123\" title=\"descriptive title here\">{icon name='xmark'}</button>\n</code></pre> <p>The icon will appear just as before, but the button is now properly accessible.</p>"},{"location":"migration/wsc55/icons/#using-css-classes-with-icons","title":"Using CSS Classes With Icons","text":"<p>It is strongly discouraged to apply CSS classes to icons themselves. Icons inherit the text color from the surrounding context which removes the need to manually apply the color.</p> <p>If you ever need to alter the icons, such as applying a special color or transformation, you should wrap the icon in an element like <code><span></code> and apply the changes to that element instead.</p>"},{"location":"migration/wsc55/icons/#using-icons-in-templates","title":"Using Icons in Templates","text":"<p>The new template function <code>{icon}</code> was added to take care of generating the HTML code for icons, including the embedded SVGs for brand icons. Icons in HTML should not be constructed using the actual HTML element, but instead always use <code>{icon}</code>.</p> <pre><code><button class=\"button\">{icon name='bell'} I\u2019m a button with a bell icon</button>\n</code></pre> <p>Unless specified the icon will attempt to use a non-solid variant of the icon if it is available. You can explicitly request a solid version of the icon by specifying it with <code>type='solid'</code>.</p> <pre><code><button class=\"button\">{icon name='bell' type='solid'} I\u2019m a button with a solid bell icon</button>\n</code></pre> <p>Icons will implicitly assume the size <code>16</code>, but you can explicitly request a different icon size using the <code>size</code> attribute:</p> <pre><code>{icon size=24 name='bell' type='solid'}\n</code></pre>"},{"location":"migration/wsc55/icons/#brand-icons","title":"Brand Icons","text":"<p>The syntax for brand icons is very similar, but you are required to specifiy parameter <code>type='brand'</code> to access them.</p> <pre><code><button class=\"button\">{icon size=16 name='facebook' type='brand'} Share on Facebook</button>\n</code></pre>"},{"location":"migration/wsc55/icons/#using-icons-in-typescriptjavascript","title":"Using Icons in TypeScript/JavaScript","text":"<p>Buttons can be dynamically created using the native <code>document.createElement()</code> using the new <code>fa-icon</code> element.</p> <pre><code>const icon = document.createElement(\"fa-icon\");\nicon.setIcon(\"bell\", true);\n\n// This is the same as the following call in templates:\n// {icon name='bell' type='solid'}\n</code></pre> <p>You can request a size other than the default value of <code>16</code> through the <code>size</code> property:</p> <pre><code>const icon = document.createElement(\"fa-icon\");\nicon.size = 24;\nicon.setIcon(\"bell\", true);\n</code></pre>"},{"location":"migration/wsc55/icons/#creating-icons-in-html-strings","title":"Creating Icons in HTML Strings","text":"<p>You can embed icons in HTML strings by constructing the <code>fa-icon</code> element yourself.</p> <pre><code>element.innerHTML = '<fa-icon name=\"bell\" solid></fa-icon>';\n</code></pre>"},{"location":"migration/wsc55/icons/#changing-an-icon-on-runtime","title":"Changing an Icon on Runtime","text":"<p>You can alter the size by changing the <code>size</code> property which accepts the numbers <code>16</code>, <code>24</code>, <code>32</code>, <code>48</code>, <code>64</code>, <code>96</code>, <code>128</code> and <code>144</code>. The icon itself should be always set through the <code>setIcon(name: string, isSolid: boolean)</code> function which validates the values and rejects unknown icons.</p> <pre><code>const div = document.createElement(\"div\");\ndiv.innerHTML = '<fa-icon name=\"user\"></fa-icon>';\n\nconst icon = div.querySelector(\"fa-icon\");\nicon.size = 24;\nicon.setIcon(\"bell\", true);\n</code></pre>"},{"location":"migration/wsc55/icons/#migrating-icons","title":"Migrating Icons","text":"<p>We provide a helper script that eases the transition by replacing icons in templates, JavaScript and TypeScript files. The script itself is very defensive and only replaces obvious matches, it will leave icons with additional CSS classes or attributes as-is and will need to be manually adjusted.</p>"},{"location":"migration/wsc55/icons/#replacing-icons-with-the-helper-script","title":"Replacing Icons With the Helper Script","text":"<p>The helper script is part of WoltLab Suite Core and can be found in the repository at <code>extra/migrate-fa-v4.php</code>. The script must be executed from CLI and requires PHP 8.1.</p> <pre><code>$> php extra/migrate-fa-v4.php /path/to/the/target/directory/\n</code></pre> <p>The target directory will be searched recursively for files with the extension <code>tpl</code>, <code>js</code> and <code>ts</code>.</p>"},{"location":"migration/wsc55/icons/#replacing-icons-manually-by-example","title":"Replacing Icons Manually by Example","text":"<p>The helper script above is limited to only perform replacements for occurrences that it can identify without doubt. It will not replace occurrences that are formatted differently and/or make use of additional attributes, including the icon misuse as clickable elements.</p> <pre><code><li>\n <span class=\"icon icon16 fa-times pointer jsButtonFoo jsTooltip\" title=\"{lang}foo.bar.baz{/lang}\">\n</li>\n</code></pre> <p>This can be replaced using a proper button element which also provides proper accessibility for free.</p> <pre><code><li>\n <button class=\"jsButtonFoo jsTooltip\" title=\"{lang}foo.bar.baz{/lang}\">\n {icon name='xmark'}\n </button>\n</li>\n</code></pre>"},{"location":"migration/wsc55/icons/#replacing-icons-in-css","title":"Replacing Icons in CSS","text":"<p>Icons created through CSS properties are generally not supported. It was often used as a convenient way to introduce a new icon with little hassle, but has way too many downsides, including but not limited to accessibility.</p> <p>Existing icons injected through CSS properties are dysfunctional and must be converted into regular icons that are injected into the DOM. If you cannot embed them directly in the template, you should inject those using JavaScript on runtime. It is possible to inject icons using JavaScript on page load by relying entirely on native JavaScript, because the icon component is eagerly loaded ahead of time, preventing any flicker or layout shifts.</p>"},{"location":"migration/wsc55/icons/#migrating-admin-configurable-icons","title":"Migrating Admin-Configurable Icons","text":"<p>If admin-configurable icon names (e.g. created by <code>IconFormField</code>) are stored within the database, these need to be migrated with an upgrade script.</p> <p>The <code>FontAwesomeIcon::mapVersion4()</code> maps a Font Awesome 4 icon name to a string that may be passed to <code>FontAwesomeIcon::fromString()</code>. It will throw an <code>UnknownIcon</code> exception if the icon cannot be mapped. It is important to catch and handle this exception to ensure a reliable upgrade even when facing malformed data.</p> <p>See WoltLab/WCF#5288 for an example script.</p>"},{"location":"migration/wsc55/javascript/","title":"Migrating from WoltLab Suite 5.5 - TypeScript and JavaScript","text":""},{"location":"migration/wsc55/javascript/#minimum-requirements","title":"Minimum requirements","text":"<p>The ECMAScript target version has been increased to ES2022 from es2017.</p>"},{"location":"migration/wsc55/javascript/#subscribe-button-wcfuserobjectwatchsubscribe","title":"Subscribe Button (WCF.User.ObjectWatch.Subscribe)","text":"<p>We have replaced the old jQuery-based <code>WCF.User.ObjectWatch.Subscribe</code> with a more modern replacement <code>WoltLabSuite/Core/Ui/User/ObjectWatch</code>.</p> <p>The new implementation comes with a ready-to-use template (<code>__userObjectWatchButton</code>) for use within <code>contentInteractionButtons</code>: <pre><code>{include file='__userObjectWatchButton' isSubscribed=$isSubscribed objectType='foo.bar' objectID=$id}\n</code></pre></p> <p>See WoltLab/WCF#4962 for details.</p>"},{"location":"migration/wsc55/javascript/#support-for-legacy-inheritance","title":"Support for Legacy Inheritance","text":"<p>The migration from JavaScript to TypeScript was a breaking change because the previous prototype based inheritance was incompatible with ES6 classes. <code>Core.enableLegacyInheritance()</code> was added in an effort to emulate the previous behavior to aid in the migration process.</p> <p>This workaround was unstable at best and was designed as a temporary solution only. WoltLab/WCF#5041 removed the legacy inheritance, requiring all depending implementations to migrate to ES6 classes.</p>"},{"location":"migration/wsc55/libraries/","title":"Migrating from WoltLab Suite 5.5 - Third Party Libraries","text":""},{"location":"migration/wsc55/libraries/#symfony-php-polyfills","title":"Symfony PHP Polyfills","text":"<p>The Symfony Polyfills for 7.3, 7.4, and 8.0 were removed, as the minimum PHP version was increased to PHP 8.1. The Polyfills for PHP 8.2 and PHP 8.3 were added.</p> <p>Refer to the documentation within the symfony/polyfill repository for details.</p>"},{"location":"migration/wsc55/libraries/#idna-handling","title":"IDNA Handling","text":"<p>The true/punycode and pear/net_idna2 dependencies were removed, because of a lack of upstream maintenance and because the <code>intl</code> extension is now required. Instead the <code>idn_to_ascii</code> function should be used.</p>"},{"location":"migration/wsc55/libraries/#laminas-diactoros","title":"Laminas Diactoros","text":"<p>Diactoros was updated from version 2.4 to 3.0.</p>"},{"location":"migration/wsc55/libraries/#input-validation","title":"Input Validation","text":"<p>WoltLab Suite 6.0 ships with cuyz/valinor 1.6 as a reliable solution to validate untrusted external input values.</p> <p>Refer to the documentation within the CuyZ/Valinor repository for details.</p>"},{"location":"migration/wsc55/libraries/#diff","title":"Diff","text":"<p>WoltLab Suite 6.0 ships with sebastian/diff as a replacement for <code>wcf\\util\\Diff</code>. The <code>wcf\\util\\Diff::rawDiffFromSebastianDiff()</code> method was added as a compatibility helper to transform sebastian/diff's output format into Diff's output format.</p> <p>Refer to the documentation within the sebastianbergmann/diff repository for details on how to use the library.</p> <p>See WoltLab/WCF#4918 for examples on how to use the compatibility helper if you need to preserve the output format for the time being.</p>"},{"location":"migration/wsc55/libraries/#content-negotiation","title":"Content Negotiation","text":"<p>WoltLab Suite 6.0 ships with willdurand/negotiation to perform HTTP content negotiation based on the headers sent within the request. The <code>wcf\\http\\Helper::getPreferredContentType()</code> method provides a convenience interface to perform content negotiation with regard to the MIME type. It is strongly recommended to make use of this method instead of interacting with the library directly.</p> <p>In case the API provided by the helper method is insufficient, please refer to the documentation within the willdurand/Negotiation repository for details on how to use the library.</p>"},{"location":"migration/wsc55/libraries/#cronjobs","title":"Cronjobs","text":"<p>WoltLab Suite 6.0 ships with dragonmantank/cron-expression as a replacement for <code>wcf\\util\\CronjobUtil</code>.</p> <p>This library is considered an internal library / implementation detail and not covered by backwards compatibility promises of WoltLab Suite.</p>"},{"location":"migration/wsc55/libraries/#ico-converter","title":".ico converter","text":"<p>The chrisjean/php-ico dependency was removed, because of a lack of upstream maintenance. As the library was only used for Favicon generation, no replacement is made available. The favicons are now delivered as PNG files.</p>"},{"location":"migration/wsc55/php/","title":"Migrating from WoltLab Suite 5.5 - PHP","text":""},{"location":"migration/wsc55/php/#minimum-requirements","title":"Minimum requirements","text":"<p>The minimum requirements have been increased to the following:</p> <ul> <li>PHP: 8.1.2 (64 bit only); <code>intl</code> extension</li> <li>MySQL: 8.0.30</li> <li>MariaDB: 10.5.12</li> </ul> <p>It is recommended to make use of the newly introduced features whereever possible. Please refer to the PHP documentation for details.</p>"},{"location":"migration/wsc55/php/#inheritance","title":"Inheritance","text":""},{"location":"migration/wsc55/php/#parameter-return-property-types","title":"Parameter / Return / Property Types","text":"<p>Parameter, return, and property types have been added to methods of various classes/interfaces. This might cause errors during inheritance, because the types are not compatible with the newly added types in the parent class.</p> <p>Return types may already be added in package versions for older WoltLab Suite branches to be forward compatible, because return types are covariant.</p>"},{"location":"migration/wsc55/php/#final","title":"final","text":"<p>The <code>final</code> modifier was added to several classes that were not usefully set up for inheritance in the first place to make it explicit that inheriting from these classes is unsupported.</p>"},{"location":"migration/wsc55/php/#application-boot","title":"Application Boot","text":""},{"location":"migration/wsc55/php/#request-specific-logic-will-no-longer-happen-during-boot","title":"Request-specific logic will no longer happen during boot","text":"<p>Historically the application boot in <code>WCF</code>\u2019s constructor performed processing based on fundamentally request-specific values, such as the accessed URL, the request body, or cookies. This is problematic, because this makes the boot dependent on the HTTP environment which may not be be available, e.g. when using the CLI interface for maintenance jobs. The latter needs to emulate certain aspects of the HTTP environment for the boot to succeed. Furthermore one of the goals of the introduction of PSR-7/PSR-15-based request processing that was started in WoltLab Suite 5.5 is the removal of implicit global state in favor of explicitly provided values by means of a <code>ServerRequestInterface</code> and thus to achieve a cleaner architecture.</p> <p>To achieve a clean separation this type of request-specific logic will incrementally be moved out of the application boot in <code>WCF</code>\u2019s constructor and into the request processing stack that is launched by <code>RequestHandler</code>, e.g. by running appropriate PSR-15 middleware.</p> <p>An example of this type of request-specific logic that was previously happening during application boot is the check that verifies whether a user is banned and denies access otherwise. This check is based on a request-specific value, namely the user\u2019s session which in turn is based on a provided (HTTP) cookie. It is now moved into the <code>CheckUserBan</code> middleware.</p> <p>This move implies that custom scripts that include WoltLab Suite Core\u2019s <code>global.php</code>, without also invoking <code>RequestHandler</code> will no longer be able to rely on this type of access control having happened and will need to implement it themselves, e.g. by manually running the appropriate middlewares.</p> <p>Notably the following checks have been moved into a middleware:</p> <ul> <li>Denying access to banned users (WoltLab/WCF#4935)</li> <li>ACP authentication (WoltLab/WCF#4939)</li> </ul> <p>The initialization of the session itself and dependent subsystems (e.g. the user object and thus the current language) is still running during application boot for now. However it is planned to also move the session initialization into the middleware in a future version and then providing access to the session by adding an attribute on the <code>ServerRequestInterface</code>, instead of querying the session via <code>WCF::getSession()</code>. As such you should begin to stop relying on the session and user outside of <code>RequestHandler</code>\u2019s middleware stack and should also avoid calling <code>WCF::getUser()</code> and <code>WCF::getSession()</code> outside of a controller, instead adding a <code>User</code> parameter to your methods to allow an appropriate user to be passed from the outside.</p> <p>An example of a method that implicitly relies on these global values is the VisitTracker's <code>trackObjectVisit()</code> method. It only takes the object type, object ID and timestamp as the parameter and will determine the <code>userID</code> by itself. The <code>trackObjectVisitByUserIDs()</code> method on the other hand does not rely on global values. Instead the relevant user IDs need to be passed explicitly from the controller as parameters, thus making the information the method works with explicit. This also makes the method reusable for use cases where an object should be marked as visited for a user other than the active user, without needing to temporarily switch the active user in the session.</p> <p>The same is true for \u201cpermission checking\u201d methods on <code>DatabaseObject</code>s. Instead of having a <code>$myObject->canView()</code> method that uses <code>WCF::getSession()</code> or <code>WCF::getUser()</code> internally, the user should explicitly be passed to the method as a parameter, allowing for permission checks to happen in a different context, for example send sending notification emails.</p> <p>Likewise event listeners should not access these request-specific values at all, because they are unable to know whether the event was fired based on these request-specific values or whether some programmatic action fired the event for another arbitrary user. Instead they must retrieve the appropriate information from the event data only.</p>"},{"location":"migration/wsc55/php/#bootstrap-scripts","title":"Bootstrap Scripts","text":"<p>WoltLab Suite 6.0 adds package-specific bootstrap scripts allowing a package to execute logic during the application boot to prepare the environment before the request is passed through the middleware pipeline into the controller in <code>RequestHandler</code>.</p> <p>Bootstrap scripts are stored in the <code>lib/bootstrap/</code> directory of WoltLab Suite Core with the package identifier as the file name. They do not need to be registered explicitly, as one future goal of the bootstrap scripts is reducing the amount of system state that needs to be stored within the database. Instead WoltLab Suite Core will automatically create a bootstrap loader that includes all installed bootstrap scripts as part of the package installation and uninstallation process.</p> <p>Bootstrap scripts will be loaded and the bootstrap functions will executed based on a topological sorting of all installed packages. A package can rely on all bootstrap scripts of its dependencies being loaded before its own bootstrap script is loaded. It can also rely on all bootstrap functions of its dependencies having executed before its own bootstrap functions is executed. However it cannot rely on any specific loading and execution order of non-dependencies.</p> <p>As hinted at in the previous paragraph, executing the bootstrap scripts happens in two phases:</p> <ol> <li>All bootstrap scripts will be <code>include()</code>d in topological order. The script is expected to return a <code>Closure</code> that is executed in phase 2.</li> <li>Once all bootstrap scripts have been included, the returned <code>Closure</code>s will be executed in the same order the bootstrap scripts were loaded.</li> </ol> files/lib/bootstrap/com.example.foo.php<pre><code><?php\n\n// Phase (1).\n\nreturn static function (): void {\n // Phase (2).\n};\n</code></pre> <p>For the vast majority of packages it is expected that the phase (1) bootstrapping is not used, except to return the <code>Closure</code>. Instead the logic should reside in the <code>Closure</code>s body that is executed in phase (2).</p>"},{"location":"migration/wsc55/php/#registering-ievent-listeners","title":"Registering <code>IEvent</code> listeners","text":"<p>An example use case for bootstrap scripts with WoltLab Suite 6.0 is registering event listeners for <code>IEvent</code>-based events that were added with WoltLab Suite 5.5, instead of using the eventListener PIP. Registering event listeners within the bootstrap script allows you to leverage your IDE\u2019s autocompletion for class names and and prevents forgetting the explicit uninstallation of old event listeners during a package upgrade.</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\event\\listener\\ValueDumpListener;\nuse wcf\\system\\foo\\event\\ValueAvailable;\n\nreturn static function (): void {\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n ValueDumpListener::class\n );\n\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n static function (ValueAvailable $event): void {\n // For simple use cases a `Closure` instead of a class name may be used.\n \\var_dump($event->getValue());\n }\n );\n};\n</code></pre>"},{"location":"migration/wsc55/php/#request-processing","title":"Request Processing","text":"<p>As previously mentioned in the Application Boot section, WoltLab Suite 6.0 improves support for PSR-7/PSR-15-based request processing that was initially announced with WoltLab Suite 5.5.</p> <p>WoltLab Suite 5.5 added support for returning a PSR-7 <code>ResponseInterface</code> from a controller and recommended to migrate existing controllers based on <code>AbstractAction</code> to make use of <code>RedirectResponse</code> and <code>JsonResponse</code> instead of using <code>HeaderUtil::redirect()</code> or manually emitting JSON with appropriate headers. Processing the request values still used PHP\u2019s superglobals (specifically <code>$_GET</code> and <code>$_POST</code>).</p> <p>WoltLab Suite 6.0 adds support for controllers based on PSR-15\u2019s <code>RequestHandlerInterface</code>, supporting request processing based on a provided PSR-7 <code>ServerRequestInterface</code> object.</p>"},{"location":"migration/wsc55/php/#recommended-changes-for-woltlab-suite-60","title":"Recommended changes for WoltLab Suite 6.0","text":"<p>It is recommended to use <code>RequestHandlerInterface</code>-based controllers whenever an <code>AbstractAction</code> would previously be used. Furthermore any AJAX-based logic that would previously rely on <code>AJAXProxyAction</code> combined with a method in an <code>AbstractDatabaseObjectAction</code> should also be implemented using a dedicated <code>RequestHandlerInterface</code>-based controller. Both <code>AbstractAction</code> and <code>AJAXProxyAction</code>-based AJAX requests should be considered soft-deprecated going forward.</p> <p>When creating a <code>RequestHandlerInterface</code>-based controller, care should be taken to ensure no mutable state is stored in object properties of the controller itself. The state of the controller object must be identical before, during and after a request was processed. Any required values must be passed explicitly by means of method parameters and return values. Likewise any functionality called by the controller\u2019s <code>handle()</code> method should not rely on implicit global values, such as <code>WCF::getUser()</code>, as was explained in the previous section about request-specific logic.</p> <p>The recommended pattern for a <code>RequestHandlerInterface</code>-based controller looks as follows:</p> files/lib/action/MyFancyAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse Laminas\\Diactoros\\Response;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\n\nfinal class MyFancyAction implements RequestHandlerInterface\n{\n public function __construct()\n {\n /* 0. Explicitly register services used by the controller, to\n * make dependencies explicit and to avoid accidentally using\n * global state outside of a controller.\n */\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n /* 1. Perform permission checks and input validation. */\n\n /* 2. Perform the action. The action must not rely on global state,\n * but instead only on explicitly passed values. It should assume\n * that permissions have already been validated by the controller,\n * allowing it to be reusable programmatically.\n */\n\n /* 3. Perform post processing. */\n\n /* 4. Prepare the response, e.g. by querying an updated object from\n * the database.\n */\n\n /* 5. Send the response. */\n return new Response();\n }\n}\n</code></pre> <p>It is recommended to leverage Valinor for structural validation of input values if using the FormBuilder is not a good fit, specifically for any values that are provided implicitly and are expected to be correct. WoltLab Suite includes a middleware that will automatically convert unhandled <code>MappingError</code>s into a response with status HTTP 400 Bad Request.</p> <p>XSRF validation will implicitly be performed for any request that uses a HTTP verb other than <code>GET</code>. Likewise any requests with a JSON body will automatically be decoded by a middleware and stored as the <code>ServerRequestInterface</code>\u2019s parsed body.</p>"},{"location":"migration/wsc55/php/#querying-requesthandlerinterface-based-controllers-via-javascript","title":"Querying RequestHandlerInterface-based controllers via JavaScript","text":"<p>The new <code>WoltLabSuite/Core/Ajax/Backend</code> module may be used to easily query a <code>RequestHandlerInterface</code>-based controller. The JavaScript code must not make any assumptions about the URI structure to reach the controller. Instead the endpoint must be generated using <code>LinkHandler</code> and explicitly provided, e.g. by storing it in a <code>data-endpoint</code> attribute:</p> <pre><code><button\n class=\"button fancyButton\"\n data-endpoint=\"{link controller='MyFancy'}{/link}\"\n>Click me!</button>\n</code></pre> <pre><code>const button = document.querySelector('.fancyButton');\nbutton.addEventListener('click', async (event) => {\n const request = prepareRequest(button.dataset.endpoint)\n .get(); // or: .post(\u2026)\n\n const response = await request.fetchAsResponse(); // or: .fetchAsJson()\n});\n</code></pre>"},{"location":"migration/wsc55/php/#formbuilder","title":"FormBuilder","text":"<p>The <code>Psr15DialogForm</code> class combined with the <code>usingFormBuilder()</code> method of <code>dialogFactory()</code> provides a \u201cbatteries-included\u201d solution to create a AJAX- and FormBuilder-based <code>RequestHandlerInterface</code>-based controller.</p> <p>Within the JavaScript code the endpoint is queried using:</p> <pre><code>const { ok, result } = await dialogFactory()\n .usingFormBuilder()\n .fromEndpoint(url);\n</code></pre> <p>The returned <code>Promise</code> will resolve when the dialog is closed, either by successfully submitting the form or by manually closing it and thus aborting the process. If the form was submitted successfully <code>ok</code> will be <code>true</code> and <code>result</code> will contain the controller\u2019s response. If the dialog was closed without successfully submitting the form, <code>ok</code> will be <code>false</code> and <code>result</code> will be set to <code>undefined</code>.</p> <p>Within the PHP code, the form may be created as usual, but use <code>Psr15DialogForm</code> as the form document. The controller must return <code>$dialogForm->toJsonResponse()</code> for <code>GET</code> requests and validate the <code>ServerRequestInterface</code> using <code>$dialogForm->validateRequest($request)</code> for <code>POST</code> requests. The latter will return a <code>ResponseInterface</code> to be returned if the validation fails, otherwise <code>null</code> is returned. If validation succeeded, the controller must perform the resulting action and return a <code>JsonResponse</code> with the <code>result</code> key:</p> <pre><code>if ($request->getMethod() === 'GET') {\n return $dialogForm->toResponse();\n} elseif ($request->getMethod() === 'POST') {\n $response = $dialogForm->validateRequest($request);\n if ($response !== null) {\n return $response;\n }\n\n $data = $dialogForm->getData();\n\n // Use $data.\n\n return new JsonResponse([\n 'result' => [\n 'some' => 'value',\n ],\n ]);\n} else {\n // The used method is validated by a middleware. Methods that are not\n // GET or POST need to be explicitly allowed using the 'AllowHttpMethod'\n // attribute.\n throw new \\LogicException('Unreachable');\n}\n</code></pre>"},{"location":"migration/wsc55/php/#example","title":"Example","text":"<p>A complete example, showcasing all the patterns can be found in WoltLab/WCF#5106. This example showcases how to:</p> <ul> <li>Store used services within the controller\u2019s constructor.</li> <li>Perform validation of inputs using Valinor.</li> <li>Perform permission checks.</li> <li>Use the FormBuilder.</li> <li>Delegate the actual processing to a reusable command that does not rely on global state.</li> <li>Store the request endpoint as a <code>data-*</code> attribute.</li> </ul>"},{"location":"migration/wsc55/php/#package-system","title":"Package System","text":""},{"location":"migration/wsc55/php/#required-minversion-for-required-packages","title":"Required \u201cminversion\u201d for required packages","text":"<p>The <code>minversion</code> attribute of the <code><requiredpackage></code> tag is now required.</p>"},{"location":"migration/wsc55/php/#rejection-of-pl-versions","title":"Rejection of \u201cpl\u201d versions","text":"<p>Woltlab Suite 6.0 no longer accepts package versions with the \u201cpl\u201d suffix as valid.</p>"},{"location":"migration/wsc55/php/#removal-of-api-compatibility","title":"Removal of API compatibility","text":"<p>WoltLab Suite 6.0 removes support for the deprecated API compatibility functionality. Any packages with a <code><compatibility></code> tag in their package.xml are assumed to not have been updated for WoltLab Suite 6.0 and will be rejected during installation. Furthermore any packages without an explicit requirement for <code>com.woltlab.wcf</code> in at least version <code>5.4.22</code> are also assumed to not have been updated for WoltLab Suite 6.0 and will also be rejected. The latter check is intended to reject old and most likely incompatible packages where the author forgot to add either an <code><excludedpackage></code> or a <code><compatibility></code> tag before releasing it.</p>"},{"location":"migration/wsc55/php/#package-installation-plugins","title":"Package Installation Plugins","text":""},{"location":"migration/wsc55/php/#eventlistener","title":"EventListener","text":"<p>Installing unnamed event listeners is no longer supported. The <code>name</code> attribute needs to be specified for all event listeners.</p> <p>Deleting unnamed event listeners still is possible to allow for a clean migration of existing listeners.</p>"},{"location":"migration/wsc55/php/#cronjob","title":"Cronjob","text":"<p>Installing unnamed cronjobs is no longer supported. The <code>name</code> attribute needs to be specified for all event listeners.</p> <p>Deleting unnamed cronjobs still is possible to allow for a clean migration of existing cronjobs.</p> <p>The cronjob PIP now supports the <code><expression></code> element, allowing to define the cronjob schedule using a full expression instead of specifying the five elements separately.</p>"},{"location":"migration/wsc55/php/#database","title":"Database","text":"<p>The <code>$name</code> parameter of <code>DatabaseTableIndex::create()</code> is no longer optional. Relying on the auto-generated index name is strongly discouraged, because of unfixable inconsistent behavior between the SQL PIP and the PHP DDL API. See WoltLab/WCF#4505 for further background information.</p> <p>The autogenerated name can still be requested by passing an empty string as the <code>$name</code>. This should only be done for backwards compatibility purposes and to migrate an index with an autogenerated name to an index with an explicit name. An example script can be found in WoltLab/com.woltlab.wcf.conversation@a33677ca051f.</p>"},{"location":"migration/wsc55/php/#internationalization","title":"Internationalization","text":"<p>WoltLab Suite 6.0 increases the System Requirements to require PHP\u2019s intl extension to be installed and enabled, allowing you to rely on the functionality provided by it to better match the rules and conventions of the different languages and regions of the world.</p> <p>One example would be the formatting of numbers. WoltLab Suite included a feature to group digits within large numbers since early versions using the <code>StringUtil::addThousandsSeparator()</code> method. While this method was able to account for some language-specific differences, e.g. by selecting an appropriate separator character based on a phrase, it failed to account for all the differences in number formatting across countries and cultures.</p> <p>As an example, English as written in the United States of America uses commas to create groups of three digits within large numbers: 123,456,789. English as written in India on the other hand also uses commas, but digits are not grouped into groups of three. Instead the right-most three digits form a group and then another comma is added every two digits: 12,34,56,789.</p> <p>Another example would be German as used within Germany and Switzerland. While both countries use groups of three, the separator character differs. Germany uses a dot (123.456.789), whereas Switzerland uses an apostrophe (123\u2019456\u2019789). The correct choice of separator could already be configured using the afore-mentioned phrase, but this is both inconvenient and fails to account for other differences between the two countries. It also made it hard to keep the behavior up to date when rules change.</p> <p>PHP\u2019s intl extension on the other hand builds on the official Unicode rules, by relying on the ICU library published by the Unicode consortium. As such it is aware of the rules of all relevant languages and regions of the world and it is already kept up to date by the operating system\u2019s package manager.</p> <p>For the four example regions (en_US, en_IN, de_DE, de_CH) intl\u2019s <code>NumberFormatter</code> class will format the number 123456789 as follows, correctly implementing the rules:</p> <pre><code>php > var_dump((new NumberFormatter('en_US', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(11) \"123,456,789\"\nphp > var_dump((new NumberFormatter('en_IN', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(12) \"12,34,56,789\"\nphp > var_dump((new NumberFormatter('de_DE', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(11) \"123.456.789\"\nphp > var_dump((new NumberFormatter('de_CH', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(15) \"123\u2019456\u2019789\"\n</code></pre> <p>WoltLab Suite\u2019s <code>StringUtil::formatNumeric()</code> method is updated to leverage the <code>NumberFormatter</code> internally. However your package might have special requirements regarding formatting, for example when formatting currencies where the position of the currency symbol differs across languages. In those cases your package should manually create an appropriately configured class from Intl\u2019s feature set. The correct locale can be queried by the new <code>Language::getLocale()</code> method.</p> <p>Another use case that showcases the <code>Language::getLocale()</code> method might be localizing a country name using <code>locale_get_display_region()</code>:</p> <pre><code>php > var_dump(\\wcf\\system\\WCF::getLanguage()->getLocale());\nstring(5) \"en_US\"\nphp > var_dump(locale_get_display_region('_DE', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(7) \"Germany\"\nphp > var_dump(locale_get_display_region('_US', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(13) \"United States\"\nphp > var_dump(locale_get_display_region('_IN', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(5) \"India\"\nphp > var_dump(locale_get_display_region('_BR', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(6) \"Brazil\"\n</code></pre> <p>See WoltLab/WCF#5048 for details.</p>"},{"location":"migration/wsc55/php/#indicating-parameters-that-hold-sensitive-information","title":"Indicating parameters that hold sensitive information","text":"<p>PHP 8.2 adds native support for redacting parameters holding sensitive information in stack traces. Parameters with the <code>#[\\SensitiveParameter]</code> attribute will show a placeholder value within the stack trace and the error log.</p> <p>WoltLab Suite\u2019s exception handler contains logic to manually apply the sanitization for PHP versions before 8.2.</p> <p>It is strongly recommended to add this attribute to all parameters holding sensitive information. Examples for sensitive parameters include passwords/passphrases, access tokens, plaintext values to be encrypted, or private keys.</p> <p>As attributes are fully backwards and forwards compatible it is possible to apply the attribute to packages targeting older WoltLab Suite or PHP versions without causing errors.</p> <p>Example:</p> <pre><code>function checkPassword(\n #[\\SensitiveParameter]\n $password,\n): bool {\n // \u2026\n}\n</code></pre> <p>See the PHP RFC: Redacting parameters in back traces for more details.</p>"},{"location":"migration/wsc55/php/#conditions","title":"Conditions","text":""},{"location":"migration/wsc55/php/#abstractintegercondition","title":"AbstractIntegerCondition","text":"<p>Deriving from <code>AbstractIntegerCondition</code> now requires to explicitly implement <code>protected function getIdentifier(): string</code>, instead of setting the <code>$identifier</code> property. This is to ensure that all conditions specify a unique identifier, instead of accidentally relying on a default value. The <code>$identifier</code> property will no longer be used and may be removed.</p> <p>See WoltLab/WCF#5077 for details.</p>"},{"location":"migration/wsc55/php/#rebuild-workers","title":"Rebuild Workers","text":"<p>Rebuild workers should no longer be registered using the <code>com.woltlab.wcf.rebuildData</code> object type definition. You can attach an event listener to the <code>wcf\\system\\worker\\event\\RebuildWorkerCollecting</code> event inside a bootstrap script to lazily register workers. The class name of the worker is registered using the event\u2019s <code>register()</code> method:</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\worker\\event\\RebuildWorkerCollecting;\n\nreturn static function (): void {\n $eventHandler = EventHandler::getInstance();\n\n $eventHandler->register(RebuildWorkerCollecting::class, static function (RebuildWorkerCollecting $event) {\n $event->register(\\bar\\system\\worker\\BazWorker::class, 0);\n });\n};\n</code></pre>"},{"location":"migration/wsc55/templates/","title":"Migrating from WoltLab Suite 5.5 - Templates","text":""},{"location":"migration/wsc55/templates/#template-modifiers","title":"Template Modifiers","text":"<p>WoltLab Suite featured a strict allow-list for template modifiers within the enterprise mode since 5.2. This allow-list has proved to be a reliable solution against malicious templates. To improve security and to reduce the number of differences between enterprise mode and non-enterprise mode the allow-list will always be enabled going forward.</p> <p>It is strongly recommended to keep the template logic as simple as possible by moving the heavy lifting into regular PHP code, reducing the number of (specialized) modifiers that need to be applied.</p> <p>See WoltLab/WCF#4788 for details.</p>"},{"location":"migration/wsc55/templates/#time-rendering","title":"Time Rendering","text":"<p>The <code>|time</code>, <code>|plainTime</code> and <code>|date</code> modifiers have been deprecated and replaced by a unified <code>{time}</code> function.</p> <p>The main benefit is that it is no longer necessary to specify the <code>@</code> symbol when rendering the interactive time element, making it easier to perform a security review of templates by searching for the <code>@</code> symbol.</p> <p>See WoltLab/WCF#5459 for details.</p>"},{"location":"migration/wsc55/templates/#comments","title":"Comments","text":"<p>In WoltLab Suite 6.0 the comment system has been overhauled. In the process, the integration of comments via templates has been significantly simplified:</p> <pre><code>{include file='comments' commentContainerID='someElementId' commentObjectID=$someObjectID}\n</code></pre> <p>An example for the migration of existing template integrations can be found here.</p> <p>See WoltLab/WCF#5210 for more details.</p>"},{"location":"migration/wsc55/templates/#the-button-element","title":"The <code><button></code> Element","text":"<p>The styling of the <code><button></code> has been completely removed in WoltLab Suite 6.0 and the element has no longer any kind of styling. This change allows the element to be used in a lot of places that previously had to use an <code>a[href=\"#\"][role=\"button\"]</code> to replicate the same behavior.</p> <p>If you have previously used the button element as an actual button, you should add the CSS class <code>.button</code> to it.</p> <p>It is recommended to identify an uses of the anchor element to replicate a native button and to use the proper <code><button></code> element from now on. Buttons will implicitly submit a form, therefore you should set the <code>type</code> attribute to explicitly define its behavior.</p> <pre><code><form method=\"post\">\n <!-- These two buttons will submit the form. -->\n <button>Button 1</button>\n <button type=\"submit\">Button 2</button>\n\n <!-- Clicking this button does nothing on its own. -->\n <button type=\"button\">Button 3</button>\n</form>\n</code></pre> <p>See WoltLab/WCF#4834 for more details.</p>"},{"location":"migration/wsc55/templates/#pagination","title":"Pagination","text":"<p>The <code>{pages}</code> template function has been deprecated and replaced by the new <code><woltlab-core-pagination></code> web component.</p> <p>If you continue to use the <code>{pages}</code> template function, it will automatically generate the code for the web component. </p> <p>See WoltLab/WCF#5158 for more details.</p>"},{"location":"migration/wsc60/deprecations_removals/","title":"Migrating from WoltLab Suite 6.0 - Deprecations and Removals","text":"<p>With version 6.1, we have deprecated certain components and removed several other components that have been deprecated for many years.</p>"},{"location":"migration/wsc60/deprecations_removals/#deprecations","title":"Deprecations","text":""},{"location":"migration/wsc60/deprecations_removals/#php","title":"PHP","text":""},{"location":"migration/wsc60/deprecations_removals/#classes","title":"Classes","text":"<ul> <li><code>wcf\\system\\exception\\ValidateActionException</code></li> <li><code>wcf\\system\\bbcode\\HtmlBBCodeParser</code> (WoltLab/WCF#5874)</li> <li><code>wcf\\action\\AbstractOauth2Action</code> (WoltLab/WCF#5891)</li> <li><code>wcf\\data\\user\\menu\\item\\event\\UserMenuItemIconResolving</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\cache\\event\\CacheCleared</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\event\\IEvent</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\event\\IInterruptableEvent</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\event\\TInterruptableEvent</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\LanguageContentCopying</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\LanguageImported</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\PhraseChanged</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\PreloadPhrasesCollecting</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\moderation\\queue\\event\\UserAssigned</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\package\\event\\PackageInstallationPluginSynced</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\package\\event\\PackageListChanged</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\package\\event\\PackageUpdateListChanged</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\user\\authentication\\event\\UserLoggedIn</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\user\\event\\UsernameValidating</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\worker\\event\\RebuildWorkerCollecting</code> (WoltLab/WCF#5912)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#methods","title":"Methods","text":"<ul> <li><code>wcf\\system\\session\\SessionHandler::resetSessions()</code> (WoltLab/WCF#3767)</li> <li><code>wcf\\system\\comment\\manager\\ICommentManager::canModerate()</code> (WoltLab/WCF#5852)</li> <li><code>wcf\\system\\box\\BoxHandler::createBoxCondition()</code> (WoltLab/WCF#5906)</li> <li><code>wcf\\system\\box\\BoxHandler::addBoxToPageAssignments()</code> (WoltLab/WCF#5906)</li> <li>Non-standard methods of <code>wcf\\data\\comment\\CommentAction</code> (WoltLab/WCF#5944)</li> <li>Non-standard methods of <code>wcf\\data\\comment\\response\\CommentResponseAction</code> (WoltLab/WCF#5944)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#javascript","title":"JavaScript","text":"<ul> <li><code>WCF.User.Action.Follow</code> (WoltLab/WCF#5747)</li> <li><code>WCF.User.Registration.Validation</code> (WoltLab/WCF#5716)</li> <li><code>WCF.User.Registration.Validation.Username</code> (WoltLab/WCF#5716)</li> <li><code>WCF.User.Registration.Validation.EmailAddress</code> (WoltLab/WCF#5716)</li> <li><code>WCF.User.RecentActivityLoader</code> (WoltLab/WCF#5804)</li> <li><code>WoltLabSuite/Core/Ui/User/Activity/Recent</code> (WoltLab/WCF#5804)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#removals","title":"Removals","text":""},{"location":"migration/wsc60/deprecations_removals/#php_1","title":"PHP","text":""},{"location":"migration/wsc60/deprecations_removals/#classes_1","title":"Classes","text":"<ul> <li><code>wcf\\data\\spider\\Spider</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\data\\spider\\SpiderAction</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\data\\spider\\SpiderEditor</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\data\\spider\\SpiderList</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\system\\cache\\SpiderCacheBuilder</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\system\\cronjob\\RefreshSearchRobotsCronjob</code> (WoltLab/WCF#5823)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#javascript_1","title":"JavaScript","text":"<ul> <li><code>WCF.User.Registration.LostPassword</code></li> <li><code>WCF.Message.BBCode.CodeViewer</code></li> <li><code>WCF.ACL</code> (WoltLab/WCF#5860)</li> <li><code>WoltLabSuite/Core/Component/Comment/GuestDialog</code> (WoltLab/WCF#5944)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#other","title":"Other","text":"<ul> <li>Option category <code>security.blacklist</code> and <code>security.blacklist.custom</code></li> <li>Option <code>BLACKLIST_SFS_ACTION</code> (replaced by <code>REGISTER_ANTISPAM_ACTION</code>)</li> </ul>"},{"location":"migration/wsc60/php/","title":"Migrating from WoltLab Suite 6.0 - PHP","text":""},{"location":"migration/wsc60/php/#htmlupcastprocessor","title":"HtmlUpcastProcessor","text":"<p>The <code>HtmlUpcastProcessor</code> is intended for use in all forms where the CKEditor5 is available as an input field. Its primary purpose is to inject necessary information into the HTML to ensure correct rendering within the editor. It is important to note that the <code>HtmlUpcastProcessor</code> is not designed for content storage and should be utilized within the <code>assignVariables</code> method.</p>"},{"location":"migration/wsc60/php/#example","title":"Example","text":"<pre><code>namespace wcf\\form;\n\nuse wcf\\system\\html\\upcast\\HtmlUpcastProcessor;\n\nclass MyForm extends AbstractForm {\n\n public string $messageObjectType = ''; // object type of `com.woltlab.wcf.message`\n public string $text = '';\n\n public function assignVariables() {\n parent::assignVariables();\n\n $upcastProcessor = new HtmlUpcastProcessor();\n $upcastProcessor->process($this->text ?? '', $this->messageObjectType, 0);\n WCF::getTPL()->assign('text', $upcastProcessor->getHtml());\n }\n}\n</code></pre>"},{"location":"migration/wsc60/php/#rss-feeds","title":"RSS Feeds","text":"<p>A new API for the output of content as an RSS feed has been introduced.</p>"},{"location":"migration/wsc60/php/#acp-menu-items","title":"ACP Menu Items","text":"<p>A new API for adding ACP menu items has been introduced. The previous option of adding menu entries via PIP is still supported, but is to be discontinued in the long term.</p>"},{"location":"migration/wsc60/php/#user-activity-events","title":"User Activity Events","text":"<p>The user activity events have been redesigned for a modern look and better user experience.</p> <p>This includes the following changes:</p> <ul> <li>The title now includes the author's name and forms a complete sentence. Example: <code><strong>{$author}</strong> replied to a comment by <strong>{$commentAuthor}</strong> on article <strong>{$article->getTitle()}</strong>.</code></li> <li>The title no longer contains links.</li> <li>Keywords in the title are highlighted in bold (e.g. author's name, topic title).</li> <li>The description is a simple text version of the content (no formatting) truncated to 500 characters.</li> <li>The event as a whole can be linked with a link that leads to the content (the entire area is clickable).</li> </ul> <p>The changes are backwards compatible, but we recommend to apply them for a uniform user experience.</p>"},{"location":"migration/wsc60/php/#example_1","title":"Example","text":"<pre><code>$object = new FooBarObject(1);\n$event->setTitle(WCF::getLanguage()->getDynamicVariable('com.foo.bar', [\n // variables\n]));\n$event->setDescription(\n StringUtil::encodeHTML(\n StringUtil::truncate($object->getPlainTextMessage(), 500)\n ),\n true\n);\n$event->setLink($object->getLink());\n</code></pre>"},{"location":"migration/wsc60/php/#box-configuration","title":"Box Configuration","text":"<p>The Methods <code>wcf\\system\\box\\BoxHandler::createBoxCondition()</code> and <code>wcf\\system\\box\\BoxHandler::addBoxToPageAssignments()</code> were used for the configuration of boxes during package installation. These methods were deprecated with version 6.1, as they led to an initialization of the box handler and can therefore cause undesirable side effects.</p> <p>The new commands <code>wcf\\system\\box\\command\\CreateBoxCondition</code> and <code>wcf\\system\\box\\command\\CreateBoxToPageAssignments</code> can be used instead.</p> <p>Example:</p> <pre><code>(new \\wcf\\system\\box\\command\\CreateBoxCondition(\n 'boxIdentifier',\n 'conditionDefinition',\n 'conditionObjectType',\n ['parameter' => 12345]\n))();\n\n(new \\wcf\\system\\box\\command\\CreateBoxToPageAssignments(\n 'boxIdentifier',\n ['pageIdentifier']\n))();\n</code></pre>"},{"location":"migration/wsc60/php/#psr-14-events","title":"PSR-14 Events","text":"<p>The old practice of placing events where they are used is somewhat inconsistent and worst of all highly intransparent for discovery purposes. WoltLab Suite 6.1 therefore introduces a unified directory structure grouped by the app namespace.</p> <p>All PSR-14 events now use the new <code>event</code> namespace (located under <code>lib/event</code>). See the PSR-14 event documentation for details.</p> <p>The changes are backwards compatible, the old namespaces can still be used.</p>"},{"location":"migration/wsc60/php/#comment-backend","title":"Comment Backend","text":"<p>The backend of the comment system has been revised and is now based on the new RPC controllers and commands. The previous backend (the methods of <code>CommentAction</code> and <code>CommentResponseAction</code>) remains for backward compatibility reasons, but has been deprecated. If you do not interact directly with the backend, no changes are usually required. See WoltLab/WCF#5944 for more details.</p>"},{"location":"migration/wsc60/php/#enable-the-sandbox-for-templates-inside-of-bbcodes","title":"Enable the Sandbox for Templates Inside of BBCodes","text":"<p>BBCodes can appear in a lot of different places and assigning template variables through <code>WCF::getTPL()->assign()</code> can cause variables from the ambient enviroment to be overwritten. You should not use this method in BBCodes at all and instead pass the variables as the third argument to <code>WCF::getTPL()->fetch()</code> as well as enabling the sandbox.</p> <pre><code>// Before\nWCF::getTPL()->assign([\n 'foo' => 'bar',\n]);\nreturn WCF::getTPL()->fetch('templateName', 'application');\n\n// After\nreturn WCF::getTPL()->fetch('templateName', 'application', [\n 'foo' => 'bar',\n], true);\n</code></pre> <p>See WoltLab/WCF#5910 for more details.</p>"},{"location":"migration/wsc60/templates/","title":"Migrating from WoltLab Suite 6.0 - Templates","text":""},{"location":"migration/wsc60/templates/#unsafe-prefix","title":"<code>unsafe</code> Prefix","text":"<p>The <code>unsafe</code> prefix is intended as a replacement for the <code>@</code> prefix in order to output the content of a variable unfiltered. The new prefix offers better readability and makes it easier to find places where the prefix is used unintentionally. The old <code>@</code> prefix is still supported, but we recommend using the new prefix for new code.</p> <p>Usage:</p> <pre><code>Old: {@$foo}\nNew: {unsafe:$foo}\n</code></pre> <p>The code listed above outputs the raw content of the variable <code>$foo</code>.</p>"},{"location":"migration/wsc60/templates/#shared-templates","title":"Shared Templates","text":"<p>Shared templates, applicable both in the frontend and the backend, are now standardized to begin with the prefix <code>shared_</code>. This naming convention enhances clarity and organization within the template system. All templates intended for shared use must adhere to this naming convention.</p> <p>It is important to note that these shared templates must reside within the template directory in the frontend. Whether they are located in the WCF template directory or in your own application's template directory.</p> <p>To facilitate migration, below is a table outlining the renaming of templates from their old names to their new <code>shared_</code> prefixed names:</p> Old Template New Template <code>__wysiwygPreviewFormButton</code> <code>shared_wysiwygPreviewFormButton</code> <code>__formButton</code> <code>shared_formButton</code> <code>__wysiwygSmileyFormContainer</code> <code>shared_wysiwygSmileyFormContainer</code> <code>__wysiwygTabMenuFormContainer</code> <code>shared_wysiwygTabMenuFormContainer</code> <code>__formContainer</code> <code>shared_formContainer</code> <code>__rowFormContainer</code> <code>shared_rowFormContainer</code> <code>__rowFormFieldContainer</code> <code>shared_rowFormFieldContainer</code> <code>__suffixFormFieldContainer</code> <code>shared_suffixFormFieldContainer</code> <code>__tabFormContainer</code> <code>shared_tabFormContainer</code> <code>__tabMenuFormContainer</code> <code>shared_tabMenuFormContainer</code> <code>__tabTabMenuFormContainer</code> <code>shared_tabTabMenuFormContainer</code> <code>__simpleAclFormField</code> <code>shared_simpleAclFormField</code> <code>__aclFormField</code> <code>shared_aclFormField</code> <code>__bbcodeAttributesFormField</code> <code>shared_bbcodeAttributesFormField</code> <code>__emptyFormFieldDependency</code> <code>shared_emptyFormFieldDependency</code> <code>__isNotClickedFormFieldDependency</code> <code>shared_isNotClickedFormFieldDependency</code> <code>__nonEmptyFormFieldDependency</code> <code>shared_nonEmptyFormFieldDependency</code> <code>__valueFormFieldDependency</code> <code>shared_valueFormFieldDependency</code> <code>__valueIntervalFormFieldDependency</code> <code>shared_valueIntervalFormFieldDependency</code> <code>__labelFormField</code> <code>shared_labelFormField</code> <code>__contentLanguageFormField</code> <code>shared_contentLanguageFormField</code> <code>__singleMediaSelectionFormField</code> <code>shared_singleMediaSelectionFormField</code> <code>__pollOptionsFormField</code> <code>shared_pollOptionsFormField</code> <code>__tagFormField</code> <code>shared_tagFormField</code> <code>__userFormField</code> <code>shared_userFormField</code> <code>__usernameFormField</code> <code>shared_usernameFormField</code> <code>__userPasswordFormField</code> <code>shared_userPasswordFormField</code> <code>__formFieldError</code> <code>shared_formFieldError</code> <code>__wysiwygAttachmentFormField</code> <code>shared_wysiwygAttachmentFormField</code> <code>__wysiwygFormField</code> <code>shared_wysiwygFormField</code> <code>__numericFormField</code> <code>shared_numericFormField</code> <code>__booleanFormField</code> <code>shared_booleanFormField</code> <code>__buttonFormField</code> <code>shared_buttonFormField</code> <code>__captchaFormField</code> <code>shared_captchaFormField</code> <code>__checkboxFormField</code> <code>shared_checkboxFormField</code> <code>__colorFormField</code> <code>shared_colorFormField</code> <code>__dateFormField</code> <code>shared_dateFormField</code> <code>__emailFormField</code> <code>shared_emailFormField</code> <code>__hiddenFormField</code> <code>shared_hiddenFormField</code> <code>__iconFormField</code> <code>shared_iconFormField</code> <code>__itemListFormField</code> <code>shared_itemListFormField</code> <code>__multilineTextFormField</code> <code>shared_multilineTextFormField</code> <code>__multipleSelectionFormField</code> <code>shared_multipleSelectionFormField</code> <code>__passwordFormField</code> <code>shared_passwordFormField</code> <code>__radioButtonFormField</code> <code>shared_radioButtonFormField</code> <code>__ratingFormField</code> <code>shared_ratingFormField</code> <code>__selectFormField</code> <code>shared_selectFormField</code> <code>__sourceCodeFormField</code> <code>shared_sourceCodeFormField</code> <code>__uploadFormField</code> <code>shared_uploadFormField</code> <code>__wysiwygSmileyFormNode</code> <code>shared_wysiwygSmileyFormNode</code> <code>__form</code> <code>shared_form</code> <code>__formContainerChildren</code> <code>shared_formContainerChildren</code> <code>__formContainerDependencies</code> <code>shared_formContainerDependencies</code> <code>__formField</code> <code>shared_formField</code> <code>__formFieldDependencies</code> <code>shared_formFieldDependencies</code> <code>__formFieldDescription</code> <code>shared_formFieldDescription</code> <code>__formFieldErrors</code> <code>shared_formFieldErrors</code> <code>__formFieldDataHandler</code> <code>shared_formFieldDataHandler</code> <code>__singleSelectionFormField</code> <code>shared_singleSelectionFormField</code> <code>__mediaSetCategoryDialog</code> <code>shared_mediaSetCategoryDialog</code> <code>__messageQuoteManager</code> <code>shared_messageQuoteManager</code> <code>__topReaction</code> <code>shared_topReaction</code> <code>__wysiwygCmsToolbar</code> <code>shared_wysiwygCmsToolbar</code> <code>aclPermissionJavaScript</code> <code>shared_aclPermissionJavaScript</code> <code>aclSimple</code> <code>shared_aclSimple</code> <code>articleAddDialog</code> <code>shared_articleAddDialog</code> <code>benchmark</code> <code>shared_benchmark</code> <code>booleanOptionType</code> <code>shared_booleanOptionType</code> <code>booleanSearchableOptionType</code> <code>shared_booleanSearchableOptionType</code> <code>captcha</code> <code>shared_captcha</code> <code>captchaQuestion</code> <code>shared_captchaQuestiona</code> <code>categoryOptionList</code> <code>shared_categoryOptionList</code> <code>checkboxesOptionType</code> <code>shared_checkboxesOptionType</code> <code>checkboxesSearchableOptionType</code> <code>shared_checkboxesSearchableOptionType</code> <code>codeMetaCode</code> <code>shared_codeMetaCode</code> <code>codemirror</code> <code>shared_codemirror</code> <code>colorPickerJavaScript</code> <code>shared_colorPickerJavaScript</code> <code>fontAwesomeJavaScript</code> <code>shared_fontAwesomeJavaScript</code> <code>formError</code> <code>shared_formError</code> <code>formNotice</code> <code>shared_formNotice</code> <code>formSuccess</code> <code>shared_formSuccess</code> <code>languageChooser</code> <code>shared_languageChooser</code> <code>lineBreakSeparatedTextOptionType</code> <code>shared_lineBreakSeparatedTextOptionType</code> <code>mediaManager</code> <code>shared_mediaManager</code> <code>messageFormAttachments</code> <code>shared_messageFormAttachments</code> <code>messageTableOfContents</code> <code>shared_messageTableOfContents</code> <code>multipleLanguageInputJavascript</code> <code>shared_multipleLanguageInputJavascript</code> <code>passwordStrengthLanguage</code> <code>shared_passwordStrengthLanguage</code> <code>quoteMetaCode</code> <code>shared_quoteMetaCode</code> <code>radioButtonSearchableOptionType</code> <code>shared_radioButtonSearchableOptionType</code> <code>recaptcha</code> <code>shared_recaptcha</code> <code>scrollablePageCheckboxList</code> <code>shared_scrollablePageCheckboxList</code> <code>sitemapEnd</code> <code>shared_sitemapEnd</code> <code>sitemapEntry</code> <code>shared_sitemapEntry</code> <code>sitemapIndex</code> <code>shared_sitemapIndex</code> <code>sitemapStart</code> <code>shared_sitemapStart</code> <code>trophyImage</code> <code>shared_trophyImage</code> <code>unfurlUrl</code> <code>shared_unfurlUrl</code> <code>uploadFieldComponent</code> <code>shared_uploadFieldComponent</code> <code>userBBCodeTag</code> <code>shared_bbcode_user</code> <code>userConditions</code> <code>shared_userConditions</code> <code>userOptionsCondition</code> <code>shared_userOptionsCondition</code> <code>worker</code> <code>shared_worker</code> <code>wysiwyg</code> <code>shared_wysiwyg</code> <code>groupBBCodeTag</code> <code>shared_bbcode_group</code> <code>__videoAttachmentBBCode</code> <code>shared_bbcode_attach_video</code> <code>__audioAttachmentBBCode</code> <code>shared_bbcode_attach_audio</code> <code>mediaBBCodeTag</code> <code>shared_bbcode_wsm</code> <code>articleBBCodeTag</code> <code>shared_bbcode_wsa</code> <code>__multiPageCondition</code> <code>shared_multiPageCondition</code> <code>__multilineItemListFormField</code> <code>shared_multilineItemListFormField</code>"},{"location":"migration/wsc60/templates/#migration","title":"Migration","text":"<p>We provide a helper script that automates the task of updating the template includes. The script will search for <code>{include file='old_template_name'}</code> and ensure that any content before or after the <code>file='old_template_name'</code> remains available within the <code>{include}</code> tag.</p> <p>The helper script is part of WoltLab Suite Core and can be found in the repository at <code>extra/migrate-shared-template.php</code>. The script must be executed from CLI and requires PHP 8.1.</p> <pre><code>$> php extra/migrate-shared-template.php /path/to/the/target/directory/\n</code></pre> <p>The script will recursively search the specified target directory for files with the <code>tpl</code> extension.</p>"},{"location":"package/acp-menu-items/","title":"ACP Menu Items","text":"<p>The API for the ACP menu items allows you to add your own menu items in the admin panel for your package.</p> <p>Since WoltLab Suite 6.1 you can attach an event listener to the <code>wcf\\event\\acp\\menu\\item\\ItemCollecting</code> event inside a bootstrap script to lazily register your ACP menu items.</p> <p>The <code>register</code> method of the event expects an object of the type <code>wcf\\system\\menu\\acp\\AcpMenuItem</code> as a parameter. An <code>AcpMenuItem</code> object consists of the following parameters:</p> Name Type Description <code>$menuItem</code> string Identifier of the item; must be unique <code>$title</code> string (Optional) title of the item; if omitted <code>$menuItem</code> is used as language variable <code>$parentMenuItem</code> string (Optional) identifier of the parent item <code>$link</code> string (Optional) URL of the linked page <code>$icon</code> ?FontAwesomeIcon (Optional) icon of the item <p>Example:</p> <pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\menu\\acp\\AcpMenuItem;\nuse wcf\\event\\acp\\menu\\item\\ItemCollecting;\nuse wcf\\system\\request\\LinkHandler;\nuse wcf\\system\\style\\FontAwesomeIcon;\n\nreturn static function (): void {\n EventHandler::getInstance()->register(ItemCollecting::class, static function (ItemCollecting $event) {\n $event->register(new AcpMenuItem(\n \"com.woltlab.foor.bar\",\n 'Example Title',\n 'wcf.acp.menu.link.application'\n ));\n\n if ($currentUserHasSomeSpecificPermission) {\n $event->register(new AcpMenuItem(\n \"com.woltlab.foor.bar.add\",\n 'Example Add Title',\n \"com.woltlab.foor.bar\",\n LinkHandler::getInstance()->getControllerLink(FooAddForm::class),\n FontAwesomeIcon::fromString('plus;false')\n ));\n }\n });\n};\n</code></pre>"},{"location":"package/bootstrap-scripts/","title":"Bootstrap Scripts","text":"<p>Package-specific bootstrap scripts allow a package to execute logic during the application boot to prepare the environment before the request is passed through the middleware pipeline into the controller in <code>RequestHandler</code>.</p> <p>Bootstrap scripts are stored in the <code>lib/bootstrap/</code> directory of WoltLab Suite Core with the package identifier as the file name. They do not need to be registered explicitly, as one future goal of the bootstrap scripts is reducing the amount of system state that needs to be stored within the database. Instead WoltLab Suite Core will automatically create a bootstrap loader that includes all installed bootstrap scripts as part of the package installation and uninstallation process.</p> <p>Bootstrap scripts will be loaded and the bootstrap functions will executed based on a topological sorting of all installed packages. A package can rely on all bootstrap scripts of its dependencies being loaded before its own bootstrap script is loaded. It can also rely on all bootstrap functions of its dependencies having executed before its own bootstrap functions is executed. However it cannot rely on any specific loading and execution order of non-dependencies.</p> <p>As hinted at in the previous paragraph, executing the bootstrap scripts happens in two phases:</p> <ol> <li>All bootstrap scripts will be <code>include()</code>d in topological order. The script is expected to return a <code>Closure</code> that is executed in phase 2.</li> <li>Once all bootstrap scripts have been included, the returned <code>Closure</code>s will be executed in the same order the bootstrap scripts were loaded.</li> </ol> files/lib/bootstrap/com.example.foo.php<pre><code><?php\n\n// Phase (1).\n\nreturn static function (): void {\n // Phase (2).\n};\n</code></pre> <p>For the vast majority of packages it is expected that the phase (1) bootstrapping is not used, except to return the <code>Closure</code>. Instead the logic should reside in the <code>Closure</code>s body that is executed in phase (2).</p>"},{"location":"package/bootstrap-scripts/#registering-ievent-listeners","title":"Registering <code>IEvent</code> listeners","text":"<p>An example use case for bootstrap scripts is registering event listeners for <code>IEvent</code>-based events, instead of using the eventListener PIP. Registering event listeners within the bootstrap script allows you to leverage your IDE\u2019s autocompletion for class names and and prevents forgetting the explicit uninstallation of old event listeners during a package upgrade.</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\event\\listener\\ValueDumpListener;\nuse wcf\\system\\foo\\event\\ValueAvailable;\n\nreturn static function (): void {\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n ValueDumpListener::class\n );\n\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n static function (ValueAvailable $event): void {\n // For simple use cases a `Closure` instead of a class name may be used.\n \\var_dump($event->getValue());\n }\n );\n};\n</code></pre>"},{"location":"package/database-php-api/","title":"Database PHP API","text":"<p>While the sql package installation plugin supports adding and removing tables, columns, and indices, it is not able to handle cases where the added table, column, or index already exist. We have added a new PHP-based API to manipulate the database scheme which can be used in combination with the database package installation plugin that skips parts that already exist:</p> <pre><code>return [\n // list of `DatabaseTable` objects\n];\n</code></pre> <p>All of the relevant components can be found in the <code>wcf\\system\\database\\table</code> namespace.</p>"},{"location":"package/database-php-api/#database-tables","title":"Database Tables","text":"<p>There are two classes representing database tables: <code>DatabaseTable</code> and <code>PartialDatabaseTable</code>. If a new table should be created, use <code>DatabaseTable</code>. In all other cases, <code>PartialDatabaseTable</code> should be used as it provides an additional save-guard against accidentally creating a new table by having a typo in the table name: If the tables does not already exist, a table represented by <code>PartialDatabaseTable</code> will cause an exception (while a <code>DatabaseTable</code> table will simply be created).</p> <p>To create a table, a <code>DatabaseTable</code> object with the table's name as to be created and table's columns, foreign keys and indices have to be specified:</p> <pre><code>DatabaseTable::create('foo1_bar')\n ->columns([\n // columns\n ])\n ->foreignKeys([\n // foreign keys\n ])\n ->indices([\n // indices\n ])\n</code></pre> <p>To update a table, the same code as above can be used, except for <code>PartialDatabaseTable</code> being used instead of <code>DatabaseTable</code>.</p> <p>To drop a table, only the <code>drop()</code> method has to be called:</p> <pre><code>PartialDatabaseTable::create('foo1_bar')\n ->drop()\n</code></pre>"},{"location":"package/database-php-api/#columns","title":"Columns","text":"<p>To represent a column of a database table, you have to create an instance of the relevant column class found in the <code>wcf\\system\\database\\table\\column</code> namespace. Such instances are created similarly to database table objects using the <code>create()</code> factory method and passing the column name as the parameter.</p> <p>Every column type supports the following methods:</p> <ul> <li><code>defaultValue($defaultValue)</code> sets the default value of the column (default: none).</li> <li><code>drop()</code> to drop the column.</li> <li><code>notNull($notNull = true)</code> sets if the value of the column can be <code>NULL</code> (default: <code>false</code>).</li> </ul> <p>Depending on the specific column class implementing additional interfaces, the following methods are also available:</p> <ul> <li><code>IAutoIncrementDatabaseTableColumn::autoIncrement($autoIncrement = true)</code> sets if the value of the colum is auto-incremented.</li> <li><code>IDecimalsDatabaseTableColumn::decimals($decimals)</code> sets the number of decimals the column supports.</li> <li><code>IEnumDatabaseTableColumn::enumValues(array $values)</code> sets the predetermined set of valid values of the column.</li> <li><code>ILengthDatabaseTableColumn::length($length)</code> sets the (maximum) length of the column.</li> </ul> <p>Additionally, there are some additionally classes of commonly used columns with specific properties:</p> <ul> <li><code>DefaultFalseBooleanDatabaseTableColumn</code> (a <code>tinyint</code> column with length <code>1</code>, default value <code>0</code> and whose values cannot be <code>null</code>)</li> <li><code>DefaultTrueBooleanDatabaseTableColumn</code> (a <code>tinyint</code> column with length <code>1</code>, default value <code>1</code> and whose values cannot be <code>null</code>)</li> <li><code>NotNullInt10DatabaseTableColumn</code> (a <code>int</code> column with length <code>10</code> and whose values cannot be <code>null</code>)</li> <li><code>NotNullVarchar191DatabaseTableColumn</code> (a <code>varchar</code> column with length <code>191</code> and whose values cannot be <code>null</code>)</li> <li><code>NotNullVarchar255DatabaseTableColumn</code> (a <code>varchar</code> column with length <code>255</code> and whose values cannot be <code>null</code>)</li> <li><code>ObjectIdDatabaseTableColumn</code> (a <code>int</code> column with length <code>10</code>, whose values cannot be <code>null</code>, and whose values are auto-incremented)</li> </ul> <p>Examples:</p> <pre><code>DefaultFalseBooleanDatabaseTableColumn::create('isDisabled')\n\nNotNullInt10DatabaseTableColumn::create('fooTypeID')\n\nSmallintDatabaseTableColumn::create('bar')\n ->length(5)\n ->notNull()\n</code></pre>"},{"location":"package/database-php-api/#foreign-keys","title":"Foreign Keys","text":"<p>Foreign keys are represented by <code>DatabaseTableForeignKey</code> objects: </p> <pre><code>DatabaseTableForeignKey::create()\n ->columns(['fooID'])\n ->referencedTable('wcf1_foo')\n ->referencedColumns(['fooID'])\n ->onDelete('CASCADE')\n</code></pre> <p>The supported actions for <code>onDelete()</code> and <code>onUpdate()</code> are <code>CASCADE</code>, <code>NO ACTION</code>, and <code>SET NULL</code>. To drop a foreign key, all of the relevant data to create the foreign key has to be present and the <code>drop()</code> method has to be called.</p> <p><code>DatabaseTableForeignKey::create()</code> also supports the foreign key name as a parameter. If it is not present, <code>DatabaseTable::foreignKeys()</code> will automatically set one based on the foreign key's data.</p>"},{"location":"package/database-php-api/#indices","title":"Indices","text":"<p>Indices are represented by <code>DatabaseTableIndex</code> objects: </p> <pre><code>DatabaseTableIndex::create('fooID')\n ->type(DatabaseTableIndex::UNIQUE_TYPE)\n ->columns(['fooID'])\n</code></pre> <p>There are four different types: <code>DatabaseTableIndex::DEFAULT_TYPE</code> (default), <code>DatabaseTableIndex::PRIMARY_TYPE</code>, <code>DatabaseTableIndex::UNIQUE_TYPE</code>, and <code>DatabaseTableIndex::FULLTEXT_TYPE</code>. For primary keys, there is also the <code>DatabaseTablePrimaryIndex</code> class which automatically sets the type to <code>DatabaseTableIndex::PRIMARY_TYPE</code>. To drop a index, all of the relevant data to create the index has to be present and the <code>drop()</code> method has to be called.</p> <p>The index name is specified as the parameter to <code>DatabaseTableIndex::create()</code>. It is strongly recommended to specify an explicit name (WoltLab/WCF#4505). If no name is given, <code>DatabaseTable::indices()</code> will automatically set one based on the index data.</p>"},{"location":"package/package-xml/","title":"package.xml","text":"<p>The <code>package.xml</code> is the core component of every package. It provides the meta data (e.g. package name, description, author) and the instruction set for a new installation and/or updating from a previous version.</p>"},{"location":"package/package-xml/#example","title":"Example","text":"package.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package name=\"com.example.package\" xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/package.xsd\">\n <packageinformation>\n <packagename>Simple Package</packagename>\n <packagedescription>A simple package to demonstrate the package system of WoltLab Suite Core</packagedescription>\n <version>1.0.0</version>\n <date>2022-01-17</date>\n </packageinformation>\n\n <authorinformation>\n <author>YOUR NAME</author>\n <authorurl>http://www.example.com</authorurl>\n </authorinformation>\n\n <requiredpackages>\n <requiredpackage minversion=\"6.0.0\">com.woltlab.wcf</requiredpackage>\n </requiredpackages>\n\n <excludedpackages>\n <excludedpackage version=\"7.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n\n <instructions type=\"install\">\n <instruction type=\"file\" />\n <instruction type=\"template\">templates.tar</instruction>\n </instructions>\n</package>\n</code></pre>"},{"location":"package/package-xml/#elements","title":"Elements","text":""},{"location":"package/package-xml/#package","title":"<code><package></code>","text":"<p>The root node of every <code>package.xml</code> it contains the reference to the namespace and the location of the XML Schema Definition (XSD).</p> <p>The attribute <code>name</code> is the most important part, it holds the unique package identifier and is mandatory. It is based upon your domain name and the package name of your choice.</p> <p>For example WoltLab Suite Forum (formerly know an WoltLab Burning Board and usually abbreviated as <code>wbb</code>) is created by WoltLab which owns the domain <code>woltlab.com</code>. The resulting package identifier is <code>com.woltlab.wbb</code> (<code><tld>.<domain>.<packageName></code>).</p>"},{"location":"package/package-xml/#packageinformation","title":"<code><packageinformation></code>","text":"<p>Holds the entire meta data of the package.</p>"},{"location":"package/package-xml/#packagename","title":"<code><packagename></code>","text":"<p>This is the actual package name displayed to the end user, this can be anything you want, try to keep it short. It supports the attribute <code>language</code> which allows you to provide the package name in different languages, please be aware that if it is not present, <code>en</code> (English) is assumed:</p> <pre><code><packageinformation>\n <packagename>Simple Package</packagename>\n <packagename language=\"de\">Einfaches Paket</packagename>\n</packageinformation>\n</code></pre>"},{"location":"package/package-xml/#packagedescription","title":"<code><packagedescription></code>","text":"<p>Brief summary of the package, use it to explain what it does since the package name might not always be clear enough. The attribute <code>language</code> can also be used here, please reference to <code><packagename></code> for details.</p>"},{"location":"package/package-xml/#version","title":"<code><version></code>","text":"<p>The package's version number, this is a string consisting of three numbers separated with a dot and optionally followed by a keyword (must be followed with another number).</p> <p>The possible keywords are:</p> <ul> <li>Alpha/dev (both is regarded to be the same)</li> <li>Beta</li> <li>RC (release candidate)</li> </ul> <p>Valid examples:</p> <ul> <li>1.0.0</li> <li>1.12.13 Alpha 19</li> </ul> <p>Invalid examples:</p> <ul> <li>1.0.0 Beta (keyword Beta must be followed by a number)</li> <li>2.0 RC 3 (version number must consist of 3 blocks of numbers)</li> <li>1.2.3 dev 4.5 (4.5 is not an integer, 4 or 5 would be valid but not the fraction)</li> </ul>"},{"location":"package/package-xml/#date","title":"<code><date></code>","text":"<p>Must be a valid ISO 8601 date, e.g. <code>2013-12-27</code>.</p>"},{"location":"package/package-xml/#packageurl","title":"<code><packageurl></code>","text":"<p>(optional)</p> <p>URL to the package website that provides detailed information about the package.</p>"},{"location":"package/package-xml/#license","title":"<code><license></code>","text":"<p>(optional)</p> <p>Name of a generic license type or URL to a custom license. The attribute <code>language</code> can also be used here, please reference to <code><packagename></code> for details.</p>"},{"location":"package/package-xml/#authorinformation","title":"<code><authorinformation></code>","text":"<p>Holds meta data regarding the package's author.</p>"},{"location":"package/package-xml/#author","title":"<code><author></code>","text":"<p>Can be anything you want.</p>"},{"location":"package/package-xml/#authorurl","title":"<code><authorurl></code>","text":"<p>(optional)</p> <p>URL to the author's website.</p>"},{"location":"package/package-xml/#requiredpackages","title":"<code><requiredpackages></code>","text":"<p>A list of packages including their version required for this package to work.</p>"},{"location":"package/package-xml/#requiredpackage","title":"<code><requiredpackage></code>","text":"<p>Example:</p> <pre><code><requiredpackage minversion=\"2.7.5\" file=\"requirements/com.example.foo.tar\">com.example.foo</requiredpackage>\n</code></pre> <p>The attribute <code>minversion</code> must be a valid version number as described in <code><version></code>. The <code>file</code> attribute is optional and specifies the location of the required package's archive relative to the <code>package.xml</code>.</p>"},{"location":"package/package-xml/#optionalpackage","title":"<code><optionalpackage></code>","text":"<p>A list of optional packages which can be selected by the user at the very end of the installation process.</p>"},{"location":"package/package-xml/#optionalpackage_1","title":"<code><optionalpackage></code>","text":"<p>Example:</p> <pre><code><optionalpackage file=\"optionals/com.example.bar.tar\">com.example.bar</optionalpackage>\n</code></pre> <p>The <code>file</code> attribute specifies the location of the optional package's archive relative to the <code>package.xml</code>.</p>"},{"location":"package/package-xml/#excludedpackages","title":"<code><excludedpackages></code>","text":"<p>List of packages which conflict with this package. It is not possible to install it if any of the specified packages is installed. In return you cannot install an excluded package if this package is installed.</p>"},{"location":"package/package-xml/#excludedpackage","title":"<code><excludedpackage></code>","text":"<p>Example:</p> <pre><code><excludedpackage version=\"7.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n</code></pre> <p>The attribute <code>version</code> must be a valid version number as described in the \\<version> section. In the example above it will be impossible to install this package in WoltLab Suite Core 7.0.0 Alpha 1 or higher.</p>"},{"location":"package/package-xml/#instructions","title":"<code><instructions></code>","text":"<p>List of instructions to be executed upon install or update. The order is important, the topmost <code><instruction></code> will be executed first.</p>"},{"location":"package/package-xml/#instructions-typeinstall","title":"<code><instructions type=\"install\"></code>","text":"<p>List of instructions for a new installation of this package.</p>"},{"location":"package/package-xml/#instructions-typeupdate-fromversion","title":"<code><instructions type=\"update\" fromversion=\"\u2026\"></code>","text":"<p>The attribute <code>fromversion</code> must be a valid version number as described in the \\<version> section and specifies a possible update from that very version to the package's version.</p> <p>The installation process will pick exactly one update instruction, ignoring everything else. Please read the explanation below!</p> <p>Example:</p> <ul> <li>Installed version: <code>1.0.0</code></li> <li>Package version: <code>1.0.2</code></li> </ul> <pre><code><instructions type=\"update\" fromversion=\"1.0.0\">\n <!-- \u2026 -->\n</instructions>\n<instructions type=\"update\" fromversion=\"1.0.1\">\n <!-- \u2026 -->\n</instructions>\n</code></pre> <p>In this example WoltLab Suite Core will pick the first update block since it allows an update from <code>1.0.0 -> 1.0.2</code>. The other block is not considered, since the currently installed version is <code>1.0.0</code>. After applying the update block (<code>fromversion=\"1.0.0\"</code>), the version now reads <code>1.0.2</code>.</p>"},{"location":"package/package-xml/#instruction","title":"<code><instruction></code>","text":"<p>Example:</p> <pre><code><instruction type=\"objectTypeDefinition\">objectTypeDefinition.xml</instruction>\n</code></pre> <p>The attribute <code>type</code> specifies the instruction type which is used to determine the package installation plugin (PIP) invoked to handle its value. The value must be a valid file relative to the location of <code>package.xml</code>. Many PIPs provide default file names which are used if no value is given:</p> <pre><code><instruction type=\"objectTypeDefinition\" />\n</code></pre> <p>There is a list of all default PIPs available.</p> <p>Both the <code>type</code>-attribute and the element value are case-sensitive. Windows does not care if the file is called <code>objecttypedefinition.xml</code> but was referenced as <code>objectTypeDefinition.xml</code>, but both Linux and Mac systems will be unable to find the file.</p> <p>In addition to the <code>type</code> attribute, an optional <code>run</code> attribute (with <code>standalone</code> as the only valid value) is supported which forces the installation to execute this PIP in an isolated request, allowing a single, resource-heavy PIP to execute without encountering restrictions such as PHP\u2019s <code>memory_limit</code> or <code>max_execution_time</code>:</p> <pre><code><instruction type=\"file\" run=\"standalone\" />\n</code></pre>"},{"location":"package/package-xml/#void","title":"<code><void/></code>","text":"<p>Sometimes a package update should only adjust the metadata of the package, for example, an optional package was added. However, WoltLab Suite Core requires that the list of <code><instructions></code> is non-empty. Instead of using a dummy <code><instruction></code> that idempotently updates some PIP, the <code><void/></code> tag can be used for this use-case.</p> <p>Using the <code><void/></code> tag is only valid for <code><instructions type=\"update\"></code> and must not be accompanied by other <code><instruction></code> tags.</p> <p>Example:</p> <pre><code><instructions type=\"update\" fromversion=\"1.0.0\">\n <void/>\n</instructions>\n</code></pre>"},{"location":"package/pip/","title":"Package Installation Plugins","text":"<p>Package Installation Plugins (PIPs) are interfaces to deploy and edit content as well as components.</p> <p>For XML-based PIPs: <code><![CDATA[]]></code> must be used for language items and page contents. In all other cases it may only be used when necessary.</p>"},{"location":"package/pip/#built-in-pips","title":"Built-In PIPs","text":"Name Description aclOption Customizable permissions for individual objects acpMenu Admin panel menu categories and items acpSearchProvider Data provider for the admin panel search acpTemplate Admin panel templates acpTemplateDelete Deletes admin panel templates installed with acpTemplate bbcode BBCodes for rich message formatting box Boxes that can be placed anywhere on a page clipboardAction Perform bulk operations on marked objects coreObject Access Singletons from within the template cronjob Periodically execute code with customizable intervals database Updates the database layout using the PHP API eventListener Register listeners for the event system file Deploy any type of files with the exception of templates fileDelete Deletes files installed with file language Language items mediaProvider Detect and convert links to media providers menu Side-wide and custom per-page menus menuItem Menu items for menus created through the menu PIP objectType Flexible type registry based on definitions objectTypeDefinition Groups objects and classes by functionality option Side-wide configuration options page Register page controllers and text-based pages pip Package Installation Plugins script Execute arbitrary PHP code during installation, update and uninstallation smiley Smileys sql Execute SQL instructions using a MySQL-flavored syntax (also see database PHP API) style Style template Frontend templates templateDelete Deletes frontend templates installed with template templateListener Embed template code into templates without altering the original userGroupOption Permissions for user groups userMenu User menu categories and items userNotificationEvent Events of the user notification system userOption User settings userProfileMenu User profile tabs"},{"location":"package/pip/acl-option/","title":"ACL Option Package Installation Plugin","text":"<p>Add customizable permissions for individual objects.</p>"},{"location":"package/pip/acl-option/#option-components","title":"Option Components","text":"<p>Each acl option is described as an <code><option></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/acl-option/#categoryname","title":"<code><categoryname></code>","text":"<p>Optional</p> <p>The name of the acl option category to which the option belongs.</p>"},{"location":"package/pip/acl-option/#objecttype","title":"<code><objecttype></code>","text":"<p>The name of the acl object type (of the object type definition <code>com.woltlab.wcf.acl</code>).</p>"},{"location":"package/pip/acl-option/#category-components","title":"Category Components","text":"<p>Each acl option category is described as an <code><category></code> element with the mandatory attribute <code>name</code> that should follow the naming pattern <code><permissionName></code> or <code><permissionType>.<permissionName></code>, with <code><permissionType></code> generally having <code>user</code> or <code>mod</code> as value.</p>"},{"location":"package/pip/acl-option/#objecttype_1","title":"<code><objecttype></code>","text":"<p>The name of the acl object type (of the object type definition <code>com.woltlab.wcf.acl</code>).</p>"},{"location":"package/pip/acl-option/#example","title":"Example","text":"aclOption.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/aclOption.xsd\">\n <import>\n <categories>\n <category name=\"user.example\">\n <objecttype>com.example.wcf.example</objecttype>\n </category>\n <category name=\"mod.example\">\n <objecttype>com.example.wcf.example</objecttype>\n </category>\n </categories>\n\n <options>\n <option name=\"canAddExample\">\n <categoryname>user.example</categoryname>\n <objecttype>com.example.wcf.example</objecttype>\n </option>\n <option name=\"canDeleteExample\">\n <categoryname>mod.example</categoryname>\n <objecttype>com.example.wcf.example</objecttype>\n </option>\n </options>\n </import>\n\n <delete>\n <optioncategory name=\"old.example\">\n <objecttype>com.example.wcf.example</objecttype>\n </optioncategory>\n <option name=\"canDoSomethingWithExample\">\n <objecttype>com.example.wcf.example</objecttype>\n </option>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/acp-menu/","title":"ACP Menu Package Installation Plugin","text":"<p>Registers new ACP menu items.</p>"},{"location":"package/pip/acp-menu/#components","title":"Components","text":"<p>Each item is described as an <code><acpmenuitem></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/acp-menu/#parent","title":"<code><parent></code>","text":"<p>Optional</p> <p>The item\u2019s parent item.</p>"},{"location":"package/pip/acp-menu/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this item within the parent item.</p>"},{"location":"package/pip/acp-menu/#controller","title":"<code><controller></code>","text":"<p>The fully qualified class name of the target controller. If not specified this item serves as a category.</p>"},{"location":"package/pip/acp-menu/#link","title":"<code><link></code>","text":"<p>Additional components if <code><controller></code> is set, the full external link otherwise.</p>"},{"location":"package/pip/acp-menu/#icon","title":"<code><icon></code>","text":"<p>Use an icon only for top-level and 4th-level items.</p> <p>Name of the Font Awesome icon class.</p>"},{"location":"package/pip/acp-menu/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the tab to be shown.</p>"},{"location":"package/pip/acp-menu/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the tab to be shown.</p>"},{"location":"package/pip/acp-menu/#example","title":"Example","text":"acpMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/acpMenu.xsd\">\n <import>\n <acpmenuitem name=\"foo.acp.menu.link.example\">\n <parent>wcf.acp.menu.link.application</parent>\n </acpmenuitem>\n\n <acpmenuitem name=\"foo.acp.menu.link.example.list\">\n <controller>foo\\acp\\page\\ExampleListPage</controller>\n <parent>foo.acp.menu.link.example</parent>\n <permissions>admin.foo.canManageExample</permissions>\n <showorder>1</showorder>\n </acpmenuitem>\n\n <acpmenuitem name=\"foo.acp.menu.link.example.add\">\n <controller>foo\\acp\\form\\ExampleAddForm</controller>\n <parent>foo.acp.menu.link.example.list</parent>\n <permissions>admin.foo.canManageExample</permissions>\n <icon>plus</icon>\n </acpmenuitem>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/acp-search-provider/","title":"ACP Search Provider Package Installation Plugin","text":"<p>Registers data provider for the admin panel search.</p>"},{"location":"package/pip/acp-search-provider/#components","title":"Components","text":"<p>Each acp search result provider is described as an <code><acpsearchprovider></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/acp-search-provider/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the search results, the class has to implement the <code>wcf\\system\\search\\acp\\IACPSearchResultProvider</code> interface.</p>"},{"location":"package/pip/acp-search-provider/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the search result list the provided results are shown.</p>"},{"location":"package/pip/acp-search-provider/#example","title":"Example","text":"acpSearchProvider.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/acpSearchProvider.xsd\">\n <import>\n <acpsearchprovider name=\"com.woltlab.wcf.example\">\n <classname>wcf\\system\\search\\acp\\ExampleACPSearchResultProvider</classname>\n <showorder>1</showorder>\n </acpsearchprovider>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/acp-template-delete/","title":"ACP Template Delete Package Installation Plugin","text":"<p>Deletes admin panel templates installed with the acpTemplate package installation plugin.</p> <p>You cannot delete acp templates provided by other packages.</p>"},{"location":"package/pip/acp-template-delete/#components","title":"Components","text":"<p>Each item is described as a <code><template></code> element with an optional <code>application</code>, which behaves like it does for acp templates. The templates are identified by their name like when adding template listeners, i.e. by the file name without the <code>.tpl</code> file extension.</p>"},{"location":"package/pip/acp-template-delete/#example","title":"Example","text":"acpTemplateDelete.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/acpTemplateDelete.xsd\">\n <delete>\n <template>fouAdd</template>\n <template application=\"app\">__appAdd</template>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/acp-template/","title":"ACP Template Installation Plugin","text":"<p>Add templates for acp pages and forms by providing an archive containing the template files.</p> <p>You cannot overwrite acp templates provided by other packages.</p>"},{"location":"package/pip/acp-template/#archive","title":"Archive","text":"<p>The <code>acpTemplate</code> package installation plugins expects a <code>.tar</code> (recommended) or <code>.tar.gz</code> archive. The templates must all be in the root of the archive. Do not include any directories in the archive. The file path given in the <code>instruction</code> element as its value must be relative to the <code>package.xml</code> file.</p>"},{"location":"package/pip/acp-template/#attributes","title":"Attributes","text":""},{"location":"package/pip/acp-template/#application","title":"<code>application</code>","text":"<p>The <code>application</code> attribute determines to which application the installed acp templates belong and thus in which directory the templates are installed. The value of the <code>application</code> attribute has to be the abbreviation of an installed application. If no <code>application</code> attribute is given, the following rules are applied:</p> <ul> <li>If the package installing the acp templates is an application, then the templates will be installed in this application's directory.</li> <li>If the package installing the acp templates is no application, then the templates will be installed in WoltLab Suite Core's directory.</li> </ul>"},{"location":"package/pip/acp-template/#example-in-packagexml","title":"Example in <code>package.xml</code>","text":"<pre><code><instruction type=\"acpTemplate\" />\n<!-- is the same as -->\n<instruction type=\"acpTemplate\">acptemplates.tar</instruction>\n\n<!-- if an application \"com.woltlab.example\" is being installed, the following lines are equivalent -->\n<instruction type=\"acpTemplate\" />\n<instruction type=\"acpTemplate\" application=\"example\" />\n</code></pre>"},{"location":"package/pip/bbcode/","title":"BBCode Package Installation Plugin","text":"<p>Registers new BBCodes.</p>"},{"location":"package/pip/bbcode/#components","title":"Components","text":"<p>Each bbcode is described as an <code><bbcode></code> element with the mandatory attribute <code>name</code>. The <code>name</code> attribute must contain alphanumeric characters only and is exposed to the user.</p>"},{"location":"package/pip/bbcode/#htmlopen","title":"<code><htmlopen></code>","text":"<p>Optional: Must not be provided if the BBCode is being processed a PHP class (<code><classname></code>).</p> <p>The contents of this tag are literally copied into the opening tag of the bbcode.</p>"},{"location":"package/pip/bbcode/#htmlclose","title":"<code><htmlclose></code>","text":"<p>Optional: Must not be provided if <code><htmlopen></code> is not given.</p> <p>Must match the <code><htmlopen></code> tag. Do not provide for self-closing tags.</p>"},{"location":"package/pip/bbcode/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the bbcode output, the class has to implement the <code>wcf\\system\\bbcode\\IBBCode</code> interface.</p> <p>BBCodes can be statically converted to HTML during input processing using a <code>wcf\\system\\html\\metacode\\converter\\*MetaConverter</code> class. This class does not need to be registered.</p>"},{"location":"package/pip/bbcode/#wysiwygicon","title":"<code><wysiwygicon></code>","text":"<p>Optional</p> <p>Name of the Font Awesome icon class or path to a <code>gif</code>, <code>jpg</code>, <code>jpeg</code>, <code>png</code>, or <code>svg</code> image (placed inside the <code>icon/</code> directory) to show in the editor toolbar.</p>"},{"location":"package/pip/bbcode/#buttonlabel","title":"<code><buttonlabel></code>","text":"<p>Optional: Must be provided if an icon is given.</p> <p>Explanatory text to show when hovering the icon.</p>"},{"location":"package/pip/bbcode/#sourcecode","title":"<code><sourcecode></code>","text":"<p>Do not set this to <code>1</code> if you don't specify a PHP class for processing. You must perform XSS sanitizing yourself!</p> <p>If set to <code>1</code> contents of this BBCode will not be interpreted, but literally passed through instead.</p>"},{"location":"package/pip/bbcode/#isblockelement","title":"<code><isBlockElement></code>","text":"<p>Set to <code>1</code> if the output of this BBCode is a HTML block element (according to the HTML specification).</p>"},{"location":"package/pip/bbcode/#attributes","title":"<code><attributes></code>","text":"<p>Each bbcode is described as an <code><attribute></code> element with the mandatory attribute <code>name</code>. The <code>name</code> attribute is a 0-indexed integer.</p>"},{"location":"package/pip/bbcode/#html","title":"<code><html></code>","text":"<p>Optional: Must not be provided if the BBCode is being processed a PHP class (<code><classname></code>).</p> <p>The contents of this tag are copied into the opening tag of the bbcode. <code>%s</code> is replaced by the attribute value.</p>"},{"location":"package/pip/bbcode/#validationpattern","title":"<code><validationpattern></code>","text":"<p>Optional</p> <p>Defines a regular expression that is used to validate the value of the attribute.</p>"},{"location":"package/pip/bbcode/#required","title":"<code><required></code>","text":"<p>Optional</p> <p>Specifies whether this attribute must be provided.</p>"},{"location":"package/pip/bbcode/#usetext","title":"<code><usetext></code>","text":"<p>Optional</p> <p>Should only be set to <code>1</code> for the attribute with name <code>0</code>.</p> <p>Specifies whether the text content of the BBCode should become this attribute's value.</p>"},{"location":"package/pip/bbcode/#example","title":"Example","text":"bbcode.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/bbcode.xsd\">\n <import>\n <bbcode name=\"foo\">\n <classname>wcf\\system\\bbcode\\FooBBCode</classname>\n <attributes>\n <attribute name=\"0\">\n <validationpattern>^\\d+$</validationpattern>\n <required>1</required>\n </attribute>\n </attributes>\n </bbcode>\n\n <bbcode name=\"example\">\n <htmlopen>div</htmlopen>\n <htmlclose>div</htmlclose>\n <isBlockElement>1</isBlockElement>\n <wysiwygicon>bath</wysiwygicon>\n <buttonlabel>wcf.editor.button.example</buttonlabel>\n </bbcode>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/box/","title":"Box Package Installation Plugin","text":"<p>Deploy and manage boxes that can be placed anywhere on the site, they come in two flavors: system and content-based.</p>"},{"location":"package/pip/box/#components","title":"Components","text":"<p>Each item is described as a <code><box></code> element with the mandatory attribute <code>name</code> that should follow the naming pattern <code><packageIdentifier>.<BoxName></code>, e.g. <code>com.woltlab.wcf.RecentActivity</code>.</p>"},{"location":"package/pip/box/#name","title":"<code><name></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The internal name displayed in the admin panel only, can be fully customized by the administrator and is immutable. Only one value is accepted and will be picked based on the site's default language, but you can provide localized values by including multiple <code><name></code> elements.</p>"},{"location":"package/pip/box/#boxtype","title":"<code><boxType></code>","text":""},{"location":"package/pip/box/#system","title":"<code>system</code>","text":"<p>The special <code>system</code> type is reserved for boxes that pull their properties and content from a registered PHP class. Requires the <code><objectType></code> element.</p>"},{"location":"package/pip/box/#html-text-or-tpl","title":"<code>html</code>, <code>text</code> or <code>tpl</code>","text":"<p>Provide arbitrary content, requires the <code><content></code> element.</p>"},{"location":"package/pip/box/#objecttype","title":"<code><objectType></code>","text":"<p>Required for boxes with <code>boxType = system</code>, must be registered through the objectType PIP for the definition <code>com.woltlab.wcf.boxController</code>.</p>"},{"location":"package/pip/box/#position","title":"<code><position></code>","text":"<p>The default display position of this box, can be any of the following:</p> <ul> <li>bottom</li> <li>contentBottom</li> <li>contentTop</li> <li>footer</li> <li>footerBoxes</li> <li>headerBoxes</li> <li>hero</li> <li>sidebarLeft</li> <li>sidebarRight</li> <li>top</li> </ul>"},{"location":"package/pip/box/#placeholder-positions","title":"Placeholder Positions","text":""},{"location":"package/pip/box/#showheader","title":"<code><showHeader></code>","text":"<p>Setting this to <code>0</code> will suppress display of the box title, useful for boxes containing advertisements or similar. Defaults to <code>1</code>.</p>"},{"location":"package/pip/box/#visibleeverywhere","title":"<code><visibleEverywhere></code>","text":"<p>Controls the display on all pages (<code>1</code>) or none (<code>0</code>), can be used in conjunction with <code><visibilityExceptions></code>.</p>"},{"location":"package/pip/box/#visibilityexceptions","title":"<code><visibilityExceptions></code>","text":"<p>Inverts the <code><visibleEverywhere></code> setting for the listed pages only.</p>"},{"location":"package/pip/box/#cssclassname","title":"<code><cssClassName></code>","text":"<p>Provide a custom CSS class name that is added to the menu container, allowing further customization of the menu's appearance.</p>"},{"location":"package/pip/box/#content","title":"<code><content></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p>"},{"location":"package/pip/box/#title","title":"<code><title></code>","text":"<p>The title element is required and controls the box title shown to the end users.</p>"},{"location":"package/pip/box/#content_1","title":"<code><content></code>","text":"<p>The content that should be used to populate the box, only used and required if the <code>boxType</code> equals <code>text</code>, <code>html</code> and <code>tpl</code>.</p>"},{"location":"package/pip/box/#example","title":"Example","text":"box.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/box.xsd\">\n <import>\n <box identifier=\"com.woltlab.wcf.RecentActivity\">\n <name language=\"de\">Letzte Aktivit\u00e4ten</name>\n <name language=\"en\">Recent Activities</name>\n <boxType>system</boxType>\n <objectType>com.woltlab.wcf.recentActivityList</objectType>\n <position>contentBottom</position>\n <showHeader>0</showHeader>\n <visibleEverywhere>0</visibleEverywhere>\n <visibilityExceptions>\n <page>com.woltlab.wcf.Dashboard</page>\n </visibilityExceptions>\n <limit>10</limit>\n\n <content language=\"de\">\n <title>Letzte Aktivit\u00e4ten</title>\n </content>\n <content language=\"en\">\n <title>Recent Activities</title>\n </content>\n </box>\n </import>\n\n <delete>\n <box identifier=\"com.woltlab.wcf.RecentActivity\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/clipboard-action/","title":"Clipboard Action Package Installation Plugin","text":"<p>Registers clipboard actions.</p>"},{"location":"package/pip/clipboard-action/#components","title":"Components","text":"<p>Each clipboard action is described as an <code><action></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/clipboard-action/#actionclassname","title":"<code><actionclassname></code>","text":"<p>The name of the class used by the clipboard API to process the concrete action. The class has to implement the <code>wcf\\system\\clipboard\\action\\IClipboardAction</code> interface, best by extending <code>wcf\\system\\clipboard\\action\\AbstractClipboardAction</code>.</p>"},{"location":"package/pip/clipboard-action/#pages","title":"<code><pages></code>","text":"<p>Element with <code><page></code> children whose value contains the class name of the controller of the page on which the clipboard action is available.</p>"},{"location":"package/pip/clipboard-action/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the clipboard action list the action is shown.</p>"},{"location":"package/pip/clipboard-action/#example","title":"Example","text":"clipboardAction.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/clipboardAction.xsd\">\n <import>\n <action name=\"delete\">\n <actionclassname>wcf\\system\\clipboard\\action\\ExampleClipboardAction</actionclassname>\n <showorder>1</showorder>\n <pages>\n <page>wcf\\acp\\page\\ExampleListPage</page>\n </pages>\n </action>\n <action name=\"foo\">\n <actionclassname>wcf\\system\\clipboard\\action\\ExampleClipboardAction</actionclassname>\n <showorder>2</showorder>\n <pages>\n <page>wcf\\acp\\page\\ExampleListPage</page>\n </pages>\n </action>\n <action name=\"bar\">\n <actionclassname>wcf\\system\\clipboard\\action\\ExampleClipboardAction</actionclassname>\n <showorder>3</showorder>\n <pages>\n <page>wcf\\acp\\page\\ExampleListPage</page>\n </pages>\n </action>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/core-object/","title":"Core Object Package Installation Plugin","text":"<p>Registers <code>wcf\\system\\SingletonFactory</code> objects to be accessible in templates.</p>"},{"location":"package/pip/core-object/#components","title":"Components","text":"<p>Each item is described as a <code><coreobject></code> element with the mandatory element <code>objectname</code>.</p>"},{"location":"package/pip/core-object/#objectname","title":"<code><objectname></code>","text":"<p>The fully qualified class name of the class.</p>"},{"location":"package/pip/core-object/#example","title":"Example","text":"coreObject.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/coreObject.xsd\">\n <import>\n <coreobject>\n <objectname>wcf\\system\\example\\ExampleHandler</objectname>\n </coreobject>\n </import>\n</data>\n</code></pre> <p>This object can be accessed in templates via <code>$__wcf->getExampleHandler()</code> (in general: the method name begins with <code>get</code> and ends with the unqualified class name).</p>"},{"location":"package/pip/cronjob/","title":"Cronjob Package Installation Plugin","text":"<p>Registers new cronjobs. The cronjob schedular works similar to the <code>cron(8)</code> daemon, which might not available to web applications on regular webspaces. The main difference is that WoltLab Suite\u2019s cronjobs do not guarantee execution at the specified points in time: WoltLab Suite\u2019s cronjobs are triggered by regular visitors in an AJAX request, once the next execution point lies in the past.</p>"},{"location":"package/pip/cronjob/#components","title":"Components","text":"<p>Each cronjob is described as an <code><cronjob></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/cronjob/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the cronjob's behaviour, the class has to implement the <code>wcf\\system\\cronjob\\ICronjob</code> interface.</p>"},{"location":"package/pip/cronjob/#description","title":"<code><description></code>","text":"<p>The <code>language</code> attribute is optional and should specify the ISO-639-1 language code.</p> <p>Provides a human readable description for the administrator.</p>"},{"location":"package/pip/cronjob/#expression","title":"<code><expression></code>","text":"<p>The cronjob schedule. The expression accepts the same syntax as described in <code>crontab(5)</code> of a cron daemon.</p>"},{"location":"package/pip/cronjob/#canbeedited","title":"<code><canbeedited></code>","text":"<p>Controls whether the administrator may edit the fields of the cronjob. Defaults to <code>1</code>.</p>"},{"location":"package/pip/cronjob/#canbedisabled","title":"<code><canbedisabled></code>","text":"<p>Controls whether the administrator may disable the cronjob. Defaults to <code>1</code>.</p>"},{"location":"package/pip/cronjob/#isdisabled","title":"<code><isdisabled></code>","text":"<p>Controls whether the cronjob is disabled by default. Defaults to <code>0</code>.</p>"},{"location":"package/pip/cronjob/#options","title":"<code><options></code>","text":"<p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the template listener to be executed.</p>"},{"location":"package/pip/cronjob/#example","title":"Example","text":"cronjob.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/cronjob.xsd\">\n <import>\n <cronjob name=\"com.example.package.example\">\n <classname>wcf\\system\\cronjob\\ExampleCronjob</classname>\n <description>Serves as an example</description>\n <description language=\"de\">Stellt ein Beispiel dar</description>\n <expression>0 2 */2 * *</expression>\n <canbeedited>1</canbeedited>\n <canbedisabled>1</canbedisabled>\n </cronjob>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/database/","title":"Database Package Installation Plugin","text":"<p>Update the database layout using the PHP API.</p> <p>You must install the PHP script through the file package installation plugin.</p> <p>The installation will attempt to delete the script after successful execution.</p>"},{"location":"package/pip/database/#attributes","title":"Attributes","text":""},{"location":"package/pip/database/#application","title":"<code>application</code>","text":"<p>The <code>application</code> attribute must have the same value as the <code>application</code> attribute of the <code>file</code> package installation plugin instruction so that the correct file in the intended application directory is executed. For further information about the <code>application</code> attribute, refer to its documentation on the acpTemplate package installation plugin page.</p>"},{"location":"package/pip/database/#expected-value","title":"Expected value","text":"<p>The <code>database</code>-PIP expects a relative path to a <code>.php</code> file that returns an array of <code>DatabaseTable</code> objects.</p>"},{"location":"package/pip/database/#naming-convention","title":"Naming convention","text":"<p>The PHP script is deployed by using the file package installation plugin. To prevent it from colliding with other install script (remember: You cannot overwrite files created by another plugin), we highly recommend to make use of these naming conventions:</p> <ul> <li>Installation: <code>acp/database/install_<package>.php</code> (example: <code>acp/database/install_com.woltlab.wbb.php</code>)</li> <li>Update: <code>acp/database/update_<package>_<targetVersion>.php</code> (example: <code>acp/database/update_com.woltlab.wbb_5.4.1.php</code>)</li> </ul> <p><code><targetVersion></code> equals the version number of the current package being installed. If you're updating from <code>1.0.0</code> to <code>1.0.1</code>, <code><targetVersion></code> should read <code>1.0.1</code>.</p> <p>If you run multiple update scripts, you can append additional information in the filename.</p>"},{"location":"package/pip/database/#execution-environment","title":"Execution environment","text":"<p>The script is included using <code>include()</code> within DatabasePackageInstallationPlugin::updateDatabase().</p>"},{"location":"package/pip/event-listener/","title":"Event Listener Package Installation Plugin","text":"<p>Registers event listeners. An explanation of events and event listeners can be found here.</p>"},{"location":"package/pip/event-listener/#components","title":"Components","text":"<p>Each event listener is described as an <code><eventlistener></code> element with a <code>name</code> attribute. As the <code>name</code> attribute has only be introduced with WSC 3.0, it is not yet mandatory to allow backwards compatibility. If <code>name</code> is not given, the system automatically sets the name based on the id of the event listener in the database.</p>"},{"location":"package/pip/event-listener/#eventclassname","title":"<code><eventclassname></code>","text":"<p>The event class name is the name of the class in which the event is fired.</p>"},{"location":"package/pip/event-listener/#eventname","title":"<code><eventname></code>","text":"<p>The event name is the name given when the event is fired to identify different events within the same class. You can either give a single event name or a comma-separated list of event names in which case the event listener listens to all of the listed events.</p> <p>Since the introduction of the new event system with version 5.5, the event name is optional and defaults to <code>:default</code>.</p>"},{"location":"package/pip/event-listener/#listenerclassname","title":"<code><listenerclassname></code>","text":"<p>The listener class name is the name of the class which is triggered if the relevant event is fired. The PHP class has to implement the <code>wcf\\system\\event\\listener\\IParameterizedEventListener</code> interface.</p> <p>Legacy event listeners are only required to implement the deprecated <code>wcf\\system\\event\\IEventListener</code> interface. When writing new code or update existing code, you should always implement the <code>wcf\\system\\event\\listener\\IParameterizedEventListener</code> interface!</p>"},{"location":"package/pip/event-listener/#inherit","title":"<code><inherit></code>","text":"<p>The inherit value can either be <code>0</code> (default value if the element is omitted) or <code>1</code> and determines if the event listener is also triggered for child classes of the given event class name. This is the case if <code>1</code> is used as the value.</p>"},{"location":"package/pip/event-listener/#environment","title":"<code><environment></code>","text":"<p>The value of the environment element must be one of <code>user</code>, <code>admin</code> or <code>all</code> and defaults to <code>user</code> if no value is given. The value determines if the event listener will be executed in the frontend (<code>user</code>), the backend (<code>admin</code>) or both (<code>all</code>).</p>"},{"location":"package/pip/event-listener/#nice","title":"<code><nice></code>","text":"<p>The nice value element can contain an integer value out of the interval <code>[-128,127]</code> with <code>0</code> being the default value if the element is omitted. The nice value determines the execution order of event listeners. Event listeners with smaller nice values are executed first. If the nice value of two event listeners is equal, they are sorted by the listener class name.</p> <p>If you pass a value out of the mentioned interval, the value will be adjusted to the closest value in the interval.</p>"},{"location":"package/pip/event-listener/#options","title":"<code><options></code>","text":"<p>The use of <code><options></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the event listener to be executed.</p>"},{"location":"package/pip/event-listener/#permissions","title":"<code><permissions></code>","text":"<p>The use of <code><permissions></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the event listener to be executed.</p>"},{"location":"package/pip/event-listener/#example","title":"Example","text":"eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/eventListener.xsd\">\n <import>\n <eventlistener name=\"inheritedAdminExample\">\n <eventclassname>wcf\\acp\\form\\UserAddForm</eventclassname>\n <eventname>assignVariables,readFormParameters,save,validate</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\InheritedAdminExampleListener</listenerclassname>\n <inherit>1</inherit>\n <environment>admin</environment>\n </eventlistener>\n\n <eventlistener name=\"nonInheritedUserExample\">\n <eventclassname>wcf\\form\\SettingsForm</eventclassname>\n <eventname>assignVariables</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\NonInheritedUserExampleListener</listenerclassname>\n </eventlistener>\n </import>\n\n <delete>\n <eventlistener name=\"oldEventListenerName\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/file-delete/","title":"File Delete Package Installation Plugin","text":"<p>Deletes files installed with the file package installation plugin.</p> <p>You cannot delete files provided by other packages.</p>"},{"location":"package/pip/file-delete/#components","title":"Components","text":"<p>Each item is described as a <code><file></code> element with an optional <code>application</code>, which behaves like it does for acp templates. The file path is relative to the installation of the app to which the file belongs.</p>"},{"location":"package/pip/file-delete/#example","title":"Example","text":"fileDelete.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/fileDelete.xsd\">\n <delete>\n <file>path/file.ext</file>\n <file application=\"app\">lib/data/foo/Fou.class.php</file>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/file/","title":"File Package Installation Plugin","text":"<p>Adds any type of files with the exception of templates.</p> <p>You cannot overwrite files provided by other packages.</p> <p>The <code>application</code> attribute behaves like it does for acp templates.</p>"},{"location":"package/pip/file/#archive","title":"Archive","text":"<p>The <code>acpTemplate</code> package installation plugins expects a <code>.tar</code> (recommended) or <code>.tar.gz</code> archive. The file path given in the <code>instruction</code> element as its value must be relative to the <code>package.xml</code> file.</p>"},{"location":"package/pip/file/#example-in-packagexml","title":"Example in <code>package.xml</code>","text":"<pre><code><instruction type=\"file\" />\n<!-- is the same as -->\n<instruction type=\"file\">files.tar</instruction>\n\n<!-- if an application \"com.woltlab.example\" is being installed, the following lines are equivalent -->\n<instruction type=\"file\" />\n<instruction type=\"file\" application=\"example\" />\n\n<!-- if the same application wants to install additional files, in WoltLab Suite Core's directory: -->\n<instruction type=\"file\" application=\"wcf\">files_wcf.tar</instruction>\n</code></pre>"},{"location":"package/pip/language/","title":"Language Package Installation Plugin","text":"<p>Registers new language items.</p>"},{"location":"package/pip/language/#components","title":"Components","text":"<p>The <code>languagecode</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The top level <code><language></code> node must contain a <code>languagecode</code> attribute.</p>"},{"location":"package/pip/language/#category","title":"<code><category></code>","text":"<p>Each category must contain a <code>name</code> attribute containing two or three components consisting of alphanumeric character only, separated by a single full stop (<code>.</code>, U+002E).</p>"},{"location":"package/pip/language/#item","title":"<code><item></code>","text":"<p>Each language item must contain a <code>name</code> attribute containing at least three components consisting of alphanumeric character only, separated by a single full stop (<code>.</code>, U+002E). The <code>name</code> of the parent <code><category></code> node followed by a full stop must be a prefix of the <code><item></code>\u2019s <code>name</code>.</p> <p>Wrap the text content inside a CDATA to avoid escaping of special characters.</p> <p>Do not use the <code>{lang}</code> tag inside a language item.</p> <p>The text content of the <code><item></code> node is the value of the language item. Language items that are not in the <code>wcf.global</code> category support template scripting.</p>"},{"location":"package/pip/language/#example","title":"Example","text":"<p>Prior to version 5.5, there was no support for deleting language items and the <code>category</code> elements had to be placed directly as children of the <code>language</code> element, see the migration guide to version 5.5.</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/language.xsd\" languagecode=\"en\">\n <import>\n <category name=\"wcf.example\">\n <item name=\"wcf.example.foo\"><![CDATA[<strong>Look!</strong>]]></item>\n </category>\n </import>\n <delete>\n <item name=\"wcf.example.obsolete\"/>\n </delete>\n</language>\n</code></pre>"},{"location":"package/pip/media-provider/","title":"Media Provider Package Installation Plugin","text":"<p>Media providers are responsible to detect and convert links to a 3rd party service inside messages.</p>"},{"location":"package/pip/media-provider/#components","title":"Components","text":"<p>Each item is described as a <code><provider></code> element with the mandatory attribute <code>name</code> that should equal the lower-cased provider name. If a provider provides multiple components that are (largely) unrelated to each other, it is recommended to use a dash to separate the name and the component, e. g. <code>youtube-playlist</code>.</p>"},{"location":"package/pip/media-provider/#title","title":"<code><title></code>","text":"<p>The title is displayed in the administration control panel and is only used there, the value is neither localizable nor is it ever exposed to regular users.</p>"},{"location":"package/pip/media-provider/#regex","title":"<code><regex></code>","text":"<p>The regular expression used to identify links to this provider, it must not contain anchors or delimiters. It is strongly recommended to capture the primary object id using the <code>(?P<ID>...)</code> group.</p>"},{"location":"package/pip/media-provider/#classname","title":"<code><className></code>","text":"<p><code><className></code> and <code><html></code> are mutually exclusive.</p> <p>PHP-Callback-Class that is invoked to process the matched link in case that additional logic must be applied that cannot be handled through a simple replacement as defined by the <code><html></code> element.</p> <p>The callback-class must implement the interface <code>\\wcf\\system\\bbcode\\media\\provider\\IBBCodeMediaProvider</code>.</p>"},{"location":"package/pip/media-provider/#html","title":"<code><html></code>","text":"<p><code><className></code> and <code><html></code> are mutually exclusive.</p> <p>Replacement HTML that gets populated using the captured matches in <code><regex></code>, variables are accessed as <code>{$VariableName}</code>. For example, the capture group <code>(?P<ID>...)</code> is accessed using <code>{$ID}</code>.</p>"},{"location":"package/pip/media-provider/#example","title":"Example","text":"mediaProvider.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/mediaProvider.xsd\">\n <import>\n <provider name=\"youtube\">\n <title>YouTube</title>\n <regex><![CDATA[https?://(?:.+?\\.)?youtu(?:\\.be/|be\\.com/(?:#/)?watch\\?(?:.*?&)?v=)(?P<ID>[a-zA-Z0-9_-]+)(?:(?:\\?|&)t=(?P<start>[0-9hms]+)$)?]]></regex>\n <!-- advanced PHP callback -->\n <className><![CDATA[wcf\\system\\bbcode\\media\\provider\\YouTubeBBCodeMediaProvider]]></className>\n </provider>\n\n <provider name=\"youtube-playlist\">\n <title>YouTube Playlist</title>\n <regex><![CDATA[https?://(?:.+?\\.)?youtu(?:\\.be/|be\\.com/)playlist\\?(?:.*?&)?list=(?P<ID>[a-zA-Z0-9_-]+)]]></regex>\n <!-- uses a simple HTML replacement -->\n <html><![CDATA[<div class=\"videoContainer\"><iframe src=\"https://www.youtube.com/embed/videoseries?list={$ID}\" allowfullscreen></iframe></div>]]></html>\n </provider>\n </import>\n\n <delete>\n <provider name=\"example\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/menu-item/","title":"Menu Item Package Installation Plugin","text":"<p>Adds menu items to existing menus.</p>"},{"location":"package/pip/menu-item/#components","title":"Components","text":"<p>Each item is described as an <code><item></code> element with the mandatory attribute <code>identifier</code> that should follow the naming pattern <code><packageIdentifier>.<PageName></code>, e.g. <code>com.woltlab.wcf.Dashboard</code>.</p>"},{"location":"package/pip/menu-item/#menu","title":"<code><menu></code>","text":"<p>The target menu that the item should be added to, requires the internal identifier set by creating a menu through the menu.xml.</p>"},{"location":"package/pip/menu-item/#title","title":"<code><title></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The title is displayed as the link title of the menu item and can be fully customized by the administrator, thus is immutable after deployment. Supports multiple <code><title></code> elements to provide localized values.</p>"},{"location":"package/pip/menu-item/#page","title":"<code><page></code>","text":"<p>The page that the link should point to, requires the internal identifier set by creating a page through the page.xml.</p>"},{"location":"package/pip/menu-item/#example","title":"Example","text":"menuItem.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/menuItem.xsd\">\n <import>\n <item identifier=\"com.woltlab.wcf.Dashboard\">\n <menu>com.woltlab.wcf.MainMenu</menu>\n <title language=\"de\">Dashboard</title>\n <title language=\"en\">Dashboard</title>\n <page>com.woltlab.wcf.Dashboard</page>\n </item>\n </import>\n\n <delete>\n <item identifier=\"com.woltlab.wcf.FooterLinks\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/menu/","title":"Menu Package Installation Plugin","text":"<p>Deploy and manage menus that can be placed anywhere on the site.</p>"},{"location":"package/pip/menu/#components","title":"Components","text":"<p>Each item is described as a <code><menu></code> element with the mandatory attribute <code>identifier</code> that should follow the naming pattern <code><packageIdentifier>.<MenuName></code>, e.g. <code>com.woltlab.wcf.MainMenu</code>.</p>"},{"location":"package/pip/menu/#title","title":"<code><title></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The internal name displayed in the admin panel only, can be fully customized by the administrator and is immutable. Only one value is accepted and will be picked based on the site's default language, but you can provide localized values by including multiple <code><title></code> elements.</p>"},{"location":"package/pip/menu/#box","title":"<code><box></code>","text":"<p>The following elements of the box PIP are supported, please refer to the documentation to learn more about them:</p> <ul> <li><code><position></code></li> <li><code><showHeader></code></li> <li><code><visibleEverywhere></code></li> <li><code><visibilityExceptions></code></li> <li><code>cssClassName</code></li> </ul>"},{"location":"package/pip/menu/#example","title":"Example","text":"menu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/menu.xsd\">\n <import>\n <menu identifier=\"com.woltlab.wcf.FooterLinks\">\n <title language=\"de\">Footer-Links</title>\n <title language=\"en\">Footer Links</title>\n\n <box>\n <position>footer</position>\n <cssClassName>boxMenuLinkGroup</cssClassName>\n <showHeader>0</showHeader>\n <visibleEverywhere>1</visibleEverywhere>\n </box>\n </menu>\n </import>\n\n <delete>\n <menu identifier=\"com.woltlab.wcf.FooterLinks\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/object-type-definition/","title":"Object Type Definition Package Installation Plugin","text":"<p>Registers an object type definition. An object type definition is a blueprint for a certain behaviour that is particularized by objectTypes. As an example: Tags can be attached to different types of content (such as forum posts or gallery images). The bulk of the work is implemented in a generalized fashion, with all the tags stored in a single database table. Certain things, such as permission checking, need to be particularized for the specific type of content, though. Thus tags (or rather \u201ctaggable content\u201d) are registered as an object type definition. Posts are then registered as an object type, implementing the \u201ctaggable content\u201d behaviour.</p> <p>Other types of object type definitions include attachments, likes, polls, subscriptions, or even the category system.</p>"},{"location":"package/pip/object-type-definition/#components","title":"Components","text":"<p>Each item is described as a <code><definition></code> element with the mandatory child <code><name></code> that should follow the naming pattern <code><packageIdentifier>.<definition></code>, e.g. <code>com.woltlab.wcf.example</code>.</p>"},{"location":"package/pip/object-type-definition/#interfacename","title":"<code><interfacename></code>","text":"<p>Optional</p> <p>The name of the PHP interface objectTypes have to implement.</p>"},{"location":"package/pip/object-type-definition/#example","title":"Example","text":"objectTypeDefinition.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/objectTypeDefinition.xsd\">\n <import>\n <definition>\n <name>com.woltlab.wcf.example</name>\n <interfacename>wcf\\system\\example\\IExampleObjectType</interfacename>\n </definition>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/object-type/","title":"Object Type Package Installation Plugin","text":"<p>Registers an object type. Read about object types in the objectTypeDefinition PIP.</p>"},{"location":"package/pip/object-type/#components","title":"Components","text":"<p>Each item is described as a <code><type></code> element with the mandatory child <code><name></code> that should follow the naming pattern <code><packageIdentifier>.<definition></code>, e.g. <code>com.woltlab.wcf.example</code>.</p>"},{"location":"package/pip/object-type/#definitionname","title":"<code><definitionname></code>","text":"<p>The <code><name></code> of the objectTypeDefinition.</p>"},{"location":"package/pip/object-type/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the object types's behaviour, the class has to implement the <code><interfacename></code> interface of the object type definition.</p>"},{"location":"package/pip/object-type/#_1","title":"<code><*></code>","text":"<p>Optional</p> <p>Additional fields may be defined for specific definitions of object types. Refer to the documentation of these for further explanation.</p>"},{"location":"package/pip/object-type/#example","title":"Example","text":"objectType.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/objectType.xsd\">\n <import>\n <type>\n <name>com.woltlab.wcf.example</name>\n <definitionname>com.woltlab.wcf.bulkProcessing.user.condition</definitionname>\n <classname>wcf\\system\\condition\\UserIntegerPropertyCondition</classname>\n <conditiongroup>contents</conditiongroup>\n <propertyname>example</propertyname>\n <minvalue>0</minvalue>\n </type>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/option/","title":"Option Package Installation Plugin","text":"<p>Registers new options. Options allow the administrator to configure the behaviour of installed packages. The specified values are exposed as PHP constants.</p>"},{"location":"package/pip/option/#category-components","title":"Category Components","text":"<p>Each category is described as an <code><category></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/option/#parent","title":"<code><parent></code>","text":"<p>Optional</p> <p>The category\u2019s parent category.</p>"},{"location":"package/pip/option/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this option within the parent category.</p>"},{"location":"package/pip/option/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the category to be shown to the administrator.</p>"},{"location":"package/pip/option/#option-components","title":"Option Components","text":"<p>Each option is described as an <code><option></code> element with the mandatory attribute <code>name</code>. The <code>name</code> is transformed into a PHP constant name by uppercasing it.</p>"},{"location":"package/pip/option/#categoryname","title":"<code><categoryname></code>","text":"<p>The option\u2019s category.</p>"},{"location":"package/pip/option/#optiontype","title":"<code><optiontype></code>","text":"<p>The type of input to be used for this option. Valid types are defined by the <code>wcf\\system\\option\\*OptionType</code> classes.</p>"},{"location":"package/pip/option/#defaultvalue","title":"<code><defaultvalue></code>","text":"<p>The value that is set after installation of a package. Valid values are defined by the <code>optiontype</code>.</p>"},{"location":"package/pip/option/#validationpattern","title":"<code><validationpattern></code>","text":"<p>Optional</p> <p>Defines a regular expression that is used to validate the value of a free form option (such as <code>text</code>).</p>"},{"location":"package/pip/option/#showorder_1","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this option within the category.</p>"},{"location":"package/pip/option/#selectoptions","title":"<code><selectoptions></code>","text":"<p>Optional</p> <p>Defined only for <code>select</code>, <code>multiSelect</code> and <code>radioButton</code> types.</p> <p>Specifies a newline-separated list of selectable values. Each line consists of an internal handle, followed by a colon (<code>:</code>, U+003A), followed by a language item. The language item is shown to the administrator, the internal handle is what is saved and exposed to the code.</p>"},{"location":"package/pip/option/#enableoptions","title":"<code><enableoptions></code>","text":"<p>Optional</p> <p>Defined only for <code>boolean</code>, <code>select</code> and <code>radioButton</code> types.</p> <p>Specifies a comma-separated list of options which should be visually enabled when this option is enabled. A leading exclamation mark (<code>!</code>, U+0021) will disable the specified option when this option is enabled. For <code>select</code> and <code>radioButton</code> types the list should be prefixed by the internal <code>selectoptions</code> handle followed by a colon (<code>:</code>, U+003A).</p> <p>This setting is a visual helper for the administrator only. It does not have an effect on the server side processing of the option.</p>"},{"location":"package/pip/option/#hidden","title":"<code><hidden></code>","text":"<p>Optional</p> <p>If <code>hidden</code> is set to <code>1</code> the option will not be shown to the administrator. It still can be modified programmatically.</p>"},{"location":"package/pip/option/#options_1","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the option to be shown to the administrator.</p>"},{"location":"package/pip/option/#supporti18n","title":"<code><supporti18n></code>","text":"<p>Optional</p> <p>Specifies whether this option supports localized input.</p>"},{"location":"package/pip/option/#requirei18n","title":"<code><requirei18n></code>","text":"<p>Optional</p> <p>Specifies whether this option requires localized input (i.e. the administrator must specify a value for every installed language).</p>"},{"location":"package/pip/option/#_1","title":"<code><*></code>","text":"<p>Optional</p> <p>Additional fields may be defined by specific types of options. Refer to the documentation of these for further explanation.</p>"},{"location":"package/pip/option/#language-items","title":"Language Items","text":"<p>All relevant language items have to be put into the <code>wcf.acp.option</code> language item category.</p>"},{"location":"package/pip/option/#categories","title":"Categories","text":"<p>If you install a category named <code>example.sub</code>, you have to provide the language item <code>wcf.acp.option.category.example.sub</code>, which is used when displaying the options. If you want to provide an optional description of the category, you have to provide the language item <code>wcf.acp.option.category.example.sub.description</code>. Descriptions are only relevant for categories whose parent has a parent itself, i.e. categories on the third level.</p>"},{"location":"package/pip/option/#options_2","title":"Options","text":"<p>If you install an option named <code>module_example</code>, you have to provide the language item <code>wcf.acp.option.module_example</code>, which is used as a label for setting the option value. If you want to provide an optional description of the option, you have to provide the language item <code>wcf.acp.option.module_example.description</code>.</p>"},{"location":"package/pip/option/#example","title":"Example","text":"option.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/option.xsd\">\n <import>\n <categories>\n <category name=\"example\" />\n <category name=\"example.sub\">\n <parent>example</parent>\n <options>module_example</options>\n </category>\n </categories>\n\n <options>\n <option name=\"module_example\">\n <categoryname>module.community</categoryname>\n <optiontype>boolean</optiontype>\n <defaultvalue>1</defaultvalue>\n </option>\n\n <option name=\"example_integer\">\n <categoryname>example.sub</categoryname>\n <optiontype>integer</optiontype>\n <defaultvalue>10</defaultvalue>\n <minvalue>5</minvalue>\n <maxvalue>40</maxvalue>\n </option>\n\n <option name=\"example_select\">\n <categoryname>example.sub</categoryname>\n <optiontype>select</optiontype>\n <defaultvalue>DESC</defaultvalue>\n <selectoptions>ASC:wcf.global.sortOrder.ascending\n DESC:wcf.global.sortOrder.descending</selectoptions>\n </option>\n </options>\n </import>\n\n <delete>\n <option name=\"outdated_example\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/page/","title":"Page Package Installation Plugin","text":"<p>Registers page controllers, making them available for selection and configuration, including but not limited to boxes and menus.</p>"},{"location":"package/pip/page/#components","title":"Components","text":"<p>Each item is described as a <code><page></code> element with the mandatory attribute <code>identifier</code> that should follow the naming pattern <code><packageIdentifier>.<PageName></code>, e.g. <code>com.woltlab.wcf.MembersList</code>.</p>"},{"location":"package/pip/page/#pagetype","title":"<code><pageType></code>","text":""},{"location":"package/pip/page/#system","title":"<code>system</code>","text":"<p>The special <code>system</code> type is reserved for pages that pull their properties and content from a registered PHP class. Requires the <code><controller></code> element.</p>"},{"location":"package/pip/page/#html-text-or-tpl","title":"<code>html</code>, <code>text</code> or <code>tpl</code>","text":"<p>Provide arbitrary content, requires the <code><content></code> element.</p>"},{"location":"package/pip/page/#controller","title":"<code><controller></code>","text":"<p>Fully qualified class name for the controller, must implement <code>wcf\\page\\IPage</code> or <code>wcf\\form\\IForm</code>.</p>"},{"location":"package/pip/page/#handler","title":"<code><handler></code>","text":"<p>Fully qualified class name that can be optionally set to provide additional methods, such as displaying a badge for unread content and verifying permissions per page object id.</p>"},{"location":"package/pip/page/#name","title":"<code><name></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The internal name displayed in the admin panel only, can be fully customized by the administrator and is immutable. Only one value is accepted and will be picked based on the site's default language, but you can provide localized values by including multiple <code><name></code> elements.</p>"},{"location":"package/pip/page/#parent","title":"<code><parent></code>","text":"<p>Sets the default parent page using its internal identifier, this setting controls the breadcrumbs and active menu item hierarchy.</p>"},{"location":"package/pip/page/#hasfixedparent","title":"<code><hasFixedParent></code>","text":"<p>Pages can be assigned any other page as parent page by default, set to <code>1</code> to make the parent setting immutable.</p>"},{"location":"package/pip/page/#permissions","title":"<code><permissions></code>","text":"<p>The comma represents a logical <code>or</code>, the check is successful if at least one permission is set.</p> <p>Comma separated list of permission names that will be checked one after another until at least one permission is set.</p>"},{"location":"package/pip/page/#options","title":"<code><options></code>","text":"<p>The comma represents a logical <code>or</code>, the check is successful if at least one option is enabled.</p> <p>Comma separated list of options that will be checked one after another until at least one option is set.</p>"},{"location":"package/pip/page/#excludefromlandingpage","title":"<code><excludeFromLandingPage></code>","text":"<p>Some pages should not be used as landing page, because they may not always be available and/or accessible to the user. For example, the account management page is available to logged-in users only and any guest attempting to visit that page would be presented with a permission denied message.</p> <p>Set this to <code>1</code> to prevent this page from becoming a landing page ever.</p>"},{"location":"package/pip/page/#requireobjectid","title":"<code><requireObjectID></code>","text":"<p>If the page requires an id of a specific object, like the user profile page requires the id of the user whose profile page is requested, <code><requireObjectID>1</requireObjectID></code> has to be added. If this item is not present, <code>requireObjectID</code> defaults to <code>0</code>.</p>"},{"location":"package/pip/page/#availableduringofflinemode","title":"<code><availableDuringOfflineMode></code>","text":"<p>During offline mode, most pages should generally not be available. Certain pages, however, might still have to be accessible due to, for example, legal reasons. To make a page available during offline mode, <code><availableDuringOfflineMode>1</availableDuringOfflineMode></code> has to be added. If this item is not present, <code>availableDuringOfflineMode</code> defaults to <code>0</code>.</p>"},{"location":"package/pip/page/#allowspiderstoindex","title":"<code><allowSpidersToIndex></code>","text":"<p>Administrators are able to set in the admin panel for each page, whether or not spiders are allowed to index it. The default value for this option can be set with the <code>allowSpidersToIndex</code> item whose value defaults to <code>0</code>.</p>"},{"location":"package/pip/page/#cssclassname","title":"<code><cssClassName></code>","text":"<p>To add custom CSS classes to a page\u2019s <code><body></code> HTML element, you can specify them via the <code>cssClassName</code> item.</p> <p>If you want to add multiple CSS classes, separate them with spaces!</p>"},{"location":"package/pip/page/#content","title":"<code><content></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p>"},{"location":"package/pip/page/#title","title":"<code><title></code>","text":"<p>The title element is required and controls the page title shown to the end users.</p>"},{"location":"package/pip/page/#content_1","title":"<code><content></code>","text":"<p>The content that should be used to populate the page, only used and required if the <code>pageType</code> equals <code>text</code>, <code>html</code> and <code>tpl</code>.</p>"},{"location":"package/pip/page/#example","title":"Example","text":"page.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/page.xsd\">\n <import>\n <page identifier=\"com.woltlab.wcf.MembersList\">\n <pageType>system</pageType>\n <controller>wcf\\page\\MembersListPage</controller>\n <name language=\"de\">Mitglieder</name>\n <name language=\"en\">Members</name>\n <options>module_members_list</options>\n <permissions>user.profile.canViewMembersList</permissions>\n <allowSpidersToIndex>1</allowSpidersToIndex>\n <content language=\"en\">\n <title>Members</title>\n </content>\n <content language=\"de\">\n <title>Mitglieder</title>\n </content>\n </page>\n </import>\n\n <delete>\n <page identifier=\"com.woltlab.wcf.MembersList\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/pip/","title":"Package Installation Plugin Package Installation Plugin","text":"<p>Registers new package installation plugins.</p>"},{"location":"package/pip/pip/#components","title":"Components","text":"<p>Each package installation plugin is described as an <code><pip></code> element with a <code>name</code> attribute and a PHP classname as the text content.</p> <p>The package installation plugin\u2019s class file must be installed into the <code>wcf</code> application and must not include classes outside the <code>\\wcf\\*</code> hierarchy to allow for proper uninstallation!</p>"},{"location":"package/pip/pip/#example","title":"Example","text":"packageInstallationPlugin.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/packageInstallationPlugin.xsd\">\n <import>\n <pip name=\"custom\">wcf\\system\\package\\plugin\\CustomPackageInstallationPlugin</pip>\n </import>\n <delete>\n <pip name=\"outdated\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/script/","title":"Script Package Installation Plugin","text":"<p>Execute arbitrary PHP code during installation, update and uninstallation of the package.</p> <p>You must install the PHP script through the file package installation plugin.</p> <p>The installation will attempt to delete the script after successful execution.</p>"},{"location":"package/pip/script/#attributes","title":"Attributes","text":""},{"location":"package/pip/script/#application","title":"<code>application</code>","text":"<p>The <code>application</code> attribute must have the same value as the <code>application</code> attribute of the <code>file</code> package installation plugin instruction so that the correct file in the intended application directory is executed. For further information about the <code>application</code> attribute, refer to its documentation on the acpTemplate package installation plugin page.</p>"},{"location":"package/pip/script/#expected-value","title":"Expected value","text":"<p>The <code>script</code>-PIP expects a relative path to a <code>.php</code> file.</p>"},{"location":"package/pip/script/#naming-convention","title":"Naming convention","text":"<p>The PHP script is deployed by using the file package installation plugin. To prevent it from colliding with other install script (remember: You cannot overwrite files created by another plugin), we highly recommend to make use of these naming conventions:</p> <ul> <li>Installation: <code>install_<package>.php</code> (example: <code>install_com.woltlab.wbb.php</code>)</li> <li>Update: <code>update_<package>_<targetVersion>.php</code> (example: <code>update_com.woltlab.wbb_5.0.0_pl_1.php</code>)</li> </ul> <p><code><targetVersion></code> equals the version number of the current package being installed. If you're updating from <code>1.0.0</code> to <code>1.0.1</code>, <code><targetVersion></code> should read <code>1.0.1</code>.</p>"},{"location":"package/pip/script/#execution-environment","title":"Execution environment","text":"<p>The script is included using <code>include()</code> within ScriptPackageInstallationPlugin::run(). This grants you access to the class members, including <code>$this->installation</code>.</p> <p>You can retrieve the package id of the current package through <code>$this->installation->getPackageID()</code>.</p>"},{"location":"package/pip/smiley/","title":"Smiley Package Installation Plugin","text":"<p>Installs new smileys.</p>"},{"location":"package/pip/smiley/#components","title":"Components","text":"<p>Each smiley is described as an <code><smiley></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/smiley/#title","title":"<code><title></code>","text":"<p>Short human readable description of the smiley.</p>"},{"location":"package/pip/smiley/#path2x","title":"<code><path(2x)?></code>","text":"<p>The files must be installed using the file PIP.</p> <p>File path relative to the root of WoltLab Suite Core. <code>path2x</code> is optional and being used for High-DPI screens.</p>"},{"location":"package/pip/smiley/#aliases","title":"<code><aliases></code>","text":"<p>Optional</p> <p>List of smiley aliases. Aliases must be separated by a line feed character (<code>\\n</code>, U+000A).</p>"},{"location":"package/pip/smiley/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the smiley list the smiley is shown.</p>"},{"location":"package/pip/smiley/#example","title":"Example","text":"smiley.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/smiley.xsd\">\n <import>\n <smiley name=\":example:\">\n <title>example</title>\n <path>images/smilies/example.png</path>\n <path2x>images/smilies/example@2x.png</path2x>\n <aliases><![CDATA[:alias:\n:more_aliases:]]></aliases>\n </smiley>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/sql/","title":"SQL Package Installation Plugin","text":"<p>Execute SQL instructions using a MySQL-flavored syntax.</p> <p>This file is parsed by WoltLab Suite Core to allow reverting of certain changes, but not every syntax MySQL supports is recognized by the parser. To avoid any troubles, you should always use statements relying on the SQL standard.</p>"},{"location":"package/pip/sql/#expected-value","title":"Expected Value","text":"<p>The <code>sql</code> package installation plugin expects a relative path to a <code>.sql</code> file.</p>"},{"location":"package/pip/sql/#features","title":"Features","text":""},{"location":"package/pip/sql/#logging","title":"Logging","text":"<p>WoltLab Suite Core uses a SQL parser to extract queries and log certain actions. This allows WoltLab Suite Core to revert some of the changes you apply upon package uninstallation.</p> <p>The logged changes are:</p> <ul> <li><code>CREATE TABLE</code></li> <li><code>ALTER TABLE \u2026 ADD COLUMN</code></li> <li><code>ALTER TABLE \u2026 ADD \u2026 KEY</code></li> </ul>"},{"location":"package/pip/sql/#instance-number","title":"Instance Number","text":"<p>It is possible to use different instance numbers, e.g. two separate WoltLab Suite Core installations within one database. WoltLab Suite Core requires you to always use <code>wcf1_<tableName></code> or <code><app>1_<tableName></code> (e.g. <code>blog1_blog</code> in WoltLab Suite Blog), the number (<code>1</code>) will be automatically replaced prior to execution. If you every use anything other but <code>1</code>, you will eventually break things, thus always use <code>1</code>!</p>"},{"location":"package/pip/sql/#table-type","title":"Table Type","text":"<p>WoltLab Suite Core will determine the type of database tables on its own: If the table contains a <code>FULLTEXT</code> index, it uses <code>MyISAM</code>, otherwise <code>InnoDB</code> is used.</p>"},{"location":"package/pip/sql/#limitations","title":"Limitations","text":""},{"location":"package/pip/sql/#logging_1","title":"Logging","text":"<p>WoltLab Suite Core cannot revert changes to the database structure which would cause to the data to be either changed or new data to be incompatible with the original format. Additionally, WoltLab Suite Core does not track regular SQL queries such as <code>DELETE</code> or <code>UPDATE</code>.</p>"},{"location":"package/pip/sql/#triggers","title":"Triggers","text":"<p>WoltLab Suite Core does not support trigger since MySQL does not support execution of triggers if the event was fired by a cascading foreign key action. If you really need triggers, you should consider adding them by custom SQL queries using a script.</p>"},{"location":"package/pip/sql/#example","title":"Example","text":"<p><code>package.xml</code>:</p> <pre><code><instruction type=\"sql\">install.sql</instruction>\n</code></pre> <p>Example content:</p> install.sql <pre><code>CREATE TABLE wcf1_foo_bar (\n fooID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n packageID INT(10) NOT NULL,\n bar VARCHAR(255) NOT NULL DEFAULT '',\n foobar VARCHAR(50) NOT NULL DEFAULT '',\n\n UNIQUE KEY baz (bar, foobar)\n);\n\nALTER TABLE wcf1_foo_bar ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;\n</code></pre>"},{"location":"package/pip/style/","title":"Style Package Installation Plugin","text":"<p>Install styles during package installation.</p> <p>The <code>style</code> package installation plugins expects a relative path to a <code>.tar</code> file, a<code>.tar.gz</code> file or a <code>.tgz</code> file. Please use the ACP's export mechanism to export styles.</p>"},{"location":"package/pip/style/#example-in-packagexml","title":"Example in <code>package.xml</code>","text":"<pre><code><instruction type=\"style\">style.tgz</instruction>\n</code></pre>"},{"location":"package/pip/template-delete/","title":"Template Delete Package Installation Plugin","text":"<p>Deletes frontend templates installed with the template package installation plugin.</p> <p>You cannot delete templates provided by other packages.</p>"},{"location":"package/pip/template-delete/#components","title":"Components","text":"<p>Each item is described as a <code><template></code> element with an optional <code>application</code>, which behaves like it does for acp templates. The templates are identified by their name like when adding template listeners, i.e. by the file name without the <code>.tpl</code> file extension.</p>"},{"location":"package/pip/template-delete/#example","title":"Example","text":"templateDelete.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/templateDelete.xsd\">\n <delete>\n <template>fouAdd</template>\n <template application=\"app\">__appAdd</template>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/template-listener/","title":"Template Listener Package Installation Plugin","text":"<p>Registers template listeners. Template listeners supplement event listeners, which modify server side behaviour, by adding additional template code to display additional elements. The added template code behaves as if it was part of the original template (i.e. it has access to all local variables).</p>"},{"location":"package/pip/template-listener/#components","title":"Components","text":"<p>Each event listener is described as an <code><templatelistener></code> element with a <code>name</code> attribute. As the <code>name</code> attribute has only be introduced with WSC 3.0, it is not yet mandatory to allow backwards compatibility. If <code>name</code> is not given, the system automatically sets the name based on the id of the event listener in the database.</p>"},{"location":"package/pip/template-listener/#templatename","title":"<code><templatename></code>","text":"<p>The template name is the name of the template in which the event is fired. It correspondes to the <code>eventclassname</code> field of event listeners.</p>"},{"location":"package/pip/template-listener/#eventname","title":"<code><eventname></code>","text":"<p>The event name is the name given when the event is fired to identify different events within the same template.</p>"},{"location":"package/pip/template-listener/#templatecode","title":"<code><templatecode></code>","text":"<p>The given template code is literally copied into the target template during compile time. The original template is not modified. If multiple template listeners listen to a single event their output is concatenated using the line feed character (<code>\\n</code>, U+000A) in the order defined by the <code>niceValue</code>.</p> <p>It is recommend that the only code is an <code>{include}</code> of a template to enable changes by the administrator. Names of templates included by a template listener start with two underscores by convention.</p>"},{"location":"package/pip/template-listener/#environment","title":"<code><environment></code>","text":"<p>The value of the environment element can either be <code>admin</code> or <code>user</code> and is <code>user</code> if no value is given. The value determines if the template listener will be executed in the frontend (<code>user</code>) or the backend (<code>admin</code>).</p>"},{"location":"package/pip/template-listener/#nice","title":"<code><nice></code>","text":"<p>Optional</p> <p>The nice value element can contain an integer value out of the interval <code>[-128,127]</code> with <code>0</code> being the default value if the element is omitted. The nice value determines the execution order of template listeners. Template listeners with smaller nice values are executed first. If the nice value of two template listeners is equal, the order is undefined.</p> <p>If you pass a value out of the mentioned interval, the value will be adjusted to the closest value in the interval.</p>"},{"location":"package/pip/template-listener/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The use of <code><options></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the template listener to be executed.</p>"},{"location":"package/pip/template-listener/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The use of <code><permissions></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the template listener to be executed.</p>"},{"location":"package/pip/template-listener/#example","title":"Example","text":"templateListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/templatelistener.xsd\">\n <import>\n <templatelistener name=\"example\">\n <environment>user</environment>\n <templatename>headIncludeJavaScript</templatename>\n <eventname>javascriptInclude</eventname>\n <templatecode><![CDATA[{include file='__myCustomJavaScript'}]]></templatecode>\n </templatelistener>\n </import>\n\n <delete>\n <templatelistener name=\"oldTemplateListenerName\">\n <environment>user</environment>\n <templatename>headIncludeJavaScript</templatename>\n <eventname>javascriptInclude</eventname>\n </templatelistener>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/template/","title":"Template Package Installation Plugin","text":"<p>Add templates for frontend pages and forms by providing an archive containing the template files.</p> <p>You cannot overwrite templates provided by other packages.</p> <p>This package installation plugin behaves exactly like the acpTemplate package installation plugin except for installing frontend templates instead of backend/acp templates.</p>"},{"location":"package/pip/user-group-option/","title":"User Group Option Package Installation Plugin","text":"<p>Registers new user group options (\u201cpermissions\u201d). The behaviour of this package installation plugin closely follows the option PIP.</p>"},{"location":"package/pip/user-group-option/#category-components","title":"Category Components","text":"<p>The category definition works exactly like the option PIP.</p>"},{"location":"package/pip/user-group-option/#option-components","title":"Option Components","text":"<p>The fields <code>hidden</code>, <code>supporti18n</code> and <code>requirei18n</code> do not apply. The following extra fields are defined:</p>"},{"location":"package/pip/user-group-option/#adminmoduserdefaultvalue","title":"<code><(admin|mod|user)defaultvalue></code>","text":"<p>Defines the <code>defaultvalue</code>s for subsets of the groups:</p> Type Description admin Groups where the <code>admin.user.accessibleGroups</code> user group option includes every group. mod Groups where the <code>mod.general.canUseModeration</code> is set to <code>true</code>. user Groups where the internal group type is neither <code>UserGroup::EVERYONE</code> nor <code>UserGroup::GUESTS</code>."},{"location":"package/pip/user-group-option/#usersonly","title":"<code><usersonly></code>","text":"<p>Makes the option unavailable for groups with the group type <code>UserGroup::GUESTS</code>.</p>"},{"location":"package/pip/user-group-option/#language-items","title":"Language Items","text":"<p>All relevant language items have to be put into the <code>wcf.acp.group</code> language item category.</p>"},{"location":"package/pip/user-group-option/#categories","title":"Categories","text":"<p>If you install a category named <code>user.foo</code>, you have to provide the language item <code>wcf.acp.group.option.category.user.foo</code>, which is used when displaying the options. If you want to provide an optional description of the category, you have to provide the language item <code>wcf.acp.group.option.category.user.foo.description</code>. Descriptions are only relevant for categories whose parent has a parent itself, i.e. categories on the third level.</p>"},{"location":"package/pip/user-group-option/#options","title":"Options","text":"<p>If you install an option named <code>user.foo.canBar</code>, you have to provide the language item <code>wcf.acp.group.option.user.foo.canBar</code>, which is used as a label for setting the option value. If you want to provide an optional description of the option, you have to provide the language item <code>wcf.acp.group.option.user.foo.canBar.description</code>.</p>"},{"location":"package/pip/user-menu/","title":"User Menu Package Installation Plugin","text":"<p>Registers new user menu items.</p>"},{"location":"package/pip/user-menu/#components","title":"Components","text":"<p>Each item is described as an <code><usermenuitem></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/user-menu/#parent","title":"<code><parent></code>","text":"<p>Optional</p> <p>The item\u2019s parent item.</p>"},{"location":"package/pip/user-menu/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this item within the parent item.</p>"},{"location":"package/pip/user-menu/#controller","title":"<code><controller></code>","text":"<p>The fully qualified class name of the target controller. If not specified this item serves as a category.</p>"},{"location":"package/pip/user-menu/#link","title":"<code><link></code>","text":"<p>Additional components if <code><controller></code> is set, the full external link otherwise.</p>"},{"location":"package/pip/user-menu/#iconclassname","title":"<code><iconclassname></code>","text":"<p>Use an icon only for top-level items.</p> <p>Specifiy the name of the Font Awesome icon. For regular icons, the solid variant can be requested with the attribute <code>solid=\"true\"</code>.</p> <p>Brand icons are supported using the separate attribute <code>type=\"brand\"</code>.</p>"},{"location":"package/pip/user-menu/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the menu item to be shown.</p>"},{"location":"package/pip/user-menu/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the menu item to be shown.</p>"},{"location":"package/pip/user-menu/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the user menu item\u2019s behaviour, the class has to implement the <code>wcf\\system\\menu\\user\\IUserMenuItemProvider</code> interface.</p>"},{"location":"package/pip/user-menu/#example","title":"Example","text":"userMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userMenu.xsd\">\n <import>\n <usermenuitem name=\"wcf.user.menu.foo\">\n <iconclassname>home</iconclassname>\n </usermenuitem>\n\n <usermenuitem name=\"wcf.user.menu.foo.bar\">\n <controller>wcf\\page\\FooBarListPage</controller>\n <parent>wcf.user.menu.foo</parent>\n <permissions>user.foo.canBar</permissions>\n <classname>wcf\\system\\menu\\user\\FooBarMenuItemProvider</classname>\n </usermenuitem>\n\n <usermenuitem name=\"wcf.user.menu.foo.baz\">\n <controller>wcf\\page\\FooBazListPage</controller>\n <parent>wcf.user.menu.foo</parent>\n <permissions>user.foo.canBaz</permissions>\n <options>module_foo_bar</options>\n </usermenuitem>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/user-notification-event/","title":"User Notification Event Package Installation Plugin","text":"<p>Registers new user notification events.</p>"},{"location":"package/pip/user-notification-event/#components","title":"Components","text":"<p>Each package installation plugin is described as an <code><event></code> element with the mandatory child <code><name></code>.</p>"},{"location":"package/pip/user-notification-event/#objecttype","title":"<code><objectType></code>","text":"<p>The <code>(name, objectType)</code> pair must be unique.</p> <p>The given object type must implement the <code>com.woltlab.wcf.notification.objectType</code> definition.</p>"},{"location":"package/pip/user-notification-event/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the event's behaviour, the class has to implement the <code>wcf\\system\\user\\notification\\event\\IUserNotificationEvent</code> interface.</p>"},{"location":"package/pip/user-notification-event/#preset","title":"<code><preset></code>","text":"<p>Defines whether this event is enabled by default.</p>"},{"location":"package/pip/user-notification-event/#presetmailnotificationtype","title":"<code><presetmailnotificationtype></code>","text":"<p>Avoid using this option, as sending unsolicited mail can be seen as spamming.</p> <p>One of <code>instant</code> or <code>daily</code>. Defines whether this type of email notifications is enabled by default.</p>"},{"location":"package/pip/user-notification-event/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the notification type to be available.</p>"},{"location":"package/pip/user-notification-event/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the notification type to be available.</p>"},{"location":"package/pip/user-notification-event/#example","title":"Example","text":"userNotificationEvent.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userNotificationEvent.xsd\">\n <import>\n <event>\n <name>like</name>\n <objecttype>com.woltlab.example.comment.like.notification</objecttype>\n <classname>wcf\\system\\user\\notification\\event\\ExampleCommentLikeUserNotificationEvent</classname>\n <preset>1</preset>\n <options>module_like</options>\n </event>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/user-option/","title":"User Option Package Installation Plugin","text":"<p>Registers new user options (profile fields / user settings). The behaviour of this package installation plugin closely follows the option PIP.</p>"},{"location":"package/pip/user-option/#category-components","title":"Category Components","text":"<p>The category definition works exactly like the option PIP.</p>"},{"location":"package/pip/user-option/#option-components","title":"Option Components","text":"<p>The fields <code>hidden</code>, <code>supporti18n</code> and <code>requirei18n</code> do not apply. The following extra fields are defined:</p>"},{"location":"package/pip/user-option/#required","title":"<code><required></code>","text":"<p>Requires that a value is provided.</p>"},{"location":"package/pip/user-option/#askduringregistration","title":"<code><askduringregistration></code>","text":"<p>If set to <code>1</code> the field is shown during user registration in the frontend.</p>"},{"location":"package/pip/user-option/#editable","title":"<code><editable></code>","text":"<p>Bitfield with the following options (constants in <code>wcf\\data\\user\\option\\UserOption</code>)</p> Name Value EDITABILITY_OWNER 1 EDITABILITY_ADMINISTRATOR 2 EDITABILITY_OWNER_DURING_REGISTRATION 4"},{"location":"package/pip/user-option/#visible","title":"<code><visible></code>","text":"<p>Bitfield with the following options (constants in <code>wcf\\data\\user\\option\\UserOption</code>)</p> Name Value VISIBILITY_OWNER 1 VISIBILITY_ADMINISTRATOR 2 VISIBILITY_REGISTERED 4 VISIBILITY_GUEST 8"},{"location":"package/pip/user-option/#searchable","title":"<code><searchable></code>","text":"<p>If set to <code>1</code> the field is searchable.</p>"},{"location":"package/pip/user-option/#outputclass","title":"<code><outputclass></code>","text":"<p>PHP class responsible for output formatting of this field. the class has to implement the <code>wcf\\system\\option\\user\\IUserOptionOutput</code> interface.</p>"},{"location":"package/pip/user-option/#language-items","title":"Language Items","text":"<p>All relevant language items have to be put into the <code>wcf.user.option</code> language item category.</p>"},{"location":"package/pip/user-option/#categories","title":"Categories","text":"<p>If you install a category named <code>example</code>, you have to provide the language item <code>wcf.user.option.category.example</code>, which is used when displaying the options. If you want to provide an optional description of the category, you have to provide the language item <code>wcf.user.option.category.example.description</code>. Descriptions are only relevant for categories whose parent has a parent itself, i.e. categories on the third level.</p>"},{"location":"package/pip/user-option/#options","title":"Options","text":"<p>If you install an option named <code>exampleOption</code>, you have to provide the language item <code>wcf.user.option.exampleOption</code>, which is used as a label for setting the option value. If you want to provide an optional description of the option, you have to provide the language item <code>wcf.user.option.exampleOption.description</code>.</p>"},{"location":"package/pip/user-profile-menu/","title":"User Profile Menu Package Installation Plugin","text":"<p>Registers new user profile tabs.</p>"},{"location":"package/pip/user-profile-menu/#components","title":"Components","text":"<p>Each tab is described as an <code><userprofilemenuitem></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/user-profile-menu/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the tab\u2019s behaviour, the class has to implement the <code>wcf\\system\\menu\\user\\profile\\content\\IUserProfileMenuContent</code> interface.</p>"},{"location":"package/pip/user-profile-menu/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the tab list the tab is shown.</p>"},{"location":"package/pip/user-profile-menu/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the tab to be shown.</p>"},{"location":"package/pip/user-profile-menu/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the tab to be shown.</p>"},{"location":"package/pip/user-profile-menu/#example","title":"Example","text":"userProfileMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"utf-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userProfileMenu.xsd\">\n <import>\n <userprofilemenuitem name=\"example\">\n <classname>wcf\\system\\menu\\user\\profile\\content\\ExampleProfileMenuContent</classname>\n <showorder>3</showorder>\n <options>module_example</options>\n </userprofilemenuitem>\n </import>\n</data>\n</code></pre>"},{"location":"php/apps/","title":"Apps for WoltLab Suite","text":""},{"location":"php/apps/#introduction","title":"Introduction","text":"<p>Apps are among the most powerful components in WoltLab Suite. Unlike plugins that extend an existing functionality and pages, apps have their own frontend with a dedicated namespace, database table prefixes and template locations.</p> <p>However, apps are meant to be a logical (and to some extent physical) separation from other parts of the framework, including other installed apps. They offer an additional layer of isolation and enable you to re-use class and template names that are already in use by the Core itself.</p> <p>If you've come here, thinking about the question if your next package should be an app instead of a regular plugin, the result is almost always: No.</p>"},{"location":"php/apps/#differences-to-plugins","title":"Differences to Plugins","text":"<p>Apps do offer a couple of unique features that are not available to plugins and there are valid reasons to use one instead of a plugin, but they also increase both the code and system complexity. There is a performance penalty for each installed app, regardless if it is actively used in a request or not, simplying being there forces the Core to include it in many places, for example, class resolution or even simple tasks such as constructing a link.</p>"},{"location":"php/apps/#unique-namespace","title":"Unique Namespace","text":"<p>Each app has its own unique namespace that is entirely separated from the Core and any other installed apps. The namespace is derived from the last part of the package identifier, for example, <code>com.example.foo</code> will yield the namespace <code>foo</code>.</p> <p>The namespace is always relative to the installation directory of the app, it doesn't matter if the app is installed on <code>example.com/foo/</code> or in <code>example.com/bar/</code>, the namespace will always resolve to the right directory.</p> <p>This app namespace is also used for ACP templates, frontend templates and files:</p> <pre><code><!-- somewhere in the package.xml -->\n<instructions type=\"file\" application=\"foo\" />\n</code></pre>"},{"location":"php/apps/#unique-database-table-prefix","title":"Unique Database Table Prefix","text":"<p>All database tables make use of a generic prefix that is derived from one of the installed apps, including <code>wcf</code> which resolves to the Core itself. Following the aforementioned example, the new prefix <code>fooN_</code> will be automatically registered and recognized in any generated statement.</p> <p>Any <code>DatabaseObject</code> that uses the app's namespace is automatically assumed to use the app's database prefix. For instance, <code>foo\\data\\bar\\Bar</code> is implicitly mapped to the database table <code>fooN_bar</code>.</p> <p>The app prefix is recognized in SQL-PIPs and statements that reference one of its database tables are automatically rewritten to use the Core's instance number.</p>"},{"location":"php/apps/#separate-domain-and-path-configuration","title":"Separate Domain and Path Configuration","text":"<p>Any controller that is provided by a plugin is served from the configured domain and path of the corresponding app, such as plugins for the Core are always served from the Core's directory. Apps are different and use their own domain and/or path to present their content, additionally, this allows the app to re-use a controller name that is already provided by the Core or any other app itself.</p>"},{"location":"php/apps/#creating-an-app","title":"Creating an App","text":"<p>This is a non-reversible operation! Once a package has been installed, its type cannot be changed without uninstalling and reinstalling the entire package, an app will always be an app and vice versa.</p>"},{"location":"php/apps/#packagexml","title":"<code>package.xml</code>","text":"<p>The <code>package.xml</code> supports two additional elements in the <code><packageinformation></code> block that are unique to applications.</p>"},{"location":"php/apps/#isapplication1isapplication","title":"<code><isapplication>1</isapplication></code>","text":"<p>This element is responsible to flag a package as an app.</p>"},{"location":"php/apps/#applicationdirectoryexampleapplicationdirectory","title":"<code><applicationdirectory>example</applicationdirectory></code>","text":"<p>Sets the suggested name of the application directory when installing it, the path result in <code><path-to-the-core>/example/</code>. If you leave this element out, the app identifier (<code>com.example.foo -> foo</code>) will be used instead.</p>"},{"location":"php/apps/#minimum-required-files","title":"Minimum Required Files","text":"<p>An example project with the source code can be found on GitHub, it includes everything that is required for a basic app.</p>"},{"location":"php/code-style-documentation/","title":"Documentation","text":"<p>The following documentation conventions are used by us for our own packages. While you do not have to follow every rule, you are encouraged to do so.</p>"},{"location":"php/code-style-documentation/#database-objects","title":"Database Objects","text":""},{"location":"php/code-style-documentation/#database-table-columns-as-properties","title":"Database Table Columns as Properties","text":"<p>As the database table columns are not explicit properties of the classes extending <code>wcf\\data\\DatabaseObject</code> but rather stored in <code>DatabaseObject::$data</code> and accessible via <code>DatabaseObject::__get($name)</code>, the IDE we use, PhpStorm, is neither able to autocomplete such property access nor to interfere the type of the property.</p> <p>To solve this problem, <code>@property-read</code> tags must be added to the class documentation which registers the database table columns as public read-only properties:</p> <pre><code> * @property-read propertyType $propertyName property description\n</code></pre> <p>The properties have to be in the same order as the order in the database table.</p> <p>The following table provides templates for common description texts so that similar database table columns have similar description texts.</p> property description template and example unique object id <code>unique id of the {object name}</code>example: <code>unique id of the acl option</code> id of the delivering package <code>id of the package which delivers the {object name}</code>example: <code>id of the package which delivers the acl option</code> show order for nested structure <code>position of the {object name} in relation to its siblings</code>example: <code>position of the ACP menu item in relation to its siblings</code> show order within different object <code>position of the {object name} in relation to the other {object name}s in the {parent object name}</code>example: <code>position of the label in relation to the other labels in the label group</code> required permissions <code>comma separated list of user group permissions of which the active user needs to have at least one to see (access, \u2026) the {object name}</code>example:<code>comma separated list of user group permissions of which the active user needs to have at least one to see the ACP menu item</code> required options <code>comma separated list of options of which at least one needs to be enabled for the {object name} to be shown (accessible, \u2026)</code>example:<code>comma separated list of options of which at least one needs to be enabled for the ACP menu item to be shown</code> id of the user who has created the object <code>id of the user who created (wrote, \u2026) the {object name} (or `null` if the user does not exist anymore (or if the {object name} has been created by a guest))</code>example:<code>id of the user who wrote the comment or `null` if the user does not exist anymore or if the comment has been written by a guest</code> name of the user who has created the object <code>name of the user (or guest) who created (wrote, \u2026) the {object name}</code>example:<code>name of the user or guest who wrote the comment</code> additional data <code>array with additional data of the {object name}</code>example:<code>array with additional data of the user activity event</code> time-related columns <code>timestamp at which the {object name} has been created (written, \u2026)</code>example:<code>timestamp at which the comment has been written</code> boolean options <code>is `1` (or `0`) if the {object name} \u2026 (and thus \u2026), otherwise `0` (or `1`)</code>example:<code>is `1` if the ad is disabled and thus not shown, otherwise `0`</code> <code>$cumulativeLikes</code> <code>cumulative result of likes (counting `+1`) and dislikes (counting `-1`) for the {object name}</code>example:<code>cumulative result of likes (counting `+1`) and dislikes (counting `-1`) for the article</code> <code>$comments</code> <code>number of comments on the {object name}</code>example:<code>number of comments on the article</code> <code>$views</code> <code>number of times the {object name} has been viewed</code>example:<code>number of times the article has been viewed</code> text field with potential language item name as value <code>{text type} of the {object name} or name of language item which contains the {text type}</code>example:<code>description of the cronjob or name of language item which contains the description</code> <code>$objectTypeID</code> <code>id of the `{object type definition name}` object type</code>example:<code>id of the `com.woltlab.wcf.modifiableContent` object type</code>"},{"location":"php/code-style-documentation/#database-object-editors","title":"Database Object Editors","text":""},{"location":"php/code-style-documentation/#class-tags","title":"Class Tags","text":"<p>Any database object editor class comment must have to following tags to properly support autocompletion by IDEs:</p> <pre><code>/**\n * \u2026\n * @method static {DBO class name} create(array $parameters = [])\n * @method {DBO class name} getDecoratedObject()\n * @mixin {DBO class name}\n */\n</code></pre> <p>The only exception to this rule is if the class overwrites the <code>create()</code> method which itself has to be properly documentation then.</p> <p>The first and second line makes sure that when calling the <code>create()</code> or <code>getDecoratedObject()</code> method, the return value is correctly recognized and not just a general <code>DatabaseObject</code> instance. The third line tells the IDE (if <code>@mixin</code> is supported) that the database object editor decorates the database object and therefore offers autocompletion for properties and methods from the database object class itself.</p>"},{"location":"php/code-style-documentation/#runtime-caches","title":"Runtime Caches","text":""},{"location":"php/code-style-documentation/#class-tags_1","title":"Class Tags","text":"<p>Any class implementing the IRuntimeCache interface must have the following class tags:</p> <pre><code>/**\n * \u2026\n * @method {DBO class name}[] getCachedObjects()\n * @method {DBO class name} getObject($objectID)\n * @method {DBO class name}[] getObjects(array $objectIDs)\n */\n</code></pre> <p>These tags ensure that when calling any of the mentioned methods, the return value refers to the concrete database object and not just generically to DatabaseObject.</p>"},{"location":"php/code-style/","title":"Code Style","text":"<p>The following code style conventions are used by us for our own packages. While you do not have to follow every rule, you are encouraged to do so.</p> <p>For information about how to document your code, please refer to the documentation page.</p>"},{"location":"php/code-style/#general-code-style","title":"General Code Style","text":""},{"location":"php/code-style/#naming-conventions","title":"Naming conventions","text":"<p>The relevant naming conventions are:</p> <ul> <li>Upper camel case: The first letters of all compound words are written in upper case.</li> <li>Lower camel case: The first letters of compound words are written in upper case, except for the first letter which is written in lower case.</li> <li>Screaming snake case: All letters are written in upper case and compound words are separated by underscores.</li> </ul> Type Convention Example Variable lower camel case <code>$variableName</code> Class upper camel case <code>class UserGroupEditor</code> Properties lower camel case <code>public $propertyName</code> Method lower camel case <code>public function getObjectByName()</code> Constant screaming snake case <code>MODULE_USER_THING</code>"},{"location":"php/code-style/#arrays","title":"Arrays","text":"<p>For arrays, use the short array syntax introduced with PHP 5.4. The following example illustrates the different cases that can occur when working with arrays and how to format them:</p> <pre><code><?php\n\n$empty = [];\n\n$oneElement = [1];\n$multipleElements = [1, 2, 3];\n\n$oneElementWithKey = ['firstElement' => 1];\n$multipleElementsWithKey = [\n 'firstElement' => 1,\n 'secondElement' => 2,\n 'thirdElement' => 3\n];\n</code></pre>"},{"location":"php/code-style/#ternary-operator","title":"Ternary Operator","text":"<p>The ternary operator can be used for short conditioned assignments:</p> <pre><code><?php\n\n$name = isset($tagArgs['name']) ? $tagArgs['name'] : 'default';\n</code></pre> <p>The condition and the values should be short so that the code does not result in a very long line which thus decreases the readability compared to an <code>if-else</code> statement.</p> <p>Parentheses may only be used around the condition and not around the whole statement:</p> <pre><code><?php\n\n// do not do it like this\n$name = (isset($tagArgs['name']) ? $tagArgs['name'] : 'default');\n</code></pre> <p>Parentheses around the conditions may not be used to wrap simple function calls:</p> <pre><code><?php\n\n// do not do it like this\n$name = (isset($tagArgs['name'])) ? $tagArgs['name'] : 'default';\n</code></pre> <p>but have to be used for comparisons or other binary operators:</p> <pre><code><?php\n\n$value = ($otherValue > $upperLimit) ? $additionalValue : $otherValue;\n</code></pre> <p>If you need to use more than one binary operator, use an <code>if-else</code> statement.</p> <p>The same rules apply to assigning array values:</p> <pre><code><?php\n\n$values = [\n 'first' => $firstValue,\n 'second' => $secondToggle ? $secondValueA : $secondValueB,\n 'third' => ($thirdToogle > 13) ? $thirdToogleA : $thirdToogleB\n];\n</code></pre> <p>or return values:</p> <pre><code><?php\n\nreturn isset($tagArgs['name']) ? $tagArgs['name'] : 'default';\n</code></pre>"},{"location":"php/code-style/#whitespaces","title":"Whitespaces","text":"<p>You have to put a whitespace in front of the following things:</p> <ul> <li>equal sign in assignments: <code>$x = 1;</code></li> <li>comparison operators: <code>$x == 1</code></li> <li>opening bracket of a block <code>public function test() {</code></li> </ul> <p>You have to put a whitespace behind the following things:</p> <ul> <li>equal sign in assignments: <code>$x = 1;</code></li> <li>comparison operators: <code>$x == 1</code></li> <li>comma in a function/method parameter list if the comma is not followed by a line break: <code>public function test($a, $b) {</code></li> <li><code>if</code>, <code>for</code>, <code>foreach</code>, <code>while</code>: <code>if ($x == 1)</code></li> </ul>"},{"location":"php/code-style/#classes","title":"Classes","text":""},{"location":"php/code-style/#referencing-class-names","title":"Referencing Class Names","text":"<p>If you have to reference a class name inside a php file, you have to use the <code>class</code> keyword.</p> <pre><code><?php\n\n// not like this\n$className = 'wcf\\data\\example\\Example';\n\n// like this\nuse wcf\\data\\example\\Example;\n$className = Example::class;\n</code></pre>"},{"location":"php/code-style/#static-getters-of-databaseobject-classes","title":"Static Getters (of <code>DatabaseObject</code> Classes)","text":"<p>Some database objects provide static getters, either if they are decorators or for a unique combination of database table columns, like <code>wcf\\data\\box\\Box::getBoxByIdentifier()</code>:</p> files/lib/data/box/Box.class.php <pre><code><?php\nnamespace wcf\\data\\box;\nuse wcf\\data\\DatabaseObject;\nuse wcf\\system\\WCF;\n\nclass Box extends DatabaseObject {\n /**\n * Returns the box with the given identifier.\n *\n * @param string $identifier\n * @return Box|null\n */\n public static function getBoxByIdentifier($identifier) {\n $sql = \"SELECT *\n FROM wcf1_box\n WHERE identifier = ?\";\n $statement = WCF::getDB()->prepare($sql);\n $statement->execute([$identifier]);\n\n return $statement->fetchObject(self::class);\n }\n}\n</code></pre> <p>Such methods should always either return the desired object or <code>null</code> if the object does not exist. <code>wcf\\system\\database\\statement\\PreparedStatement::fetchObject()</code> already takes care of this distinction so that its return value can simply be returned by such methods.</p> <p>The name of such getters should generally follow the convention <code>get{object type}By{column or other description}</code>.</p>"},{"location":"php/code-style/#long-method-calls","title":"Long method calls","text":"<p>In some instances, methods with many argument have to be called which can result in lines of code like this one:</p> <pre><code><?php\n\n\\wcf\\system\\search\\SearchIndexManager::getInstance()->set('com.woltlab.wcf.article', $articleContent->articleContentID, $articleContent->content, $articleContent->title, $articles[$articleContent->articleID]->time, $articles[$articleContent->articleID]->userID, $articles[$articleContent->articleID]->username, $articleContent->languageID, $articleContent->teaser);\n</code></pre> <p>which is hardly readable. Therefore, the line must be split into multiple lines with each argument in a separate line:</p> <pre><code><?php\n\n\\wcf\\system\\search\\SearchIndexManager::getInstance()->set(\n 'com.woltlab.wcf.article',\n $articleContent->articleContentID,\n $articleContent->content,\n $articleContent->title,\n $articles[$articleContent->articleID]->time,\n $articles[$articleContent->articleID]->userID,\n $articles[$articleContent->articleID]->username,\n $articleContent->languageID,\n $articleContent->teaser\n);\n</code></pre> <p>In general, this rule applies to the following methods:</p> <ul> <li><code>wcf\\system\\edit\\EditHistoryManager::add()</code></li> <li><code>wcf\\system\\message\\quote\\MessageQuoteManager::addQuote()</code></li> <li><code>wcf\\system\\message\\quote\\MessageQuoteManager::getQuoteID()</code></li> <li><code>wcf\\system\\search\\SearchIndexManager::set()</code></li> <li><code>wcf\\system\\user\\object\\watch\\UserObjectWatchHandler::updateObject()</code></li> <li><code>wcf\\system\\user\\notification\\UserNotificationHandler::fireEvent()</code></li> </ul>"},{"location":"php/database-access/","title":"Database Access","text":"<p>Database Objects provide a convenient and object-oriented approach to work with the database, but there can be use-cases that require raw access including writing methods for model classes. This section assumes that you have either used prepared statements before or at least understand how it works.</p>"},{"location":"php/database-access/#the-preparedstatement-object","title":"The PreparedStatement Object","text":"<p>The database access is designed around PreparedStatement, built on top of PHP's <code>PDOStatement</code> so that you call all of <code>PDOStatement</code>'s methods, and each query requires you to obtain a statement object.</p> <pre><code><?php\n$statement = \\wcf\\system\\WCF::getDB()->prepare(\"SELECT * FROM wcf1_example\");\n$statement->execute();\nwhile ($row = $statement->fetchArray()) {\n // handle result\n}\n</code></pre>"},{"location":"php/database-access/#query-parameters","title":"Query Parameters","text":"<p>The example below illustrates the usage of parameters where each value is replaced with the generic <code>?</code>-placeholder. Values are provided by calling <code>$statement->execute()</code> with a continuous, one-dimensional array that exactly match the number of question marks.</p> <pre><code><?php\n$sql = \"SELECT *\n FROM wcf1_example\n WHERE exampleID = ?\n OR bar IN (?, ?, ?, ?, ?)\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute([\n $exampleID,\n $list, $of, $values, $for, $bar\n]);\nwhile ($row = $statement->fetchArray()) {\n // handle result\n}\n</code></pre>"},{"location":"php/database-access/#fetching-a-single-result","title":"Fetching a Single Result","text":"<p>Do not attempt to use <code>fetchSingleRow()</code> or <code>fetchSingleColumn()</code> if the result contains more than one row.</p> <p>You can opt-in to retrieve only a single row from database and make use of shortcut methods to reduce the code that you have to write.</p> <pre><code><?php\n$sql = \"SELECT *\n FROM wcf1_example\n WHERE exampleID = ?\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql, 1);\n$statement->execute([$exampleID]);\n$row = $statement->fetchSingleRow();\n</code></pre> <p>There are two distinct differences when comparing with the example on query parameters above:</p> <ol> <li>The method <code>prepare()</code> receives a secondary parameter that will be appended to the query as <code>LIMIT 1</code>.</li> <li>Data is read using <code>fetchSingleRow()</code> instead of <code>fetchArray()</code> or similar methods, that will read one result and close the cursor.</li> </ol>"},{"location":"php/database-access/#fetch-by-column","title":"Fetch by Column","text":"<p>There is no way to return another column from the same row if you use <code>fetchColumn()</code> to retrieve data.</p> <p>Fetching an array is only useful if there is going to be more than one column per result row, otherwise accessing the column directly is much more convenient and increases the code readability.</p> <pre><code><?php\n$sql = \"SELECT bar\n FROM wcf1_example\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\nwhile ($bar = $statement->fetchColumn()) {\n // handle result\n}\n$bar = $statement->fetchSingleColumn();\n</code></pre> <p>Similar to fetching a single row, you can also issue a query that will select a single row, but reads only one column from the result row.</p> <pre><code><?php\n$sql = \"SELECT bar\n FROM wcf1_example\n WHERE exampleID = ?\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql, 1);\n$statement->execute([$exampleID]);\n$bar = $statement->fetchSingleColumn();\n</code></pre>"},{"location":"php/database-access/#fetching-all-results","title":"Fetching All Results","text":"<p>If you want to fetch all results of a query but only store them in an array without directly processing them, in most cases, you can rely on built-in methods.</p> <p>To fetch all rows of query, you can use <code>PDOStatement::fetchAll()</code> with <code>\\PDO::FETCH_ASSOC</code> as the first parameter:</p> <pre><code><?php\n$sql = \"SELECT *\n FROM wcf1_example\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$rows = $statement->fetchAll(\\PDO::FETCH_ASSOC);\n</code></pre> <p>As a result, you get an array containing associative arrays with the rows of the <code>wcf{WCF_N}_example</code> database table as content.</p> <p>If you only want to fetch a list of the values of a certain column, you can use <code>\\PDO::FETCH_COLUMN</code> as the first parameter:</p> <pre><code><?php\n$sql = \"SELECT exampleID\n FROM wcf1_example\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$exampleIDs = $statement->fetchAll(\\PDO::FETCH_COLUMN);\n</code></pre> <p>As a result, you get an array with all <code>exampleID</code> values.</p> <p>The <code>PreparedStatement</code> class adds an additional methods that covers another common use case in our code: Fetching two columns and using the first column's value as the array key and the second column's value as the array value. This case is covered by <code>PreparedStatement::fetchMap()</code>:</p> <pre><code><?php\n$sql = \"SELECT exampleID, userID\n FROM wcf1_example_mapping\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$map = $statement->fetchMap('exampleID', 'userID');\n</code></pre> <p><code>$map</code> is a one-dimensional array where each <code>exampleID</code> value maps to the corresponding <code>userID</code> value.</p> <p>If there are multiple entries for a certain <code>exampleID</code> value with different <code>userID</code> values, the existing entry in the array will be overwritten and contain the last read value from the database table. Therefore, this method should generally only be used for unique combinations.</p> <p>If you do not have a combination of columns with unique pairs of values, but you want to get a list of <code>userID</code> values with the same <code>exampleID</code>, you can set the third parameter of <code>fetchMap()</code> to <code>false</code> and get a list:</p> <pre><code><?php\n$sql = \"SELECT exampleID, userID\n FROM wcf1_example_mapping\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$map = $statement->fetchMap('exampleID', 'userID', false);\n</code></pre> <p>Now, as a result, you get a two-dimensional array with the array keys being the <code>exampleID</code> values and the array values being arrays with all <code>userID</code> values from rows with the respective <code>exampleID</code> value.</p>"},{"location":"php/database-access/#building-complex-conditions","title":"Building Complex Conditions","text":"<p>Building conditional conditions can turn out to be a real mess and it gets even worse with SQL's <code>IN (\u2026)</code> which requires as many placeholders as there will be values. The solutions is <code>PreparedStatementConditionBuilder</code>, a simple but useful helper class with a bulky name, it is also the class used when accessing <code>DatabaseObjecList::getConditionBuilder()</code>.</p> <pre><code><?php\n$conditions = new \\wcf\\system\\database\\util\\PreparedStatementConditionBuilder();\n$conditions->add(\"exampleID = ?\", [$exampleID]);\nif (!empty($valuesForBar)) {\n $conditions->add(\"(bar IN (?) OR baz = ?)\", [$valuesForBar, $baz]);\n}\n</code></pre> <p>The <code>IN (?)</code> in the example above is automatically expanded to match the number of items contained in <code>$valuesForBar</code>. Be aware that the method will generate an invalid query if <code>$valuesForBar</code> is empty!</p>"},{"location":"php/database-access/#insert-or-update-in-bulk","title":"INSERT or UPDATE in Bulk","text":"<p>Prepared statements not only protect against SQL injection by separating the logical query and the actual data, but also provides the ability to reuse the same query with different values. This leads to a performance improvement as the code does not have to transmit the query with for every data set and only has to parse and analyze the query once.</p> <pre><code><?php\n$data = ['abc', 'def', 'ghi'];\n\n$sql = \"INSERT INTO wcf1_example\n (bar)\n VALUES (?)\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n\n\\wcf\\system\\WCF::getDB()->beginTransaction();\nforeach ($data as $bar) {\n $statement->execute([$bar]);\n}\n\\wcf\\system\\WCF::getDB()->commitTransaction();\n</code></pre> <p>It is generally advised to wrap bulk operations in a transaction as it allows the database to optimize the process, including fewer I/O operations.</p> <pre><code><?php\n$data = [\n 1 => 'abc',\n 3 => 'def',\n 4 => 'ghi'\n];\n\n$sql = \"UPDATE wcf1_example\n SET bar = ?\n WHERE exampleID = ?\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n\n\\wcf\\system\\WCF::getDB()->beginTransaction();\nforeach ($data as $exampleID => $bar) {\n $statement->execute([\n $bar,\n $exampleID\n ]);\n}\n\\wcf\\system\\WCF::getDB()->commitTransaction();\n</code></pre>"},{"location":"php/database-objects/","title":"Database Objects","text":"<p>WoltLab Suite uses a unified interface to work with database rows using an object based approach instead of using native arrays holding arbitrary data. Each database table is mapped to a model class that is designed to hold a single record from that table and expose methods to work with the stored data, for example providing assistance when working with normalized datasets.</p> <p>Developers are required to provide the proper DatabaseObject implementations themselves, they're not automatically generated, all though the actual code that needs to be written is rather small. The following examples assume the fictional database table <code>wcf1_example</code>, <code>exampleID</code> as the auto-incrementing primary key and the column <code>bar</code> to store some text.</p>"},{"location":"php/database-objects/#databaseobject","title":"DatabaseObject","text":"<p>The basic model derives from <code>wcf\\data\\DatabaseObject</code> and provides a convenient constructor to fetch a single row or construct an instance using pre-loaded rows.</p> files/lib/data/example/Example.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObject;\n\nclass Example extends DatabaseObject {}\n</code></pre> <p>The class is intended to be empty by default and there only needs to be code if you want to add additional logic to your model. Both the class name and primary key are determined by <code>DatabaseObject</code> using the namespace and class name of the derived class. The example above uses the namespace <code>wcf\\\u2026</code> which is used as table prefix and the class name <code>Example</code> is converted into <code>exampleID</code>, resulting in the database table name <code>wcfN_example</code> with the primary key <code>exampleID</code>.</p> <p>You can prevent this automatic guessing by setting the class properties <code>$databaseTableName</code> and <code>$databaseTableIndexName</code> manually.</p>"},{"location":"php/database-objects/#databaseobjectdecorator","title":"DatabaseObjectDecorator","text":"<p>If you already have a <code>DatabaseObject</code> class and would like to extend it with additional data or methods, for example by providing a class <code>ViewableExample</code> which features view-related changes without polluting the original object, you can use <code>DatabaseObjectDecorator</code> which a default implementation of a decorator for database objects.</p> files/lib/data/example/ViewableExample.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObjectDecorator;\n\nclass ViewableExample extends DatabaseObjectDecorator {\n protected static $baseClass = Example::class;\n\n public function getOutput() {\n $output = '';\n\n // [determine output]\n\n return $output;\n }\n}\n</code></pre> <p>It is mandatory to set the static <code>$baseClass</code> property to the name of the decorated class.</p> <p>Like for any decorator, you can directly access the decorated object's properties and methods for a decorated object by accessing the property or calling the method on the decorated object. You can access the decorated objects directly via <code>DatabaseObjectDecorator::getDecoratedObject()</code>.</p>"},{"location":"php/database-objects/#databaseobjecteditor","title":"DatabaseObjectEditor","text":"<p>This is the low-level interface to manipulate data rows, it is recommended to use <code>AbstractDatabaseObjectAction</code>.</p> <p>Adding, editing and deleting models is done using the <code>DatabaseObjectEditor</code> class that decorates a <code>DatabaseObject</code> and uses its data to perform the actions.</p> files/lib/data/example/ExampleEditor.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObjectEditor;\n\nclass ExampleEditor extends DatabaseObjectEditor {\n protected static $baseClass = Example::class;\n}\n</code></pre> <p>The editor class requires you to provide the fully qualified name of the model, that is the class name including the complete namespace. Database table name and index key will be pulled directly from the model.</p>"},{"location":"php/database-objects/#create-a-new-row","title":"Create a new row","text":"<p>Inserting a new row into the database table is provided through <code>DatabaseObjectEditor::create()</code> which yields a <code>DatabaseObject</code> instance after creation.</p> <pre><code><?php\n$example = \\wcf\\data\\example\\ExampleEditor::create([\n 'bar' => 'Hello World!'\n]);\n\n// output: Hello World!\necho $example->bar;\n</code></pre>"},{"location":"php/database-objects/#updating-an-existing-row","title":"Updating an existing row","text":"<p>The internal state of the decorated <code>DatabaseObject</code> is not altered at any point, the values will still be the same after editing or deleting the represented row. If you need an object with the latest data, you'll have to discard the current object and refetch the data from database.</p> <pre><code><?php\n$example = new \\wcf\\data\\example\\Example($id);\n$exampleEditor = new \\wcf\\data\\example\\ExampleEditor($example);\n$exampleEditor->update([\n 'bar' => 'baz'\n]);\n\n// output: Hello World!\necho $example->bar;\n\n// re-creating the object will query the database again and retrieve the updated value\n$example = new \\wcf\\data\\example\\Example($example->id);\n\n// output: baz\necho $example->bar;\n</code></pre>"},{"location":"php/database-objects/#deleting-a-row","title":"Deleting a row","text":"<p>Similar to the update process, the decorated <code>DatabaseObject</code> is not altered and will then point to an inexistent row.</p> <pre><code><?php\n$example = new \\wcf\\data\\example\\Example($id);\n$exampleEditor = new \\wcf\\data\\example\\ExampleEditor($example);\n$exampleEditor->delete();\n</code></pre>"},{"location":"php/database-objects/#databaseobjectlist","title":"DatabaseObjectList","text":"<p>Every row is represented as a single instance of the model, but the instance creation deals with single rows only. Retrieving larger sets of rows would be quite inefficient due to the large amount of queries that will be dispatched. This is solved with the <code>DatabaseObjectList</code> object that exposes an interface to query the database table using arbitrary conditions for data selection. All rows will be fetched using a single query and the resulting rows are automatically loaded into separate models.</p> files/lib/data/example/ExampleList.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObjectList;\n\nclass ExampleList extends DatabaseObjectList {\n public $className = Example::class;\n}\n</code></pre> <p>The following code listing illustrates loading a large set of examples and iterating over the list to retrieve the objects.</p> <pre><code><?php\n$exampleList = new \\wcf\\data\\example\\ExampleList();\n// add constraints using the condition builder\n$exampleList->getConditionBuilder()->add('bar IN (?)', [['Hello World!', 'bar', 'baz']]);\n// actually read the rows\n$exampleList->readObjects();\nforeach ($exampleList as $example) {\n echo $example->bar;\n}\n\n// retrieve the models directly instead of iterating over them\n$examples = $exampleList->getObjects();\n\n// just retrieve the number of rows\n$exampleCount = $exampleList->countObjects();\n</code></pre> <p><code>DatabaseObjectList</code> implements both SeekableIterator and Countable.</p> <p>Additionally, <code>DatabaseObjectList</code> objects has the following three public properties that are useful when fetching data with lists:</p> <ul> <li><code>$sqlLimit</code> determines how many rows are fetched. If its value is <code>0</code> (which is the default value), all results are fetched. So be careful when dealing with large tables and you only want a limited number of rows: Set <code>$sqlLimit</code> to a value larger than zero!</li> <li><code>$sqlOffset</code>: Paginated pages like a thread list use this feature a lot, it allows you to skip a given number of results. Imagine you want to display 20 threads per page but there are a total of 60 threads available. In this case you would specify <code>$sqlLimit = 20</code> and <code>$sqlOffset = 20</code> which will skip the first 20 threads, effectively displaying thread 21 to 40.</li> <li><code>$sqlOrderBy</code> determines by which column(s) the rows are sorted in which order. Using our example in <code>$sqlOffset</code> you might want to display the 20 most recent threads on page 1, thus you should specify the order field and its direction, e.g. <code>$sqlOrderBy = 'thread.lastPostTime DESC'</code> which returns the most recent thread first.</li> </ul> <p>For more advanced usage, there two additional fields that deal with the type of objects returned. First, let's go into a bit more detail what setting the <code>$className</code> property actually does:</p> <ol> <li>It is the type of database object in which the rows are wrapped.</li> <li>It determines which database table is actually queried and which index is used (see the <code>$databaseTableName</code> and <code>$databaseTableIndexName</code> properties of <code>DatabaseObject</code>).</li> </ol> <p>Sometimes you might use the database table of some database object but wrap the rows in another database object. This can be achieved by setting the <code>$objectClassName</code> property to the desired class name.</p> <p>In other cases, you might want to wrap the created objects in a database object decorator which can be done by setting the <code>$decoratorClassName</code> property to the desired class name:</p> <pre><code><?php\n$exampleList = new \\wcf\\data\\example\\ExampleList();\n$exampleList->decoratorClassName = \\wcf\\data\\example\\ViewableExample::class;\n</code></pre> <p>Of course, you do not have to set the property after creating the list object, you can also set it by creating a dedicated class:</p> files/lib/data/example/ViewableExampleList.class.php <pre><code><?php\nnamespace wcf\\data\\example;\n\nclass ViewableExampleList extends ExampleList {\n public $decoratorClassName = ViewableExample::class;\n}\n</code></pre>"},{"location":"php/database-objects/#abstractdatabaseobjectaction","title":"AbstractDatabaseObjectAction","text":"<p>Row creation and manipulation can be performed using the aforementioned <code>DatabaseObjectEditor</code> class, but this approach has two major issues:</p> <ol> <li>Row creation, update and deletion takes place silently without notifying any other components.</li> <li>Data is passed to the database adapter without any further processing.</li> </ol> <p>The <code>AbstractDatabaseObjectAction</code> solves both problems by wrapping around the editor class and thus provide an additional layer between the action that should be taken and the actual process. The first problem is solved by a fixed set of events being fired, the second issue is addressed by having a single entry point for all data editing.</p> files/lib/data/example/ExampleAction.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\AbstractDatabaseObjectAction;\n\nclass ExampleAction extends AbstractDatabaseObjectAction {\n public $className = ExampleEditor::class;\n}\n</code></pre>"},{"location":"php/database-objects/#executing-an-action","title":"Executing an Action","text":"<p>The method <code>AbstractDatabaseObjectAction::validateAction()</code> is internally used for AJAX method invocation and must not be called programmatically.</p> <p>The next example represents the same functionality as seen for <code>DatabaseObjectEditor</code>:</p> <pre><code><?php\nuse wcf\\data\\example\\ExampleAction;\n\n// create a row\n$exampleAction = new ExampleAction([], 'create', [\n 'data' => ['bar' => 'Hello World']\n]);\n$example = $exampleAction->executeAction()['returnValues'];\n\n// update a row using the id\n$exampleAction = new ExampleAction([1], 'update', [\n 'data' => ['bar' => 'baz']\n]);\n$exampleAction->executeAction();\n\n// delete a row using a model\n$exampleAction = new ExampleAction([$example], 'delete');\n$exampleAction->executeAction();\n</code></pre> <p>You can access the return values both by storing the return value of <code>executeAction()</code> or by retrieving it via <code>getReturnValues()</code>.</p> <p>Events <code>initializeAction</code>, <code>validateAction</code> and <code>finalizeAction</code></p>"},{"location":"php/database-objects/#custom-method-with-ajax-support","title":"Custom Method with AJAX Support","text":"<p>The AJAX interface of database object actions is considered soft-deprecated in WoltLab Suite 6.0. Instead a dedicated PSR-15 controller should be used. Please refer to the migration guide.</p> <p>This section is about adding the method <code>baz()</code> to <code>ExampleAction</code> and calling it via AJAX.</p>"},{"location":"php/database-objects/#ajax-validation","title":"AJAX Validation","text":"<p>Methods of an action cannot be called via AJAX, unless they have a validation method. This means that <code>ExampleAction</code> must define both a <code>public function baz()</code> and <code>public function validateBaz()</code>, the name for the validation method is constructed by upper-casing the first character of the method name and prepending <code>validate</code>.</p> <p>The lack of the companion <code>validate*</code> method will cause the AJAX proxy to deny the request instantaneously. Do not add a validation method if you don't want it to be callable via AJAX ever!</p>"},{"location":"php/database-objects/#create-update-and-delete","title":"create, update and delete","text":"<p>The methods <code>create</code>, <code>update</code> and <code>delete</code> are available for all classes deriving from <code>AbstractDatabaseObjectAction</code> and directly pass the input data to the <code>DatabaseObjectEditor</code>. These methods deny access to them via AJAX by default, unless you explicitly enable access. Depending on your case, there are two different strategies to enable AJAX access to them.</p> <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\AbstractDatabaseObjectAction;\n\nclass ExampleAction extends AbstractDatabaseObjectAction {\n // `create()` can now be called via AJAX if the requesting user posses the listed permissions\n protected $permissionsCreate = ['admin.example.canManageExample'];\n\n public function validateUpdate() {\n // your very own validation logic that does not make use of the\n // built-in `$permissionsUpdate` property\n\n // you can still invoke the built-in permissions check if you like to\n parent::validateUpdate();\n }\n}\n</code></pre>"},{"location":"php/database-objects/#allow-invokation-by-guests","title":"Allow Invokation by Guests","text":"<p>Invoking methods is restricted to logged-in users by default and the only way to override this behavior is to alter the property <code>$allowGuestAccess</code>. It is a simple string array that is expected to hold all methods that should be accessible by users, excluding their companion validation methods.</p>"},{"location":"php/database-objects/#acp-access-only","title":"ACP Access Only","text":"<p>Method access is usually limited by permissions, but sometimes there might be the need for some added security to avoid mistakes. The <code>$requireACP</code> property works similar to <code>$allowGuestAccess</code>, but enforces the request to originate from the ACP together with a valid ACP session, ensuring that only users able to access the ACP can actually invoke these methods.</p>"},{"location":"php/exceptions/","title":"Exceptions","text":""},{"location":"php/exceptions/#spl-exceptions","title":"SPL Exceptions","text":"<p>The Standard PHP Library (SPL) provides some exceptions that should be used whenever possible.</p>"},{"location":"php/exceptions/#custom-exceptions","title":"Custom Exceptions","text":"<p>Do not use <code>wcf\\system\\exception\\SystemException</code> anymore, use specific exception classes!</p> <p>The following table contains a list of custom exceptions that are commonly used. All of the exceptions are found in the <code>wcf\\system\\exception</code> namespace.</p> Class name (examples) when to use <code>IllegalLinkException</code> access to a page that belongs to a non-existing object, executing actions on specific non-existing objects (is shown as http 404 error to the user) <code>ImplementationException</code> a class does not implement an expected interface <code>InvalidObjectArgument</code> 5.4+ API method support generic objects but specific implementation requires objects of specific (sub)class and different object is given <code>InvalidObjectTypeException</code> object type is not of an expected object type definition <code>InvalidSecurityTokenException</code> given security token does not match the security token of the active user's session <code>ParentClassException</code> a class does not extend an expected (parent) class <code>PermissionDeniedException</code> page access without permission, action execution without permission (is shown as http 403 error to the user) <code>UserInputException</code> user input does not pass validation"},{"location":"php/exceptions/#sensitive-arguments-in-stack-traces","title":"Sensitive Arguments in Stack Traces","text":"<p>Sometimes sensitive values are passed as a function or method argument. If the callee throws an Exception, these values will be part of the Exception\u2019s stack trace and logged, unless the Exception is caught and ignored.</p> <p>WoltLab Suite will automatically suppress the values of parameters named like they might contain sensitive values, namely arguments matching the regular expression <code>/(?:^(?:password|passphrase|secret)|(?:Password|Passphrase|Secret))/</code>.</p> <p>If you need to suppress additional arguments from appearing in the stack trace, you can add the <code>\\wcf\\SensitiveArgument</code> attribute to such parameters. Arguments are only supported as of PHP 8 and ignored as comments in lower PHP versions. In PHP 7, such arguments will not be suppressed, but the code will continue to work. Make sure to insert a linebreak between the attribute and the parameter name.</p> <p>Example:</p> wcfsetup/install/files/lib/data/user/User.class.php<pre><code><?php\n\nnamespace wcf\\data\\user;\n\n// \u2026\n\nfinal class User extends DatabaseObject implements IPopoverObject, IRouteController, IUserContent\n{\n // \u2026\n\n public function checkPassword(\n #[\\wcf\\SensitiveArgument()]\n $password\n ) {\n // \u2026\n }\n\n // \u2026\n}\n</code></pre>"},{"location":"php/gdpr/","title":"General Data Protection Regulation (GDPR)","text":""},{"location":"php/gdpr/#introduction","title":"Introduction","text":"<p>The General Data Protection Regulation (GDPR) of the European Union enters into force on May 25, 2018. It comes with a set of restrictions when handling users' personal data as well as to provide an interface to export this data on demand.</p> <p>If you're looking for a guide on the implications of the GDPR and what you will need or consider to do, please read the article Implementation of the GDPR on woltlab.com.</p>"},{"location":"php/gdpr/#including-data-in-the-export","title":"Including Data in the Export","text":"<p>The <code>wcf\\acp\\action\\UserExportGdprAction</code> already includes WoltLab Suite Core itself as well as all official apps, but you'll need to include any personal data stored for your plugin or app by yourself.</p> <p>The event <code>export</code> is fired before any data is sent out, but after any Core data has been dumped to the <code>$data</code> property.</p>"},{"location":"php/gdpr/#example-code","title":"Example code","text":"files/lib/system/event/listener/MyUserExportGdprActionListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\nuse wcf\\acp\\action\\UserExportGdprAction;\nuse wcf\\data\\user\\UserProfile;\n\nclass MyUserExportGdprActionListener implements IParameterizedEventListener {\n public function execute(/** @var UserExportGdprAction $eventObj */$eventObj, $className, $eventName, array &$parameters) {\n /** @var UserProfile $user */\n $user = $eventObj->user;\n\n $eventObj->data['my.fancy.plugin'] = [\n 'superPersonalData' => \"This text is super personal and should be included in the output\",\n 'weirdIpAddresses' => $eventObj->exportIpAddresses('app'.WCF_N.'_non_standard_column_names_for_ip_addresses', 'ipAddressColumnName', 'timeColumnName', 'userIDColumnName')\n ];\n $eventObj->exportUserProperties[] = 'shouldAlwaysExportThisField';\n $eventObj->exportUserPropertiesIfNotEmpty[] = 'myFancyField';\n $eventObj->exportUserOptionSettings[] = 'thisSettingIsAlwaysExported';\n $eventObj->exportUserOptionSettingsIfNotEmpty[] = 'someSettingContainingPersonalData';\n $eventObj->ipAddresses['my.fancy.plugin'] = ['wcf'.WCF_N.'_my_fancy_table', 'wcf'.WCF_N.'_i_also_store_ipaddresses_here'];\n $eventObj->skipUserOptions[] = 'thisLooksLikePersonalDataButItIsNot';\n $eventObj->skipUserOptions[] = 'thisIsAlsoNotPersonalDataPleaseIgnoreIt';\n }\n}\n</code></pre>"},{"location":"php/gdpr/#data","title":"<code>$data</code>","text":"<p>Contains the entire data that will be included in the exported JSON file, some fields may already exist (such as <code>'com.woltlab.wcf'</code>) and while you may add or edit any fields within, you should restrict yourself to only append data from your plugin or app.</p>"},{"location":"php/gdpr/#exportuserproperties","title":"<code>$exportUserProperties</code>","text":"<p>Only a whitelist of columns in <code>wcfN_user</code> is exported by default, if your plugin or app adds one or more columns to this table that do hold personal data, then you will have to append it to this array. The listed properties will always be included regardless of their content.</p>"},{"location":"php/gdpr/#exportuserpropertiesifnotempty","title":"<code>$exportUserPropertiesIfNotEmpty</code>","text":"<p>Only a whitelist of columns in <code>wcfN_user</code> is exported by default, if your plugin or app adds one or more columns to this table that do hold personal data, then you will have to append it to this array. Empty values will not be added to the output.</p>"},{"location":"php/gdpr/#exportuseroptionsettings","title":"<code>$exportUserOptionSettings</code>","text":"<p>Any user option that exists within a <code>settings.*</code> category is automatically excluded from the export, with the notable exception of the <code>timezone</code> option. You can opt-in to include your setting by appending to this array, if it contains any personal data. The listed settings are always included regardless of their content.</p>"},{"location":"php/gdpr/#exportuseroptionsettingsifnotempty","title":"<code>$exportUserOptionSettingsIfNotEmpty</code>","text":"<p>Any user option that exists within a <code>settings.*</code> category is automatically excluded from the export, with the notable exception of the <code>timezone</code> option. You can opt-in to include your setting by appending to this array, if it contains any personal data.</p>"},{"location":"php/gdpr/#ipaddresses","title":"<code>$ipAddresses</code>","text":"<p>List of database table names per package identifier that contain ip addresses. The contained ip addresses will be exported when the ip logging module is enabled.</p> <p>It expects the database table to use the column names <code>ipAddress</code>, <code>time</code> and <code>userID</code>. If your table does not match this pattern for whatever reason, you'll need to manually probe for <code>LOG_IP_ADDRESS</code> and then call <code>exportIpAddresses()</code> to retrieve the list. Afterwards you are responsible to append these ip addresses to the <code>$data</code> array to have it exported.</p>"},{"location":"php/gdpr/#skipuseroptions","title":"<code>$skipUserOptions</code>","text":"<p>All user options are included in the export by default, unless they start with <code>can*</code> or <code>admin*</code>, or are blacklisted using this array. You should append any of your plugin's or app's user option that should not be exported, for example because it does not contain personal data, such as internal data.</p>"},{"location":"php/pages/","title":"Page Types","text":""},{"location":"php/pages/#abstractpage","title":"AbstractPage","text":"<p>The default implementation for pages to present any sort of content, but are designed to handle <code>GET</code> requests only. They usually follow a fixed method chain that will be invoked one after another, adding logical sections to the request flow.</p>"},{"location":"php/pages/#method-chain","title":"Method Chain","text":""},{"location":"php/pages/#__run","title":"__run()","text":"<p>This is the only method being invoked from the outside and starts the whole chain.</p>"},{"location":"php/pages/#readparameters","title":"readParameters()","text":"<p>Reads and sanitizes request parameters, this should be the only method to ever read user-supplied input. Read data should be stored in class properties to be accessible at a later point, allowing your code to safely assume that the data has been sanitized and is safe to work with.</p> <p>A typical example is the board page from the forum app that reads the id and attempts to identify the request forum.</p> <pre><code>public function readParameters() {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) $this->boardID = intval($_REQUEST['id']);\n $this->board = BoardCache::getInstance()->getBoard($this->boardID);\n if ($this->board === null) {\n throw new IllegalLinkException();\n }\n\n // check permissions\n if (!$this->board->canEnter()) {\n throw new PermissionDeniedException();\n }\n}\n</code></pre> <p>Events <code>readParameters</code></p>"},{"location":"php/pages/#show","title":"show()","text":"<p>Used to be the method of choice to handle permissions and module option checks, but has been used almost entirely as an internal method since the introduction of the properties <code>$loginRequired</code>, <code>$neededModules</code> and <code>$neededPermissions</code>.</p> <p>Events <code>checkModules</code>, <code>checkPermissions</code> and <code>show</code></p>"},{"location":"php/pages/#readdata","title":"readData()","text":"<p>Central method for data retrieval based on class properties including those populated with user data in <code>readParameters()</code>. It is strongly recommended to use this method to read data in order to properly separate the business logic present in your class.</p> <p>Events <code>readData</code></p>"},{"location":"php/pages/#assignvariables","title":"assignVariables()","text":"<p>Last method call before the template engine kicks in and renders the template. All though some properties are bound to the template automatically, you still need to pass any custom variables and class properties to the engine to make them available in templates.</p> <p>Following the example in <code>readParameters()</code>, the code below adds the board data to the template.</p> <pre><code>public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'board' => $this->board,\n 'boardID' => $this->boardID\n ]);\n}\n</code></pre> <p>Events <code>assignVariables</code></p>"},{"location":"php/pages/#abstractform","title":"AbstractForm","text":"<p>Extends the AbstractPage implementation with additional methods designed to handle form submissions properly.</p>"},{"location":"php/pages/#method-chain_1","title":"Method Chain","text":""},{"location":"php/pages/#__run_1","title":"__run()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#readparameters_1","title":"readParameters()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#show_1","title":"show()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#submit","title":"submit()","text":"<p>The methods <code>submit()</code> up until <code>save()</code> are only invoked if either <code>$_POST</code> or <code>$_FILES</code> are not empty, otherwise they won't be invoked and the execution will continue with <code>readData()</code>.</p> <p>This is an internal method that is responsible of input processing and validation.</p> <p>Events <code>submit</code></p>"},{"location":"php/pages/#readformparameters","title":"readFormParameters()","text":"<p>This method is quite similar to <code>readParameters()</code> that is being called earlier, but is designed around reading form data submitted through POST requests. You should avoid accessing <code>$_GET</code> or <code>$_REQUEST</code> in this context to avoid mixing up parameters evaluated when retrieving the page on first load and when submitting to it.</p> <p>Events <code>readFormParameters</code></p>"},{"location":"php/pages/#validate","title":"validate()","text":"<p>Deals with input validation and automatically catches exceptions deriving from <code>wcf\\system\\exception\\UserInputException</code>, resulting in a clean and consistent error handling for the user.</p> <p>Events <code>validate</code></p>"},{"location":"php/pages/#save","title":"save()","text":"<p>Saves the processed data to database or any other source of your choice. Please keep in mind to invoke <code>$this->saved()</code> before resetting the form data.</p> <p>Events <code>save</code></p>"},{"location":"php/pages/#saved","title":"saved()","text":"<p>This method is not called automatically and must be invoked manually by executing <code>$this->saved()</code> inside <code>save()</code>.</p> <p>The only purpose of this method is to fire the event <code>saved</code> that signals that the form data has been processed successfully and data has been saved. It is somewhat special as it is dispatched after the data has been saved, but before the data is purged during form reset. This is by default the last event that has access to the processed data.</p> <p>Events <code>saved</code></p>"},{"location":"php/pages/#readdata_1","title":"readData()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#assignvariables_1","title":"assignVariables()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/api/acp_dashboard_boxes/","title":"ACP Dashboard Boxes","text":"<p>ACP Dashboard Boxes are displayed on the landing page of the admin panel and can provide the user with useful information. A box consists of an internal identifier, a name and the content of the box. The content can contain HTML code.</p>"},{"location":"php/api/acp_dashboard_boxes/#create-a-custom-box","title":"Create a Custom Box","text":"<p>A custom box can be created with a custom PHP class that needs to implement the <code>wcf\\system\\acp\\dashboard\\box\\IAcpDashboardBox</code> interface. It is recommended to extend the class <code>wcf\\system\\acp\\dashboard\\box\\AbstractAcpDashboardBox</code>, which already provides a basic implementation of the interface.</p> <p>Example:</p> <pre><code><?php\nnamespace wcf\\system\\acp\\dashboard\\box;\n\nfinal class FooBox extends AbstractAcpDashboardBox {\n public function getTitle(): string\n {\n return 'title of the box';\n }\n\n public function getContent(): string\n {\n return 'content of the box';\n }\n\n public function getName(): string\n {\n return 'com.foo.bar'; // identifier of the box; must be unique\n }\n}\n</code></pre>"},{"location":"php/api/acp_dashboard_boxes/#register-a-custom-box","title":"Register a Custom Box","text":"<p>You can attach an event listener to the <code>wcf\\event\\acp\\dashboard\\box\\BoxCollecting</code> event inside a bootstrap script to lazily register custom boxes. The class name of the box is registered using the event\u2019s <code>register()</code> method:</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\event\\acp\\dashboard\\box\\BoxCollecting;\n\nreturn static function (): void {\n $eventHandler = EventHandler::getInstance();\n\n $eventHandler->register(BoxCollecting::class, static function (BoxCollecting $event) {\n $event->register(\\wcf\\system\\acp\\dashboard\\box\\FooBox::class);\n });\n};\n</code></pre>"},{"location":"php/api/caches/","title":"Caches","text":"<p>WoltLab Suite offers two distinct types of caches:</p> <ol> <li>Persistent caches created by cache builders whose data can be stored using different cache sources.</li> <li>Runtime caches store objects for the duration of a single request.</li> </ol>"},{"location":"php/api/caches/#understanding-caching","title":"Understanding Caching","text":"<p>Every so often, plugins make use of cache builders or runtime caches to store their data, even if there is absolutely no need for them to do so. Usually, this involves a strong opinion about the total number of SQL queries on a page, including but not limited to some magic treshold numbers, which should not be exceeded for \"performance reasons\".</p> <p>This misconception can easily lead into thinking that SQL queries should be avoided or at least written to a cache, so that it doesn't need to be executed so often. Unfortunately, this completely ignores the fact that both a single query can take down your app (e. g. full table scan on millions of rows), but 10 queries using a primary key on a table with a few hundred rows will not slow down your page.</p> <p>There are some queries that should go into caches by design, but most of the cache builders weren't initially there, but instead have been added because they were required to reduce the load significantly. You need to understand that caches always come at a cost, even a runtime cache does! In particular, they will always consume memory that is not released over the duration of the request lifecycle and potentially even leak memory by holding references to objects and data structures that are no longer required.</p> <p>Caching should always be a solution for a problem.</p>"},{"location":"php/api/caches/#when-to-use-a-cache","title":"When to Use a Cache","text":"<p>It's difficult to provide a definite answer or checklist when to use a cache and why it is required at this point, because the answer is: It depends. The permission cache for user groups is a good example for a valid cache, where we can achieve significant performance improvement compared to processing this data on every request.</p> <p>Its caches are build for each permutation of user group memberships that are encountered for a page request. Building this data is an expensive process that involves both inheritance and specific rules in regards to when a value for a permission overrules another value. The added benefit of this cache is that one cache usually serves a large number of users with the same group memberships and by computing these permissions once, we can serve many different requests. Also, the permissions are rather static values that change very rarely and thus we can expect a very high cache lifetime before it gets rebuild.</p>"},{"location":"php/api/caches/#when-not-to-use-a-cache","title":"When not to Use a Cache","text":"<p>I remember, a few years ago, there was a plugin that displayed a user's character from an online video game. The character sheet not only included a list of basic statistics, but also displayed the items that this character was wearing and or holding at the time.</p> <p>The data for these items were downloaded in bulk from the game's vendor servers and stored in a persistent cache file that periodically gets renewed. There is nothing wrong with the idea of caching the data on your own server rather than requesting them everytime from the vendor's servers - not only because they imposed a limit on the number of requests per hour.</p> <p>Unfortunately, the character sheet had a sub-par performance and the users were upset by the significant loading times compared to literally every other page on the same server. The author of the plugin was working hard to resolve this issue and was evaluating all kind of methods to improve the page performance, including deep-diving into the realm of micro-optimizations to squeeze out every last bit of performance that is possible.</p> <p>The real problem was the cache file itself, it turns out that it was holding the data for several thousand items with a total file size of about 13 megabytes. It doesn't look that much at first glance, after all this isn't the '90s anymore, but unserializing a 13 megabyte array is really slow and looking up items in such a large array isn't exactly fast either.</p> <p>The solution was rather simple, the data that was fetched from the vendor's API was instead written into a separate database table. Next, the persistent cache was removed and the character sheet would now request the item data for that specific character straight from the database. Previously, the character sheet took several seconds to load and after the change it was done in a fraction of a second. Although quite extreme, this illustrates a situation where the cache file was introduced in the design process, without evaluating if the cache - at least how it was implemented - was really necessary.</p> <p>Caching should always be a solution for a problem. Not the other way around.</p>"},{"location":"php/api/caches_persistent-caches/","title":"Persistent Caches","text":"<p>Relational databases are designed around the principle of normalized data that is organized across clearly separated tables with defined releations between data rows. While this enables you to quickly access and modify individual rows and columns, it can create the problem that re-assembling this data into a more complex structure can be quite expensive.</p> <p>For example, the user group permissions are stored for each user group and each permissions separately, but in order to be applied, they need to be fetched and the cumulative values across all user groups of an user have to be calculated. These repetitive tasks on barely ever changing data make them an excellent target for caching, where all sub-sequent requests are accelerated because they no longer have to perform the same expensive calculations every time.</p> <p>It is easy to get lost in the realm of caching, especially when it comes to the decision if you should use a cache or not. When in doubt, you should opt to not use them, because they also come at a hidden cost that cannot be expressed through simple SQL query counts. If you haven't already, it is recommended that you read the introduction article on caching first, it provides a bit of background on caches and examples that should help you in your decision.</p>"},{"location":"php/api/caches_persistent-caches/#abstractcachebuilder","title":"<code>AbstractCacheBuilder</code>","text":"<p>Every cache builder should derive from the base class AbstractCacheBuilder that already implements the mandatory interface ICacheBuilder.</p> files/lib/system/cache/builder/ExampleCacheBuilder.class.php <pre><code><?php\nnamespace wcf\\system\\cache\\builder;\n\nclass ExampleCacheBuilder extends AbstractCacheBuilder {\n // 3600 = 1hr\n protected $maxLifetime = 3600;\n\n public function rebuild(array $parameters) {\n $data = [];\n\n // fetch and process your data and assign it to `$data`\n\n return $data;\n }\n}\n</code></pre> <p>Reading data from your cache builder is quite simple and follows a consistent pattern. The callee only needs to know the name of the cache builder, which parameters it requires and how the returned data looks like. It does not need to know how the data is retrieve, where it was stored, nor if it had to be rebuild due to the maximum lifetime.</p> <pre><code><?php\nuse wcf\\system\\cache\\builder\\ExampleCacheBuilder;\n\n$data = ExampleCacheBuilder::getInstance()->getData($parameters);\n</code></pre>"},{"location":"php/api/caches_persistent-caches/#getdataarray-parameters-string-arrayindex-array","title":"<code>getData(array $parameters = [], string $arrayIndex = ''): array</code>","text":"<p>Retrieves the data from the cache builder, the <code>$parameters</code> array is automatically sorted to allow sub-sequent requests for the same parameters to be recognized, even if their parameters are mixed. For example, <code>getData([1, 2])</code> and <code>getData([2, 1])</code> will have the same exact result.</p> <p>The optional <code>$arrayIndex</code> will instruct the cache builder to retrieve the data and examine if the returned data is an array that has the index <code>$arrayIndex</code>. If it is set, the potion below this index is returned instead.</p>"},{"location":"php/api/caches_persistent-caches/#getmaxlifetime-int","title":"<code>getMaxLifetime(): int</code>","text":"<p>Returns the maximum lifetime of a cache in seconds. It can be controlled through the <code>protected $maxLifetime</code> property which defaults to <code>0</code>. Any cache that has a lifetime greater than 0 is automatically discarded when exceeding this age, otherwise it will remain forever until it is explicitly removed or invalidated.</p>"},{"location":"php/api/caches_persistent-caches/#resetarray-parameters-void","title":"<code>reset(array $parameters = []): void</code>","text":"<p>Invalidates a cache, the <code>$parameters</code> array will again be ordered using the same rules that are applied for <code>getData()</code>.</p>"},{"location":"php/api/caches_persistent-caches/#rebuildarray-parameters-array","title":"<code>rebuild(array $parameters): array</code>","text":"<p>This method is protected.</p> <p>This is the only method that a cache builder deriving from <code>AbstractCacheBuilder</code> has to implement and it will be invoked whenever the cache is required to be rebuild for whatever reason.</p>"},{"location":"php/api/caches_runtime-caches/","title":"Runtime Caches","text":"<p>Runtime caches store objects created during the runtime of the script and are automatically discarded after the script terminates. Runtime caches are especially useful when objects are fetched by different APIs, each requiring separate requests. By using a runtime cache, you have two advantages:</p> <ol> <li>If the API allows it, you can delay fetching the actual objects and initially only tell the runtime cache that at some point in the future of the current request, you need the objects with the given ids. If multiple APIs do this one after another, all objects can be fetched using only one query instead of each API querying the database on its own.</li> <li>If an object with the same ID has already been fetched from database, this object is simply returned and can be reused instead of being fetched from database again.</li> </ol>"},{"location":"php/api/caches_runtime-caches/#iruntimecache","title":"<code>IRuntimeCache</code>","text":"<p>Every runtime cache has to implement the IRuntimeCache interface. It is recommended, however, that you extend AbstractRuntimeCache, the default implementation of the runtime cache interface. In most instances, you only need to set the <code>AbstractRuntimeCache::$listClassName</code> property to the name of database object list class which fetches the cached objects from database (see example).</p>"},{"location":"php/api/caches_runtime-caches/#usage","title":"Usage","text":"<pre><code><?php\nuse wcf\\system\\cache\\runtime\\UserRuntimeCache;\n\n$userIDs = [1, 2];\n\n// first (optional) step: tell runtime cache to remember user ids\nUserRuntimeCache::getInstance()->cacheObjectIDs($userIDs);\n\n// [\u2026]\n\n// second step: fetch the objects from database\n$users = UserRuntimeCache::getInstance()->getObjects($userIDs);\n\n// somewhere else: fetch only one user\n$userID = 1;\n\nUserRuntimeCache::getInstance()->cacheObjectID($userID);\n\n// [\u2026]\n\n// get user without the cache actually fetching it from database because it has already been loaded\n$user = UserRuntimeCache::getInstance()->getObject($userID);\n\n// somewhere else: fetch users directly without caching user ids first\n$users = UserRuntimeCache::getInstance()->getObjects([3, 4]);\n</code></pre>"},{"location":"php/api/caches_runtime-caches/#example","title":"Example","text":"files/lib/system/cache/runtime/UserRuntimeCache.class.php <pre><code><?php\nnamespace wcf\\system\\cache\\runtime;\nuse wcf\\data\\user\\User;\nuse wcf\\data\\user\\UserList;\n\n/**\n * Runtime cache implementation for users.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2016 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Cache\\Runtime\n * @since 3.0\n *\n * @method User[] getCachedObjects()\n * @method User getObject($objectID)\n * @method User[] getObjects(array $objectIDs)\n */\nclass UserRuntimeCache extends AbstractRuntimeCache {\n /**\n * @inheritDoc\n */\n protected $listClassName = UserList::class;\n}\n</code></pre>"},{"location":"php/api/comments/","title":"Comments","text":""},{"location":"php/api/comments/#user-group-options","title":"User Group Options","text":"<p>You need to create the following permissions:</p> user group type permission type naming user creating comments <code>user.foo.canAddComment</code> user editing own comments <code>user.foo.canEditComment</code> user deleting own comments <code>user.foo.canDeleteComment</code> moderator moderating comments <code>mod.foo.canModerateComment</code> moderator editing comments <code>mod.foo.canEditComment</code> moderator deleting comments <code>mod.foo.canDeleteComment</code> <p>Within their respective user group option category, the options should be listed in the same order as in the table above.</p>"},{"location":"php/api/comments/#language-items","title":"Language Items","text":""},{"location":"php/api/comments/#user-group-options_1","title":"User Group Options","text":"<p>The language items for the comment-related user group options generally have the same values:</p> <ul> <li><code>wcf.acp.group.option.user.foo.canAddComment</code></li> </ul> <p>German: <code>Kann Kommentare erstellen</code></p> <p>English: <code>Can create comments</code></p> <ul> <li><code>wcf.acp.group.option.user.foo.canEditComment</code></li> </ul> <p>German: <code>Kann eigene Kommentare bearbeiten</code></p> <p>English: <code>Can edit their comments</code></p> <ul> <li><code>wcf.acp.group.option.user.foo.canDeleteComment</code></li> </ul> <p>German: <code>Kann eigene Kommentare l\u00f6schen</code></p> <p>English: <code>Can delete their comments</code></p> <ul> <li><code>wcf.acp.group.option.mod.foo.canModerateComment</code></li> </ul> <p>German: <code>Kann Kommentare moderieren</code></p> <p>English: <code>Can moderate comments</code></p> <ul> <li><code>wcf.acp.group.option.mod.foo.canEditComment</code></li> </ul> <p>German: <code>Kann Kommentare bearbeiten</code></p> <p>English: <code>Can edit comments</code></p> <ul> <li><code>wcf.acp.group.option.mod.foo.canDeleteComment</code></li> </ul> <p>German: <code>Kann Kommentare l\u00f6schen</code></p> <p>English: <code>Can delete comments</code></p>"},{"location":"php/api/cronjobs/","title":"Cronjobs","text":"<p>Cronjobs offer an easy way to execute actions periodically, like cleaning up the database.</p> <p>The execution of cronjobs is not guaranteed but requires someone to access the page with JavaScript enabled.</p> <p>This page focuses on the technical aspects of cronjobs, the cronjob package installation plugin page covers how you can actually register a cronjob.</p>"},{"location":"php/api/cronjobs/#example","title":"Example","text":"files/lib/system/cronjob/LastActivityCronjob.class.php <pre><code><?php\nnamespace wcf\\system\\cronjob;\nuse wcf\\data\\cronjob\\Cronjob;\nuse wcf\\system\\WCF;\n\n/**\n * Updates the last activity timestamp in the user table.\n *\n * @author Marcel Werk\n * @copyright 2001-2016 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Cronjob\n */\nclass LastActivityCronjob extends AbstractCronjob {\n /**\n * @inheritDoc\n */\n public function execute(Cronjob $cronjob) {\n parent::execute($cronjob);\n\n $sql = \"UPDATE wcf1_user user_table,\n wcf1_session session\n SET user_table.lastActivityTime = session.lastActivityTime\n WHERE user_table.userID = session.userID\n AND session.userID <> 0\";\n $statement = WCF::getDB()->prepare($sql);\n $statement->execute();\n }\n}\n</code></pre>"},{"location":"php/api/cronjobs/#icronjob-interface","title":"<code>ICronjob</code> Interface","text":"<p>Every cronjob needs to implement the <code>wcf\\system\\cronjob\\ICronjob</code> interface which requires the <code>execute(Cronjob $cronjob)</code> method to be implemented. This method is called by wcf\\system\\cronjob\\CronjobScheduler when executing the cronjobs.</p> <p>In practice, however, you should extend the <code>AbstractCronjob</code> class and also call the <code>AbstractCronjob::execute()</code> method as it fires an event which makes cronjobs extendable by plugins (see event documentation).</p>"},{"location":"php/api/event_list/","title":"Event List","text":"<p>Events whose name is marked with an asterisk are called from a static method and thus do not provide any object, just the class name. </p>"},{"location":"php/api/event_list/#woltlab-suite-core","title":"WoltLab Suite Core","text":"Class Event Name <code>wcf\\acp\\action\\UserExportGdprAction</code> <code>export</code> <code>wcf\\acp\\form\\StyleAddForm</code> <code>setVariables</code> <code>wcf\\acp\\form\\UserSearchForm</code> <code>search</code> <code>wcf\\action\\AbstractAction</code> <code>checkModules</code> <code>wcf\\action\\AbstractAction</code> <code>checkPermissions</code> <code>wcf\\action\\AbstractAction</code> <code>execute</code> <code>wcf\\action\\AbstractAction</code> <code>executed</code> <code>wcf\\action\\AbstractAction</code> <code>readParameters</code> <code>wcf\\data\\attachment\\AttachmentAction</code> <code>generateThumbnail</code> <code>wcf\\data\\session\\SessionAction</code> <code>keepAlive</code> <code>wcf\\data\\session\\SessionAction</code> <code>poll</code> <code>wcf\\data\\trophy\\Trophy</code> <code>renderTrophy</code> <code>wcf\\data\\user\\online\\UserOnline</code> <code>getBrowser</code> <code>wcf\\data\\user\\online\\UsersOnlineList</code> <code>isVisible</code> <code>wcf\\data\\user\\online\\UsersOnlineList</code> <code>isVisibleUser</code> <code>wcf\\data\\user\\trophy\\UserTrophy</code> <code>getReplacements</code> <code>wcf\\data\\user\\UserAction</code> <code>beforeFindUsers</code> <code>wcf\\data\\user\\UserAction</code> <code>rename</code> <code>wcf\\data\\user\\UserProfile</code> <code>getAvatar</code> <code>wcf\\data\\user\\UserProfile</code> <code>isAccessible</code> <code>wcf\\data\\AbstractDatabaseObjectAction</code> <code>finalizeAction</code> <code>wcf\\data\\AbstractDatabaseObjectAction</code> <code>initializeAction</code> <code>wcf\\data\\AbstractDatabaseObjectAction</code> <code>validateAction</code> <code>wcf\\data\\DatabaseObjectList</code> <code>init</code> <code>wcf\\form\\AbstractForm</code> <code>readFormParameters</code> <code>wcf\\form\\AbstractForm</code> <code>save</code> <code>wcf\\form\\AbstractForm</code> <code>saved</code> <code>wcf\\form\\AbstractForm</code> <code>submit</code> <code>wcf\\form\\AbstractForm</code> <code>validate</code> <code>wcf\\form\\AbstractFormBuilderForm</code> <code>createForm</code> <code>wcf\\form\\AbstractFormBuilderForm</code> <code>buildForm</code> <code>wcf\\form\\AbstractModerationForm</code> <code>prepareSave</code> <code>wcf\\page\\AbstractPage</code> <code>assignVariables</code> <code>wcf\\page\\AbstractPage</code> <code>checkModules</code> <code>wcf\\page\\AbstractPage</code> <code>checkPermissions</code> <code>wcf\\page\\AbstractPage</code> <code>readData</code> <code>wcf\\page\\AbstractPage</code> <code>readParameters</code> <code>wcf\\page\\AbstractPage</code> <code>show</code> <code>wcf\\page\\MultipleLinkPage</code> <code>beforeReadObjects</code> <code>wcf\\page\\MultipleLinkPage</code> <code>insteadOfReadObjects</code> <code>wcf\\page\\MultipleLinkPage</code> <code>afterInitObjectList</code> <code>wcf\\page\\MultipleLinkPage</code> <code>calculateNumberOfPages</code> <code>wcf\\page\\MultipleLinkPage</code> <code>countItems</code> <code>wcf\\page\\SortablePage</code> <code>validateSortField</code> <code>wcf\\page\\SortablePage</code> <code>validateSortOrder</code> <code>wcf\\system\\bbcode\\MessageParser</code> <code>afterParsing</code> <code>wcf\\system\\bbcode\\MessageParser</code> <code>beforeParsing</code> <code>wcf\\system\\bbcode\\SimpleMessageParser</code> <code>afterParsing</code> <code>wcf\\system\\bbcode\\SimpleMessageParser</code> <code>beforeParsing</code> <code>wcf\\system\\box\\BoxHandler</code> <code>loadBoxes</code> <code>wcf\\system\\box\\AbstractBoxController</code> <code>__construct</code> <code>wcf\\system\\box\\AbstractBoxController</code> <code>afterLoadContent</code> <code>wcf\\system\\box\\AbstractBoxController</code> <code>beforeLoadContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>afterLoadContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>beforeLoadContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>hasContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>readObjects</code> <code>wcf\\system\\cronjob\\AbstractCronjob</code> <code>execute</code> <code>wcf\\system\\email\\Email</code> <code>getJobs</code> <code>wcf\\system\\form\\builder\\container\\wysiwyg\\WysiwygFormContainer</code> <code>populate</code> <code>wcf\\system\\html\\input\\filter\\MessageHtmlInputFilter</code> <code>setAttributeDefinitions</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>afterProcess</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>beforeEmbeddedProcess</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>beforeProcess</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>convertPlainLinks</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>getTextContent</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>parseEmbeddedContent</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeWoltlabMetacodeMarker</code> <code>filterGroups</code> <code>wcf\\system\\html\\output\\node\\HtmlOutputNodePre</code> <code>selectHighlighter</code> <code>wcf\\system\\html\\output\\node\\HtmlOutputNodeProcessor</code> <code>beforeProcess</code> <code>wcf\\system\\image\\adapter\\ImagickImageAdapter</code> <code>getResizeFilter</code> <code>wcf\\system\\menu\\user\\profile\\UserProfileMenu</code> <code>init</code> <code>wcf\\system\\menu\\user\\profile\\UserProfileMenu</code> <code>loadCache</code> <code>wcf\\system\\menu\\TreeMenu</code> <code>init</code> <code>wcf\\system\\menu\\TreeMenu</code> <code>loadCache</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>addFullQuote</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>allowedDataParameters</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>beforeRenderQuote</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>createMessage</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>createdMessage</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>getMessage</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>validateParameters</code> <code>wcf\\system\\message\\quote\\MessageQuoteManager</code> <code>addFullQuote</code> <code>wcf\\system\\message\\quote\\MessageQuoteManager</code> <code>beforeRenderQuote</code> <code>wcf\\system\\option\\OptionHandler</code> <code>afterReadCache</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>construct</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>hasUninstall</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>install</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>uninstall</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>update</code> <code>wcf\\system\\package\\plugin\\ObjectTypePackageInstallationPlugin</code> <code>addConditionFields</code> <code>wcf\\system\\package\\PackageInstallationDispatcher</code> <code>postInstall</code> <code>wcf\\system\\package\\PackageUninstallationDispatcher</code> <code>postUninstall</code> <code>wcf\\system\\reaction\\ReactionHandler</code> <code>getDataAttributes</code> <code>wcf\\system\\request\\RouteHandler</code> <code>didInit</code> <code>wcf\\system\\session\\ACPSessionFactory</code> <code>afterInit</code> <code>wcf\\system\\session\\ACPSessionFactory</code> <code>beforeInit</code> <code>wcf\\system\\session\\SessionHandler</code> <code>afterChangeUser</code> <code>wcf\\system\\session\\SessionHandler</code> <code>beforeChangeUser</code> <code>wcf\\system\\style\\StyleCompiler</code> <code>compile</code> <code>wcf\\system\\template\\TemplateEngine</code> <code>afterDisplay</code> <code>wcf\\system\\template\\TemplateEngine</code> <code>beforeDisplay</code> <code>wcf\\system\\upload\\DefaultUploadFileSaveStrategy</code> <code>generateThumbnails</code> <code>wcf\\system\\upload\\DefaultUploadFileSaveStrategy</code> <code>save</code> <code>wcf\\system\\user\\authentication\\UserAuthenticationFactory</code> <code>init</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>createdNotification</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>fireEvent</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>markAsConfirmed</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>markAsConfirmedByIDs</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>removeNotifications</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>updateTriggerCount</code> <code>wcf\\system\\user\\UserBirthdayCache</code> <code>loadMonth</code> <code>wcf\\system\\worker\\AbstractRebuildDataWorker</code> <code>execute</code> <code>wcf\\system\\WCF</code> <code>initialized</code> <code>wcf\\util\\HeaderUtil</code> <code>parseOutput</code>*"},{"location":"php/api/event_list/#woltlab-suite-core-conversations","title":"WoltLab Suite Core: Conversations","text":"Class Event Name <code>wcf\\data\\conversation\\ConversationAction</code> <code>addParticipants_validateParticipants</code> <code>wcf\\data\\conversation\\message\\ConversationMessageAction</code> <code>afterQuickReply</code>"},{"location":"php/api/event_list/#woltlab-suite-core-infractions","title":"WoltLab Suite Core: Infractions","text":"Class Event Name <code>wcf\\system\\infraction\\suspension\\BanSuspensionAction</code> <code>suspend</code> <code>wcf\\system\\infraction\\suspension\\BanSuspensionAction</code> <code>unsuspend</code>"},{"location":"php/api/event_list/#woltlab-suite-forum","title":"WoltLab Suite Forum","text":"Class Event Name <code>wbb\\data\\board\\BoardAction</code> <code>cloneBoard</code> <code>wbb\\data\\post\\PostAction</code> <code>quickReplyShouldMerge</code> <code>wbb\\system\\thread\\ThreadHandler</code> <code>didInit</code>"},{"location":"php/api/event_list/#woltlab-suite-filebase","title":"WoltLab Suite Filebase","text":"Class Event Name <code>filebase\\data\\file\\File</code> <code>getPrice</code> <code>filebase\\data\\file\\ViewableFile</code> <code>getUnreadFiles</code>"},{"location":"php/api/events/","title":"Events","text":"<p>WoltLab Suite's event system allows manipulation of program flows and data without having to change any of the original source code. At many locations throughout the PHP code of WoltLab Suite Core and mainly through inheritance also in the applications and plugins, so called events are fired which trigger registered event listeners that get access to the object firing the event (or at least the class name if the event has been fired in a static method).</p> <p>This page focuses on the technical aspects of events and event listeners, the eventListener package installation plugin page covers how you can actually register an event listener. A comprehensive list of all available events is provided here.</p>"},{"location":"php/api/events/#introductory-example","title":"Introductory Example","text":"<p>Let's start with a simple example to illustrate how the event system works. Consider this pre-existing class:</p> files/lib/system/example/ExampleComponent.class.php <pre><code><?php\nnamespace wcf\\system\\example;\nuse wcf\\system\\event\\EventHandler;\n\nclass ExampleComponent {\n public $var = 1;\n\n public function getVar() {\n EventHandler::getInstance()->fireAction($this, 'getVar');\n\n return $this->var;\n }\n}\n</code></pre> <p>where an event with event name <code>getVar</code> is fired in the <code>getVar()</code> method.</p> <p>If you create an object of this class and call the <code>getVar()</code> method, the return value will be <code>1</code>, of course:</p> <pre><code><?php\n\n$example = new wcf\\system\\example\\ExampleComponent();\nif ($example->getVar() == 1) {\n echo \"var is 1!\";\n}\nelse if ($example->getVar() == 2) {\n echo \"var is 2!\";\n}\nelse {\n echo \"No, var is neither 1 nor 2.\";\n}\n\n// output: var is 1!\n</code></pre> <p>Now, consider that we have registered the following event listener to this event:</p> files/lib/system/event/listener/ExampleEventListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\n\nclass ExampleEventListener implements IParameterizedEventListener {\n public function execute($eventObj, $className, $eventName, array &$parameters) {\n $eventObj->var = 2;\n }\n}\n</code></pre> <p>Whenever the event in the <code>getVar()</code> method is called, this method (of the same event listener object) is called. In this case, the value of the method's first parameter is the <code>ExampleComponent</code> object passed as the first argument of the <code>EventHandler::fireAction()</code> call in <code>ExampleComponent::getVar()</code>. As <code>ExampleComponent::$var</code> is a public property, the event listener code can change it and set it to <code>2</code>.</p> <p>If you now execute the example code from above again, the output will change from <code>var is 1!</code> to <code>var is 2!</code> because prior to returning the value, the event listener code changes the value from <code>1</code> to <code>2</code>.</p> <p>This introductory example illustrates how event listeners can change data in a non-intrusive way. Program flow can be changed, for example, by throwing a <code>wcf\\system\\exception\\PermissionDeniedException</code> if some additional constraint to access a page is not fulfilled.</p>"},{"location":"php/api/events/#listening-to-events","title":"Listening to Events","text":"<p>In order to listen to events, you need to register the event listener and the event listener itself needs to implement the interface <code>wcf\\system\\event\\listener\\IParameterizedEventListener</code> which only contains the <code>execute</code> method (see example above).</p> <p>The first parameter <code>$eventObj</code> of the method contains the passed object where the event is fired or the name of the class in which the event is fired if it is fired from a static method. The second parameter <code>$className</code> always contains the name of the class where the event has been fired. The third parameter <code>$eventName</code> provides the name of the event within a class to uniquely identify the exact location in the class where the event has been fired. The last parameter <code>$parameters</code> is a reference to the array which contains additional data passed by the method firing the event. If no additional data is passed, <code>$parameters</code> is empty.</p>"},{"location":"php/api/events/#firing-events","title":"Firing Events","text":"<p>If you write code and want plugins to have access at certain points, you can fire an event on your own. The only thing to do is to call the <code>wcf\\system\\event\\EventHandler::fireAction($eventObj, $eventName, array &$parameters = [])</code> method and pass the following parameters:</p> <ol> <li><code>$eventObj</code> should be <code>$this</code> if you fire from an object context, otherwise pass the class name <code>static::class</code>.</li> <li><code>$eventName</code> identifies the event within the class and generally has the same name as the method. In cases, were you might fire more than one event in a method, for example before and after a certain piece of code, you can use the prefixes <code>before*</code> and <code>after*</code> in your event names.</li> <li><code>$parameters</code> is an optional array which allows you to pass additional data to the event listeners without having to make this data accessible via a property explicitly only created for this purpose. This additional data can either be just additional information for the event listeners about the context of the method call or allow the event listener to manipulate local data if the code, where the event has been fired, uses the passed data afterwards. </li> </ol>"},{"location":"php/api/events/#example-using-parameters-argument","title":"Example: Using <code>$parameters</code> argument","text":"<p>Consider the following method which gets some text that the methods parses.</p> files/lib/system/example/ExampleParser.class.php <pre><code><?php\nnamespace wcf\\system\\example;\nuse wcf\\system\\event\\EventHandler;\n\nclass ExampleParser {\n public function parse($text) {\n // [some parsing done by default]\n\n $parameters = ['text' => $text];\n EventHandler::getInstance()->fireAction($this, 'parse', $parameters);\n\n return $parameters['text'];\n }\n}\n</code></pre> <p>After the default parsing by the method itself, the author wants to enable plugins to do additional parsing and thus fires an event and passes the parsed text as an additional parameter. Then, a plugin can deliver the following event listener</p> files/lib/system/event/listener/ExampleParserEventListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\n\nclass ExampleParserEventListener implements IParameterizedEventListener {\n public function execute($eventObj, $className, $eventName, array &$parameters) {\n $text = $parameters['text'];\n\n // [some additional parsing which changes $text]\n\n $parameters['text'] = $text;\n }\n}\n</code></pre> <p>which can access the text via <code>$parameters['text']</code>.</p> <p>This example can also be perfectly used to illustrate how to name multiple events in the same method. Let's assume that the author wants to enable plugins to change the text before and after the method does its own parsing and thus fires two events:</p> files/lib/system/example/ExampleParser.class.php <pre><code><?php\nnamespace wcf\\system\\example;\nuse wcf\\system\\event\\EventHandler;\n\nclass ExampleParser {\n public function parse($text) {\n $parameters = ['text' => $text];\n EventHandler::getInstance()->fireAction($this, 'beforeParsing', $parameters);\n $text = $parameters['text'];\n\n // [some parsing done by default]\n\n $parameters = ['text' => $text];\n EventHandler::getInstance()->fireAction($this, 'afterParsing', $parameters);\n\n return $parameters['text'];\n }\n}\n</code></pre>"},{"location":"php/api/events/#advanced-example-additional-form-field","title":"Advanced Example: Additional Form Field","text":"<p>One common reason to use event listeners is to add an additional field to a pre-existing form (in combination with template listeners, which we will not cover here). We will assume that users are able to do both, create and edit the objects via this form. The points in the program flow of AbstractForm that are relevant here are:</p> <ul> <li>adding object (after the form has been submitted):</li> <li>reading the value of the field</li> <li>validating the read value</li> <li> <p>saving the additional value after successful validation and resetting locally stored value or assigning the current value of the field to the template after unsuccessful validation</p> </li> <li> <p>editing object:</p> </li> <li>on initial form request:<ol> <li>reading the pre-existing value of the edited object</li> <li>assigning the field value to the template</li> </ol> </li> <li>after the form has been submitted:<ol> <li>reading the value of the field</li> <li>validating the read value</li> <li>saving the additional value after successful validation</li> <li>assigning the current value of the field to the template</li> </ol> </li> </ul> <p>All of these cases can be covered the by following code in which we assume that <code>wcf\\form\\ExampleAddForm</code> is the form to create example objects and that <code>wcf\\form\\ExampleEditForm</code> extends <code>wcf\\form\\ExampleAddForm</code> and is used for editing existing example objects.</p> files/lib/system/event/listener/ExampleAddFormListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\nuse wcf\\form\\ExampleAddForm;\nuse wcf\\form\\ExampleEditForm;\nuse wcf\\system\\exception\\UserInputException;\nuse wcf\\system\\WCF;\n\nclass ExampleAddFormListener implements IParameterizedEventListener {\n protected $var = 0;\n\n public function execute($eventObj, $className, $eventName, array &$parameters) {\n $this->$eventName($eventObj);\n }\n\n protected function assignVariables() {\n WCF::getTPL()->assign('var', $this->var);\n }\n\n protected function readData(ExampleEditForm $eventObj) {\n if (empty($_POST)) {\n $this->var = $eventObj->example->var;\n }\n }\n\n protected function readFormParameters() {\n if (isset($_POST['var'])) $this->var = intval($_POST['var']);\n }\n\n protected function save(ExampleAddForm $eventObj) {\n $eventObj->additionalFields = array_merge($eventObj->additionalFields, ['var' => $this->var]);\n }\n\n protected function saved() {\n $this->var = 0;\n }\n\n protected function validate() {\n if ($this->var < 0) {\n throw new UserInputException('var', 'isNegative');\n }\n }\n}\n</code></pre> <p>The <code>execute</code> method in this example just delegates the call to a method with the same name as the event so that this class mimics the structure of a form class itself. The form object is passed to the methods but is only given in the method signatures as a parameter here whenever the form object is actually used. Furthermore, the type-hinting of the parameter illustrates in which contexts the method is actually called which will become clear in the following discussion of the individual methods:</p> <ul> <li><code>assignVariables()</code> is called for the add and the edit form and simply assigns the current value of the variable to the template.</li> <li><code>readData()</code> reads the pre-existing value of <code>$var</code> if the form has not been submitted and thus is only relevant when editing objects which is illustrated by the explicit type-hint of <code>ExampleEditForm</code>.</li> <li><code>readFormParameters()</code> reads the value for both, the add and the edit form.</li> <li><code>save()</code> is, of course, also relevant in both cases but requires the form object to store the additional value in the <code>wcf\\form\\AbstractForm::$additionalFields</code> array which can be used if a <code>var</code> column has been added to the database table in which the example objects are stored.</li> <li><code>saved()</code> is only called for the add form as it clears the internal value so that in the <code>assignVariables()</code> call, the default value will be assigned to the template to create an \"empty\" form. During edits, this current value is the actual value that should be shown.</li> <li><code>validate()</code> also needs to be called in both cases as the input data always has to be validated.</li> </ul> <p>Lastly, the following XML file has to be used to register the event listeners (you can find more information about how to register event listeners on the eventListener package installation plugin page):</p> eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/eventListener.xsd\">\n <import>\n <eventlistener name=\"exampleAddInherited\">\n <eventclassname>wcf\\form\\ExampleAddForm</eventclassname>\n <eventname>assignVariables,readFormParameters,save,validate</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\ExampleAddFormListener</listenerclassname>\n <inherit>1</inherit>\n </eventlistener>\n\n <eventlistener name=\"exampleAdd\">\n <eventclassname>wcf\\form\\ExampleAddForm</eventclassname>\n <eventname>saved</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\ExampleAddFormListener</listenerclassname>\n </eventlistener>\n\n <eventlistener name=\"exampleEdit\">\n <eventclassname>wcf\\form\\ExampleEditForm</eventclassname>\n <eventname>readData</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\ExampleAddFormListener</listenerclassname>\n </eventlistener>\n </import>\n</data>\n</code></pre>"},{"location":"php/api/events/#psr-14-events","title":"PSR-14 Events","text":"<p>WoltLab Suite 5.5 introduces the concept of dedicated, reusable event classes. Any newly introduced event will receive a dedicated class, implementing the <code>wcf\\event\\IPsr14Event</code> interface. These event classes may be fired from multiple locations, making them reusable to convey that a conceptual action happened, instead of a specific class doing something. An example for using the new event system could be a user logging in: Instead of listening on a the login form being submitted and the Facebook login action successfully running, an event <code>UserLoggedIn</code> might be fired whenever a user logs in, no matter how the login is performed.</p> <p>Additionally, these dedicated event classes will benefit from full IDE support. All the relevant values may be stored as real properties on the event object.</p> <p>Event classes should not have an <code>Event</code> suffix and should be stored in an <code>event</code> namespace in a matching location. Thus, the <code>UserLoggedIn</code> example might have a FQCN of <code>\\wcf\\event\\user\\authentication\\UserLoggedIn</code>.</p> <p>Event listeners for events implementing <code>IPsr14Event</code> need to follow PSR-14, i.e. they need to be callable. In practice, this means that the event listener class needs to implement <code>__invoke()</code>. No interface has to be implemented in this case.</p> <p>Previously:</p> <pre><code>$parameters = [\n 'value' => \\random_int(1, 1024),\n];\n\nEventHandler::getInstance()->fireAction($this, 'valueAvailable', $parameters);\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\form\\ValueForm;\n\nfinal class ValueDumpListener implements IParameterizedEventListener\n{\n /**\n * @inheritDoc\n * @param ValueForm $eventObj\n */\n public function execute($eventObj, $className, $eventName, array &$parameters)\n {\n var_dump($parameters['value']);\n }\n}\n</code></pre> <p>Now:</p> <pre><code>EventHandler::getInstance()->fire(new ValueAvailable(\\random_int(1, 1024)));\n</code></pre> lib/event/foo/ValueAvailable.class.php<pre><code><?php\n\nnamespace wcf\\event\\foo;\n\nuse wcf\\event\\IPsr14Event;\n\nfinal class ValueAvailable implements IPsr14Event\n{\n /**\n * @var int\n */\n private $value;\n\n public function __construct(int $value)\n {\n $this->value = $value;\n }\n\n public function getValue(): int\n {\n return $this->value;\n }\n}\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\event\\foo\\ValueAvailable;\n\nfinal class ValueDumpListener\n{\n public function __invoke(ValueAvailable $event): void\n {\n \\var_dump($event->getValue());\n }\n}\n</code></pre>"},{"location":"php/api/events/#available-psr-14-events","title":"Available PSR-14 Events","text":"Class Description <code>wcf\\event\\acp\\dashboard\\box\\BoxCollecting</code> Requests the collection of boxes for the acp dashboard. <code>wcf\\event\\acp\\dashboard\\box\\PHPExtensionCollecting</code> Requests the collection of PHP extensions for the system info ACP dashboard box. <code>wcf\\event\\acp\\dashboard\\box\\StatusMessageCollecting</code> Requests the collection of status messages for the status message dashboard box. <code>wcf\\event\\acp\\menu\\item\\ItemCollecting</code> Requests the collection of acp menu items. <code>wcf\\event\\cache\\CacheCleared</code> Indicates that a full cache clear was performed. <code>wcf\\event\\comment\\CommentCreated</code> Indicates that a new comment has been created. <code>wcf\\event\\comment\\CommentPublished</code> Indicates that a new comment has been published. This can happen directly when a comment is created or be delayed if a comment has first been checked and approved by a moderator. <code>wcf\\event\\comment\\CommentUpdated</code> Indicates that a comment has been updated. <code>wcf\\event\\comment\\CommentsDeleted</code> Indicates that multiple comments have been deleted. <code>wcf\\event\\comment\\response\\ResponseCreated</code> Indicates that a new comment response has been created. <code>wcf\\event\\comment\\response\\ResponsePublished</code> Indicates that a new comment response has been published. This can happen directly when a comment is created or be delayed if a response has first been checked and approved by a moderator. <code>wcf\\event\\comment\\response\\ResponseUpdated</code> Indicates that a response has been updated. <code>wcf\\event\\comment\\response\\ResponsesDeleted</code> Indicates that multiple responses have been deleted. <code>wcf\\event\\endpoint\\ControllerCollecting</code> Collects the list of API controllers. <code>wcf\\event\\language\\LanguageContentCopying</code> Indicates that the contents of a language should be copied to another one. <code>wcf\\event\\language\\LanguageImported</code> Indicates that a language was created or updated through a manual import. <code>wcf\\event\\language\\PhraseChanged</code> Indicates that a phrase has been modified by the user. <code>wcf\\event\\language\\PreloadPhrasesCollecting</code> Requests the collection of phrases that should be included in the preload cache. <code>wcf\\event\\message\\MessageSpamChecking</code> Indicates that a new message by a user is currently validated. If this event is interrupted, the message is considered to be spam. <code>wcf\\event\\moderation\\queue\\UserAssigned</code> Indicates that a user was assigned or reassigned to a moderation queue entry. <code>wcf\\event\\package\\PackageInstallationPluginSynced</code> Indicates that the a package installation plugin was executed through the developer tools. <code>wcf\\event\\package\\PackageListChanged</code> Indicates that the there have been changes to the package list. These changes include the installation, removal or update of existing packages. The event is fired at the end of the overall process and not for each package that has been modified. <code>wcf\\event\\package\\PackageUpdateListChanged</code> Indicates that the there have been changes to the package update list. <code>wcf\\event\\page\\ContactFormSpamChecking</code> Indicates that a new contact form message is currently validated. If this event is interrupted, the message is considered to be spam. <code>wcf\\event\\request\\ActivePageResolving</code> Indicates that the <code>RequestHandler</code> could not determine the active page. <code>wcf\\event\\session\\PreserveVariablesCollecting</code> This event allows the configuration of session variables that are to be preserved when the user changes. <code>wcf\\event\\spider\\SpiderCollecting</code> Requests the collection of spiders. <code>wcf\\event\\user\\RegistrationSpamChecking</code> Indicates that a registration by a new user is currently validated. If $matches is not empty, the registration is considered to be a spammer or an undesirable user. <code>wcf\\event\\user\\UsernameValidating</code> Indicates that a username is currently validated. If this event is interrupted, the username is considered to be invalid. This event will not be fired for usernames changed by an administrator. <code>wcf\\event\\user\\authentication\\UserLoggedIn</code> Indicates that the user actively logged in, i.e. that a user change happened in response to a user's request based off proper authentication. This event specifically must not be used if the active user is changed for technical reasons, e.g. when switching back to the real user after executing some logic with guest permissions. <code>wcf\\event\\user\\authentication\\configuration\\ConfigurationLoading</code> Indicates the loading of the user auth configuration. <code>wcf\\event\\user\\menu\\item\\IconResolving</code> Resolves the icon of a user menu item. <code>wcf\\event\\worker\\RebuildWorkerCollecting</code> Requests the collection of workers that should be included in the list of rebuild workers."},{"location":"php/api/package_installation_plugins/","title":"Package Installation Plugins","text":"<p>A package installation plugin (PIP) defines the behavior to handle a specific instruction during package installation, update or uninstallation.</p>"},{"location":"php/api/package_installation_plugins/#abstractpackageinstallationplugin","title":"<code>AbstractPackageInstallationPlugin</code>","text":"<p>Any package installation plugin has to implement the IPackageInstallationPlugin interface. It is recommended however, to extend the abstract implementation AbstractPackageInstallationPlugin of this interface instead of directly implementing the interface. The abstract implementation will always provide sane methods in case of any API changes.</p>"},{"location":"php/api/package_installation_plugins/#class-members","title":"Class Members","text":"<p>Package Installation Plugins have a few notable class members easing your work:</p>"},{"location":"php/api/package_installation_plugins/#installation","title":"<code>$installation</code>","text":"<p>This member contains an instance of PackageInstallationDispatcher which provides you with all meta data related to the current package being processed. The most common usage is the retrieval of the package ID via <code>$this->installation->getPackageID()</code>.</p>"},{"location":"php/api/package_installation_plugins/#application","title":"<code>$application</code>","text":"<p>Represents the abbreviation of the target application, e.g. <code>wbb</code> (default value: <code>wcf</code>), used for the name of database table in which the installed data is stored.</p>"},{"location":"php/api/package_installation_plugins/#abstractxmlpackageinstallationplugin","title":"<code>AbstractXMLPackageInstallationPlugin</code>","text":"<p>AbstractPackageInstallationPlugin is the default implementation for all package installation plugins based upon a single XML document. It handles the evaluation of the document and provide you an object-orientated approach to handle its data.</p>"},{"location":"php/api/package_installation_plugins/#class-members_1","title":"Class Members","text":""},{"location":"php/api/package_installation_plugins/#classname","title":"<code>$className</code>","text":"<p>Value must be the qualified name of a class deriving from DatabaseObjectEditor which is used to create and update objects.</p>"},{"location":"php/api/package_installation_plugins/#tagname","title":"<code>$tagName</code>","text":"<p>Specifies the tag name within a <code><import></code> or <code><delete></code> section of the XML document used for each installed object.</p>"},{"location":"php/api/package_installation_plugins/#prepareimportarray-data","title":"<code>prepareImport(array $data)</code>","text":"<p>The passed array <code>$data</code> contains the parsed value from each evaluated tag in the <code><import></code> section:</p> <ul> <li><code>$data['elements']</code> contains a list of tag names and their value.</li> <li><code>$data['attributes']</code> contains a list of attributes present on the tag identified by $tagName.</li> </ul> <p>This method should return an one-dimensional array, where each key maps to the corresponding database column name (key names are case-sensitive). It will be passed to either <code>DatabaseObjectEditor::create()</code> or <code>DatabaseObjectEditor::update()</code>.</p> <p>Example:</p> <pre><code><?php\nreturn [\n 'environment' => $data['elements']['environment'],\n 'eventName' => $data['elements']['eventname'],\n 'name' => $data['attributes']['name']\n];\n</code></pre>"},{"location":"php/api/package_installation_plugins/#validateimportarray-data","title":"<code>validateImport(array $data)</code>","text":"<p>The passed array <code>$data</code> equals the data returned by prepareImport(). This method has no return value, instead you should throw an exception if the passed data is invalid.</p>"},{"location":"php/api/package_installation_plugins/#findexistingitemarray-data","title":"<code>findExistingItem(array $data)</code>","text":"<p>The passed array <code>$data</code> equals the data returned by prepareImport(). This method is expected to return an array with two keys:</p> <ul> <li><code>sql</code> contains the SQL query with placeholders.</li> <li><code>parameters</code> contains an array with values used for the SQL query.</li> </ul>"},{"location":"php/api/package_installation_plugins/#example","title":"Example","text":"<pre><code><?php\n$sql = \"SELECT *\n FROM wcf\".WCF_N.\"_\".$this->tableName.\"\n WHERE packageID = ?\n AND name = ?\n AND templateName = ?\n AND eventName = ?\n AND environment = ?\";\n$parameters = [\n $this->installation->getPackageID(),\n $data['name'],\n $data['templateName'],\n $data['eventName'],\n $data['environment']\n];\n\nreturn [\n 'sql' => $sql,\n 'parameters' => $parameters\n];\n</code></pre>"},{"location":"php/api/package_installation_plugins/#handledeletearray-items","title":"<code>handleDelete(array $items)</code>","text":"<p>The passed array <code>$items</code> contains the original node data, similar to prepareImport(). You should make use of this data to remove the matching element from database.</p> <p>Example: <pre><code><?php\n$sql = \"DELETE FROM wcf1_{$this->tableName}\n WHERE packageID = ?\n AND environment = ?\n AND eventName = ?\n AND name = ?\n AND templateName = ?\";\n$statement = WCF::getDB()->prepare($sql);\nforeach ($items as $item) {\n $statement->execute([\n $this->installation->getPackageID(),\n $item['elements']['environment'],\n $item['elements']['eventname'],\n $item['attributes']['name'],\n $item['elements']['templatename']\n ]);\n}\n</code></pre></p>"},{"location":"php/api/package_installation_plugins/#postimport","title":"<code>postImport()</code>","text":"<p>Allows you to (optionally) run additionally actions after all elements were processed.</p>"},{"location":"php/api/package_installation_plugins/#abstractoptionpackageinstallationplugin","title":"<code>AbstractOptionPackageInstallationPlugin</code>","text":"<p>AbstractOptionPackageInstallationPlugin is an abstract implementation for options, used for:</p> <ul> <li>ACL Options</li> <li>Options</li> <li>User Options</li> <li>User Group Options</li> </ul>"},{"location":"php/api/package_installation_plugins/#differences-to-abstractxmlpackageinstallationplugin","title":"Differences to <code>AbstractXMLPackageInstallationPlugin</code>","text":""},{"location":"php/api/package_installation_plugins/#reservedtags","title":"<code>$reservedTags</code>","text":"<p><code>$reservedTags</code> is a list of reserved tag names so that any tag encountered but not listed here will be added to the database column <code>additionalData</code>. This allows options to store arbitrary data which can be accessed but were not initially part of the PIP specifications.</p>"},{"location":"php/api/rpc_api/","title":"RPC API","text":"<p>The RPC API provides a consistent and predictable JSON API for the interaction with the server. Authentication is entirely handled through the existing cookie-backed session system.</p> <p>The current implementation covers a few reference endpoints that replaced existing PSR-based actions. It is designed to be a replacement for the existing <code>AbstractDatabaseObjectAction</code> actions in the mid to long term. You are more than welcome to share any feedback, including but not limited to suggestions for improvements, on GitHub.</p> <p>The implementation of the RPC API is built in a way that it could support a token based authentication in the future but this is entirely out of scope for the current iteration.</p>"},{"location":"php/api/rpc_api/#predictable-api","title":"Predictable API","text":""},{"location":"php/api/rpc_api/#idempotency-whenever-reasonably-possible","title":"Idempotency Whenever Reasonably Possible","text":"<p>Some endpoints will perform a specific action, such as following a user or reacting to a message. These endpoints SHOULD be idempotent whenever possible, treating the request to be the \u201cshould\u201d state.</p> <p>For example, following a user for the first time should produce the same response as attempting to follow them again while still following. Reacting to a message that has already been reacted to using a difference reaction should implicitly revoke the previous reaction. If the user has already reacted using the same reaction then no change should be made. However, in both cases the response should be indistinguishable from reacting to a message for the first time.</p>"},{"location":"php/api/rpc_api/#http-verbs","title":"HTTP Verbs","text":"<p>We will only support three basic verbs: <code>GET</code>, <code>POST</code> and <code>DELETE</code>.</p> <p>Some implementations also make use of <code>PATCH</code> and <code>PUT</code>, but this would make it much more complex and adds little benefit plus its quite verbose since the verb implies the semantics of the endpoint. The same can be achieved by using distinct endpoints and using <code>POST</code> instead. Plus historically the support for <code>PATCH</code> and <code>PUT</code> was rather poor.</p>"},{"location":"php/api/rpc_api/#response-format","title":"Response Format","text":"<p>The PSR messaging interface allows for a host of useful response types, such as <code>204 No Content</code>, returning a plain \u201cHTML\u201d response or any format that is suitable. While this is more efficient, it also makes the API much more complicated and less predictable, requiring different response handling based on the endpoint being targeted.</p>"},{"location":"php/api/rpc_api/#http-status-codes","title":"HTTP Status Codes","text":"Code Name Meaning 200 OK The request was successful. 400 Bad Request The provided parameters are insufficient. 403 Permission Denied The callee is not authorized to execute this request. 404 Not Found The requested endpoint does not exist. 405 Method Not Allowed Using any HTTP verb other than <code>GET</code>, <code>POST</code> or <code>DELETE</code>. 500 Internal Server Error The server failed to process the request. 503 Service Unavailable The API is currently unavailable."},{"location":"php/api/rpc_api/#error-format","title":"Error Format","text":"<p>Whenever a request is rejected with the error code 400, the response will match the following data structure:</p> <pre><code>type ErrorResponse = {\n type: \"api_error\" | \"invalid_request_error\";\n code: string;\n message: string;\n param: string;\n};\n</code></pre> <p>A typical response could look like this:</p> <pre><code>{\n \"type\": \"invalid_request_error\",\n \"code\": \"value_too_short\",\n \"message\": \"\",\n \"param\": \"username\"\n}\n</code></pre>"},{"location":"php/api/rpc_api/#type","title":"<code>type</code>","text":"<p>The error type is used to tell apart issues caused by the request being made by the client or by unexpected errors taking place on the server side processing.</p>"},{"location":"php/api/rpc_api/#code","title":"<code>code</code>","text":"<p>The error code is all lowercase and using snake case to describe the type of error, for example, <code>missing_api_key</code>.</p>"},{"location":"php/api/rpc_api/#message","title":"<code>message</code>","text":"<p>The message can be empty but when present contains a non-localized string explaining the cause of the error with the intention of assisting a developer to resolve the issue.</p> <p>You MUST NOT present this message to the end user.</p>"},{"location":"php/api/rpc_api/#param","title":"<code>param</code>","text":"<p>Validation errors may refer to a specific parameter that has caused the request to be rejected. A common use case is to point to a specific input field, allowing for contextual error message presented to the user.</p>"},{"location":"php/api/rpc_api/#examples","title":"Examples","text":"<p>The endpoints below may or may not exist at any point and are only used for illustration purposes.</p> Verb Endpoint Explanation <code>GET</code> <code>/core/users</code> Retrieve a list of users, may include query parameters to control the response. <code>GET</code> <code>/core/users/{id:\\d+}</code> Retrieve a user, may include query parameters to control the response. <code>GET</code> <code>/core/users/{id:\\d+}/following</code> Retrieve a list of users that the target user is following. - - - <code>POST</code> <code>/core/users</code> Creates a new user, parameters are always presented in the body. <code>POST</code> <code>/core/users/{id:\\d+}</code> (Partially) updates a user. <code>POST</code> <code>/core/moderationqueues/{id:\\d+}/assign</code> Assigns a user. - - - <code>DELETE</code> <code>/forum/threads/{id:\\d+}</code> Deletes a thread."},{"location":"php/api/rpc_api/#implementation-of-an-endpoint","title":"Implementation of an Endpoint","text":""},{"location":"php/api/rpc_api/#namespaces-for-endpoints","title":"Namespaces for Endpoints","text":"<p>Endpoints are defined using a strict rule set:</p> <ul> <li>The first path segment is a namespace that holds other objects.</li> <li>The namespaces <code>core</code>, <code>forum</code>, <code>blog</code>, <code>filebase</code> and <code>gallery</code> are reserved and MUST NOT be used by third parties.</li> <li>Segments MUST be lowercase ASCII and use the plural form.</li> <li>Parameters MAY appear starting with the third path segment and are defined with a leading colon.</li> <li>The name of a parameter MUST be unique within one endpoint.</li> </ul>"},{"location":"php/api/rpc_api/#convention-for-file-name-and-location","title":"Convention for File Name and Location","text":"<p>It is strongly recommended to place the files in <code>lib/system/endpoint/<namespace>/<objects>/<nameOfTheAction>.class.php</code>. The file name should reflect the action itself, following the pattern <code><Verb><Object></code>, for example, <code>DeleteFile</code> or <code>CreatePost</code>.</p>"},{"location":"php/api/rpc_api/#registering-the-route-of-an-endpoint","title":"Registering the Route of an Endpoint","text":"<p>Every endpoint needs to implement <code>wcf\\system\\endpoint\\IController</code> which defines the <code>__invoke()</code> method that will receive the <code>ServerRequestInterface</code> and an array containing any defined route parameters.</p> <p>Any endpoint can only ever serve a single verb, registered through the use of the <code>wcf\\system\\endpoint\\GetRequest</code>, <code>wcf\\system\\endpoint\\PostRequest</code> or <code>wcf\\system\\endpoint\\DeleteRequest</code> class attribute. The attribute expects a single parameter to define the endpoint\u2019s route.</p>"},{"location":"php/api/rpc_api/#placeholders","title":"Placeholders","text":"<p>The route implementation uses FastRoute which supports named placeholders through the <code>{name}</code> syntax. Optionally, a validation pattern can be specified to further narrow down the valid value of the placeholder: <code>{id:\\d+}</code></p>"},{"location":"php/api/rpc_api/#available-helper-methods","title":"Available Helper Methods","text":"<p>The <code>wcf\\http\\Helper</code> class offers a few helpful methods that simplify the validation and processing of request parameters.</p>"},{"location":"php/api/rpc_api/#mapapiparametersserverrequestinterface-request-string-classname","title":"<code>mapApiParameters(ServerRequestInterface $request, string $className)</code>","text":"<p>Takes the <code>$request</code> from the <code>__invoke()</code> call and maps the parameters against the provided class name. By convention it is recommended to use an internal class that is defined at the end of the class file and uses a <code>Parameters</code> suffix.</p> <p>For <code>GET</code> and <code>DELETE</code> requests the query string is used as the source. For <code>POST</code> requests the request body is mapped to the parameters.</p>"},{"location":"php/api/rpc_api/#fetchobjectfromrequestparameterintstring-objectid-string-classname","title":"<code>fetchObjectFromRequestParameter(int|string $objectID, string $className)</code>","text":"<p>Expects <code>$className</code> to be derived from <code>wcf\\data\\DatabaseObject</code> and attempts to fetch it using the <code>$objectID</code> parameter. Afterwards the object is tested to have a non-falsy object id, otherwise a <code>UserInputException</code> is raised.</p> <p>Returns the fetched object on success.</p>"},{"location":"php/api/rpc_api/#interacting-with-the-php-rpc-api-in-typescript","title":"Interacting with the PHP RPC API in TypeScript","text":"<p>You can find an introduction to the TypeScript API for the RPC API in the documentation.</p>"},{"location":"php/api/rss_feeds/","title":"RSS Feeds","text":"<p>The RSS feed API makes it possible to output content in the RSS format in accordance with the RSS 2.0 specifications. The ArticleRssFeedPage is available as a reference implementation.</p>"},{"location":"php/api/rss_feeds/#rssfeed","title":"<code>RssFeed</code>","text":"<p>RssFeed represents an RSS feed.</p> <p>After content has been added to the RSS feed, the feed can be output as XML using the <code>render</code> method.</p> <p>Example:</p> <pre><code>$feed = new RssFeed();\n...\n$output = $feed->render();\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedcategory","title":"<code>RssFeedCategory</code>","text":"<p>RssFeedCategory represents a category of a feed item. A feed item can have multiple categories.</p> <p>An instance of <code>RssFeedCategory</code> is created implicitly when a category is assigned to a feed item.</p> <p>Example:</p> <pre><code>$item = new RssFeedItem();\n$item->category('title', 'domain');\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedchannel","title":"<code>RssFeedChannel</code>","text":"<p>RssFeedChannel represents a channel within an RSS feed.</p> <p>Example:</p> <pre><code>$feed = new RssFeed();\n$channel = new RssFeedChannel();\n$channel\n ->title('title')\n ->description('description')\n ->link('https://www.example.net');\n$feed->channel($channel);\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedenclosure","title":"<code>RssFeedEnclosure</code>","text":"<p>RssFeedEnclosure represents an enclosure of a feed item. A feed item can only have one enclosure.</p> <p>An instance of <code>RssFeedEnclosure</code> is created implicitly when an enclosure is assigned to a feed item.</p> <p>Example:</p> <pre><code>$item = new RssFeedItem();\n$item->enclosure('url', /*size*/1024, 'mime/type');\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeeditem","title":"<code>RssFeedItem</code>","text":"<p>RssFeedItem represents an item in an RSS feed.</p> <p>Example:</p> <pre><code>$feed = new RssFeed();\n$channel = new RssFeedChannel();\n$feed->channel($channel);\n\n$item = new RssFeedItem();\n$item\n ->title('title')\n ->link('url');\n$channel->item($item);\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedsource","title":"<code>RssFeedSource</code>","text":"<p>RssFeedSource represents the source of a feed item. A feed item can only have one source.</p> <p>An instance of <code>RssFeedSource</code> is created implicitly when an source is assigned to a feed item.</p> <p>Example:</p> <pre><code>$item = new RssFeedItem();\n$item->source('title', 'url');\n</code></pre>"},{"location":"php/api/sitemaps/","title":"Sitemaps","text":"<p>WoltLab Suite is capable of automatically creating a sitemap. This sitemap contains all static pages registered via the page package installation plugin and which may be indexed by search engines (checking the <code>allowSpidersToIndex</code> parameter and page permissions) and do not expect an object ID. Other pages have to be added to the sitemap as a separate object.</p> <p>The only prerequisite for sitemap objects is that the objects are instances of <code>wcf\\data\\DatabaseObject</code> and that there is a <code>wcf\\data\\DatabaseObjectList</code> implementation.</p> <p>First, we implement the PHP class, which provides us all database objects and optionally checks the permissions for a single object. The class must implement the interface <code>wcf\\system\\sitemap\\object\\ISitemapObjectObjectType</code>. However, in order to have some methods already implemented and ensure backwards compatibility, you should use the abstract class <code>wcf\\system\\sitemap\\object\\AbstractSitemapObjectObjectType</code>. The abstract class takes care of generating the <code>DatabaseObjectList</code> class name and list directly and implements optional methods with the default values. The only method that you have to implement yourself is the <code>getObjectClass()</code> method which returns the fully qualified name of the <code>DatabaseObject</code> class. The <code>DatabaseObject</code> class must implement the interface <code>wcf\\data\\ILinkableObject</code>.</p> <p>Other optional methods are:</p> <ul> <li>The <code>getLastModifiedColumn()</code> method returns the name of the column in the database where the last modification date is stored. If there is none, this method must return <code>null</code>.</li> <li>The <code>canView()</code> method checks whether the passed <code>DatabaseObject</code> is visible to the current user with the current user always being a guest.</li> <li>The <code>getObjectListClass()</code> method returns a non-standard <code>DatabaseObjectList</code> class name.</li> <li>The <code>getObjectList()</code> method returns the <code>DatabaseObjectList</code> instance. You can, for example, specify additional query conditions in the method.</li> </ul> <p>As an example, the implementation for users looks like this:</p> files/lib/system/sitemap/object/UserSitemapObject.class.php <pre><code><?php\nnamespace wcf\\system\\sitemap\\object;\nuse wcf\\data\\user\\User;\nuse wcf\\data\\DatabaseObject;\nuse wcf\\system\\WCF;\n\n/**\n * User sitemap implementation.\n *\n * @author Joshua Ruesweg\n * @copyright 2001-2017 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Sitemap\\Object\n * @since 3.1\n */\nclass UserSitemapObject extends AbstractSitemapObjectObjectType {\n /**\n * @inheritDoc\n */\n public function getObjectClass() {\n return User::class;\n }\n\n /**\n * @inheritDoc\n */\n public function getLastModifiedColumn() {\n return 'lastActivityTime';\n }\n\n /**\n * @inheritDoc\n */\n public function canView(DatabaseObject $object) {\n return WCF::getSession()->getPermission('user.profile.canViewUserProfile');\n }\n}\n</code></pre> <p>Next, the sitemap object must be registered as an object type:</p> <pre><code><type>\n <name>com.example.plugin.sitemap.object.user</name>\n <definitionname>com.woltlab.wcf.sitemap.object</definitionname>\n <classname>wcf\\system\\sitemap\\object\\UserSitemapObject</classname>\n <priority>0.5</priority>\n <changeFreq>monthly</changeFreq>\n <rebuildTime>259200</rebuildTime>\n</type>\n</code></pre> <p>In addition to the fully qualified class name, the object type definition <code>com.woltlab.wcf.sitemap.object</code> and the object type name, the parameters <code>priority</code>, <code>changeFreq</code> and <code>rebuildTime</code> must also be specified. <code>priority</code> (https://www.sitemaps.org/protocol.html#prioritydef) and <code>changeFreq</code> (https://www.sitemaps.org/protocol.html#changefreqdef) are specifications in the sitemaps protocol and can be changed by the user in the ACP. The <code>priority</code> should be <code>0.5</code> by default, unless there is an important reason to change it. The parameter <code>rebuildTime</code> specifies the number of seconds after which the sitemap should be regenerated.</p> <p>Finally, you have to create the language variable for the sitemap object. The language variable follows the pattern <code>wcf.acp.sitemap.objectType.{objectTypeName}</code> and is in the category <code>wcf.acp.sitemap</code>.</p>"},{"location":"php/api/user_activity_events/","title":"User Activity Events","text":"<p>User activity events provide content from different sources for the list of recent activities. Entries in the last activities consist of a title, optionally a description, the author and the date.</p>"},{"location":"php/api/user_activity_events/#registration-of-user-activity-events","title":"Registration of User Activity Events","text":"<p>To integrate user activity events into your package, you have to register object types for the defintion <code>com.woltlab.wcf.user.recentActivityEvent</code> and specify a class that implements the <code>wcf\\system\\user\\activity\\event\\IUserActivityEvent</code> interface:</p> <pre><code><type>\n <name>foo.bar.recentActivityEvent</name>\n <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>\n <classname>wcf\\system\\user\\activity\\event\\FooUserActivityEvent</classname>\n</type>\n</code></pre> <p>Specify multiple object types if you want to provide multiple types of user activity events. </p> <p>Example of the implementation of the <code>wcf\\system\\user\\activity\\event\\IUserActivityEvent</code> interface:</p> <pre><code><?php\n\nnamespace wcf\\system\\user\\activity\\event;\n\nuse wcf\\data\\user\\activity\\event\\ViewableUserActivityEvent;\nuse wcf\\system\\user\\activity\\event\\IUserActivityEvent;\nuse wcf\\system\\WCF;\nuse wcf\\util\\StringUtil;\n\nfinal class FooUserActivityEvent implements IUserActivityEvent\n{\n public function prepare(array $events)\n {\n foreach ($events as $event) {\n $this->handleEvent($event);\n }\n }\n\n private function handleEvent(ViewableUserActivityEvent $event): void\n {\n $foo = new FooObject($event->objectID);\n if ($foo === null) {\n $event->setIsOrphaned();\n return;\n }\n\n $event->setIsAccessible();\n $event->setTitle(WCF::getLanguage()->getDynamicVariable('foo.bar.recentActivity', [\n 'foo' => $foo,\n 'author' => $event->getUserProfile(),\n ]));\n $event->setDescription(\n StringUtil::encodeHTML(\n StringUtil::truncate($foo->getPlainTextDescription(), 500)\n ),\n true\n );\n $event->setLink($foo->getLink());\n }\n}\n</code></pre>"},{"location":"php/api/user_activity_events/#creating-user-activity-events","title":"Creating User Activity Events","text":"<p>If a relevant object is created, you have to use <code>UserActivityEventHandler::fireEvent()</code> which expects the name of the object type, the id of the object and optionally the language id, user id and the date.</p> <pre><code>UserActivityEventHandler::getInstance()->fireEvent(\n 'foo.bar.recentActivityEvent',\n 1, // object id\n 2, // language id\n 3, // user id\n \\TIME_NOW // date\n);\n</code></pre>"},{"location":"php/api/user_activity_events/#removing-user-activity-events","title":"Removing User Activity Events","text":"<p>To remove user activity events once objects are deleted, you have to use <code>UserActivityEventHandler::removeEvents()</code> which also expects the name of the object type and additionally an array with object ids:</p> <pre><code>UserActivityEventHandler::getInstance()->removeEvents(\n 'foo.bar.recentActivityEvent',\n [1, 2]\n);\n</code></pre>"},{"location":"php/api/user_activity_points/","title":"User Activity Points","text":"<p>Users get activity points whenever they create content to award them for their contribution. Activity points are used to determine the rank of a user and can also be used for user conditions, for example for automatic user group assignments.</p> <p>To integrate activity points into your package, you have to register an object type for the defintion <code>com.woltlab.wcf.user.activityPointEvent</code> and specify a default number of points:</p> <pre><code><type>\n <name>com.example.foo.activityPointEvent.bar</name>\n <definitionname>com.woltlab.wcf.user.activityPointEvent</definitionname>\n <points>10</points>\n</type>\n</code></pre> <p>The number of points awarded for this type of activity point event can be changed by the administrator in the admin control panel. For this form and the user activity point list shown in the frontend, you have to provide the language item</p> <pre><code>wcf.user.activityPoint.objectType.com.example.foo.activityPointEvent.bar\n</code></pre> <p>that contains the name of the content for which the activity points are awarded.</p> <p>If a relevant object is created, you have to use <code>UserActivityPointHandler::fireEvent()</code> which expects the name of the activity point event object type, the id of the object for which the points are awarded (though the object id is not used at the moment) and the user who gets the points:</p> <pre><code>UserActivityPointHandler::getInstance()->fireEvent(\n 'com.example.foo.activityPointEvent.bar',\n $bar->barID,\n $bar->userID\n);\n</code></pre> <p>To remove activity points once objects are deleted, you have to use <code>UserActivityPointHandler::removeEvents()</code> which also expects the name of the activity point event object type and additionally an array mapping the id of the user whose activity points will be reduced to the number of objects that are removed for the relevant user:</p> <pre><code>UserActivityPointHandler::getInstance()->removeEvents(\n 'com.example.foo.activityPointEvent.bar',\n [\n 1 => 1, // remove points for one object for user with id `1`\n 4 => 2 // remove points for two objects for user with id `4`\n ]\n);\n</code></pre>"},{"location":"php/api/user_notifications/","title":"User Notifications","text":"<p>WoltLab Suite includes a powerful user notification system that supports notifications directly shown on the website and emails sent immediately or on a daily basis.</p>"},{"location":"php/api/user_notifications/#objecttypexml","title":"<code>objectType.xml</code>","text":"<p>For any type of object related to events, you have to define an object type for the object type definition <code>com.woltlab.wcf.notification.objectType</code>:</p> objectType.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/objectType.xsd\">\n <import>\n <type>\n <name>com.woltlab.example.foo</name>\n <definitionname>com.woltlab.wcf.notification.objectType</definitionname>\n <classname>example\\system\\user\\notification\\object\\type\\FooUserNotificationObjectType</classname>\n <category>com.woltlab.example</category>\n </type>\n </import>\n</data>\n</code></pre> <p>The referenced class <code>FooUserNotificationObjectType</code> has to implement the IUserNotificationObjectType interface, which should be done by extending AbstractUserNotificationObjectType.</p> files/lib/system/user/notification/object/type/FooUserNotificationObjectType.class.php <pre><code><?php\nnamespace example\\system\\user\\notification\\object\\type;\nuse example\\data\\foo\\Foo;\nuse example\\data\\foo\\FooList;\nuse example\\system\\user\\notification\\object\\FooUserNotificationObject;\nuse wcf\\system\\user\\notification\\object\\type\\AbstractUserNotificationObjectType;\n\n/**\n * Represents a foo as a notification object type.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2017 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Example\\System\\User\\Notification\\Object\\Type\n */\nclass FooUserNotificationObjectType extends AbstractUserNotificationObjectType {\n /**\n * @inheritDoc\n */\n protected static $decoratorClassName = FooUserNotificationObject::class;\n\n /**\n * @inheritDoc\n */\n protected static $objectClassName = Foo::class;\n\n /**\n * @inheritDoc\n */\n protected static $objectListClassName = FooList::class;\n}\n</code></pre> <p>You have to set the class names of the database object (<code>$objectClassName</code>) and the related list (<code>$objectListClassName</code>). Additionally, you have to create a class that implements the IUserNotificationObject whose name you have to set as the value of the <code>$decoratorClassName</code> property.</p> files/lib/system/user/notification/object/FooUserNotificationObject.class.php <pre><code><?php\n\nnamespace example\\system\\user\\notification\\object;\n\nuse example\\data\\foo\\Foo;\nuse wcf\\data\\DatabaseObjectDecorator;\nuse wcf\\system\\user\\notification\\object\\IUserNotificationObject;\n\n/**\n * Represents a foo as a notification object.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2017 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Example\\System\\User\\Notification\\Object\n *\n * @method Foo getDecoratedObject()\n * @mixin Foo\n */\nclass FooUserNotificationObject extends DatabaseObjectDecorator implements IUserNotificationObject\n{\n /**\n * @inheritDoc\n */\n protected static $baseClass = Foo::class;\n\n /**\n * @inheritDoc\n */\n public function getTitle(): string\n {\n return $this->getDecoratedObject()->getTitle();\n }\n\n /**\n * @inheritDoc\n */\n public function getURL()\n {\n return $this->getDecoratedObject()->getLink();\n }\n\n /**\n * @inheritDoc\n */\n public function getAuthorID()\n {\n return $this->getDecoratedObject()->userID;\n }\n}\n</code></pre> <ul> <li>The <code>getTitle()</code> method returns the title of the object. In this case, we assume that the <code>Foo</code> class has implemented the ITitledObject interface so that the decorated <code>Foo</code> can handle this method call itself.</li> <li>The <code>getURL()</code> method returns the link to the object. As for the <code>getTitle()</code>, we assume that the <code>Foo</code> class has implemented the ILinkableObject interface so that the decorated <code>Foo</code> can also handle this method call itself.</li> <li>The <code>getAuthorID()</code> method returns the id of the user who created the decorated <code>Foo</code> object. We assume that <code>Foo</code> objects have a <code>userID</code> property that contains this id.</li> </ul>"},{"location":"php/api/user_notifications/#usernotificationeventxml","title":"<code>userNotificationEvent.xml</code>","text":"<p>Each event that you fire in your package needs to be registered using the user notification event package installation plugin. An example file might look like this:</p> userNotificationEvent.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userNotificationEvent.xsd\">\n <import>\n <event>\n <name>bar</name>\n <objecttype>com.woltlab.example.foo</objecttype>\n <classname>example\\system\\user\\notification\\event\\FooUserNotificationEvent</classname>\n <preset>1</preset>\n </event>\n </import>\n</data>\n</code></pre> <p>Here, you reference the user notification object type created via <code>objectType.xml</code>. The referenced class in the <code><classname></code> element has to implement the IUserNotificationEvent interface by extending the AbstractUserNotificationEvent class or the AbstractSharedUserNotificationEvent class if you want to pre-load additional data before processing notifications. In <code>AbstractSharedUserNotificationEvent::prepare()</code>, you can, for example, tell runtime caches to prepare to load certain objects which then are loaded all at once when the objects are needed.</p> files/lib/system/user/notification/event/FooUserNotificationEvent.class.php <pre><code><?php\n\nnamespace example\\system\\user\\notification\\event;\n\nuse example\\system\\cache\\runtime\\BazRuntimeCache;\nuse example\\system\\user\\notification\\object\\FooUserNotificationObject;\nuse wcf\\system\\email\\Email;\nuse wcf\\system\\request\\LinkHandler;\nuse wcf\\system\\user\\notification\\event\\AbstractSharedUserNotificationEvent;\n\n/**\n * Notification event for foos.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2017 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Example\\System\\User\\Notification\\Event\n *\n * @method FooUserNotificationObject getUserNotificationObject()\n */\nclass FooUserNotificationEvent extends AbstractSharedUserNotificationEvent\n{\n /**\n * @inheritDoc\n */\n protected $stackable = true;\n\n /** @noinspection PhpMissingParentCallCommonInspection */\n /**\n * @inheritDoc\n */\n public function checkAccess()\n {\n $this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));\n\n if (!$this->getUserNotificationObject()->isAccessible()) {\n // do some cleanup, if necessary\n\n return false;\n }\n\n return true;\n }\n\n /** @noinspection PhpMissingParentCallCommonInspection */\n /**\n * @inheritDoc\n */\n public function getEmailMessage($notificationType = 'instant')\n {\n $this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));\n\n $messageID = '<com.woltlab.example.baz/' . $this->getUserNotificationObject()->bazID . '@' . Email::getHost() . '>';\n\n return [\n 'application' => 'example',\n 'in-reply-to' => [$messageID],\n 'message-id' => 'com.woltlab.example.foo/' . $this->getUserNotificationObject()->fooID,\n 'references' => [$messageID],\n 'template' => 'email_notification_foo'\n ];\n }\n\n /**\n * @inheritDoc\n * @since 5.0\n */\n public function getEmailTitle()\n {\n $this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));\n\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.mail.title', [\n 'userNotificationObject' => $this->getUserNotificationObject()\n ]);\n }\n\n /** @noinspection PhpMissingParentCallCommonInspection */\n /**\n * @inheritDoc\n */\n public function getEventHash()\n {\n return sha1($this->eventID . '-' . $this->getUserNotificationObject()->bazID);\n }\n\n /**\n * @inheritDoc\n */\n public function getLink(): string\n {\n return LinkHandler::getInstance()->getLink('Foo', [\n 'application' => 'example',\n 'object' => $this->getUserNotificationObject()->getDecoratedObject()\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function getMessage()\n {\n $authors = $this->getAuthors();\n $count = count($authors);\n\n if ($count > 1) {\n if (isset($authors[0])) {\n unset($authors[0]);\n }\n $count = count($authors);\n\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.message.stacked', [\n 'author' => $this->author,\n 'authors' => array_values($authors),\n 'count' => $count,\n 'guestTimesTriggered' => $this->notification->guestTimesTriggered,\n 'message' => $this->getUserNotificationObject(),\n 'others' => $count - 1\n ]);\n }\n\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.message', [\n 'author' => $this->author,\n 'userNotificationObject' => $this->getUserNotificationObject()\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function getTitle(): string\n {\n $count = count($this->getAuthors());\n if ($count > 1) {\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.title.stacked', [\n 'count' => $count,\n 'timesTriggered' => $this->notification->timesTriggered\n ]);\n }\n\n return $this->getLanguage()->get('example.foo.notification.title');\n }\n\n /**\n * @inheritDoc\n */\n protected function prepare()\n {\n BazRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->bazID);\n }\n}\n</code></pre> <ul> <li>The <code>$stackable</code> property is <code>false</code> by default and has to be explicitly set to <code>true</code> if stacking of notifications should be enabled. Stacking of notification does not create new notifications for the same event for a certain object if the related action as been triggered by different users. For example, if something is liked by one user and then liked again by another user before the recipient of the notification has confirmed it, the existing notification will be amended to include both users who liked the content. Stacking can thus be used to avoid cluttering the notification list of users.</li> <li>The <code>checkAccess()</code> method makes sure that the active user still has access to the object related to the notification. If that is not the case, the user notification system will automatically deleted the user notification based on the return value of the method. If you have any cached values related to notifications, you should also reset these values here.</li> <li>The <code>getEmailMessage()</code> method return data to create the instant email or the daily summary email. For instant emails (<code>$notificationType = 'instant'</code>), you have to return an array like the one shown in the code above with the following components:</li> <li><code>application</code>: abbreviation of application</li> <li><code>in-reply-to</code> (optional): message id of the notification for the parent item and used to improve the ordering in threaded email clients</li> <li><code>message-id</code> (optional): message id of the notification mail and has to be used in <code>in-reply-to</code> and <code>references</code> for follow up mails</li> <li><code>references</code> (optional): all of the message ids of parent items (i.e. recursive in-reply-to)</li> <li><code>template</code>: name of the template used to render the email body, should start with <code>email_</code></li> <li><code>variables</code> (optional): template variables passed to the email template where they can be accessed via <code>$notificationContent[variables]</code></li> </ul> <p>For daily emails (<code>$notificationType = 'daily'</code>), only <code>application</code>, <code>template</code>, and <code>variables</code> are supported. - The <code>getEmailTitle()</code> returns the title of the instant email sent to the user. By default, <code>getEmailTitle()</code> simply calls <code>getTitle()</code>. - The <code>getEventHash()</code> method returns a hash by which user notifications are grouped. Here, we want to group them not by the actual <code>Foo</code> object but by its parent <code>Baz</code> object and thus overwrite the default implementation provided by <code>AbstractUserNotificationEvent</code>. - The <code>getLink()</code> returns the link to the <code>Foo</code> object the notification belongs to. - The <code>getMessage()</code> method and the <code>getTitle()</code> return the message and the title of the user notification respectively. By checking the value of <code>count($this->getAuthors())</code>, we check if the notification is stacked, thus if the event has been triggered for multiple users so that different languages items are used. If your notification event does not support stacking, this distinction is not necessary. - The <code>prepare()</code> method is called for each user notification before all user notifications are rendered. This allows to tell runtime caches to prepare to load objects later on (see Runtime Caches).</p>"},{"location":"php/api/user_notifications/#firing-events","title":"Firing Events","text":"<p>When the action related to a user notification is executed, you can use <code>UserNotificationHandler::fireEvent()</code> to create the notifications:</p> <pre><code>$recipientIDs = []; // fill with user ids of the recipients of the notification\nUserNotificationHandler::getInstance()->fireEvent(\n 'bar', // event name\n 'com.woltlab.example.foo', // event object type name\n new FooUserNotificationObject(new Foo($fooID)), // object related to the event\n $recipientIDs\n);\n</code></pre>"},{"location":"php/api/user_notifications/#marking-notifications-as-confirmed","title":"Marking Notifications as Confirmed","text":"<p>In some instances, you might want to manually mark user notifications as confirmed without the user manually confirming them, for example when they visit the page that is related to the user notification. In this case, you can use <code>UserNotificationHandler::markAsConfirmed()</code>:</p> <pre><code>$recipientIDs = []; // fill with user ids of the recipients of the notification\n$fooIDs = []; // fill with ids of related foo objects\nUserNotificationHandler::getInstance()->markAsConfirmed(\n 'bar', // event name\n 'com.woltlab.example.foo', // event object type name\n $recipientIDs,\n $fooIDs\n);\n</code></pre>"},{"location":"php/api/form_builder/dependencies/","title":"Form Node Dependencies","text":"<p>Form node dependencies allow to make parts of a form dynamically available or unavailable depending on the values of form fields. Dependencies are always added to the object whose visibility is determined by certain form fields. They are not added to the form field\u2019s whose values determine the visibility! An example is a text form field that should only be available if a certain option from a single selection form field is selected. Form builder\u2019s dependency system supports such scenarios and also automatically making form containers unavailable once all of its children are unavailable.</p> <p>If a form node has multiple dependencies and one of them is not met, the form node is unavailable. A form node not being available due to dependencies has to the following consequences:</p> <ul> <li>The form field value is not validated. It is, however, read from the request data as all request data needs to be read first so that the dependencies can determine whether they are met or not.</li> <li>No data is collected for the form field and returned by <code>IFormDocument::getData()</code>.</li> <li>In the actual form, the form field will be hidden via JavaScript.</li> </ul>"},{"location":"php/api/form_builder/dependencies/#iformfielddependency","title":"<code>IFormFieldDependency</code>","text":"<p>The basis of the dependencies is the <code>IFormFieldDependency</code> interface that has to be implemented by every dependency class. The interface requires the following methods:</p> <ul> <li><code>checkDependency()</code> checks if the dependency is met, thus if the dependant form field should be considered available.</li> <li><code>dependentNode(IFormNode $node)</code> and <code>getDependentNode()</code> can be used to set and get the node whose availability depends on the referenced form field. <code>TFormNode::addDependency()</code> automatically calls <code>dependentNode(IFormNode $node)</code> with itself as the dependent node, thus the dependent node is automatically set by the API.</li> <li><code>field(IFormField $field)</code> and <code>getField()</code> can be used to set and get the form field that influences the availability of the dependent node.</li> <li><code>fieldId($fieldId)</code> and <code>getFieldId()</code> can be used to set and get the id of the form field that influences the availability of the dependent node.</li> <li><code>getHtml()</code> returns JavaScript code required to ensure the dependency in the form output.</li> <li><code>getId()</code> returns the id of the dependency used to identify multiple dependencies of the same form node.</li> <li><code>static create($id)</code> is the factory method that has to be used to create new dependencies with the given id.</li> </ul> <p><code>AbstractFormFieldDependency</code> provides default implementations for all methods except for <code>checkDependency()</code>.</p> <p>Using <code>fieldId($fieldId)</code> instead of <code>field(IFormField $field)</code> makes sense when adding the dependency directly when setting up the form:</p> <pre><code>$container->appendChildren([\n FooField::create('a'),\n\n BarField::create('b')\n ->addDependency(\n BazDependency::create('a')\n ->fieldId('a')\n )\n]);\n</code></pre> <p>Here, without an additional assignment, the first field with id <code>a</code> cannot be accessed thus <code>fieldId($fieldId)</code> should be used as the id of the relevant field is known. When the form is built, all dependencies that only know the id of the relevant field and do not have a reference for the actual object are populated with the actual form field objects.</p>"},{"location":"php/api/form_builder/dependencies/#default-dependencies","title":"Default Dependencies","text":"<p>WoltLab Suite Core delivers the following default dependency classes by default:</p>"},{"location":"php/api/form_builder/dependencies/#nonemptyformfielddependency","title":"<code>NonEmptyFormFieldDependency</code>","text":"<p><code>NonEmptyFormFieldDependency</code> can be used to ensure that a node is only shown if the value of the referenced form field is not empty (being empty is determined using PHP\u2019s <code>empty()</code> language construct).</p>"},{"location":"php/api/form_builder/dependencies/#emptyformfielddependency","title":"<code>EmptyFormFieldDependency</code>","text":"<p>This is the inverse of <code>NonEmptyFormFieldDependency</code>, checking for <code>!empty()</code>.</p>"},{"location":"php/api/form_builder/dependencies/#valueformfielddependency","title":"<code>ValueFormFieldDependency</code>","text":"<p><code>ValueFormFieldDependency</code> can be used to ensure that a node is only shown if the value of the referenced form field is from a specified list of of values (see methods <code>values($values)</code> and <code>getValues()</code>). Additionally, via <code>negate($negate = true)</code> and <code>isNegated()</code>, the logic can also be inverted by requiring the value of the referenced form field not to be from a specified list of values.</p>"},{"location":"php/api/form_builder/dependencies/#valueintervalformfielddependency","title":"<code>ValueIntervalFormFieldDependency</code>","text":"<p><code>ValueIntervalFormFieldDependency</code> can be used to ensure that a node is only shown if the value of the referenced form field is in a specific interval whose boundaries are set via <code>minimum(?float $minimum = null)</code> and <code>maximum(?float $maximum = null)</code>.</p>"},{"location":"php/api/form_builder/dependencies/#isnotclickedformfielddependency","title":"<code>IsNotClickedFormFieldDependency</code>","text":"<p><code>IsNotClickedFormFieldDependency</code> is a special dependency for <code>ButtonFormField</code>s. Refer to the documentation of <code>ButtomFormField</code> for details.</p>"},{"location":"php/api/form_builder/dependencies/#javascript-implementation","title":"JavaScript Implementation","text":"<p>To ensure that dependent node are correctly shown and hidden when changing the value of referenced form fields, every PHP dependency class has a corresponding JavaScript module that checks the dependency in the browser. Every JavaScript dependency has to extend <code>WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract</code> and implement the <code>checkDependency()</code> function, the JavaScript version of <code>IFormFieldDependency::checkDependency()</code>.</p> <p>All of the JavaScript dependency objects automatically register themselves during initialization with the <code>WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager</code> which takes care of checking the dependencies at the correct points in time.</p> <p>Additionally, the dependency manager also ensures that form containers in which all children are hidden due to dependencies are also hidden and, once any child becomes available again, makes the container also available again. Every form container has to create a matching form container dependency object from a module based on <code>WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract</code>.</p>"},{"location":"php/api/form_builder/dependencies/#examples","title":"Examples","text":"<p>If <code>$booleanFormField</code> is an instance of <code>BooleanFormField</code> and the text form field <code>$textFormField</code> should only be available if \u201cYes\u201d has been selected, the following condition has to be set up:</p> <pre><code>$textFormField->addDependency(\n NonEmptyFormFieldDependency::create('booleanFormField')\n ->field($booleanFormField)\n);\n</code></pre> <p>If <code>$singleSelectionFormField</code> is an instance of <code>SingleSelectionFormField</code> that offers the options <code>1</code>, <code>2</code>, and <code>3</code> and <code>$textFormField</code> should only be available if <code>1</code> or <code>3</code> is selected, the following condition has to be set up:</p> <pre><code>$textFormField->addDependency(\n ValueFormFieldDependency::create('singleSelectionFormField')\n ->field($singleSelectionFormField)\n ->values([1, 3])\n);\n</code></pre> <p>If, in contrast, <code>$singleSelectionFormField</code> has many available options and <code>7</code> is the only option for which <code>$textFormField</code> should not be available, <code>negate()</code> should be used:</p> <pre><code>$textFormField->addDependency(\n ValueFormFieldDependency::create('singleSelectionFormField')\n ->field($singleSelectionFormField)\n ->values([7])\n ->negate()\n);\n</code></pre>"},{"location":"php/api/form_builder/form_fields/","title":"Form Builder Fields","text":""},{"location":"php/api/form_builder/form_fields/#abstract-form-fields","title":"Abstract Form Fields","text":"<p>The following form field classes cannot be instantiated directly because they are abstract, but they can/must be used when creating own form field classes. </p>"},{"location":"php/api/form_builder/form_fields/#abstractformfield","title":"<code>AbstractFormField</code>","text":"<p><code>AbstractFormField</code> is the abstract default implementation of the <code>IFormField</code> interface and it is expected that every implementation of <code>IFormField</code> implements the interface by extending this class.</p>"},{"location":"php/api/form_builder/form_fields/#abstractnumericformfield","title":"<code>AbstractNumericFormField</code>","text":"<p><code>AbstractNumericFormField</code> is the abstract implementation of a form field handling a single numeric value. The class implements <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, <code>IInputModeFormField</code>, <code>IMaximumFormField</code>, <code>IMinimumFormField</code>, <code>INullableFormField</code>, <code>IPlaceholderFormField</code> and <code>ISuffixedFormField</code>. If the property <code>$integerValues</code> is <code>true</code>, the form field works with integer values, otherwise it works with floating point numbers. The methods <code>step($step = null)</code> and <code>getStep()</code> can be used to set and get the step attribute of the <code>input</code> element. The default step for form fields with integer values is <code>1</code>. Otherwise, the default step is <code>any</code>.</p>"},{"location":"php/api/form_builder/form_fields/#abstractformfielddecorator","title":"<code>AbstractFormFieldDecorator</code>","text":"<p><code>AbstractFormFieldDecorator</code> is a default implementation of a decorator for form fields that forwards calls to all methods defined in <code>IFormField</code> to the respective method of the decorated object. The class implements <code>IFormfield</code>. If the implementation of a more specific interface is required then the remaining methods must be implemented in the concrete decorator derived from <code>AbstractFormFieldDecorator</code> and the type of the <code>$field</code> property must be narrowed appropriately.</p>"},{"location":"php/api/form_builder/form_fields/#general-form-fields","title":"General Form Fields","text":"<p>The following form fields are general reusable fields without any underlying context.</p>"},{"location":"php/api/form_builder/form_fields/#booleanformfield","title":"<code>BooleanFormField</code>","text":"<p><code>BooleanFormField</code> is used for boolean (<code>0</code> or <code>1</code>, <code>yes</code> or <code>no</code>) values. Objects of this class require a label. The return value of <code>getSaveValue()</code> is the integer representation of the boolean value, i.e. <code>0</code> or <code>1</code>. The class implements <code>IAttributeFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, and <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>BooleanFormField::create('example')\n ->label('foo.bar.example')\n ->value(true)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#checkboxformfield","title":"<code>CheckboxFormField</code>","text":"<p><code>CheckboxFormField</code> extends <code>BooleanFormField</code> and offers a simple HTML checkbox.</p> <p>Example:</p> <pre><code>CheckboxFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#classnameformfield","title":"<code>ClassNameFormField</code>","text":"<p><code>ClassNameFormField</code> is a text form field that supports additional settings, specific to entering a PHP class name:</p> <ul> <li><code>classExists($classExists = true)</code> and <code>getClassExists()</code> can be used to ensure that the entered class currently exists in the installation. By default, the existance of the entered class is required.</li> <li><code>implementedInterface($interface)</code> and <code>getImplementedInterface()</code> can be used to ensure that the entered class implements the specified interface. By default, no interface is required.</li> <li><code>parentClass($parentClass)</code> and <code>getParentClass()</code> can be used to ensure that the entered class extends the specified class. By default, no parent class is required.</li> <li><code>instantiable($instantiable = true)</code> and <code>isInstantiable()</code> can be used to ensure that the entered class is instantiable. By default, entered classes have to instantiable.</li> </ul> <p>Additionally, the default id of a <code>ClassNameFormField</code> object is <code>className</code>, the default label is <code>wcf.form.field.className</code>, and if either an interface or a parent class is required, a default description is set if no description has already been set (<code>wcf.form.field.className.description.interface</code> and <code>wcf.form.field.className.description.parentClass</code>, respectively).</p> <p>Example:</p> <pre><code>ClassNameFormField::create('example')\n ->label('foo.bar.example')\n ->classExists()\n ->implementedInterface(ExampleInterface::class)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#currencyformfield","title":"<code>CurrencyFormField</code>","text":"<p><code>CurrencyFormField</code> is an implementation designed for two-decimal currencies like EUR or USD. The API expect amounts to be provided in the smallest unit. For example, to set a value to 10 USD, provide an amount value of 1000 (i.e., 1000 cents).</p> <p>Example:</p> <pre><code>CurrencyFormField::create('name')\n ->currency('USD')\n ->value(1000); // = USD 10\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#dateformfield","title":"<code>DateFormField</code>","text":"<p><code>DateFormField</code> is a form field to enter a date (and optionally a time). The class implements <code>IAttributeFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, and <code>INullableFormField</code>. The following methods are specific to this form field class:</p> <ul> <li><code>earliestDate($earliestDate)</code> and <code>getEarliestDate()</code> can be used to get and set the earliest selectable/valid date and <code>latestDate($latestDate)</code> and <code>getLatestDate()</code> can be used to get and set the latest selectable/valid date. The date passed to the setters must have the same format as set via <code>saveValueFormat()</code>. If a custom format is used, that format has to be set via <code>saveValueFormat()</code> before calling any of the setters.</li> <li><code>saveValueFormat($saveValueFormat)</code> and <code>getSaveValueFormat()</code> can be used to specify the date format of the value returned by <code>getSaveValue()</code>. By default, <code>U</code> is used as format. The PHP manual provides an overview of supported formats.</li> <li><code>supportTime($supportsTime = true)</code> and <code>supportsTime()</code> can be used to toggle whether, in addition to a date, a time can also be specified. By default, specifying a time is disabled.</li> </ul> <p>Example:</p> <pre><code>DateFormField::create('example')\n ->label('foo.bar.example')\n ->saveValueFormat('Y-m-d')\n ->value(DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'Y-m-d'))\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#descriptionformfield","title":"<code>DescriptionFormField</code>","text":"<p><code>DescriptionFormField</code> is a multi-line text form field with <code>description</code> as the default id and <code>wcf.global.description</code> as the default label.</p> <p>Example:</p> <pre><code>DescriptionFormField::create('example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#emailformfield","title":"<code>EmailFormField</code>","text":"<p><code>EmailFormField</code> is a form field to enter an email address which is internally validated using <code>UserUtil::isValidEmail()</code>. The class implements <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, <code>II18nFormField</code>, <code>IImmutableFormField</code>, <code>IInputModeFormField</code>, <code>IPatternFormField</code>, and <code>IPlaceholderFormField</code>.</p> <p>Example:</p> <pre><code>EmailFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#floatformfield","title":"<code>FloatFormField</code>","text":"<p><code>FloatFormField</code> is an implementation of AbstractNumericFormField for floating point numbers.</p> <p>Example:</p> <pre><code>FloatFormField::create('example')\n ->label('foo.bar.example')\n ->value(0.5)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#hiddenformfield","title":"<code>HiddenFormField</code>","text":"<p><code>HiddenFormField</code> is a form field without any user-visible UI. Even though the form field is invisible to the user, the value can still be modified by the user, e.g. by leveraging the web browsers developer tools. The <code>HiddenFormField</code> must not be used to transfer sensitive information or information that the user should not be able to modify.</p> <p>Example:</p> <pre><code>HiddenFormField::create('example')\n ->value('hidden value')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#iconformfield","title":"<code>IconFormField</code>","text":"<p><code>IconFormField</code> is a form field to select a FontAwesome icon.</p> <p>Example:</p> <pre><code>IconFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#integerformfield","title":"<code>IntegerFormField</code>","text":"<p><code>IntegerFormField</code> is an implementation of AbstractNumericFormField for integers.</p> <p>Example:</p> <pre><code>IntegerFormField::create('example')\n ->label('foo.bar.example')\n ->value(10)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#isdisabledformfield","title":"<code>IsDisabledFormField</code>","text":"<p><code>IsDisabledFormField</code> is a boolean form field with <code>isDisabled</code> as the default id.</p> <p>Example:</p> <pre><code>IsDisabledFormField::create()\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#itemlistformfield","title":"<code>ItemListFormField</code>","text":"<p><code>ItemListFormField</code> is a form field in which multiple values can be entered and returned in different formats as save value. The class implements <code>IAttributeFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, and <code>IMultipleFormField</code>. The <code>saveValueType($saveValueType)</code> and <code>getSaveValueType()</code> methods are specific to this form field class and determine the format of the save value. The following save value types are supported:</p> <ul> <li><code>ItemListFormField::SAVE_VALUE_TYPE_ARRAY</code> adds a custom data processor that writes the form field data directly in the parameters array and not in the data sub-array of the parameters array.</li> <li><code>ItemListFormField::SAVE_VALUE_TYPE_CSV</code> lets the value be returned as a string in which the values are concatenated by commas.</li> <li><code>ItemListFormField::SAVE_VALUE_TYPE_NSV</code> lets the value be returned as a string in which the values are concatenated by <code>\\n</code>.</li> <li><code>ItemListFormField::SAVE_VALUE_TYPE_SSV</code> lets the value be returned as a string in which the values are concatenated by spaces.</li> </ul> <p>By default, <code>ItemListFormField::SAVE_VALUE_TYPE_CSV</code> is used.</p> <p>If <code>ItemListFormField::SAVE_VALUE_TYPE_ARRAY</code> is used as save value type, <code>ItemListFormField</code> objects register a custom form field data processor to add the relevant array into the <code>$parameters</code> array directly using the object property as the array key.</p> <p>Example:</p> <pre><code>ItemListFormField::create('example')\n ->label('foo.bar.example')\n ->saveValueType(ItemListFormField::SAVE_VALUE_TYPE_CSV)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#languageitemformnode","title":"<code>LanguageItemFormNode</code>","text":"<p><code>LanguageItemFormNode</code> is a form node that shows a language item without any surrounding HTML code.</p> <p>Example:</p> <pre><code>LanguageItemFormNode::create('name')\n ->languageItem('name_of_language_item');\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#multilinetextformfield","title":"<code>MultilineTextFormField</code>","text":"<p><code>MultilineTextFormField</code> is a text form field that supports multiple rows of text. The methods <code>rows($rows)</code> and <code>getRows()</code> can be used to set and get the number of rows of the <code>textarea</code> elements. The default number of rows is <code>10</code>. These methods do not, however, restrict the number of text rows that can be entered.</p> <p>Example:</p> <pre><code>MultilineTextFormField::create('example')\n ->label('foo.bar.example')\n ->maximumLength(5000)\n ->rows(5)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#multipleselectionformfield","title":"<code>MultipleSelectionFormField</code>","text":"<p><code>MultipleSelectionFormField</code> is a form fields that allows the selection of multiple options out of a predefined list of available options. The class implements <code>IAttributeFormField</code>, <code>ICssClassFormField</code>, <code>IFilterableSelectionFormField</code>, and <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>MultipleSelectionFormField::create('example')\n ->label('foo.bar.example')\n ->options([\n 1 => 'one',\n 2 => 'two',\n ])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#noticeformnode","title":"<code>NoticeFormNode</code>","text":"<p><code>NoticeFormNode</code> is a form node that shows a notice without any surrounding HTML code.</p> <p>Example:</p> <pre><code>NoticeFormNode::create('name')\n ->type(NoticeFormNodeType::Success)\n ->languageItem('name_of_language_item');\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#radiobuttonformfield","title":"<code>RadioButtonFormField</code>","text":"<p><code>RadioButtonFormField</code> is a form fields that allows the selection of a single option out of a predefined list of available options using radiobuttons. The class implements <code>IAttributeFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, and <code>ISelectionFormField</code>.</p> <p>Example:</p> <pre><code>RadioButtonFormField::create('example')\n ->label('foo.bar.example')\n ->options([\n 1 => 'one',\n 2 => 'two',\n ])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#ratingformfield","title":"<code>RatingFormField</code>","text":"<p><code>RatingFormField</code> is a form field to set a rating for an object. The class implements <code>IImmutableFormField</code>, <code>IMaximumFormField</code>, <code>IMinimumFormField</code>, and <code>INullableFormField</code>. Form fields of this class have <code>rating</code> as their default id, <code>wcf.form.field.rating</code> as their default label, <code>1</code> as their default minimum, and <code>5</code> as their default maximum. For this field, the minimum and maximum refer to the minimum and maximum rating an object can get. When the field is shown, there will be <code>maximum() - minimum() + 1</code> icons be shown with additional CSS classes that can be set and gotten via <code>defaultCssClasses(array $cssClasses)</code> and <code>getDefaultCssClasses()</code>. If a rating values is set, the first <code>getValue()</code> icons will instead use the classes that can be set and gotten via <code>activeCssClasses(array $cssClasses)</code> and <code>getActiveCssClasses()</code>. By default, the only default class is <code>star-o</code> and the active classes are <code>star</code> and <code>orange</code>. </p> <p>Example:</p> <pre><code>RatingFormField::create('example')\n ->label('foo.bar.example')\n ->minimum(1)\n ->maximum(5)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#selectformfield","title":"<code>SelectFormField</code>","text":"<p><code>SelectFormField</code> is a form fields that allows the selection of a single option out of a predefined list of available options. The class implements <code>ICssClassFormField</code> and <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>SelectFormField::create('select')\n ->options(['option1', 'option2', 'option3']);\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#showorderformfield","title":"<code>ShowOrderFormField</code>","text":"<p><code>ShowOrderFormField</code> is a single selection form field for which the selected value determines the position at which an object is shown. The show order field provides a list of all siblings and the object will be positioned after the selected sibling. To insert objects at the very beginning, the <code>options()</code> automatically method prepends an additional option for that case so that only the existing siblings need to be passed. The default id of instances of this class is <code>showOrder</code> and their default label is <code>wcf.form.field.showOrder</code>.</p> <p>It is important that the relevant object property is always kept updated. Whenever a new object is added or an existing object is edited or delete, the values of the other objects have to be adjusted to ensure consecutive numbering.</p> <p>Example:</p> <pre><code>ShowOrderFormField::create('example')\n ->options(new FooList())\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#singleselectionformfield","title":"<code>SingleSelectionFormField</code>","text":"<p><code>SingleSelectionFormField</code> is a form fields that allows the selection of a single option out of a predefined list of available options. The class implements <code>ICssClassFormField</code>, <code>IFilterableSelectionFormField</code>, <code>IImmutableFormField</code>, and <code>INullableFormField</code>. If the field is nullable and the current form field value is considered <code>empty</code> by PHP, <code>null</code> is returned as the save value.</p> <p>Example:</p> <pre><code>SingleSelectionFormField::create('example')\n ->options(['option1', 'option2', 'option3'])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#sortorderformfield","title":"<code>SortOrderFormField</code>","text":"<p><code>SingleSelectionFormField</code> is a single selection form field with default id <code>sortOrder</code>, default label <code>wcf.global.showOrder</code> and default options <code>ASC: wcf.global.sortOrder.ascending</code> and <code>DESC: wcf.global.sortOrder.descending</code>.</p> <p>Example:</p> <pre><code>SingleSelectionFormField::create('example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#textformfield","title":"<code>TextFormField</code>","text":"<p><code>TextFormField</code> is a form field that allows entering a single line of text. The class implements <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, <code>II18nFormField</code>, <code>IInputModeFormField</code>, <code>IMaximumLengthFormField</code>, <code>IMinimumLengthFormField</code>, <code>IPatternFormField</code>, and <code>IPlaceholderFormField</code>.</p> <p>Example:</p> <pre><code>TextFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#titleformfield","title":"<code>TitleFormField</code>","text":"<p><code>TitleFormField</code> is a text form field with <code>title</code> as the default id and <code>wcf.global.title</code> as the default label.</p> <p>Example:</p> <pre><code>TitleFormField::create()\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#urlformfield","title":"<code>UrlFormField</code>","text":"<p><code>UrlFormField</code> is a text form field whose values are checked via <code>Url::is()</code>.</p> <p>Example:</p> <pre><code>UrlFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#specific-fields","title":"Specific Fields","text":"<p>The following form fields are reusable fields that generally are bound to a certain API or <code>DatabaseObject</code> implementation.</p>"},{"location":"php/api/form_builder/form_fields/#aclformfield","title":"<code>AclFormField</code>","text":"<p><code>AclFormField</code> is used for setting up acl values for specific objects. The class implements <code>IObjectTypeFormField</code> and requires an object type of the object type definition <code>com.woltlab.wcf.acl</code>. Additionally, the class provides the methods <code>categoryName($categoryName)</code> and <code>getCategoryName()</code> that allow setting a specific name or filter for the acl option categories whose acl options are shown. A category name of <code>null</code> signals that no category filter is used.</p> <p>Since version 5.5, the category name also supports filtering using a wildcard like <code>user.*</code>, see WoltLab/WCF#4355.</p> <p><code>AclFormField</code> objects register a custom form field data processor to add the relevant ACL object type id into the <code>$parameters</code> array directly using <code>{$objectProperty}_aclObjectTypeID</code> as the array key. The relevant database object action method is expected, based on the given ACL object type id, to save the ACL option values appropriately.</p>"},{"location":"php/api/form_builder/form_fields/#example","title":"Example","text":"<p>The following source code creates an <code>AclFormField</code> with the object type <code>foo.bar.acl</code>:</p> <pre><code>FormContainer::create('aclContainer')\n ->label('foo.bar.acl')\n ->appendChildren([\n AclFormField::create('acl')\n ->objectType('foo.bar.acl')\n ])\n</code></pre> <p>After submitting the form, the id of the object type is passed to the DatabaseObjectAction and can be used there to process the data with the help of the <code>ACLHandler</code>.</p> <pre><code>use wcf\\data\\AbstractDatabaseObjectAction;\nuse wcf\\system\\acl\\ACLHandler;\n\nclass FooAction extends AbstractDatabaseObjectAction {\n public function create() {\n $object = parent::create();\n\n if (!empty($this->parameters['acl_aclObjectTypeID'])) {\n ACLHandler::getInstance()->save($object->getObjectID(), $this->parameters['acl_aclObjectTypeID']);\n }\n }\n}\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#buttonformfield","title":"<code>ButtonFormField</code>","text":"<p><code>ButtonFormField</code> shows a submit button as part of the form. The class implements <code>IAttributeFormField</code> and <code>ICssClassFormField</code>.</p> <p>Specifically for this form field, there is the <code>IsNotClickedFormFieldDependency</code> dependency with which certain parts of the form will only be processed if the relevent button has not clicked. </p> <p>Example:</p> <pre><code>ButtonFormField::create('example')\n ->buttonLabel('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#captchaformfield","title":"<code>CaptchaFormField</code>","text":"<p><code>CaptchaFormField</code> is used to add captcha protection to the form.</p> <p>You must specify a captcha object type (<code>com.woltlab.wcf.captcha</code>) using the <code>objectType()</code> method.</p> <p>Example:</p> <pre><code>CaptchaFormField::create('captcha')\n ->objectType(CAPTCHA_TYPE)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#colorformfield","title":"<code>ColorFormField</code>","text":"<p><code>ColorFormField</code> is used to specify RGBA colors using the <code>rgba(r, g, b, a)</code> format. The class implements <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>ColorFormField::create('example')\n ->label('foo.bar.example')\n ->value('rgba(1,1,1,1)')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#contentlanguageformfield","title":"<code>ContentLanguageFormField</code>","text":"<p><code>ContentLanguageFormField</code> is used to select the content language of an object. Fields of this class are only available if multilingualism is enabled and if there are content languages. The class implements <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>ContentLanguageFormField::create()\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#labelformfield","title":"<code>LabelFormField</code>","text":"<p><code>LabelFormField</code> is used to select a label from a specific label group. The class implements <code>IObjectTypeFormNode</code>.</p> <p>The <code>labelGroup(ViewableLabelGroup $labelGroup)</code> and <code>getLabelGroup()</code> methods are specific to this form field class and can be used to set and get the label group whose labels can be selected. Additionally, there is the static method <code>createFields($objectType, array $labelGroups, $objectProperty = 'labelIDs)</code> that can be used to create all relevant label form fields for a given list of label groups. In most cases, <code>LabelFormField::createFields()</code> should be used.</p> <p>Example:</p> <pre><code>LabelFormField::create('example')\n ->objectType('foo.bar.example.object.type')\n ->labelGroup(LabelHandler::getInstance()->getLabelGroup($groupID))\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#optionformfield","title":"<code>OptionFormField</code>","text":"<p><code>OptionFormField</code> is an item list form field to set a list of options. The class implements <code>IPackagesFormField</code> and only options of the set packages are considered available. The default label of instances of this class is <code>wcf.form.field.option</code> and their default id is <code>options</code>.</p> <p>Example:</p> <pre><code>OptionFormField::create()\n ->description('foo.bar.example')\n ->packageIDs([1, 2])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#simpleaclformfield","title":"<code>SimpleAclFormField</code>","text":"<p><code>SimpleAclFormField</code> is used for setting up simple acl values (one <code>yes</code>/<code>no</code> option per user and user group) for specific objects.</p> <p><code>SimpleAclFormField</code> objects register a custom form field data processor to add the relevant simple ACL data array into the <code>$parameters</code> array directly using the object property as the array key.</p> <p>Since version 5.5, the field also supports inverted permissions, see WoltLab/WCF#4570.</p> <p>The <code>SimpleAclFormField</code> supports inverted permissions, allowing the administrator to grant access to all non-selected users and groups. If this behavior is desired, it needs to be enabled by calling <code>supportInvertedPermissions</code>. An <code>invertPermissions</code> key containing a boolean value with the users selection will be provided together with the ACL values when saving the field.</p> <p>Example:</p> <pre><code>SimpleAclFormField::create('example')\n ->label('foo.bar.example')\n ->supportInvertedPermissions(true)\n ->value([\n 'allowAll' => false,\n 'user' => [1, 2],\n ])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#singlemediaselectionformfield","title":"<code>SingleMediaSelectionFormField</code>","text":"<p><code>SingleMediaSelectionFormField</code> is used to select a specific media file. The class implements <code>IImmutableFormField</code>.</p> <p>The following methods are specific to this form field class:</p> <ul> <li><code>imageOnly($imageOnly = true)</code> and <code>isImageOnly()</code> can be used to set and check if only images may be selected.</li> <li><code>getMedia()</code> returns the media file based on the current field value if a field is set.</li> </ul> <p>Example:</p> <pre><code>SingleMediaSelectionFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#tagformfield","title":"<code>TagFormField</code>","text":"<p><code>TagFormField</code> is a form field to enter tags. The class implements <code>IAttributeFormField</code> and <code>IObjectTypeFormNode</code>. Arrays passed to <code>TagFormField::values()</code> can contain tag names as strings and <code>Tag</code> objects. The default label of instances of this class is <code>wcf.tagging.tags</code> and their default description is <code>wcf.tagging.tags.description</code>.</p> <p><code>TagFormField</code> objects register a custom form field data processor to add the array with entered tag names into the <code>$parameters</code> array directly using the object property as the array key.</p> <p>Example:</p> <pre><code>TagFormField::create()\n ->objectType('foo.bar.example.object.type')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#uploadformfield","title":"<code>UploadFormField</code>","text":"<p><code>UploadFormField</code> is a form field that allows uploading files by the user.</p> <p><code>UploadFormField</code> objects register a custom form field data processor to add the array of <code>wcf\\system\\file\\upload\\UploadFile\\UploadFile</code> into the <code>$parameters</code> array directly using the object property as the array key. Also it registers the removed files as an array of <code>wcf\\system\\file\\upload\\UploadFile\\UploadFile</code> into the <code>$parameters</code> array directly using the object property with the suffix <code>_removedFiles</code> as the array key. </p> <p>The field supports additional settings:</p> <ul> <li><code>imageOnly($imageOnly = true)</code> and <code>isImageOnly()</code> can be used to ensure that the uploaded files are only images.</li> <li><code>allowSvgImage($allowSvgImages = true)</code> and <code>svgImageAllowed()</code> can be used to allow SVG images, if the image only mode is enabled (otherwise, the method will throw an exception). By default, SVG images are not allowed.</li> </ul> <p>Example:</p> <pre><code>UploadFormField::create('example')\n ->label('foo.bar.example')\n ->maximum(1)\n ->imageOnly(true)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#provide-value-from-database-object","title":"Provide value from database object","text":"<p>To provide values from a database object, you should implement the method <code>get{$objectProperty}UploadFileLocations()</code> to your database object class. This method must return an array of strings with the locations of the files.</p>"},{"location":"php/api/form_builder/form_fields/#process-files","title":"Process files","text":"<p>To process files in the database object action class, you must <code>rename</code> the file to the final destination. You get the temporary location, by calling the method <code>getLocation()</code> on the given <code>UploadFile</code> objects. After that, you call <code>setProcessed($location)</code> with <code>$location</code> contains the new file location. This method sets the <code>isProcessed</code> flag to true and saves the new location. For updating files, it is relevant, whether a given file is already processed or not. For this case, the <code>UploadFile</code> object has an method <code>isProcessed()</code> which indicates, whether a file is already processed or new uploaded.</p>"},{"location":"php/api/form_builder/form_fields/#userformfield","title":"<code>UserFormField</code>","text":"<p><code>UserFormField</code> is a form field to enter existing users. The class implements <code>IAutoCompleteFormField</code>, <code>IAutoFocusFormField</code>, <code>IImmutableFormField</code>, <code>IMultipleFormField</code>, and <code>INullableFormField</code>. While the user is presented the names of the specified users in the user interface, the field returns the ids of the users as data. The relevant <code>UserProfile</code> objects can be accessed via the <code>getUsers()</code> method.</p> <p>Example:</p> <pre><code>UserFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#userpasswordfield","title":"<code>UserPasswordField</code>","text":"<p><code>UserPasswordField</code> is a form field for users' to enter their current password. The class implements <code>IAttributeFormField</code>, <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>IAutoFocusFormField</code>, and <code>IPlaceholderFormField</code></p> <p>Example:</p> <pre><code>UserPasswordField::create()\n ->autocomplete('current-password')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#usergroupoptionformfield","title":"<code>UserGroupOptionFormField</code>","text":"<p><code>UserGroupOptionFormField</code> is an item list form field to set a list of user group options/permissions. The class implements <code>IPackagesFormField</code> and only user group options of the set packages are considered available. The default label of instances of this class is <code>wcf.form.field.userGroupOption</code> and their default id is <code>permissions</code>.</p> <p>Example:</p> <pre><code>UserGroupOptionFormField::create()\n ->packageIDs([1, 2])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#usernameformfield","title":"<code>UsernameFormField</code>","text":"<p><code>UsernameFormField</code> is used for entering one non-existing username. The class implements <code>IAttributeFormField</code>, <code>IImmutableFormField</code>, <code>IMaximumLengthFormField</code>, <code>IMinimumLengthFormField</code>, <code>INullableFormField</code>, and <code>IPlaceholderFormField</code>. As usernames have a system-wide restriction of a minimum length of 3 and a maximum length of 100 characters, these values are also used as the default value for the field\u2019s minimum and maximum length.</p> <p>Example:</p> <pre><code>UsernameFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#wysiwyg-form-container","title":"Wysiwyg form container","text":"<p>To integrate a wysiwyg editor into a form, you have to create a <code>WysiwygFormContainer</code> object. This container takes care of creating all necessary form nodes listed below for a wysiwyg editor.</p> <p>When creating the container object, its id has to be the id of the form field that will manage the actual text.</p> <p>The following methods are specific to this form container class:</p> <ul> <li><code>addSettingsNode(IFormChildNode $settingsNode)</code> and <code>addSettingsNodes(array $settingsNodes)</code> can be used to add nodes to the settings tab container.</li> <li><code>attachmentData($objectType, $parentObjectID)</code> can be used to set the data relevant for attachment support. By default, not attachment data is set, thus attachments are not supported.</li> <li><code>getAttachmentField()</code>, <code>getPollContainer()</code>, <code>getSettingsContainer()</code>, <code>getSmiliesContainer()</code>, and <code>getWysiwygField()</code> can be used to get the different components of the wysiwyg form container once the form has been built.</li> <li><code>enablePreviewButton($enablePreviewButton)</code> can be used to set whether the preview button for the message is shown or not. By default, the preview button is shown. This method is only relevant before the form is built. Afterwards, the preview button availability can not be changed.</li> <li><code>getObjectId()</code> returns the id of the edited object or <code>0</code> if no object is edited.</li> <li><code>getPreselect()</code>, <code>preselect($preselect)</code> can be used to set the value of the wysiwyg tab menu's <code>data-preselect</code> attribute used to determine which tab is preselected. By default, the preselect is <code>'true'</code> which is used to pre-select the first tab.</li> <li><code>messageObjectType($messageObjectType)</code> can be used to set the message object type.</li> <li><code>pollObjectType($pollObjectType)</code> can be used to set the poll object type. By default, no poll object type is set, thus the poll form field container is not available.</li> <li><code>supportMentions($supportMentions)</code> can be used to set if mentions are supported. By default, mentions are not supported. This method is only relevant before the form is built. Afterwards, mention support can only be changed via the wysiwyg form field.</li> <li><code>supportSmilies($supportSmilies)</code> can be used to set if smilies are supported. By default, smilies are supported. This method is only relevant before the form is built. Afterwards, smiley availability can only be changed via changing the availability of the smilies form container.</li> </ul>"},{"location":"php/api/form_builder/form_fields/#wysiwygattachmentformfield","title":"<code>WysiwygAttachmentFormField</code>","text":"<p><code>WysiwygAttachmentFormField</code> provides attachment support for a wysiwyg editor via a tab in the menu below the editor. This class should not be used directly but only via <code>WysiwygFormContainer</code>. The methods <code>attachmentHandler(AttachmentHandler $attachmentHandler)</code> and <code>getAttachmentHandler()</code> can be used to set and get the <code>AttachmentHandler</code> object that is used for uploaded attachments.</p>"},{"location":"php/api/form_builder/form_fields/#wysiwygpollformcontainer","title":"<code>WysiwygPollFormContainer</code>","text":"<p><code>WysiwygPollFormContainer</code> provides poll support for a wysiwyg editor via a tab in the menu below the editor. This class should not be used directly but only via <code>WysiwygFormContainer</code>. <code>WysiwygPollFormContainer</code> contains all form fields that are required to create polls and requires edited objects to implement <code>IPollContainer</code>.</p> <p>The following methods are specific to this form container class:</p> <ul> <li><code>getEndTimeField()</code> returns the form field to set the end time of the poll once the form has been built.</li> <li><code>getIsChangeableField()</code> returns the form field to set if poll votes can be changed once the form has been built.</li> <li><code>getIsPublicField()</code> returns the form field to set if poll results are public once the form has been built.</li> <li><code>getMaxVotesField()</code> returns the form field to set the maximum number of votes once the form has been built.</li> <li><code>getOptionsField()</code> returns the form field to set the poll options once the form has been built.</li> <li><code>getQuestionField()</code> returns the form field to set the poll question once the form has been built.</li> <li><code>getResultsRequireVoteField()</code> returns the form field to set if viewing the poll results requires voting once the form has been built.</li> <li><code>getSortByVotesField()</code> returns the form field to set if the results are sorted by votes once the form has been built.</li> </ul>"},{"location":"php/api/form_builder/form_fields/#wysiwygsmileyformcontainer","title":"<code>WysiwygSmileyFormContainer</code>","text":"<p><code>WysiwygSmileyFormContainer</code> provides smiley support for a wysiwyg editor via a tab in the menu below the editor. This class should not be used directly but only via <code>WysiwygFormContainer</code>. <code>WysiwygSmileyFormContainer</code> creates a sub-tab for each smiley category.</p>"},{"location":"php/api/form_builder/form_fields/#wysiwygsmileyformnode","title":"<code>WysiwygSmileyFormNode</code>","text":"<p><code>WysiwygSmileyFormNode</code> is contains the smilies of a specific category. This class should not be used directly but only via <code>WysiwygSmileyFormContainer</code>.</p>"},{"location":"php/api/form_builder/form_fields/#example_1","title":"Example","text":"<p>The following code creates a WYSIWYG editor component for a <code>message</code> object property. As smilies are supported by default and an attachment object type is given, the tab menu below the editor has two tabs: \u201cSmilies\u201d and \u201cAttachments\u201d. Additionally, mentions and quotes are supported.</p> <pre><code>WysiwygFormContainer::create('message')\n ->label('foo.bar.message')\n ->messageObjectType('com.example.foo.bar')\n ->attachmentData('com.example.foo.bar')\n ->supportMentions()\n ->supportQuotes()\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#wysiwygformfield","title":"<code>WysiwygFormField</code>","text":"<p><code>WysiwygFormField</code> is used for wysiwyg editor form fields. This class should, in general, not be used directly but only via <code>WysiwygFormContainer</code>. The class implements <code>IAttributeFormField</code>, <code>IMaximumLengthFormField</code>, <code>IMinimumLengthFormField</code>, and <code>IObjectTypeFormNode</code> and requires an object type of the object type definition <code>com.woltlab.wcf.message</code>. The following methods are specific to this form field class:</p> <ul> <li><code>autosaveId($autosaveId)</code> and <code>getAutosaveId()</code> can be used enable automatically saving the current editor contents in the browser using the given id. An empty string signals that autosaving is disabled.</li> <li><code>lastEditTime($lastEditTime)</code> and <code>getLastEditTime()</code> can be used to set the last time the contents have been edited and saved so that the JavaScript can determine if the contents stored in the browser are older or newer. <code>0</code> signals that no last edit time has been set.</li> <li> <p><code>supportAttachments($supportAttachments)</code> and <code>supportsAttachments()</code> can be used to set and check if the form field supports attachments.</p> <p>It is not sufficient to simply signal attachment support via these methods for attachments to work. These methods are relevant internally to signal the Javascript code that the editor supports attachments. Actual attachment support is provided by <code>WysiwygAttachmentFormField</code>.</p> </li> <li> <p><code>supportMentions($supportMentions)</code> and <code>supportsMentions()</code> can be used to set and check if the form field supports mentions of other users.</p> </li> </ul> <p><code>WysiwygFormField</code> objects register a custom form field data processor to add the relevant simple ACL data array into the <code>$parameters</code> array directly using the object property as the array key.</p>"},{"location":"php/api/form_builder/form_fields/#twysiwygformnode","title":"<code>TWysiwygFormNode</code>","text":"<p>All form nodes that need to know the id of the <code>WysiwygFormField</code> field should use <code>TWysiwygFormNode</code>. This trait provides <code>getWysiwygId()</code> and <code>wysiwygId($wysiwygId)</code> to get and set the relevant wysiwyg editor id.</p>"},{"location":"php/api/form_builder/form_fields/#application-specific-form-fields","title":"Application-Specific Form Fields","text":""},{"location":"php/api/form_builder/form_fields/#woltlab-suite-forum","title":"WoltLab Suite Forum","text":""},{"location":"php/api/form_builder/form_fields/#multipleboardselectionformfield","title":"<code>MultipleBoardSelectionFormField</code>","text":"<p><code>MultipleBoardSelectionFormField</code> is used to select multiple forums. The class implements <code>IAttributeFormField</code>, <code>ICssClassFormField</code>, and <code>IImmutableFormField</code>.</p> <p>The field supports additional settings:</p> <ul> <li><code>boardNodeList(BoardNodeList $boardNodeList): self</code> and <code>getBoardNodeList(): BoardNodeList</code> are used to set and get the list of board nodes used to render the board selection. <code>boardNodeList(BoardNodeList $boardNodeList): self</code> will automatically call <code>readNodeTree()</code> on the given board node list.</li> <li><code>categoriesSelectable(bool $categoriesSelectable = true): self</code> and <code>areCategoriesSelectable(): bool</code> are used to set and check if the categories in the board node list are selectable. By default, categories are selectable. This option is useful if only actual boards, in which threads can be posted, should be selectable but the categories must still be shown so that the overall forum structure is still properly shown.</li> <li><code>supportExternalLinks(bool $supportExternalLinks): self</code> and <code>supportsExternalLinks(): bool</code> are used to set and check if external links will be shown in the selection list. By default, external links are shown. Like in the example given before, in cases where only actual boards, in which threads can be posted, are relevant, this option allows to exclude external links.</li> </ul>"},{"location":"php/api/form_builder/form_fields/#single-use-form-fields","title":"Single-Use Form Fields","text":"<p>The following form fields are specific for certain forms and hardly reusable in other contexts.</p>"},{"location":"php/api/form_builder/form_fields/#bbcodeattributesformfield","title":"<code>BBCodeAttributesFormField</code>","text":"<p><code>BBCodeAttributesFormField</code> is a form field for setting the attributes of a BBCode.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectexcludedpackagesformfield","title":"<code>DevtoolsProjectExcludedPackagesFormField</code>","text":"<p><code>DevtoolsProjectExcludedPackagesFormField</code> is a form field for setting the excluded packages of a devtools project.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectinstructionsformfield","title":"<code>DevtoolsProjectInstructionsFormField</code>","text":"<p><code>DevtoolsProjectInstructionsFormField</code> is a form field for setting the installation and update instructions of a devtools project.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectoptionalpackagesformfield","title":"<code>DevtoolsProjectOptionalPackagesFormField</code>","text":"<p><code>DevtoolsProjectOptionalPackagesFormField</code> is a form field for setting the optional packages of a devtools project.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectrequiredpackagesformfield","title":"<code>DevtoolsProjectRequiredPackagesFormField</code>","text":"<p><code>DevtoolsProjectRequiredPackagesFormField</code> is a form field for setting the required packages of a devtools project.</p>"},{"location":"php/api/form_builder/overview/","title":"Form Builder","text":"<p>WoltLab Suite includes a powerful way of creating forms: Form Builder. Form builder allows you to easily define all the fields and their constraints and interdependencies within PHP with full IDE support. It will then automatically generate the necessary HTML with full interactivity to render all the fields and also validate the fields\u2019 contents upon submission.</p> <p>The migration guide for WoltLab Suite Core 5.2 provides some examples of how to migrate existing forms to form builder that can also help in understanding form builder if the old way of creating forms is familiar.</p>"},{"location":"php/api/form_builder/overview/#form-builder-components","title":"Form Builder Components","text":"<p>Form builder consists of several components that are presented on the following pages:</p> <ol> <li>Structure of form builder</li> <li>Form validation and form data</li> <li>Form node dependencies</li> </ol> <p>In general, form builder provides default implementation of interfaces by providing either abstract classes or traits. It is expected that the interfaces are always implemented using these abstract classes and traits! This way, if new methods are added to the interfaces, default implementations can be provided by the abstract classes and traits without causing backwards compatibility problems.</p>"},{"location":"php/api/form_builder/overview/#abstractformbuilderform","title":"<code>AbstractFormBuilderForm</code>","text":"<p>To make using form builder easier, <code>AbstractFormBuilderForm</code> extends <code>AbstractForm</code> and provides most of the code needed to set up a form (of course without specific fields, those have to be added by the concrete form class), like reading and validating form values and using a database object action to use the form data to create or update a database object.</p> <p>In addition to the existing methods inherited by <code>AbstractForm</code>, <code>AbstractFormBuilderForm</code> provides the following methods:</p> <ul> <li> <p><code>buildForm()</code> builds the form in the following steps:</p> </li> <li> <p>Call <code>AbtractFormBuilderForm::createForm()</code> to create the <code>IFormDocument</code> object and add the form fields.</p> </li> <li>Call <code>IFormDocument::build()</code> to build the form.</li> <li>Call <code>AbtractFormBuilderForm::finalizeForm()</code> to finalize the form like adding dependencies.</li> </ul> <p>Additionally, between steps 1 and 2 and after step 3, the method provides two events, <code>createForm</code> and <code>buildForm</code> to allow plugins to register event listeners to execute additional code at the right point in time. - <code>createForm()</code> creates the <code>FormDocument</code> object and sets the form mode. Classes extending <code>AbstractFormBuilderForm</code> have to override this method (and call <code>parent::createForm()</code> as the first line in the overridden method) to add concrete form containers and form fields to the bare form document. - <code>finalizeForm()</code> is called after the form has been built and the complete form hierarchy has been established. This method should be overridden to add dependencies, for example. - <code>setFormAction()</code> is called at the end of <code>readData()</code> and sets the form document\u2019s action based on the controller class name and whether an object is currently edited. - If an object is edited, at the beginning of <code>readData()</code>, <code>setFormObjectData()</code> is called which calls <code>IFormDocument::loadValuesFromObject()</code>. If values need to be loaded from additional sources, this method should be used for that.</p> <p><code>AbstractFormBuilderForm</code> also provides the following (public) properties:</p> <ul> <li><code>$form</code> contains the <code>IFormDocument</code> object created in <code>createForm()</code>.</li> <li><code>$formAction</code> is either <code>create</code> (default) or <code>edit</code> and handles which method of the database object is called by default (<code>create</code> is called for <code>$formAction = 'create'</code> and <code>update</code> is called for <code>$formAction = 'edit'</code>) and is used to set the value of the <code>action</code> template variable.</li> <li><code>$formObject</code> contains the <code>IStorableObject</code> if the form is used to edit an existing object. For forms used to create objects, <code>$formObject</code> is always <code>null</code>. Edit forms have to manually identify the edited object based on the request data and set the value of <code>$formObject</code>. </li> <li><code>$objectActionName</code> can be used to set an alternative action to be executed by the database object action that deviates from the default action determined by the value of <code>$formAction</code>.</li> <li><code>$objectActionClass</code> is the name of the database object action class that is used to create or update the database object.</li> </ul> <p>Example:</p> <pre><code><?php\n\nnamespace wcf\\acp\\form;\n\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\field\\BooleanFormField;\nuse wcf\\system\\form\\builder\\field\\TextFormField;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidationError;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidator;\n\nclass FooAddForm extends AbstractFormBuilderForm\n{\n /**\n * @inheritDoc\n */\n public $objectActionClass = FooAction::class;\n\n #[\\Override]\n protected function createForm()\n {\n parent::createForm();\n\n $this->form->appendChildren([\n TextFormField::create('name')\n ->label('wcf.foo.name')\n ->description('wcf.foo.name.description')\n ->required()\n ->maximumLength(255)\n ->addValidator(new FormFieldValidator('notFoo', function (TextFormField $formField) {\n if ($formField->getValue() === 'foo') {\n $formField->addValidationError(\n new FormFieldValidationError(\n 'isFoo',\n 'wcf.foo.name.error.isFoo'\n )\n );\n }\n })),\n BooleanFormField::create('isCool')\n ->label('wcf.foo.isCool')\n ->value(true)\n ]);\n }\n}\n</code></pre>"},{"location":"php/api/form_builder/overview/#psr15dialogform","title":"<code>Psr15DialogForm</code>","text":"<p>Form builder forms can also be used in dialogs. For such forms, <code>Psr15DialogForm</code> should be used which provides the additional methods <code>validateRequest(ServerRequestInterface $request)</code> and <code>toResponse()</code> to enable processing of the form via an AJAX request.</p> <p>Example:</p> <pre><code><?php\n\nnamespace wcf\\action;\n\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidationError;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidator;\nuse wcf\\system\\form\\builder\\Psr15DialogForm;\nuse wcf\\system\\WCF;\n\nfinal class FooAction implements RequestHandlerInterface\n{\n /**\n * @inheritDoc\n */\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $form = $this->getForm();\n\n if ($request->getMethod() === 'GET') {\n return $form->toResponse();\n } elseif ($request->getMethod() === 'POST') {\n $response = $form->validateRequest($request);\n if ($response !== null) {\n return $response;\n }\n\n $data = $form->getData()['data'];\n\n // process data\n } else {\n throw new \\LogicException('Unreachable');\n }\n }\n\n private function getForm(): Psr15DialogForm\n {\n $form = new Psr15DialogForm(\n static::class,\n WCF::getLanguage()->get('wcf.foo.dialog.name')\n );\n $form->appendChildren([\n TextFormField::create('name')\n ->label('wcf.foo.name')\n ->description('wcf.foo.name.description')\n ->required()\n ->maximumLength(255)\n ->addValidator(new FormFieldValidator('notFoo', function (TextFormField $formField) {\n if ($formField->getValue() === 'foo') {\n $formField->addValidationError(\n new FormFieldValidationError(\n 'isFoo',\n 'wcf.foo.name.error.isFoo'\n )\n );\n }\n })),\n BooleanFormField::create('isCool')\n ->label('wcf.foo.isCool')\n ->value(true)\n ]);\n $form->build();\n\n return $form;\n }\n}\n</code></pre> <p>On the client side, the dialog is loaded using the dialog API. A tuple is made available as a return, which provides the status of the successful form submission (<code>ok: boolean</code>) and the server-side return (<code>result: any</code>).</p> <p>Example:</p> <pre><code>require(['WoltLabSuite/Core/Component/Dialog'], async ({ dialogFactory }) => {\n const { ok, result } = await dialogFactory().usingFormBuilder().fromEndpoint('endpoint_url');\n\n if (ok) {\n // Form submission was successful\n }\n});\n</code></pre>"},{"location":"php/api/form_builder/structure/","title":"Structure of Form Builder","text":"<p>Forms built with form builder consist of three major structural elements listed from top to bottom:</p> <ol> <li>form document,</li> <li>form container,</li> <li>form field.</li> </ol> <p>The basis for all three elements are form nodes.</p> <p>The form builder API uses fluent interfaces heavily, meaning that unless a method is a getter, it generally returns the objects itself to support method chaining.</p>"},{"location":"php/api/form_builder/structure/#form-nodes","title":"Form Nodes","text":"<ul> <li><code>IFormNode</code> is the base interface that any node of a form has to implement.</li> <li><code>IFormChildNode</code> extends <code>IFormNode</code> for such elements of a form that can be a child node to a parent node.</li> <li><code>IFormParentNode</code> extends <code>IFormNode</code> for such elements of a form that can be a parent to child nodes.</li> <li><code>IFormElement</code> extends <code>IFormNode</code> for such elements of a form that can have a description and a label.</li> </ul>"},{"location":"php/api/form_builder/structure/#iformnode","title":"<code>IFormNode</code>","text":"<p><code>IFormNode</code> is the base interface that any node of a form has to implement and it requires the following methods:</p> <ul> <li><code>addClass($class)</code>, <code>addClasses(array $classes)</code>, <code>removeClass($class)</code>, <code>getClasses()</code>, and <code>hasClass($class)</code> add, remove, get, and check for CSS classes of the HTML element representing the form node. If the form node consists of multiple (nested) HTML elements, the classes are generally added to the top element. <code>static validateClass($class)</code> is used to check if a given CSS class is valid. By default, a form node has no CSS classes.</li> <li><code>addDependency(IFormFieldDependency $dependency)</code>, <code>removeDependency($dependencyId)</code>, <code>getDependencies()</code>, and <code>hasDependency($dependencyId)</code> add, remove, get, and check for dependencies of this form node on other form fields. <code>checkDependencies()</code> checks if all of the node\u2019s dependencies are met and returns a boolean value reflecting the check\u2019s result. The form builder dependency documentation provides more detailed information about dependencies and how they work. By default, a form node has no dependencies.</li> <li><code>attribute($name, $value = null)</code>, <code>removeAttribute($name)</code>, <code>getAttribute($name)</code>, <code>getAttributes()</code>, <code>hasAttribute($name)</code> add, remove, get, and check for attributes of the HTML element represting the form node. The attributes are added to the same element that the CSS classes are added to. <code>static validateAttribute($name)</code> is used to check if a given attribute is valid. By default, a form node has no attributes.</li> <li><code>available($available = true)</code> and <code>isAvailable()</code> can be used to set and check if the node is available. The availability functionality can be used to easily toggle form nodes based, for example, on options without having to create a condition to append the relevant. This way of checking availability makes it easier to set up forms. By default, every form node is available.</li> </ul> <p>The following aspects are important when working with availability:</p> <ul> <li>Unavailable fields produce no output, their value is not read, they are not validated and they are not checked for save values.</li> <li>Form fields are also able to mark themselves as unavailable, for example, a selection field without any options.</li> <li>Form containers are automatically unavailable if they contain no available children.</li> </ul> <p>Availability sets the static availability for form nodes that does not change during the lifetime of a form. In contrast, dependencies represent a dynamic availability for form nodes that depends on the current value of certain form fields. - <code>cleanup()</code> is called after the whole form is not used anymore to reset other APIs if the form fields depends on them and they expect such a reset. This method is not intended to clean up the form field\u2019s value as a new form document object is created to show a clean form. - <code>getDocument()</code> returns the <code>IFormDocument</code> object the node belongs to. (As <code>IFormDocument</code> extends <code>IFormNode</code>, form document objects simply return themselves.) - <code>getHtml()</code> returns the HTML representation of the node. <code>getHtmlVariables()</code> return template variables (in addition to the form node itself) to render the node\u2019s HTML representation. - <code>id($id)</code> and <code>getId()</code> set and get the id of the form node. Every id has to be unique within a form. <code>getPrefixedId()</code> returns the prefixed version of the node\u2019s id (see <code>IFormDocument::getPrefix()</code> and <code>IFormDocument::prefix()</code>). <code>static validateId($id)</code> is used to check if a given id is valid. - <code>populate()</code> is called by <code>IFormDocument::build()</code> after all form nodes have been added. This method should finilize the initialization of the form node after all parent-child relations of the form document have been established. This method is needed because during the construction of a form node, it neither knows the form document it will belong to nor does it know its parent. - <code>validate()</code> checks, after the form is submitted, if the form node is valid. A form node with children is valid if all of its child nodes are valid. A form field is valid if its value is valid. - <code>static create($id)</code> is the factory method that has to be used to create new form nodes with the given id.</p> <p><code>TFormNode</code> provides a default implementation of most of these methods.</p>"},{"location":"php/api/form_builder/structure/#iformchildnode","title":"<code>IFormChildNode</code>","text":"<p><code>IFormChildNode</code> extends <code>IFormNode</code> for such elements of a form that can be a child node to a parent node and it requires the <code>parent(IFormParentNode $parentNode)</code> and <code>getParent()</code> methods used to set and get the node\u2019s parent node. <code>TFormChildNode</code> provides a default implementation of these two methods and also of <code>IFormNode::getDocument()</code>.</p>"},{"location":"php/api/form_builder/structure/#iformparentnode","title":"<code>IFormParentNode</code>","text":"<p><code>IFormParentNode</code> extends <code>IFormNode</code> for such elements of a form that can be a parent to child nodes. Additionally, the interface also extends <code>\\Countable</code> and <code>\\RecursiveIterator</code>. The interface requires the following methods:</p> <ul> <li><code>appendChild(IFormChildNode $child)</code>, <code>appendChildren(array $children)</code>, <code>insertAfter(IFormChildNode $child, $referenceNodeId)</code>, and <code>insertBefore(IFormChildNode $child, $referenceNodeId)</code> are used to insert new children either at the end or at specific positions. <code>validateChild(IFormChildNode $child)</code> is used to check if a given child node can be added. A child node cannot be added if it would cause an id to be used twice.</li> <li><code>children()</code> returns the direct children of a form node.</li> <li><code>getIterator()</code> return a recursive iterator for a form node.</li> <li><code>getNodeById($nodeId)</code> returns the node with the given id by searching for it in the node\u2019s children and recursively in all of their children. <code>contains($nodeId)</code> can be used to simply check if a node with the given id exists.</li> <li><code>hasValidationErrors()</code> checks if a form node or any of its children has a validation error (see <code>IFormField::getValidationErrors()</code>).</li> <li><code>readValues()</code> recursively calls <code>IFormParentNode::readValues()</code> and <code>IFormField::readValue()</code> on its children.</li> </ul>"},{"location":"php/api/form_builder/structure/#iformelement","title":"<code>IFormElement</code>","text":"<p><code>IFormElement</code> extends <code>IFormNode</code> for such elements of a form that can have a description and a label and it requires the following methods:</p> <ul> <li><code>label($languageItem = null, array $variables = [])</code> and <code>getLabel()</code> can be used to set and get the label of the form element. <code>requiresLabel()</code> can be checked if the form element requires a label. A label-less form element that requires a label will prevent the form from being rendered by throwing an exception.</li> <li><code>description($languageItem = null, array $variables = [])</code> and <code>getDescription()</code> can be used to set and get the description of the form element.</li> </ul>"},{"location":"php/api/form_builder/structure/#iobjecttypeformnode","title":"<code>IObjectTypeFormNode</code>","text":"<p><code>IObjectTypeFormField</code> has to be implemented by form nodes that rely on a object type of a specific object type definition in order to function. The implementing class has to implement the methods <code>objectType($objectType)</code>, <code>getObjectType()</code>, and <code>getObjectTypeDefinition()</code>. <code>TObjectTypeFormNode</code> provides a default implementation of these three methods.</p>"},{"location":"php/api/form_builder/structure/#customformnode","title":"<code>CustomFormNode</code>","text":"<p><code>CustomFormNode</code> is a form node whose contents can be set directly via <code>content($content)</code>.</p> <p>This class should generally not be relied on. Instead, <code>TemplateFormNode</code> should be used.</p> <p>Example:</p> <pre><code>CustomFormNode::create('example')\n ->content('html code')\n</code></pre>"},{"location":"php/api/form_builder/structure/#templateformnode","title":"<code>TemplateFormNode</code>","text":"<p><code>TemplateFormNode</code> is a form node whose contents are read from a template. <code>TemplateFormNode</code> has the following additional methods:</p> <ul> <li><code>application($application)</code> and <code>getApplicaton()</code> can be used to set and get the abbreviation of the application the shown template belongs to. If no template has been set explicitly, <code>getApplicaton()</code> returns <code>wcf</code>.</li> <li><code>templateName($templateName)</code> and <code>getTemplateName()</code> can be used to set and get the name of the template containing the node contents. If no template has been set and the node is rendered, an exception will be thrown.</li> <li><code>variables(array $variables)</code> and <code>getVariables()</code> can be used to set and get additional variables passed to the template.</li> </ul> <p>Example:</p> <pre><code>TemplateFormNode::create('example')\n ->templateName('example_template_name')\n</code></pre>"},{"location":"php/api/form_builder/structure/#form-document","title":"Form Document","text":"<p>A form document object represents the form as a whole and has to implement the <code>IFormDocument</code> interface. WoltLab Suite provides a default implementation with the <code>FormDocument</code> class. <code>IFormDocument</code> should not be implemented directly but instead <code>FormDocument</code> should be extended to avoid issues if the <code>IFormDocument</code> interface changes in the future.</p> <p><code>IFormDocument</code> extends <code>IFormParentNode</code> and requires the following additional methods:</p> <ul> <li><code>action($action)</code> and <code>getAction()</code> can be used set and get the <code>action</code> attribute of the <code><form></code> HTML element.</li> <li><code>addButton(IFormButton $button)</code> and <code>getButtons()</code> can be used add and get form buttons that are shown at the bottom of the form. <code>addDefaultButton($addDefaultButton)</code> and <code>hasDefaultButton()</code> can be used to set and check if the form has the default button which is added by default unless specified otherwise. Each implementing class may define its own default button. <code>FormDocument</code> has a button with id <code>submitButton</code>, label <code>wcf.global.button.submit</code>, access key <code>s</code>, and CSS class <code>buttonPrimary</code> as its default button. </li> <li><code>ajax($ajax)</code> and <code>isAjax()</code> can be used to set and check if the form document is requested via an AJAX request or processes data via an AJAX request. These methods are helpful for form fields that behave differently when providing data via AJAX.</li> <li><code>build()</code> has to be called once after all nodes have been added to this document to trigger <code>IFormNode::populate()</code>.</li> <li> <p><code>formMode($formMode)</code> and <code>getFormMode()</code> sets the form mode. Possible form modes are:</p> </li> <li> <p><code>IFormDocument::FORM_MODE_CREATE</code> has to be used when the form is used to create a new object.</p> </li> <li><code>IFormDocument::FORM_MODE_UPDATE</code> has to be used when the form is used to edit an existing object.</li> <li><code>getData()</code> returns the array containing the form data and which is passed as the <code>$parameters</code> argument of the constructor of a database object action object.</li> <li><code>getDataHandler()</code> returns the data handler for this document that is used to process the field data into a parameters array for the constructor of a database object action object.</li> <li><code>getEnctype()</code> returns the encoding type of the form. If the form contains a <code>IFileFormField</code>, <code>multipart/form-data</code> is returned, otherwise <code>null</code> is returned.</li> <li><code>loadValues(array $data, IStorableObject $object)</code> is used when editing an existing object to set the form field values by calling <code>IFormField::loadValue()</code> for all form fields. Additionally, the form mode is set to <code>IFormDocument::FORM_MODE_UPDATE</code>.</li> <li>5.4+ <code>markRequiredFields(bool $markRequiredFields = true): self</code> and <code>marksRequiredFields(): bool</code> can be used to set and check whether fields that are required are marked (with an asterisk in the label) in the output.</li> <li><code>method($method)</code> and <code>getMethod()</code> can be used to set and get the <code>method</code> attribute of the <code><form></code> HTML element. By default, the method is <code>post</code>.</li> <li><code>prefix($prefix)</code> and <code>getPrefix()</code> can be used to set and get a global form prefix that is prepended to form elements\u2019 names and ids to avoid conflicts with other forms. By default, the prefix is an empty string. If a prefix of <code>foo</code> is set, <code>getPrefix()</code> returns <code>foo_</code> (additional trailing underscore).</li> <li><code>requestData(array $requestData)</code>, <code>getRequestData($index = null)</code>, and <code>hasRequestData($index = null)</code> can be used to set, get and check for specific request data. In most cases, the relevant request data is the <code>$_POST</code> array. In default AJAX requests handled by database object actions, however, the request data generally is in <code>AbstractDatabaseObjectAction::$parameters</code>. By default, <code>$_POST</code> is the request data.</li> </ul> <p>The last aspect is relevant for <code>DialogFormDocument</code> objects. <code>DialogFormDocument</code> is a specialized class for forms in dialogs that, in contrast to <code>FormDocument</code> do not require an <code>action</code> to be set. Additionally, <code>DialogFormDocument</code> provides the <code>cancelable($cancelable = true)</code> and <code>isCancelable()</code> methods used to determine if the dialog from can be canceled. By default, dialog forms are cancelable.</p>"},{"location":"php/api/form_builder/structure/#form-button","title":"Form Button","text":"<p>A form button object represents a button shown at the end of the form that, for example, submits the form. Every form button has to implement the <code>IFormButton</code> interface that extends <code>IFormChildNode</code> and <code>IFormElement</code>. <code>IFormButton</code> requires four methods to be implemented:</p> <ul> <li><code>accessKey($accessKey)</code> and <code>getAccessKey()</code> can be used to set and get the access key with which the form button can be activated. By default, form buttons have no access key set.</li> <li><code>submit($submitButton)</code> and <code>isSubmit()</code> can be used to set and check if the form button is a submit button. A submit button is an <code>input[type=submit]</code> element. Otherwise, the button is a <code>button</code> element. </li> </ul>"},{"location":"php/api/form_builder/structure/#form-container","title":"Form Container","text":"<p>A form container object represents a container for other form containers or form field directly. Every form container has to implement the <code>IFormContainer</code> interface which requires the following method:</p> <ul> <li><code>loadValues(array $data, IStorableObject $object)</code> is called by <code>IFormDocument::loadValuesFromObject()</code> to inform the container that object data is loaded. This method is not intended to generally call <code>IFormField::loadValues()</code> on its form field children as these methods are already called by <code>IFormDocument::loadValuesFromObject()</code>. This method is intended for specialized form containers with more complex logic.</li> </ul> <p>There are multiple default container implementations:</p> <ol> <li><code>FormContainer</code> is the default implementation of <code>IFormContainer</code>.</li> <li><code>TabMenuFormContainer</code> represents the container of tab menu, while</li> <li><code>TabFormContainer</code> represents a tab of a tab menu and</li> <li><code>TabTabMenuFormContainer</code> represents a tab of a tab menu that itself contains a tab menu.</li> <li>The children of <code>RowFormContainer</code> are shown in a row and should use <code>col-*</code> classes.</li> <li>The children of <code>RowFormFieldContainer</code> are also shown in a row but does not show the labels and descriptions of the individual form fields. Instead of the individual labels and descriptions, the container's label and description is shown and both span all of fields.</li> <li><code>SuffixFormFieldContainer</code> can be used for one form field with a second selection form field used as a suffix.</li> </ol> <p>The methods of the interfaces that <code>FormContainer</code> is implementing are well documented, but here is a short overview of the most important methods when setting up a form or extending a form with an event listener:</p> <ul> <li><code>appendChild(IFormChildNode $child)</code>, <code>appendChildren(array $children)</code>, and <code>insertBefore(IFormChildNode $child, $referenceNodeId)</code> are used to insert new children into the form container.</li> <li><code>description($languageItem = null, array $variables = [])</code> and <code>label($languageItem = null, array $variables = [])</code> are used to set the description and the label or title of the form container.</li> </ul> <p>Example:</p> <pre><code>$form->appendChild(\n FormContainer::create('example')\n ->appendChildren([ ... ])\n );\n</code></pre>"},{"location":"php/api/form_builder/structure/#form-field","title":"Form Field","text":"<p>A form field object represents a concrete form field that allows entering data. Every form field has to implement the <code>IFormField</code> interface which extends <code>IFormChildNode</code> and <code>IFormElement</code>.</p> <p><code>IFormField</code> requires the following additional methods:</p> <ul> <li><code>addValidationError(IFormFieldValidationError $error)</code> and <code>getValidationErrors()</code> can be used to get and set validation errors of the form field (see form validation).</li> <li><code>addValidator(IFormFieldValidator $validator)</code>, <code>getValidators()</code>, <code>removeValidator($validatorId)</code>, and <code>hasValidator($validatorId)</code> can be used to get, set, remove, and check for validators for the form field (see form validation).</li> <li><code>getFieldHtml()</code> returns the field's HTML output without the surrounding <code>dl</code> structure.</li> <li><code>objectProperty($objectProperty)</code> and <code>getObjectProperty()</code> can be used to get and set the object property that the field represents. When setting the object property is set to an empty string, the previously set object property is unset. If no object property has been set, the field\u2019s (non-prefixed) id is returned.</li> </ul> <p>The object property allows having different fields (requiring different ids) that represent the same object property which is handy when available options of the field\u2019s value depend on another field. Having object property allows to define different fields for each value of the other field and to use form field dependencies to only show the appropriate field. - <code>readValue()</code> reads the form field value from the request data after the form is submitted. - <code>required($required = true)</code> and <code>isRequired()</code> can be used to determine if the form field has to be filled out. By default, form fields do not have to be filled out. - <code>value($value)</code> and <code>getSaveValue()</code> can be used to get and set the value of the form field to be used outside of the context of forms. <code>getValue()</code>, in contrast, returns the internal representation of the form field\u2019s value. In general, the internal representation is only relevant when validating the value in additional validators. <code>loadValue(array $data, IStorableObject $object)</code> extracts the form field value from the given data array (and additional, non-editable data from the object if the field needs them).</p> <p><code>AbstractFormField</code> provides default implementations of many of the listed methods above and should be extended instead of implementing <code>IFormField</code> directly.</p> <p>An overview of the form fields provided by default can be found here.</p>"},{"location":"php/api/form_builder/structure/#form-field-interfaces-and-traits","title":"Form Field Interfaces and Traits","text":"<p>WoltLab Suite Core provides a variety of interfaces and matching traits with default implementations for several common features of form fields:</p>"},{"location":"php/api/form_builder/structure/#iattributeformfield","title":"<code>IAttributeFormField</code>","text":"<p><code>IAttributeFormField</code> has to be implemented by form fields for which attributes can be added to the actual form element (in addition to adding attributes to the surrounding element via the attribute-related methods of <code>IFormNode</code>). The implementing class has to implement the methods <code>fieldAttribute(string $name, string $value = null): self</code> and <code>getFieldAttribute(string $name): self</code>/<code>getFieldAttributes(): array</code>, which are used to add and get the attributes, respectively. Additionally, <code>hasFieldAttribute(string $name): bool</code> has to implemented to check if a certain attribute is present, <code>removeFieldAttribute(string $name): self</code> to remove an attribute, and <code>static validateFieldAttribute(string $name)</code> to check if the attribute is valid for this specific class. <code>TAttributeFormField</code> provides a default implementation of these methods and <code>TInputAttributeFormField</code> specializes the trait for <code>input</code>-based form fields. These two traits also ensure that if a specific interface that handles a specific attribute is implemented, like <code>IAutoCompleteFormField</code> handling <code>autocomplete</code>, this attribute cannot be set with this API. Instead, the dedicated API provided by the relevant interface has to be used.</p>"},{"location":"php/api/form_builder/structure/#iautocompleteformfield","title":"<code>IAutoCompleteFormField</code>","text":"<p><code>IAutoCompleteFormField</code> has to be implemented by form fields that support the <code>autocomplete</code> attribute. The implementing class has to implement the methods <code>autoComplete(?string $autoComplete): self</code> and <code>getAutoComplete(): ?string</code>, which are used to set and get the autocomplete value, respectively. <code>TAutoCompleteFormField</code> provides a default implementation of these two methods and <code>TTextAutoCompleteFormField</code> specializes the trait for text form fields. When using <code>TAutoCompleteFormField</code>, you have to implement the <code>getValidAutoCompleteTokens(): array</code> method which returns all valid <code>autocomplete</code> tokens.</p>"},{"location":"php/api/form_builder/structure/#iautofocusformfield","title":"<code>IAutoFocusFormField</code>","text":"<p><code>IAutoFocusFormField</code> has to be implemented by form fields that can be auto-focused. The implementing class has to implement the methods <code>autoFocus($autoFocus = true)</code> and <code>isAutoFocused()</code>. By default, form fields are not auto-focused. <code>TAutoFocusFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#icssclassformfield","title":"<code>ICssClassFormField</code>","text":"<p><code>ICssClassFormField</code> has to be implemented by form fields for which CSS classes can be added to the actual form element (in addition to adding CSS classes to the surrounding element via the class-related methods of <code>IFormNode</code>). The implementing class has to implement the methods <code>addFieldClass(string $class): self</code>/<code>addFieldClasses(array $classes): self</code> and <code>getFieldClasses(): array</code>, which are used to add and get the CSS classes, respectively. Additionally, <code>hasFieldClass(string $class): bool</code> has to implemented to check if a certain CSS class is present and <code>removeFieldClass(string $class): self</code> to remove a CSS class. <code>TCssClassFormField</code> provides a default implementation of these methods.</p>"},{"location":"php/api/form_builder/structure/#ifileformfield","title":"<code>IFileFormField</code>","text":"<p><code>IFileFormField</code> has to be implemented by every form field that uploads files so that the <code>enctype</code> attribute of the form document is <code>multipart/form-data</code> (see <code>IFormDocument::getEnctype()</code>).</p>"},{"location":"php/api/form_builder/structure/#ifilterableselectionformfield","title":"<code>IFilterableSelectionFormField</code>","text":"<p><code>IFilterableSelectionFormField</code> extends <code>ISelectionFormField</code> by the possibilty for users when selecting the value(s) to filter the list of available options. The implementing class has to implement the methods <code>filterable($filterable = true)</code> and <code>isFilterable()</code>. <code>TFilterableSelectionFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#ii18nformfield","title":"<code>II18nFormField</code>","text":"<p><code>II18nFormField</code> has to be implemented by form fields if the form field value can be entered separately for all available languages. The implementing class has to implement the following methods:</p> <ul> <li><code>i18n($i18n = true)</code> and <code>isI18n()</code> can be used to set whether a specific instance of the class actually supports multilingual input.</li> <li><code>i18nRequired($i18nRequired = true)</code> and <code>isI18nRequired()</code> can be used to set whether a specific instance of the class requires separate values for all languages.</li> <li><code>languageItemPattern($pattern)</code> and <code>getLanguageItemPattern()</code> can be used to set the pattern/regular expression for the language item used to save the multilingual values.</li> <li><code>hasI18nValues()</code> and <code>hasPlainValue()</code> check if the current value is a multilingual or monolingual value.</li> </ul> <p><code>TI18nFormField</code> provides a default implementation of these eight methods and additional default implementations of some of the <code>IFormField</code> methods. If multilingual input is enabled for a specific form field, classes using <code>TI18nFormField</code> register a custom form field data processor to add the array with multilingual input into the <code>$parameters</code> array directly using <code>{$objectProperty}_i18n</code> as the array key. If multilingual input is enabled but only a monolingual value is entered, the custom form field data processor does nothing and the form field\u2019s value is added by the <code>DefaultFormDataProcessor</code> into the <code>data</code> sub-array of the <code>$parameters</code> array.</p> <p><code>TI18nFormField</code> already provides a default implementation of <code>IFormField::validate()</code>.</p>"},{"location":"php/api/form_builder/structure/#iimmutableformfield","title":"<code>IImmutableFormField</code>","text":"<p><code>IImmutableFormField</code> has to be implemented by form fields that support being displayed but whose value cannot be changed. The implementing class has to implement the methods <code>immutable($immutable = true)</code> and <code>isImmutable()</code> that can be used to determine if the value of the form field is mutable or immutable. By default, form field are mutable.</p>"},{"location":"php/api/form_builder/structure/#iinputmodeformfield","title":"<code>IInputModeFormField</code>","text":"<p><code>IInputModeFormField</code> has to be implemented by form fields that support the <code>inputmode</code> attribute. The implementing class has to implement the methods <code>inputMode(?string $inputMode): self</code> and <code>getInputMode(): ?string</code>, which are used to set and get the input mode, respectively. <code>TInputModeFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#imaximumformfield","title":"<code>IMaximumFormField</code>","text":"<p><code>IMaximumFormField</code> has to be implemented by form fields if the entered value must have a maximum value. The implementing class has to implement the methods <code>maximum($maximum = null)</code> and <code>getMaximum()</code>. A maximum of <code>null</code> signals that no maximum value has been set. <code>TMaximumFormField</code> provides a default implementation of these two methods.</p> <p>The implementing class has to validate the entered value against the maximum value manually.</p>"},{"location":"php/api/form_builder/structure/#imaximumlengthformfield","title":"<code>IMaximumLengthFormField</code>","text":"<p><code>IMaximumLengthFormField</code> has to be implemented by form fields if the entered value must have a maximum length. The implementing class has to implement the methods <code>maximumLength($maximumLength = null)</code>, <code>getMaximumLength()</code>, and <code>validateMaximumLength($text, Language $language = null)</code>. A maximum length of <code>null</code> signals that no maximum length has been set. <code>TMaximumLengthFormField</code> provides a default implementation of these two methods.</p> <p>The implementing class has to validate the entered value against the maximum value manually by calling <code>validateMaximumLength()</code>.</p>"},{"location":"php/api/form_builder/structure/#iminimumformfield","title":"<code>IMinimumFormField</code>","text":"<p><code>IMinimumFormField</code> has to be implemented by form fields if the entered value must have a minimum value. The implementing class has to implement the methods <code>minimum($minimum = null)</code> and <code>getMinimum()</code>. A minimum of <code>null</code> signals that no minimum value has been set. <code>TMinimumFormField</code> provides a default implementation of these three methods.</p> <p>The implementing class has to validate the entered value against the minimum value manually.</p>"},{"location":"php/api/form_builder/structure/#iminimumlengthformfield","title":"<code>IMinimumLengthFormField</code>","text":"<p><code>IMinimumLengthFormField</code> has to be implemented by form fields if the entered value must have a minimum length. The implementing class has to implement the methods <code>minimumLength($minimumLength = null)</code>, <code>getMinimumLength()</code>, and <code>validateMinimumLength($text, Language $language = null)</code>. A minimum length of <code>null</code> signals that no minimum length has been set. <code>TMinimumLengthFormField</code> provides a default implementation of these three methods.</p> <p>The implementing class has to validate the entered value against the minimum value manually by calling <code>validateMinimumLength()</code>.</p>"},{"location":"php/api/form_builder/structure/#imultipleformfield","title":"<code>IMultipleFormField</code>","text":"<p><code>IMinimumLengthFormField</code> has to be implemented by form fields that support selecting or setting multiple values. The implementing class has to implement the following methods:</p> <ul> <li><code>multiple($multiple = true)</code> and <code>allowsMultiple()</code> can be used to set whether a specific instance of the class actually should support multiple values. By default, multiple values are not supported.</li> <li><code>minimumMultiples($minimum)</code> and <code>getMinimumMultiples()</code> can be used to set the minimum number of values that have to be selected/entered. By default, there is no required minimum number of values.</li> <li><code>maximumMultiples($minimum)</code> and <code>getMaximumMultiples()</code> can be used to set the maximum number of values that have to be selected/entered. By default, there is no maximum number of values. <code>IMultipleFormField::NO_MAXIMUM_MULTIPLES</code> is returned if no maximum number of values has been set and it can also be used to unset a previously set maximum number of values.</li> </ul> <p><code>TMultipleFormField</code> provides a default implementation of these six methods and classes using <code>TMultipleFormField</code> register a custom form field data processor to add the <code>HtmlInputProcessor</code> object with the text into the <code>$parameters</code> array directly using <code>{$objectProperty}_htmlInputProcessor</code> as the array key.</p> <p>The implementing class has to validate the values against the minimum and maximum number of values manually.</p>"},{"location":"php/api/form_builder/structure/#inullableformfield","title":"<code>INullableFormField</code>","text":"<p><code>INullableFormField</code> has to be implemented by form fields that support <code>null</code> as their (empty) value. The implementing class has to implement the methods <code>nullable($nullable = true)</code> and <code>isNullable()</code>. <code>TNullableFormField</code> provides a default implementation of these two methods.</p> <p><code>null</code> should be returned by <code>IFormField::getSaveValue()</code> is the field is considered empty and the form field has been set as nullable.</p>"},{"location":"php/api/form_builder/structure/#ipackagesformfield","title":"<code>IPackagesFormField</code>","text":"<p><code>IPackagesFormField</code> has to be implemented by form fields that, in some way, considers packages whose ids may be passed to the field object. The implementing class has to implement the methods <code>packageIDs(array $packageIDs)</code> and <code>getPackageIDs()</code>. <code>TPackagesFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#ipatternformfield","title":"<code>IPatternFormField</code>","text":"<p><code>IPatternFormField</code> has to be implemented by form fields that support the <code>pattern</code> attribute. The implementing class has to implement the methods <code>pattern(?string $pattern): self</code> and <code>getPattern(): ?string</code>, which are used to set and get the pattern, respectively. <code>TPatternFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#iplaceholderformfield","title":"<code>IPlaceholderFormField</code>","text":"<p><code>IPlaceholderFormField</code> has to be implemented by form fields that support a placeholder value for empty fields. The implementing class has to implement the methods <code>placeholder($languageItem = null, array $variables = [])</code> and <code>getPlaceholder()</code>. <code>TPlaceholderFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#iselectionformfield","title":"<code>ISelectionFormField</code>","text":"<p><code>ISelectionFormField</code> has to be implemented by form fields with a predefined set of possible values. The implementing class has to implement the getter and setter methods <code>options($options, $nestedOptions = false, $labelLanguageItems = true)</code> and <code>getOptions()</code> and additionally two methods related to nesting, i.e. whether the selectable options have a hierarchy: <code>supportsNestedOptions()</code> and <code>getNestedOptions()</code>. <code>TSelectionFormField</code> provides a default implementation of these four methods.</p>"},{"location":"php/api/form_builder/structure/#isuffixedformfield","title":"<code>ISuffixedFormField</code>","text":"<p><code>ISuffixedFormField</code> has to be implemented by form fields that support supports displaying a suffix behind the actual input field. The implementing class has to implement the methods <code>suffix($languageItem = null, array $variables = [])</code> and <code>getSuffix()</code>. <code>TSuffixedFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#tdefaultidformfield","title":"<code>TDefaultIdFormField</code>","text":"<p>Form fields that have a default id have to use <code>TDefaultIdFormField</code> and have to implement the method <code>getDefaultId()</code>.</p>"},{"location":"php/api/form_builder/structure/#displaying-forms","title":"Displaying Forms","text":"<p>The only thing to do in a template to display the whole form including all of the necessary JavaScript is to put</p> <pre><code>{unsafe:$form->getHtml()}\n</code></pre> <p>into the template file at the relevant position.</p>"},{"location":"php/api/form_builder/validation_data/","title":"Form Validation and Form Data","text":""},{"location":"php/api/form_builder/validation_data/#form-validation","title":"Form Validation","text":"<p>Every form field class has to implement <code>IFormField::validate()</code> according to their internal logic of what constitutes a valid value. If a certain constraint for the value is not met, a form field validation error object is added to the form field. Form field validation error classes have to implement the interface <code>IFormFieldValidationError</code>.</p> <p>In addition to intrinsic validations like checking the length of the value of a text form field, in many cases, there are additional constraints specific to the form like ensuring that the text is not already used by a different object of the same database object class. Such additional validations can be added to (and removed from) the form field via implementations of the <code>IFormFieldValidator</code> interface.</p>"},{"location":"php/api/form_builder/validation_data/#iformfieldvalidationerror-formfieldvalidationerror","title":"<code>IFormFieldValidationError</code> / <code>FormFieldValidationError</code>","text":"<p><code>IFormFieldValidationError</code> requires the following methods:</p> <ul> <li><code>__construct($type, $languageItem = null, array $information = [])</code> creates a new validation error object for an error with the given type and message stored in the given language items. The information array is used when generating the error message.</li> <li><code>getHtml()</code> returns the HTML element representing the error that is shown to the user.</li> <li><code>getMessage()</code> returns the error message based on the language item and information array given in the constructor.</li> <li><code>getInformation()</code> and <code>getType()</code> are getters for the first and third parameter of the constructor.</li> </ul> <p><code>FormFieldValidationError</code> is a default implementation of the interface that shows the error in an <code>small.innerError</code> HTML element below the form field.</p> <p>Form field validation errors are added to form fields via the <code>IFormField::addValidationError(IFormFieldValidationError $error)</code> method.</p>"},{"location":"php/api/form_builder/validation_data/#iformfieldvalidator-formfieldvalidator","title":"<code>IFormFieldValidator</code> / <code>FormFieldValidator</code>","text":"<p><code>IFormFieldValidator</code> requires the following methods:</p> <ul> <li><code>__construct($id, callable $validator)</code> creates a new validator with the given id that passes the validated form field to the given callable that does the actual validation. <code>static validateId($id)</code> is used to check if the given id is valid.</li> <li><code>__invoke(IFormField $field)</code> is used when the form field is validated to execute the validator.</li> <li><code>getId()</code> returns the id of the validator.</li> </ul> <p><code>FormFieldValidator</code> is a default implementation of the interface.</p> <p>Form field validators are added to form fields via the <code>addValidator(IFormFieldValidator $validator)</code> method.</p>"},{"location":"php/api/form_builder/validation_data/#example","title":"Example","text":"<p>The following source code adds a validator that validates whether the value in the input field matches a specific value.</p> <pre><code>$container->appendChildren([\n FooField::create('a')\n ->addValidator(new FormFieldValidator('b', function (FooField $formField) {\n if ($formField->getValue() != 'value') {\n $formField->addValidationError(\n new FormFieldValidationError(\n 'type',\n 'phrase'\n )\n );\n }\n })),\n]);\n</code></pre>"},{"location":"php/api/form_builder/validation_data/#form-data","title":"Form Data","text":"<p>After a form is successfully validated, the data of the form fields (returned by <code>IFormDocument::getData()</code>) have to be extracted which is the job of the <code>IFormDataHandler</code> object returned by <code>IFormDocument::getDataHandler()</code>. Form data handlers themselves, however, are only iterating through all <code>IFormDataProcessor</code> instances that have been registered with the data handler.</p>"},{"location":"php/api/form_builder/validation_data/#iformdatahandler-formdatahandler","title":"<code>IFormDataHandler</code> / <code>FormDataHandler</code>","text":"<p><code>IFormDataHandler</code> requires the following methods:</p> <ul> <li><code>addProcessor(IFormDataProcessor $processor)</code> adds a new data processor to the data handler.</li> <li><code>getFormData(IFormDocument $document)</code> returns the data of the given form by applying all registered data handlers on the form.</li> <li><code>getObjectData(IFormDocument $document, IStorableObject $object)</code> returns the data of the given object which will be used to populate the form field values of the given form.</li> </ul> <p><code>FormDataHandler</code> is the default implementation of this interface and should also be extended instead of implementing the interface directly.</p>"},{"location":"php/api/form_builder/validation_data/#iformdataprocessor-defaultformdataprocessor","title":"<code>IFormDataProcessor</code> / <code>DefaultFormDataProcessor</code>","text":"<p><code>IFormDataProcessor</code> requires the following methods:</p> <ul> <li><code>processFormData(IFormDocument $document, array $parameters)</code> is called by <code>IFormDataHandler::getFormData()</code>. The method processes the given parameters array and returns the processed version.</li> <li><code>processObjectData(IFormDocument $document, array $data, IStorableObject $object)</code> is called by <code>IFormDataHandler::getObjectData()</code>. The method processes the given object data array and returns the processed version.</li> </ul> <p>When <code>FormDocument</code> creates its <code>FormDataHandler</code> instance, it automatically registers an <code>DefaultFormDataProcessor</code> object as the first data processor. <code>DefaultFormDataProcessor</code> puts the save value of all form fields that are available and have a save value into <code>$parameters['data']</code> using the form field\u2019s object property as the array key.</p> <p><code>IFormDataProcessor</code> should not be implemented directly. Instead, <code>AbstractFormDataProcessor</code> should be extended.</p> <p>All form data is put into the <code>data</code> sub-array so that the whole <code>$parameters</code> array can be passed to a database object action object that requires the actual database object data to be in the <code>data</code> sub-array.</p> <p>When adding a data processor to a form, make sure to add the data processor after the form has been built.</p>"},{"location":"php/api/form_builder/validation_data/#additional-data-processors","title":"Additional Data Processors","text":""},{"location":"php/api/form_builder/validation_data/#customformdataprocessor","title":"<code>CustomFormDataProcessor</code>","text":"<p>As mentioned above, the data in the <code>data</code> sub-array is intended to directly create or update the database object with. As these values are used in the database query directly, these values cannot contain arrays. Several form fields, however, store and return their data in form of arrays. Thus, this data cannot be returned by <code>IFormField::getSaveValue()</code> so that <code>IFormField::hasSaveValue()</code> returns <code>false</code> and the form field\u2019s data is not collected by the standard <code>DefaultFormDataProcessor</code> object.</p> <p>Instead, such form fields register a <code>CustomFormDataProcessor</code> in their <code>IFormField::populate()</code> method that inserts the form field value into the <code>$parameters</code> array directly. This way, the relevant database object action method has access to the data to save it appropriately.</p> <p>The constructor of <code>CustomFormDataProcessor</code> requires an id (that is primarily used in error messages during the validation of the second parameter) and callables for <code>IFormDataProcessor::processFormData()</code> and <code>IFormDataProcessor::processObjectData()</code> which are passed the same parameters as the <code>IFormDataProcessor</code> methods. Only one of the callables has to be given, the other one then defaults to simply returning the relevant array unchanged.</p>"},{"location":"php/api/form_builder/validation_data/#example_1","title":"Example","text":"<p>The following source code adds a custom processor that handles the return of <code>MultilineItemListFormField</code> and converts the content of an array into a multiline string in order to store it in the database.</p> <pre><code>$form->getDataHandler()->addProcessor(\n new CustomFormDataProcessor(\n 'additionalItems',\n static function (IFormDocument $document, array $parameters) {\n $additionalItems = $document->getNodeById('additionalItems');\n \\assert($additionalItems instanceof MultilineItemListFormField);\n\n $value = $additionalItems->getValue();\n if ($value === null || $value === []) {\n $parameters['data']['additionalItems'] = null;\n } else {\n $parameters['data']['additionalItems'] = \\implode(\"\\n\", $value);\n }\n\n return $parameters;\n },\n static function (IFormDocument $document, array $data, IStorableObject $object) {\n if ($object->additionalItems !== null) {\n $data['additionalItems'] = \\explode(\"\\n\", $data['additionalItems']);\n }\n\n return $data;\n }\n )\n);\n</code></pre>"},{"location":"php/api/form_builder/validation_data/#voidformdataprocessor","title":"<code>VoidFormDataProcessor</code>","text":"<p>Some form fields might only exist to toggle the visibility of other form fields (via dependencies) but the data of form field itself is irrelevant. As <code>DefaultFormDataProcessor</code> collects the data of all form fields, an additional data processor in the form of a <code>VoidFormDataProcessor</code> can be added whose constructor <code>__construct($property, $isDataProperty = true)</code> requires the name of the relevant object property/form id and whether the form field value is stored in the <code>data</code> sub-array or directory in the <code>$parameters</code> array. When the data processor is invoked, it checks whether the relevant entry in the <code>$parameters</code> array exists and voids it by removing it from the array.</p>"},{"location":"tutorial/series/overview/","title":"Tutorial Series","text":"<p>In this tutorial series, we will code a package that allows administrators to create a registry of people. In this context, \"people\" does not refer to users registered on the website but anybody living, dead or fictional.</p> <p>We will start this tutorial series by creating a base structure for the package and then continue by adding further features step by step using different APIs. Note that in the context of this example, not every added feature might make perfect sense but the goal of this tutorial is not to create a useful package but to introduce you to WoltLab Suite.</p> <ul> <li>Part 1: Base Structure</li> <li>Part 2: Event and Template Listeners</li> <li>Part 3: Person Page and Comments</li> <li>Part 4: Box and Box Conditions</li> <li>Part 5: Person Information</li> <li>Part 6: Activity Points and Activity Events</li> </ul>"},{"location":"tutorial/series/part_1/","title":"Tutorial Series Part 1: Base Structure","text":"<p>In the first part of this tutorial series, we will lay out what the basic version of package should be able to do and how to implement these functions.</p>"},{"location":"tutorial/series/part_1/#package-functionality","title":"Package Functionality","text":"<p>The package should provide the following possibilities/functions:</p> <ul> <li>Sortable list of all people in the ACP</li> <li>Ability to add, edit and delete people in the ACP</li> <li>Restrict the ability to add, edit and delete people (in short: manage people) in the ACP</li> <li>Sortable list of all people in the front end</li> </ul>"},{"location":"tutorial/series/part_1/#used-components","title":"Used Components","text":"<p>We will use the following package installation plugins:</p> <ul> <li>acpTemplate package installation plugin,</li> <li>acpMenu package installation plugin,</li> <li>database package installation plugin,</li> <li>file package installation plugin,</li> <li>language package installation plugin,</li> <li>menuItem package installation plugin,</li> <li>page package installation plugin,</li> <li>template package installation plugin,</li> <li>userGroupOption package installation plugin,</li> </ul> <p>use database objects, create pages and use templates.</p>"},{"location":"tutorial/series/part_1/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure:</p> <pre><code>\u251c\u2500\u2500 acpMenu.xml\n\u251c\u2500\u2500 acptemplates\n\u2502 \u251c\u2500\u2500 personAdd.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.php\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u251c\u2500\u2500 form\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 PersonAddForm.class.php\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 PersonEditForm.class.php\n\u2502 \u2502 \u2514\u2500\u2500 page\n\u2502 \u2502 \u2514\u2500\u2500 PersonListPage.class.php\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 Person.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonAction.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonEditor.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonList.class.php\n\u2502 \u2514\u2500\u2500 page\n\u2502 \u2514\u2500\u2500 PersonListPage.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 menuItem.xml\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 page.xml\n\u251c\u2500\u2500 templates\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u2514\u2500\u2500 userGroupOption.xml\n</code></pre>"},{"location":"tutorial/series/part_1/#person-modeling","title":"Person Modeling","text":""},{"location":"tutorial/series/part_1/#database-table","title":"Database Table","text":"<p>As the first step, we have to model the people we want to manage with this package. As this is only an introductory tutorial, we will keep things simple and only consider the first and last name of a person. Thus, the database table we will store the people in only contains three columns:</p> <ol> <li><code>personID</code> is the unique numeric identifier of each person created,</li> <li><code>firstName</code> contains the first name of the person,</li> <li><code>lastName</code> contains the last name of the person.</li> </ol> <p>The first file for our package is the <code>install_com.woltlab.wcf.people.php</code> file used to create such a database table during package installation:</p> files/acp/database/install_com.woltlab.wcf.people.php <pre><code><?php\n\nuse wcf\\system\\database\\table\\column\\NotNullVarchar255DatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\ObjectIdDatabaseTableColumn;\nuse wcf\\system\\database\\table\\DatabaseTable;\nuse wcf\\system\\database\\table\\index\\DatabaseTablePrimaryIndex;\n\nreturn [\n DatabaseTable::create('wcf1_person')\n ->columns([\n ObjectIdDatabaseTableColumn::create('personID'),\n NotNullVarchar255DatabaseTableColumn::create('firstName'),\n NotNullVarchar255DatabaseTableColumn::create('lastName'),\n ])\n ->indices([\n DatabaseTablePrimaryIndex::create()\n ->columns(['personID']),\n ]),\n];\n</code></pre>"},{"location":"tutorial/series/part_1/#database-object","title":"Database Object","text":""},{"location":"tutorial/series/part_1/#person","title":"<code>Person</code>","text":"<p>In our PHP code, each person will be represented by an object of the following class:</p> files/lib/data/person/Person.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\DatabaseObject;\nuse wcf\\system\\request\\IRouteController;\n\n/**\n * Represents a person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @property-read int $personID unique id of the person\n * @property-read string $firstName first name of the person\n * @property-read string $lastName last name of the person\n */\nclass Person extends DatabaseObject implements IRouteController\n{\n /**\n * Returns the first and last name of the person if a person object is treated as a string.\n *\n * @return string\n */\n public function __toString()\n {\n return $this->getTitle();\n }\n\n /**\n * @inheritDoc\n */\n public function getTitle(): string\n {\n return $this->firstName . ' ' . $this->lastName;\n }\n}\n</code></pre> <p>The important thing here is that <code>Person</code> extends <code>DatabaseObject</code>. Additionally, we implement the <code>IRouteController</code> interface, which allows us to use <code>Person</code> objects to create links, and we implement PHP's magic __toString() method for convenience.</p> <p>For every database object, you need to implement three additional classes: an action class, an editor class and a list class.</p>"},{"location":"tutorial/series/part_1/#personaction","title":"<code>PersonAction</code>","text":"files/lib/data/person/PersonAction.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\AbstractDatabaseObjectAction;\n\n/**\n * Executes person-related actions.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @method Person create()\n * @method PersonEditor[] getObjects()\n * @method PersonEditor getSingleObject()\n */\nclass PersonAction extends AbstractDatabaseObjectAction\n{\n /**\n * @inheritDoc\n */\n protected $permissionsDelete = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n protected $requireACP = ['delete'];\n}\n</code></pre> <p>This implementation of <code>AbstractDatabaseObjectAction</code> is very basic and only sets the <code>$permissionsDelete</code> and <code>$requireACP</code> properties. This is done so that later on, when implementing the people list for the ACP, we can delete people simply via AJAX. <code>$permissionsDelete</code> has to be set to the permission needed in order to delete a person. We will later use the userGroupOption package installation plugin to create the <code>admin.content.canManagePeople</code> permission. <code>$requireACP</code> restricts deletion of people to the ACP.</p>"},{"location":"tutorial/series/part_1/#personeditor","title":"<code>PersonEditor</code>","text":"files/lib/data/person/PersonEditor.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\DatabaseObjectEditor;\n\n/**\n * Provides functions to edit people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @method static Person create(array $parameters = [])\n * @method Person getDecoratedObject()\n * @mixin Person\n */\nclass PersonEditor extends DatabaseObjectEditor\n{\n /**\n * @inheritDoc\n */\n protected static $baseClass = Person::class;\n}\n</code></pre> <p>This implementation of <code>DatabaseObjectEditor</code> fulfills the minimum requirement for a database object editor: setting the static <code>$baseClass</code> property to the database object class name.</p>"},{"location":"tutorial/series/part_1/#personlist","title":"<code>PersonList</code>","text":"files/lib/data/person/PersonList.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\DatabaseObjectList;\n\n/**\n * Represents a list of people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @method Person current()\n * @method Person[] getObjects()\n * @method Person|null search($objectID)\n * @property Person[] $objects\n */\nclass PersonList extends DatabaseObjectList\n{\n}\n</code></pre> <p>Due to the default implementation of <code>DatabaseObjectList</code>, our <code>PersonList</code> class just needs to extend it and everything else is either automatically set by the code of <code>DatabaseObjectList</code> or, in the case of properties and methods, provided by that class.</p>"},{"location":"tutorial/series/part_1/#acp","title":"ACP","text":"<p>Next, we will take care of the controllers and views for the ACP. In total, we need three each:</p> <ol> <li>page to list people,</li> <li>form to add people, and</li> <li>form to edit people.</li> </ol> <p>Before we create the controllers and views, let us first create the menu items for the pages in the ACP menu.</p>"},{"location":"tutorial/series/part_1/#acp-menu","title":"ACP Menu","text":"<p>We need to create three menu items:</p> <ol> <li>a \u201cparent\u201d menu item on the second level of the ACP menu item tree,</li> <li>a third level menu item for the people list page, and</li> <li>a fourth level menu item for the form to add new people.</li> </ol> acpMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/acpMenu.xsd\">\n <import>\n <acpmenuitem name=\"wcf.acp.menu.link.person\">\n <parent>wcf.acp.menu.link.content</parent>\n </acpmenuitem>\n <acpmenuitem name=\"wcf.acp.menu.link.person.list\">\n <controller>wcf\\acp\\page\\PersonListPage</controller>\n <parent>wcf.acp.menu.link.person</parent>\n <permissions>admin.content.canManagePeople</permissions>\n </acpmenuitem>\n <acpmenuitem name=\"wcf.acp.menu.link.person.add\">\n <controller>wcf\\acp\\form\\PersonAddForm</controller>\n <parent>wcf.acp.menu.link.person.list</parent>\n <permissions>admin.content.canManagePeople</permissions>\n <icon>plus</icon>\n </acpmenuitem>\n </import>\n</data>\n</code></pre> <p>We choose <code>wcf.acp.menu.link.content</code> as the parent menu item for the first menu item <code>wcf.acp.menu.link.person</code> because the people we are managing is just one form of content. The fourth level menu item <code>wcf.acp.menu.link.person.add</code> will only be shown as an icon and thus needs an additional element <code>icon</code> which takes a FontAwesome icon class as value.</p>"},{"location":"tutorial/series/part_1/#people-list","title":"People List","text":"<p>To list the people in the ACP, we need a <code>PersonListPage</code> class and a <code>personList</code> template.</p>"},{"location":"tutorial/series/part_1/#personlistpage","title":"<code>PersonListPage</code>","text":"files/lib/acp/page/PersonListPage.class.php <pre><code><?php\n\nnamespace wcf\\acp\\page;\n\nuse wcf\\data\\person\\PersonList;\nuse wcf\\page\\SortablePage;\n\n/**\n * Shows the list of people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Page\n */\nclass PersonListPage extends SortablePage\n{\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.list';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public $objectListClassName = PersonList::class;\n\n /**\n * @inheritDoc\n */\n public $validSortFields = ['personID', 'firstName', 'lastName'];\n}\n</code></pre> <p>As WoltLab Suite Core already provides a powerful default implementation of a sortable page, our work here is minimal:</p> <ol> <li>We need to set the active ACP menu item via the <code>$activeMenuItem</code>.</li> <li><code>$neededPermissions</code> contains a list of permissions of which the user needs to have at least one in order to see the person list. We use the same permission for both the menu item and the page.</li> <li>The database object list class whose name is provided via <code>$objectListClassName</code> and that handles fetching the people from database is the <code>PersonList</code> class, which we have already created.</li> <li>To validate the sort field passed with the request, we set <code>$validSortFields</code> to the available database table columns.</li> </ol>"},{"location":"tutorial/series/part_1/#personlisttpl","title":"<code>personList.tpl</code>","text":"acptemplates/personList.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.list'}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.list{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonAdd'}{/link}\" class=\"button\">{icon name='plus'} <span>{lang}wcf.acp.menu.link.person.add{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{if $pages > 1}\n <div class=\"paginationTop\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n{/if}\n\n{if $objects|count}\n <div class=\"section tabularBox\">\n <table class=\"table jsObjectActionContainer\" data-object-action-class-name=\"wcf\\data\\person\\PersonAction\">\n <thead>\n <tr>\n <th class=\"columnID columnPersonID{if $sortField == 'personID'} active {$sortOrder}{/if}\" colspan=\"2\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=personID&sortOrder={if $sortField == 'personID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.global.objectID{/lang}</a></th>\n <th class=\"columnTitle columnFirstName{if $sortField == 'firstName'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=firstName&sortOrder={if $sortField == 'firstName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.firstName{/lang}</a></th>\n <th class=\"columnTitle columnLastName{if $sortField == 'lastName'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=lastName&sortOrder={if $sortField == 'lastName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.lastName{/lang}</a></th>\n\n {event name='columnHeads'}\n </tr>\n </thead>\n\n <tbody class=\"jsReloadPageWhenEmpty\">\n {foreach from=$objects item=person}\n <tr class=\"jsObjectActionObject\" data-object-id=\"{$person->getObjectID()}\">\n <td class=\"columnIcon\">\n <a href=\"{link controller='PersonEdit' object=$person}{/link}\" title=\"{lang}wcf.global.button.edit{/lang}\" class=\"jsTooltip\">{icon name='pencil'}</a>\n {objectAction action=\"delete\" objectTitle=$person->getTitle()}\n\n {event name='rowButtons'}\n </td>\n <td class=\"columnID\">{#$person->personID}</td>\n <td class=\"columnTitle columnFirstName\"><a href=\"{link controller='PersonEdit' object=$person}{/link}\">{$person->firstName}</a></td>\n <td class=\"columnTitle columnLastName\"><a href=\"{link controller='PersonEdit' object=$person}{/link}\">{$person->lastName}</a></td>\n\n {event name='columns'}\n </tr>\n {/foreach}\n </tbody>\n </table>\n </div>\n\n <footer class=\"contentFooter\">\n {if $pages > 1}\n <div class=\"paginationBottom\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n {/if}\n\n <nav class=\"contentFooterNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonAdd'}{/link}\" class=\"button\">{icon name='plus'} <span>{lang}wcf.acp.menu.link.person.add{/lang}</span></a></li>\n\n {event name='contentFooterNavigation'}\n </ul>\n </nav>\n </footer>\n{else}\n <p class=\"info\">{lang}wcf.global.noItems{/lang}</p>\n{/if}\n\n{include file='footer'}\n</code></pre> <p>We will go piece by piece through the template code:</p> <ol> <li>We include the <code>header</code> template and set the page title <code>wcf.acp.person.list</code>. You have to include this template for every page!</li> <li>We set the content header and additional provide a button to create a new person in the content header navigation.</li> <li>As not all people are listed on the same page if many people have been created, we need a pagination for which we use the <code>pages</code> template plugin. The <code>{hascontent}{content}{/content}{/hascontent}</code> construct ensures the <code>.paginationTop</code> element is only shown if the <code>pages</code> template plugin has a return value, thus if a pagination is necessary.</li> <li>Now comes the main part of the page, the list of the people, which will only be displayed if any people exist. Otherwise, an info box is displayed using the generic <code>wcf.global.noItems</code> language item. The <code>$objects</code> template variable is automatically assigned by <code>wcf\\page\\MultipleLinkPage</code> and contains the <code>PersonList</code> object used to read the people from database. The table itself consists of a <code>thead</code> and a <code>tbody</code> element and is extendable with more columns using the template events <code>columnHeads</code> and <code>columns</code>. In general, every table should provide these events. The default structure of a table is used here so that the first column of the content rows contains icons to edit and to delete the row (and provides another standard event <code>rowButtons</code>) and that the second column contains the ID of the person. The table can be sorted by clicking on the head of each column. The used variables <code>$sortField</code> and <code>$sortOrder</code> are automatically assigned to the template by <code>SortablePage</code>.</li> <li>The <code>.contentFooter</code> element is only shown if people exist as it basically repeats the <code>.contentHeaderNavigation</code> and <code>.paginationTop</code> element.</li> <li>The delete button for each person shown in the <code>.columnIcon</code> element relies on the global <code>WoltLabSuite/Core/Ui/Object/Action</code> module which only requires the <code>jsObjectActionContainer</code> CSS class in combination with the <code>data-object-action-class-name</code> attribute for the <code>table</code> element, the <code>jsObjectActionObject</code> CSS class for each person's <code>tr</code> element in combination with the <code>data-object-id</code> attribute, and lastly the delete button itself, which is created with the <code>objectAction</code> template plugin.</li> <li>The <code>.jsReloadPageWhenEmpty</code> CSS class on the <code>tbody</code> element ensures that once all persons on the page have been deleted, the page is reloaded.</li> <li>Lastly, the <code>footer</code> template is included that terminates the page. You also have to include this template for every page!</li> </ol> <p>Now, we have finished the page to manage the people so that we can move on to the forms with which we actually create and edit the people.</p>"},{"location":"tutorial/series/part_1/#person-add-form","title":"Person Add Form","text":"<p>Like the person list, the form to add new people requires a controller class and a template.</p>"},{"location":"tutorial/series/part_1/#personaddform","title":"<code>PersonAddForm</code>","text":"files/lib/acp/form/PersonAddForm.class.php <pre><code><?php\n\nnamespace wcf\\acp\\form;\n\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\container\\FormContainer;\nuse wcf\\system\\form\\builder\\field\\TextFormField;\n\n/**\n * Shows the form to create a new person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonAddForm extends AbstractFormBuilderForm\n{\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.add';\n\n /**\n * @inheritDoc\n */\n public $formAction = 'create';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public $objectActionClass = PersonAction::class;\n\n /**\n * @inheritDoc\n */\n public $objectEditLinkController = PersonEditForm::class;\n\n /**\n * @inheritDoc\n */\n protected function createForm()\n {\n parent::createForm();\n\n $this->form->appendChild(\n FormContainer::create('data')\n ->label('wcf.global.form.data')\n ->appendChildren([\n TextFormField::create('firstName')\n ->label('wcf.person.firstName')\n ->required()\n ->autoFocus()\n ->maximumLength(255),\n\n TextFormField::create('lastName')\n ->label('wcf.person.lastName')\n ->required()\n ->maximumLength(255),\n ])\n );\n }\n}\n</code></pre> <p>The properties here consist of three types: the \u201chousekeeping\u201d properties <code>$activeMenuItem</code> and <code>$neededPermissions</code>, which fulfill the same roles as for <code>PersonListPage</code>, and the <code>$objectEditLinkController</code> property, which is used to generate a link to edit the newly created person after submitting the form, and finally <code>$formAction</code> and <code>$objectActionClass</code> required by the PHP form builder API used to generate the form.</p> <p>Because of using form builder, we only have to set up the two form fields for entering the first and last name, respectively:</p> <ol> <li>Each field is a simple single-line text field, thus we use <code>TextFormField</code>.</li> <li>The parameter of the <code>create()</code> method expects the id of the field/name of the database object property, which is <code>firstName</code> and <code>lastName</code>, respectively, here.</li> <li>The language item of the label shown in the ouput above the input field is set via the <code>label()</code> method.</li> <li>As both fields have to be filled out, <code>required()</code> is called, and the maximum length is set via <code>maximumLength()</code>.</li> <li>Lastly, to make it easier to fill out the form more quickly, the first field is auto-focused by calling <code>autoFocus()</code>.</li> </ol>"},{"location":"tutorial/series/part_1/#personaddtpl","title":"<code>personAdd.tpl</code>","text":"acptemplates/personAdd.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.'|concat:$action}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.{$action}{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonList'}{/link}\" class=\"button\">{icon name='list'} <span>{lang}wcf.acp.menu.link.person.list{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{unsafe:$form->getHtml()}\n\n{include file='footer'}\n</code></pre> <p>We will now only concentrate on the new parts compared to <code>personList.tpl</code>:</p> <ol> <li>We use the <code>$action</code> variable to distinguish between the languages items used for adding a person and for creating a person.</li> <li>Because of form builder, we only have to call <code>{unsafe:$form->getHtml()}</code> to generate all relevant output for the form.</li> </ol>"},{"location":"tutorial/series/part_1/#person-edit-form","title":"Person Edit Form","text":"<p>As mentioned before, for the form to edit existing people, we only need a new controller as the template has already been implemented in a way that it handles both, adding and editing.</p>"},{"location":"tutorial/series/part_1/#personeditform","title":"<code>PersonEditForm</code>","text":"files/lib/acp/form/PersonEditForm.class.php <pre><code><?php\n\nnamespace wcf\\acp\\form;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\exception\\IllegalLinkException;\n\n/**\n * Shows the form to edit an existing person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonEditForm extends PersonAddForm\n{\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person';\n\n /**\n * @inheritDoc\n */\n public $formAction = 'update';\n\n /**\n * @inheritDoc\n */\n public function readParameters()\n {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) {\n $this->formObject = new Person($_REQUEST['id']);\n\n if (!$this->formObject->getObjectID()) {\n throw new IllegalLinkException();\n }\n }\n }\n}\n</code></pre> <p>In general, edit forms extend the associated add form so that the code to read and to validate the input data is simply inherited.</p> <p>After setting a different active menu item, we have to change the value of <code>$formAction</code> because this form, in contrast to <code>PersonAddForm</code>, does not create but update existing persons.</p> <p>As we rely on form builder, the only thing necessary in this controller is to read and validate the edit object, i.e. the edited person, which is done in <code>readParameters()</code>.</p>"},{"location":"tutorial/series/part_1/#frontend","title":"Frontend","text":"<p>For the front end, that means the part with which the visitors of a website interact, we want to implement a simple sortable page that lists the people. This page should also be directly linked in the main menu.</p>"},{"location":"tutorial/series/part_1/#pagexml","title":"<code>page.xml</code>","text":"<p>First, let us register the page with the system because every front end page or form needs to be explicitly registered using the page package installation plugin:</p> page.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/page.xsd\">\n <import>\n <page identifier=\"com.woltlab.wcf.people.PersonList\">\n <pageType>system</pageType>\n <controller>wcf\\page\\PersonListPage</controller>\n <name language=\"de\">Personen-Liste</name>\n <name language=\"en\">Person List</name>\n\n <content language=\"de\">\n <title>Personen</title>\n </content>\n <content language=\"en\">\n <title>People</title>\n </content>\n </page>\n </import>\n</data>\n</code></pre> <p>For more information about what each of the elements means, please refer to the page package installation plugin page.</p>"},{"location":"tutorial/series/part_1/#menuitemxml","title":"<code>menuItem.xml</code>","text":"<p>Next, we register the menu item using the menuItem package installation plugin:</p> menuItem.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/menuItem.xsd\">\n <import>\n <item identifier=\"com.woltlab.wcf.people.PersonList\">\n <menu>com.woltlab.wcf.MainMenu</menu>\n <title language=\"de\">Personen</title>\n <title language=\"en\">People</title>\n <page>com.woltlab.wcf.people.PersonList</page>\n </item>\n </import>\n</data>\n</code></pre> <p>Here, the import parts are that we register the menu item for the main menu <code>com.woltlab.wcf.MainMenu</code> and link the menu item with the page <code>com.woltlab.wcf.people.PersonList</code>, which we just registered.</p>"},{"location":"tutorial/series/part_1/#people-list_1","title":"People List","text":"<p>As in the ACP, we need a controller and a template. You might notice that both the controller\u2019s (unqualified) class name and the template name are the same for the ACP and the front end. This is no problem because the qualified names of the classes differ and the files are stored in different directories and because the templates are installed by different package installation plugins and are also stored in different directories.</p>"},{"location":"tutorial/series/part_1/#personlistpage_1","title":"<code>PersonListPage</code>","text":"files/lib/page/PersonListPage.class.php <pre><code><?php\n\nnamespace wcf\\page;\n\nuse wcf\\data\\person\\PersonList;\n\n/**\n * Shows the list of people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Page\n */\nclass PersonListPage extends SortablePage\n{\n /**\n * @inheritDoc\n */\n public $defaultSortField = 'lastName';\n\n /**\n * @inheritDoc\n */\n public $objectListClassName = PersonList::class;\n\n /**\n * @inheritDoc\n */\n public $validSortFields = ['personID', 'firstName', 'lastName'];\n}\n</code></pre> <p>This class is almost identical to the ACP version. In the front end, we do not need to set the active menu item manually because the system determines the active menu item automatically based on the requested page. Furthermore, <code>$neededPermissions</code> has not been set because in the front end, users do not need any special permission to access the page. In the front end, we explicitly set the <code>$defaultSortField</code> so that the people listed on the page are sorted by their last name (in ascending order) by default.</p>"},{"location":"tutorial/series/part_1/#personlisttpl_1","title":"<code>personList.tpl</code>","text":"templates/personList.tpl <pre><code>{capture assign='contentTitle'}{lang}wcf.person.list{/lang} <span class=\"badge\">{#$items}</span>{/capture}\n\n{capture assign='headContent'}\n {if $pageNo < $pages}\n <link rel=\"next\" href=\"{link controller='PersonList'}pageNo={$pageNo+1}{/link}\">\n {/if}\n {if $pageNo > 1}\n <link rel=\"prev\" href=\"{link controller='PersonList'}{if $pageNo > 2}pageNo={$pageNo-1}{/if}{/link}\">\n {/if}\n <link rel=\"canonical\" href=\"{link controller='PersonList'}{if $pageNo > 1}pageNo={$pageNo}{/if}{/link}\">\n{/capture}\n\n{capture assign='sidebarRight'}\n <section class=\"box\">\n <form method=\"post\" action=\"{link controller='PersonList'}{/link}\">\n <h2 class=\"boxTitle\">{lang}wcf.global.sorting{/lang}</h2>\n\n <div class=\"boxContent\">\n <dl>\n <dt></dt>\n <dd>\n <select id=\"sortField\" name=\"sortField\">\n <option value=\"firstName\"{if $sortField == 'firstName'} selected{/if}>{lang}wcf.person.firstName{/lang}</option>\n <option value=\"lastName\"{if $sortField == 'lastName'} selected{/if}>{lang}wcf.person.lastName{/lang}</option>\n {event name='sortField'}\n </select>\n <select name=\"sortOrder\">\n <option value=\"ASC\"{if $sortOrder == 'ASC'} selected{/if}>{lang}wcf.global.sortOrder.ascending{/lang}</option>\n <option value=\"DESC\"{if $sortOrder == 'DESC'} selected{/if}>{lang}wcf.global.sortOrder.descending{/lang}</option>\n </select>\n </dd>\n </dl>\n\n <div class=\"formSubmit\">\n <input type=\"submit\" value=\"{lang}wcf.global.button.submit{/lang}\" accesskey=\"s\">\n </div>\n </div>\n </form>\n </section>\n{/capture}\n\n{include file='header'}\n\n{if $pages > 1}\n <div class=\"paginationTop\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n{/if}\n\n{if $items}\n <div class=\"section sectionContainerList\">\n <ol class=\"containerList personList\">\n {foreach from=$objects item=person}\n <li>\n <div class=\"box48\">\n {icon name='user' size=48}\n\n <div class=\"details personInformation\">\n <div class=\"containerHeadline\">\n <h3>{$person}</h3>\n </div>\n\n {hascontent}\n <ul class=\"inlineList commaSeparated\">\n {content}{event name='personData'}{/content}\n </ul>\n {/hascontent}\n\n {hascontent}\n <dl class=\"plain inlineDataList small\">\n {content}{event name='personStatistics'}{/content}\n </dl>\n {/hascontent}\n </div>\n </div>\n </li>\n {/foreach}\n </ol>\n </div>\n{else}\n <p class=\"info\">{lang}wcf.global.noItems{/lang}</p>\n{/if}\n\n<footer class=\"contentFooter\">\n {if $pages > 1}\n <div class=\"paginationBottom\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n {/if}\n\n {hascontent}\n <nav class=\"contentFooterNavigation\">\n <ul>\n {content}{event name='contentFooterNavigation'}{/content}\n </ul>\n </nav>\n {/hascontent}\n</footer>\n\n{include file='footer'}\n</code></pre> <p>If you compare this template to the one used in the ACP, you will recognize similar elements like the <code>.paginationTop</code> element, the <code>p.info</code> element if no people exist, and the <code>.contentFooter</code> element. Furthermore, we include a template called <code>header</code> before actually showing any of the page contents and terminate the template by including the <code>footer</code> template.</p> <p>Now, let us take a closer look at the differences:</p> <ul> <li>We do not explicitly create a <code>.contentHeader</code> element but simply assign the title to the <code>contentTitle</code> variable. The value of the assignment is simply the title of the page and a badge showing the number of listed people. The <code>header</code> template that we include later will handle correctly displaying the content header on its own based on the <code>$contentTitle</code> variable.</li> <li>Next, we create additional element for the HTML document\u2019s <code><head></code> element. In this case, we define the canonical link of the page and, because we are showing paginated content, add links to the previous and next page (if they exist).</li> <li>We want the page to be sortable but as we will not be using a table for listing the people like in the ACP, we are not able to place links to sort the people into the table head. Instead, usually a box is created in the sidebar on the right-hand side that contains <code>select</code> elements to determine sort field and sort order.</li> <li>The main part of the page is the listing of the people. We use a structure similar to the one used for displaying registered users. Here, for each person, we simply display a FontAwesome icon representing a person and show the person\u2019s full name relying on <code>Person::__toString()</code>. Additionally, like in the user list, we provide the initially empty <code>ul.inlineList.commaSeparated</code> and <code>dl.plain.inlineDataList.small</code> elements that can be filled by plugins using the templates events. </li> </ul>"},{"location":"tutorial/series/part_1/#usergroupoptionxml","title":"<code>userGroupOption.xml</code>","text":"<p>We have already used the <code>admin.content.canManagePeople</code> permissions several times, now we need to install it using the userGroupOption package installation plugin:</p> userGroupOption.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/userGroupOption.xsd\">\n <import>\n <options>\n <option name=\"admin.content.canManagePeople\">\n <categoryname>admin.content</categoryname>\n <optiontype>boolean</optiontype>\n <defaultvalue>0</defaultvalue>\n <admindefaultvalue>1</admindefaultvalue>\n <usersonly>1</usersonly>\n </option>\n </options>\n </import>\n</data>\n</code></pre> <p>We use the existing <code>admin.content</code> user group option category for the permission as the people are \u201ccontent\u201d (similar the the ACP menu item). As the permission is for administrators only, we set <code>defaultvalue</code> to <code>0</code> and <code>admindefaultvalue</code> to <code>1</code>. This permission is only relevant for registered users so that it should not be visible when editing the guest user group. This is achieved by setting <code>usersonly</code> to <code>1</code>.</p>"},{"location":"tutorial/series/part_1/#packagexml","title":"<code>package.xml</code>","text":"<p>Lastly, we need to create the <code>package.xml</code> file. For more information about this kind of file, please refer to the <code>package.xml</code> page.</p> package.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package name=\"com.woltlab.wcf.people\" xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/package.xsd\">\n <packageinformation>\n <packagename>WoltLab Suite Core Tutorial: People</packagename>\n <packagedescription>Adds a simple management system for people as part of a tutorial to create packages.</packagedescription>\n <version>5.4.0</version>\n <date>2022-01-17</date>\n </packageinformation>\n\n <authorinformation>\n <author>WoltLab GmbH</author>\n <authorurl>http://www.woltlab.com</authorurl>\n </authorinformation>\n\n <requiredpackages>\n <requiredpackage minversion=\"5.4.10\">com.woltlab.wcf</requiredpackage>\n </requiredpackages>\n\n <excludedpackages>\n <excludedpackage version=\"6.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n\n <instructions type=\"install\">\n <instruction type=\"acpTemplate\" />\n <instruction type=\"file\" />\n <instruction type=\"database\">acp/database/install_com.woltlab.wcf.people.php</instruction>\n <instruction type=\"template\" />\n <instruction type=\"language\" />\n\n <instruction type=\"acpMenu\" />\n <instruction type=\"page\" />\n <instruction type=\"menuItem\" />\n <instruction type=\"userGroupOption\" />\n </instructions>\n</package>\n</code></pre> <p>As this is a package for WoltLab Suite Core 3, we need to require it using <code><requiredpackage></code>. We require the latest version (when writing this tutorial) <code>5.4.0 Alpha 1</code>. Additionally, we disallow installation of the package in the next major version <code>6.0</code> by excluding the <code>6.0.0 Alpha 1</code> version.</p> <p>The most important part are to installation instructions. First, we install the ACP templates, files and templates, create the database table and import the language item. Afterwards, the ACP menu items and the permission are added. Now comes the part of the instructions where the order of the instructions is crucial: In <code>menuItem.xml</code>, we refer to the <code>com.woltlab.wcf.people.PersonList</code> page that is delivered by <code>page.xml</code>. As the menu item package installation plugin validates the given page and throws an exception if the page does not exist, we need to install the page before the menu item! </p> <p>This concludes the first part of our tutorial series after which you now have a working simple package with which you can manage people in the ACP and show the visitors of your website a simple list of all created people in the front end.</p> <p>The complete source code of this part can be found on GitHub.</p>"},{"location":"tutorial/series/part_2/","title":"Part 2: Event and Template Listeners","text":"<p>In the first part of this tutorial series, we have created the base structure of our people management package. In further parts, we will use the package of the first part as a basis to directly add new features. In order to explain how event listeners and template works, however, we will not directly adding a new feature to the package by altering it in this part, but we will assume that somebody else created the package and that we want to extend it the \u201ccorrect\u201d way by creating a plugin.</p> <p>The goal of the small plugin that will be created in this part is to add the birthday of the managed people. As in the first part, we will not bother with careful validation of the entered date but just make sure that it is a valid date.</p>"},{"location":"tutorial/series/part_2/#package-functionality","title":"Package Functionality","text":"<p>The package should provide the following possibilities/functions:</p> <ul> <li>List person\u2019s birthday (if set) in people list in the ACP</li> <li>Sort people list by birthday in the ACP</li> <li>Add or remove birthday when adding or editing person</li> <li>List person\u2019s birthday (if set) in people list in the front end</li> <li>Sort people list by birthday in the front end</li> </ul>"},{"location":"tutorial/series/part_2/#used-components","title":"Used Components","text":"<p>We will use the following package installation plugins:</p> <ul> <li>database package installation plugin,</li> <li>eventListener package installation plugin,</li> <li>file package installation plugin,</li> <li>language package installation plugin,</li> <li>template package installation plugin,</li> <li>templateListener package installation plugin.</li> </ul> <p>For more information about the event system, please refer to the dedicated page on events.</p>"},{"location":"tutorial/series/part_2/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure:</p> <pre><code>\u251c\u2500\u2500 eventListener.xml\n\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.birthday.php\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u2514\u2500\u2500 event\n\u2502 \u2514\u2500\u2500 listener\n\u2502 \u251c\u2500\u2500 BirthdayPersonAddFormListener.class.php\n\u2502 \u2514\u2500\u2500 BirthdaySortFieldPersonListPageListener.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 templateListener.xml\n\u2514\u2500\u2500 templates\n \u251c\u2500\u2500 __personListBirthday.tpl\n \u2514\u2500\u2500 __personListBirthdaySortField.tpl\n</code></pre>"},{"location":"tutorial/series/part_2/#extending-person-model","title":"Extending Person Model","text":"<p>The existing model of a person only contains the person\u2019s first name and their last name (in additional to the id used to identify created people). To add the birthday to the model, we need to create an additional database table column using the <code>database</code> package installation plugin:</p> files/acp/database/install_com.woltlab.wcf.people.birthday.php <pre><code><?php\n\nuse wcf\\system\\database\\table\\column\\DateDatabaseTableColumn;\nuse wcf\\system\\database\\table\\PartialDatabaseTable;\n\nreturn [\n PartialDatabaseTable::create('wcf1_person')\n ->columns([\n DateDatabaseTableColumn::create('birthday'),\n ]),\n];\n</code></pre> <p>If we have a <code>Person</code> object, this new property can be accessed the same way as the <code>personID</code> property, the <code>firstName</code> property, or the <code>lastName</code> property from the base package: <code>$person->birthday</code>.</p>"},{"location":"tutorial/series/part_2/#setting-birthday-in-acp","title":"Setting Birthday in ACP","text":"<p>To set the birthday of a person, we only have to add another form field with an event listener:</p> files/lib/system/event/listener/BirthdayPersonAddFormListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\acp\\form\\PersonAddForm;\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\container\\FormContainer;\nuse wcf\\system\\form\\builder\\field\\DateFormField;\n\n/**\n * Handles setting the birthday when adding and editing people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class BirthdayPersonAddFormListener extends AbstractEventListener\n{\n /**\n * @see AbstractFormBuilderForm::createForm()\n */\n protected function onCreateForm(PersonAddForm $form): void\n {\n $dataContainer = $form->form->getNodeById('data');\n \\assert($dataContainer instanceof FormContainer);\n $dataContainer->appendChild(\n DateFormField::create('birthday')\n ->label('wcf.person.birthday')\n ->saveValueFormat('Y-m-d')\n ->nullable()\n );\n }\n}\n</code></pre> <p>registered via</p> <pre><code><eventlistener name=\"createForm@wcf\\acp\\form\\PersonAddForm\">\n <environment>admin</environment>\n <eventclassname>wcf\\acp\\form\\PersonAddForm</eventclassname>\n <eventname>createForm</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdayPersonAddFormListener</listenerclassname>\n <inherit>1</inherit>\n</eventlistener>\n</code></pre> <p>in <code>eventListener.xml</code>, see below.</p> <p>As <code>BirthdayPersonAddFormListener</code> extends <code>AbstractEventListener</code> and as the name of relevant event is <code>createForm</code>, <code>AbstractEventListener</code> internally automatically calls <code>onCreateForm()</code> with the event object as the parameter. It is important to set <code><inherit>1</inherit></code> so that the event listener is also executed for <code>PersonEditForm</code>, which extends <code>PersonAddForm</code>.</p> <p>The language item <code>wcf.person.birthday</code> used in the label is the only new one for this package:</p> language/de.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"de\">\n <category name=\"wcf.person\">\n <item name=\"wcf.person.birthday\"><![CDATA[Geburtstag]]></item>\n </category>\n</language>\n</code></pre> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\">\n <category name=\"wcf.person\">\n <item name=\"wcf.person.birthday\"><![CDATA[Birthday]]></item>\n </category>\n</language>\n</code></pre>"},{"location":"tutorial/series/part_2/#adding-birthday-table-column-in-acp","title":"Adding Birthday Table Column in ACP","text":"<p>To add a birthday column to the person list page in the ACP, we need three parts:</p> <ol> <li>an event listener that makes the <code>birthday</code> database table column a valid sort field,</li> <li>a template listener that adds the birthday column to the table\u2019s head, and</li> <li>a template listener that adds the birthday column to the table\u2019s rows.</li> </ol> <p>The first part is a very simple class:</p> files/lib/system/event/listener/BirthdaySortFieldPersonListPageListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\page\\SortablePage;\n\n/**\n * Makes people's birthday a valid sort field in the ACP and the front end.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class BirthdaySortFieldPersonListPageListener extends AbstractEventListener\n{\n /**\n * @see SortablePage::validateSortField()\n */\n public function onValidateSortField(SortablePage $page): void\n {\n $page->validSortFields[] = 'birthday';\n }\n}\n</code></pre> <p>We use <code>SortablePage</code> as a type hint instead of <code>wcf\\acp\\page\\PersonListPage</code> because we will be using the same event listener class in the front end to also allow sorting that list by birthday.</p> <p>As the relevant template codes are only one line each, we will simply put them directly in the <code>templateListener.xml</code> file that will be shown later on. The code for the table head is similar to the other <code>th</code> elements:</p> <pre><code><th class=\"columnDate columnBirthday{if $sortField == 'birthday'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=birthday&sortOrder={if $sortField == 'birthday' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.birthday{/lang}</a></th>\n</code></pre> <p>For the table body\u2019s column, we need to make sure that the birthday is only show if it is actually set:</p> <pre><code><td class=\"columnDate columnBirthday\">{if $person->birthday}{$person->birthday|strtotime|date}{/if}</td>\n</code></pre>"},{"location":"tutorial/series/part_2/#adding-birthday-in-front-end","title":"Adding Birthday in Front End","text":"<p>In the front end, we also want to make the list sortable by birthday and show the birthday as part of each person\u2019s \u201cstatistics\u201d.</p> <p>To add the birthday as a valid sort field, we use <code>BirthdaySortFieldPersonListPageListener</code> just as in the ACP. In the front end, we will now use a template (<code>__personListBirthdaySortField.tpl</code>) instead of a directly putting the template code in the <code>templateListener.xml</code> file:</p> templates/__personListBirthdaySortField.tpl <pre><code><option value=\"birthday\"{if $sortField == 'birthday'} selected{/if}>{lang}wcf.person.birthday{/lang}</option>\n</code></pre> <p>You might have noticed the two underscores at the beginning of the template file. For templates that are included via template listeners, this is the naming convention we use.</p> <p>Putting the template code into a file has the advantage that in the administrator is able to edit the code directly via a custom template group, even though in this case this might not be very probable.</p> <p>To show the birthday, we use the following template code for the <code>personStatistics</code> template event, which again makes sure that the birthday is only shown if it is actually set:</p> templates/__personListBirthday.tpl <pre><code>{if $person->birthday}\n <dt>{lang}wcf.person.birthday{/lang}</dt>\n <dd>{$person->birthday|strtotime|date}</dd>\n{/if}\n</code></pre>"},{"location":"tutorial/series/part_2/#templatelistenerxml","title":"<code>templateListener.xml</code>","text":"<p>The following code shows the <code>templateListener.xml</code> file used to install all mentioned template listeners:</p> templateListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/tornado/5.4/templateListener.xsd\">\n <import>\n <!-- admin -->\n <templatelistener name=\"personListBirthdayColumnHead\">\n <eventname>columnHeads</eventname>\n <environment>admin</environment>\n <templatecode><![CDATA[<th class=\"columnDate columnBirthday{if $sortField == 'birthday'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=birthday&sortOrder={if $sortField == 'birthday' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.birthday{/lang}</a></th>]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <templatelistener name=\"personListBirthdayColumn\">\n <eventname>columns</eventname>\n <environment>admin</environment>\n <templatecode><![CDATA[<td class=\"columnDate columnBirthday\">{if $person->birthday}{$person->birthday|strtotime|date}{/if}</td>]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <!-- /admin -->\n\n <!-- user -->\n <templatelistener name=\"personListBirthday\">\n <eventname>personStatistics</eventname>\n <environment>user</environment>\n <templatecode><![CDATA[{include file='__personListBirthday'}]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <templatelistener name=\"personListBirthdaySortField\">\n <eventname>sortField</eventname>\n <environment>user</environment>\n <templatecode><![CDATA[{include file='__personListBirthdaySortField'}]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <!-- /user -->\n </import>\n</data>\n</code></pre> <p>In cases where a template is used, we simply use the <code>include</code> syntax to load the template.</p>"},{"location":"tutorial/series/part_2/#eventlistenerxml","title":"<code>eventListener.xml</code>","text":"<p>There are two event listeners that make <code>birthday</code> a valid sort field in the ACP and the front end, respectively, and the third event listener takes care of setting the birthday.</p> eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/eventListener.xsd\">\n <import>\n <!-- admin -->\n <eventlistener name=\"validateSortField@wcf\\acp\\page\\PersonListPage\">\n <environment>admin</environment>\n <eventclassname>wcf\\acp\\page\\PersonListPage</eventclassname>\n <eventname>validateSortField</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdaySortFieldPersonListPageListener</listenerclassname>\n </eventlistener>\n <eventlistener name=\"createForm@wcf\\acp\\form\\PersonAddForm\">\n <environment>admin</environment>\n <eventclassname>wcf\\acp\\form\\PersonAddForm</eventclassname>\n <eventname>createForm</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdayPersonAddFormListener</listenerclassname>\n <inherit>1</inherit>\n </eventlistener>\n <!-- /admin -->\n\n <!-- user -->\n <eventlistener name=\"validateSortField@wcf\\page\\PersonListPage\">\n <environment>user</environment>\n <eventclassname>wcf\\page\\PersonListPage</eventclassname>\n <eventname>validateSortField</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdaySortFieldPersonListPageListener</listenerclassname>\n </eventlistener>\n <!-- /user -->\n </import>\n</data>\n</code></pre>"},{"location":"tutorial/series/part_2/#packagexml","title":"<code>package.xml</code>","text":"<p>The only relevant difference between the <code>package.xml</code> file of the base page from part 1 and the <code>package.xml</code> file of this package is that this package requires the base package <code>com.woltlab.wcf.people</code> (see <code><requiredpackages></code>):</p> package.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package name=\"com.woltlab.wcf.people.birthday\" xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/package.xsd\">\n <packageinformation>\n <packagename>WoltLab Suite Core Tutorial: People (Birthday)</packagename>\n <packagedescription>Adds a birthday field to the people management system as part of a tutorial to create packages.</packagedescription>\n <version>5.4.0</version>\n <date>2022-01-17</date>\n </packageinformation>\n\n <authorinformation>\n <author>WoltLab GmbH</author>\n <authorurl>http://www.woltlab.com</authorurl>\n </authorinformation>\n\n <requiredpackages>\n <requiredpackage minversion=\"5.4.10\">com.woltlab.wcf</requiredpackage>\n <requiredpackage minversion=\"5.4.0\">com.woltlab.wcf.people</requiredpackage>\n </requiredpackages>\n\n <excludedpackages>\n <excludedpackage version=\"6.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n\n <instructions type=\"install\">\n <instruction type=\"file\" />\n <instruction type=\"database\">acp/database/install_com.woltlab.wcf.people.birthday.php</instruction>\n <instruction type=\"template\" />\n <instruction type=\"language\" />\n\n <instruction type=\"eventListener\" />\n <instruction type=\"templateListener\" />\n </instructions>\n</package>\n</code></pre> <p>This concludes the second part of our tutorial series after which you now have extended the base package using event listeners and template listeners that allow you to enter the birthday of the people.</p> <p>The complete source code of this part can be found on GitHub.</p>"},{"location":"tutorial/series/part_3/","title":"Part 3: Person Page and Comments","text":"<p>In this part of our tutorial series, we will add a new front end page to our package that is dedicated to each person and shows their personal details. To make good use of this new page and introduce a new API of WoltLab Suite, we will add the opportunity for users to comment on the person using WoltLab Suite\u2019s reusable comment functionality.</p>"},{"location":"tutorial/series/part_3/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 1, the package will provide the following possibilities/functions after this part of the tutorial:</p> <ul> <li>Details page for each person linked in the front end person list</li> <li>Comment on people on their respective page (can be disabled per person)</li> <li>User online location for person details page with name and link to person details page</li> <li>Create menu items linking to specific person details pages</li> </ul>"},{"location":"tutorial/series/part_3/#used-components","title":"Used Components","text":"<p>In addition to the components used in part 1, we will use the objectType package installation plugin, use the comment API, create a runtime cache, and create a page handler.</p>"},{"location":"tutorial/series/part_3/#package-structure","title":"Package Structure","text":"<p>The complete package will have the following file structure (including the files from part 1):</p> <pre><code>\u251c\u2500\u2500 acpMenu.xml\n\u251c\u2500\u2500 acptemplates\n\u2502 \u251c\u2500\u2500 personAdd.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.php\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u251c\u2500\u2500 form\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 PersonAddForm.class.php\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 PersonEditForm.class.php\n\u2502 \u2502 \u2514\u2500\u2500 page\n\u2502 \u2502 \u2514\u2500\u2500 PersonListPage.class.php\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 Person.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonAction.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonEditor.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonList.class.php\n\u2502 \u251c\u2500\u2500 page\n\u2502 \u2502 \u251c\u2500\u2500 PersonListPage.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonPage.class.php\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u251c\u2500\u2500 cache\n\u2502 \u2502 \u2514\u2500\u2500 runtime\n\u2502 \u2502 \u2514\u2500\u2500 PersonRuntimeCache.class.php\n\u2502 \u251c\u2500\u2500 comment\n\u2502 \u2502 \u2514\u2500\u2500 manager\n\u2502 \u2502 \u2514\u2500\u2500 PersonCommentManager.class.php\n\u2502 \u2514\u2500\u2500 page\n\u2502 \u2514\u2500\u2500 handler\n\u2502 \u2514\u2500\u2500 PersonPageHandler.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 menuItem.xml\n\u251c\u2500\u2500 objectType.xml\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 page.xml\n\u251c\u2500\u2500 templates\n\u2502 \u251c\u2500\u2500 person.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u2514\u2500\u2500 userGroupOption.xml\n</code></pre> <p>We will not mention every code change between the first part and this part, as we only want to focus on the important, new parts of the code. For example, there is a new <code>Person::getLink()</code> method and new language items have been added. For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_3/#runtime-cache","title":"Runtime Cache","text":"<p>To reduce the number of database queries when different APIs require person objects, we implement a runtime cache for people:</p> files/lib/system/cache/runtime/PersonRuntimeCache.class.php <pre><code><?php\n\nnamespace wcf\\system\\cache\\runtime;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\person\\PersonList;\n\n/**\n * Runtime cache implementation for people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Cache\\Runtime\n *\n * @method Person[] getCachedObjects()\n * @method Person getObject($objectID)\n * @method Person[] getObjects(array $objectIDs)\n */\nfinal class PersonRuntimeCache extends AbstractRuntimeCache\n{\n /**\n * @inheritDoc\n */\n protected $listClassName = PersonList::class;\n}\n</code></pre>"},{"location":"tutorial/series/part_3/#comments","title":"Comments","text":"<p>To allow users to comment on people, we need to tell the system that people support comments. This is done by registering a <code>com.woltlab.wcf.comment.commentableContent</code> object type whose processor implements ICommentManager:</p> objectType.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/objectType.xsd\">\n <import>\n <type>\n <name>com.woltlab.wcf.person.personComment</name>\n <definitionname>com.woltlab.wcf.comment.commentableContent</definitionname>\n <classname>wcf\\system\\comment\\manager\\PersonCommentManager</classname>\n </type>\n </import>\n</data>\n</code></pre> <p>The <code>PersonCommentManager</code> class extended <code>ICommentManager</code>\u2019s default implementation AbstractCommentManager:</p> files/lib/system/comment/manager/PersonCommentManager.class.php <pre><code><?php\n\nnamespace wcf\\system\\comment\\manager;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\person\\PersonEditor;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\WCF;\n\n/**\n * Comment manager implementation for people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Comment\\Manager\n */\nfinal class PersonCommentManager extends AbstractCommentManager\n{\n /**\n * @inheritDoc\n */\n protected $permissionAdd = 'user.person.canAddComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionAddWithoutModeration = 'user.person.canAddCommentWithoutModeration';\n\n /**\n * @inheritDoc\n */\n protected $permissionCanModerate = 'mod.person.canModerateComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionDelete = 'user.person.canDeleteComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionEdit = 'user.person.canEditComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionModDelete = 'mod.person.canDeleteComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionModEdit = 'mod.person.canEditComment';\n\n /**\n * @inheritDoc\n */\n public function getLink($objectTypeID, $objectID)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID)->getLink();\n }\n\n /**\n * @inheritDoc\n */\n public function isAccessible($objectID, $validateWritePermission = false)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID) !== null;\n }\n\n /**\n * @inheritDoc\n */\n public function getTitle($objectTypeID, $objectID, $isResponse = false)\n {\n if ($isResponse) {\n return WCF::getLanguage()->get('wcf.person.commentResponse');\n }\n\n return WCF::getLanguage()->getDynamicVariable('wcf.person.comment');\n }\n\n /**\n * @inheritDoc\n */\n public function updateCounter($objectID, $value)\n {\n (new PersonEditor(new Person($objectID)))->updateCounters(['comments' => $value]);\n }\n}\n</code></pre> <ul> <li>First, the system is told the names of the permissions via the <code>$permission*</code> properties. More information about comment permissions can be found here.</li> <li>The <code>getLink()</code> method returns the link to the person with the passed comment id. As in <code>isAccessible()</code>, <code>PersonRuntimeCache</code> is used to potentially save database queries.</li> <li>The <code>isAccessible()</code> method checks if the active user can access the relevant person. As we do not have any special restrictions for accessing people, we only need to check if the person exists.</li> <li>The <code>getTitle()</code> method returns the title used for comments and responses, which is just a generic language item in this case.</li> <li>The <code>updateCounter()</code> updates the comments\u2019 counter of the person. We have added a new <code>comments</code> database table column to the <code>wcf1_person</code> database table in order to keep track on the number of comments.</li> </ul> <p>Additionally, we have added a new <code>enableComments</code> database table column to the <code>wcf1_person</code> database table whose value can be set when creating or editing a person in the ACP. With this option, comments on individual people can be disabled.</p> <p>Liking comments is already built-in and only requires some extra code in the <code>PersonPage</code> class for showing the likes of pre-loaded comments.</p>"},{"location":"tutorial/series/part_3/#person-page","title":"Person Page","text":""},{"location":"tutorial/series/part_3/#personpage","title":"<code>PersonPage</code>","text":"files/lib/page/PersonPage.class.php <pre><code><?php\n\nnamespace wcf\\page;\n\nuse wcf\\data\\comment\\StructuredCommentList;\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\comment\\CommentHandler;\nuse wcf\\system\\comment\\manager\\PersonCommentManager;\nuse wcf\\system\\exception\\IllegalLinkException;\nuse wcf\\system\\WCF;\n\n/**\n * Shows the details of a certain person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Page\n */\nclass PersonPage extends AbstractPage\n{\n /**\n * list of comments\n * @var StructuredCommentList\n */\n public $commentList;\n\n /**\n * person comment manager object\n * @var PersonCommentManager\n */\n public $commentManager;\n\n /**\n * id of the person comment object type\n * @var int\n */\n public $commentObjectTypeID = 0;\n\n /**\n * shown person\n * @var Person\n */\n public $person;\n\n /**\n * id of the shown person\n * @var int\n */\n public $personID = 0;\n\n /**\n * @inheritDoc\n */\n public function assignVariables()\n {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'commentCanAdd' => WCF::getSession()->getPermission('user.person.canAddComment'),\n 'commentList' => $this->commentList,\n 'commentObjectTypeID' => $this->commentObjectTypeID,\n 'lastCommentTime' => $this->commentList ? $this->commentList->getMinCommentTime() : 0,\n 'likeData' => MODULE_LIKE && $this->commentList ? $this->commentList->getLikeData() : [],\n 'person' => $this->person,\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function readData()\n {\n parent::readData();\n\n if ($this->person->enableComments) {\n $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID(\n 'com.woltlab.wcf.person.personComment'\n );\n $this->commentManager = CommentHandler::getInstance()->getObjectType(\n $this->commentObjectTypeID\n )->getProcessor();\n $this->commentList = CommentHandler::getInstance()->getCommentList(\n $this->commentManager,\n $this->commentObjectTypeID,\n $this->person->personID\n );\n }\n }\n\n /**\n * @inheritDoc\n */\n public function readParameters()\n {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) {\n $this->personID = \\intval($_REQUEST['id']);\n }\n $this->person = new Person($this->personID);\n if (!$this->person->personID) {\n throw new IllegalLinkException();\n }\n }\n}\n</code></pre> <p>The <code>PersonPage</code> class is similar to the <code>PersonEditForm</code> in the ACP in that it reads the id of the requested person from the request data and validates the id in <code>readParameters()</code>. The rest of the code only handles fetching the list of comments on the requested person. In <code>readData()</code>, this list is fetched using <code>CommentHandler::getCommentList()</code> if comments are enabled for the person. The <code>assignVariables()</code> method assigns some additional template variables like <code>$commentCanAdd</code>, which is <code>1</code> if the active person can add comments and is <code>0</code> otherwise, <code>$lastCommentTime</code>, which contains the UNIX timestamp of the last comment, and <code>$likeData</code>, which contains data related to the likes for the disabled comments.</p>"},{"location":"tutorial/series/part_3/#persontpl","title":"<code>person.tpl</code>","text":"templates/person.tpl <pre><code>{capture assign='pageTitle'}{$person} - {lang}wcf.person.list{/lang}{/capture}\n\n{capture assign='contentTitle'}{$person}{/capture}\n\n{include file='header'}\n\n{if $person->enableComments}\n {if $commentList|count || $commentCanAdd}\n <section id=\"comments\" class=\"section sectionContainerList\">\n <header class=\"sectionHeader\">\n <h2 class=\"sectionTitle\">\n {lang}wcf.person.comments{/lang}\n {if $person->comments}<span class=\"badge\">{#$person->comments}</span>{/if}\n </h2>\n </header>\n\n {include file='__commentJavaScript' commentContainerID='personCommentList'}\n\n <div class=\"personComments\">\n <ul id=\"personCommentList\" class=\"commentList containerList\" {*\n *}data-can-add=\"{if $commentCanAdd}true{else}false{/if}\" {*\n *}data-object-id=\"{$person->personID}\" {*\n *}data-object-type-id=\"{$commentObjectTypeID}\" {*\n *}data-comments=\"{if $person->comments}{$commentList->countObjects()}{else}0{/if}\" {*\n *}data-last-comment-time=\"{$lastCommentTime}\" {*\n *}>\n {include file='commentListAddComment' wysiwygSelector='personCommentListAddComment'}\n {include file='commentList'}\n </ul>\n </div>\n </section>\n {/if}\n{/if}\n\n<footer class=\"contentFooter\">\n {hascontent}\n <nav class=\"contentFooterNavigation\">\n <ul>\n {content}{event name='contentFooterNavigation'}{/content}\n </ul>\n </nav>\n {/hascontent}\n</footer>\n\n{include file='footer'}\n</code></pre> <p>For now, the <code>person</code> template is still very empty and only shows the comments in the content area. The template code shown for comments is very generic and used in this form in many locations as it only sets the header of the comment list and the container <code>ul#personCommentList</code> element for the comments shown by <code>commentList</code> template. The <code>ul#personCommentList</code> elements has five additional <code>data-</code> attributes required by the JavaScript API for comments for loading more comments or creating new ones. The <code>commentListAddComment</code> template adds the WYSIWYG support. The attribute <code>wysiwygSelector</code> should be the id of the comment list <code>personCommentList</code> with an additional <code>AddComment</code> suffix.</p>"},{"location":"tutorial/series/part_3/#pagexml","title":"<code>page.xml</code>","text":"page.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/page.xsd\">\n <import>\n <page identifier=\"com.woltlab.wcf.people.PersonList\">\n <pageType>system</pageType>\n <controller>wcf\\page\\PersonListPage</controller>\n <name language=\"de\">Personen-Liste</name>\n <name language=\"en\">Person List</name>\n\n <content language=\"de\">\n <title>Personen</title>\n </content>\n <content language=\"en\">\n <title>People</title>\n </content>\n </page>\n <page identifier=\"com.woltlab.wcf.people.Person\">\n <pageType>system</pageType>\n <controller>wcf\\page\\PersonPage</controller>\n <handler>wcf\\system\\page\\handler\\PersonPageHandler</handler>\n <name language=\"de\">Person</name>\n <name language=\"en\">Person</name>\n <requireObjectID>1</requireObjectID>\n <parent>com.woltlab.wcf.people.PersonList</parent>\n </page>\n </import>\n</data>\n</code></pre> <p>The <code>page.xml</code> file has been extended for the new person page with identifier <code>com.woltlab.wcf.people.Person</code>. Compared to the pre-existing <code>com.woltlab.wcf.people.PersonList</code> page, there are four differences:</p> <ol> <li>It has a <code><handler></code> element with a class name as value. This aspect will be discussed in more detail in the next section.</li> <li>There are no <code><content></code> elements because, both, the title and the content of the page are dynamically generated in the template.</li> <li>The <code><requireObjectID></code> tells the system that this page requires an object id to properly work, in this case a valid person id.</li> <li>This page has a <code><parent></code> page, the person list page. In general, the details page for any type of object that is listed on a different page has the list page as its parent.</li> </ol>"},{"location":"tutorial/series/part_3/#personpagehandler","title":"<code>PersonPageHandler</code>","text":"files/lib/system/page/handler/PersonPageHandler.class.php <pre><code><?php\n\nnamespace wcf\\system\\page\\handler;\n\nuse wcf\\data\\page\\Page;\nuse wcf\\data\\person\\PersonList;\nuse wcf\\data\\user\\online\\UserOnline;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\database\\util\\PreparedStatementConditionBuilder;\nuse wcf\\system\\WCF;\n\n/**\n * Page handler implementation for person page.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Page\\Handler\n */\nfinal class PersonPageHandler extends AbstractLookupPageHandler implements IOnlineLocationPageHandler\n{\n use TOnlineLocationPageHandler;\n\n /**\n * @inheritDoc\n */\n public function getLink($objectID)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID)->getLink();\n }\n\n /**\n * Returns the textual description if a user is currently online viewing this page.\n *\n * @see IOnlineLocationPageHandler::getOnlineLocation()\n *\n * @param Page $page visited page\n * @param UserOnline $user user online object with request data\n * @return string\n */\n public function getOnlineLocation(Page $page, UserOnline $user)\n {\n if ($user->pageObjectID === null) {\n return '';\n }\n\n $person = PersonRuntimeCache::getInstance()->getObject($user->pageObjectID);\n if ($person === null) {\n return '';\n }\n\n return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.' . $page->identifier, ['person' => $person]);\n }\n\n /**\n * @inheritDoc\n */\n public function isValid($objectID = null)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID) !== null;\n }\n\n /**\n * @inheritDoc\n */\n public function lookup($searchString)\n {\n $conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR');\n $conditionBuilder->add('person.firstName LIKE ?', ['%' . $searchString . '%']);\n $conditionBuilder->add('person.lastName LIKE ?', ['%' . $searchString . '%']);\n\n $personList = new PersonList();\n $personList->getConditionBuilder()->add($conditionBuilder, $conditionBuilder->getParameters());\n $personList->readObjects();\n\n $results = [];\n foreach ($personList as $person) {\n $results[] = [\n 'image' => 'user',\n 'link' => $person->getLink(),\n 'objectID' => $person->personID,\n 'title' => $person->getTitle(),\n ];\n }\n\n return $results;\n }\n\n /**\n * Prepares fetching all necessary data for the textual description if a user is currently online\n * viewing this page.\n *\n * @see IOnlineLocationPageHandler::prepareOnlineLocation()\n *\n * @param Page $page visited page\n * @param UserOnline $user user online object with request data\n */\n public function prepareOnlineLocation(Page $page, UserOnline $user)\n {\n if ($user->pageObjectID !== null) {\n PersonRuntimeCache::getInstance()->cacheObjectID($user->pageObjectID);\n }\n }\n}\n</code></pre> <p>Like any page handler, the <code>PersonPageHandler</code> class has to implement the IMenuPageHandler interface, which should be done by extending the AbstractMenuPageHandler class. As we want administrators to link to specific people in menus, for example, we have to also implement the ILookupPageHandler interface by extending the AbstractLookupPageHandler class.</p> <p>For the <code>ILookupPageHandler</code> interface, we need to implement three methods:</p> <ol> <li><code>getLink($objectID)</code> returns the link to the person page with the given id. In this case, we simply delegate this method call to the <code>Person</code> object returned by <code>PersonRuntimeCache::getObject()</code>.</li> <li><code>isValid($objectID)</code> returns <code>true</code> if the person with the given id exists, otherwise <code>false</code>. Here, we use <code>PersonRuntimeCache::getObject()</code> again and check if the return value is <code>null</code>, which is the case for non-existing people.</li> <li><code>lookup($searchString)</code> is used when setting up an internal link and when searching for the linked person. This method simply searches the first and last name of the people and returns an array with the person data. While the <code>link</code>, the <code>objectID</code>, and the <code>title</code> element are self-explanatory, the <code>image</code> element can either contain an HTML <code><img></code> tag, which is displayed next to the search result (WoltLab Suite uses an image tag for users showing their avatar, for example), or a FontAwesome icon class.</li> </ol> <p>Additionally, the class also implements IOnlineLocationPageHandler which is used to determine the online location of users. To ensure upwards-compatibility if the <code>IOnlineLocationPageHandler</code> interface changes, the TOnlineLocationPageHandler trait is used. The <code>IOnlineLocationPageHandler</code> interface requires two methods to be implemented:</p> <ol> <li><code>getOnlineLocation(Page $page, UserOnline $user)</code> returns the textual description of the online location. The language item for the user online locations should use the pattern <code>wcf.page.onlineLocation.{page identifier}</code>.</li> <li><code>prepareOnlineLocation(Page $page, UserOnline $user)</code> is called for each user online before the <code>getOnlineLocation()</code> calls. In this case, calling <code>prepareOnlineLocation()</code> first enables us to add all relevant person ids to the person runtime cache so that for all <code>getOnlineLocation()</code> calls combined, only one database query is necessary to fetch all person objects.</li> </ol> <p>This concludes the third part of our tutorial series after which each person has a dedicated page on which people can comment on the person.</p> <p>The complete source code of this part can be found on GitHub.</p>"},{"location":"tutorial/series/part_4/","title":"Part 4: Box and Box Conditions","text":"<p>In this part of our tutorial series, we add support for creating boxes listing people.</p>"},{"location":"tutorial/series/part_4/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 3, the package will provide the following functionality after this part of the tutorial:</p> <ul> <li>Creating boxes dynamically listing people</li> <li>Filtering the people listed in boxes using conditions</li> </ul>"},{"location":"tutorial/series/part_4/#used-components","title":"Used Components","text":"<p>In addition to the components used in previous parts, we will use the <code>objectTypeDefinition</code> package installation plugin and use the box and condition APIs.</p> <p>To pre-install a specific person list box, we refer to the documentation of the <code>box</code> package installation plugin.</p>"},{"location":"tutorial/series/part_4/#package-structure","title":"Package Structure","text":"<p>The complete package will have the following file structure (excluding unchanged files from part 3):</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u251c\u2500\u2500 box\n\u2502 \u2502 \u2514\u2500\u2500 PersonListBoxController.class.php\n\u2502 \u2514\u2500\u2500 condition\n\u2502 \u2514\u2500\u2500 person\n\u2502 \u251c\u2500\u2500 PersonFirstNameTextPropertyCondition.class.php\n\u2502 \u2514\u2500\u2500 PersonLastNameTextPropertyCondition.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 objectType.xml\n\u251c\u2500\u2500 objectTypeDefinition.xml\n\u2514\u2500\u2500 templates\n \u2514\u2500\u2500 boxPersonList.tpl\n</code></pre> <p>For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_4/#box-controller","title":"Box Controller","text":"<p>In addition to static boxes with fixed contents, administrators are able to create dynamic boxes with contents from the database. In our case here, we want administrators to be able to create boxes listing people. To do so, we first have to register a new object type for this person list box controller for the object type definition <code>com.woltlab.wcf.boxController</code>:</p> <pre><code><type>\n <name>com.woltlab.wcf.personList</name>\n <definitionname>com.woltlab.wcf.boxController</definitionname>\n <classname>wcf\\system\\box\\PersonListBoxController</classname>\n</type>\n</code></pre> <p>The <code>com.woltlab.wcf.boxController</code> object type definition requires the provided class to implement <code>wcf\\system\\box\\IBoxController</code>:</p> files/lib/system/box/PersonListBoxController.class.php <pre><code><?php\n\nnamespace wcf\\system\\box;\n\nuse wcf\\data\\person\\PersonList;\nuse wcf\\system\\WCF;\n\n/**\n * Dynamic box controller implementation for a list of persons.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Box\n */\nfinal class PersonListBoxController extends AbstractDatabaseObjectListBoxController\n{\n /**\n * @inheritDoc\n */\n protected $conditionDefinition = 'com.woltlab.wcf.box.personList.condition';\n\n /**\n * @inheritDoc\n */\n public $defaultLimit = 5;\n\n /**\n * @inheritDoc\n */\n protected $sortFieldLanguageItemPrefix = 'wcf.person';\n\n /**\n * @inheritDoc\n */\n protected static $supportedPositions = [\n 'sidebarLeft',\n 'sidebarRight',\n ];\n\n /**\n * @inheritDoc\n */\n public $validSortFields = [\n 'firstName',\n 'lastName',\n 'comments',\n ];\n\n /**\n * @inheritDoc\n */\n protected function getObjectList()\n {\n return new PersonList();\n }\n\n /**\n * @inheritDoc\n */\n protected function getTemplate()\n {\n return WCF::getTPL()->fetch('boxPersonList', 'wcf', [\n 'boxPersonList' => $this->objectList,\n 'boxSortField' => $this->sortField,\n 'boxPosition' => $this->box->position,\n ], true);\n }\n}\n</code></pre> <p>By extending <code>AbstractDatabaseObjectListBoxController</code>, we only have to provide minimal data ourself and rely mostly on the default implementation provided by <code>AbstractDatabaseObjectListBoxController</code>:</p> <ol> <li>As we will support conditions for the listed people, we have to set the relevant condition definition via <code>$conditionDefinition</code>.</li> <li><code>AbstractDatabaseObjectListBoxController</code> already supports restricting the number of listed objects. To do so, you only have to specify the default number of listed objects via <code>$defaultLimit</code>.</li> <li><code>AbstractDatabaseObjectListBoxController</code> also supports setting the sort order of the listed objects. You have to provide the supported sort fields via <code>$validSortFields</code> and specify the prefix used for the language items of the sort fields via <code>$sortFieldLanguageItemPrefix</code> so that for every <code>$validSortField</code> in <code>$validSortFields</code>, the language item <code>{$sortFieldLanguageItemPrefix}.{$validSortField}</code> must exist.</li> <li>The box system supports different positions. Each box controller specifies the positions it supports via <code>$supportedPositions</code>. To keep the implementation simple here as different positions might require different output in the template, we restrict ourselves to sidebars.</li> <li><code>getObjectList()</code> returns an instance of <code>DatabaseObjectList</code> that is used to read the listed objects. <code>getObjectList()</code> itself must not call <code>readObjects()</code>, as <code>AbstractDatabaseObjectListBoxController</code> takes care of calling the method after adding the conditions and setting the sort order.</li> <li><code>getTemplate()</code> returns the contents of the box relying on the <code>boxPersonList</code> template here:</li> </ol> templates/boxPersonList.tpl <pre><code><ul class=\"sidebarItemList\">\n {foreach from=$boxPersonList item=boxPerson}\n <li class=\"box24\">\n {icon name='user' size=24}\n\n <div class=\"sidebarItemTitle\">\n <h3>{anchor object=$boxPerson}</h3>\n {capture assign='__boxPersonDescription'}{lang __optional=true}wcf.person.boxList.description.{$boxSortField}{/lang}{/capture}\n {if $__boxPersonDescription}\n <small>{unsafe:$__boxPersonDescription}</small>\n {/if}\n </div>\n </li>\n {/foreach}\n</ul>\n</code></pre> <p>The template relies on a <code>.sidebarItemList</code> element, which is generally used for sidebar listings. (If different box positions were supported, we either have to generate different output by considering the value of <code>$boxPosition</code> in the template or by using different templates in <code>getTemplate()</code>.) One specific piece of code is the <code>$__boxPersonDescription</code> variable, which supports an optional description below the person's name relying on the optional language item <code>wcf.person.boxList.description.{$boxSortField}</code>. We only add one such language item when sorting the people by comments: In such a case, the number of comments will be shown. (When sorting by first and last name, there are no additional useful information that could be shown here, though the plugin from part 2 adding support for birthdays might also show the birthday when sorting by first or last name.)</p> <p>Lastly, we also provide the language item <code>wcf.acp.box.boxController.com.woltlab.wcf.personList</code>, which is used in the list of available box controllers.</p>"},{"location":"tutorial/series/part_4/#conditions","title":"Conditions","text":"<p>The condition system can be used to generally filter a list of objects. In our case, the box system supports conditions to filter the objects shown in a specific box. Admittedly, our current person implementation only contains minimal data so that filtering might not make the most sense here but it will still show how to use the condition system for boxes. We will support filtering the people by their first and last name so that, for example, a box can be created listing all people with a specific first name.</p> <p>The first step for condition support is to register a object type definition for the relevant conditions requiring the <code>IObjectListCondition</code> interface:</p> objectTypeDefinition.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/objectTypeDefinition.xsd\">\n <import>\n <definition>\n <name>com.woltlab.wcf.box.personList.condition</name>\n <interfacename>wcf\\system\\condition\\IObjectListCondition</interfacename>\n </definition>\n </import>\n</data>\n</code></pre> <p>Next, we register the specific conditions for filtering by the first and last name using this object type condition:</p> <pre><code><type>\n <name>com.woltlab.wcf.people.firstName</name>\n <definitionname>com.woltlab.wcf.box.personList.condition</definitionname>\n <classname>wcf\\system\\condition\\person\\PersonFirstNameTextPropertyCondition</classname>\n</type>\n<type>\n <name>com.woltlab.wcf.people.lastName</name>\n <definitionname>com.woltlab.wcf.box.personList.condition</definitionname>\n <classname>wcf\\system\\condition\\person\\PersonLastNameTextPropertyCondition</classname>\n</type>\n</code></pre> <p><code>PersonFirstNameTextPropertyCondition</code> and <code>PersonLastNameTextPropertyCondition</code> only differ minimally so that we only focus on <code>PersonFirstNameTextPropertyCondition</code> here, which relies on the default implementation <code>AbstractObjectTextPropertyCondition</code> and only requires specifying different object properties:</p> files/lib/system/condition/person/PersonFirstNameTextPropertyCondition.class.php <pre><code><?php\n\nnamespace wcf\\system\\condition\\person;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\condition\\AbstractObjectTextPropertyCondition;\n\n/**\n * Condition implementation for the first name of a person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Core\\System\\Condition\n */\nfinal class PersonFirstNameTextPropertyCondition extends AbstractObjectTextPropertyCondition\n{\n /**\n * @inheritDoc\n */\n protected $className = Person::class;\n\n /**\n * @inheritDoc\n */\n protected $description = 'wcf.person.condition.firstName.description';\n\n /**\n * @inheritDoc\n */\n protected $fieldName = 'personFirstName';\n\n /**\n * @inheritDoc\n */\n protected $label = 'wcf.person.firstName';\n\n /**\n * @inheritDoc\n */\n protected $propertyName = 'firstName';\n\n /**\n * @inheritDoc\n */\n protected $supportsMultipleValues = true;\n}\n</code></pre> <ol> <li><code>$className</code> contains the class name of the relevant database object from which the class name of the database object list is derived and <code>$propertyName</code> is the name of the database object's property that contains the value used for filtering.</li> <li>By setting <code>$supportsMultipleValues</code> to <code>true</code>, multiple comma-separated values can be specified so that, for example, a box can also only list people with either of two specific first names.</li> <li><code>$description</code> (optional), <code>$fieldName</code>, and <code>$label</code> are used in the output of the form field.</li> </ol> <p>(The implementation here is specific for <code>AbstractObjectTextPropertyCondition</code>. The <code>wcf\\system\\condition</code> namespace also contains several other default condition implementations.)</p>"},{"location":"tutorial/series/part_5/","title":"Part 5: Person Information","text":"<p>This part of our tutorial series lays the foundation for future parts in which we will be using additional APIs, which we have not used in this series yet. To make use of those APIs, we need content generated by users in the frontend.</p>"},{"location":"tutorial/series/part_5/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 4, the package will provide the following functionality after this part of the tutorial:</p> <ul> <li>Users are able to add information on the people in the frontend.</li> <li>Users are able to edit and delete the pieces of information they added.</li> <li>Moderators are able to edit and delete all pieces of information.</li> </ul>"},{"location":"tutorial/series/part_5/#used-components","title":"Used Components","text":"<p>In addition to the components used in previous parts, we will use the form builder API to create forms shown in dialogs instead of dedicated pages and we will, for the first time, add TypeScript code.</p>"},{"location":"tutorial/series/part_5/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure excluding unchanged files from previous parts:</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.php\n\u2502 \u251c\u2500\u2500 js\n\u2502 \u2502 \u2514\u2500\u2500 WoltLabSuite\n\u2502 \u2502 \u2514\u2500\u2500 Core\n\u2502 \u2502 \u2514\u2500\u2500 Controller\n\u2502 \u2502 \u2514\u2500\u2500 Person.js\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 Person.class.php\n\u2502 \u2502 \u2514\u2500\u2500 information\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformation.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformationAction.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformationEditor.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonInformationList.class.php\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u2514\u2500\u2500 worker\n\u2502 \u2514\u2500\u2500 PersonRebuildDataWorker.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 objectType.xml\n\u251c\u2500\u2500 templates\n\u2502 \u251c\u2500\u2500 person.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u251c\u2500\u2500 ts\n\u2502 \u2514\u2500\u2500 WoltLabSuite\n\u2502 \u2514\u2500\u2500 Core\n\u2502 \u2514\u2500\u2500 Controller\n\u2502 \u2514\u2500\u2500 Person.ts\n\u2514\u2500\u2500 userGroupOption.xml\n</code></pre> <p>For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_5/#miscellaneous","title":"Miscellaneous","text":"<p>Before we focus on the main aspects of this part, we mention some minor aspects that will be used later on:</p> <ul> <li>Several new user group options and the relevant language items have been added related to creating, editing, and deleting information:<ul> <li><code>mod.person.canEditInformation</code> and <code>mod.person.canDeleteInformation</code> are moderative permissions to edit and delete any piece of information, regardless of who created it.</li> <li><code>user.person.canAddInformation</code> is the permission for users to add new pieces of information.</li> <li><code>user.person.canEditInformation</code> and <code>user.person.canDeleteInformation</code> are the user permissions to edit and the piece of information they created.</li> </ul> </li> <li>The actual information text will be entered via a WYSIWYG editor, which requires an object type of the definition <code>com.woltlab.wcf.message</code>: <code>com.woltlab.wcf.people.information</code>.</li> <li><code>personList.tpl</code> has been adjusted to show the number of pieces of information in the person statistics section.</li> <li>We have not updated the person list box to also support sorting by the number of pieces of information added for each person.</li> </ul>"},{"location":"tutorial/series/part_5/#person-information-model","title":"Person Information Model","text":"<p>The PHP file with the database layout has been updated as follows:</p> files/acp/database/install_com.woltlab.wcf.people.php <pre><code><?php\n\nuse wcf\\system\\database\\table\\column\\DefaultTrueBooleanDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\IntDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\NotNullInt10DatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\NotNullVarchar255DatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\ObjectIdDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\SmallintDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\TextDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\VarcharDatabaseTableColumn;\nuse wcf\\system\\database\\table\\DatabaseTable;\nuse wcf\\system\\database\\table\\index\\DatabaseTableForeignKey;\nuse wcf\\system\\database\\table\\index\\DatabaseTablePrimaryIndex;\n\nreturn [\n DatabaseTable::create('wcf1_person')\n ->columns([\n ObjectIdDatabaseTableColumn::create('personID'),\n NotNullVarchar255DatabaseTableColumn::create('firstName'),\n NotNullVarchar255DatabaseTableColumn::create('lastName'),\n NotNullInt10DatabaseTableColumn::create('informationCount')\n ->defaultValue(0),\n SmallintDatabaseTableColumn::create('comments')\n ->length(5)\n ->notNull()\n ->defaultValue(0),\n DefaultTrueBooleanDatabaseTableColumn::create('enableComments'),\n ])\n ->indices([\n DatabaseTablePrimaryIndex::create()\n ->columns(['personID']),\n ]),\n\n DatabaseTable::create('wcf1_person_information')\n ->columns([\n ObjectIdDatabaseTableColumn::create('informationID'),\n NotNullInt10DatabaseTableColumn::create('personID'),\n TextDatabaseTableColumn::create('information'),\n IntDatabaseTableColumn::create('userID')\n ->length(10),\n NotNullVarchar255DatabaseTableColumn::create('username'),\n VarcharDatabaseTableColumn::create('ipAddress')\n ->length(39)\n ->notNull(true)\n ->defaultValue(''),\n NotNullInt10DatabaseTableColumn::create('time'),\n ])\n ->indices([\n DatabaseTablePrimaryIndex::create()\n ->columns(['informationID']),\n ])\n ->foreignKeys([\n DatabaseTableForeignKey::create()\n ->columns(['personID'])\n ->referencedTable('wcf1_person')\n ->referencedColumns(['personID'])\n ->onDelete('CASCADE'),\n DatabaseTableForeignKey::create()\n ->columns(['userID'])\n ->referencedTable('wcf1_user')\n ->referencedColumns(['userID'])\n ->onDelete('SET NULL'),\n ]),\n];\n</code></pre> <ul> <li>The number of pieces of information per person is tracked via the new <code>informationCount</code> column.</li> <li>The <code>wcf1_person_information</code> table has been added for the <code>PersonInformation</code> model. The meaning of the different columns is explained in the property documentation part of <code>PersonInformation</code>'s documentation (see below). The two foreign keys ensure that if a person is deleted, all of their information is also deleted, and that if a user is deleted, the <code>userID</code> column is set to <code>NULL</code>.</li> </ul> files/lib/data/person/information/PersonInformation.class.php <pre><code><?php\n\nnamespace wcf\\data\\person\\information;\n\nuse wcf\\data\\DatabaseObject;\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\user\\UserProfile;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\cache\\runtime\\UserProfileRuntimeCache;\nuse wcf\\system\\html\\output\\HtmlOutputProcessor;\nuse wcf\\system\\WCF;\n\n/**\n * Represents a piece of information for a person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\\Information\n *\n * @property-read int $informationID unique id of the information\n * @property-read int $personID id of the person the information belongs to\n * @property-read string $information information text\n * @property-read int|null $userID id of the user who added the information or `null` if the user no longer exists\n * @property-read string $username name of the user who added the information\n * @property-read int $time timestamp at which the information was created\n */\nclass PersonInformation extends DatabaseObject\n{\n /**\n * Returns `true` if the active user can delete this piece of information and `false` otherwise.\n */\n public function canDelete(): bool\n {\n if (\n WCF::getUser()->userID\n && WCF::getUser()->userID == $this->userID\n && WCF::getSession()->getPermission('user.person.canDeleteInformation')\n ) {\n return true;\n }\n\n return WCF::getSession()->getPermission('mod.person.canDeleteInformation');\n }\n\n /**\n * Returns `true` if the active user can edit this piece of information and `false` otherwise.\n */\n public function canEdit(): bool\n {\n if (\n WCF::getUser()->userID\n && WCF::getUser()->userID == $this->userID\n && WCF::getSession()->getPermission('user.person.canEditInformation')\n ) {\n return true;\n }\n\n return WCF::getSession()->getPermission('mod.person.canEditInformation');\n }\n\n /**\n * Returns the formatted information.\n */\n public function getFormattedInformation(): string\n {\n $processor = new HtmlOutputProcessor();\n $processor->process(\n $this->information,\n 'com.woltlab.wcf.people.information',\n $this->informationID\n );\n\n return $processor->getHtml();\n }\n\n /**\n * Returns the person the information belongs to.\n */\n public function getPerson(): Person\n {\n return PersonRuntimeCache::getInstance()->getObject($this->personID);\n }\n\n /**\n * Returns the user profile of the user who added the information.\n */\n public function getUserProfile(): UserProfile\n {\n if ($this->userID) {\n return UserProfileRuntimeCache::getInstance()->getObject($this->userID);\n } else {\n return UserProfile::getGuestUserProfile($this->username);\n }\n }\n}\n</code></pre> <p><code>PersonInformation</code> provides two methods, <code>canDelete()</code> and <code>canEdit()</code>, to check whether the active user can delete or edit a specific piece of information. In both cases, it is checked if the current user has created the relevant piece of information to check the user-specific permissions or to fall back to the moderator-specific permissions.</p> <p>There also two getter methods for the person, the piece of information belongs to (<code>getPerson()</code>), and for the user profile of the user who created the information (<code>getUserProfile()</code>). In both cases, we use runtime caches, though in <code>getUserProfile()</code>, we also have to consider the case of the user who created the information being deleted, i.e. <code>userID</code> being <code>null</code>. For such a case, we also save the name of the user who created the information in <code>username</code>, so that we can return a guest user profile object in this case. The most interesting method is <code>getFormattedInformation()</code>, which returns the HTML code of the information text meant for output. To generate such an output, <code>HtmlOutputProcessor::process()</code> is used and here is where we first use the associated message object type <code>com.woltlab.wcf.people.information</code> mentioned before.</p> <p>While <code>PersonInformationEditor</code> is simply the default implementation and thus not explicitly shown here, <code>PersonInformationList::readObjects()</code> caches the relevant ids of the associated people and users who created the pieces of information using runtime caches:</p> files/lib/data/person/information/PersonInformationList.class.php <pre><code><?php\n\nnamespace wcf\\data\\person\\information;\n\nuse wcf\\data\\DatabaseObjectList;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\cache\\runtime\\UserProfileRuntimeCache;\n\n/**\n * Represents a list of person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\PersonInformation\n *\n * @method PersonInformation current()\n * @method PersonInformation[] getObjects()\n * @method PersonInformation|null search($objectID)\n * @property PersonInformation[] $objects\n */\nclass PersonInformationList extends DatabaseObjectList\n{\n public function readObjects()\n {\n parent::readObjects();\n\n UserProfileRuntimeCache::getInstance()->cacheObjectIDs(\\array_unique(\\array_filter(\\array_column(\n $this->objects,\n 'userID'\n ))));\n PersonRuntimeCache::getInstance()->cacheObjectIDs(\\array_unique(\\array_column(\n $this->objects,\n 'personID'\n )));\n }\n}\n</code></pre>"},{"location":"tutorial/series/part_5/#listing-and-deleting-person-information","title":"Listing and Deleting Person Information","text":"<p>The <code>person.tpl</code> template has been updated to include a block for listing the information at the beginning:</p> templates/person.tpl <pre><code>{capture assign='pageTitle'}{$person} - {lang}wcf.person.list{/lang}{/capture}\n\n{capture assign='contentTitle'}{$person}{/capture}\n\n{include file='header'}\n\n{if $person->informationCount || $__wcf->session->getPermission('user.person.canAddInformation')}\n <section class=\"section sectionContainerList\">\n <header class=\"sectionHeader\">\n <h2 class=\"sectionTitle\">\n {lang}wcf.person.information.list{/lang}\n {if $person->informationCount}\n <span class=\"badge\">{#$person->informationCount}</span>\n {/if}\n </h2>\n </header>\n\n <ul class=\"commentList containerList personInformationList jsObjectActionContainer\" {*\n *}data-object-action-class-name=\"wcf\\data\\person\\information\\PersonInformationAction\"{*\n *}>\n {if $__wcf->session->getPermission('user.person.canAddInformation')}\n <li class=\"containerListButtonGroup\">\n <ul class=\"buttonGroup\">\n <li>\n <a href=\"#\" class=\"button\" id=\"personInformationAddButton\">\n {icon name='plus'}\n <span>{lang}wcf.person.information.add{/lang}</span>\n </a>\n </li>\n </ul>\n </li>\n {/if}\n\n {foreach from=$person->getInformation() item=$information}\n <li class=\"comment personInformation jsObjectActionObject\" data-object-id=\"{$information->getObjectID()}\">\n <div class=\"box48{if $__wcf->getUserProfileHandler()->isIgnoredUser($information->userID, 2)} ignoredUserContent{/if}\">\n {user object=$information->getUserProfile() type='avatar48' ariaHidden='true' tabindex='-1'}\n\n <div class=\"commentContentContainer\">\n <div class=\"commentContent\">\n <div class=\"containerHeadline\">\n <h3>\n {if $information->userID}\n {user object=$information->getUserProfile()}\n {else}\n <span>{$information->username}</span>\n {/if}\n\n <small class=\"separatorLeft\">{unsafe:$information->time|time}</small>\n </h3>\n </div>\n\n <div class=\"htmlContent userMessage\" id=\"personInformation{$information->getObjectID()}\">\n {unsafe:$information->getFormattedInformation()}\n </div>\n\n <nav class=\"jsMobileNavigation buttonGroupNavigation\">\n <ul class=\"buttonList iconList\">\n {if $information->canEdit()}\n <li class=\"jsOnly\">\n <a href=\"#\" title=\"{lang}wcf.global.button.edit{/lang}\" class=\"jsEditInformation jsTooltip\">\n {icon name='pencil'}\n <span class=\"invisible\">{lang}wcf.global.button.edit{/lang}</span>\n </a>\n </li>\n {/if}\n {if $information->canDelete()}\n <li class=\"jsOnly\">\n <a href=\"#\" title=\"{lang}wcf.global.button.delete{/lang}\" class=\"jsObjectAction jsTooltip\" data-object-action=\"delete\" data-confirm-message=\"{lang}wcf.person.information.delete.confirmMessage{/lang}\">\n {icon name='times'}\n <span class=\"invisible\">{lang}wcf.global.button.edit{/lang}</span>\n </a>\n </li>\n {/if}\n\n {event name='informationOptions'}\n </ul>\n </nav>\n </div>\n </div>\n </div>\n </li>\n {/foreach}\n </ul>\n </section>\n{/if}\n\n{if $person->enableComments}\n {if $commentList|count || $commentCanAdd}\n <section id=\"comments\" class=\"section sectionContainerList\">\n <header class=\"sectionHeader\">\n <h2 class=\"sectionTitle\">\n {lang}wcf.person.comments{/lang}\n {if $person->comments}<span class=\"badge\">{#$person->comments}</span>{/if}\n </h2>\n </header>\n\n {include file='__commentJavaScript' commentContainerID='personCommentList'}\n\n <div class=\"personComments\">\n <ul id=\"personCommentList\" class=\"commentList containerList\" {*\n *}data-can-add=\"{if $commentCanAdd}true{else}false{/if}\" {*\n *}data-object-id=\"{$person->personID}\" {*\n *}data-object-type-id=\"{$commentObjectTypeID}\" {*\n *}data-comments=\"{if $person->comments}{$commentList->countObjects()}{else}0{/if}\" {*\n *}data-last-comment-time=\"{$lastCommentTime}\" {*\n *}>\n {include file='commentListAddComment' wysiwygSelector='personCommentListAddComment'}\n {include file='commentList'}\n </ul>\n </div>\n </section>\n {/if}\n{/if}\n\n<footer class=\"contentFooter\">\n {hascontent}\n <nav class=\"contentFooterNavigation\">\n <ul>\n {content}{event name='contentFooterNavigation'}{/content}\n </ul>\n </nav>\n {/hascontent}\n</footer>\n\n<script data-relocate=\"true\">\n require(['Language', 'WoltLabSuite/Core/Controller/Person'], (Language, ControllerPerson) => {\n Language.addObject({\n 'wcf.person.information.add': '{jslang}wcf.person.information.add{/jslang}',\n 'wcf.person.information.add.success': '{jslang}wcf.person.information.add.success{/jslang}',\n 'wcf.person.information.edit': '{jslang}wcf.person.information.edit{/jslang}',\n 'wcf.person.information.edit.success': '{jslang}wcf.person.information.edit.success{/jslang}',\n });\n\n ControllerPerson.init({$person->personID}, {\n canAddInformation: {if $__wcf->session->getPermission('user.person.canAddInformation')}true{else}false{/if},\n });\n });\n</script>\n\n{include file='footer'}\n</code></pre> <p>To keep things simple here, we reuse the structure and CSS classes used for comments. Additionally, we always list all pieces of information. If there are many pieces of information, a nicer solution would be a pagination or loading more pieces of information with JavaScript.</p> <p>First, we note the <code>jsObjectActionContainer</code> class in combination with the <code>data-object-action-class-name</code> attribute, which are needed for the delete button for each piece of information, as explained here. In <code>PersonInformationAction</code>, we have overridden the default implementations of <code>validateDelete()</code> and <code>delete()</code> which are called after clicking on a delete button. In <code>validateDelete()</code>, we call <code>PersonInformation::canDelete()</code> on all pieces of information to be deleted for proper permission validation, and in <code>delete()</code>, we update the <code>informationCount</code> values of the people the deleted pieces of information belong to (see below).</p> <p>The button to add a new piece of information, <code>#personInformationAddButton</code>, and the buttons to edit existing pieces of information, <code>.jsEditInformation</code>, are controlled with JavaScript code initialized at the very end of the template.</p> <p>Lastly, in <code>create()</code> we provide default values for the <code>time</code>, <code>userID</code>, <code>username</code>, and <code>ipAddress</code> for cases like here when creating a new piece of information, where do not explicitly provide this data. Additionally, we extract the information text from the <code>information_htmlInputProcessor</code> parameter provided by the associated WYSIWYG form field and update the number of pieces of information created for the relevant person.</p>"},{"location":"tutorial/series/part_5/#creating-and-editing-person-information","title":"Creating and Editing Person Information","text":"<p>To create new pieces of information or editing existing ones, we do not add new form controllers but instead use dialogs generated by the form builder API so that the user does not have to leave the person page.</p> <p>When clicking on the add button or on any of the edit buttons, a dialog opens with the relevant form:</p> ts/WoltLabSuite/Core/Controller/Person.ts <pre><code>/**\n * Provides the JavaScript code for the person page.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @module WoltLabSuite/Core/Controller/Person\n */\n\nimport FormBuilderDialog from \"WoltLabSuite/Core/Form/Builder/Dialog\";\nimport * as Language from \"WoltLabSuite/Core/Language\";\nimport * as UiNotification from \"WoltLabSuite/Core/Ui/Notification\";\n\nlet addDialog: FormBuilderDialog;\nconst editDialogs = new Map<string, FormBuilderDialog>();\n\ninterface EditReturnValues {\n formattedInformation: string;\n informationID: number;\n}\n\ninterface Options {\n canAddInformation: true;\n}\n\n/**\n * Opens the edit dialog after clicking on the edit button for a piece of information.\n */\nfunction editInformation(event: Event): void {\n event.preventDefault();\n\n const currentTarget = event.currentTarget as HTMLElement;\n const information = currentTarget.closest(\".jsObjectActionObject\") as HTMLElement;\n const informationId = information.dataset.objectId!;\n\n if (!editDialogs.has(informationId)) {\n editDialogs.set(\n informationId,\n new FormBuilderDialog(\n `personInformationEditDialog${informationId}`,\n \"wcf\\\\data\\\\person\\\\information\\\\PersonInformationAction\",\n \"getEditDialog\",\n {\n actionParameters: {\n informationID: informationId,\n },\n dialog: {\n title: Language.get(\"wcf.person.information.edit\"),\n },\n submitActionName: \"submitEditDialog\",\n successCallback(returnValues: EditReturnValues) {\n document.getElementById(`personInformation${returnValues.informationID}`)!.innerHTML =\n returnValues.formattedInformation;\n\n UiNotification.show(Language.get(\"wcf.person.information.edit.success\"));\n },\n },\n ),\n );\n }\n\n editDialogs.get(informationId)!.open();\n}\n\n/**\n * Initializes the JavaScript code for the person page.\n */\nexport function init(personId: number, options: Options): void {\n if (options.canAddInformation) {\n // Initialize the dialog to add new information.\n addDialog = new FormBuilderDialog(\n \"personInformationAddDialog\",\n \"wcf\\\\data\\\\person\\\\information\\\\PersonInformationAction\",\n \"getAddDialog\",\n {\n actionParameters: {\n personID: personId,\n },\n dialog: {\n title: Language.get(\"wcf.person.information.add\"),\n },\n submitActionName: \"submitAddDialog\",\n successCallback() {\n UiNotification.show(Language.get(\"wcf.person.information.add.success\"), () => window.location.reload());\n },\n },\n );\n\n document.getElementById(\"personInformationAddButton\")!.addEventListener(\"click\", (event) => {\n event.preventDefault();\n\n addDialog.open();\n });\n }\n\n document\n .querySelectorAll(\".jsEditInformation\")\n .forEach((el) => el.addEventListener(\"click\", (ev) => editInformation(ev)));\n}\n</code></pre> <p>We use the <code>WoltLabSuite/Core/Form/Builder/Dialog</code> module, which takes care of the internal handling with regard to these dialogs. We only have to provide some data during for initializing these objects and call the <code>open()</code> function after a button has been clicked.</p> <p>Explanation of the initialization arguments for <code>WoltLabSuite/Core/Form/Builder/Dialog</code> used here:</p> <ul> <li>The first argument is the id of the dialog used to identify it.</li> <li>The second argument is the PHP class name which provides the contents of the dialog's form and handles the data after the form is submitted.</li> <li>The third argument is the name of the method in the referenced PHP class in the previous argument that returns the dialog form.</li> <li>The fourth argument contains additional options:<ul> <li><code>actionParameters</code> are additional parameters send during each AJAX request. Here, we either pass the id of the person for who a new piece of information is added or the id of the edited piece of information.</li> <li><code>dialog</code> contains the options for the dialog, see the <code>DialogOptions</code> interface. Here, we only provide the title of the dialog.</li> <li><code>submitActionName</code> is the name of the method in the referenced PHP class that is called with the form data after submitting the form.</li> <li><code>successCallback</code> is called after the submit AJAX request was successful. After adding a new piece of information, we reload the page, and after editing an existing piece of information, we update the existing information text with the updated text. (Dynamically inserting a newly added piece of information instead of reloading the page would also be possible, of course, but for this tutorial series, we kept things simple.)</li> </ul> </li> </ul> <p>Next, we focus on <code>PersonInformationAction</code>, which actually provides the contents of these dialogs and creates and edits the information:</p> files/lib/data/person/information/PersonInformationAction.class.php <pre><code><?php\n\nnamespace wcf\\data\\person\\information;\n\nuse wcf\\data\\AbstractDatabaseObjectAction;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\data\\person\\PersonEditor;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\exception\\IllegalLinkException;\nuse wcf\\system\\exception\\PermissionDeniedException;\nuse wcf\\system\\exception\\UserInputException;\nuse wcf\\system\\form\\builder\\container\\wysiwyg\\WysiwygFormContainer;\nuse wcf\\system\\form\\builder\\DialogFormDocument;\nuse wcf\\system\\html\\input\\HtmlInputProcessor;\nuse wcf\\system\\WCF;\nuse wcf\\util\\UserUtil;\n\n/**\n * Executes person information-related actions.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\\Information\n *\n * @method PersonInformationEditor[] getObjects()\n * @method PersonInformationEditor getSingleObject()\n */\nclass PersonInformationAction extends AbstractDatabaseObjectAction\n{\n /**\n * @var DialogFormDocument\n */\n public $dialog;\n\n /**\n * @var PersonInformation\n */\n public $information;\n\n /**\n * @return PersonInformation\n */\n public function create()\n {\n if (!isset($this->parameters['data']['time'])) {\n $this->parameters['data']['time'] = TIME_NOW;\n }\n if (!isset($this->parameters['data']['userID'])) {\n $this->parameters['data']['userID'] = WCF::getUser()->userID;\n $this->parameters['data']['username'] = WCF::getUser()->username;\n }\n\n if (LOG_IP_ADDRESS) {\n if (!isset($this->parameters['data']['ipAddress'])) {\n $this->parameters['data']['ipAddress'] = UserUtil::getIpAddress();\n }\n } else {\n unset($this->parameters['data']['ipAddress']);\n }\n\n if (!empty($this->parameters['information_htmlInputProcessor'])) {\n /** @var HtmlInputProcessor $htmlInputProcessor */\n $htmlInputProcessor = $this->parameters['information_htmlInputProcessor'];\n $this->parameters['data']['information'] = $htmlInputProcessor->getHtml();\n }\n\n /** @var PersonInformation $information */\n $information = parent::create();\n\n (new PersonAction([$information->personID], 'update', [\n 'counters' => [\n 'informationCount' => 1,\n ],\n ]))->executeAction();\n\n return $information;\n }\n\n /**\n * @inheritDoc\n */\n public function update()\n {\n if (!empty($this->parameters['information_htmlInputProcessor'])) {\n /** @var HtmlInputProcessor $htmlInputProcessor */\n $htmlInputProcessor = $this->parameters['information_htmlInputProcessor'];\n $this->parameters['data']['information'] = $htmlInputProcessor->getHtml();\n }\n\n parent::update();\n }\n\n /**\n * @inheritDoc\n */\n public function validateDelete()\n {\n if (empty($this->objects)) {\n $this->readObjects();\n\n if (empty($this->objects)) {\n throw new UserInputException('objectIDs');\n }\n }\n\n foreach ($this->getObjects() as $informationEditor) {\n if (!$informationEditor->canDelete()) {\n throw new PermissionDeniedException();\n }\n }\n }\n\n /**\n * @inheritDoc\n */\n public function delete()\n {\n $deleteCount = parent::delete();\n\n if (!$deleteCount) {\n return $deleteCount;\n }\n\n $counterUpdates = [];\n foreach ($this->getObjects() as $informationEditor) {\n if (!isset($counterUpdates[$informationEditor->personID])) {\n $counterUpdates[$informationEditor->personID] = 0;\n }\n\n $counterUpdates[$informationEditor->personID]--;\n }\n\n WCF::getDB()->beginTransaction();\n foreach ($counterUpdates as $personID => $counterUpdate) {\n (new PersonEditor(PersonRuntimeCache::getInstance()->getObject($personID)))->updateCounters([\n 'informationCount' => $counterUpdate,\n ]);\n }\n WCF::getDB()->commitTransaction();\n\n return $deleteCount;\n }\n\n /**\n * Validates the `getAddDialog` action.\n */\n public function validateGetAddDialog(): void\n {\n WCF::getSession()->checkPermissions(['user.person.canAddInformation']);\n\n $this->readInteger('personID');\n if (PersonRuntimeCache::getInstance()->getObject($this->parameters['personID']) === null) {\n throw new UserInputException('personID');\n }\n }\n\n /**\n * Returns the data to show the dialog to add a new piece of information on a person.\n *\n * @return string[]\n */\n public function getAddDialog(): array\n {\n $this->buildDialog();\n\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n /**\n * Validates the `submitAddDialog` action.\n */\n public function validateSubmitAddDialog(): void\n {\n $this->validateGetAddDialog();\n\n $this->buildDialog();\n $this->dialog->requestData($_POST['parameters']['data'] ?? []);\n $this->dialog->readValues();\n $this->dialog->validate();\n }\n\n /**\n * Creates a new piece of information on a person after submitting the dialog.\n *\n * @return string[]\n */\n public function submitAddDialog(): array\n {\n // If there are any validation errors, show the form again.\n if ($this->dialog->hasValidationErrors()) {\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n (new static([], 'create', \\array_merge($this->dialog->getData(), [\n 'data' => [\n 'personID' => $this->parameters['personID'],\n ],\n ])))->executeAction();\n\n return [];\n }\n\n /**\n * Validates the `getEditDialog` action.\n */\n public function validateGetEditDialog(): void\n {\n WCF::getSession()->checkPermissions(['user.person.canAddInformation']);\n\n $this->readInteger('informationID');\n $this->information = new PersonInformation($this->parameters['informationID']);\n if (!$this->information->getObjectID()) {\n throw new UserInputException('informationID');\n }\n if (!$this->information->canEdit()) {\n throw new IllegalLinkException();\n }\n }\n\n /**\n * Returns the data to show the dialog to edit a piece of information on a person.\n *\n * @return string[]\n */\n public function getEditDialog(): array\n {\n $this->buildDialog();\n $this->dialog->updatedObject($this->information);\n\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n /**\n * Validates the `submitEditDialog` action.\n */\n public function validateSubmitEditDialog(): void\n {\n $this->validateGetEditDialog();\n\n $this->buildDialog();\n $this->dialog->updatedObject($this->information, false);\n $this->dialog->requestData($_POST['parameters']['data'] ?? []);\n $this->dialog->readValues();\n $this->dialog->validate();\n }\n\n /**\n * Updates a piece of information on a person after submitting the edit dialog.\n *\n * @return string[]\n */\n public function submitEditDialog(): array\n {\n // If there are any validation errors, show the form again.\n if ($this->dialog->hasValidationErrors()) {\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n (new static([$this->information], 'update', $this->dialog->getData()))->executeAction();\n\n // Reload the information with the updated data.\n $information = new PersonInformation($this->information->getObjectID());\n\n return [\n 'formattedInformation' => $information->getFormattedInformation(),\n 'informationID' => $this->information->getObjectID(),\n ];\n }\n\n /**\n * Builds the dialog to create or edit person information.\n */\n protected function buildDialog(): void\n {\n if ($this->dialog !== null) {\n return;\n }\n\n $this->dialog = DialogFormDocument::create('personInformationAddDialog')\n ->appendChild(\n WysiwygFormContainer::create('information')\n ->messageObjectType('com.woltlab.wcf.people.information')\n ->required()\n );\n\n EventHandler::getInstance()->fireAction($this, 'buildDialog');\n\n $this->dialog->build();\n }\n}\n</code></pre> <p>When setting up the <code>WoltLabSuite/Core/Form/Builder/Dialog</code> object for adding new pieces of information, we specified <code>getAddDialog</code> and <code>submitAddDialog</code> as the names of the dialog getter and submit handler. In addition to these two methods, the matching validation methods <code>validateGetAddDialog()</code> and <code>validateGetAddDialog()</code> are also added. As the forms for adding and editing pieces of information have the same structure, this form is created in <code>buildDialog()</code> using a <code>DialogFormDocument</code> object, which is intended for forms in dialogs. We fire an event in <code>buildDialog()</code> so that plugins are able to easily extend the dialog with additional data.</p> <p><code>validateGetAddDialog()</code> checks if the user has the permission to create new pieces of information and if a valid id for the person, the information will belong to, is given. The method configured in the <code>WoltLabSuite/Core/Form/Builder/Dialog</code> object returning the dialog is expected to return two values: the id of the form (<code>formId</code>) and the contents of form shown in the dialog (<code>dialog</code>). This data is returned by <code>getAddDialog</code> using the dialog build previously by <code>buildDialog()</code>.</p> <p>After the form is submitted, <code>validateSubmitAddDialog()</code> has to do the same basic validation as <code>validateGetAddDialog()</code> so that <code>validateGetAddDialog()</code> is simply called. Additionally, the form data is read and validated. In <code>submitAddDialog()</code>, we first check if there have been any validation errors: If any error occured during validation, we return the same data as in <code>getAddDialog()</code> so that the dialog is shown again with the erroneous fields marked as such. Otherwise, if the validation succeeded, the form data is used to create the new piece of information. In addition to the form data, we manually add the id of the person to whom the information belongs to. Lastly, we could return some data that we could access in the JavaScript callback function after successfully submitting the dialog. As we will simply be reloading the page, no such data is returned. An alternative to reloading to the page would be dynamically inserting the new piece of information in the list so that we would have to return the rendered list item for the new piece of information.</p> <p>The process for getting and submitting the dialog to edit existing pieces of information is similar to the process for adding new pieces of information. Instead of the id of the person, however, we now pass the id of the edited piece of information and in <code>submitEditDialog()</code>, we update the edited information instead of creating a new one like in <code>submitAddDialog()</code>. After editing a piece of information, we do not reload the page but dynamically update the text of the information in the TypeScript code so that we return the updated rendered information text and id of the edited pieced of information in <code>submitAddDialog()</code>.</p>"},{"location":"tutorial/series/part_5/#rebuild-data-worker","title":"Rebuild Data Worker","text":"<p>To ensure the integrity of the person data, <code>PersonRebuildDataWorker</code> updates the <code>informationCount</code> counter:</p> files/lib/system/worker/PersonRebuildDataWorker.class.php <pre><code><?php\n\nnamespace wcf\\system\\worker;\n\nuse wcf\\data\\person\\PersonList;\nuse wcf\\system\\WCF;\n\n/**\n * Worker implementation for updating people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Worker\n *\n * @method PersonList getObjectList()\n */\nfinal class PersonRebuildDataWorker extends AbstractRebuildDataWorker\n{\n /**\n * @inheritDoc\n */\n protected $limit = 500;\n\n /**\n * @inheritDoc\n */\n protected $objectListClassName = PersonList::class;\n\n /**\n * @inheritDoc\n */\n protected function initObjectList()\n {\n parent::initObjectList();\n\n $this->objectList->sqlOrderBy = 'person.personID';\n }\n\n /**\n * @inheritDoc\n */\n public function execute()\n {\n parent::execute();\n\n if (!\\count($this->objectList)) {\n return;\n }\n\n $sql = \"UPDATE wcf1_person person\n SET informationCount = (\n SELECT COUNT(*)\n FROM wcf1_person_information person_information\n WHERE person_information.personID = person.personID\n )\n WHERE person.personID = ?\";\n $statement = WCF::getDB()->prepare($sql);\n\n WCF::getDB()->beginTransaction();\n foreach ($this->getObjectList() as $person) {\n $statement->execute([$person->personID]);\n }\n WCF::getDB()->commitTransaction();\n }\n}\n</code></pre>"},{"location":"tutorial/series/part_5/#username-and-ip-address-event-listeners","title":"Username and IP Address Event Listeners","text":"<p>As we store the name of the user who create a new piece of information and store their IP address, we have to add event listeners to properly handle the following scenarios:</p> <ol> <li>If the user is renamed, the value of <code>username</code> stored with the person information has to be updated, which can be achieved by a simple event listener that only has to specify the name of relevant database table if <code>AbstractUserActionRenameListener</code> is extended:</li> </ol> files/lib/system/event/listener/PersonUserActionRenameListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\n/**\n * Updates person information during user renaming.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserActionRenameListener extends AbstractUserActionRenameListener\n{\n /**\n * @inheritDoc\n */\n protected $databaseTables = [\n 'wcf{WCF_N}_person_information',\n ];\n}\n</code></pre> <ol> <li>If users are merged, all pieces of information need to be assigned to the target user of the merging. Again, we only have to specify the name of relevant database table if <code>AbstractUserMergeListener</code> is extended:</li> </ol> files/lib/system/event/listener/PersonUserMergeListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\n/**\n * Updates person information during user merging.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserMergeListener extends AbstractUserMergeListener\n{\n /**\n * @inheritDoc\n */\n protected $databaseTables = [\n 'wcf{WCF_N}_person_information',\n ];\n}\n</code></pre> <ol> <li>If the option to prune stored ip addresses after a certain period of time is enabled, we also have to prune them in the person information database table. Here we also only have to specify the name of the relevant database table and provide the mapping from the <code>ipAddress</code> column to the <code>time</code> column:</li> </ol> files/lib/system/event/listener/PersonPruneIpAddressesCronjobListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\system\\cronjob\\PruneIpAddressesCronjob;\n\n/**\n * Prunes old ip addresses.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonPruneIpAddressesCronjobListener extends AbstractEventListener\n{\n protected function onExecute(PruneIpAddressesCronjob $cronjob): void\n {\n $cronjob->columns['wcf' . WCF_N . '_person_information']['ipAddress'] = 'time';\n }\n}\n</code></pre> <ol> <li>The ip addresses in the person information database table also have to be considered for the user data export which can also be done with minimal effort by providing the name of the relevant database table:</li> </ol> files/lib/system/event/listener/PersonUserExportGdprListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\acp\\action\\UserExportGdprAction;\n\n/**\n * Adds the ip addresses stored with the person information during user data export.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserExportGdprListener extends AbstractEventListener\n{\n protected function onExport(UserExportGdprAction $action): void\n {\n $action->ipAddresses['com.woltlab.wcf.people'] = ['wcf' . WCF_N . '_person_information'];\n }\n}\n</code></pre> <p>Lastly, we present the updated <code>eventListener.xml</code> file with new entries for all of these event listeners:</p> eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/eventListener.xsd\">\n <import>\n <eventlistener name=\"rename@wcf\\data\\user\\UserAction\">\n <eventclassname>wcf\\data\\user\\UserAction</eventclassname>\n <eventname>rename</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserActionRenameListener</listenerclassname>\n <environment>all</environment>\n </eventlistener>\n <eventlistener name=\"save@wcf\\acp\\form\\UserMergeForm\">\n <eventclassname>wcf\\acp\\form\\UserMergeForm</eventclassname>\n <eventname>save</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserMergeListener</listenerclassname>\n <environment>admin</environment>\n </eventlistener>\n <eventlistener name=\"execute@wcf\\system\\cronjob\\PruneIpAddressesCronjob\">\n <eventclassname>wcf\\system\\cronjob\\PruneIpAddressesCronjob</eventclassname>\n <eventname>execute</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonPruneIpAddressesCronjobListener</listenerclassname>\n <environment>all</environment>\n </eventlistener>\n <eventlistener name=\"export@wcf\\acp\\action\\UserExportGdprAction\">\n <eventclassname>wcf\\acp\\action\\UserExportGdprAction</eventclassname>\n <eventname>export</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserExportGdprListener</listenerclassname>\n <environment>admin</environment>\n </eventlistener>\n </import>\n</data>\n</code></pre>"},{"location":"tutorial/series/part_6/","title":"Part 6: Activity Points and Activity Events","text":"<p>In this part of our tutorial series, we use the person information added in the previous part to award activity points to users adding new pieces of information and to also create activity events for these pieces of information.</p>"},{"location":"tutorial/series/part_6/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 5, the package will provide the following functionality after this part of the tutorial:</p> <ul> <li>Users are awarded activity points for adding new pieces of information for people.</li> <li>If users add new pieces of information for people, activity events are added which are then shown in the list of recent activities.</li> </ul>"},{"location":"tutorial/series/part_6/#used-components","title":"Used Components","text":"<p>In addition to the components used in previous parts, we will use the user activity points API and the user activity events API.</p>"},{"location":"tutorial/series/part_6/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure excluding unchanged files from previous parts:</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 PersonAction.class.php\n\u2502 \u2502 \u2514\u2500\u2500 information\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformation.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonInformationAction.class.php\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u251c\u2500\u2500 user\n\u2502 \u2502 \u2514\u2500\u2500 activity\n\u2502 \u2502 \u2514\u2500\u2500 event\n\u2502 \u2502 \u2514\u2500\u2500 PersonInformationUserActivityEvent.class.php\n\u2502 \u2514\u2500\u2500 worker\n\u2502 \u251c\u2500\u2500 PersonInformationRebuildDataWorker.class.php\n\u2502 \u2514\u2500\u2500 PersonRebuildDataWorker.class.php\n\u251c\u2500\u2500 eventListener.xml\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u2514\u2500\u2500 objectType.xml\n</code></pre> <p>For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_6/#user-activity-points","title":"User Activity Points","text":"<p>The first step to support activity points is to register an object type for the <code>com.woltlab.wcf.user.activityPointEvent</code> object type definition for created person information and specify the default number of points awarded per piece of information:</p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.people.information</name>\n <definitionname>com.woltlab.wcf.user.activityPointEvent</definitionname>\n <points>2</points>\n</type>\n</code></pre> <p>Additionally, the phrase <code>wcf.user.activityPoint.objectType.com.woltlab.wcf.people.information</code> (in general: <code>wcf.user.activityPoint.objectType.{objectType}</code>) has to be added.</p> <p>The activity points are awarded when new pieces are created via <code>PersonInformation::create()</code> using <code>UserActivityPointHandler::fireEvent()</code> and removed in <code>PersonInformation::create()</code> via <code>UserActivityPointHandler::removeEvents()</code> if pieces of information are deleted.</p> <p>Lastly, we have to add two components for updating data: First, we register a new rebuild data worker</p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.people.information</name>\n <definitionname>com.woltlab.wcf.rebuildData</definitionname>\n <classname>wcf\\system\\worker\\PersonInformationRebuildDataWorker</classname>\n</type>\n</code></pre> files/lib/system/worker/PersonInformationRebuildDataWorker.class.php <pre><code><?php\n\nnamespace wcf\\system\\worker;\n\nuse wcf\\data\\person\\information\\PersonInformationList;\nuse wcf\\system\\user\\activity\\point\\UserActivityPointHandler;\n\n/**\n * Worker implementation for updating person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Worker\n *\n * @method PersonInformationList getObjectList()\n */\nfinal class PersonInformationRebuildDataWorker extends AbstractRebuildDataWorker\n{\n /**\n * @inheritDoc\n */\n protected $objectListClassName = PersonInformationList::class;\n\n /**\n * @inheritDoc\n */\n protected $limit = 500;\n\n /**\n * @inheritDoc\n */\n protected function initObjectList()\n {\n parent::initObjectList();\n\n $this->objectList->sqlOrderBy = 'person_information.personID';\n }\n\n /**\n * @inheritDoc\n */\n public function execute()\n {\n parent::execute();\n\n if (!$this->loopCount) {\n UserActivityPointHandler::getInstance()->reset('com.woltlab.wcf.people.information');\n }\n\n if (!\\count($this->objectList)) {\n return;\n }\n\n $itemsToUser = [];\n foreach ($this->getObjectList() as $personInformation) {\n if ($personInformation->userID) {\n if (!isset($itemsToUser[$personInformation->userID])) {\n $itemsToUser[$personInformation->userID] = 0;\n }\n\n $itemsToUser[$personInformation->userID]++;\n }\n }\n\n UserActivityPointHandler::getInstance()->fireEvents(\n 'com.woltlab.wcf.people.information',\n $itemsToUser,\n false\n );\n }\n}\n</code></pre> <p>which updates the number of instances for which any user received person information activity points. (This data worker also requires the phrases <code>wcf.acp.rebuildData.com.woltlab.wcf.people.information</code> and <code>wcf.acp.rebuildData.com.woltlab.wcf.people.information.description</code>).</p> <p>Second, we add an event listener for <code>UserActivityPointItemsRebuildDataWorker</code> to update the total user activity points awarded for person information:</p> eventListener.xml<pre><code><eventlistener name=\"execute@wcf\\system\\worker\\UserActivityPointItemsRebuildDataWorker\">\n <eventclassname>wcf\\system\\worker\\UserActivityPointItemsRebuildDataWorker</eventclassname>\n <eventname>execute</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserActivityPointItemsRebuildDataWorkerListener</listenerclassname>\n <environment>admin</environment>\n</eventlistener>\n</code></pre> files/lib/system/event/listener/PersonUserActivityPointItemsRebuildDataWorkerListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\system\\database\\util\\PreparedStatementConditionBuilder;\nuse wcf\\system\\user\\activity\\point\\UserActivityPointHandler;\nuse wcf\\system\\WCF;\nuse wcf\\system\\worker\\UserActivityPointItemsRebuildDataWorker;\n\n/**\n * Updates the user activity point items counter for person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserActivityPointItemsRebuildDataWorkerListener extends AbstractEventListener\n{\n protected function onExecute(UserActivityPointItemsRebuildDataWorker $worker): void\n {\n $objectType = UserActivityPointHandler::getInstance()\n ->getObjectTypeByName('com.woltlab.wcf.people.information');\n\n $conditionBuilder = new PreparedStatementConditionBuilder();\n $conditionBuilder->add('user_activity_point.objectTypeID = ?', [$objectType->objectTypeID]);\n $conditionBuilder->add('user_activity_point.userID IN (?)', [$worker->getObjectList()->getObjectIDs()]);\n\n $sql = \"UPDATE wcf1_user_activity_point user_activity_point\n SET user_activity_point.items = (\n SELECT COUNT(*)\n FROM wcf1_person_information person_information\n WHERE person_information.userID = user_activity_point.userID\n ),\n user_activity_point.activityPoints = user_activity_point.items * ?\n {$conditionBuilder}\";\n $statement = WCF::getDB()->prepare($sql);\n $statement->execute([\n $objectType->points,\n ...$conditionBuilder->getParameters()\n ]);\n }\n}\n</code></pre>"},{"location":"tutorial/series/part_6/#user-activity-events","title":"User Activity Events","text":"<p>To support user activity events, an object type for <code>com.woltlab.wcf.user.recentActivityEvent</code> has to be registered with a class implementing <code>wcf\\system\\user\\activity\\event\\IUserActivityEvent</code>:</p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.people.information</name>\n <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>\n <classname>wcf\\system\\user\\activity\\event\\PersonInformationUserActivityEvent</classname>\n</type>\n</code></pre> files/lib/system/user/activity/event/PersonInformationUserActivityEvent.class.php <pre><code><?php\n\nnamespace wcf\\system\\user\\activity\\event;\n\nuse wcf\\data\\person\\information\\PersonInformationList;\nuse wcf\\system\\SingletonFactory;\nuse wcf\\system\\WCF;\n\n/**\n * User activity event implementation for person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\User\\Activity\\Event\n */\nfinal class PersonInformationUserActivityEvent extends SingletonFactory implements IUserActivityEvent\n{\n /**\n * @inheritDoc\n */\n public function prepare(array $events)\n {\n $objectIDs = \\array_column($events, 'objectID');\n\n $informationList = new PersonInformationList();\n $informationList->setObjectIDs($objectIDs);\n $informationList->readObjects();\n $information = $informationList->getObjects();\n\n foreach ($events as $event) {\n if (isset($information[$event->objectID])) {\n $personInformation = $information[$event->objectID];\n\n $event->setIsAccessible();\n $event->setTitle(\n WCF::getLanguage()->getDynamicVariable(\n 'wcf.user.profile.recentActivity.personInformation',\n [\n 'person' => $personInformation->getPerson(),\n 'personInformation' => $personInformation,\n ]\n )\n );\n $event->setDescription($personInformation->getFormattedExcerpt());\n }\n }\n }\n}\n</code></pre> <p><code>PersonInformationUserActivityEvent::prepare()</code> must check for all events whether the associated piece of information still exists and if it is the case, mark the event as accessible via the <code>setIsAccessible()</code> method, set the title of the activity event via <code>setTitle()</code>, and set a description of the event via <code>setDescription()</code> for which we use the newly added <code>PersonInformation::getFormattedExcerpt()</code> method.</p> <p>Lastly, we have to add the phrase <code>wcf.user.recentActivity.com.woltlab.wcf.people.information</code>, which is shown in the list of activity events as the type of activity event.</p>"},{"location":"view/css/","title":"CSS","text":""},{"location":"view/css/#scss-and-css","title":"SCSS and CSS","text":"<p>SCSS is a scripting language that features a syntax similar to CSS and compiles into native CSS at runtime. It provides many great additions to CSS such as declaration nesting and variables, it is recommended to read the official guide to learn more.</p> <p>You can create <code>.scss</code> files containing only pure CSS code and it will work just fine, you are at no point required to write actual SCSS code.</p>"},{"location":"view/css/#file-location","title":"File Location","text":"<p>Please place your style files in a subdirectory of the <code>style/</code> directory of the target application or the Core's style directory, for example <code>style/layout/pageHeader.scss</code>.</p>"},{"location":"view/css/#variables","title":"Variables","text":"<p>You can access variables with <code>$myVariable</code>, variable interpolation (variables inside strings) is accomplished with <code>#{$myVariable}</code>.</p>"},{"location":"view/css/#linking-images","title":"Linking images","text":"<p>Images used within a style must be located in the style's image folder. To get the folder name within the CSS the SCSS variable <code>#{$style_image_path}</code> can be used. The value will contain a trailing slash.</p>"},{"location":"view/css/#media-breakpoints","title":"Media Breakpoints","text":"<p>Media breakpoints instruct the browser to apply different CSS depending on the viewport dimensions, e.g. serving a desktop PC a different view than when viewed on a smartphone.</p> <pre><code>/* red background color for desktop pc */\n@include screen-lg {\n body {\n background-color: red;\n }\n}\n\n/* green background color on smartphones and tablets */\n@include screen-md-down {\n body {\n background-color: green;\n }\n}\n</code></pre>"},{"location":"view/css/#available-breakpoints","title":"Available Breakpoints","text":"<p>Some very large smartphones, for example the Apple iPhone 7 Plus, do match the media query for <code>Tablets (portrait)</code> when viewed in landscape mode.</p> Name Devices <code>@media</code> equivalent <code>screen-xs</code> Smartphones only <code>(max-width: 544px)</code> <code>screen-sm</code> Tablets (portrait) <code>(min-width: 545px) and (max-width: 768px)</code> <code>screen-sm-down</code> Tablets (portrait) and smartphones <code>(max-width: 768px)</code> <code>screen-sm-up</code> Tablets and desktop PC <code>(min-width: 545px)</code> <code>screen-sm-md</code> Tablets only <code>(min-width: 545px) and (max-width: 1024px)</code> <code>screen-md</code> Tablets (landscape) <code>(min-width: 769px) and (max-width: 1024px)</code> <code>screen-md-down</code> Smartphones and tablets <code>(max-width: 1024px)</code> <code>screen-md-up</code> Tablets (landscape) and desktop PC <code>(min-width: 769px)</code> <code>screen-lg</code> Desktop PC <code>(min-width: 1025px)</code> <code>screen-lg-only</code> Desktop PC <code>(min-width: 1025px) and (max-width: 1280px)</code> <code>screen-lg-down</code> Smartphones, tablets, and desktop PC <code>(max-width: 1280px)</code> <code>screen-xl</code> Desktop PC <code>(min-width: 1281px)</code>"},{"location":"view/css/#asset-preloading","title":"Asset Preloading","text":"<p>WoltLab Suite\u2019s SCSS compiler supports adding preloading metadata to the CSS. To communicate the preloading intent to the compiler, the <code>--woltlab-suite-preload</code> CSS variable is set to the result of the <code>preload()</code> function:</p> <pre><code>.fooBar {\n --woltlab-suite-preload: #{preload(\n '#{$style_image_path}custom/background.png',\n $as: \"image\",\n $crossorigin: false,\n $type: \"image/png\"\n )};\n\n background: url('#{$style_image_path}custom/background.png');\n}\n</code></pre> <p>The parameters of the <code>preload()</code> function map directly to the preloading properties that are used within the <code><link></code> tag and the <code>link:</code> HTTP response header.</p> <p>The above example will result in a <code><link></code> similar to the following being added to the generated HTML:</p> <pre><code><link rel=\"preload\" href=\"https://example.com/images/style-1/custom/background.png\" as=\"image\" type=\"image/png\">\n</code></pre> <p>Use preloading sparingly for the most important resources where you can be certain that the browser will need them. Unused preloaded resources will unnecessarily waste bandwidth.</p>"},{"location":"view/languages-naming-conventions/","title":"Language Naming Conventions","text":"<p>This page contains general rules for naming language items and for their values. API-specific rules are listed on the relevant API page:</p> <ul> <li>Comments</li> </ul>"},{"location":"view/languages-naming-conventions/#forms","title":"Forms","text":""},{"location":"view/languages-naming-conventions/#fields","title":"Fields","text":"<p>If you have an application <code>foo</code> and a database object <code>foo\\data\\bar\\Bar</code> with a property <code>baz</code> that can be set via a form field, the name of the corresponding language item has to be <code>foo.bar.baz</code>. If you want to add an additional description below the field, use the language item <code>foo.bar.baz.description</code>.</p>"},{"location":"view/languages-naming-conventions/#error-texts","title":"Error Texts","text":"<p>If an error of type <code>{error type}</code> for the previously mentioned form field occurs during validation, you have to use the language item <code>foo.bar.baz.error.{error type}</code> for the language item describing the error.</p> <p>Exception to this rule: There are several general error messages like <code>wcf.global.form.error.empty</code> that have to be used for general errors like an empty field that may not be empty to avoid duplication of the same error message text over and over again in different language items.</p>"},{"location":"view/languages-naming-conventions/#naming-conventions","title":"Naming Conventions","text":"<ul> <li>If the entered text does not conform to some special rules, i.e. if the text is invalid, use <code>invalid</code> as error type.</li> <li>If the entered text is required to be unique but is already used for another object, use <code>notUnique</code> as error type.</li> </ul>"},{"location":"view/languages-naming-conventions/#confirmation-messages","title":"Confirmation messages","text":"<p>If the language item for an action is <code>foo.bar.action</code>, the language item for the confirmation message has to be <code>foo.bar.action.confirmMessage</code> instead of <code>foo.bar.action.sure</code> which is still used by some older language items.</p>"},{"location":"view/languages-naming-conventions/#type-specific-deletion-confirmation-message","title":"Type-Specific Deletion Confirmation Message","text":""},{"location":"view/languages-naming-conventions/#german","title":"German","text":"<pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} {element type} wirklich l\u00f6schen?\n</code></pre> <p>Example:</p> <pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} das Icon wirklich l\u00f6schen?\n</code></pre>"},{"location":"view/languages-naming-conventions/#english","title":"English","text":"<pre><code>Do you really want delete the {element type}?\n</code></pre> <p>Example:</p> <pre><code>Do you really want delete the icon?\n</code></pre>"},{"location":"view/languages-naming-conventions/#object-specific-deletion-confirmation-message","title":"Object-Specific Deletion Confirmation Message","text":""},{"location":"view/languages-naming-conventions/#german_1","title":"German","text":"<pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} {element type} <span class=\"confirmationObject\">{object name}</span> wirklich l\u00f6schen?\n</code></pre> <p>Example:</p> <pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Artikel <span class=\"confirmationObject\">{$article->getTitle()}</span> wirklich l\u00f6schen?\n</code></pre>"},{"location":"view/languages-naming-conventions/#english_1","title":"English","text":"<pre><code>Do you really want to delete the {element type} <span class=\"confirmationObject\">{object name}</span>?\n</code></pre> <p>Example:</p> <pre><code>Do you really want to delete the article <span class=\"confirmationObject\">{$article->getTitle()}</span>?\n</code></pre>"},{"location":"view/languages-naming-conventions/#user-group-options","title":"User Group Options","text":""},{"location":"view/languages-naming-conventions/#comments","title":"Comments","text":""},{"location":"view/languages-naming-conventions/#german_2","title":"German","text":"group type action example permission name language item user adding <code>user.foo.canAddComment</code> <code>Kann Kommentare erstellen</code> user deleting <code>user.foo.canDeleteComment</code> <code>Kann eigene Kommentare l\u00f6schen</code> user editing <code>user.foo.canEditComment</code> <code>Kann eigene Kommentare bearbeiten</code> moderator deleting <code>mod.foo.canDeleteComment</code> <code>Kann Kommentare l\u00f6schen</code> moderator editing <code>mod.foo.canEditComment</code> <code>Kann Kommentare bearbeiten</code> moderator moderating <code>mod.foo.canModerateComment</code> <code>Kann Kommentare moderieren</code>"},{"location":"view/languages-naming-conventions/#english_2","title":"English","text":"group type action example permission name language item user adding <code>user.foo.canAddComment</code> <code>Can create comments</code> user deleting <code>user.foo.canDeleteComment</code> <code>Can delete their comments</code> user editing <code>user.foo.canEditComment</code> <code>Can edit their comments</code> moderator deleting <code>mod.foo.canDeleteComment</code> <code>Can delete comments</code> moderator editing <code>mod.foo.canEditComment</code> <code>Can edit comments</code> moderator moderating <code>mod.foo.canModerateComment</code> <code>Can moderate comments</code>"},{"location":"view/languages/","title":"Languages","text":"<p>WoltLab Suite offers full i18n support with its integrated language system, including but not limited to dynamic phrases using template scripting and the built-in support for right-to-left languages.</p> <p>Phrases are deployed using the language package installation plugin, please also read the naming conventions for language items.</p>"},{"location":"view/languages/#special-phrases","title":"Special Phrases","text":""},{"location":"view/languages/#wcfdatedateformat","title":"<code>wcf.date.dateFormat</code>","text":"<p>Many characters in the format have a special meaning and will be replaced with date fragments. If you want to include a literal character, you'll have to use the backslash <code>\\</code> as an escape sequence to indicate that the character should be output as-is rather than being replaced. For example, <code>Y-m-d</code> will be output as <code>2018-03-30</code>, but <code>\\Y-m-d</code> will result in <code>Y-03-30</code>.</p> <p>Defaults to <code>M jS Y</code>.</p> <p>The date format without time using PHP's format characters for the <code>date()</code> function. This value is also used inside the JavaScript implementation, where the characters are mapped to an equivalent representation.</p>"},{"location":"view/languages/#wcfdatetimeformat","title":"<code>wcf.date.timeFormat</code>","text":"<p>Defaults to <code>g:i a</code>.</p> <p>The date format that is used to represent a time, but not a date. Please see the explanation on <code>wcf.date.dateFormat</code> to learn more about the format characters.</p>"},{"location":"view/languages/#wcfdatefirstdayoftheweek","title":"<code>wcf.date.firstDayOfTheWeek</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Sets the first day of the week: * <code>0</code> - Sunday * <code>1</code> - Monday</p>"},{"location":"view/languages/#wcfglobalpagedirection-rtl-support","title":"<code>wcf.global.pageDirection</code> - RTL support","text":"<p>Defaults to <code>ltr</code>.</p> <p>Changing this value to <code>rtl</code> will reverse the page direction and enable the right-to-left support for phrases. Additionally, a special version of the stylesheet is loaded that contains all necessary adjustments for the reverse direction.</p>"},{"location":"view/template-modifiers/","title":"Template Modifiers","text":"<p>Variable modifiers are used to modify the output of variables within templates. These modifiers allow you to perform various operations on the variables before displaying them. The general syntax for applying a variable modifier is <code>{$variable|modifier}</code>.</p> <p>Modifiers can be chained together to perform multiple operations on a variable. In such cases, the modifiers are applied from left to right. For example: <pre><code>{$variable|modifier1|modifier2|modifier3}\n</code></pre></p> <p>A modifier may accept additional parameters that affect its behavior. These parameters follow the modifier name and are separated by a <code>:</code>. For example: <pre><code>{$variable|modifier:'param1':'param2'}\n</code></pre></p>"},{"location":"view/template-modifiers/#build-in-modifiers","title":"Build-in Modifiers","text":""},{"location":"view/template-modifiers/#concat","title":"<code>|concat</code>","text":"<p><code>concat</code> is a modifier used to concatenate multiple strings:</p> <pre><code>{assign var=foo value='foo'}\n\n{assign var=templateVariable value='bar'|concat:$foo}\n\n{$templateVariable} {* prints 'foobar *}\n</code></pre>"},{"location":"view/template-modifiers/#currency","title":"<code>|currency</code>","text":"<p><code>currency</code> is a modifier used to format currency values with two decimals using language dependent thousands separators and decimal point:</p> <pre><code>{assign var=currencyValue value=12.345}\n\n{$currencyValue|currency} {* prints '12.34' *}\n</code></pre>"},{"location":"view/template-modifiers/#date","title":"<code>|date</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0. Use <code>{time type='plainDate'}</code> or <code>{time type='custom'}</code> instead.</p> <p><code>date</code> generated a formatted date using <code>wcf\\util\\DateUtil::format()</code> with <code>DateUtil::DATE_FORMAT</code> internally.</p> <pre><code>{$timestamp|date}\n</code></pre>"},{"location":"view/template-modifiers/#encodejs","title":"<code>|encodeJS</code>","text":"<p><code>encodeJS</code> encodes a string to be used as a single-quoted string in JavaScript by replacing <code>\\\\</code> with <code>\\\\\\\\</code>, <code>'</code> with <code>\\'</code>, linebreaks with <code>\\n</code>, and <code>/</code> with <code>\\/</code>.</p> <pre><code><script>\n var foo = '{unsafe:$foo|encodeJS}';\n</script>\n</code></pre>"},{"location":"view/template-modifiers/#escapecdata","title":"<code>|escapeCDATA</code>","text":"<p><code>escapeCDATA</code> encodes a string to be used in a <code>CDATA</code> element by replacing <code>]]></code> with <code>]]]]><![CDATA[></code>.</p> <pre><code><![CDATA[{unsafe:$foo|encodeCDATA}]]>\n</code></pre>"},{"location":"view/template-modifiers/#filesizebinary","title":"<code>|filesizeBinary</code>","text":"<p><code>filesizeBinary</code> formats the filesize using binary filesize (in bytes).</p> <pre><code>{$filesize|filesizeBinary}\n</code></pre>"},{"location":"view/template-modifiers/#filesize","title":"<code>|filesize</code>","text":"<p><code>filesize</code> formats the filesize using filesize (in bytes).</p> <pre><code>{$filesize|filesize}\n</code></pre>"},{"location":"view/template-modifiers/#ipsearch","title":"<code>|ipSearch</code>","text":"<p><code>ipSearch</code> generates a link to search for an IP address.</p> <pre><code>{\"127.0.0.1\"|ipSearch}\n</code></pre>"},{"location":"view/template-modifiers/#json","title":"<code>|json</code>","text":"<p><code>json</code> JSON-encodes the given value.</p> <pre><code><script>\nlet data = { \"title\": {unsafe:$foo->getTitle()|json} };\n</script>\n</code></pre>"},{"location":"view/template-modifiers/#language","title":"<code>|language</code>","text":"<p><code>language</code> replaces a language items with its value. If the template variable <code>__language</code> exists, this language object will be used instead of <code>WCF::getLanguage()</code>. This modifier is useful when assigning the value directly to a variable.</p> <p>Note that template scripting is applied to the output of the variable, which can lead to unwanted side effects. Use <code>phrase</code> instead if you don't want to use template scripting.</p> <pre><code>{$languageItem|language}\n\n{assign var=foo value=$languageItem|language}\n</code></pre>"},{"location":"view/template-modifiers/#newlinetobreak","title":"<code>|newlineToBreak</code>","text":"<p><code>newlineToBreak</code> transforms newlines into HTML <code><br></code> elements after encoding the content via <code>wcf\\util\\StringUtil::encodeHTML()</code>.</p> <pre><code>{$foo|newlineToBreak}\n</code></pre>"},{"location":"view/template-modifiers/#phrase","title":"<code>|phrase</code>","text":"<p><code>phrase</code> replaces a language items with its value. If the template variable <code>__language</code> exists, this language object will be used instead of <code>WCF::getLanguage()</code>. This modifier is useful when assigning the value directly to a variable.</p> <p><code>phrase</code> should be used instead of <code>language</code> unless you want to explicitly allow template scripting on a variable's output.</p> <pre><code>{$languageItem|phrase}\n\n{assign var=foo value=$languageItem|phrase}\n</code></pre>"},{"location":"view/template-modifiers/#plaintime","title":"<code>|plainTime</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0. Use <code>{time type='plainTime'}</code> instead.</p> <p><code>plainTime</code> formats a timestamp to include year, month, day, hour, and minutes. The exact formatting depends on the current language (via the language items <code>wcf.date.dateTimeFormat</code>, <code>wcf.date.dateFormat</code>, and <code>wcf.date.timeFormat</code>).</p> <pre><code>{$timestamp|plainTime}\n</code></pre>"},{"location":"view/template-modifiers/#shortunit","title":"<code>|shortUnit</code>","text":"<p><code>shortUnit</code> shortens numbers larger than 1000 by using unit suffixes:</p> <pre><code>{10000|shortUnit} {* prints 10k *}\n{5400000|shortUnit} {* prints 5.4M *}\n</code></pre>"},{"location":"view/template-modifiers/#tablewordwrap","title":"<code>|tableWordwrap</code>","text":"<p><code>tableWordwrap</code> inserts zero width spaces every 30 characters in words longer than 30 characters.</p> <pre><code>{$foo|tableWordwrap}\n</code></pre>"},{"location":"view/template-modifiers/#time","title":"<code>|time</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0. Use <code>{time}</code> instead.</p> <p><code>time</code> generates an HTML <code>time</code> elements based on a timestamp that shows a relative time or the absolute time if the timestamp more than six days ago.</p> <pre><code>{$timestamp|time} {* prints a '<time>' element *}\n</code></pre>"},{"location":"view/template-modifiers/#truncate","title":"<code>|truncate</code>","text":"<p><code>truncate</code> truncates a long string into a shorter one:</p> <pre><code>{$foo|truncate:35}\n\n{$foo|truncate:35:'_':true}\n</code></pre> Parameter Number Description 0 truncated string 1 truncated length; <code>80</code> by default 2 ellipsis symbol; <code>wcf\\util\\StringUtil::HELLIP</code> by default 3 if <code>true</code>, words can be broken up in the middle; <code>false</code> by default"},{"location":"view/template-modifiers/#php-functions","title":"PHP Functions","text":"<p>A limited number of safe native PHP functions may also be used as variable modifiers:</p> <ul> <li><code>abs</code></li> <li><code>addslashes</code></li> <li><code>array_diff</code></li> <li><code>array_fill</code></li> <li><code>array_key_exists</code></li> <li><code>array_keys</code></li> <li><code>array_pop</code></li> <li><code>array_slice</code></li> <li><code>array_values</code></li> <li><code>base64_decode</code></li> <li><code>base64_encode</code></li> <li><code>basename</code></li> <li><code>ceil</code></li> <li><code>concat</code></li> <li><code>constant</code></li> <li><code>count</code></li> <li><code>currency</code></li> <li><code>current</code></li> <li><code>date</code></li> <li><code>defined</code></li> <li><code>doubleval</code></li> <li><code>empty</code></li> <li><code>end</code></li> <li><code>explode</code></li> <li><code>file_exists</code></li> <li><code>filesize</code></li> <li><code>floatval</code></li> <li><code>floor</code></li> <li><code>function_exists</code></li> <li><code>get_class</code></li> <li><code>gmdate</code></li> <li><code>hash</code></li> <li><code>htmlspecialchars</code></li> <li><code>html_entity_decode</code></li> <li><code>http_build_query</code></li> <li><code>implode</code></li> <li><code>in_array</code></li> <li><code>is_array</code></li> <li><code>is_null</code></li> <li><code>is_numeric</code></li> <li><code>is_object</code></li> <li><code>is_string</code></li> <li><code>iterator_count</code></li> <li><code>intval</code></li> <li><code>is_subclass_of</code></li> <li><code>isset</code></li> <li><code>json_encode</code></li> <li><code>key</code></li> <li><code>lcfirst</code></li> <li><code>ltrim</code></li> <li><code>max</code></li> <li><code>mb_strpos</code></li> <li><code>mb_strlen</code></li> <li><code>mb_strpos</code></li> <li><code>mb_strtolower</code></li> <li><code>mb_strtoupper</code></li> <li><code>mb_substr</code></li> <li><code>md5</code></li> <li><code>method_exists</code></li> <li><code>microtime</code></li> <li><code>min</code></li> <li><code>nl2br</code></li> <li><code>number_format</code></li> <li><code>parse_url</code></li> <li><code>preg_match</code></li> <li><code>preg_replace</code></li> <li><code>print_r</code></li> <li><code>random_int</code></li> <li><code>rawurlencode</code></li> <li><code>reset</code></li> <li><code>round</code></li> <li><code>sha1</code></li> <li><code>spl_object_hash</code></li> <li><code>sprintf</code></li> <li><code>strip_tags</code></li> <li><code>strlen</code></li> <li><code>strpos</code></li> <li><code>strtolower</code></li> <li><code>strtotime</code></li> <li><code>strtoupper</code></li> <li><code>str_contains</code></li> <li><code>str_ends_with</code></li> <li><code>str_ireplace</code></li> <li><code>str_pad</code></li> <li><code>str_repeat</code></li> <li><code>str_replace</code></li> <li><code>str_starts_with</code></li> <li><code>substr</code></li> <li><code>trim</code></li> <li><code>ucfirst</code></li> <li><code>uniqid</code></li> <li><code>urlencode</code></li> <li><code>var_dump</code></li> <li><code>version_compare</code></li> <li><code>wcfDebug</code></li> <li><code>wordwrap</code></li> </ul>"},{"location":"view/template-plugins/","title":"Template Plugins","text":""},{"location":"view/template-plugins/#anchor","title":"<code>{anchor}</code>","text":"<p>The <code>anchor</code> template plugin creates <code>a</code> HTML elements. The easiest way to use the template plugin is to pass it an instance of <code>ITitledLinkObject</code>:</p> <pre><code>{anchor object=$object}\n</code></pre> <p>generates the same output as</p> <pre><code><a href=\"{$object->getLink()}\">{$object->getTitle()}</a>\n</code></pre> <p>Instead of an <code>object</code> parameter, a <code>link</code> and <code>content</code> parameter can be used:</p> <pre><code>{anchor link=$linkObject content=$content}\n</code></pre> <p>where <code>$linkObject</code> implements <code>ILinkableObject</code> and <code>$content</code> is either an object implementing <code>ITitledObject</code> or having a <code>__toString()</code> method or <code>$content</code> is a string or a number.</p> <p>The last special attribute is <code>append</code> whose contents are appended to the <code>href</code> attribute of the generated anchor element.</p> <p>All of the other attributes matching <code>~^[a-z]+([A-z]+)+$~</code>, expect for <code>href</code> which is disallowed, are added as attributes to the anchor element.</p> <p>If an <code>object</code> attribute is present, the object also implements <code>IPopoverObject</code> and if the return value of <code>IPopoverObject::getPopoverLinkClass()</code> is included in the <code>class</code> attribute of the <code>anchor</code> tag, <code>data-object-id</code> is automatically added. This functionality makes it easy to generate links with popover support. Instead of</p> <pre><code><a href=\"{$entry->getLink()}\" class=\"blogEntryLink\" data-object-id=\"{$entry->entryID}\">{$entry->subject}</a>\n</code></pre> <p>using</p> <pre><code>{anchor object=$entry class='blogEntryLink'}\n</code></pre> <p>is sufficient if <code>Entry::getPopoverLinkClass()</code> returns <code>blogEntryLink</code>.</p>"},{"location":"view/template-plugins/#anchorattributes","title":"<code>{anchorAttributes}</code>","text":"<p><code>anchorAttributes</code> compliments the <code>StringUtil::getAnchorTagAttributes(string, bool): string</code> method. It allows to easily generate the necessary attributes for an anchor tag based off the destination URL.</p> <pre><code><a href=\"https://www.example.com\" {anchorAttributes url='https://www.example.com' appendHref=false appendClassname=true isUgc=true}>\n</code></pre> Attribute Description <code>url</code> destination URL <code>appendHref</code> whether the <code>href</code> attribute should be generated; <code>true</code> by default <code>isUgc</code> whether the <code>rel=\"ugc\"</code> attribute should be generated; <code>false</code> by default <code>appendClassname</code> whether the <code>class=\"externalURL\"</code> attribute should be generated; <code>true</code> by default"},{"location":"view/template-plugins/#append","title":"<code>{append}</code>","text":"<p>If a string should be appended to the value of a variable, <code>append</code> can be used:</p> <pre><code>{assign var=templateVariable value='newValue'}\n\n{$templateVariable} {* prints 'newValue *}\n\n{append var=templateVariable value='2'}\n\n{$templateVariable} {* now prints 'newValue2 *}\n</code></pre> <p>If the variables does not exist yet, <code>append</code> creates a new one with the given value. If <code>append</code> is used on an array as the variable, the value is appended to all elements of the array.</p>"},{"location":"view/template-plugins/#assign","title":"<code>{assign}</code>","text":"<p>New template variables can be declared and new values can be assigned to existing template variables using <code>assign</code>:</p> <pre><code>{assign var=templateVariable value='newValue'}\n\n{$templateVariable} {* prints 'newValue *}\n</code></pre>"},{"location":"view/template-plugins/#capture","title":"<code>{capture}</code>","text":"<p>In some situations, <code>assign</code> is not sufficient to assign values to variables in templates if the value is complex. Instead, <code>capture</code> can be used:</p> <pre><code>{capture var=templateVariable}\n {if $foo}\n <p>{$bar}</p>\n {else}\n <small>{$baz}</small>\n {/if}\n{/capture}\n</code></pre>"},{"location":"view/template-plugins/#counter","title":"<code>{counter}</code>","text":"<p><code>counter</code> can be used to generate and optionally print a counter:</p> <pre><code>{counter name=fooCounter print=true} {* prints '1' *}\n\n{counter name=fooCounter print=true} {* prints '2' now *}\n\n{counter name=fooCounter} {* prints nothing, but counter value is '3' now internally *}\n\n{counter name=fooCounter print=true} {* prints '4' *}\n</code></pre> <p>Counter supports the following attributes:</p> Attribute Description <code>assign</code> optional name of the template variable the current counter value is assigned to <code>direction</code> counting direction, either <code>up</code> or <code>down</code>; <code>up</code> by default <code>name</code> name of the counter, relevant if multiple counters are used simultaneously <code>print</code> if <code>true</code>, the current counter value is printed; <code>false</code> by default <code>skip</code> positive counting increment; <code>1</code> by default <code>start</code> start counter value; <code>1</code> by default"},{"location":"view/template-plugins/#54-csrftoken","title":"5.4+ <code>csrfToken</code>","text":"<p><code>{csrfToken}</code> prints out the session's CSRF token (\u201cSecurity Token\u201d).</p> <pre><code><form action=\"{link controller=\"Foo\"}{/link}\" method=\"post\">\n {* snip *}\n\n {csrfToken}\n</form>\n</code></pre> <p>The <code>{csrfToken}</code> template plugin supports a <code>type</code> parameter. Specifying this parameter might be required in rare situations. Please check the implementation for details.</p>"},{"location":"view/template-plugins/#cycle","title":"<code>{cycle}</code>","text":"<p><code>cycle</code> can be used to cycle between different values:</p> <pre><code>{cycle name=fooCycle values='bar,baz'} {* prints 'bar' *}\n\n{cycle name=fooCycle} {* prints 'baz' *}\n\n{cycle name=fooCycle advance=false} {* prints 'baz' again *}\n\n{cycle name=fooCycle} {* prints 'bar' *}\n</code></pre> <p>The values attribute only has to be present for the first call. If <code>cycle</code> is used in a loop, the presence of the same values in consecutive calls has no effect. Only once the values change, the cycle is reset.</p> Attribute Description <code>advance</code> if <code>true</code>, the current cycle value is advanced to the next value; <code>true</code> by default <code>assign</code> optional name of the template variable the current cycle value is assigned to; if used, <code>print</code> is set to <code>false</code> <code>delimiter</code> delimiter between the different cycle values; <code>,</code> by default <code>name</code> name of the cycle, relevant if multiple cycles are used simultaneously <code>print</code> if <code>true</code>, the current cycle value is printed, <code>false</code> by default <code>reset</code> if <code>true</code>, the current cycle value is set to the first value, <code>false</code> by default <code>values</code> string containing the different cycles values, also see <code>delimiter</code>"},{"location":"view/template-plugins/#dateinterval","title":"<code>{dateInterval}</code>","text":"<p><code>dateInterval</code> calculates the difference between two unix timestamps and generated a textual date interval.</p> <pre><code>{dateInterval start=$startTimestamp end=$endTimestamp full=true format='sentence'}\n</code></pre> Attribute Description <code>end</code> end of the time interval; current timestamp by default (though either <code>start</code> or <code>end</code> has to be set) <code>format</code> output format, either <code>default</code>, <code>sentence</code>, or <code>plain</code>; defaults to <code>default</code>, see <code>wcf\\util\\DateUtil::FORMAT_*</code> constants <code>full</code> if <code>true</code>, full difference in minutes is shown; if <code>false</code>, only the longest time interval is shown; <code>false</code> by default <code>start</code> start of the time interval; current timestamp by default (though either <code>start</code> or <code>end</code> has to be set)"},{"location":"view/template-plugins/#event","title":"<code>{event}</code>","text":"<p><code>event</code> provides extension points in templates that template listeners can use.</p> <pre><code>{event name='foo'}\n</code></pre>"},{"location":"view/template-plugins/#hascontent","title":"<code>{hascontent}</code>","text":"<p>In many cases, conditional statements can be used to determine if a certain section of a template is shown:</p> <pre><code>{if $foo === 'bar'}\n only shown if $foo is bar\n{/if}\n</code></pre> <p>In some situations, however, such conditional statements are not sufficient. One prominent example is a template event:</p> <pre><code>{if $foo === 'bar'}\n <ul>\n {if $foo === 'bar'}\n <li>Bar</li>\n {/if}\n\n {event name='listItems'}\n </li>\n{/if}\n</code></pre> <p>In this example, if <code>$foo !== 'bar'</code>, the list will not be shown, regardless of the additional template code provided by template listeners. In such a situation, <code>hascontent</code> has to be used:</p> <pre><code>{hascontent}\n <ul>\n {content}\n {if $foo === 'bar'}\n <li>Bar</li>\n {/if}\n\n {event name='listItems'}\n {/content}\n </ul>\n{/hascontent}\n</code></pre> <p>If the part of the template wrapped in the <code>content</code> tags has any (trimmed) content, the part of the template wrapped by <code>hascontent</code> tags is shown (including the part wrapped by the <code>content</code> tags), otherwise nothing is shown. Thus, this construct avoids an empty list compared to the <code>if</code> solution above.</p> <p>Like <code>foreach</code>, <code>hascontent</code> also supports an <code>else</code> part:</p> <pre><code>{hascontent}\n <ul>\n {content}\n {* \u2026 *}\n {/content}\n </ul>\n{hascontentelse}\n no list\n{/hascontent}\n</code></pre>"},{"location":"view/template-plugins/#htmlcheckboxes","title":"<code>{htmlCheckboxes}</code>","text":"<p><code>htmlCheckboxes</code> generates a list of HTML checkboxes.</p> <pre><code>{htmlCheckboxes name=foo options=$fooOptions selected=$currentFoo}\n\n{htmlCheckboxes name=bar output=$barLabels values=$barValues selected=$currentBar}\n</code></pre> Attribute Description <code>disabled</code> if <code>true</code>, all checkboxes are disabled <code>disableEncoding</code> if <code>true</code>, the values are not passed through <code>wcf\\util\\StringUtil::encodeHTML()</code>; <code>false</code> by default <code>name</code> <code>name</code> attribute of the <code>input</code> checkbox element <code>output</code> array used as keys and values for <code>options</code> if present; not present by default <code>options</code> array selectable options with the key used as <code>value</code> attribute and the value as the checkbox label <code>selected</code> current selected value(s) <code>separator</code> separator between the different checkboxes in the generated output; empty string by default <code>values</code> array with values used in combination with <code>output</code>, where <code>output</code> is only used as keys for <code>options</code>"},{"location":"view/template-plugins/#htmloptions","title":"<code>{htmlOptions}</code>","text":"<p><code>htmlOptions</code> generates an <code>select</code> HTML element.</p> <pre><code>{htmlOptions name='foo' options=$options selected=$selected}\n\n<select name=\"bar\">\n <option value=\"\"{if !$selected} selected{/if}>{lang}foo.bar.default{/lang}</option>\n {htmlOptions options=$options selected=$selected} {* no `name` attribute *}\n</select>\n</code></pre> Attribute Description <code>disableEncoding</code> if <code>true</code>, the values are not passed through <code>wcf\\util\\StringUtil::encodeHTML()</code>; <code>false</code> by default <code>object</code> optional instance of <code>wcf\\data\\DatabaseObjectList</code> that provides the selectable options (overwrites <code>options</code> attribute internally) <code>name</code> <code>name</code> attribute of the <code>select</code> element; if not present, only the contents of the <code>select</code> element are printed <code>output</code> array used as keys and values for <code>options</code> if present; not present by default <code>values</code> array with values used in combination with <code>output</code>, where <code>output</code> is only used as keys for <code>options</code> <code>options</code> array selectable options with the key used as <code>value</code> attribute and the value as the option label; if a value is an array, an <code>optgroup</code> is generated with the array key as the <code>optgroup</code> label <code>selected</code> current selected value(s) <p>All additional attributes are added as attributes of the <code>select</code> HTML element.</p>"},{"location":"view/template-plugins/#icon","title":"<code>{icon}</code>","text":"<p><code>{icon}</code> renders a \u201cFont Awesome\u201d icon with support for brand icons.</p> <pre><code>{icon name='magnifying-glass'}\n{icon size=24 name='github' type='brand'}\n{icon size=32 name='user' type='solid'}\n{icon size=64 name='bell'}\n</code></pre> Attribute Description <code>size</code> the size of the icon, possible values are <code>16</code>, <code>24</code>, <code>32</code>, <code>48</code>, <code>64</code>, <code>96</code>, <code>128</code> and <code>144</code>; defaults to <code>16</code> <code>type</code> requests the least \u201cthick\u201d icon when omitted, the solid variant with <code>'solid'</code> and a brand icon with <code>'brand'</code>"},{"location":"view/template-plugins/#implode","title":"<code>{implode}</code>","text":"<p><code>implodes</code> transforms an array into a string and prints it.</p> <pre><code>{implode from=$array key=key item=item glue=\";\"}{$key}: {$value}{/implode}\n</code></pre> Attribute Description <code>from</code> array with the imploded values <code>glue</code> separator between the different array values; <code>', '</code> by default <code>item</code> template variable name where the current array value is stored during the iteration <code>key</code> optional template variable name where the current array key is stored during the iteration"},{"location":"view/template-plugins/#js","title":"<code>{js}</code>","text":"<p><code>js</code> generates script tags based on whether <code>ENABLE_DEBUG_MODE</code> and <code>VISITOR_USE_TINY_BUILD</code> are enabled.</p> <pre><code>{js application='wbb' file='WBB'} {* generates 'http://example.com/js/WBB.js' *}\n\n{js application='wcf' file='WCF.User' bundle='WCF.Combined'}\n {* generates 'http://example.com/wcf/js/WCF.User.js' if ENABLE_DEBUG_MODE=1 *}\n {* generates 'http://example.com/wcf/js/WCF.Combined.min.js' if ENABLE_DEBUG_MODE=0 *}\n\n{js application='wcf' lib='jquery'}\n {* generates 'http://example.com/wcf/js/3rdParty/jquery.js' *}\n\n{js application='wcf' lib='jquery-ui' file='awesomeWidget'}\n {* generates 'http://example.com/wcf/js/3rdParty/jquery-ui/awesomeWidget.js' *}\n\n{js application='wcf' file='WCF.User' bundle='WCF.Combined' hasTiny=true}\n {* generates 'http://example.com/wcf/js/WCF.User.js' if ENABLE_DEBUG_MODE=1 *}\n {* generates 'http://example.com/wcf/js/WCF.Combined.min.js' (ENABLE_DEBUG_MODE=0 *}\n {* generates 'http://example.com/wcf/js/WCF.Combined.tiny.min.js' if ENABLE_DEBUG_MODE=0 and VISITOR_USE_TINY_BUILD=1 *}\n</code></pre>"},{"location":"view/template-plugins/#jslang","title":"<code>{jslang}</code>","text":"<p><code>jslang</code> works like <code>lang</code> with the difference that the resulting string is automatically passed through <code>encodeJS</code>.</p> <pre><code>require(['Language', /* \u2026 */], function(Language, /* \u2026 */) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}',\n });\n\n // \u2026\n});\n</code></pre>"},{"location":"view/template-plugins/#60-jsphrase","title":"6.0+ <code>{jsphrase}</code>","text":"<p><code>jsphrase</code> generates the necessary JavaScript code to register a phrase in the JavaScript language store. This plugin only supports static phrase names. If a dynamic phrase should be registered, the <code>jslang</code> plugin needs to be used.</p> <pre><code><script data-relocate=\"true\">\n{jsphrase name='app.foo.bar'}\n\n// \u2026\n</script>\n</code></pre>"},{"location":"view/template-plugins/#lang","title":"<code>{lang}</code>","text":"<p><code>lang</code> replaces a language items with its value.</p> <pre><code>{lang}foo.bar.baz{/lang}\n\n{lang __literal=true}foo.bar.baz{/lang}\n\n{lang foo='baz'}foo.bar.baz{/lang}\n\n{lang}foo.bar.baz.{$action}{/lang}\n</code></pre> Attribute Description <code>__encode</code> if <code>true</code>, the output will be passed through <code>StringUtil::encodeHTML()</code> <code>__literal</code> if <code>true</code>, template variables will not resolved but printed as they are in the language item; <code>false</code> by default <code>__optional</code> if <code>true</code> and the language item does not exist, an empty string is printed; <code>false</code> by default <p>All additional attributes are available when parsing the language item.</p>"},{"location":"view/template-plugins/#link","title":"<code>{link}</code>","text":"<p><code>link</code> generates internal links using <code>LinkHandler</code>.</p> <pre><code><a href=\"{link controller='FooList' application='bar'}param1=2&param2=A{/link}\">Foo</a>\n</code></pre> Attribute Description <code>application</code> abbreviation of the application the controller belongs to; <code>wcf</code> by default <code>controller</code> name of the controller; if not present, the landing page is linked in the frontend and the index page in the ACP <code>encode</code> if <code>true</code>, the generated link is passed through <code>wcf\\util\\StringUtil::encodeHTML()</code>; <code>true</code> by default <code>isEmail</code> sets <code>encode=false</code> and forces links to link to the frontend <p>Additional attributes are passed to <code>LinkHandler::getLink()</code>.</p>"},{"location":"view/template-plugins/#54-objectaction","title":"5.4+ <code>objectAction</code>","text":"<p><code>objectAction</code> generates action buttons to be used in combination with the <code>WoltLabSuite/Core/Ui/Object/Action</code> API. For detailed information on its usage, we refer to the extensive documentation in the <code>ObjectActionFunctionTemplatePlugin</code> class itself.</p>"},{"location":"view/template-plugins/#page","title":"<code>{page}</code>","text":"<p><code>page</code> generates an internal link to a CMS page.</p> <pre><code>{page}com.woltlab.wcf.CookiePolicy{/page}\n\n{page pageID=1}{/page}\n\n{page language='de'}com.woltlab.wcf.CookiePolicy{/page}\n\n{page languageID=2}com.woltlab.wcf.CookiePolicy{/page}\n</code></pre> Attribute Description <code>pageID</code> unique id of the page (cannot be used together with a page identifier as value) <code>languageID</code> id of the page language (cannot be used together with <code>language</code>) <code>language</code> language code of the page language (cannot be used together with <code>languageID</code>)"},{"location":"view/template-plugins/#pages","title":"<code>{pages}</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0.</p> <p><code>pages</code> generates a pagination.</p> <pre><code>{pages controller='FooList' link=\"pageNo=%d\" print=true assign=pagesLinks} {* prints pagination *}\n\n{unsafe:$pagesLinks} {* prints same pagination again *}\n</code></pre> Attribute Description <code>assign</code> optional name of the template variable the pagination is assigned to <code>controller</code> controller name of the generated links <code>link</code> additional link parameter where <code>%d</code> will be replaced with the relevant page number <code>pages</code> maximum number of of pages; by default, the template variable <code>$pages</code> is used <code>print</code> if <code>false</code> and <code>assign=true</code>, the pagination is not printed <code>application</code>, <code>id</code>, <code>object</code>, <code>title</code> additional parameters passed to <code>LinkHandler::getLink()</code> to generate page links"},{"location":"view/template-plugins/#plural","title":"<code>{plural}</code>","text":"<p><code>plural</code> allows to easily select the correct plural form of a phrase based on a given <code>value</code>. The pluralization logic follows the Unicode Language Plural Rules for cardinal numbers.</p> <p>The <code>#</code> placeholder within the resulting phrase is replaced by the <code>value</code>. It is automatically formatted using <code>StringUtil::formatNumeric</code>.</p> <p>English:</p> <p>Note the use of <code>1</code> if the number (<code>#</code>) is not used within the phrase and the use of <code>one</code> otherwise. They are equivalent for English, but following this rule generalizes better to other languages, helping the translator. <pre><code>{assign var=numberOfWorlds value=2}\n<h1>Hello {plural value=$numberOfWorlds 1='World' other='Worlds'}!</h1>\n<p>There {plural value=$numberOfWorlds 1='is one world' other='are # worlds'}!</p>\n<p>There {plural value=$numberOfWorlds one='is # world' other='are # worlds'}!</p>\n</code></pre></p> <p>German: <pre><code>{assign var=numberOfWorlds value=2}\n<h1>Hallo {plural value=$numberOfWorlds 1='Welt' other='Welten'}!</h1>\n<p>Es gibt {plural value=$numberOfWorlds 1='eine Welt' other='# Welten'}!</p>\n<p>Es gibt {plural value=$numberOfWorlds one='# Welt' other='# Welten'}!</p>\n</code></pre></p> <p>Romanian:</p> <p>Note the additional use of <code>few</code> which is not required in English or German. <pre><code>{assign var=numberOfWorlds value=2}\n<h1>Salut {plural value=$numberOfWorlds 1='lume' other='lumi'}!</h1>\n<p>Exist\u0103 {plural value=$numberOfWorlds 1='o lume' few='# lumi' other='# de lumi'}!</p>\n<p>Exist\u0103 {plural value=$numberOfWorlds one='# lume' few='# lumi' other='# de lumi'}!</p>\n</code></pre></p> <p>Russian:</p> <p>Note the difference between <code>1</code> (exactly <code>1</code>) and <code>one</code> (ending in <code>1</code>, except ending in <code>11</code>). <pre><code>{assign var=numberOfWorlds value=2}\n<h1>\u041f\u0440\u0438\u0432\u0435\u0442 {plural value=$numberOfWorld 1='\u043c\u0438\u0440' other='\u043c\u0438\u0440\u044b'}!</h1>\n<p>\u0415\u0441\u0442\u044c {plural value=$numberOfWorlds 1='\u043c\u0438\u0440' one='# \u043c\u0438\u0440' few='# \u043c\u0438\u0440\u0430' many='# \u043c\u0438\u0440\u043e\u0432' other='# \u043c\u0438\u0440\u043e\u0432'}!</p>\n</code></pre></p> Attribute Description value The value that is used to select the proper phrase. other The phrase that is used when no other selector matches. Any Category Name The phrase that is used when <code>value</code> belongs to the named category. Available categories depend on the language. Any Integer The phrase that is used when <code>value</code> is that exact integer."},{"location":"view/template-plugins/#prepend","title":"<code>{prepend}</code>","text":"<p>If a string should be prepended to the value of a variable, <code>prepend</code> can be used:</p> <pre><code>{assign var=templateVariable value='newValue'}\n\n{$templateVariable} {* prints 'newValue *}\n\n{prepend var=templateVariable value='2'}\n\n{$templateVariable} {* now prints '2newValue' *}\n</code></pre> <p>If the variables does not exist yet, <code>prepend</code> creates a new one with the given value. If <code>prepend</code> is used on an array as the variable, the value is prepended to all elements of the array.</p>"},{"location":"view/template-plugins/#time","title":"<code>{time}</code>","text":"<p><code>time</code> allows to output times in different (human readable) formats. Acceptables inputs are either a <code>\\DateTimeInterface</code> or an integer representing a Unix timestamp.</p> <pre><code>{time time=$time}\n{time time=$time type='plainTime'}\n{time time=$time type='plainDate'}\n{time time=$time type='machine'}\n{time time=$time type='custom' format='Y-m-d'}\n</code></pre> Attribute Description time The <code>\\DateTimeInterface</code> or Unix timestamp to format. type The output format. Type Description \u2013 An interactive <code><woltlab-core-date-time></code> element that renders as dynamically updated relative times. plainTime Date with time in the user\u2019s locale and timezone as a plain string. plainDate Date without time in the user\u2019s locale and timezone as a plain string. machine A machine readable string in ISO-8601 format. custom A custom format that is passed to <code>\\DateTimeInterface::format()</code>. The timezone will be the user\u2019s timezone."},{"location":"view/template-plugins/#user","title":"<code>{user}</code>","text":"<p><code>user</code> generates links to user profiles. The mandatory <code>object</code> parameter requires an instances of <code>UserProfile</code>. The optional <code>type</code> parameter is responsible for what the generated link contains:</p> <ul> <li><code>type='default'</code> (also applies if no <code>type</code> is given) outputs the formatted username relying on the \u201cUser Marking\u201d setting of the relevant user group. Additionally, the user popover card will be shown when hovering over the generated link.</li> <li><code>type='plain'</code> outputs the username without additional formatting.</li> <li><code>type='avatar(\\d+)'</code> outputs the user\u2019s avatar in the specified size, i.e., <code>avatar48</code> outputs the avatar with a width and height of 48 pixels.</li> </ul> <p>The last special attribute is <code>append</code> whose contents are appended to the <code>href</code> attribute of the generated anchor element.</p> <p>All of the other attributes matching <code>~^[a-z]+([A-z]+)+$~</code>, except for <code>href</code> which may not be added, are added as attributes to the anchor element.</p> <p>Examples:</p> <pre><code>{user object=$user}\n</code></pre> <p>generates</p> <pre><code><a href=\"{$user->getLink()}\" data-object-id=\"{$user->userID}\" class=\"userLink\">{unsafe:$user->getFormattedUsername()}</a>\n</code></pre> <p>and</p> <pre><code>{user object=$user type='avatar48' foo='bar'}\n</code></pre> <p>generates</p> <pre><code><a href=\"{$user->getLink()}\" foo=\"bar\">{unsafe:$object->getAvatar()->getImageTag(48)}</a>\n</code></pre>"},{"location":"view/templates/","title":"Templates","text":"<p>Templates are responsible for the output a user sees when requesting a page (while the PHP code is responsible for providing the data that will be shown). Templates are text files with <code>.tpl</code> as the file extension. WoltLab Suite Core compiles the template files once into a PHP file that is executed when a user requests the page. In subsequent request, as the PHP file containing the compiled template already exists, compiling the template is not necessary anymore.</p>"},{"location":"view/templates/#template-types-and-conventions","title":"Template Types and Conventions","text":"<p>WoltLab Suite Core supports two types of templates: frontend templates (or simply templates) and backend templates (ACP templates). Each type of template is only available in its respective domain, thus frontend templates cannot be included or used in the ACP and vice versa.</p> <p>For pages and forms, the name of the template matches the unqualified name of the PHP class except for the <code>Page</code> or <code>Form</code> suffix:</p> <ul> <li><code>RegisterForm.class.php</code> \u2192 <code>register.tpl</code></li> <li><code>UserPage.class.php</code> \u2192 <code>user.tpl</code></li> </ul> <p>If you follow this convention, WoltLab Suite Core will automatically determine the template name so that you do not have to explicitly set it.</p> <p>For forms that handle creating and editing objects, in general, there are two form classes: <code>FooAddForm</code> and <code>FooEditForm</code>. WoltLab Suite Core, however, generally only uses one template <code>fooAdd.tpl</code> and the template variable <code>$action</code> to distinguish between creating a new object (<code>$action = 'add'</code>) and editing an existing object (<code>$action = 'edit'</code>) as the differences between templates for adding and editing an object are minimal.</p>"},{"location":"view/templates/#installing-templates","title":"Installing Templates","text":"<p>Templates and ACP templates are installed by two different package installation plugins: the template PIP and the ACP template PIP. More information about installing templates can be found on those pages. </p>"},{"location":"view/templates/#base-templates","title":"Base Templates","text":""},{"location":"view/templates/#frontend","title":"Frontend","text":"<pre><code>{include file='header'}\n\n{* content *}\n\n{include file='footer'}\n</code></pre>"},{"location":"view/templates/#backend","title":"Backend","text":"<pre><code>{include file='header' pageTitle='foo.bar.baz'}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">Title</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n {* your default content header navigation buttons *}\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{* content *}\n\n{include file='footer'}\n</code></pre> <p><code>foo.bar.baz</code> is the language item that contains the title of the page.</p>"},{"location":"view/templates/#common-template-components","title":"Common Template Components","text":""},{"location":"view/templates/#forms","title":"Forms","text":"<p>For new forms, use the form builder API.</p> <pre><code><form method=\"post\" action=\"{link controller='FooBar'}{/link}\">\n <div class=\"section\">\n <dl{if $errorField == 'baz'} class=\"formError\"{/if}>\n <dt><label for=\"baz\">{lang}foo.bar.baz{/lang}</label></dt>\n <dd>\n <input type=\"text\" id=\"baz\" name=\"baz\" value=\"{$baz}\" class=\"long\" required autofocus>\n {if $errorField == 'baz'}\n <small class=\"innerError\">\n {if $errorType == 'empty'}\n {lang}wcf.global.form.error.empty{/lang}\n {else}\n {lang}foo.bar.baz.error.{$errorType}{/lang}\n {/if}\n </small>\n {/if}\n </dd>\n </dl>\n\n <dl>\n <dt><label for=\"bar\">{lang}foo.bar.bar{/lang}</label></dt>\n <dd>\n <textarea name=\"bar\" id=\"bar\" cols=\"40\" rows=\"10\">{$bar}</textarea>\n {if $errorField == 'bar'}\n <small class=\"innerError\">{lang}foo.bar.bar.error.{$errorType}{/lang}</small>\n {/if}\n </dd>\n </dl>\n\n {* other fields *}\n\n {event name='dataFields'}\n </div>\n\n {* other sections *}\n\n {event name='sections'}\n\n <div class=\"formSubmit\">\n <input type=\"submit\" value=\"{lang}wcf.global.button.submit{/lang}\" accesskey=\"s\">\n {csrfToken}\n </div>\n</form>\n</code></pre>"},{"location":"view/templates/#tab-menus","title":"Tab Menus","text":"<pre><code><div class=\"section tabMenuContainer\">\n <nav class=\"tabMenu\">\n <ul>\n <li><a href=\"#tab1\">Tab 1</a></li>\n <li><a href=\"#tab2\">Tab 2</a></li>\n\n {event name='tabMenuTabs'}\n </ul>\n </nav>\n\n <div id=\"tab1\" class=\"tabMenuContent\">\n <div class=\"section\">\n {* contents of first tab *}\n </div>\n </div>\n\n <div id=\"tab2\" class=\"tabMenuContainer tabMenuContent\">\n <nav class=\"menu\">\n <ul>\n <li><a href=\"#tab2A\">Tab 2A</a></li>\n <li><a href=\"#tab2B\">Tab 2B</a></li>\n\n {event name='tabMenuTab2Subtabs'}\n </ul>\n </nav>\n\n <div id=\"tab2A\" class=\"tabMenuContent\">\n <div class=\"section\">\n {* contents of first subtab for second tab *}\n </div>\n </div>\n\n <div id=\"tab2B\" class=\"tabMenuContent\">\n <div class=\"section\">\n {* contents of second subtab for second tab *}\n </div>\n </div>\n\n {event name='tabMenuTab2Contents'}\n </div>\n\n {event name='tabMenuContents'}\n</div>\n</code></pre>"},{"location":"view/templates/#template-scripting","title":"Template Scripting","text":""},{"location":"view/templates/#template-variables","title":"Template Variables","text":"<p>Template variables can be assigned via <code>WCF::getTPL()->assign('foo', 'bar')</code> and accessed in templates via <code>$foo</code>:</p> <ul> <li><code>{$foo}</code> will result in the contents of <code>$foo</code> to be passed to <code>StringUtil::encodeHTML()</code> before being printed.</li> <li><code>{#$foo}</code> will result in the contents of <code>$foo</code> to be passed to <code>StringUtil::formatNumeric()</code> before being printed. Thus, this method is relevant when printing numbers and having them formatted correctly according the the user\u2019s language.</li> <li><code>{unsafe:$foo}</code> will result in the contents of <code>$foo</code> to be printed directly. This method should only be used if you want to output the content of the variable directly and unfiltered. Never use this method for user-generated input that has not already been sanitized by other means.</li> </ul> <p>Multiple template variables can be assigned by passing an array:</p> <pre><code>WCF::getTPL()->assign([\n 'foo' => 'bar',\n 'baz' => false \n]);\n</code></pre>"},{"location":"view/templates/#modifiers","title":"Modifiers","text":"<p>Variable modifiers are used to modify the output of variables within templates. These modifiers allow you to perform various operations on the variables before displaying them. The general syntax for applying a variable modifier is <code>{$variable|modifier}</code>.</p> <p>Modifiers can be chained together to perform multiple operations on a variable. In such cases, the modifiers are applied from left to right. For example: <pre><code>{$variable|modifier1|modifier2|modifier3}\n</code></pre></p> <p>A modifier may accept additional parameters that affect its behavior. These parameters follow the modifier name and are separated by a <code>:</code>. For example: <pre><code>{$variable|modifier:'param1':'param2'}\n</code></pre></p> <p>An overview of all available modifiers is available on a dedicated page.</p>"},{"location":"view/templates/#system-template-variable","title":"System Template Variable","text":"<ul> <li><code>$__wcf</code> contains the <code>WCF</code> object (or <code>WCFACP</code> object in the backend).</li> </ul>"},{"location":"view/templates/#comments","title":"Comments","text":"<p>Comments are wrapped in <code>{*</code> and <code>*}</code> and can span multiple lines:</p> <pre><code>{* some\n comment *}\n</code></pre> <p>The template compiler discards the comments, so that they not included in the compiled template.</p>"},{"location":"view/templates/#conditions","title":"Conditions","text":"<p>Conditions follow a similar syntax to PHP code:</p> <pre><code>{if $foo === 'bar'}\n foo is bar\n{elseif $foo === 'baz'}\n foo is baz\n{else}\n foo is neither bar nor baz\n{/if}\n</code></pre> <p>The supported operators in conditions are <code>===</code>, <code>!==</code>, <code>==</code>, <code>!=</code>, <code><=</code>, <code><</code>, <code>>=</code>, <code>></code>, <code>||</code>, <code>&&</code>, <code>!</code>, and <code>=</code>.</p> <p>More examples:</p> <pre><code>{if $bar|isset}\u2026{/if}\n\n{if $bar|count > 3 && $bar|count < 100}\u2026{/if}\n</code></pre>"},{"location":"view/templates/#foreach-loops","title":"Foreach Loops","text":"<p>Foreach loops allow to iterate over arrays or iterable objects:</p> <pre><code><ul>\n {foreach from=$array key=key item=value}\n <li>{$key}: {$value}</li>\n {/foreach}\n</ul>\n</code></pre> <p>While the <code>from</code> attribute containing the iterated structure and the <code>item</code> attribute containg the current value are mandatory, the <code>key</code> attribute is optional. If the foreach loop has a name assigned to it via the <code>name</code> attribute, the <code>$tpl</code> template variable provides additional data about the loop:</p> <pre><code><ul>\n {foreach from=$array key=key item=value name=foo}\n {if $tpl[foreach][foo][first]}\n something special for the first iteration\n {elseif $tpl[foreach][foo][last]}\n something special for the last iteration\n {/if}\n\n <li>iteration {#$tpl[foreach][foo][iteration]+1} out of {#$tpl[foreach][foo][total]} {$key}: {$value}</li>\n {/foreach}\n</ul>\n</code></pre> <p>In contrast to PHP\u2019s foreach loop, templates also support <code>foreachelse</code>:</p> <pre><code>{foreach from=$array item=value}\n \u2026\n{foreachelse}\n there is nothing to iterate over\n{/foreach}\n</code></pre>"},{"location":"view/templates/#including-other-templates","title":"Including Other Templates","text":"<p>To include template named <code>foo</code> from the same domain (frontend/backend), you can use</p> <pre><code>{include file='foo'}\n</code></pre> <p>If the template belongs to an application, you have to specify that application using the <code>application</code> attribute:</p> <pre><code>{include file='foo' application='app'}\n</code></pre> <p>Additional template variables can be passed to the included template as additional attributes:</p> <pre><code>{include file='foo' application='app' var1='foo1' var2='foo2'}\n</code></pre>"},{"location":"view/templates/#template-plugins","title":"Template Plugins","text":"<p>An overview of all available template plugins can be found here.</p>"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"WoltLab Suite 6.1 Documentation","text":""},{"location":"#introduction","title":"Introduction","text":"<p>This documentation explains the basic API functionality and the creation of own packages. It is expected that you are somewhat experienced with PHP, object-oriented programming and MySQL.</p> <p>Head over to the quick start tutorial to learn more.</p>"},{"location":"#about-woltlab-suite","title":"About WoltLab Suite","text":"<p>WoltLab Suite Core as well as most of the other packages are available on GitHub and are licensed under the terms of the GNU Lesser General Public License 2.1.</p>"},{"location":"getting-started/","title":"Creating a simple package","text":""},{"location":"getting-started/#setup-and-requirements","title":"Setup and Requirements","text":"<p>This guide will help you to create a simple package that provides a simple test page. It is nothing too fancy, but you can use it as the foundation for your next project.</p> <p>There are some requirements you should met before starting:</p> <ul> <li>Text editor with syntax highlighting for PHP, Notepad++ or Visual Studio Code are a solid pick</li> <li><code>*.php</code> and <code>*.tpl</code> should be encoded with ANSI/ASCII</li> <li><code>*.xml</code> are always encoded with UTF-8, but omit the BOM (byte-order-mark)</li> <li>An active installation of WoltLab Suite</li> <li>An application to create <code>*.tar</code> archives, e.g. 7-Zip on Windows</li> </ul>"},{"location":"getting-started/#the-packagexml-file","title":"The package.xml File","text":"<p>We want to create a simple page that will display the sentence \"Hello World\" embedded into the application frame. Create an empty directory in the workspace of your choice to start with.</p> <p>Create a new file called <code>package.xml</code> and insert the code below:</p> <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/package.xsd\" name=\"com.example.test\">\n <packageinformation>\n <!-- com.example.test -->\n <packagename>Simple Package</packagename>\n <packagedescription>A simple package to demonstrate the package system of WoltLab Suite Core</packagedescription>\n <version>1.0.0</version>\n <date>2023-09-15</date>\n </packageinformation>\n <authorinformation>\n <author>Your Name</author>\n <authorurl>http://www.example.com</authorurl>\n </authorinformation>\n <requiredpackages>\n <requiredpackage minversion=\"6.0.0\">com.woltlab.wcf</requiredpackage>\n </requiredpackages>\n <excludedpackages>\n <excludedpackage version=\"7.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n <instructions type=\"install\">\n <instruction type=\"file\" />\n <instruction type=\"template\" />\n <instruction type=\"page\" />\n </instructions>\n</package>\n</code></pre> <p>There is an entire chapter on the package system that explains what the code above does and how you can adjust it to fit your needs. For now we'll keep it as it is.</p>"},{"location":"getting-started/#the-php-class","title":"The PHP Class","text":"<p>The next step is to create the PHP class which will serve our page:</p> <ol> <li>Create the directory <code>files</code> in the same directory where <code>package.xml</code> is located</li> <li>Open <code>files</code> and create the directory <code>lib</code></li> <li>Open <code>lib</code> and create the directory <code>page</code></li> <li>Within the directory <code>page</code>, please create the file <code>TestPage.class.php</code></li> </ol> <p>Copy and paste the following code into the <code>TestPage.class.php</code>:</p> <pre><code><?php\nnamespace wcf\\page;\nuse wcf\\system\\WCF;\n\n/**\n * A simple test page for demonstration purposes.\n *\n * @author YOUR NAME\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n */\nclass TestPage extends AbstractPage {\n /**\n * @var string\n */\n protected $greet = '';\n\n /**\n * @inheritDoc\n */\n public function readParameters() {\n parent::readParameters();\n\n if (isset($_GET['greet'])) $this->greet = $_GET['greet'];\n }\n\n /**\n * @inheritDoc\n */\n public function readData() {\n parent::readData();\n\n if (empty($this->greet)) {\n $this->greet = 'World';\n }\n }\n\n /**\n * @inheritDoc\n */\n public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'greet' => $this->greet\n ]);\n }\n}\n</code></pre> <p>The class inherits from wcf\\page\\AbstractPage, the default implementation of pages without form controls. It defines quite a few methods that will be automatically invoked in a specific order, for example <code>readParameters()</code> before <code>readData()</code> and finally <code>assignVariables()</code> to pass arbitrary values to the template.</p> <p>The property <code>$greet</code> is defined as <code>World</code>, but can optionally be populated through a GET variable (<code>index.php?test/&greet=You</code> would output <code>Hello You!</code>). This extra code illustrates the separation of data processing that takes place within all sort of pages, where all user-supplied data is read from within a single method. It helps organizing the code, but most of all it enforces a clean class logic that does not start reading user input at random places, including the risk to only escape the input of variable <code>$_GET['foo']</code> 4 out of 5 times.</p> <p>Reading and processing the data is only half the story, now we need a template to display the actual content for our page. You don't need to specify it yourself, it will be automatically guessed based on your namespace and class name, you can read more about it later.</p> <p>Last but not least, you must not include the closing PHP tag <code>?></code> at the end, it can cause PHP to break on whitespaces and is not required at all.</p>"},{"location":"getting-started/#the-template","title":"The Template","text":"<p>Navigate back to the root directory of your package until you see both the <code>files</code> directory and the <code>package.xml</code>. Now create a directory called <code>templates</code>, open it and create the file <code>test.tpl</code>.</p> <pre><code>{include file='header'}\n\n<div class=\"section\">\n Hello {$greet}!\n</div>\n\n{include file='footer'}\n</code></pre> <p>Templates are a mixture of HTML and Smarty-like template scripting to overcome the static nature of raw HTML. The above code will display the phrase <code>Hello World!</code> in the application frame, just as any other page would render. The included templates <code>header</code> and <code>footer</code> are responsible for the majority of the overall page functionality, but offer a whole lot of customization abilities to influence their behavior and appearance.</p>"},{"location":"getting-started/#the-page-definition","title":"The Page Definition","text":"<p>The package now contains the PHP class and the matching template, but it is still missing the page definition. Please create the file <code>page.xml</code> in your project's root directory, thus on the same level as the <code>package.xml</code>.</p> <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/page.xsd\">\n <import>\n <page identifier=\"com.example.test.Test\">\n <controller>wcf\\page\\TestPage</controller>\n <name language=\"en\">Test Page</name>\n <pageType>system</pageType>\n </page>\n </import>\n</data>\n</code></pre> <p>You can provide a lot more data for a page, including logical nesting and dedicated handler classes for display in menus.</p>"},{"location":"getting-started/#building-the-package","title":"Building the Package","text":"<p>If you have followed the above guidelines carefully, your package directory should now look like this:</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u2514\u2500\u2500 page\n\u2502 \u2514\u2500\u2500 TestPage.class.php\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 page.xml\n\u2514\u2500\u2500 templates\n \u2514\u2500\u2500 test.tpl\n</code></pre> <p>Both files and templates are archive-based package components, that deploy their payload using tar archives rather than adding the raw files to the package file. Please create the archive <code>files.tar</code> and add the contents of the <code>files/*</code> directory, but not the directory <code>files/</code> itself. Repeat the same process for the <code>templates</code> directory, but this time with the file name <code>templates.tar</code>. Place both files in the root of your project.</p> <p>Last but not least, create the package archive <code>com.example.test.tar</code> and add all the files listed below.</p> <ul> <li><code>files.tar</code></li> <li><code>package.xml</code></li> <li><code>page.xml</code></li> <li><code>templates.tar</code></li> </ul> <p>The archive's filename can be anything you want, all though it is the general convention to use the package name itself for easier recognition.</p>"},{"location":"getting-started/#installation","title":"Installation","text":"<p>Open the Administration Control Panel and navigate to <code>Configuration > Packages > Install Package</code>, click on <code>Upload Package</code> and select the file <code>com.example.test.tar</code> from your disk. Follow the on-screen instructions until it has been successfully installed.</p> <p>Open a new browser tab and navigate to your newly created page. If WoltLab Suite is installed at <code>https://example.com/wsc/</code>, then the URL should read <code>https://example.com/wsc/index.php?test/</code>.</p> <p>Congratulations, you have just created your first package!</p>"},{"location":"getting-started/#developer-tools","title":"Developer Tools","text":"<p>The developer tools provide an interface to synchronize the data of an installed package with a bare repository on the local disk. You can re-import most PIPs at any time and have the changes applied without crafting a manual update. This process simulates a regular package update with a single PIP only, and resets the cache after the import has been completed.</p>"},{"location":"getting-started/#registering-a-project","title":"Registering a Project","text":"<p>Projects require the absolute path to the package directory, that is, the directory where it can find the <code>package.xml</code>. It is not required to install an package to register it as a project, but you have to install it in order to work with it. It does not install the package by itself!</p> <p>There is a special button on the project list that allows for a mass-import of projects based on a search path. Each direct child directory of the provided path will be tested and projects created this way will use the identifier extracted from the <code>package.xml</code>.</p>"},{"location":"getting-started/#synchronizing","title":"Synchronizing","text":"<p>The install instructions in the <code>package.xml</code> are ignored when offering the PIP imports, the detection works entirely based on the default filename for each PIP. On top of that, only PIPs that implement the interface <code>wcf\\system\\devtools\\pip\\IIdempotentPackageInstallationPlugin</code> are valid for import, as it indicates that importing the PIP multiple times will have no side-effects and that the result is deterministic regardless of the number of times it has been imported.</p> <p>Some built-in PIPs, such as <code>sql</code> or <code>script</code>, do not qualify for this step and remain unavailable at all times. However, you can still craft and perform an actual package update to have these PIPs executed.</p>"},{"location":"getting-started/#appendix","title":"Appendix","text":""},{"location":"getting-started/#template-guessing","title":"Template Guessing","text":"<p>The class name including the namespace is used to automatically determine the path to the template and its name. The example above used the page class name <code>wcf\\page\\TestPage</code> that is then split into four distinct parts:</p> <ol> <li><code>wcf</code>, the internal abbreviation of WoltLab Suite Core (previously known as WoltLab Community Framework)</li> <li><code>\\page\\</code> (ignored)</li> <li><code>Test</code>, the actual name that is used for both the template and the URL</li> <li><code>Page</code> (page type, ignored)</li> </ol> <p>The fragments <code>1.</code> and <code>3.</code> from above are used to construct the path to the template: <code><installDirOfWSC>/templates/test.tpl</code> (the first letter of <code>Test</code> is being converted to lower-case).</p>"},{"location":"javascript/code-snippets/","title":"Code Snippets - JavaScript API","text":"<p>This is a list of code snippets that do not fit into any of the other articles and merely describe how to achieve something very specific, rather than explaining the inner workings of a function.</p>"},{"location":"javascript/code-snippets/#imageviewer","title":"ImageViewer","text":"<p>The ImageViewer is available on all frontend pages by default, you can easily add images to the viewer by wrapping the thumbnails with a link with the CSS class <code>jsImageViewer</code> that points to the full version.</p> <pre><code><a href=\"http://example.com/full.jpg\" class=\"jsImageViewer\">\n <img src=\"http://example.com/thumbnail.jpg\">\n</a>\n</code></pre>"},{"location":"javascript/components_ckeditor5/","title":"CKEditor 5 - JavaScript API","text":"<p>WoltLab Suite 6.0 ships with a customized version of CKEditor 5 that is enriched by multiple plugins to integrate into the framework. The editor can be accessed through an abstraction layer and event system to interact with basic functionality and to alter its initialization process.</p>"},{"location":"javascript/components_ckeditor5/#the-ckeditor-api","title":"The <code>Ckeditor</code> API","text":"<p>The <code>WoltLabSuite/Core/Component/Ckeditor</code> API offers multiple helper methods to interface with CKEditor and to insert and extract content. You can get access to the instance using the <code>getCkeditor()</code> and <code>getCkeditorById()</code> methods once the editor has been initialized.</p> <p>Please refer to the typings of this component to learn about its API methods.</p>"},{"location":"javascript/components_ckeditor5/#the-event-system-for-ckeditor-5","title":"The Event System for CKEditor 5","text":"<p>The event system of CKEditor 5 was designed for actions from within the editor but not to interface with the \u201coutside world\u201d. In order to provide a deeper integration there is <code>WoltLabSuite/Core/Component/Ckeditor/Event</code> and its exported function <code>listenToCkeditor()</code>.</p> <p><code>listenToCkeditor()</code> expects the source element of the editor which usually is the <code><textarea></code> for the content. There is also <code>dispatchToCkeditor()</code> which is considered to be an internal API used from within the editor.</p>"},{"location":"javascript/components_ckeditor5/#lifecycle-of-ckeditor-5","title":"Lifecycle of CKEditor 5","text":"<p>The initialization of any CKEditor 5 instance is asynchronous and goes through multiple steps to collect the data needed to initialize the editor.</p> <ol> <li><code>setupFeatures()</code> is an override to disable the available features of this instance. The list of features becomes immutable after this event.</li> <li><code>setupConfiguration()</code> is called at the end of the configuration phase and allows changes to the <code>EditorConfig</code> before it is passed to CKEditor.</li> <li>The <code>ready()</code> is fired as soon as the editor has been fully initialized and provides the <code>Ckeditor</code> object to access the editor.</li> <li><code>collectMetaData()</code> is used in inline editors to request the injection of additional payloads that should be included in the server request.</li> <li><code>reset()</code> notifies that the editor is being fully reset and reliant components should perform a reset themselves.</li> <li><code>destroy()</code> signals that the editor has been destroyed and is no longer available.</li> </ol>"},{"location":"javascript/components_ckeditor5/#custom-bbcode-buttons-in-the-editor-toolbar","title":"Custom BBCode Buttons in the Editor Toolbar","text":"<p>Custom buttons in the editor can be injected by pushing them to the toolbar in <code>setupConfiguration()</code>. This is implicitly takes place for buttons that are registered through the BBCode system and are set to appear in the editor.</p> <pre><code>listenToCkeditor(element).setupConfiguration(({ configuration }) => {\n configuration.woltlabBbcode.push({\n icon: \"fire;false\",\n name: \"foo\",\n label: \"Button label for foo\",\n });\n});\n</code></pre> <p>Clicks on the buttons are forwarded through the <code>bbcode()</code> event. The only data passed to the callback is the name of the BBCode that was invoked.</p> <p>The default action of the custom buttons is to insert the BBCode into the editor, including the ability to wrap the selected text in the BBCode tags. Every event listener registered to this event MUST return a boolean to indicate if it wants to suppress the insertion of the text BBCode, for example to open a dialog or trigger another action.</p> <pre><code>listenToCkeditor(element).ready(({ ckeditor }) => {\n listenToCkeditor(element).bbcode(({ bbcode }) => {\n if (bbcode !== \"foo\") {\n return false;\n }\n\n // Do something when the button for `foo` was clicked.\n\n return true;\n });\n});\n</code></pre>"},{"location":"javascript/components_ckeditor5/#submit-the-editor-on-enter","title":"Submit the Editor on Enter","text":"<p>The editor supports the special feature flag <code>submitOnEnter</code> that can be enabled through <code>setupFeatures()</code>. Once enabled it changes the behavior of the Enter key to signal that the contents should be submitted to the server.</p> <pre><code>listenToCkeditor(element).setupFeatures(({ features }) => {\n features.submitOnEnter = true;\n});\n</code></pre> <p>You can subscribe to the <code>submitOnEnter()</code> to be notified when the Enter key was pressed and the editor is not empty. The contents of the editor is provided through the <code>html</code> key.</p> <p>This mode does not suppress the insertion of hard breaks through Shift + Enter.</p> <pre><code>listenToCkeditor(element).submitOnEnter(({ ckeditor, html }) => {\n // Do something with the resulting `html`.\n});\n</code></pre>"},{"location":"javascript/components_ckeditor5/#creating-plugins","title":"Creating Plugins","text":"<p>CKEditor 5 was designed to be compiled as a single bundle, relying a lot on identity checks to access and associate data. Any extra plugin that should be added to the editor must be built using the modules exposed through the <code>setupConfiguration()</code> event otherwise the identity checks will fail.</p> <pre><code>listenToCkeditor(element).setupConfiguration(({ configuration, CKEditor5 }) => {\n class FooPlugin extends CKEditor5.Core.Plugin {\n static get pluginName() {\n return \"FooPlugin\";\n }\n\n init(): void {\n // \u2026\n }\n }\n\n configuration.extraPlugins.push(FooPlugin);\n});\n</code></pre>"},{"location":"javascript/components_confirmation/","title":"Confirmation - JavaScript API","text":"<p>The purpose of confirmation dialogs is to prevent misclicks and to inform the user of potential consequences of their action. A confirmation dialog should always ask a concise question that includes a reference to the object the action is performed upon.</p> <p>You can exclude extra information or form elements in confirmation dialogs, but these should be kept as compact as possible.</p>"},{"location":"javascript/components_confirmation/#example","title":"Example","text":"<pre><code>import { confirmationFactory } from \"WoltLabSuite/Core/Component/Confirmation\";\n\nconst result = await confirmationFactory()\n .custom(\"Do you want a cookie?\")\n .withoutMessage();\nif (result) {\n // User has confirmed the dialog.\n}\n</code></pre> <p>Confirmation dialogs are a special type that use the <code>role=\"alertdialog\"</code> attribute and will always include a cancel button. The dialog itself will be limited to a width of 500px, the title can wrap into multiple lines and there will be no \u201cX\u201d button to close the dialog.</p>"},{"location":"javascript/components_confirmation/#when-to-use","title":"When to Use","text":"<p>Over the past few years the term \u201cConfirmation Fatique\u201d has emerged that describes the issue of having too many confirmation dialogs even there is no real need for them. A confirmation dialog should only be displayed when the action requires further inputs, for example, a soft delete that requires a reason, or when the action is destructive.</p>"},{"location":"javascript/components_confirmation/#proper-wording","title":"Proper Wording","text":"<p>The confirmation question should hint the severity of the action, in particular whether or not it is destructive. Destructive actions are those that cannot be undone and either cause a permanent mutation or that cause data loss. All questions should be phrased in one or two ways depending on the action.</p> <p>Destructive action:</p> <p>Are you sure you want to delete \u201cExample Object\u201d? (German) Wollen Sie \u201eBeispiel-Objekt\u201c wirklich l\u00f6schen?</p> <p>All other actions:</p> <p>Do you want to move \u201cExample Object\u201d to the trash bin? (German) M\u00f6chten Sie \u201eBeispiel-Objekt\u201c in den Papierkorb verschieben?</p>"},{"location":"javascript/components_confirmation/#available-presets","title":"Available Presets","text":"<p>WoltLab Suite 6.0 currently ships with three presets for common confirmation dialogs.</p> <p>All three presets have an optional parameter for the title of the related object as part of the question asked to the user. It is strongly recommended to provide the title if it exists, otherwise it can be omitted and an indeterminate variant is used instead.</p>"},{"location":"javascript/components_confirmation/#soft-delete","title":"Soft Delete","text":"<p>Soft deleting objects with an optional input field for a reason:</p> <pre><code>const askForReason = true;\nconst { result, reason } = await confirmationFactory().softDelete(\n theObjectName,\n askForReason\n);\nif (result) {\n console.log(\n \"The user has requested a soft delete, the following reason was provided:\",\n reason\n );\n}\n</code></pre> <p>The <code>reason</code> will always be a string, but with a length of zero if the <code>result</code> is <code>false</code> or if no reason was requested. You can simply omit the value if you do not use the reason.</p> <pre><code>const askForReason = false;\nconst { result } = await confirmationFactory().softDelete(\n theObjectName,\n askForReason\n);\nif (result) {\n console.log(\"The user has requested a soft delete.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#restore","title":"Restore","text":"<p>Restore a previously soft deleted object:</p> <pre><code>const result = await confirmationFactory().restore(theObjectName);\nif (result) {\n console.log(\"The user has requested to restore the object.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#delete","title":"Delete","text":"<p>Permanently delete an object, will inform the user that the action cannot be undone:</p> <pre><code>const result = await confirmationFactory().delete(theObjectName);\nif (result) {\n console.log(\"The user has requested to delete the object.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#custom-confirmation-prompts","title":"Custom Confirmation Prompts","text":"<p>The <code>custom()</code> permits a custom confirmation dialog with a user-defined dialog content.</p> <pre><code>const result = await confirmationFactory()\n .custom(theQuestionToAsk)\n .message(someLengthyExplanation);\nif (result) {\n console.log(\"The user has confirmed the dialog.\");\n}\n</code></pre>"},{"location":"javascript/components_confirmation/#use-custom-html-in-the-dialog-body","title":"Use Custom HTML in the Dialog Body","text":"<p>Some dialogs require additional input elements, for example, the prompt to remove an element has an optional text field for a reason.</p> <pre><code>const { result, dialog } = await confirmationFactory()\n .custom(theQuestionToAsk)\n .withFormElements((dialog) => {\n const p = document.createElement(\"p\");\n p.textContent = \"Hello World\";\n dialog.content.append(p);\n });\nif (result) {\n console.log(\"The user has confirmed the dialog.\");\n console.log(\n \"The DOM of the dialog can be accessed through `dialog.content`\",\n dialog.content\n );\n}\n</code></pre>"},{"location":"javascript/components_dialog/","title":"Dialogs - JavaScript API","text":"<p>Modal dialogs are a powerful tool to draw the viewer\u2019s attention to an important message, question or form. Dialogs naturally interrupt the workflow and prevent the navigation to other sections by making other elements on the page inert.</p> <p>WoltLab Suite 6.0 ships with four different types of dialogs.</p>"},{"location":"javascript/components_dialog/#quickstart","title":"Quickstart","text":"<p>There are four different types of dialogs that each fulfill their own specialized role and that provide built-in features to make the development much easier. Please see the following list to make a quick decision of what kind of dialog you need.</p> <ul> <li>Is this some kind of error message? Use an alert dialog.</li> <li>Are you asking the user to confirm an action? Use a confirmation dialog.</li> <li>Does the dialog contain form inputs that the user must fill in? Use a prompt dialog.</li> <li>Do you want to present information to the user without requiring any action? Use a dialog without controls.</li> </ul>"},{"location":"javascript/components_dialog/#dialogs-without-controls","title":"Dialogs Without Controls","text":"<p>Dialogs may contain just an explanation or extra information that should be presented to the viewer without requiring any further interaction. The dialog can be closed via the \u201cX\u201d button or by clicking the modal backdrop.</p> <pre><code>import { dialogFactory } from \"WoltLabSuite/Core/Component/Dialog\";\n\nconst dialog = dialogFactory().fromHtml(\"<p>Hello World</p>\").withoutControls();\ndialog.show(\"Greetings from my dialog\");\n</code></pre>"},{"location":"javascript/components_dialog/#when-to-use","title":"When to Use","text":"<p>The short answer is: Don\u2019t.</p> <p>Dialogs without controls are an anti-pattern because they only contain content that does not require the modal appearance of a dialog. More often than not dialogs are used for this kind of content because they are easy to use without thinking about better ways to present the content.</p> <p>If possible these dialogs should be avoided and the content is presented in a more suitable way, for example, as a flyout or by showing content on an existing or new page.</p>"},{"location":"javascript/components_dialog/#alerts","title":"Alerts","text":"<p>Alerts are designed to inform the user of something important that requires no further action by the user. Typical examples for alerts are error messages or warnings.</p> <p>An alert will only provide a single button to acknowledge the dialog and must not contain interactive content. The dialog itself will be limited to a width of 500px, the title can wrap into multiple lines and there will be no \u201cX\u201d button to close the dialog.</p> <pre><code>import { dialogFactory } from \"WoltLabSuite/Core/Component/Dialog\";\n\nconst dialog = dialogFactory()\n .fromHtml(\"<p>ERROR: Something went wrong!</p>\")\n .asAlert();\ndialog.show(\"Server Error\");\n</code></pre> <p>You can customize the label of the primary button to better explain what will happen next. This can be useful for alerts that will have a side-effect when closing the dialog, such as redirect to a different page.</p> <pre><code>const dialog = dialogFactory()\n .fromHtml(\"<p>Something went wrong, we cannot find your shopping cart.</p>\")\n .asAlert({\n primary: \"Back to the Store Page\",\n });\n\ndialog.addEventListener(\"primary\", () => {\n window.location.href = \"https://example.com/shop/\";\n});\n\ndialog.show(\"The shopping cart is missing\");\n</code></pre> <p>The <code>primary</code> event is triggered both by clicking on the primary button and by clicks on the modal backdrop.</p>"},{"location":"javascript/components_dialog/#when-to-use_1","title":"When to Use","text":"<p>Alerts are a special type of dialog that use the <code>role=\"alert\"</code> attribute to signal its importance to assistive tools. Use alerts sparingly when there is no other way to communicate that something did not work as expected.</p> <p>Alerts should not be used for cases where you expect an error to happen. For example, a form control that expectes an input to fall within a restricted range should show an inline error message instead of raising an alert.</p>"},{"location":"javascript/components_dialog/#confirmation","title":"Confirmation","text":"<p>Confirmation dialogs are supported through a separate factory function that provides a set of presets as well as a generic API. Please see the separate documentation for confirmation dialogs to learn more.</p>"},{"location":"javascript/components_dialog/#prompts","title":"Prompts","text":"<p>The most common type of dialogs are prompts that are similar to confirmation dialogs, but without the restrictions and with a regular title. These dialogs can be used universally and provide a submit and cancel button by default.</p> <p>In addition they offer an \u201cextra\u201d button that is placed to the left of the default buttons are can be used to offer a single additional action. A possible use case for an \u201cextra\u201d button would be a dialog that includes an instance of the WYSIWYG editor, the extra button could be used to trigger a message preview.</p>"},{"location":"javascript/components_dialog/#code-example","title":"Code Example","text":"<pre><code><button id=\"showMyDialog\">Show the dialog</button>\n\n<template id=\"myDialog\">\n <dl>\n <dt>\n <label for=\"myInput\">Title</label>\n </dt>\n <dd>\n <input type=\"text\" name=\"myInput\" id=\"myInput\" value=\"\" required />\n </dd>\n </dl>\n</template>\n</code></pre> <pre><code>import { dialogFactory } from \"WoltLabSuite/Core/Component/Dialog\";\n\ndocument.getElementById(\"showMyDialog\")!.addEventListener(\"click\", () => {\n const dialog = dialogFactory().fromId(\"myDialog\").asPrompt();\n\n dialog.addEventListener(\"primary\", () => {\n const myInput = document.getElementById(\"myInput\");\n\n console.log(\"Provided title:\", myInput.value.trim());\n });\n});\n</code></pre>"},{"location":"javascript/components_dialog/#custom-buttons","title":"Custom Buttons","text":"<p>The <code>asPrompt()</code> call permits some level of customization of the form control buttons.</p>"},{"location":"javascript/components_dialog/#customizing-the-primary-button","title":"Customizing the Primary Button","text":"<p>The <code>primary</code> option is used to change the default label of the primary button.</p> <pre><code>dialogFactory()\n .fromId(\"myDialog\")\n .asPrompt({\n primary: Language.get(\"wcf.dialog.button.primary\"),\n });\n</code></pre>"},{"location":"javascript/components_dialog/#adding-an-extra-button","title":"Adding an Extra Button","text":"<p>The extra button has no default label, enabling it requires you to provide a readable name.</p> <pre><code>const dialog = dialogFactory()\n .fromId(\"myDialog\")\n .asPrompt({\n extra: Language.get(\"my.extra.button.name\"),\n });\n\ndialog.addEventListener(\"extra\", () => {\n // The extra button does nothing on its own. If you want\n // to close the button after performing an action you\u2019ll\n // need to call `dialog.close()` yourself.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#interacting-with-dialogs","title":"Interacting with dialogs","text":"<p>Dialogs are represented by the <code><woltlab-core-dialog></code> element that exposes a set of properties and methods to interact with it.</p>"},{"location":"javascript/components_dialog/#opening-and-closing-dialogs","title":"Opening and Closing Dialogs","text":"<p>You can open a dialog through the <code>.show()</code> method that expects the title of the dialog as the only argument. Check the <code>.open</code> property to determine if the dialog is currently open.</p> <p>Programmatically closing a dialog is possibly through <code>.close()</code>.</p>"},{"location":"javascript/components_dialog/#accessing-the-content","title":"Accessing the Content","text":"<p>All contents of a dialog exists within a child element that can be accessed through the <code>content</code> property.</p> <pre><code>// Add some text to the dialog.\nconst p = document.createElement(\"p\");\np.textContent = \"Hello World\";\ndialog.content.append(p);\n\n// Find a text input inside the dialog.\nconst input = dialog.content.querySelector('input[type=\"text\"]');\n</code></pre>"},{"location":"javascript/components_dialog/#disabling-the-submit-button-of-a-dialog","title":"Disabling the Submit Button of a Dialog","text":"<p>You can prevent the dialog submission until a condition is met, allowing you to dynamically enable or disable the button at will.</p> <pre><code>dialog.incomplete = false;\n\nconst checkbox = dialog.content.querySelector('input[type=\"checkbox\"]')!;\ncheckbox.addEventListener(\"change\", () => {\n // Block the dialog submission unless the checkbox is checked.\n dialog.incomplete = !checkbox.checked;\n});\n</code></pre>"},{"location":"javascript/components_dialog/#managing-an-instance-of-a-dialog","title":"Managing an Instance of a Dialog","text":"<p>The old API for dialogs implicitly kept track of the instance by binding it to the <code>this</code> parameter as seen in calls like <code>UiDialog.open(this);</code>. The new implementation requires to you to keep track of the dialog on your own.</p> <pre><code>class MyComponent {\n #dialog?: WoltlabCoreDialogElement;\n\n constructor() {\n const button = document.querySelector(\".myButton\") as HTMLButtonElement;\n button.addEventListener(\"click\", () => {\n this.#showGreeting(button.dataset.name);\n });\n }\n\n #showGreeting(name: string | undefined): void {\n const dialog = this.#getDialog();\n\n const p = dialog.content.querySelector(\"p\")!;\n if (name === undefined) {\n p.textContent = \"Hello World\";\n } else {\n p.textContent = `Hello ${name}`;\n }\n\n dialog.show(\"Greetings!\");\n }\n\n #getDialog(): WoltlabCoreDialogElement {\n if (this.#dialog === undefined) {\n this.#dialog = dialogFactory()\n .fromHtml(\"<p>Hello from MyComponent</p>\")\n .withoutControls();\n }\n\n return this.#dialog;\n }\n}\n</code></pre>"},{"location":"javascript/components_dialog/#event-access","title":"Event Access","text":"<p>You can bind event listeners to specialized events to get notified of events and to modify its behavior.</p>"},{"location":"javascript/components_dialog/#afterclose","title":"<code>afterClose</code>","text":"<p>This event cannot be canceled.</p> <p>Fires when the dialog has closed.</p> <pre><code>dialog.addEventListener(\"afterClose\", () => {\n // Dialog was closed.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#close","title":"<code>close</code>","text":"<p>Fires when the dialog is about to close.</p> <pre><code>dialog.addEventListener(\"close\", (event) => {\n if (someCondition) {\n event.preventDefault();\n }\n});\n</code></pre>"},{"location":"javascript/components_dialog/#cancel","title":"<code>cancel</code>","text":"<p>Fires only when there is a \u201cCancel\u201d button and the user has either pressed that button or clicked on the modal backdrop. The dialog will close if the event is not canceled.</p> <pre><code>dialog.addEventListener(\"cancel\", (event) => {\n if (someCondition) {\n event.preventDefault();\n }\n});\n</code></pre>"},{"location":"javascript/components_dialog/#extra","title":"<code>extra</code>","text":"<p>This event cannot be canceled.</p> <p>Fires when an extra button is present and the button was clicked by the user. This event does nothing on its own and is supported for dialogs of type \u201cPrompt\u201d only.</p> <pre><code>dialog.addEventListener(\"extra\", () => {\n // The extra button was clicked.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#primary","title":"<code>primary</code>","text":"<p>This event cannot be canceled.</p> <p>Fires only when there is a primary action button and the user has either pressed that button or submitted the form through keyboard controls.</p> <pre><code>dialog.addEventListener(\"primary\", () => {\n // The primary action button was clicked or the\n // form was submitted through keyboard controls.\n //\n // The `validate` event has completed successfully.\n});\n</code></pre>"},{"location":"javascript/components_dialog/#validate","title":"<code>validate</code>","text":"<p>Fires only when there is a form and the user has pressed the primary action button or submitted the form through keyboard controls. Canceling this event is interpreted as a form validation failure.</p> <pre><code>const input = document.createElement(\"input\");\ndialog.content.append(input);\n\ndialog.addEventListener(\"validate\", (event) => {\n if (input.value.trim() === \"\") {\n event.preventDefault();\n\n // Display an inline error message.\n }\n});\n</code></pre>"},{"location":"javascript/components_google_maps/","title":"Google Maps - JavaScript API","text":"<p>The Google Maps component is used to show a map using the Google Maps API.</p>"},{"location":"javascript/components_google_maps/#example","title":"Example","text":"<p>The component can be included directly as follows:</p> <pre><code><woltlab-core-google-maps\n id=\"id\"\n class=\"googleMap\"\n api-key=\"your_api_key\"\n></woltlab-core-google-maps>\n</code></pre> <p>Alternatively, the component can be included via a template that uses the API key from the configuration and also handles the user content:</p> <pre><code>{include file='googleMapsElement' googleMapsElementID=\"id\"}\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#id","title":"<code>id</code>","text":"<p>ID of the map instance.</p>"},{"location":"javascript/components_google_maps/#api-key","title":"<code>api-key</code>","text":"<p>Google Maps API key.</p>"},{"location":"javascript/components_google_maps/#zoom","title":"<code>zoom</code>","text":"<p>Defaults to <code>13</code>.</p> <p>Default zoom factor of the map.</p>"},{"location":"javascript/components_google_maps/#lat","title":"<code>lat</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Latitude of the default map position.</p>"},{"location":"javascript/components_google_maps/#lng","title":"<code>lng</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Longitude of the default map position.</p>"},{"location":"javascript/components_google_maps/#access-user-location","title":"<code>access-user-location</code>","text":"<p>If set, the map will try to center based on the user's current position.</p>"},{"location":"javascript/components_google_maps/#map-related-functions","title":"Map-related Functions","text":""},{"location":"javascript/components_google_maps/#addmarker","title":"<code>addMarker</code>","text":"<p>Adds a marker to the map.</p>"},{"location":"javascript/components_google_maps/#example_1","title":"Example","text":"<pre><code><script data-relocate=\"true\">\n require(['WoltLabSuite/Core/Component/GoogleMaps/Marker'], ({ addMarker }) => {\n void addMarker(document.getElementById('map_id'), 52.4505, 13.7546, 'Title', true);\n });\n</script>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_1","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#element","title":"<code>element</code>","text":"<p><code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#latitude","title":"<code>latitude</code>","text":"<p>Marker position (latitude)</p>"},{"location":"javascript/components_google_maps/#longitude","title":"<code>longitude</code>","text":"<p>Marker position (longitude)</p>"},{"location":"javascript/components_google_maps/#title","title":"<code>title</code>","text":"<p>Title of the marker.</p>"},{"location":"javascript/components_google_maps/#focus","title":"<code>focus</code>","text":"<p>Defaults to <code>false</code>.</p> <p>True, to focus the map on the position of the marker.</p>"},{"location":"javascript/components_google_maps/#adddraggablemarker","title":"<code>addDraggableMarker</code>","text":"<p>Adds a draggable marker to the map.</p>"},{"location":"javascript/components_google_maps/#example_2","title":"Example","text":"<pre><code><script data-relocate=\"true\">\n require(['WoltLabSuite/Core/Component/GoogleMaps/Marker'], ({ addDraggableMarker }) => {\n void addDraggableMarker(document.getElementById('map_id'), 52.4505, 13.7546);\n });\n</script>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_2","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#element_1","title":"<code>element</code>","text":"<p><code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#latitude_1","title":"<code>latitude</code>","text":"<p>Marker position (latitude)</p>"},{"location":"javascript/components_google_maps/#longitude_1","title":"<code>longitude</code>","text":"<p>Marker position (longitude)</p>"},{"location":"javascript/components_google_maps/#geocoding","title":"<code>Geocoding</code>","text":"<p>Enables the geocoding feature for a map.</p>"},{"location":"javascript/components_google_maps/#example_3","title":"Example","text":"<pre><code><input\n type=\"text\"\n data-google-maps-geocoding=\"map_id\"\n data-google-maps-marker\n data-google-maps-geocoding-store=\"prefix\"\n>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_3","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#data-google-maps-geocoding","title":"<code>data-google-maps-geocoding</code>","text":"<p>ID of the <code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#data-google-maps-marker","title":"<code>data-google-maps-marker</code>","text":"<p>If set, a movable marker is created that is coupled with the input field.</p>"},{"location":"javascript/components_google_maps/#data-google-maps-geocoding-store","title":"<code>data-google-maps-geocoding-store</code>","text":"<p>If set, the coordinates (latitude and longitude) are stored comma-separated in a hidden input field. Optionally, a value can be passed that is used as a prefix for the name of the input field.</p>"},{"location":"javascript/components_google_maps/#markerloader","title":"<code>MarkerLoader</code>","text":"<p>Handles a large map with many markers where markers are loaded via AJAX.</p>"},{"location":"javascript/components_google_maps/#example_4","title":"Example","text":"<pre><code><script data-relocate=\"true\">\n require(['WoltLabSuite/Core/Component/GoogleMaps/MarkerLoader'], ({ setup }) => {\n setup(document.getElementById('map_id'), 'action_classname', {});\n });\n</script>\n</code></pre>"},{"location":"javascript/components_google_maps/#parameters_4","title":"Parameters","text":""},{"location":"javascript/components_google_maps/#element_2","title":"<code>element</code>","text":"<p><code><woltlab-core-google-maps></code> element.</p>"},{"location":"javascript/components_google_maps/#actionclassname","title":"<code>actionClassName</code>","text":"<p>Name of the PHP class that is called to retrieve the markers via AJAX.</p>"},{"location":"javascript/components_google_maps/#additionalparameters","title":"<code>additionalParameters</code>","text":"<p>Additional parameters that are transmitted when querying the markers via AJAX.</p>"},{"location":"javascript/components_notice/","title":"Notices - JavaScript API","text":"<p>The notice component can be used to show text notices for the user. The type of the notice can be controlled depending on the <code>type</code> parameter.</p>"},{"location":"javascript/components_notice/#example","title":"Example","text":"<pre><code><woltlab-core-notice type=\"info\">Hello World!</woltlab-core-notice>\n</code></pre>"},{"location":"javascript/components_notice/#parameters","title":"Parameters","text":""},{"location":"javascript/components_notice/#type","title":"<code>type</code>","text":"<p>Controls the type of a notice (color and displayed icon). The following values are available: <code>info</code>, <code>success</code>, <code>warning</code>, <code>error</code></p>"},{"location":"javascript/components_pagination/","title":"Pagination - JavaScript API","text":"<p>The pagination component is used to expose multiple pages to the end user. This component supports both static URLs and dynamic navigation using DOM events.</p>"},{"location":"javascript/components_pagination/#example","title":"Example","text":"<pre><code><woltlab-core-pagination page=\"1\" count=\"10\" url=\"https://www.woltlab.com\"></woltlab-core-pagination>\n</code></pre>"},{"location":"javascript/components_pagination/#parameters","title":"Parameters","text":""},{"location":"javascript/components_pagination/#page","title":"<code>page</code>","text":"<p>Defaults to <code>1</code>.</p> <p>The number of the currently displayed page.</p>"},{"location":"javascript/components_pagination/#count","title":"<code>count</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Number of available pages. Must be greater than <code>1</code> for the pagination to be displayed.</p>"},{"location":"javascript/components_pagination/#url","title":"<code>url</code>","text":"<p>Defaults to an empty string.</p> <p>If defined, static pagination links are created based on the URL with the <code>pageNo</code> parameter appended to it. Otherwise only the <code>switchPage</code> event will be fired if a user clicks on a pagination link.</p>"},{"location":"javascript/components_pagination/#events","title":"Events","text":""},{"location":"javascript/components_pagination/#switchpage","title":"<code>switchPage</code>","text":"<p>The <code>switchPage</code> event will be fired when the user clicks on a pagination link. The event detail will contain the number of the selected page. The event can be canceled to prevent navigation.</p>"},{"location":"javascript/components_pagination/#jumptopage","title":"<code>jumpToPage</code>","text":"<p>The <code>jumpToPage</code> event will be fired when the user clicks on one of the ellipsis buttons within the pagination.</p>"},{"location":"javascript/components_rpc_api/","title":"RPC API","text":"<p>The PHP RPC API has a companion implementation in TypeScript that greatly simplifies the communication with the server and provides helper methods to process responses.</p>"},{"location":"javascript/components_rpc_api/#implementing-the-api","title":"Implementing the API","text":""},{"location":"javascript/components_rpc_api/#naming-schema","title":"Naming Schema","text":"<p>The module should roughly map to the route parameters for simplicity, for example, <code>WoltLabSuite/Core/Api/Sessions/DeleteSession</code> maps to the <code>DELETE /sessions/:id</code> endpoint.</p>"},{"location":"javascript/components_rpc_api/#using-woltlabsuitecoreapiresult","title":"Using <code>WoltLabSuite/Core/Api/Result</code>","text":"<p>The <code>Result</code> module provides a consistent interface to interact with the API. A comprehensive implementation can be found in <code>WoltLabSuite/Core/Api/Comments/RenderComment.ts</code>:</p> <pre><code>import { prepareRequest } from \"WoltLabSuite/Core/Ajax/Backend\";\nimport { ApiResult, apiResultFromError, apiResultFromValue } from \"../Result\";\n\ntype Response = {\n template: string;\n response: string | undefined;\n};\n\nexport async function renderComment(\n commentId: number,\n responseId: number | undefined = undefined,\n messageOnly: boolean = false,\n objectTypeId: number | undefined = undefined\n): Promise<ApiResult<Response>> {\n const url = new URL(\n `${window.WSC_API_URL}index.php?api/rpc/core/comments/${commentId}/render`\n );\n url.searchParams.set(\"messageOnly\", messageOnly.toString());\n if (responseId !== undefined) {\n url.searchParams.set(\"responseID\", responseId.toString());\n }\n if (objectTypeId !== undefined) {\n url.searchParams.set(\"objectTypeID\", objectTypeId.toString());\n }\n\n let response: Response;\n try {\n response = (await prepareRequest(url).get().fetchAsJson()) as Response;\n } catch (e) {\n return apiResultFromError(e);\n }\n\n return apiResultFromValue(response);\n}\n</code></pre> <p>For <code>GET</code> and <code>DELETE</code> parameters it is possibly to provide additional parameters using the query string. You should use the native <code>URL</code> class to (conditionally) set those parameters as shown in the example above.</p>"},{"location":"javascript/components_rpc_api/#apiresult","title":"<code>ApiResult</code>","text":"<p>The type <code>ApiResult</code> represents the two possible states of the response, either an error or the actual result. The callee should evaluate the <code>ok</code> property to distinguish between the two cases to properly handle any rejections.</p> <p>Sometimes an action is infallible by design in which case the shortcut <code>.unwrap()</code> should be used. It will return the result value or fail hard when there is an actual error.</p>"},{"location":"javascript/components_rpc_api/#apiresultfromerrorerror-unknown","title":"<code>apiResultFromError(error: unknown)</code>","text":"<p>This function checks if the <code>error</code> represents a server response that is not in the 2xx range. Any network errors or other kind of client errors will fail hard.</p> <p>The returned value from the server will be attempted to be parsed into an <code>WoltLabSuite/Core/Api/Error</code> that represents the well-defined error response from the PHP RPC API. Validation errors can easily be detected through the <code>.getValidationError()</code> method of <code>ApiError</code> which returns <code>undefined</code> for all other error classes.</p>"},{"location":"javascript/general-usage/","title":"General JavaScript Usage","text":"<p>WoltLab Suite 5.4 introduced support for TypeScript, migrating all existing modules to TypeScript. The JavaScript section of the documentation is not yet updated to account for the changes, possibly explaining concepts that cannot be applied as-is when writing TypeScript. You can learn about basic TypeScript use in WoltLab Suite, such as consuming WoltLab Suite\u2019s types in own packages, within in the TypeScript section.</p>"},{"location":"javascript/general-usage/#the-history-of-the-legacy-api","title":"The History of the Legacy API","text":"<p>The WoltLab Suite 3.0 introduced a new API based on AMD-Modules with ES5-JavaScript that was designed with high performance and visible dependencies in mind. This was a fundamental change in comparison to the legacy API that was build many years before while jQuery was still a thing and we had to deal with ancient browsers such as Internet Explorer 9 that felt short in both CSS and JavaScript capabilities.</p> <p>Fast forward a few years, the old API is still around and most important, it is actively being used by some components that have not been rewritten yet. This has been done to preserve the backwards-compatibility and to avoid the significant amount of work that it requires to rewrite a component. The components invoked on page initialization have all been rewritten to use the modern API, but some deferred objects that are invoked later during the page runtime may still use the old API.</p> <p>However, the legacy API is deprecated and you should not rely on it for new components at all. It slowly but steadily gets replaced up until a point where its last bits are finally removed from the code base.</p>"},{"location":"javascript/general-usage/#embedding-javascript-inside-templates","title":"Embedding JavaScript inside Templates","text":"<p>The <code><script></code>-tags are extracted and moved during template processing, eventually placing them at the very end of the body element while preserving their order of appearance.</p> <p>This behavior is controlled through the <code>data-relocate=\"true\"</code> attribute on the <code><script></code> which is mandatory for almost all scripts, mostly because their dependencies (such as jQuery) are moved to the bottom anyway.</p> <pre><code><script data-relocate=\"true\">\n $(function() {\n // Code that uses jQuery (Legacy API)\n });\n</script>\n\n<!-- or -->\n\n<script data-relocate=\"true\">\n require([\"Some\", \"Dependencies\"], function(Some, Dependencies) {\n // Modern API\n });\n</script>\n</code></pre>"},{"location":"javascript/general-usage/#including-external-javascript-files","title":"Including External JavaScript Files","text":"<p>The AMD-Modules used in the new API are automatically recognized and lazy-loaded on demand, so unless you have a rather large and pre-compiled code-base, there is nothing else to worry about.</p>"},{"location":"javascript/general-usage/#debug-variants-and-cache-buster","title":"Debug-Variants and Cache-Buster","text":"<p>Your JavaScript files may change over time and you would want the users' browsers to always load and use the latest version of your files. This can be achieved by appending the special <code>LAST_UPDATE_TIME</code> constant to your file path. It contains the unix timestamp of the last time any package was installed, updated or removed and thus avoid outdated caches by relying on a unique value, without invalidating the cache more often that it needs to be.</p> <pre><code><script data-relocate=\"true\" src=\"{$__wcf->getPath('app')}js/App.js?t={LAST_UPDATE_TIME}\"></script>\n</code></pre> <p>For small scripts you can simply serve the full, non-minified version to the user at all times, the differences in size and execution speed are insignificant and are very unlikely to offer any benefits. They might even yield a worse performance, because you'll have to include them statically in the template, even if the code is never called.</p> <p>However, if you're including a minified build in your app or plugin, you should include a switch to load the uncompressed version in the debug mode, while serving the minified and optimized file to the average visitor. You should use the <code>ENABLE_DEBUG_MODE</code> constant to decide which version should be loaded.</p> <pre><code><script data-relocate=\"true\" src=\"{$__wcf->getPath('app')}js/App{if !ENABLE_DEBUG_MODE}.min{/if}.js?t={LAST_UPDATE_TIME}\"></script>\n</code></pre>"},{"location":"javascript/general-usage/#the-accelerated-guest-view-tiny-builds","title":"The Accelerated Guest View (\"Tiny Builds\")","text":"<p>You can learn more on the Accelerated Guest View in the migration docs.</p> <p>The \u201cAccelerated Guest View\u201d aims to decrease page size and to improve responsiveness by enabling a read-only mode for visitors. If you are providing a separate compiled build for this mode, you'll need to include yet another switch to serve the right version to the visitor.</p> <pre><code><script data-relocate=\"true\" src=\"{$__wcf->getPath('app')}js/App{if !ENABLE_DEBUG_MODE}{if VISITOR_USE_TINY_BUILD}.tiny{/if}.min{/if}.js?t={LAST_UPDATE_TIME}\"></script>\n</code></pre>"},{"location":"javascript/general-usage/#the-js-template-plugin","title":"The <code>{js}</code> Template Plugin","text":"<p>The <code>{js}</code> template plugin exists solely to provide a much easier and less error-prone method to include external JavaScript files.</p> <pre><code>{js application='app' file='App' hasTiny=true}\n</code></pre> <p>The <code>hasTiny</code> attribute is optional, you can set it to <code>false</code> or just omit it entirely if you do not provide a tiny build for your file.</p>"},{"location":"javascript/legacy-api/","title":"Legacy JavaScript API","text":""},{"location":"javascript/legacy-api/#introduction","title":"Introduction","text":"<p>The legacy JavaScript API is the original code that was part of the 2.x series of WoltLab Suite, formerly known as WoltLab Community Framework. It has been superseded for the most part by the ES5/AMD-modules API introduced with WoltLab Suite 3.0.</p> <p>Some parts still exist to this day for backwards-compatibility and because some less important components have not been rewritten yet. The old API is still supported, but marked as deprecated and will continue to be replaced parts by part in future releases, up until their entire removal, including jQuery support.</p> <p>This guide does not provide any explanation on the usage of those legacy components, but instead serves as a cheat sheet to convert code to use the new API.</p>"},{"location":"javascript/legacy-api/#classes","title":"Classes","text":""},{"location":"javascript/legacy-api/#singletons","title":"Singletons","text":"<p>Singleton instances are designed to provide a unique \"instance\" of an object regardless of when its first instance was created. Due to the lack of a <code>class</code> construct in ES5, they are represented by mere objects that act as an instance.</p> <pre><code>// App.js\nwindow.App = {};\nApp.Foo = {\n bar: function() {}\n};\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n return {\n bar: function() {}\n };\n});\n</code></pre>"},{"location":"javascript/legacy-api/#regular-classes","title":"Regular Classes","text":"<pre><code>// App.js\nwindow.App = {};\nApp.Foo = Class.extend({\n bar: function() {}\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {}\n };\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/legacy-api/#inheritance","title":"Inheritance","text":"<pre><code>// App.js\nwindow.App = {};\nApp.Foo = Class.extend({\n bar: function() {}\n});\nApp.Baz = App.Foo.extend({\n makeSnafucated: function() {}\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {}\n };\n\n return Foo;\n});\n\n// App/Baz.js\ndefine([\"Core\", \"./Foo\"], function(Core, Foo) {\n \"use strict\";\n\n function Baz() {};\n Core.inherit(Baz, Foo, {\n makeSnafucated: function() {}\n });\n\n return Baz;\n});\n</code></pre>"},{"location":"javascript/legacy-api/#ajax-requests","title":"Ajax Requests","text":"<pre><code>// App.js\nApp.Foo = Class.extend({\n _proxy: null,\n\n init: function() {\n this._proxy = new WCF.Action.Proxy({\n success: $.proxy(this._success, this)\n });\n },\n\n bar: function() {\n this._proxy.setOption(\"data\", {\n actionName: \"baz\",\n className: \"app\\\\foo\\\\FooAction\",\n objectIDs: [1, 2, 3],\n parameters: {\n foo: \"bar\",\n baz: true\n }\n });\n this._proxy.sendRequest();\n },\n\n _success: function(data) {\n // ajax request result\n }\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([\"Ajax\"], function(Ajax) {\n \"use strict\";\n\n function Foo() {}\n Foo.prototype = {\n bar: function() {\n Ajax.api(this, {\n objectIDs: [1, 2, 3],\n parameters: {\n foo: \"bar\",\n baz: true\n }\n });\n },\n\n // magic method!\n _ajaxSuccess: function(data) {\n // ajax request result\n },\n\n // magic method!\n _ajaxSetup: function() {\n return {\n actionName: \"baz\",\n className: \"app\\\\foo\\\\FooAction\"\n }\n }\n }\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/legacy-api/#phrases","title":"Phrases","text":"<pre><code><script data-relocate=\"true\">\n$(function() {\n WCF.Language.addObject({\n 'app.foo.bar': '{lang}app.foo.bar{/lang}'\n });\n\n console.log(WCF.Language.get(\"app.foo.bar\"));\n});\n</script>\n\n<!-- NEW API -->\n\n<script data-relocate=\"true\">\nrequire([\"Language\"], function(Language) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}'\n });\n\n console.log(Language.get(\"app.foo.bar\"));\n});\n</script>\n</code></pre>"},{"location":"javascript/legacy-api/#event-listener","title":"Event-Listener","text":"<pre><code><script data-relocate=\"true\">\n$(function() {\n WCF.System.Event.addListener(\"app.foo.bar\", \"makeSnafucated\", function(data) {\n console.log(\"Event was invoked.\");\n });\n\n WCF.System.Event.fireEvent(\"app.foo.bar\", \"makeSnafucated\", { some: \"data\" });\n});\n</script>\n\n<!-- NEW API -->\n\n<script data-relocate=\"true\">\nrequire([\"EventHandler\"], function(EventHandler) {\n EventHandler.add(\"app.foo.bar\", \"makeSnafucated\", function(data) {\n console.log(\"Event was invoked\");\n });\n\n EventHandler.fire(\"app.foo.bar\", \"makeSnafucated\", { some: \"data\" });\n});\n</script>\n</code></pre>"},{"location":"javascript/new-api_ajax/","title":"Ajax Requests - JavaScript API","text":""},{"location":"javascript/new-api_ajax/#promise-based-api-for-databaseobjectaction","title":"<code>Promise</code>-based API for <code>DatabaseObjectAction</code>","text":"<p>WoltLab Suite 5.5 introduces a new API for Ajax requests that uses <code>Promise</code>s to control the code flow. It does not rely on references to existing objects and does not use arbitrary callbacks to handle the setup and handling of the request.</p>"},{"location":"javascript/new-api_ajax/#usage","title":"Usage","text":"MyModule.ts<pre><code>import * as Ajax from \"./Ajax\";\n\ntype ResponseGetLatestFoo = {\n template: string;\n};\n\nexport class MyModule {\n private readonly bar: string;\n private readonly objectId: number;\n\n constructor(objectId: number, bar: string, buttonId: string) {\n this.bar = bar;\n this.objectId = objectId;\n\n const button = document.getElementById(buttonId);\n button?.addEventListener(\"click\", (event) => void this.click(event));\n }\n\n async click(event: MouseEvent): Promise<void> {\n event.preventDefault();\n\n const button = event.currentTarget as HTMLElement;\n if (button.classList.contains(\"disabled\")) {\n return;\n }\n button.classList.add(\"disabled\");\n\n try {\n const response = (await Ajax.dboAction(\"getLatestFoo\", \"wcf\\\\data\\\\foo\\\\FooAction\")\n .objectIds([this.objectId])\n .payload({ bar: this.bar })\n .dispatch()) as ResponseGetLatestFoo;\n\n document.getElementById(\"latestFoo\")!.innerHTML = response.template;\n } finally {\n button.classList.remove(\"disabled\");\n }\n }\n}\n\nexport default MyModule;\n</code></pre> <p>The actual code to dispatch and evaluate a request is only four lines long and offers full IDE auto completion support. This example uses a <code>finally</code> block to reset the button class once the request has finished, regardless of the result.</p> <p>If you do not handle the errors (or chose not to handle some errors), the global rejection handler will take care of this and show an dialog that informs about the failed request. This mimics the behavior of the <code>_ajaxFailure()</code> callback in the legacy API.</p>"},{"location":"javascript/new-api_ajax/#aborting-in-flight-requests","title":"Aborting in-flight requests","text":"<p>Sometimes new requests are dispatched against the same API before the response from the previous has arrived. This applies to either long running requests or requests that are dispatched in rapid succession, for example, looking up values when the user is actively typing into a search field.</p> RapidRequests.ts<pre><code>import * as Ajax from \"./Ajax\";\n\nexport class RapidRequests {\n private lastRequest: AbortController | undefined = undefined;\n\n constructor(inputId: string) {\n const input = document.getElementById(inputId) as HTMLInputElement;\n input.addEventListener(\"input\", (event) => void this.input(event));\n }\n\n async input(event: Event): Promise<void> {\n event.preventDefault();\n\n const input = event.currentTarget as HTMLInputElement;\n const value = input.value.trim();\n\n if (this.lastRequest) {\n this.lastRequest.abort();\n }\n\n if (value) {\n const request = Ajax.dboAction(\"getSuggestions\", \"wcf\\\\data\\\\bar\\\\BarAction\").payload({ value });\n this.lastRequest = request.getAbortController();\n\n const response = await request.dispatch();\n // Handle the response\n }\n }\n}\n\nexport default RapidRequests;\n</code></pre>"},{"location":"javascript/new-api_ajax/#ajax-inside-modules-legacy-api","title":"Ajax inside Modules (Legacy API)","text":"<p>The Ajax component was designed to be used from inside modules where an object reference is used to delegate request callbacks. This is acomplished through a set of magic methods that are automatically called when the request is created or its state has changed.</p>"},{"location":"javascript/new-api_ajax/#_ajaxsetup","title":"<code>_ajaxSetup()</code>","text":"<p>The lazy initialization is performed upon the first invocation from the callee, using the magic <code>_ajaxSetup()</code> method to retrieve the basic configuration for this and any future requests.</p> <p>The data returned by <code>_ajaxSetup()</code> is cached and the data will be used to pre-populate the request data before sending it. The callee can overwrite any of these properties. It is intended to reduce the overhead when issuing request when these requests share the same properties, such as accessing the same endpoint.</p> <pre><code>// App/Foo.js\ndefine([\"Ajax\"], function(Ajax) {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n one: function() {\n // this will issue an ajax request with the parameter `value` set to `1`\n Ajax.api(this);\n },\n\n two: function() {\n // this request is almost identical to the one issued with `.one()`, but\n // the value is now set to `2` for this invocation only.\n Ajax.api(this, {\n parameters: {\n value: 2\n }\n });\n },\n\n _ajaxSetup: function() {\n return {\n data: {\n actionName: \"makeSnafucated\",\n className: \"app\\\\data\\\\foo\\\\FooAction\",\n parameters: {\n value: 1\n }\n }\n }\n }\n };\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/new-api_ajax/#request-settings","title":"Request Settings","text":"<p>The object returned by the aforementioned <code>_ajaxSetup()</code> callback can contain these values:</p>"},{"location":"javascript/new-api_ajax/#data","title":"<code>data</code>","text":"<p>Defaults to <code>{}</code>.</p> <p>A plain JavaScript object that contains the request data that represents the form data of the request. The <code>parameters</code> key is recognized by the PHP Ajax API and becomes accessible through <code>$this->parameters</code>.</p>"},{"location":"javascript/new-api_ajax/#contenttype","title":"<code>contentType</code>","text":"<p>Defaults to <code>application/x-www-form-urlencoded; charset=UTF-8</code>.</p> <p>The request content type, sets the <code>Content-Type</code> HTTP header if it is not empty.</p>"},{"location":"javascript/new-api_ajax/#responsetype","title":"<code>responseType</code>","text":"<p>Defaults to <code>application/json</code>.</p> <p>The server must respond with the <code>Content-Type</code> HTTP header set to this value, otherwise the request will be treated as failed. Requests for <code>application/json</code> will have the return body attempted to be evaluated as JSON.</p> <p>Other content types will only be validated based on the HTTP header, but no additional transformation is performed. For example, setting the <code>responseType</code> to <code>application/xml</code> will check the HTTP header, but will not transform the <code>data</code> parameter, you'll still receive a string in <code>_ajaxSuccess</code>!</p>"},{"location":"javascript/new-api_ajax/#type","title":"<code>type</code>","text":"<p>Defaults to <code>POST</code>.</p> <p>The HTTP Verb used for this request.</p>"},{"location":"javascript/new-api_ajax/#url","title":"<code>url</code>","text":"<p>Defaults to an empty string.</p> <p>Manual override for the request endpoint, it will be automatically set to the Core API endpoint if left empty. If the Core API endpoint is used, the options <code>includeRequestedWith</code> and <code>withCredentials</code> will be force-set to true.</p>"},{"location":"javascript/new-api_ajax/#withcredentials","title":"<code>withCredentials</code>","text":"<p>Enabling this parameter for any domain other than the current will trigger a CORS preflight request.</p> <p>Defaults to <code>false</code>.</p> <p>Include cookies with this requested, is always true when <code>url</code> is (implicitly) set to the Core API endpoint.</p>"},{"location":"javascript/new-api_ajax/#autoabort","title":"<code>autoAbort</code>","text":"<p>Defaults to <code>false</code>.</p> <p>When set to <code>true</code>, any pending responses to earlier requests will be silently discarded when issuing a new request. This only makes sense if the new request is meant to completely replace the result of the previous one, regardless of its reponse body.</p> <p>Typical use-cases include input field with suggestions, where possible values are requested from the server, but the input changed faster than the server was able to reply. In this particular case the client is not interested in the result for an earlier value, auto-aborting these requests avoids implementing this logic in the requesting code.</p>"},{"location":"javascript/new-api_ajax/#ignoreerror","title":"<code>ignoreError</code>","text":"<p>Defaults to <code>false</code>.</p> <p>Any failing request will invoke the <code>failure</code>-callback to check if an error message should be displayed. Enabling this option will suppress the general error overlay that reports a failed request.</p> <p>You can achieve the same result by returning <code>false</code> in the <code>failure</code>-callback.</p>"},{"location":"javascript/new-api_ajax/#silent","title":"<code>silent</code>","text":"<p>Defaults to <code>false</code>.</p> <p>Enabling this option will suppress the loading indicator overlay for this request, other non-\"silent\" requests will still trigger the loading indicator.</p>"},{"location":"javascript/new-api_ajax/#includerequestedwith","title":"<code>includeRequestedWith</code>","text":"<p>Enabling this parameter for any domain other than the current will trigger a CORS preflight request.</p> <p>Defaults to <code>true</code>.</p> <p>Sets the custom HTTP header <code>X-Requested-With: XMLHttpRequest</code> for the request, it is automatically set to <code>true</code> when <code>url</code> is pointing at the WSC API endpoint.</p>"},{"location":"javascript/new-api_ajax/#failure","title":"<code>failure</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Optional callback function that will be invoked for requests that have failed for one of these reasons: 1. The request timed out. 2. The HTTP status is not <code>2xx</code> or <code>304</code>. 3. A <code>responseType</code> was set, but the response HTTP header <code>Content-Type</code> did not match the expected value. 4. The <code>responseType</code> was set to <code>application/json</code>, but the response body was not valid JSON.</p> <p>The callback function receives the parameter <code>xhr</code> (the <code>XMLHttpRequest</code> object) and <code>options</code> (deep clone of the request parameters). If the callback returns <code>false</code>, the general error overlay for failed requests will be suppressed.</p> <p>There will be no error overlay if <code>ignoreError</code> is set to <code>true</code> or if the request failed while attempting to evaluate the response body as JSON.</p>"},{"location":"javascript/new-api_ajax/#finalize","title":"<code>finalize</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Optional callback function that will be invoked once the request has completed, regardless if it succeeded or failed. The only parameter it receives is <code>options</code> (the request parameters object), but it does not receive the request's <code>XMLHttpRequest</code>.</p>"},{"location":"javascript/new-api_ajax/#success","title":"<code>success</code>","text":"<p>Defaults to <code>null</code>.</p> <p>This semi-optional callback function will always be set to <code>_ajaxSuccess()</code> when invoking <code>Ajax.api()</code>. It receives four parameters: 1. <code>data</code> - The request's response body as a string, or a JavaScript object if <code>contentType</code> was set to <code>application/json</code>. 2. <code>responseText</code> - The unmodified response body, it equals the value for <code>data</code> for non-JSON requests. 3. <code>xhr</code> - The underlying <code>XMLHttpRequest</code> object. 4. <code>requestData</code> - The request parameters that were supplied when the request was issued.</p>"},{"location":"javascript/new-api_ajax/#_ajaxsuccess","title":"<code>_ajaxSuccess()</code>","text":"<p>This callback method is automatically called for successful AJAX requests, it receives four parameters, with the first one containing either the response body as a string, or a JavaScript object for JSON requests.</p>"},{"location":"javascript/new-api_ajax/#_ajaxfailure","title":"<code>_ajaxFailure()</code>","text":"<p>Optional callback function that is invoked for failed requests, it will be automatically called if the callee implements it, otherwise the global error handler will be executed.</p>"},{"location":"javascript/new-api_ajax/#single-requests-without-a-module-legacy-api","title":"Single Requests Without a Module (Legacy API)","text":"<p>The <code>Ajax.api()</code> method expects an object that is used to extract the request configuration as well as providing the callback functions when the request state changes.</p> <p>You can issue a simple Ajax request without object binding through <code>Ajax.apiOnce()</code> that will destroy the instance after the request was finalized. This method is significantly more expensive for repeated requests and does not offer deriving modules from altering the behavior. It is strongly recommended to always use <code>Ajax.api()</code> for requests to the WSC API endpoint.</p> <pre><code><script data-relocate=\"true\">\n require([\"Ajax\"], function(Ajax) {\n Ajax.apiOnce({\n data: {\n actionName: \"makeSnafucated\",\n className: \"app\\\\data\\\\foo\\\\FooAction\",\n parameters: {\n value: 3\n }\n },\n success: function(data) {\n elBySel(\".some-element\").textContent = data.bar;\n }\n })\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_browser/","title":"Browser and Screen Sizes - JavaScript API","text":""},{"location":"javascript/new-api_browser/#uiscreen","title":"<code>Ui/Screen</code>","text":"<p>CSS offers powerful media queries that alter the layout depending on the screen sizes, including but not limited to changes between landscape and portrait mode on mobile devices.</p> <p>The <code>Ui/Screen</code> module exposes a consistent interface to execute JavaScript code based on the same media queries that are available in the CSS code already. It features support for unmatching and executing code when a rule matches for the first time during the page lifecycle.</p>"},{"location":"javascript/new-api_browser/#supported-aliases","title":"Supported Aliases","text":"<p>You can pass in custom media queries, but it is strongly recommended to use the built-in media queries that match the same dimensions as your CSS.</p> Alias Media Query <code>screen-xs</code> <code>(max-width: 544px)</code> <code>screen-sm</code> <code>(min-width: 545px) and (max-width: 768px)</code> <code>screen-sm-down</code> <code>(max-width: 768px)</code> <code>screen-sm-up</code> <code>(min-width: 545px)</code> <code>screen-sm-md</code> <code>(min-width: 545px) and (max-width: 1024px)</code> <code>screen-md</code> <code>(min-width: 769px) and (max-width: 1024px)</code> <code>screen-md-down</code> <code>(max-width: 1024px)</code> <code>screen-md-up</code> <code>(min-width: 769px)</code> <code>screen-lg</code> <code>(min-width: 1025px)</code>"},{"location":"javascript/new-api_browser/#onquery-string-callbacks-object-string","title":"<code>on(query: string, callbacks: Object): string</code>","text":"<p>Registers a set of callback functions for the provided media query, the possible keys are <code>match</code>, <code>unmatch</code> and <code>setup</code>. The method returns a randomly generated UUIDv4 that is used to identify these callbacks and allows them to be removed via <code>.remove()</code>.</p>"},{"location":"javascript/new-api_browser/#removequery-string-uuid-string","title":"<code>remove(query: string, uuid: string)</code>","text":"<p>Removes all callbacks for a media query that match the UUIDv4 that was previously obtained from the call to <code>.on()</code>.</p>"},{"location":"javascript/new-api_browser/#isquery-string-boolean","title":"<code>is(query: string): boolean</code>","text":"<p>Tests if the provided media query currently matches and returns true on match.</p>"},{"location":"javascript/new-api_browser/#scrolldisable","title":"<code>scrollDisable()</code>","text":"<p>Temporarily prevents the page from being scrolled, until <code>.scrollEnable()</code> is called.</p>"},{"location":"javascript/new-api_browser/#scrollenable","title":"<code>scrollEnable()</code>","text":"<p>Enables page scrolling again, unless another pending action has also prevented the page scrolling.</p>"},{"location":"javascript/new-api_browser/#environment","title":"<code>Environment</code>","text":"<p>The <code>Environment</code> module uses a mixture of feature detection and user agent sniffing to determine the browser and platform. In general, its results have proven to be very accurate, but it should be taken with a grain of salt regardless. Especially the browser checks are designed to be your last resort, please use feature detection instead whenever it is possible!</p> <p>Sometimes it may be necessary to alter the behavior of your code depending on the browser platform (e. g. mobile devices) or based on a specific browser in order to work-around some quirks.</p>"},{"location":"javascript/new-api_browser/#browser-string","title":"<code>browser(): string</code>","text":"<p>Attempts to detect browsers based on their technology and supported CSS vendor prefixes, and although somewhat reliable for major browsers, it is highly recommended to use feature detection instead.</p> <p>Possible values: - <code>chrome</code> (includes Opera 15+ and Vivaldi) - <code>firefox</code> - <code>safari</code> - <code>microsoft</code> (Internet Explorer and Edge) - <code>other</code> (default)</p>"},{"location":"javascript/new-api_browser/#platform-string","title":"<code>platform(): string</code>","text":"<p>Attempts to detect the browser platform using user agent sniffing.</p> <p>Possible values: - <code>ios</code> - <code>android</code> - <code>windows</code> (IE Mobile) - <code>mobile</code> (generic mobile device) - <code>desktop</code> (default)</p>"},{"location":"javascript/new-api_core/","title":"Core Modules and Functions - JavaScript API","text":"<p>A brief overview of common methods that may be useful when writing any module.</p>"},{"location":"javascript/new-api_core/#core","title":"<code>Core</code>","text":""},{"location":"javascript/new-api_core/#cloneobject-object-object","title":"<code>clone(object: Object): Object</code>","text":"<p>Creates a deep-clone of the provided object by value, removing any references on the original element, including arrays. However, this does not clone references to non-plain objects, these instances will be copied by reference.</p> <pre><code>require([\"Core\"], function(Core) {\n var obj1 = { a: 1 };\n var obj2 = Core.clone(obj1);\n\n console.log(obj1 === obj2); // output: false\n console.log(obj2.hasOwnProperty(\"a\") && obj2.a === 1); // output: true\n});\n</code></pre>"},{"location":"javascript/new-api_core/#extendbase-object-merge-object-object","title":"<code>extend(base: Object, ...merge: Object[]): Object</code>","text":"<p>Accepts an infinite amount of plain objects as parameters, values will be copied from the 2nd...nth object into the first object. The first parameter will be cloned and the resulting object is returned.</p> <pre><code>require([\"Core\"], function(Core) {\n var obj1 = { a: 2 };\n var obj2 = { a: 1, b: 2 };\n var obj = Core.extend({\n b: 1\n }, obj1, obj2);\n\n console.log(obj.b === 2); // output: true\n console.log(obj.hasOwnProperty(\"a\") && obj.a === 2); // output: false\n});\n</code></pre>"},{"location":"javascript/new-api_core/#inheritbase-object-target-object-merge-object","title":"<code>inherit(base: Object, target: Object, merge?: Object)</code>","text":"<p>Derives the second object's prototype from the first object, afterwards the derived class will pass the <code>instanceof</code> check against the original class.</p> <pre><code>// App.js\nwindow.App = {};\nApp.Foo = Class.extend({\n bar: function() {}\n});\nApp.Baz = App.Foo.extend({\n makeSnafucated: function() {}\n});\n\n// --- NEW API ---\n\n// App/Foo.js\ndefine([], function() {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {}\n };\n\n return Foo;\n});\n\n// App/Baz.js\ndefine([\"Core\", \"./Foo\"], function(Core, Foo) {\n \"use strict\";\n\n function Baz() {};\n Core.inherit(Baz, Foo, {\n makeSnafucated: function() {}\n });\n\n return Baz;\n});\n</code></pre>"},{"location":"javascript/new-api_core/#isplainobjectobject-object-boolean","title":"<code>isPlainObject(object: Object): boolean</code>","text":"<p>Verifies if an object is a plain JavaScript object and not an object instance.</p> <pre><code>require([\"Core\"], function(Core) {\n function Foo() {}\n Foo.prototype = {\n hello: \"world\";\n };\n\n var obj1 = { hello: \"world\" };\n var obj2 = new Foo();\n\n console.log(Core.isPlainObject(obj1)); // output: true\n console.log(obj1.hello === obj2.hello); // output: true\n console.log(Core.isPlainObject(obj2)); // output: false\n});\n</code></pre>"},{"location":"javascript/new-api_core/#triggereventelement-element-eventname-string","title":"<code>triggerEvent(element: Element, eventName: string)</code>","text":"<p>Creates and dispatches a synthetic JavaScript event on an element.</p> <pre><code>require([\"Core\"], function(Core) {\n var element = elBySel(\".some-element\");\n Core.triggerEvent(element, \"click\");\n});\n</code></pre>"},{"location":"javascript/new-api_core/#language","title":"<code>Language</code>","text":""},{"location":"javascript/new-api_core/#addkey-string-value-string","title":"<code>add(key: string, value: string)</code>","text":"<p>Registers a new phrase.</p> <pre><code><script data-relocate=\"true\">\n require([\"Language\"], function(Language) {\n Language.add('app.foo.bar', '{jslang}app.foo.bar{/jslang}');\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_core/#addobjectobject-object","title":"<code>addObject(object: Object)</code>","text":"<p>Registers a list of phrases using a plain object.</p> <pre><code><script data-relocate=\"true\">\n require([\"Language\"], function(Language) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}'\n });\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_core/#getkey-string-parameters-object-string","title":"<code>get(key: string, parameters?: Object): string</code>","text":"<p>Retrieves a phrase by its key, optionally supporting basic template scripting with dynamic variables passed using the <code>parameters</code> object.</p> <pre><code>require([\"Language\"], function(Language) {\n var title = Language.get(\"app.foo.title\");\n var content = Language.get(\"app.foo.content\", {\n some: \"value\"\n });\n});\n</code></pre>"},{"location":"javascript/new-api_core/#stringutil","title":"<code>StringUtil</code>","text":""},{"location":"javascript/new-api_core/#escapehtmlstr-string-string","title":"<code>escapeHTML(str: string): string</code>","text":"<p>Escapes special HTML characters by converting them into an HTML entity.</p> Character Replacement <code>&</code> <code>&amp;</code> <code>\"</code> <code>&quot;</code> <code><</code> <code>&lt;</code> <code>></code> <code>&gt;</code>"},{"location":"javascript/new-api_core/#escaperegexpstr-string-string","title":"<code>escapeRegExp(str: string): string</code>","text":"<p>Escapes a list of characters that have a special meaning in regular expressions and could alter the behavior when embedded into regular expressions.</p>"},{"location":"javascript/new-api_core/#lcfirststr-string-string","title":"<code>lcfirst(str: string): string</code>","text":"<p>Makes a string's first character lowercase.</p>"},{"location":"javascript/new-api_core/#ucfirststr-string-string","title":"<code>ucfirst(str: string): string</code>","text":"<p>Makes a string's first character uppercase.</p>"},{"location":"javascript/new-api_core/#unescapehtmlstr-string-string","title":"<code>unescapeHTML(str: string): string</code>","text":"<p>Converts some HTML entities into their original character. This is the reverse function of <code>escapeHTML()</code>.</p>"},{"location":"javascript/new-api_dialogs/","title":"Dialogs - JavaScript API","text":"<p>This API has been deprecated in WoltLab Suite 6.0, please refer to the new dialog implementation.</p>"},{"location":"javascript/new-api_dialogs/#introduction","title":"Introduction","text":"<p>Dialogs are full screen overlays that cover the currently visible window area using a semi-opague backdrop and a prominently placed dialog window in the foreground. They shift the attention away from the original content towards the dialog and usually contain additional details and/or dedicated form inputs.</p>"},{"location":"javascript/new-api_dialogs/#_dialogsetup","title":"<code>_dialogSetup()</code>","text":"<p>The lazy initialization is performed upon the first invocation from the callee, using the magic <code>_dialogSetup()</code> method to retrieve the basic configuration for the dialog construction and any event callbacks.</p> <pre><code>// App/Foo.js\ndefine([\"Ui/Dialog\"], function(UiDialog) {\n \"use strict\";\n\n function Foo() {};\n Foo.prototype = {\n bar: function() {\n // this will open the dialog constructed by _dialogSetup\n UiDialog.open(this);\n },\n\n _dialogSetup: function() {\n return {\n id: \"myDialog\",\n source: \"<p>Hello World!</p>\",\n options: {\n onClose: function() {\n // the fancy dialog was closed!\n }\n }\n }\n }\n };\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/new-api_dialogs/#id-string","title":"<code>id: string</code>","text":"<p>The <code>id</code> is used to identify a dialog on runtime, but is also part of the first- time setup when the dialog has not been opened before. If <code>source</code> is <code>undefined</code>, the module attempts to construct the dialog using an element with the same id.</p>"},{"location":"javascript/new-api_dialogs/#source-any","title":"<code>source: any</code>","text":"<p>There are six different types of value that <code>source</code> does allow and each of them changes how the initial dialog is constructed:</p> <ol> <li><code>undefined</code> The dialog exists already and the value of <code>id</code> should be used to identify the element.</li> <li><code>null</code> The HTML is provided using the second argument of <code>.open()</code>.</li> <li><code>() => void</code> If the <code>source</code> is a function, it is executed and is expected to start the dialog initialization itself.</li> <li><code>Object</code> Plain objects are interpreted as parameters for an Ajax request, in particular <code>source.data</code> will be used to issue the request. It is possible to specify the key <code>source.after</code> as a callback <code>(content: Element, responseData: Object) => void</code> that is executed after the dialog was opened.</li> <li><code>string</code> The string is expected to be plain HTML that should be used to construct the dialog.</li> <li><code>DocumentFragment</code> A new container <code><div></code> with the provided <code>id</code> is created and the contents of the <code>DocumentFragment</code> is appended to it. This container is then used for the dialog.</li> </ol>"},{"location":"javascript/new-api_dialogs/#options-object","title":"<code>options: Object</code>","text":"<p>All configuration options and callbacks are handled through this object.</p>"},{"location":"javascript/new-api_dialogs/#optionsbackdropcloseonclick-boolean","title":"<code>options.backdropCloseOnClick: boolean</code>","text":"<p>Defaults to <code>true</code>.</p> <p>Clicks on the dialog backdrop will close the top-most dialog. This option will be force-disabled if the option <code>closeable</code> is set to <code>false</code>.</p>"},{"location":"javascript/new-api_dialogs/#optionsclosable-boolean","title":"<code>options.closable: boolean</code>","text":"<p>Defaults to <code>true</code>.</p> <p>Enables the close button in the dialog title, when disabled the dialog can be closed through the <code>.close()</code> API call only.</p>"},{"location":"javascript/new-api_dialogs/#optionsclosebuttonlabel-string","title":"<code>options.closeButtonLabel: string</code>","text":"<p>Defaults to <code>Language.get(\"wcf.global.button.close\")</code>.</p> <p>The phrase that is displayed in the tooltip for the close button.</p>"},{"location":"javascript/new-api_dialogs/#optionscloseconfirmmessage-string","title":"<code>options.closeConfirmMessage: string</code>","text":"<p>Defaults to <code>\"\"</code>.</p> <p>Shows a confirmation dialog using the configured message before closing the dialog. The dialog will not be closed if the dialog is rejected by the user.</p>"},{"location":"javascript/new-api_dialogs/#optionstitle-string","title":"<code>options.title: string</code>","text":"<p>Defaults to <code>\"\"</code>.</p> <p>The phrase that is displayed in the dialog title.</p>"},{"location":"javascript/new-api_dialogs/#optionsonbeforeclose-id-string-void","title":"<code>options.onBeforeClose: (id: string) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>The callback is executed when the user clicks on the close button or, if enabled, on the backdrop. The callback is responsible to close the dialog by itself, the default close behavior is automatically prevented.</p>"},{"location":"javascript/new-api_dialogs/#optionsonclose-id-string-void","title":"<code>options.onClose: (id: string) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>The callback is notified once the dialog is about to be closed, but is still visible at this point. It is not possible to abort the close operation at this point.</p>"},{"location":"javascript/new-api_dialogs/#optionsonshow-content-element-void","title":"<code>options.onShow: (content: Element) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Receives the dialog content element as its only argument, allowing the callback to modify the DOM or to register event listeners before the dialog is presented to the user. The dialog is already visible at call time, but the dialog has not been finalized yet.</p>"},{"location":"javascript/new-api_dialogs/#settitleid-string-object-title-string","title":"<code>setTitle(id: string | Object, title: string)</code>","text":"<p>Sets the title of a dialog.</p>"},{"location":"javascript/new-api_dialogs/#setcallbackid-string-object-key-string-value-data-any-void-null","title":"<code>setCallback(id: string | Object, key: string, value: (data: any) => void | null)</code>","text":"<p>Sets a callback function after the dialog initialization, the special value <code>null</code> will remove a previously set callback. Valid values for <code>key</code> are <code>onBeforeClose</code>, <code>onClose</code> and <code>onShow</code>.</p>"},{"location":"javascript/new-api_dialogs/#rebuildid-string-object","title":"<code>rebuild(id: string | Object)</code>","text":"<p>Rebuilds a dialog by performing various calculations on the maximum dialog height in regards to the overflow handling and adjustments for embedded forms. This method is automatically invoked whenever a dialog is shown, after invoking the <code>options.onShow</code> callback.</p>"},{"location":"javascript/new-api_dialogs/#closeid-string-object","title":"<code>close(id: string | Object)</code>","text":"<p>Closes an open dialog, this will neither trigger a confirmation dialog, nor does it invoke the <code>options.onBeforeClose</code> callback. The <code>options.onClose</code> callback will always be invoked, but it cannot abort the close operation.</p>"},{"location":"javascript/new-api_dialogs/#getdialogid-string-object-object","title":"<code>getDialog(id: string | Object): Object</code>","text":"<p>This method returns an internal data object by reference, any modifications made do have an effect on the dialogs behavior and in particular no validation is performed on the modification. It is strongly recommended to use the <code>.set*()</code> methods only.</p> <p>Returns the internal dialog data that is attached to a dialog. The most important key is <code>.content</code> which holds a reference to the dialog's inner content element.</p>"},{"location":"javascript/new-api_dialogs/#isopenid-string-object-boolean","title":"<code>isOpen(id: string | Object): boolean</code>","text":"<p>Returns true if the dialog exists and is open.</p>"},{"location":"javascript/new-api_dom/","title":"Working with the DOM - JavaScript API","text":""},{"location":"javascript/new-api_dom/#domutil","title":"<code>Dom/Util</code>","text":""},{"location":"javascript/new-api_dom/#createfragmentfromhtmlhtml-string-documentfragment","title":"<code>createFragmentFromHtml(html: string): DocumentFragment</code>","text":"<p>Parses a HTML string and creates a <code>DocumentFragment</code> object that holds the resulting nodes.</p>"},{"location":"javascript/new-api_dom/#identifyelement-element-string","title":"<code>identify(element: Element): string</code>","text":"<p>Retrieves the unique identifier (<code>id</code>) of an element. If it does not currently have an id assigned, a generic identifier is used instead.</p>"},{"location":"javascript/new-api_dom/#outerheightelement-element-styles-cssstyledeclaration-number","title":"<code>outerHeight(element: Element, styles?: CSSStyleDeclaration): number</code>","text":"<p>Computes the outer height of an element using the element's <code>offsetHeight</code> and the sum of the rounded down values for <code>margin-top</code> and <code>margin-bottom</code>.</p>"},{"location":"javascript/new-api_dom/#outerwidthelement-element-styles-cssstyledeclaration-number","title":"<code>outerWidth(element: Element, styles?: CSSStyleDeclaration): number</code>","text":"<p>Computes the outer width of an element using the element's <code>offsetWidth</code> and the sum of the rounded down values for <code>margin-left</code> and <code>margin-right</code>.</p>"},{"location":"javascript/new-api_dom/#outerdimensionselement-element-height-number-width-number","title":"<code>outerDimensions(element: Element): { height: number, width: number }</code>","text":"<p>Computes the outer dimensions of an element including its margins.</p>"},{"location":"javascript/new-api_dom/#offsetelement-element-top-number-left-number","title":"<code>offset(element: Element): { top: number, left: number }</code>","text":"<p>Computes the element's offset relative to the top left corner of the document.</p>"},{"location":"javascript/new-api_dom/#setinnerhtmlelement-element-innerhtml-string","title":"<code>setInnerHtml(element: Element, innerHtml: string)</code>","text":"<p>Sets the inner HTML of an element via <code>element.innerHTML = innerHtml</code>. Browsers do not evaluate any embedded <code><script></code> tags, therefore this method extracts each of them, creates new <code><script></code> tags and inserts them in their original order of appearance.</p>"},{"location":"javascript/new-api_dom/#containselement-element-child-element-boolean","title":"<code>contains(element: Element, child: Element): boolean</code>","text":"<p>Evaluates if <code>element</code> is a direct or indirect parent element of <code>child</code>.</p>"},{"location":"javascript/new-api_dom/#unwrapchildnodeselement-element","title":"<code>unwrapChildNodes(element: Element)</code>","text":"<p>Moves all child nodes out of <code>element</code> while maintaining their order, then removes <code>element</code> from the document.</p>"},{"location":"javascript/new-api_dom/#domchangelistener","title":"<code>Dom/ChangeListener</code>","text":"<p>This class is used to observe specific changes to the DOM, for example after an Ajax request has completed. For performance reasons this is a manually-invoked listener that does not rely on a <code>MutationObserver</code>.</p> <pre><code>require([\"Dom/ChangeListener\"], function(DomChangeListener) {\n DomChangeListener.add(\"App/Foo\", function() {\n // the DOM may have been altered significantly\n });\n\n // propagate changes to the DOM\n DomChangeListener.trigger();\n});\n</code></pre>"},{"location":"javascript/new-api_events/","title":"Event Handling - JavaScript API","text":""},{"location":"javascript/new-api_events/#eventkey","title":"<code>EventKey</code>","text":"<p>This class offers a set of static methods that can be used to determine if some common keys are being pressed. Internally it compares either the <code>.key</code> property if it is supported or the value of <code>.which</code>.</p> <pre><code>require([\"EventKey\"], function(EventKey) {\n elBySel(\".some-input\").addEventListener(\"keydown\", function(event) {\n if (EventKey.Enter(event)) {\n // the `Enter` key was pressed\n }\n });\n});\n</code></pre>"},{"location":"javascript/new-api_events/#arrowdownevent-keyboardevent-boolean","title":"<code>ArrowDown(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2193</code> key.</p>"},{"location":"javascript/new-api_events/#arrowleftevent-keyboardevent-boolean","title":"<code>ArrowLeft(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2190</code> key.</p>"},{"location":"javascript/new-api_events/#arrowrightevent-keyboardevent-boolean","title":"<code>ArrowRight(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2192</code> key.</p>"},{"location":"javascript/new-api_events/#arrowupevent-keyboardevent-boolean","title":"<code>ArrowUp(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u2191</code> key.</p>"},{"location":"javascript/new-api_events/#commaevent-keyboardevent-boolean","title":"<code>Comma(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>,</code> key.</p>"},{"location":"javascript/new-api_events/#enterevent-keyboardevent-boolean","title":"<code>Enter(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u21b2</code> key.</p>"},{"location":"javascript/new-api_events/#escapeevent-keyboardevent-boolean","title":"<code>Escape(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>Esc</code> key.</p>"},{"location":"javascript/new-api_events/#tabevent-keyboardevent-boolean","title":"<code>Tab(event: KeyboardEvent): boolean</code>","text":"<p>Returns true if the user has pressed the <code>\u21b9</code> key.</p>"},{"location":"javascript/new-api_events/#eventhandler","title":"<code>EventHandler</code>","text":"<p>A synchronous event system based on string identifiers rather than DOM elements, similar to the PHP event system in WoltLab Suite. Any components can listen to events or trigger events itself at any time.</p>"},{"location":"javascript/new-api_events/#identifiying-events-with-the-developer-tools","title":"Identifiying Events with the Developer Tools","text":"<p>The Developer Tools offer an easy option to identify existing events that are fired while code is being executed. You can enable this watch mode through your browser's console using <code>Devtools.toggleEventLogging()</code>:</p> <pre><code>> Devtools.toggleEventLogging();\n< Event logging enabled\n< [Devtools.EventLogging] Firing event: bar @ com.example.app.foo\n< [Devtools.EventLogging] Firing event: baz @ com.example.app.foo\n</code></pre>"},{"location":"javascript/new-api_events/#addidentifier-string-action-string-callback-data-object-void-string","title":"<code>add(identifier: string, action: string, callback: (data: Object) => void): string</code>","text":"<p>Adding an event listeners returns a randomly generated UUIDv4 that is used to identify the listener. This UUID is required to remove a specific listener through the <code>remove()</code> method.</p>"},{"location":"javascript/new-api_events/#fireidentifier-string-action-string-data-object","title":"<code>fire(identifier: string, action: string, data?: Object)</code>","text":"<p>Triggers an event using an optional <code>data</code> object that is passed to each listener by reference.</p>"},{"location":"javascript/new-api_events/#removeidentifier-string-action-string-uuid-string","title":"<code>remove(identifier: string, action: string, uuid: string)</code>","text":"<p>Removes a previously registered event listener using the UUID returned by <code>add()</code>.</p>"},{"location":"javascript/new-api_events/#removeallidentifier-string-action-string","title":"<code>removeAll(identifier: string, action: string)</code>","text":"<p>Removes all event listeners registered for the provided <code>identifier</code> and <code>action</code>.</p>"},{"location":"javascript/new-api_events/#removeallbysuffixidentifier-string-suffix-string","title":"<code>removeAllBySuffix(identifier: string, suffix: string)</code>","text":"<p>Removes all event listeners for an <code>identifier</code> whose action ends with the value of <code>suffix</code>.</p>"},{"location":"javascript/new-api_ui/","title":"User Interface - JavaScript API","text":""},{"location":"javascript/new-api_ui/#uialignment","title":"<code>Ui/Alignment</code>","text":"<p>Calculates the alignment of one element relative to another element, with support for boundary constraints, alignment restrictions and additional pointer elements.</p>"},{"location":"javascript/new-api_ui/#setelement-element-referenceelement-element-options-object","title":"<code>set(element: Element, referenceElement: Element, options: Object)</code>","text":"<p>Calculates and sets the alignment of the element <code>element</code>.</p>"},{"location":"javascript/new-api_ui/#verticaloffset-number","title":"<code>verticalOffset: number</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Creates a gap between the element and the reference element, in pixels.</p>"},{"location":"javascript/new-api_ui/#pointer-boolean","title":"<code>pointer: boolean</code>","text":"<p>Defaults to <code>false</code>.</p> <p>Sets the position of the pointer element, requires an existing child of the element with the CSS class <code>.elementPointer</code>.</p>"},{"location":"javascript/new-api_ui/#pointeroffset-number","title":"<code>pointerOffset: number</code>","text":"<p>Defaults to <code>4</code>.</p> <p>The margin from the left/right edge of the element and is used to avoid the arrow from being placed right at the edge.</p> <p>Does not apply when aligning the element to the reference elemnent's center.</p>"},{"location":"javascript/new-api_ui/#pointerclassnames-string","title":"<code>pointerClassNames: string[]</code>","text":"<p>Defaults to <code>[]</code>.</p> <p>If your element uses CSS-only pointers, such as using the <code>::before</code> or <code>::after</code> pseudo selectors, you can specifiy two separate CSS class names that control the alignment:</p> <ul> <li><code>pointerClassNames[0]</code> is applied to the element when the pointer is displayed at the bottom.</li> <li><code>pointerClassNames[1]</code> is used to align the pointer to the right side of the element.</li> </ul>"},{"location":"javascript/new-api_ui/#refdimensionselement-element","title":"<code>refDimensionsElement: Element</code>","text":"<p>Defaults to <code>null</code>.</p> <p>An alternative element that will be used to determine the position and dimensions of the reference element. This can be useful if you reference element is contained in a wrapper element with alternating dimensions.</p>"},{"location":"javascript/new-api_ui/#horizontal-string","title":"<code>horizontal: string</code>","text":"<p>This value is automatically flipped for RTL (right-to-left) languages, <code>left</code> is changed into <code>right</code> and vice versa.</p> <p>Defaults to <code>\"left\"</code>.</p> <p>Sets the prefered alignment, accepts either <code>left</code> or <code>right</code>. The value <code>left</code> instructs the module to align the element with the left boundary of the reference element.</p> <p>The <code>horizontal</code> alignment is used as the default and a flip only occurs, if there is not enough space in the desired direction. If the element exceeds the boundaries in both directions, the value of <code>horizontal</code> is used.</p>"},{"location":"javascript/new-api_ui/#vertical-string","title":"<code>vertical: string</code>","text":"<p>Defaults to <code>\"bottom\"</code>.</p> <p>Sets the prefered alignment, accepts either <code>bottom</code> or <code>top</code>. The value <code>bottom</code> instructs the module to align the element below the reference element.</p> <p>The <code>vertical</code> alignment is used as the default and a flip only occurs, if there is not enough space in the desired direction. If the element exceeds the boundaries in both directions, the value of <code>vertical</code> is used.</p>"},{"location":"javascript/new-api_ui/#allowflip-string","title":"<code>allowFlip: string</code>","text":"<p>The value for <code>horizontal</code> is automatically flipped for RTL (right-to-left) languages, <code>left</code> is changed into <code>right</code> and vice versa. This setting only controls the behavior when violating space constraints, therefore the aforementioned transformation is always applied.</p> <p>Defaults to <code>\"both\"</code>.</p> <p>Restricts the automatic alignment flipping if the element exceeds the window boundaries in the instructed direction.</p> <ul> <li><code>both</code> - No restrictions.</li> <li><code>horizontal</code> - Element can be aligned with the left or the right boundary of the reference element, but the vertical position is fixed.</li> <li><code>vertical</code> - Element can be aligned below or above the reference element, but the vertical position is fixed.</li> <li><code>none</code> - No flipping can occur, the element will be aligned regardless of any space constraints.</li> </ul>"},{"location":"javascript/new-api_ui/#uicloseoverlay","title":"<code>Ui/CloseOverlay</code>","text":"<p>Register elements that should be closed when the user clicks anywhere else, such as drop-down menus or tooltips.</p> <pre><code>require([\"Ui/CloseOverlay\"], function(UiCloseOverlay) {\n UiCloseOverlay.add(\"App/Foo\", function() {\n // invoked, close something\n });\n});\n</code></pre>"},{"location":"javascript/new-api_ui/#addidentifier-string-callback-void","title":"<code>add(identifier: string, callback: () => void)</code>","text":"<p>Adds a callback that will be invoked when the user clicks anywhere else.</p>"},{"location":"javascript/new-api_ui/#uiconfirmation","title":"<code>Ui/Confirmation</code>","text":"<p>Prompt the user to make a decision before carrying out an action, such as a safety warning before permanently deleting content.</p> <pre><code>require([\"Ui/Confirmation\"], function(UiConfirmation) {\n UiConfirmation.show({\n confirm: function() {\n // the user has confirmed the dialog\n },\n message: \"Do you really want to continue?\"\n });\n});\n</code></pre>"},{"location":"javascript/new-api_ui/#showoptions-object","title":"<code>show(options: Object)</code>","text":"<p>Displays a dialog overlay with actions buttons to confirm or reject the dialog.</p>"},{"location":"javascript/new-api_ui/#cancel-parameters-object-void","title":"<code>cancel: (parameters: Object) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Callback that is invoked when the dialog was rejected.</p>"},{"location":"javascript/new-api_ui/#confirm-parameters-object-void","title":"<code>confirm: (parameters: Object) => void</code>","text":"<p>Defaults to <code>null</code>.</p> <p>Callback that is invoked when the user has confirmed the dialog.</p>"},{"location":"javascript/new-api_ui/#message-string","title":"<code>message: string</code>","text":"<p>Defaults to '\"\"'.</p> <p>Text that is displayed in the content area of the dialog, optionally this can be HTML, but this requires <code>messageIsHtml</code> to be enabled.</p>"},{"location":"javascript/new-api_ui/#messageishtml","title":"<code>messageIsHtml</code>","text":"<p>Defaults to <code>false</code>.</p> <p>The <code>message</code> option is interpreted as text-only, setting this option to <code>true</code> will cause the <code>message</code> to be evaluated as HTML.</p>"},{"location":"javascript/new-api_ui/#parameters-object","title":"<code>parameters: Object</code>","text":"<p>Optional list of parameter options that will be passed to the <code>cancel()</code> and <code>confirm()</code> callbacks.</p>"},{"location":"javascript/new-api_ui/#template-string","title":"<code>template: string</code>","text":"<p>An optional HTML template that will be inserted into the dialog content area, but after the <code>message</code> section.</p>"},{"location":"javascript/new-api_ui/#uinotification","title":"<code>Ui/Notification</code>","text":"<p>Displays a simple notification at the very top of the window, such as a success message for Ajax based actions.</p> <pre><code>require([\"Ui/Notification\"], function(UiNotification) {\n UiNotification.show(\n \"Your changes have been saved.\",\n function() {\n // this callback will be invoked after 2 seconds\n },\n \"success\"\n );\n});\n</code></pre>"},{"location":"javascript/new-api_ui/#showmessage-string-callback-void-cssclassname-string","title":"<code>show(message: string, callback?: () => void, cssClassName?: string)</code>","text":"<p>Shows the notification and executes the callback after 2 seconds.</p>"},{"location":"javascript/new-api_writing-a-module/","title":"Writing a Module - JavaScript API","text":""},{"location":"javascript/new-api_writing-a-module/#introduction","title":"Introduction","text":"<p>The new JavaScript-API was introduced with WoltLab Suite 3.0 and was a major change in all regards. The previously used API heavily relied on larger JavaScript files that contained a lot of different components with hidden dependencies and suffered from extensive jQuery usage for historic reasons.</p> <p>Eventually a new API was designed that solves the issues with the legacy API by following a few basic principles: 1. Vanilla ES5-JavaScript. It allows us to achieve the best performance across all platforms, there is simply no reason to use jQuery today and the performance penalty on mobile devices is a real issue. 2. Strict usage of modules. Each component is placed in an own file and all dependencies are explicitly declared and injected at the top.Eventually we settled with AMD-style modules using require.js which offers both lazy loading and \"ahead of time\"-compilatio with <code>r.js</code>. 3. No jQuery-based components on page init. Nothing is more annoying than loading a page and then wait for JavaScript to modify the page before it becomes usable, forcing the user to sit and wait. Heavily optimized vanilla JavaScript components offered the speed we wanted. 4. Limited backwards-compatibility. The new API should make it easy to update existing components by providing similar interfaces, while still allowing legacy code to run side-by-side for best compatibility and to avoid rewritting everything from the start.</p>"},{"location":"javascript/new-api_writing-a-module/#defining-a-module","title":"Defining a Module","text":"<p>The default location for modules is <code>js/</code> in the Core's app dir, but every app and plugin can register their own lookup path by providing the path using a template-listener on <code>requirePaths@headIncludeJavaScript</code>.</p> <p>For this example we'll assume the file is placed at <code>js/WoltLabSuite/Core/Ui/Foo.js</code>, the module name is therefore <code>WoltLabSuite/Core/Ui/Foo</code>, it is automatically derived from the file path and name.</p> <p>For further instructions on how to define and require modules head over to the RequireJS API.</p> <pre><code>define([\"Ajax\", \"WoltLabSuite/Core/Ui/Bar\"], function(Ajax, UiBar) {\n \"use strict\";\n\n function Foo() { this.init(); }\n Foo.prototype = {\n init: function() {\n elBySel(\".myButton\").addEventListener(WCF_CLICK_EVENT, this._click.bind(this));\n },\n\n _click: function(event) {\n event.preventDefault();\n\n if (UiBar.isSnafucated()) {\n Ajax.api(this);\n }\n },\n\n _ajaxSuccess: function(data) {\n console.log(\"Received response\", data);\n },\n\n _ajaxSetup: function() {\n return {\n data: {\n actionName: \"makeSnafucated\",\n className: \"wcf\\\\data\\\\foo\\\\FooAction\"\n }\n };\n }\n }\n\n return Foo;\n});\n</code></pre>"},{"location":"javascript/new-api_writing-a-module/#loading-a-module","title":"Loading a Module","text":"<p>Modules can then be loaded through their derived name:</p> <pre><code><script data-relocate=\"true\">\n require([\"WoltLabSuite/Core/Ui/Foo\"], function(UiFoo) {\n new UiFoo();\n });\n</script>\n</code></pre>"},{"location":"javascript/new-api_writing-a-module/#module-aliases","title":"Module Aliases","text":"<p>Some common modules have short-hand aliases that can be used to include them without writing out their full name. You can still use their original path, but it is strongly recommended to use the aliases for consistency.</p> Alias Full Path Ajax WoltLabSuite/Core/Ajax AjaxJsonp WoltLabSuite/Core/Ajax/Jsonp AjaxRequest WoltLabSuite/Core/Ajax/Request CallbackList WoltLabSuite/Core/CallbackList ColorUtil WoltLabSuite/Core/ColorUtil Core WoltLabSuite/Core/Core DateUtil WoltLabSuite/Core/Date/Util Devtools WoltLabSuite/Core/Devtools Dom/ChangeListener WoltLabSuite/Core/Dom/Change/Listener Dom/Traverse WoltLabSuite/Core/Dom/Traverse Dom/Util WoltLabSuite/Core/Dom/Util Environment WoltLabSuite/Core/Environment EventHandler WoltLabSuite/Core/Event/Handler EventKey WoltLabSuite/Core/Event/Key Language WoltLabSuite/Core/Language Permission WoltLabSuite/Core/Permission StringUtil WoltLabSuite/Core/StringUtil Ui/Alignment WoltLabSuite/Core/Ui/Alignment Ui/CloseOverlay WoltLabSuite/Core/Ui/CloseOverlay Ui/Confirmation WoltLabSuite/Core/Ui/Confirmation Ui/Dialog WoltLabSuite/Core/Ui/Dialog Ui/Notification WoltLabSuite/Core/Ui/Notification Ui/ReusableDropdown WoltLabSuite/Core/Ui/Dropdown/Reusable Ui/Screen WoltLabSuite/Core/Ui/Screen Ui/Scroll WoltLabSuite/Core/Ui/Scroll Ui/SimpleDropdown WoltLabSuite/Core/Ui/Dropdown/Simple Ui/TabMenu WoltLabSuite/Core/Ui/TabMenu Upload WoltLabSuite/Core/Upload User WoltLabSuite/Core/User"},{"location":"javascript/typescript/","title":"TypeScript","text":""},{"location":"javascript/typescript/#consuming-woltlab-suites-types","title":"Consuming WoltLab Suite\u2019s Types","text":"<p>To consume the types of WoltLab Suite, you will need to install the <code>@woltlab/wcf</code> npm package using a git URL that refers to the appropriate branch of WoltLab/WCF.</p> <p>A full <code>package.json</code> that includes WoltLab Suite, TypeScript, eslint and Prettier could look like the following.</p> package.json <pre><code>{\n \"devDependencies\": {\n \"@typescript-eslint/eslint-plugin\": \"^6.5.0\",\n \"@typescript-eslint/parser\": \"^6.5.0\",\n \"eslint\": \"^8.48.0\",\n \"eslint-config-prettier\": \"^9.0.0\",\n \"prettier\": \"^3.0.3\",\n \"typescript\": \"^5.2.2\"\n },\n \"dependencies\": {\n \"@woltlab/d.ts\": \"https://github.com/WoltLab/d.ts.git#51281749962192683d2b9d6a17388fb2298b4b62\"\n }\n}\n</code></pre> <p>After installing the types using npm, you will also need to configure <code>tsconfig.json</code> to take the types into account. To do so, you will need to add them to the <code>compilerOptions.paths</code> option. A complete <code>tsconfig.json</code> file that matches the configuration of WoltLab Suite could look like the following.</p> tsconfig.json <pre><code>{\n \"include\": [\n \"node_modules/@woltlab/d.ts/global.d.ts\",\n \"ts/**/*\"\n ],\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"amd\",\n \"rootDir\": \"ts/\",\n \"outDir\": \"files/js/\",\n \"lib\": [\n \"DOM\",\n \"DOM.Iterable\",\n \"ES2022\"\n ],\n \"strictNullChecks\": true,\n \"moduleResolution\": \"node\",\n \"esModuleInterop\": true,\n \"noImplicitThis\": true,\n \"strictBindCallApply\": true,\n \"baseUrl\": \".\",\n \"paths\": {\n \"*\": [\n \"node_modules/@woltlab/d.ts/*\"\n ]\n },\n \"importHelpers\": true,\n \"newLine\": \"lf\"\n }\n}\n</code></pre> <p>After this initial set-up, you would place your TypeScript source files into the <code>ts/</code> folder of your project. The generated JavaScript target files will be placed into <code>files/js/</code> and thus will be installed by the file PIP.</p> <p>To update the TypeScript types, the commit hash in <code>package.json</code> needs to be updated to an appropriate commit in the d.ts repository and <code>npm install</code> needs to be rerun.</p>"},{"location":"javascript/typescript/#additional-tools","title":"Additional Tools","text":"<p>WoltLab Suite uses additional tools to ensure the high quality and a consistent code style of the TypeScript modules. The current configuration of these tools is as follows. It is recommended to re-use this configuration as is.</p> .prettierrc <pre><code>trailingComma: all\nprintWidth: 120\n</code></pre> .eslintrc.js <pre><code>module.exports = {\n root: true,\n parser: \"@typescript-eslint/parser\",\n parserOptions: {\n tsconfigRootDir: __dirname,\n project: [\"./tsconfig.json\"]\n },\n plugins: [\"@typescript-eslint\"],\n extends: [\n \"eslint:recommended\",\n \"plugin:@typescript-eslint/recommended\",\n \"plugin:@typescript-eslint/recommended-type-checked\",\n \"plugin:@typescript-eslint/strict\",\n \"plugin:@typescript-eslint/strict-type-checked\",\n \"plugin:@typescript-eslint/stylistic\",\n \"plugin:@typescript-eslint/stylistic-type-checked\",\n \"prettier\"\n ],\n rules: {\n \"@typescript-eslint/no-non-null-assertion\": 0,\n \"@typescript-eslint/consistent-type-definitions\": 0,\n \"@typescript-eslint/prefer-nullish-coalescing\": 0,\n \"@typescript-eslint/no-unused-vars\": [\n \"error\", {\n \"argsIgnorePattern\": \"^_\"\n }\n ],\n \"@typescript-eslint/strict-boolean-expressions\": [\n \"error\", {\n \"allowNullableBoolean\": true\n }\n ],\n }\n};\n</code></pre> .eslintignore <pre><code>**/*.js\nvendor/**\n</code></pre> <p>This <code>.gitattributes</code> configuration will automatically collapse the generated JavaScript target files in GitHub\u2019s Diff view. You will not need it if you do not use git or GitHub.</p> .gitattributes <pre><code>files/js/**/*.js linguist-generated\n</code></pre>"},{"location":"javascript/typescript/#writing-a-simple-module","title":"Writing a simple module","text":"<p>After completing this initial set-up you can start writing your first TypeScript module. The TypeScript compiler can be launched in Watch Mode by running <code>npx tsc -w</code>.</p> <p>WoltLab Suite\u2019s modules can be imported using the standard ECMAScript module import syntax by specifying the full module name. The public API of the module can also be exported using the standard ECMAScript module export syntax.</p> ts/Example.ts <pre><code>import * as Language from \"WoltLabSuite/Core/Language\";\n\nexport function run() {\n alert(Language.get(\"wcf.foo.bar\"));\n}\n</code></pre> <p>This simple example module will compile to plain JavaScript that is compatible with the AMD loader that is used by WoltLab Suite.</p> files/js/Example.js <pre><code>define([\"require\", \"exports\", \"tslib\", \"WoltLabSuite/Core/Language\"], function (require, exports, tslib_1, Language) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.run = void 0;\n Language = tslib_1.__importStar(Language);\n function run() {\n alert(Language.get(\"wcf.foo.bar\"));\n }\n exports.run = run;\n});\n</code></pre> <p>Within templates it can be consumed as follows.</p> <pre><code><script data-relocate=\"true\">\n require([\"Example\"], (Example) => {\n Example.run(); // Alerts the contents of the `wcf.foo.bar` phrase.\n });\n</script>\n</code></pre>"},{"location":"migration/wcf21/css/","title":"WCF 2.1.x - CSS","text":"<p>The LESS compiler has been in use since WoltLab Community Framework 2.0, but was replaced with a SCSS compiler in WoltLab Suite 3.0. This change was motivated by SCSS becoming the de facto standard for CSS pre-processing and some really annoying shortcomings in the old LESS compiler.</p> <p>The entire CSS has been rewritten from scratch, please read the docs on CSS to learn what has changed.</p>"},{"location":"migration/wcf21/package/","title":"WCF 2.1.x - Package Components","text":""},{"location":"migration/wcf21/package/#packagexml","title":"package.xml","text":""},{"location":"migration/wcf21/package/#short-instructions","title":"Short Instructions","text":"<p>Instructions can now omit the filename, causing them to use the default filename if defined by the package installation plugin (in short: <code>PIP</code>). Unless overridden it will default to the PIP's class name with the first letter being lower-cased, e.g. <code>EventListenerPackageInstallationPlugin</code> implies the filename <code>eventListener.xml</code>. The file is always assumed to be in the archive's root, files located in subdirectories need to be explicitly stated, just as it worked before.</p> <p>Every PIP can define a custom filename if the default value cannot be properly derived. For example the <code>ACPMenu</code>-pip would default to <code>aCPMenu.xml</code>, requiring the class to explicitly override the default filename with <code>acpMenu.xml</code> for readability.</p>"},{"location":"migration/wcf21/package/#example","title":"Example","text":"<pre><code><instructions type=\"install\">\n <!-- assumes `eventListener.xml` -->\n <instruction type=\"eventListener\" />\n <!-- assumes `install.sql` -->\n <instruction type=\"sql\" />\n <!-- assumes `language/*.xml` -->\n <instruction type=\"language\" />\n\n <!-- exceptions -->\n\n <!-- assumes `files.tar` -->\n <instruction type=\"file\" />\n <!-- no default value, requires relative path -->\n <instruction type=\"script\">acp/install_com.woltlab.wcf_3.0.php</instruction>\n</instructions>\n</code></pre>"},{"location":"migration/wcf21/package/#exceptions","title":"Exceptions","text":"<p>These exceptions represent the built-in PIPs only, 3rd party plugins and apps may define their own exceptions.</p> PIP Default Value <code>acpTemplate</code> <code>acptemplates.tar</code> <code>file</code> <code>files.tar</code> <code>language</code> <code>language/*.xml</code> <code>script</code> (No default value) <code>sql</code> <code>install.sql</code> <code>template</code> <code>templates.tar</code>"},{"location":"migration/wcf21/package/#acpmenuxml","title":"acpMenu.xml","text":""},{"location":"migration/wcf21/package/#renamed-categories","title":"Renamed Categories","text":"<p>The following categories have been renamed, menu items need to be adjusted to reflect the new names:</p> Old Value New Value <code>wcf.acp.menu.link.system</code> <code>wcf.acp.menu.link.configuration</code> <code>wcf.acp.menu.link.display</code> <code>wcf.acp.menu.link.customization</code> <code>wcf.acp.menu.link.community</code> <code>wcf.acp.menu.link.application</code>"},{"location":"migration/wcf21/package/#submenu-items","title":"Submenu Items","text":"<p>Menu items can now offer additional actions to be accessed from within the menu using an icon-based navigation. This step avoids filling the menu with dozens of <code>Add \u2026</code> links, shifting the focus on to actual items. Adding more than one action is not recommended and you should at maximum specify two actions per item.</p>"},{"location":"migration/wcf21/package/#example_1","title":"Example","text":"<pre><code><!-- category -->\n<acpmenuitem name=\"wcf.acp.menu.link.group\">\n <parent>wcf.acp.menu.link.user</parent>\n <showorder>2</showorder>\n</acpmenuitem>\n\n<!-- menu item -->\n<acpmenuitem name=\"wcf.acp.menu.link.group.list\">\n <controller>wcf\\acp\\page\\UserGroupListPage</controller>\n <parent>wcf.acp.menu.link.group</parent>\n <permissions>admin.user.canEditGroup,admin.user.canDeleteGroup</permissions>\n</acpmenuitem>\n<!-- menu item action -->\n<acpmenuitem name=\"wcf.acp.menu.link.group.add\">\n <controller>wcf\\acp\\form\\UserGroupAddForm</controller>\n <!-- actions are defined by menu items of menu items -->\n <parent>wcf.acp.menu.link.group.list</parent>\n <permissions>admin.user.canAddGroup</permissions>\n <!-- required FontAwesome icon name used for display -->\n <icon>fa-plus</icon>\n</acpmenuitem>\n</code></pre>"},{"location":"migration/wcf21/package/#common-icon-names","title":"Common Icon Names","text":"<p>You should use the same icon names for the (logically) same task, unifying the meaning of items and making the actions predictable.</p> Meaning Icon Name Result Add or create <code>fa-plus</code> Search <code>fa-search</code> Upload <code>fa-upload</code>"},{"location":"migration/wcf21/package/#boxxml","title":"box.xml","text":"<p>The box PIP has been added.</p>"},{"location":"migration/wcf21/package/#cronjobxml","title":"cronjob.xml","text":"<p>Legacy cronjobs are assigned a non-deterministic generic name, the only way to assign them a name is removing them and then adding them again.</p> <p>Cronjobs can now be assigned a name using the name attribute as in <code><cronjob name=\"com.woltlab.wcf.refreshPackageUpdates\"></code>, it will be used to identify cronjobs during an update or delete.</p>"},{"location":"migration/wcf21/package/#eventlistenerxml","title":"eventListener.xml","text":"<p>Legacy event listeners are assigned a non-deterministic generic name, the only way to assign them a name is removing them and then adding them again.</p> <p>Event listeners can now be assigned a name using the name attribute as in <code><eventlistener name=\"sessionPageAccessLog\"></code>, it will be used to identify event listeners during an update or delete.</p>"},{"location":"migration/wcf21/package/#menuxml","title":"menu.xml","text":"<p>The menu PIP has been added.</p>"},{"location":"migration/wcf21/package/#menuitemxml","title":"menuItem.xml","text":"<p>The menuItem PIP has been added.</p>"},{"location":"migration/wcf21/package/#objecttypexml","title":"objectType.xml","text":"<p>The definition <code>com.woltlab.wcf.user.dashboardContainer</code> has been removed, it was previously used to register pages that qualify for dashboard boxes. Since WoltLab Suite 3.0, all pages registered through the <code>page.xml</code> are valid containers and therefore there is no need for this definition anymore.</p> <p>The definitions <code>com.woltlab.wcf.page</code> and <code>com.woltlab.wcf.user.online.location</code> have been superseded by the <code>page.xml</code>, they're no longer supported.</p>"},{"location":"migration/wcf21/package/#optionxml","title":"option.xml","text":"<p>The <code>module.display</code> category has been renamed into <code>module.customization</code>.</p>"},{"location":"migration/wcf21/package/#pagexml","title":"page.xml","text":"<p>The page PIP has been added.</p>"},{"location":"migration/wcf21/package/#pagemenuxml","title":"pageMenu.xml","text":"<p>The <code>pageMenu.xml</code> has been superseded by the <code>page.xml</code> and is no longer available.</p>"},{"location":"migration/wcf21/php/","title":"WCF 2.1.x - PHP","text":""},{"location":"migration/wcf21/php/#message-processing","title":"Message Processing","text":"<p>WoltLab Suite 3.0 finally made the transition from raw bbcode to bbcode-flavored HTML, with many new features related to message processing being added. This change impacts both message validation and storing, requiring slightly different APIs to get the job done.</p>"},{"location":"migration/wcf21/php/#input-processing-for-storage","title":"Input Processing for Storage","text":"<p>The returned HTML is an intermediate representation with a maximum of meta data embedded into it, designed to be stored in the database. Some bbcodes are replaced during this process, for example <code>[b]\u2026[/b]</code> becomes <code><strong>\u2026</strong></code>, while others are converted into a metacode tag for later processing.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->process($message, $messageObjectType, $messageObjectID);\n$html = $processor->getHtml();\n</code></pre> <p>The <code>$messageObjectID</code> can be zero if the element did not exist before, but it should be non-zero when saving an edited message.</p>"},{"location":"migration/wcf21/php/#embedded-objects","title":"Embedded Objects","text":"<p>Embedded objects need to be registered after saving the message, but once again you can use the processor instance to do the job.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->process($message, $messageObjectType, $messageObjectID);\n$html = $processor->getHtml();\n\n// at this point the message is saved to database and the created object\n// `$example` is a `DatabaseObject` with the id column `$exampleID`\n\n$processor->setObjectID($example->exampleID);\nif (\\wcf\\system\\message\\embedded\\object\\MessageEmbeddedObjectManager::getInstance()->registerObjects($processor)) {\n // there is at least one embedded object, this is also the point at which you\n // would set `hasEmbeddedObjects` to true (if implemented by your type)\n (new \\wcf\\data\\example\\ExampleEditor($example))->update(['hasEmbeddedObjects' => 1]);\n}\n</code></pre>"},{"location":"migration/wcf21/php/#rendering-the-message","title":"Rendering the Message","text":"<p>The output processor will parse the intermediate HTML and finalize the output for display. This step is highly dynamic and allows for bbcode evaluation and contextual output based on the viewer's permissions.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\output\\HtmlOutputProcessor();\n$processor->process($html, $messageObjectType, $messageObjectID);\n$renderedHtml = $processor->getHtml();\n</code></pre>"},{"location":"migration/wcf21/php/#simplified-output","title":"Simplified Output","text":"<p>At some point there can be the need of a simplified output HTML that includes only basic HTML formatting and reduces more sophisticated bbcodes into a simpler representation.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\output\\HtmlOutputProcessor();\n$processor->setOutputType('text/simplified-html');\n$processor->process(\u2026);\n</code></pre>"},{"location":"migration/wcf21/php/#plaintext-output","title":"Plaintext Output","text":"<p>The <code>text/plain</code> output type will strip down the simplified HTML into pure text, suitable for text-only output such as the plaintext representation of an email.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\output\\HtmlOutputProcessor();\n$processor->setOutputType('text/plain');\n$processor->process(\u2026);\n</code></pre>"},{"location":"migration/wcf21/php/#rebuilding-data","title":"Rebuilding Data","text":""},{"location":"migration/wcf21/php/#converting-from-bbcode","title":"Converting from BBCode","text":"<p>Enabling message conversion for HTML messages is undefined and yields unexpected results.</p> <p>Legacy message that still use raw bbcodes must be converted to be properly parsed by the html processors. This process is enabled by setting the fourth parameter of <code>process()</code> to <code>true</code>.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->process($html, $messageObjectType, $messageObjectID, true);\n$renderedHtml = $processor->getHtml();\n</code></pre>"},{"location":"migration/wcf21/php/#extracting-embedded-objects","title":"Extracting Embedded Objects","text":"<p>The <code>process()</code> method of the input processor is quite expensive, as it runs through the full message validation including the invocation of HTMLPurifier. This is perfectly fine when dealing with single messages, but when you're handling messages in bulk to extract their embedded objects, you're better of with <code>processEmbeddedContent()</code>. This method deconstructs the message, but skips all validation and expects the input to be perfectly valid, that is the output of a previous run of <code>process()</code> saved to storage.</p> <pre><code><?php\n$processor = new \\wcf\\system\\html\\input\\HtmlInputProcessor();\n$processor->processEmbeddedContent($html, $messageObjectType, $messageObjectID);\n\n// invoke `MessageEmbeddedObjectManager::registerObjects` here\n</code></pre>"},{"location":"migration/wcf21/php/#breadcrumbs-page-location","title":"Breadcrumbs / Page Location","text":"<p>Breadcrumbs used to be added left to right, but parent locations are added from the bottom to the top, starting with the first ancestor and going upwards. In most cases you simply need to reverse the order.</p> <p>Breadcrumbs used to be a lose collection of arbitrary links, but are now represented by actual page objects and the control has shifted over to the <code>PageLocationManager</code>.</p> <pre><code><?php\n// before\n\\wcf\\system\\WCF::getBreadcrumbs()->add(new \\wcf\\system\\breadcrumb\\Breadcrumb('title', 'link'));\n\n// after\n\\wcf\\system\\page\\PageLocationManager::getInstance()->addParentLocation($pageIdentifier, $pageObjectID, $object);\n</code></pre>"},{"location":"migration/wcf21/php/#pages-and-forms","title":"Pages and Forms","text":"<p>The property <code>$activeMenuItem</code> has been deprecated for the front end and is no longer evaluated at runtime. Recognition of the active item is entirely based around the invoked controller class name and its definition in the page table. You need to properly register your pages for this feature to work.</p>"},{"location":"migration/wcf21/php/#search","title":"Search","text":""},{"location":"migration/wcf21/php/#isearchableobjecttype","title":"ISearchableObjectType","text":"<p>Added the <code>setLocation()</code> method that is used to set the current page location based on the search result.</p>"},{"location":"migration/wcf21/php/#searchindexmanager","title":"SearchIndexManager","text":"<p>The methods <code>SearchIndexManager::add()</code> and <code>SearchIndexManager::update()</code> have been deprecated and forward their call to the new method <code>SearchIndexManager::set()</code>.</p>"},{"location":"migration/wcf21/templates/","title":"WCF 2.1.x - Templates","text":""},{"location":"migration/wcf21/templates/#page-layout","title":"Page Layout","text":"<p>The template structure has been overhauled and it is no longer required nor recommended to include internal templates, such as <code>documentHeader</code>, <code>headInclude</code> or <code>userNotice</code>. Instead use a simple <code>{include file='header'}</code> that now takes care of of the entire application frame.</p> <ul> <li>Templates must not include a trailing <code></body></html></code> after including the <code>footer</code> template.</li> <li>The <code>documentHeader</code>, <code>headInclude</code> and <code>userNotice</code> template should no longer be included manually, the same goes with the <code><body></code> element, please use <code>{include file='header'}</code> instead.</li> <li>The <code>sidebarOrientation</code> variable for the <code>header</code> template has been removed and no longer works.</li> <li><code>header.boxHeadline</code> has been unified and now reads <code>header.contentHeader</code></li> </ul> <p>Please see the full example at the end of this page for more information.</p>"},{"location":"migration/wcf21/templates/#sidebars","title":"Sidebars","text":"<p>Sidebars are now dynamically populated by the box system, this requires a small change to unify the markup. Additionally the usage of <code><fieldset></code> has been deprecated due to browser inconsistencies and bugs and should be replaced with <code>section.box</code>.</p> <p>Previous markup used in WoltLab Community Framework 2.1 and earlier:</p> <pre><code><fieldset>\n <legend><!-- Title --></legend>\n\n <div>\n <!-- Content -->\n </div>\n</fieldset>\n</code></pre> <p>The new markup since WoltLab Suite 3.0:</p> <pre><code><section class=\"box\">\n <h2 class=\"boxTitle\"><!-- Title --></h2>\n\n <div class=\"boxContent\">\n <!-- Content -->\n </div>\n</section>\n</code></pre>"},{"location":"migration/wcf21/templates/#forms","title":"Forms","text":"<p>The input tag for session ids <code>SID_INPUT_TAG</code> has been deprecated and no longer yields any content, it can be safely removed. In previous versions forms have been wrapped in <code><div class=\"container containerPadding marginTop\">\u2026</div></code> which no longer has any effect and should be removed.</p> <p>If you're using the preview feature for WYSIWYG-powered input fields, you need to alter the preview button include instruction:</p> <pre><code>{include file='messageFormPreviewButton' previewMessageObjectType='com.example.foo.bar' previewMessageObjectID=0}\n</code></pre> <p>The message object id should be non-zero when editing.</p>"},{"location":"migration/wcf21/templates/#icons","title":"Icons","text":"<p>The old <code>.icon-<iconName></code> classes have been removed, you are required to use the official <code>.fa-<iconName></code> class names from FontAwesome. This does not affect the generic classes <code>.icon</code> (indicates an icon) and <code>.icon<size></code> (e.g. <code>.icon16</code> that sets the dimensions), these are still required and have not been deprecated.</p> <p>Before:</p> <pre><code><span class=\"icon icon16 icon-list\">\n</code></pre> <p>Now:</p> <pre><code><span class=\"icon icon16 fa-list\">\n</code></pre>"},{"location":"migration/wcf21/templates/#changed-icon-names","title":"Changed Icon Names","text":"<p>Quite a few icon names have been renamed, the official wiki lists the new icon names in FontAwesome 4.</p>"},{"location":"migration/wcf21/templates/#changed-classes","title":"Changed Classes","text":"<ul> <li><code>.dataList</code> has been replaced and should now read <code><ol class=\"inlineList commaSeparated\"></code> (same applies to <code><ul></code>)</li> <li><code>.framedIconList</code> has been changed into <code>.userAvatarList</code></li> </ul>"},{"location":"migration/wcf21/templates/#removed-elements-and-classes","title":"Removed Elements and Classes","text":"<ul> <li><code><nav class=\"jsClipboardEditor\"></code> and <code><div class=\"jsClipboardContainer\"></code> have been replaced with a floating button.</li> <li>The anchors <code>a.toTopLink</code> have been replaced with a floating button.</li> <li>Avatars should no longer receive the class <code>framed</code></li> <li>The <code>dl.condensed</code> class, as seen in the editor tab menu, is no longer required.</li> <li>Anything related to <code>sidebarCollapsed</code> has been removed as sidebars are no longer collapsible.</li> </ul>"},{"location":"migration/wcf21/templates/#simple-example","title":"Simple Example","text":"<p>The code below includes only the absolute minimum required to display a page, the content title is already included in the output.</p> <pre><code>{include file='header'}\n\n<div class=\"section\">\n Hello World!\n</div>\n\n{include file='footer'}\n</code></pre>"},{"location":"migration/wcf21/templates/#full-example","title":"Full Example","text":"<pre><code>{*\n The page title is automatically set using the page definition, avoid setting it if you can!\n If you really need to modify the title, you can still reference the original title with:\n {$__wcf->getActivePage()->getTitle()}\n*}\n{capture assign='pageTitle'}Custom Page Title{/capture}\n\n{*\n NOTICE: The content header goes here, see the section after this to learn more.\n*}\n\n{* you must not use `headContent` for JavaScript *}\n{capture assign='headContent'}\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"{lang}wcf.global.button.rss{/lang}\" href=\"\u2026\">\n{/capture}\n\n{* optional, content will be added to the top of the left sidebar *}\n{capture assign='sidebarLeft'}\n \u2026\n\n {event name='boxes'}\n{/capture}\n\n{* optional, content will be added to the top of the right sidebar *}\n{capture assign='sidebarRight'}\n \u2026\n\n {event name='boxes'}\n{/capture}\n\n{capture assign='headerNavigation'}\n <li><a href=\"#\" title=\"Custom Button\" class=\"jsTooltip\"><span class=\"icon icon16 fa-check\"></span> <span class=\"invisible\">Custom Button</span></a></li>\n{/capture}\n\n{include file='header'}\n\n{hascontent}\n <div class=\"paginationTop\">\n {content}\n {pages \u2026}\n {/content}\n </div>\n{/hascontent}\n\n{* the actual content *}\n<div class=\"section\">\n \u2026\n</div>\n\n<footer class=\"contentFooter\">\n {* skip this if you're not using any pagination *}\n {hascontent}\n <div class=\"paginationBottom\">\n {content}{@$pagesLinks}{/content}\n </div>\n {/hascontent}\n\n <nav class=\"contentFooterNavigation\">\n <ul>\n <li><a href=\"\u2026\" class=\"button\"><span class=\"icon icon16 fa-plus\"></span> <span>Custom Button</span></a></li>\n {event name='contentFooterNavigation'}\n </ul>\n </nav>\n</footer>\n\n<script data-relocate=\"true\">\n /* any JavaScript code you need */\n</script>\n\n{* do not include `</body></html>` here, the footer template is the last bit of code! *}\n{include file='footer'}\n</code></pre>"},{"location":"migration/wcf21/templates/#content-header","title":"Content Header","text":"<p>There are two different methods to set the content header, one sets only the actual values, but leaves the outer HTML untouched, that is generated by the <code>header</code> template. This is the recommended approach and you should avoid using the alternative method whenever possible.</p>"},{"location":"migration/wcf21/templates/#recommended-approach","title":"Recommended Approach","text":"<pre><code>{* This is automatically set using the page data and should not be set manually! *}\n{capture assign='contentTitle'}Custom Content Title{/capture}\n\n{capture assign='contentDescription'}Optional description that is displayed right after the title.{/capture}\n\n{capture assign='contentHeaderNavigation'}List of navigation buttons displayed right next to the title.{/capture}\n</code></pre>"},{"location":"migration/wcf21/templates/#alternative","title":"Alternative","text":"<pre><code>{capture assign='contentHeader'}\n <header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">Custom Content Title</h1>\n <p class=\"contentHeaderDescription\">Custom Content Description</p>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='CustomController'}{/link}\" class=\"button\"><span class=\"icon icon16 fa-plus\"></span> <span>Custom Button</span></a></li>\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n </header>\n{/capture}\n</code></pre>"},{"location":"migration/wsc30/css/","title":"Migrating from WSC 3.0 - CSS","text":""},{"location":"migration/wsc30/css/#new-style-variables","title":"New Style Variables","text":"<p>The new style variables are only applied to styles that have the compatibility set to WSC 3.1</p>"},{"location":"migration/wsc30/css/#wcfcontentcontainer","title":"wcfContentContainer","text":"<p>The page content is encapsulated in a new container that wraps around the inner content, but excludes the sidebars, header and page navigation elements.</p> <ul> <li><code>$wcfContentContainerBackground</code> - background color</li> <li><code>$wcfContentContainerBorder</code> - border color</li> </ul>"},{"location":"migration/wsc30/css/#wcfeditorbutton","title":"wcfEditorButton","text":"<p>These variables control the appearance of the editor toolbar and its buttons.</p> <ul> <li><code>$wcfEditorButtonBackground</code> - button and toolbar background color</li> <li><code>$wcfEditorButtonBackgroundActive</code> - active button background color</li> <li><code>$wcfEditorButtonText</code> - text color for available buttons</li> <li><code>$wcfEditorButtonTextActive</code> - text color for active buttons</li> <li><code>$wcfEditorButtonTextDisabled</code> - text color for disabled buttons</li> </ul>"},{"location":"migration/wsc30/css/#color-variables-in-alertscss","title":"Color Variables in <code>alert.scss</code>","text":"<p>The color values for <code><small class=\"innerError\"></code> used to be hardcoded values, but have now been changed to use the values for error messages (<code>wcfStatusError*</code>) instead.</p>"},{"location":"migration/wsc30/javascript/","title":"Migrating from WSC 3.0 - JavaScript","text":""},{"location":"migration/wsc30/javascript/#accelerated-guest-view-tiny-builds","title":"Accelerated Guest View / Tiny Builds","text":"<p>The new tiny builds are highly optimized variants of existing JavaScript files and modules, aiming for significant performance improvements for guests and search engines alike. This is accomplished by heavily restricting page interaction to read-only actions whenever possible, which in return removes the need to provide certain JavaScript modules in general.</p> <p>For example, disallowing guests to write any formatted messages will in return remove the need to provide the WYSIWYG editor at all. But it doesn't stop there, there are a lot of other modules that provide additional features for the editor, and by excluding the editor, we can also exclude these modules too.</p> <p>Long story short, the tiny mode guarantees that certain actions will never be carried out by guests or search engines, therefore some modules are not going to be needed by them ever.</p>"},{"location":"migration/wsc30/javascript/#code-templates-for-tiny-builds","title":"Code Templates for Tiny Builds","text":"<p>The following examples assume that you use the virtual constant <code>COMPILER_TARGET_DEFAULT</code> as a switch for the optimized code path. This is also the constant used by the official build scripts for JavaScript files.</p> <p>We recommend that you provide a mock implementation for existing code to ensure 3rd party compatibility. It is enough to provide a bare object or class that exposes the original properties using the same primitive data types. This is intended to provide a soft-fail for implementations that are not aware of the tiny mode yet, but is not required for classes that did not exist until now.</p>"},{"location":"migration/wsc30/javascript/#legacy-javascript","title":"Legacy JavaScript","text":"<pre><code>if (COMPILER_TARGET_DEFAULT) {\n WCF.Example.Foo = {\n makeSnafucated: function() {\n return \"Hello World\";\n }\n };\n\n WCF.Example.Bar = Class.extend({\n foobar: \"baz\",\n\n foo: function($bar) {\n return $bar + this.foobar;\n }\n });\n}\nelse {\n WCF.Example.Foo = {\n makeSnafucated: function() {}\n };\n\n WCF.Example.Bar = Class.extend({\n foobar: \"\",\n foo: function() {}\n });\n}\n</code></pre>"},{"location":"migration/wsc30/javascript/#requirejs-modules","title":"require.js Modules","text":"<pre><code>define([\"some\", \"fancy\", \"dependencies\"], function(Some, Fancy, Dependencies) {\n \"use strict\";\n\n if (!COMPILER_TARGET_DEFAULT) {\n var Fake = function() {};\n Fake.prototype = {\n init: function() {},\n makeSnafucated: function() {}\n };\n return Fake;\n }\n\n function MyAwesomeClass(niceArgument) { this.init(niceArgument); }\n MyAwesomeClass.prototype = {\n init: function(niceArgument) {\n if (niceArgument) {\n this.makeSnafucated();\n }\n },\n\n makeSnafucated: function() {\n console.log(\"Hello World\");\n }\n }\n\n return MyAwesomeClass;\n});\n</code></pre>"},{"location":"migration/wsc30/javascript/#including-tinified-builds-through-js","title":"Including tinified builds through <code>{js}</code>","text":"<p>The <code>{js}</code> template-plugin has been updated to include support for tiny builds controlled through the optional flag <code>hasTiny=true</code>:</p> <pre><code>{js application='wcf' file='WCF.Example' hasTiny=true}\n</code></pre> <p>This line generates a different output depending on the debug mode and the user login-state.</p>"},{"location":"migration/wsc30/javascript/#real-error-messages-for-ajax-responses","title":"Real Error Messages for AJAX Responses","text":"<p>The <code>errorMessage</code> property in the returned response object for failed AJAX requests contained an exception-specific but still highly generic error message. This issue has been around for quite a long time and countless of implementations are relying on this false behavior, eventually forcing us to leave the value unchanged.</p> <p>This problem is solved by adding the new property <code>realErrorMessage</code> that exposes the message exactly as it was provided and now matches the value that would be displayed to users in traditional forms.</p>"},{"location":"migration/wsc30/javascript/#example-code","title":"Example Code","text":"<pre><code>define(['Ajax'], function(Ajax) {\n return {\n // ...\n _ajaxFailure: function(responseData, responseText, xhr, requestData) {\n console.log(responseData.realErrorMessage);\n }\n // ...\n };\n});\n</code></pre>"},{"location":"migration/wsc30/javascript/#simplified-form-submit-in-dialogs","title":"Simplified Form Submit in Dialogs","text":"<p>Forms embedded in dialogs often do not contain the HTML <code><form></code>-element and instead rely on JavaScript click- and key-handlers to emulate a <code><form></code>-like submit behavior. This has spawned a great amount of nearly identical implementations that all aim to handle the form submit through the <code>Enter</code>-key, still leaving some dialogs behind.</p> <p>WoltLab Suite 3.1 offers automatic form submit that is enabled through a set of specific conditions and data attributes:</p> <ol> <li>There must be a submit button that matches the selector <code>.formSubmit > input[type=\"submit\"], .formSubmit > button[data-type=\"submit\"]</code>.</li> <li>The dialog object provided to <code>UiDialog.open()</code> implements the method <code>_dialogSubmit()</code>.</li> <li>Input fields require the attribute <code>data-dialog-submit-on-enter=\"true\"</code> to be set, the <code>type</code> must be one of <code>number</code>, <code>password</code>, <code>search</code>, <code>tel</code>, <code>text</code> or <code>url</code>.</li> </ol> <p>Clicking on the submit button or pressing the <code>Enter</code>-key in any watched input field will start the submit process. This is done automatically and does not require a manual interaction in your code, therefore you should not bind any click listeners on the submit button yourself.</p> <p>Any input field with the <code>required</code> attribute set will be validated to contain a non-empty string after processing the value with <code>String.prototype.trim()</code>. An empty field will abort the submit process and display a visible error message next to the offending field.</p>"},{"location":"migration/wsc30/javascript/#helper-function-for-inline-error-messages","title":"Helper Function for Inline Error Messages","text":"<p>Displaying inline error messages on-the-fly required quite a few DOM operations that were quite simple but also super repetitive and thus error-prone when incorrectly copied over. The global helper function <code>elInnerError()</code> was added to provide a simple and consistent behavior of inline error messages.</p> <p>You can display an error message by invoking <code>elInnerError(elementRef, \"Your Error Message\")</code>, it will insert a new <code><small class=\"innerError\"></code> and sets the given message. If there is already an inner error present, then the message will be replaced instead.</p> <p>Hiding messages is done by setting the 2nd parameter to <code>false</code> or an empty string:</p> <ul> <li><code>elInnerError(elementRef, false)</code></li> <li><code>elInnerError(elementRef, '')</code></li> </ul> <p>The special values <code>null</code> and <code>undefined</code> are supported too, but their usage is discouraged, because they make it harder to understand the intention by reading the code:</p> <ul> <li><code>elInnerError(elementRef, null)</code></li> <li><code>elInnerError(elementRef)</code></li> </ul>"},{"location":"migration/wsc30/javascript/#example-code_1","title":"Example Code","text":"<pre><code>require(['Language'], function(Language)) {\n var input = elBySel('input[type=\"text\"]');\n if (input.value.trim() === '') {\n // displays a new inline error or replaces the message if there is one already\n elInnerError(input, Language.get('wcf.global.form.error.empty'));\n }\n else {\n // removes the inline error if it exists\n elInnerError(input, false);\n }\n\n // the above condition is equivalent to this:\n elInnerError(input, (input.value.trim() === '' ? Language.get('wcf.global.form.error.empty') : false));\n}\n</code></pre>"},{"location":"migration/wsc30/package/","title":"Migrating from WSC 3.0 - Package Components","text":""},{"location":"migration/wsc30/package/#cronjob-scheduler-uses-server-timezone","title":"Cronjob Scheduler uses Server Timezone","text":"<p>The execution time of cronjobs was previously calculated based on the coordinated universal time (UTC). This was changed in WoltLab Suite 3.1 to use the server timezone or, to be precise, the default timezone set in the administration control panel.</p>"},{"location":"migration/wsc30/package/#exclude-pages-from-becoming-a-landing-page","title":"Exclude Pages from becoming a Landing Page","text":"<p>Some pages do not qualify as landing page, because they're designed around specific expectations that aren't matched in all cases. Examples include the user control panel and its sub-pages that cannot be accessed by guests and will therefore break the landing page for those. While it is somewhat to be expected from control panel pages, there are enough pages that fall under the same restrictions, but aren't easily recognized as such by an administrator.</p> <p>You can exclude these pages by adding <code><excludeFromLandingPage>1</excludeFromLandingPage></code> (case-sensitive) to the relevant pages in your <code>page.xml</code>.</p>"},{"location":"migration/wsc30/package/#example-code","title":"Example Code","text":"<pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/tornado/page.xsd\">\n <import>\n <page identifier=\"com.example.foo.Bar\">\n <!-- ... -->\n <excludeFromLandingPage>1</excludeFromLandingPage>\n <!-- ... -->\n </page>\n </import>\n</data>\n</code></pre>"},{"location":"migration/wsc30/package/#new-package-installation-plugin-for-media-providers","title":"New Package Installation Plugin for Media Providers","text":"<p>Please refer to the documentation of the <code>mediaProvider.xml</code> to learn more.</p>"},{"location":"migration/wsc30/package/#limited-forward-compatibility-for-plugins","title":"Limited Forward-Compatibility for Plugins","text":"<p>Please refer to the documentation of the <code><compatibility></code> tag in the <code>package.xml</code>.</p>"},{"location":"migration/wsc30/php/","title":"Migrating from WSC 3.0 - PHP","text":""},{"location":"migration/wsc30/php/#approval-system-for-comments","title":"Approval-System for Comments","text":"<p>Comments can now be set to require approval by a moderator before being published. This feature is disabled by default if you do not provide a permission in the manager class, enabling it requires a new permission that has to be provided in a special property of your manage implementation.</p> files/lib/system/comment/manager/ExampleCommentManager.class.php<pre><code><?php\nclass ExampleCommentManager extends AbstractCommentManager {\n protected $permissionAddWithoutModeration = 'foo.bar.example.canAddCommentWithoutModeration';\n}\n</code></pre>"},{"location":"migration/wsc30/php/#raw-html-in-user-activity-events","title":"Raw HTML in User Activity Events","text":"<p>User activity events were previously encapsulated inside <code><div class=\"htmlContent\">\u2026</div></code>, with impacts on native elements such as lists. You can now disable the class usage by defining your event as raw HTML:</p> files/lib/system/user/activity/event/ExampleUserActivityEvent.class.php<pre><code><?php\nclass ExampleUserActivityEvent {\n // enables raw HTML for output, defaults to `false`\n protected $isRawHtml = true;\n}\n</code></pre>"},{"location":"migration/wsc30/php/#permission-to-view-likes-of-an-object","title":"Permission to View Likes of an Object","text":"<p>Being able to view the like summary of an object was restricted to users that were able to like the object itself. This creates situations where the object type in general is likable, but the particular object cannot be liked by the current users, while also denying them to view the like summary (but it gets partly exposed through the footer note/summary!).</p> <p>Implement the interface <code>\\wcf\\data\\like\\IRestrictedLikeObjectTypeProvider</code> in your object provider to add support for this new permission check.</p> files/lib/data/example/LikeableExampleProvider.class.php<pre><code><?php\nclass LikeableExampleProvider extends ExampleProvider implements IRestrictedLikeObjectTypeProvider, IViewableLikeProvider {\n public function canViewLikes(ILikeObject $object) {\n // perform your permission checks here\n return true;\n }\n}\n</code></pre>"},{"location":"migration/wsc30/php/#developer-tools-sync-feature","title":"Developer Tools: Sync Feature","text":"<p>The synchronization feature of the newly added developer tools works by invoking a package installation plugin (PIP) outside of a regular installation, while simulating the basic environment that is already exposed by the API.</p> <p>However, not all PIPs qualify for this kind of execution, especially because it could be invoked multiple times in a row by the user. This is solved by requiring a special marking for PIPs that have no side-effects (= idempotent) when invoked any amount of times with the same arguments.</p> <p>There's another feature that allows all matching PIPs to be executed in a row using a single button click. In order to solve dependencies on other PIPs, any implementing PIP must also provide the method <code>getSyncDependencies()</code> that returns the dependent PIPs in an arbitrary order.</p> files/lib/data/package/plugin/ExamplePackageInstallationPlugin.class.php<pre><code><?php\nclass ExamplePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin implements IIdempotentPackageInstallationPlugin {\n public static function getSyncDependencies() {\n // provide a list of dependent PIPs in arbitrary order\n return [];\n }\n}\n</code></pre>"},{"location":"migration/wsc30/php/#media-providers","title":"Media Providers","text":"<p>Media providers were added through regular SQL queries in earlier versions, but this is neither convenient, nor did it offer a reliable method to update an existing provider. WoltLab Suite 3.1 adds a new <code>mediaProvider</code>-PIP that also offers a <code>className</code> parameter to off-load the result evaluation and HTML generation.</p>"},{"location":"migration/wsc30/php/#example-implementation","title":"Example Implementation","text":"mediaProvider.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/tornado/mediaProvider.xsd\">\n <import>\n <provider name=\"example\">\n <title>Example Provider</title>\n <regex>https?://example.com/watch?v=(?P<ID>[a-zA-Z0-9])</regex>\n <className>wcf\\system\\bbcode\\media\\provider\\ExampleBBCodeMediaProvider</className>\n </provider>\n </import>\n</data>\n</code></pre>"},{"location":"migration/wsc30/php/#php-callback","title":"PHP Callback","text":"<p>The full match is provided for <code>$url</code>, while any capture groups from the regular expression are assigned to <code>$matches</code>.</p> <pre><code><?php\nclass ExampleBBCodeMediaProvider implements IBBCodeMediaProvider {\n public function parse($url, array $matches = []) {\n return \"final HTML output\";\n }\n}\n</code></pre>"},{"location":"migration/wsc30/php/#re-evaluate-html-messages","title":"Re-Evaluate HTML Messages","text":"<p>You need to manually set the disallowed bbcodes in order to avoid unintentional bbcode evaluation. Please see this commit for a reference implementation inside worker processes.</p> <p>The HtmlInputProcessor only supported two ways to handle an existing HTML message:</p> <ol> <li>Load the string through <code>process()</code> and run it through the validation and sanitation process, both of them are rather expensive operations and do not qualify for rebuild data workers.</li> <li>Detect embedded content using <code>processEmbeddedContent()</code> which bypasses most tasks that are carried out by <code>process()</code> which aren't required, but does not allow a modification of the message.</li> </ol> <p>The newly added method <code>reprocess($message, $objectType, $objectID)</code> solves this short-coming by offering a full bbcode and text re-evaluation while bypassing any input filters, assuming that the input HTML was already filtered previously.</p>"},{"location":"migration/wsc30/php/#example-usage","title":"Example Usage","text":"<pre><code><?php\n// rebuild data workers tend to contain code similar to this:\nforeach ($this->objectList as $message) {\n // ...\n if (!$message->enableHtml) {\n // ...\n }\n else {\n // OLD:\n $this->getHtmlInputProcessor()->processEmbeddedContent($message->message, 'com.example.foo.message', $message->messageID);\n\n // REPLACE WITH:\n $this->getHtmlInputProcessor()->reprocess($message->message, 'com.example.foo.message', $message->messageID);\n $data['message'] = $this->getHtmlInputProcessor()->getHtml();\n }\n // ...\n}\n</code></pre>"},{"location":"migration/wsc30/templates/","title":"Migrating from WSC 3.0 - Templates","text":""},{"location":"migration/wsc30/templates/#comment-system-overhaul","title":"Comment-System Overhaul","text":"<p>Unfortunately, there has been a breaking change related to the creation of comments. You need to apply the changes below before being able to create new comments.</p>"},{"location":"migration/wsc30/templates/#adding-comments","title":"Adding Comments","text":"<p>Existing implementations need to include a new template right before including the generic <code>commentList</code> template.</p> <pre><code><ul id=\"exampleCommentList\" class=\"commentList containerList\" data-...>\n {include file='commentListAddComment' wysiwygSelector='exampleCommentListAddComment'}\n {include file='commentList'}\n</ul>\n</code></pre>"},{"location":"migration/wsc30/templates/#redesigned-acp-user-list","title":"Redesigned ACP User List","text":"<p>Custom interaction buttons were previously added through the template event <code>rowButtons</code> and were merely a link-like element with an icon inside. This is still valid and supported for backwards-compatibility, but it is recommend to adapt to the new drop-down-style options using the new template event <code>dropdownItems</code>.</p> <pre><code><!-- button for usage with the `rowButtons` event -->\n<span class=\"icon icon16 fa-list jsTooltip\" title=\"Button Title\"></span>\n\n<!-- new drop-down item for the `dropdownItems` event -->\n<li><a href=\"#\" class=\"jsMyButton\">Button Title</a></li>\n</code></pre>"},{"location":"migration/wsc30/templates/#sidebar-toogle-buttons-on-mobile-device","title":"Sidebar Toogle-Buttons on Mobile Device","text":"<p>You cannot override the button label for sidebars containing navigation menus.</p> <p>The page sidebars are automatically collapsed and presented as one or, when both sidebar are present, two condensed buttons. They use generic sidebar-related labels when open or closed, with the exception of embedded menus which will change the button label to read \"Show/Hide Navigation\".</p> <p>You can provide a custom label before including the sidebars by assigning the new labels to a few special variables:</p> <pre><code>{assign var='__sidebarLeftShow' value='Show Left Sidebar'}\n{assign var='__sidebarLeftHide' value='Hide Left Sidebar'}\n{assign var='__sidebarRightShow' value='Show Right Sidebar'}\n{assign var='__sidebarRightHide' value='Hide Right Sidebar'}\n</code></pre>"},{"location":"migration/wsc31/form-builder/","title":"Migrating from WSC 3.1 - Form Builder","text":""},{"location":"migration/wsc31/form-builder/#example-two-text-form-fields","title":"Example: Two Text Form Fields","text":"<p>As the first example, the pre-WoltLab Suite Core 5.2 versions of the forms to add and edit persons from the first part of the tutorial series will be updated to the new form builder API. This form is the perfect first examples as it is very simple with only two text fields whose only restriction is that they have to be filled out and that their values may not be longer than 255 characters each.</p> <p>As a reminder, here are the two relevant PHP files and the relevant template file:</p> files/lib/acp/form/PersonAddForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractForm;\nuse wcf\\system\\exception\\UserInputException;\nuse wcf\\system\\WCF;\nuse wcf\\util\\StringUtil;\n\n/**\n * Shows the form to create a new person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonAddForm extends AbstractForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.add';\n\n /**\n * first name of the person\n * @var string\n */\n public $firstName = '';\n\n /**\n * last name of the person\n * @var string\n */\n public $lastName = '';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'action' => 'add',\n 'firstName' => $this->firstName,\n 'lastName' => $this->lastName\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function readFormParameters() {\n parent::readFormParameters();\n\n if (isset($_POST['firstName'])) $this->firstName = StringUtil::trim($_POST['firstName']);\n if (isset($_POST['lastName'])) $this->lastName = StringUtil::trim($_POST['lastName']);\n }\n\n /**\n * @inheritDoc\n */\n public function save() {\n parent::save();\n\n $this->objectAction = new PersonAction([], 'create', [\n 'data' => array_merge($this->additionalFields, [\n 'firstName' => $this->firstName,\n 'lastName' => $this->lastName\n ])\n ]);\n $this->objectAction->executeAction();\n\n $this->saved();\n\n // reset values\n $this->firstName = '';\n $this->lastName = '';\n\n // show success message\n WCF::getTPL()->assign('success', true);\n }\n\n /**\n * @inheritDoc\n */\n public function validate() {\n parent::validate();\n\n // validate first name\n if (empty($this->firstName)) {\n throw new UserInputException('firstName');\n }\n if (mb_strlen($this->firstName) > 255) {\n throw new UserInputException('firstName', 'tooLong');\n }\n\n // validate last name\n if (empty($this->lastName)) {\n throw new UserInputException('lastName');\n }\n if (mb_strlen($this->lastName) > 255) {\n throw new UserInputException('lastName', 'tooLong');\n }\n }\n}\n</code></pre> files/lib/acp/form/PersonEditForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractForm;\nuse wcf\\system\\exception\\IllegalLinkException;\nuse wcf\\system\\WCF;\n\n/**\n * Shows the form to edit an existing person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonEditForm extends PersonAddForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person';\n\n /**\n * edited person object\n * @var Person\n */\n public $person = null;\n\n /**\n * id of the edited person\n * @var integer\n */\n public $personID = 0;\n\n /**\n * @inheritDoc\n */\n public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'action' => 'edit',\n 'person' => $this->person\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function readData() {\n parent::readData();\n\n if (empty($_POST)) {\n $this->firstName = $this->person->firstName;\n $this->lastName = $this->person->lastName;\n }\n }\n\n /**\n * @inheritDoc\n */\n public function readParameters() {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) $this->personID = intval($_REQUEST['id']);\n $this->person = new Person($this->personID);\n if (!$this->person->personID) {\n throw new IllegalLinkException();\n }\n }\n\n /**\n * @inheritDoc\n */\n public function save() {\n AbstractForm::save();\n\n $this->objectAction = new PersonAction([$this->person], 'update', [\n 'data' => array_merge($this->additionalFields, [\n 'firstName' => $this->firstName,\n 'lastName' => $this->lastName\n ])\n ]);\n $this->objectAction->executeAction();\n\n $this->saved();\n\n // show success message\n WCF::getTPL()->assign('success', true);\n }\n}\n</code></pre> acptemplates/personAdd.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.'|concat:$action}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.{$action}{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonList'}{/link}\" class=\"button\"><span class=\"icon icon16 fa-list\"></span> <span>{lang}wcf.acp.menu.link.person.list{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{include file='formError'}\n\n{if $success|isset}\n <p class=\"success\">{lang}wcf.global.success.{$action}{/lang}</p>\n{/if}\n\n<form method=\"post\" action=\"{if $action == 'add'}{link controller='PersonAdd'}{/link}{else}{link controller='PersonEdit' object=$person}{/link}{/if}\">\n <div class=\"section\">\n <dl{if $errorField == 'firstName'} class=\"formError\"{/if}>\n <dt><label for=\"firstName\">{lang}wcf.person.firstName{/lang}</label></dt>\n <dd>\n <input type=\"text\" id=\"firstName\" name=\"firstName\" value=\"{$firstName}\" required autofocus maxlength=\"255\" class=\"long\">\n {if $errorField == 'firstName'}\n <small class=\"innerError\">\n {if $errorType == 'empty'}\n {lang}wcf.global.form.error.empty{/lang}\n {else}\n {lang}wcf.acp.person.firstName.error.{$errorType}{/lang}\n {/if}\n </small>\n {/if}\n </dd>\n </dl>\n\n <dl{if $errorField == 'lastName'} class=\"formError\"{/if}>\n <dt><label for=\"lastName\">{lang}wcf.person.lastName{/lang}</label></dt>\n <dd>\n <input type=\"text\" id=\"lastName\" name=\"lastName\" value=\"{$lastName}\" required maxlength=\"255\" class=\"long\">\n {if $errorField == 'lastName'}\n <small class=\"innerError\">\n {if $errorType == 'empty'}\n {lang}wcf.global.form.error.empty{/lang}\n {else}\n {lang}wcf.acp.person.lastName.error.{$errorType}{/lang}\n {/if}\n </small>\n {/if}\n </dd>\n </dl>\n\n {event name='dataFields'}\n </div>\n\n {event name='sections'}\n\n <div class=\"formSubmit\">\n <input type=\"submit\" value=\"{lang}wcf.global.button.submit{/lang}\" accesskey=\"s\">\n {@SECURITY_TOKEN_INPUT_TAG}\n </div>\n</form>\n\n{include file='footer'}\n</code></pre> <p>Updating the template is easy as the complete form is replace by a single line of code:</p> acptemplates/personAdd.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.'|concat:$action}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.{$action}{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonList'}{/link}\" class=\"button\"><span class=\"icon icon16 fa-list\"></span> <span>{lang}wcf.acp.menu.link.person.list{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{@$form->getHtml()}\n\n{include file='footer'}\n</code></pre> <p><code>PersonEditForm</code> also becomes much simpler: only the edited <code>Person</code> object must be read:</p> files/lib/acp/form/PersonEditForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\exception\\IllegalLinkException;\n\n/**\n * Shows the form to edit an existing person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonEditForm extends PersonAddForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person';\n\n /**\n * @inheritDoc\n */\n public function readParameters() {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) {\n $this->formObject = new Person(intval($_REQUEST['id']));\n if (!$this->formObject->personID) {\n throw new IllegalLinkException();\n }\n }\n }\n}\n</code></pre> <p>Most of the work is done in <code>PersonAddForm</code>:</p> files/lib/acp/form/PersonAddForm.class.php <pre><code><?php\nnamespace wcf\\acp\\form;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\container\\FormContainer;\nuse wcf\\system\\form\\builder\\field\\TextFormField;\n\n/**\n * Shows the form to create a new person.\n * \n * @author Matthias Schmidt\n * @copyright 2001-2019 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonAddForm extends AbstractFormBuilderForm {\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.add';\n\n /**\n * @inheritDoc\n */\n public $formAction = 'create';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public $objectActionClass = PersonAction::class;\n\n /**\n * @inheritDoc\n */\n protected function createForm() {\n parent::createForm();\n\n $dataContainer = FormContainer::create('data')\n ->appendChildren([\n TextFormField::create('firstName')\n ->label('wcf.person.firstName')\n ->required()\n ->maximumLength(255),\n\n TextFormField::create('lastName')\n ->label('wcf.person.lastName')\n ->required()\n ->maximumLength(255)\n ]);\n\n $this->form->appendChild($dataContainer);\n }\n}\n</code></pre> <p>But, as you can see, the number of lines almost decreased by half. All changes are due to extending <code>AbstractFormBuilderForm</code>:</p> <ul> <li><code>$formAction</code> is added and set to <code>create</code> as the form is used to create a new person. In the edit form, <code>$formAction</code> has not to be set explicitly as it is done automatically if a <code>$formObject</code> is set.</li> <li><code>$objectActionClass</code> is set to <code>PersonAction::class</code> and is the class name of the used <code>AbstractForm::$objectAction</code> object to create and update the <code>Person</code> object.</li> <li><code>AbstractFormBuilderForm::createForm()</code> is overridden and the form contents are added: a form container representing the <code>div.section</code> element from the old version and the two form fields with the same ids and labels as before. The contents of the old <code>validate()</code> method is put into two method calls: <code>required()</code> to ensure that the form is filled out and <code>maximumLength(255)</code> to ensure that the names are not longer than 255 characters.</li> </ul>"},{"location":"migration/wsc31/like/","title":"Migrating from WSC 3.1 - Like System","text":""},{"location":"migration/wsc31/like/#introduction","title":"Introduction","text":"<p>With version 5.2 of WoltLab Suite Core the like system was completely replaced by the new reactions system. This makes it necessary to make some adjustments to existing code so that your plugin integrates completely into the new system. However, we have kept these adjustments as small as possible so that it is possible to use the reaction system with slight restrictions even without adjustments. </p>"},{"location":"migration/wsc31/like/#limitations-if-no-adjustments-are-made-to-the-existing-code","title":"Limitations if no adjustments are made to the existing code","text":"<p>If no adjustments are made to the existing code, the following functions are not available: * Notifications about reactions/likes * Recent Activity Events for reactions/likes</p>"},{"location":"migration/wsc31/like/#migration","title":"Migration","text":""},{"location":"migration/wsc31/like/#notifications","title":"Notifications","text":""},{"location":"migration/wsc31/like/#mark-notification-as-compatible","title":"Mark notification as compatible","text":"<p>Since there are no more likes with the new version, it makes no sense to send notifications about it. Instead of notifications about likes, notifications about reactions are now sent. However, this only changes the notification text and not the notification itself. To update the notification, we first add the interface <code>\\wcf\\data\\reaction\\object\\IReactionObject</code> to the <code>\\wcf\\data\\like\\object\\ILikeObject</code> object (e.g. in WoltLab Suite Forum we added the interface to the class <code>\\wbb\\data\\post\\LikeablePost</code>). After that the object is marked as \"compatible with WoltLab Suite Core 5.2\" and notifications about reactions are sent again. </p>"},{"location":"migration/wsc31/like/#language-variables","title":"Language Variables","text":"<p>Next, to display all reactions for the current notification in the notification text, we include the trait <code>\\wcf\\system\\user\\notification\\event\\TReactionUserNotificationEvent</code> in the user notification event class (typically named like <code>*LikeUserNotificationEvent</code>). These trait provides a new function that reads out and groups the reactions. The result of this function must now only be passed to the language variable. The name \"reactions\" is typically used as the variable name for the language variable. </p> <p>As a final step, we only need to change the language variables themselves. To ensure a consistent usability, the same formulations should be used as in the WoltLab Suite Core. </p>"},{"location":"migration/wsc31/like/#english","title":"English","text":"<p><code>{prefix}.like.title</code> <pre><code>Reaction to a {objectName}\n</code></pre></p> <p><code>{prefix}.like.title.stacked</code></p> <pre><code>{#$count} users reacted to your {objectName}\n</code></pre> <p><code>{prefix}.like.message</code> <pre><code>{@$author->getAnchorTag()} reacted to your {objectName} ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre></p> <p><code>{prefix}.like.message.stacked</code></p> <pre><code>{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} others{/if} reacted to your {objectName} ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre> <p><code>wcf.user.notification.{objectTypeName}.like.notification.like</code> <pre><code>Notify me when someone reacted to my {objectName}\n</code></pre></p>"},{"location":"migration/wsc31/like/#german","title":"German","text":"<p><code>{prefix}.like.title</code> <pre><code>Reaktion auf einen {objectName}\n</code></pre></p> <p><code>{prefix}.like.title.stacked</code></p> <pre><code>{#$count} Benutzern haben auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert\n</code></pre> <p><code>{prefix}.like.message</code> <pre><code>{@$author->getAnchorTag()} hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre></p> <p><code>{prefix}.like.message.stacked</code></p> <pre><code>{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere{/if} haben auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}).\n</code></pre> <p><code>wcf.user.notification.{object_type_name}.like.notification.like</code> <pre><code>Jemandem hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}dein(en){else}Ihr(en){/if} {objectName} reagiert\n</code></pre></p>"},{"location":"migration/wsc31/like/#recent-activity","title":"Recent Activity","text":"<p>To adjust entries in the Recent Activity, only three small steps are necessary. First we pass the concrete reaction to the language variable, so that we can use the reaction object there. To do this, we add the following variable to the text of the <code>\\wcf\\system\\user\\activity\\event\\IUserActivityEvent</code> object: <code>$event->reactionType</code>. Typically we name the variable <code>reactionType</code>. In the second step, we mark the event as compatible. Therefore we set the parameter <code>supportsReactions</code> in the <code>objectType.xml</code> to <code>1</code>. So for example the entry looks like this:</p> objectType.xml<pre><code><type>\n <name>com.woltlab.example.likeableObject.recentActivityEvent</name>\n <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>\n <classname>wcf\\system\\user\\activity\\event\\LikeableObjectUserActivityEvent</classname>\n <supportsReactions>1</supportsReactions>\n</type>\n</code></pre> <p>Finally we modify our language variable. To ensure a consistent usability, the same formulations should be used as in the WoltLab Suite Core.</p>"},{"location":"migration/wsc31/like/#english_1","title":"English","text":"<p><code>wcf.user.recentActivity.{object_type_name}.recentActivityEvent</code> <pre><code>Reaction ({objectName})\n</code></pre></p> <p>Your language variable for the recent activity text <pre><code>Reacted with <span title=\"{$reactionType->getTitle()}\" class=\"jsTooltip\">{@$reactionType->renderIcon()}</span> to the {objectName}.\n</code></pre></p>"},{"location":"migration/wsc31/like/#german_1","title":"German","text":"<p><code>wcf.user.recentActivity.{objectTypeName}.recentActivityEvent</code> <pre><code>Reaktion ({objectName})\n</code></pre></p> <p>Your language variable for the recent activity text <pre><code>Hat mit <span title=\"{$reactionType->getTitle()}\" class=\"jsTooltip\">{@$reactionType->renderIcon()}</span> auf {objectName} reagiert.\n</code></pre></p>"},{"location":"migration/wsc31/like/#comments","title":"Comments","text":"<p>If comments send notifications, they must also be updated. The language variables are changed in the same way as described in the section Notifications / Language. After that comment must be marked as compatible. Therefore we set the parameter <code>supportsReactions</code> in the <code>objectType.xml</code> to <code>1</code>. So for example the entry looks like this: </p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.objectComment.response.like.notification</name>\n <definitionname>com.woltlab.wcf.notification.objectType</definitionname>\n <classname>wcf\\system\\user\\notification\\object\\type\\LikeUserNotificationObjectType</classname>\n <category>com.woltlab.example</category>\n <supportsReactions>1</supportsReactions>\n</type>\n</code></pre>"},{"location":"migration/wsc31/like/#forward-compatibility","title":"Forward Compatibility","text":"<p>So that these changes also work in older versions of WoltLab Suite Core, the used classes and traits were backported with WoltLab Suite Core 3.0.22 and WoltLab Suite Core 3.1.10.</p>"},{"location":"migration/wsc31/php/","title":"Migrating from WSC 3.1 - PHP","text":""},{"location":"migration/wsc31/php/#form-builder","title":"Form Builder","text":"<p>WoltLab Suite Core 5.2 introduces a new, simpler and quicker way of creating forms: form builder. You can find examples of how to migrate existing forms to form builder here.</p> <p>In the near future, to ensure backwards compatibility within WoltLab packages, we will only use form builder for new forms or for major rewrites of existing forms that would break backwards compatibility anyway.</p>"},{"location":"migration/wsc31/php/#like-system","title":"Like System","text":"<p>WoltLab Suite Core 5.2 replaced the like system with the reaction system. You can find the migration guide here.</p>"},{"location":"migration/wsc31/php/#user-content-providers","title":"User Content Providers","text":"<p>User content providers help the WoltLab Suite to find user generated content. They provide a class with which you can find content from a particular user and delete objects.</p>"},{"location":"migration/wsc31/php/#php-class","title":"PHP Class","text":"<p>First, we create the PHP class that provides our interface to provide the data. The class must implement interface <code>wcf\\system\\user\\content\\provider\\IUserContentProvider</code> in any case. Mostly we process data which is based on <code>wcf\\data\\DatabaseObject</code>. In this case, the WoltLab Suite provides an abstract class <code>wcf\\system\\user\\content\\provider\\AbstractDatabaseUserContentProvider</code> that can be used to automatically generates the standardized classes to generate the list and deletes objects via the DatabaseObjectAction. For example, if we would create a content provider for comments, the class would look like this: </p> files/lib/system/user/content/provider/CommentUserContentProvider.class.php<pre><code><?php\nnamespace wcf\\system\\user\\content\\provider;\nuse wcf\\data\\comment\\Comment;\n\n/**\n * User content provider for comments.\n *\n * @author Joshua Ruesweg\n * @copyright 2001-2018 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\User\\Content\\Provider\n * @since 5.2\n */\nclass CommentUserContentProvider extends AbstractDatabaseUserContentProvider {\n /**\n * @inheritdoc\n */\n public static function getDatabaseObjectClass() {\n return Comment::class;\n }\n}\n</code></pre>"},{"location":"migration/wsc31/php/#object-type","title":"Object Type","text":"<p>Now the appropriate object type must be created for the class. This object type must be from the definition <code>com.woltlab.wcf.content.userContentProvider</code> and include the previous created class as FQN in the parameter <code>classname</code>. Also the following parameters can be used in the object type: </p>"},{"location":"migration/wsc31/php/#nicevalue","title":"<code>nicevalue</code>","text":"<p>Optional</p> <p>The nice value is used to determine the order in which the remove content worker are execute the provider. Content provider with lower nice values are executed first.</p>"},{"location":"migration/wsc31/php/#hidden","title":"<code>hidden</code>","text":"<p>Optional</p> <p>Specifies whether or not this content provider can be actively selected in the Content Remove Worker. If it cannot be selected, it will not be executed automatically! </p>"},{"location":"migration/wsc31/php/#requiredobjecttype","title":"<code>requiredobjecttype</code>","text":"<p>Optional</p> <p>The specified list of comma-separated object types are automatically removed during content removal when this object type is being removed. Attention: The order of removal is undefined by default, specify a <code>nicevalue</code> if the order is important.</p>"},{"location":"migration/wsc31/php/#php-database-api","title":"PHP Database API","text":"<p>WoltLab Suite 5.2 introduces a new way to update the database scheme: database PHP API.</p>"},{"location":"migration/wsc52/libraries/","title":"Migrating from WoltLab Suite 5.2 - Third Party Libraries","text":""},{"location":"migration/wsc52/libraries/#scss-compiler","title":"SCSS Compiler","text":"<p>WoltLab Suite Core 5.3 upgrades the bundled SCSS compiler from <code>leafo/scssphp</code> 0.7.x to <code>scssphp/scssphp</code> 1.1.x. With the updated composer package name the SCSS compiler also received updated namespaces. WoltLab Suite Core adds a compatibility layer that maps the old namespace to the new namespace. The classes themselves appear to be drop-in compatible. Exceptions cannot be mapped using this compatibility layer, any <code>catch</code> blocks catching a specific Exception within the <code>Leafo</code> namespace will need to be adjusted.</p> <p>More details can be found in the Pull Request WoltLab/WCF#3415.</p>"},{"location":"migration/wsc52/libraries/#guzzle","title":"Guzzle","text":"<p>WoltLab Suite Core 5.3 ships with a bundled version of Guzzle 6. Going forward using Guzzle is the recommended way to perform HTTP requests. The <code>\\wcf\\util\\HTTPRequest</code> class should no longer be used and transparently uses Guzzle under the hood.</p> <p>Use <code>\\wcf\\system\\io\\HttpFactory</code> to retrieve a correctly configured <code>GuzzleHttp\\ClientInterface</code>.</p> <p>Please note that it is recommended to explicitely specify a <code>sink</code> when making requests, due to a PHP / Guzzle bug. Have a look at the implementation in WoltLab/WCF for an example.</p>"},{"location":"migration/wsc52/php/","title":"Migrating from WoltLab Suite 5.2 - PHP","text":""},{"location":"migration/wsc52/php/#comments","title":"Comments","text":"<p>The <code>ICommentManager::isContentAuthor(Comment|CommentResponse): bool</code> method was added. A default implementation that always returns <code>false</code> is available when inheriting from <code>AbstractCommentManager</code>.</p> <p>It is strongly recommended to implement <code>isContentAuthor</code> within your custom comment manager. An example implementation can be found in <code>ArticleCommentManager</code>.</p>"},{"location":"migration/wsc52/php/#event-listeners","title":"Event Listeners","text":"<p>The <code>AbstractEventListener</code> class was added. <code>AbstractEventListener</code> contains an implementation of <code>execute()</code> that will dispatch the event handling to dedicated methods based on the <code>$eventName</code> and, in case of the event object being an <code>AbstractDatabaseObjectAction</code>, the action name.</p> <p>Find the details of the dispatch behavior within the class comment of <code>AbstractEventListener</code>.</p>"},{"location":"migration/wsc52/php/#email-activation","title":"Email Activation","text":"<p>Starting with WoltLab Suite 5.3 the user activation status is independent of the email activation status. A user can be activated even though their email address has not been confirmed, preventing emails being sent to these users. Going forward the new <code>User::isEmailConfirmed()</code> method should be used to check whether sending automated emails to this user is acceptable. If you need to check the user's activation status you should use the new method <code>User::pendingActivation()</code> instead of relying on <code>activationCode</code>. To check, which type of activation is missing, you can use the new methods <code>User::requiresEmailActivation()</code> and <code>User::requiresAdminActivation()</code>.</p>"},{"location":"migration/wsc52/php/#addform","title":"<code>*AddForm</code>","text":"<p>WoltLab Suite 5.3 provides a new framework to allow the administrator to easily edit newly created objects by adding an edit link to the success message. To support this edit link two small changes are required within your <code>*AddForm</code>.</p> <ol> <li> <p>Update the template.</p> <p>Replace: <pre><code>{include file='formError'}\n\n{if $success|isset}\n <p class=\"success\">{lang}wcf.global.success.{$action}{/lang}</p>\n{/if}\n</code></pre></p> <p>With: <pre><code>{include file='formNotice'}\n</code></pre></p> </li> <li> <p>Expose <code>objectEditLink</code> to the template.</p> <p>Example (<code>$object</code> being the newly created object): <pre><code>WCF::getTPL()->assign([\n 'success' => true,\n 'objectEditLink' => LinkHandler::getInstance()->getControllerLink(ObjectEditForm::class, ['id' => $object->objectID]),\n]);\n</code></pre></p> </li> </ol>"},{"location":"migration/wsc52/php/#user-generated-links","title":"User Generated Links","text":"<p>It is recommended by search engines to mark up links within user generated content using the <code>rel=\"ugc\"</code> attribute to indicate that they might be less trustworthy or spammy.</p> <p>WoltLab Suite 5.3 will automatically sets that attribute on external links during message output processing. Set the new <code>HtmlOutputProcessor::$enableUgc</code> property to <code>false</code> if the type of message is not user-generated content, but restricted to a set of trustworthy users. An example of such a type of message would be official news articles.</p> <p>If you manually generate links based off user input you need to specify the attribute yourself. The <code>$isUgc</code> attribute was added to <code>StringUtil::getAnchorTag(string, string, bool, bool): string</code>, allowing you to easily generate a correct anchor tag.</p> <p>If you need to specify additional HTML attributes for the anchor tag you can use the new <code>StringUtil::getAnchorTagAttributes(string, bool): string</code> method to generate the anchor attributes that are dependent on the target URL. Specifically the attributes returned are the <code>class=\"externalURL\"</code> attribute, the <code>rel=\"\u2026\"</code> attribute and the <code>target=\"\u2026\"</code> attribute.</p> <p>Within the template the <code>{anchorAttributes}</code> template plugin is newly available.</p>"},{"location":"migration/wsc52/php/#resource-management-when-scaling-images","title":"Resource Management When Scaling Images","text":"<p>It was discovered that the code holds references to scaled image resources for an unnecessarily long time, taking up memory. This becomes especially apparent when multiple images are scaled within a loop, reusing the same variable name for consecutive images. Unless the destination variable is explicitely cleared before processing the next image up to two images will be stored in memory concurrently. This possibly causes the request to exceed the memory limit or ImageMagick's internal resource limits, even if sufficient resources would have been available to scale the current image.</p> <p>Starting with WoltLab Suite 5.3 it is recommended to clear image handles as early as possible. The usual pattern of creating a thumbnail for an existing image would then look like this:</p> <pre><code><?php\nforeach ([ 200, 500 ] as $size) {\n $adapter = ImageHandler::getInstance()->getAdapter();\n $adapter->loadFile($src);\n $thumbnail = $adapter->createThumbnail(\n $size,\n $size,\n true\n );\n $adapter->writeImage($thumbnail, $destination);\n // New: Clear thumbnail as soon as possible to free up the memory.\n $thumbnail = null;\n}\n</code></pre> <p>Refer to WoltLab/WCF#3505 for additional details.</p>"},{"location":"migration/wsc52/php/#toggle-for-accelerated-mobile-pages-amp","title":"Toggle for Accelerated Mobile Pages (AMP)","text":"<p>Controllers delivering AMP versions of pages have to check for the new option <code>MODULE_AMP</code> and the templates of the non-AMP versions have to also check if the option is enabled before outputting the <code><link rel=\"amphtml\" /></code> element.</p>"},{"location":"migration/wsc52/templates/","title":"Migrating WoltLab Suite 5.2 - Templates and Languages","text":""},{"location":"migration/wsc52/templates/#jslang","title":"<code>{jslang}</code>","text":"<p>Starting with WoltLab Suite 5.3 the <code>{jslang}</code> template plugin is available. <code>{jslang}</code> works like <code>{lang}</code>, with the difference that the result is automatically encoded for use within a single quoted JavaScript string.</p> <p>Before:</p> <pre><code><script>\nrequire(['Language', /* \u2026 */], function(Language, /* \u2026 */) {\n Language.addObject({\n 'app.foo.bar': '{lang}app.foo.bar{/lang}',\n });\n\n // \u2026\n});\n</script>\n</code></pre> <p>After:</p> <pre><code><script>\nrequire(['Language', /* \u2026 */], function(Language, /* \u2026 */) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}',\n });\n\n // \u2026\n});\n</script>\n</code></pre>"},{"location":"migration/wsc52/templates/#template-plugins","title":"Template Plugins","text":"<p>The <code>{anchor}</code>, <code>{plural}</code>, and <code>{user}</code> template plugins have been added.</p>"},{"location":"migration/wsc52/templates/#notification-language-items","title":"Notification Language Items","text":"<p>In addition to using the new template plugins mentioned above, language items for notifications have been further simplified.</p> <p>As the whole notification is clickable now, all <code>a</code> elements have been replaced with <code>strong</code> elements in notification messages.</p> <p>The template code to output reactions has been simplified by introducing helper methods:</p> <pre><code>{* old *}\n{implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}\u00d7{#$count}{/implode}\n{* new *}\n{@$__wcf->getReactionHandler()->renderInlineList($reactions)}\n\n{* old *}\n<span title=\"{$like->getReactionType()->getTitle()}\" class=\"jsTooltip\">{@$like->getReactionType()->renderIcon()}</span>\n{* new *}\n{@$like->render()}\n</code></pre> <p>Similarly, showing labels is now also easier due to the new <code>render</code> method:</p> <pre><code>{* old *}\n<span class=\"label badge{if $label->getClassNames()} {$label->getClassNames()}{/if}\">{$label->getTitle()}</span>\n{* new *}\n{@$label->render()}\n</code></pre> <p>The commonly used template code</p> <pre><code>{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count != 1}{if $count == 2 && !$guestTimesTriggered} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3}{if !$guestTimesTriggered} and {else}, {/if} {@$authors[2]->getAnchorTag()}{/if}{/if}{if $guestTimesTriggered} and {if $guestTimesTriggered == 1}a guest{else}guests{/if}{/if}{else}{@$authors[0]->getAnchorTag()}{if $guestTimesTriggered},{else} and{/if} {#$others} other users {if $guestTimesTriggered}and {if $guestTimesTriggered == 1}a guest{else}guests{/if}{/if}{/if}\n</code></pre> <p>in stacked notification messages can be replaced with a new language item:</p> <pre><code>{@'wcf.user.notification.stacked.authorList'|language}\n</code></pre>"},{"location":"migration/wsc52/templates/#popovers","title":"Popovers","text":"<p>Popovers provide additional information of the linked object when a user hovers over a link. We unified the approach for such links:</p> <ol> <li>The relevant DBO class implements <code>wcf\\data\\IPopoverObject</code>.</li> <li>The relevant DBO action class implements <code>wcf\\data\\IPopoverAction</code> and the <code>getPopover()</code> method returns an array with popover content.</li> <li>Globally available, <code>WoltLabSuite/Core/Controller/Popover</code> is initialized with the relevant data.</li> <li>Links are created with the <code>anchor</code> template plugin with an additional <code>class</code> attribute whose value is the return value of <code>IPopoverObject::getPopoverLinkClass()</code>.</li> </ol> <p>Example:</p> files/lib/data/foo/Foo.class.php<pre><code>class Foo extends DatabaseObject implements IPopoverObject {\n public function getPopoverLinkClass() {\n return 'fooLink';\n }\n}\n</code></pre> files/lib/data/foo/FooAction.class.php<pre><code>class FooAction extends AbstractDatabaseObjectAction implements IPopoverAction {\n public function validateGetPopover() {\n // \u2026\n }\n\n public function getPopover() {\n return [\n 'template' => '\u2026',\n ];\n }\n}\n</code></pre> <pre><code>require(['WoltLabSuite/Core/Controller/Popover'], function(ControllerPopover) {\n ControllerPopover.init({\n className: 'fooLink',\n dboAction: 'wcf\\\\data\\\\foo\\\\FooAction',\n identifier: 'com.woltlab.wcf.foo'\n });\n});\n</code></pre> <pre><code>{anchor object=$foo class='fooLink'}\n</code></pre>"},{"location":"migration/wsc53/javascript/","title":"Migrating from WoltLab Suite 5.3 - TypeScript and JavaScript","text":""},{"location":"migration/wsc53/javascript/#typescript","title":"TypeScript","text":"<p>WoltLab Suite 5.4 introduces TypeScript support. Learn about consuming WoltLab Suite\u2019s types in the TypeScript section of the JavaScript API documentation.</p> <p>The JavaScript API documentation will be updated to properly take into account the changes that came with the new TypeScript support in the future. Existing AMD based modules have been migrated to TypeScript, but will expose the existing and known API.</p> <p>It is recommended that you migrate your custom packages to make use of TypeScript. It will make consuming newly written modules that properly leverage TypeScript\u2019s features much more pleasant and will also ease using existing modules due to proper autocompletion and type checking.</p>"},{"location":"migration/wsc53/javascript/#replacements-for-deprecated-components","title":"Replacements for Deprecated Components","text":"<p>The helper functions in <code>wcf.globalHelper.js</code> should not be used anymore but replaced by their native counterpart:</p> Function Native Replacement <code>elCreate(tag)</code> <code>document.createElement(tag)</code> <code>elRemove(el)</code> <code>el.remove()</code> <code>elShow(el)</code> <code>DomUtil.show(el)</code> <code>elHide(el)</code> <code>DomUtil.hide(el)</code> <code>elIsHidden(el)</code> <code>DomUtil.isHidden(el)</code> <code>elToggle(el)</code> <code>DomUtil.toggle(el)</code> <code>elAttr(el, \"attr\")</code> <code>el.attr</code> or <code>el.getAttribute(\"attr\")</code> <code>elData(el, \"data\")</code> <code>el.dataset.data</code> <code>elDataBool(element, \"data\")</code> <code>Core.stringToBool(el.dataset.data)</code> <code>elById(id)</code> <code>document.getElementById(id)</code> <code>elBySel(sel)</code> <code>document.querySelector(sel)</code> <code>elBySel(sel, el)</code> <code>el.querySelector(sel)</code> <code>elBySelAll(sel)</code> <code>document.querySelectorAll(sel)</code> <code>elBySelAll(sel, el)</code> <code>el.querySelectorAll(sel)</code> <code>elBySelAll(sel, el, callback)</code> <code>el.querySelectorAll(sel).forEach((el) => callback(el));</code> <code>elClosest(el, sel)</code> <code>el.closest(sel)</code> <code>elByClass(class)</code> <code>document.getElementsByClassName(class)</code> <code>elByClass(class, el)</code> <code>el.getElementsByClassName(class)</code> <code>elByTag(tag)</code> <code>document.getElementsByTagName(tag)</code> <code>elByTag(tag, el)</code> <code>el.getElementsByTagName(tag)</code> <code>elInnerError(el, message, isHtml)</code> <code>DomUtil.innerError(el, message, isHtml)</code> <p>Additionally, the following modules should also be replaced by their native counterpart:</p> Module Native Replacement <code>WoltLabSuite/Core/Dictionary</code> <code>Map</code> <code>WoltLabSuite/Core/List</code> <code>Set</code> <code>WoltLabSuite/Core/ObjectMap</code> <code>WeakMap</code> <p>For event listeners on click events, <code>WCF_CLICK_EVENT</code> is deprecated and should no longer be used. Instead, use <code>click</code> directly:</p> <pre><code>// before\nelement.addEventListener(WCF_CLICK_EVENT, this._click.bind(this));\n\n// after\nelement.addEventListener('click', (ev) => this._click(ev));\n</code></pre>"},{"location":"migration/wsc53/javascript/#wcfactiondelete-and-wcfactiontoggle","title":"<code>WCF.Action.Delete</code> and <code>WCF.Action.Toggle</code>","text":"<p><code>WCF.Action.Delete</code> and <code>WCF.Action.Toggle</code> were used for buttons to delete or enable/disable objects via JavaScript. In each template, <code>WCF.Action.Delete</code> or <code>WCF.Action.Toggle</code> instances had to be manually created for each object listing.</p> <p>With version 5.4 of WoltLab Suite, we have added a CSS selector-based global TypeScript module that only requires specific CSS classes to be added to the HTML structure for these buttons to work. Additionally, we have added a new <code>{objectAction}</code> template plugin, which generates these buttons reducing the amount of boilerplate template code.</p> <p>The required base HTML structure is as follows:</p> <ol> <li>A <code>.jsObjectActionContainer</code> element with a <code>data-object-action-class-name</code> attribute that contains the name of PHP class that executes the actions.</li> <li><code>.jsObjectActionObject</code> elements within <code>.jsObjectActionContainer</code> that represent the objects for which actions can be executed. Each <code>.jsObjectActionObject</code> element must have a <code>data-object-id</code> attribute with the id of the object.</li> <li><code>.jsObjectAction</code> elements within <code>.jsObjectActionObject</code> for each action with a <code>data-object-action</code> attribute with the name of the action. These elements can be generated with the <code>{objectAction}</code> template plugin for the <code>delete</code> and <code>toggle</code> action.</li> </ol> <p>Example:</p> <pre><code><table class=\"table jsObjectActionContainer\" {*\n *}data-object-action-class-name=\"wcf\\data\\foo\\FooAction\">\n <thead>\n <tr>\n {* \u2026 *}\n </tr>\n </thead>\n\n <tbody>\n {foreach from=$objects item=foo}\n <tr class=\"jsObjectActionObject\" data-object-id=\"{$foo->getObjectID()}\">\n <td class=\"columnIcon\">\n {objectAction action=\"toggle\" isDisabled=$foo->isDisabled}\n {objectAction action=\"delete\" objectTitle=$foo->getTitle()}\n {* \u2026 *}\n </td>\n {* \u2026 *}\n </tr>\n {/foreach}\n </tbody>\n</table>\n</code></pre> <p>Please refer to the documentation in <code>ObjectActionFunctionTemplatePlugin</code> for details and examples on how to use this template plugin.</p> <p>The relevant TypeScript module registering the event listeners on the object action buttons is <code>Ui/Object/Action</code>. When an action button is clicked, an AJAX request is sent using the PHP class name and action name. After the successful execution of the action, the page is either reloaded if the action button has a <code>data-object-action-success=\"reload\"</code> attribute or an event using the <code>EventHandler</code> module is fired using <code>WoltLabSuite/Core/Ui/Object/Action</code> as the identifier and the object action name. <code>Ui/Object/Action/Delete</code> and <code>Ui/Object/Action/Toggle</code> listen to these events and update the user interface depending on the execute action by removing the object or updating the toggle button, respectively.</p> <p>Converting from <code>WCF.Action.*</code> to the new approach requires minimal changes per template, as shown in the relevant pull request #4080.</p>"},{"location":"migration/wsc53/javascript/#wcftableemptytablehandler","title":"<code>WCF.Table.EmptyTableHandler</code>","text":"<p>When all objects in a table or list are deleted via their delete button or clipboard actions, an empty table or list can remain. Previously, <code>WCF.Table.EmptyTableHandler</code> had to be explicitly used in each template for these tables and lists to reload the page. As a TypeScript-based replacement for <code>WCF.Table.EmptyTableHandler</code> that is only initialized once globally, <code>WoltLabSuite/Core/Ui/Empty</code> was added. To use this new module, you only have to add the CSS class <code>jsReloadPageWhenEmpty</code> to the relevant HTML element. Once this HTML element no longer has child elements, the page is reloaded. To also cover scenarios in which there are fixed child elements that should not be considered when determining if there are no child elements, the <code>data-reload-page-when-empty=\"ignore\"</code> can be set for these elements.</p> <p>Examples:</p> <pre><code><table class=\"table\">\n <thead>\n <tr>\n {* \u2026 *}\n </tr>\n </thead>\n\n <tbody class=\"jsReloadPageWhenEmpty\">\n {foreach from=$objects item=object}\n <tr>\n {* \u2026 *}\n </tr>\n {/foreach}\n </tbody>\n</table>\n</code></pre> <pre><code><div class=\"section tabularBox messageGroupList\">\n <ol class=\"tabularList jsReloadPageWhenEmpty\">\n <li class=\"tabularListRow tabularListRowHead\" data-reload-page-when-empty=\"ignore\">\n {* \u2026 *}\n </li>\n\n {foreach from=$objects item=object}\n <li>\n {* \u2026 *}\n </li>\n {/foreach}\n </ol>\n</div>\n</code></pre>"},{"location":"migration/wsc53/libraries/","title":"Migrating from WoltLab Suite 5.3 - Third Party Libraries","text":""},{"location":"migration/wsc53/libraries/#guzzle","title":"Guzzle","text":"<p>The bundled Guzzle version was updated to Guzzle 7. No breaking changes are expected for simple uses. A detailed Guzzle migration guide can be found in the Guzzle documentation.</p> <p>The explicit <code>sink</code> that was recommended in the migration guide for WoltLab Suite 5.2 can now be removed, as the Guzzle issue #2735 was fixed in Guzzle 7.</p>"},{"location":"migration/wsc53/libraries/#emogrifier-css-inliner","title":"Emogrifier / CSS Inliner","text":"<p>The Emogrifier library was updated from version 2.2 to 5.0. This update comes with a breaking change, as the <code>Emogrifier</code> class was removed. With the updated Emogrifier library, the <code>CssInliner</code> class must be used instead.</p> <p>No compatibility layer was added for the <code>Emogrifier</code> class, as the Emogrifier library's purpose was to be used within the email subsystem of WoltLab Suite. In case you use Emogrifier directly within your own code, you will need to adjust the usage. Refer to the Emogrifier CHANGELOG and WoltLab/WCF #3738 if you need help making the necessary adjustments.</p> <p>If you only use Emogrifier indirectly by sending HTML mail via the email subsystem then you might notice unexpected visual changes due to the improved CSS support. Double check your CSS declarations and particularly the specificity of your selectors in these cases.</p>"},{"location":"migration/wsc53/libraries/#scssphp","title":"scssphp","text":"<p>scssphp was updated from version 1.1 to 1.4.</p> <p>If you interact with scssphp only by deploying <code>.scss</code> files, then you should not experience any breaking changes, except when the improved SCSS compatibility interprets your SCSS code differently.</p> <p>If you happen to directly use scssphp in your PHP code, you should be aware that scssphp deprecated the use of output formatters in favor of a simple output style enum.</p> <p>Refer to WoltLab/WCF #3851 and the scssphp releases for details.</p>"},{"location":"migration/wsc53/libraries/#constant-time-encoder","title":"Constant Time Encoder","text":"<p>WoltLab Suite 5.4 ships the <code>paragonie/constant_time_encoding</code> library. It is recommended to use this library to perform encoding and decoding of secrets to prevent leaks via cache timing attacks. Refer to the library author\u2019s blog post for more background detail.</p> <p>For the common case of encoding the bytes taken from a CSPRNG in hexadecimal form, the required change would look like the following:</p> <p>Previously:</p> <pre><code><?php\n$encoded = hex2bin(random_bytes(16));\n</code></pre> <p>Now:</p> <pre><code><?php\nuse ParagonIE\\ConstantTime\\Hex;\n\n// For security reasons you should add the backslash\n// to ensure you refer to the `random_bytes` function\n// within the global namespace and not a function\n// defined in the current namespace.\n$encoded = Hex::encode(\\random_bytes(16));\n</code></pre> <p>Please refer to the documentation and source code of the <code>paragonie/constant_time_encoding</code> library to learn how to use the library with different encodings (e.g. base64).</p>"},{"location":"migration/wsc53/php/","title":"Migrating from WoltLab Suite 5.3 - PHP","text":""},{"location":"migration/wsc53/php/#minimum-requirements","title":"Minimum requirements","text":"<p>The minimum requirements have been increased to the following:</p> <ul> <li>PHP: 7.2.24</li> <li>MySQL: 5.7.31 or 8.0.19</li> <li>MariaDB: 10.1.44</li> </ul> <p>Most notably PHP 7.2 contains usable support for scalar types by the addition of nullable types in PHP 7.1 and parameter type widening in PHP 7.2.</p> <p>It is recommended to make use of scalar types and other newly introduced features whereever possible. Please refer to the PHP documentation for details.</p>"},{"location":"migration/wsc53/php/#flood-control","title":"Flood Control","text":"<p>To prevent users from creating massive amounts of contents in short periods of time, i.e., spam, existing systems already use flood control mechanisms to limit the amount of contents created within a certain period of time. With WoltLab Suite 5.4, we have added a general API that manages such rate limiting. Leveraging this API is easily done.</p> <ol> <li>Register an object type for the definition <code>com.woltlab.wcf.floodControl</code>: <code>com.example.foo.myContent</code>.</li> <li>Whenever the active user creates content of this type, call <pre><code>FloodControl::getInstance()->registerContent('com.example.foo.myContent');\n</code></pre> You should only call this method if the user creates the content themselves. If the content is automatically created by the system, for example when copying / duplicating existing content, no activity should be registered.</li> <li> <p>To check the last time when the active user created content of the relevant type, use <pre><code>FloodControl::getInstance()->getLastTime('com.example.foo.myContent');\n</code></pre> If you want to limit the number of content items created within a certain period of time, for example within one day, use <pre><code>$data = FloodControl::getInstance()->countContent('com.example.foo.myContent', new \\DateInterval('P1D'));\n// number of content items created within the last day\n$count = $data['count'];\n// timestamp when the earliest content item was created within the last day\n$earliestTime = $data['earliestTime'];\n</code></pre> The method also returns <code>earliestTime</code> so that you can tell the user in the error message when they are able again to create new content of the relevant type.</p> <p>Flood control entries are only stored for 31 days and older entries are cleaned up daily.</p> </li> </ol> <p>The previously mentioned methods of <code>FloodControl</code> use the active user and the current timestamp as reference point. <code>FloodControl</code> also provides methods to register content or check flood control for other registered users or for guests via their IP address. For further details on these methods, please refer to the documentation in the FloodControl class.</p> <p>Do not interact directly with the flood control database table but only via the <code>FloodControl</code> class!</p>"},{"location":"migration/wsc53/php/#databasepackageinstallationplugin","title":"DatabasePackageInstallationPlugin","text":"<p><code>DatabasePackageInstallationPlugin</code> is a new idempotent package installation plugin (thus it is available in the sync function in the devtools) to update the database schema using the PHP-based database API. <code>DatabasePackageInstallationPlugin</code> is similar to <code>ScriptPackageInstallationPlugin</code> by requiring a PHP script that is included during the execution of the script. The script is expected to return an array of <code>DatabaseTable</code> objects representing the schema changes so that in contrast to using <code>ScriptPackageInstallationPlugin</code>, no <code>DatabaseTableChangeProcessor</code> object has to be created. The PHP file must be located in the <code>acp/database/</code> directory for the devtools sync function to recognize the file.</p>"},{"location":"migration/wsc53/php/#php-database-api","title":"PHP Database API","text":"<p>The PHP API to add and change database tables during package installations and updates in the <code>wcf\\system\\database\\table</code> namespace now also supports renaming existing table columns with the new <code>IDatabaseTableColumn::renameTo()</code> method:</p> <pre><code>PartialDatabaseTable::create('wcf1_test')\n ->columns([\n NotNullInt10DatabaseTableColumn::create('oldName')\n ->renameTo('newName')\n ]);\n</code></pre> <p>Like with every change to existing database tables, packages can only rename columns that they installed.</p>"},{"location":"migration/wsc53/php/#captcha","title":"Captcha","text":"<p>The reCAPTCHA v1 implementation was completely removed. This includes the <code>\\wcf\\system\\recaptcha\\RecaptchaHandler</code> class (not to be confused with the one in the <code>captcha</code> namespace).</p> <p>The reCAPTCHA v1 endpoints have already been turned off by Google and always return a HTTP 404. Thus the implementation was completely non-functional even before this change.</p> <p>See WoltLab/WCF#3781 for details.</p>"},{"location":"migration/wsc53/php/#search","title":"Search","text":"<p>The generic implementation in the <code>AbstractSearchEngine::parseSearchQuery()</code> method was dangerous, because it did not have knowledge about the search engine\u2019s specifics. The implementation was completely removed: <code>AbstractSearchEngine::parseSearchQuery()</code> now always throws a <code>\\BadMethodCallException</code>.</p> <p>If you implemented a custom search engine and relied on this method, you can inline the previous implementation to preserve existing behavior. You should take the time to verify the rewritten queries against the manual of the search engine to make sure it cannot generate malformed queries or security issues.</p> <p>See WoltLab/WCF#3815 for details.</p>"},{"location":"migration/wsc53/php/#styles","title":"Styles","text":"<p>The <code>StyleCompiler</code> class is marked <code>final</code> now. The internal SCSS compiler object being stored in the <code>$compiler</code> property was a design issue that leaked compiler state across multiple compiled styles, possibly causing misgenerated stylesheets. As the removal of the <code>$compiler</code> property effectively broke compatibility within the <code>StyleCompiler</code> and as the <code>StyleCompiler</code> never was meant to be extended, it was marked final.</p> <p>See WoltLab/WCF#3929 for details.</p>"},{"location":"migration/wsc53/php/#tags","title":"Tags","text":"<p>Use of the <code>wcf1_tag_to_object.languageID</code> column is deprecated. The <code>languageID</code> column is redundant, because its value can be derived from the <code>tagID</code>. With WoltLab Suite 5.4, it will no longer be part of any indices, allowing more efficient index usage in the general case.</p> <p>If you need to filter the contents of <code>wcf1_tag_to_object</code> by language, you should perform an <code>INNER JOIN wcf1_tag tag ON tag.tagID = tag_to_object.tagID</code> and filter on <code>wcf1_tag.languageID</code>.</p> <p>See WoltLab/WCF#3904 for details.</p>"},{"location":"migration/wsc53/php/#avatars","title":"Avatars","text":"<p>The <code>ISafeFormatAvatar</code> interface was added to properly support fallback image types for use in emails. If your custom <code>IUserAvatar</code> implementation supports image types without broad support (i.e. anything other than PNG, JPEG, and GIF), then you should implement the <code>ISafeFormatAvatar</code> interface to return a fallback PNG, JPEG, or GIF image.</p> <p>See WoltLab/WCF#4001 for details.</p>"},{"location":"migration/wsc53/php/#linebreakseparatedtext-option-type","title":"<code>lineBreakSeparatedText</code> Option Type","text":"<p>Currently, several of the (user group) options installed by our packages use the <code>textarea</code> option type and split its value by linebreaks to get a list of items, for example for allowed file extensions. To improve the user interface when setting up the value of such options, we have added the <code>lineBreakSeparatedText</code> option type as a drop-in replacement where the individual items are explicitly represented as distinct items in the user interface.</p>"},{"location":"migration/wsc53/php/#ignoring-of-users","title":"Ignoring of Users","text":"<p>WoltLab Suite 5.4 distinguishes between blocking direct contact only and hiding all contents when ignoring users. To allow for detecting the difference, the <code>UserProfile::getIgnoredUsers()</code> and <code>UserProfile::isIgnoredUser()</code> methods received a new <code>$type</code> parameter. Pass either <code>UserIgnore::TYPE_BLOCK_DIRECT_CONTACT</code> or <code>UserIgnore::TYPE_HIDE_MESSAGES</code> depending on whether the check refers to a non-directed usage or content.</p> <p>See WoltLab/WCF#4064 and WoltLab/WCF#3981 for details.</p>"},{"location":"migration/wsc53/php/#databaseprepare","title":"<code>Database::prepare()</code>","text":"<p><code>Database::prepare(string $statement, int $limit = 0, int $offset = 0): PreparedStatement</code> works the same way as <code>Database::prepareStatement()</code> but additionally also replaces all occurences of <code>app1_</code> with <code>app{WCF_N}_</code> for all installed apps. This new method makes it superfluous to use <code>WCF_N</code> when building queries.</p>"},{"location":"migration/wsc53/session/","title":"Migrating from WoltLab Suite 5.3 - Session Handling and Authentication","text":"<p>WoltLab Suite 5.4 includes a completely refactored session handling. As long as you only interact with sessions via <code>WCF::getSession()</code>, especially when you perform read-only accesses, you should not notice any breaking changes.</p> <p>You might appreciate some of the new session methods if you process security sensitive data.</p>"},{"location":"migration/wsc53/session/#summary-and-concepts","title":"Summary and Concepts","text":"<p>Most of the changes revolve around the removal of the legacy persistent login functionality and the assumption that every user has a single session only. Both aspects are related to each other.</p>"},{"location":"migration/wsc53/session/#legacy-persistent-login","title":"Legacy Persistent Login","text":"<p>The legacy persistent login was rather an automated login. Upon bootstrapping a session, it was checked whether the user had a cookie pair storing the user\u2019s <code>userID</code> and (a single BCrypt hash of) the user\u2019s password. If such a cookie pair exists and the BCrypt hash within the cookie matches the user\u2019s password hash when hashed again, the session would immediately <code>changeUser()</code> to the respective user.</p> <p>This legacy persistent login was completely removed. Instead, any sessions that belong to an authenticated user will automatically be long-lived. These long-lived sessions expire no sooner than 14 days after the last activity, ensuring that the user continously stays logged in, provided that they visit the page at least once per fortnight.</p>"},{"location":"migration/wsc53/session/#multiple-sessions","title":"Multiple Sessions","text":"<p>To allow for a proper separation of these long-lived user sessions, WoltLab Suite now allows for multiple sessions per user. These sessions are completely unrelated to each other. Specifically, they do not share session variables and they expire independently.</p> <p>As the existing <code>wcf1_session</code> table is also used for the online lists and location tracking, it will be maintained on a best effort basis. It no longer stores any private session data.</p> <p>The actual sessions storing security sensitive information are in an unrelated location. They must only be accessed via the PHP API exposed by the <code>SessionHandler</code>.</p>"},{"location":"migration/wsc53/session/#merged-acp-and-frontend-sessions","title":"Merged ACP and Frontend Sessions","text":"<p>WoltLab Suite 5.4 shares a single session across both the frontend, as well as the ACP. When a user logs in to the frontend, they will also be logged into the ACP and vice versa.</p> <p>Actual access to the ACP is controlled via the new reauthentication mechanism.</p> <p>The session variable store is scoped: Session variables set within the frontend are not available within the ACP and vice versa.</p>"},{"location":"migration/wsc53/session/#improved-authentication-and-reauthentication","title":"Improved Authentication and Reauthentication","text":"<p>WoltLab Suite 5.4 ships with multi-factor authentication support and a generic re-authentication implementation that can be used to verify the account owner\u2019s presence.</p>"},{"location":"migration/wsc53/session/#additions-and-changes","title":"Additions and Changes","text":""},{"location":"migration/wsc53/session/#password-hashing","title":"Password Hashing","text":"<p>WoltLab Suite 5.4 includes a new object-oriented password hashing framework that is modeled after PHP\u2019s <code>password_*</code> API. Check <code>PasswordAlgorithmManager</code> and <code>IPasswordAlgorithm</code> for details.</p> <p>The new default password hash is a standard BCrypt hash. All newly generated hashes in <code>wcf1_user.password</code> will now include a type prefix, instead of just passwords imported from other systems.</p>"},{"location":"migration/wsc53/session/#session-storage","title":"Session Storage","text":"<p>The <code>wcf1_session</code> table will no longer be used for session storage. Instead, it is maintained for compatibility with existing online lists.</p> <p>The actual session storage is considered an implementation detail and you must not directly interact with the session tables. Future versions might support alternative session backends, such as Redis.</p> <p>Do not interact directly with the session database tables but only via the <code>SessionHandler</code> class!</p>"},{"location":"migration/wsc53/session/#reauthentication","title":"Reauthentication","text":"<p>For security sensitive processing, you might want to ensure that the account owner is actually present instead of a third party accessing a session that was accidentally left logged in.</p> <p>WoltLab Suite 5.4 ships with a generic reauthentication framework. To request reauthentication within your controller you need to:</p> <ol> <li>Use the <code>wcf\\system\\user\\authentication\\TReauthenticationCheck</code> trait.</li> <li>Call: <pre><code>$this->requestReauthentication(LinkHandler::getInstance()->getControllerLink(static::class, [\n /* additional parameters */\n]));\n</code></pre></li> </ol> <p><code>requestReauthentication()</code> will check if the user has recently authenticated themselves. If they did, the request proceeds as usual. Otherwise, they will be asked to reauthenticate themselves. After the successful authentication, they will be redirected to the URL that was passed as the first parameter (the current controller within the example).</p> <p>Details can be found in WoltLab/WCF#3775.</p>"},{"location":"migration/wsc53/session/#multi-factor-authentication","title":"Multi-factor Authentication","text":"<p>To implement multi-factor authentication securely, WoltLab Suite 5.4 implements the concept of a \u201cpending user change\u201d. The user will not be logged in (i.e. <code>WCF::getUser()->userID</code> returns <code>null</code>) until they authenticate themselves with their second factor.</p> <p>Requesting multi-factor authentication is done on an opt-in basis for compatibility reasons. If you perform authentication yourself and do not trust the authentication source to perform multi-factor authentication itself, you will need to adjust your logic to request multi-factor authentication from WoltLab Suite:</p> <p>Previously:</p> <pre><code>WCF::getSession()->changeUser($targetUser);\n</code></pre> <p>Now:</p> <pre><code>$isPending = WCF::getSession()->changeUserAfterMultifactorAuthentication($targetUser);\nif ($isPending) {\n // Redirect to the authentication form. The user will not be logged in.\n // Note: Do not use `getControllerLink` to support both the frontend as well as the ACP.\n HeaderUtil::redirect(LinkHandler::getInstance()->getLink('MultifactorAuthentication', [\n 'url' => /* Return To */,\n ]));\n exit;\n}\n// Proceed as usual. The user will be logged in.\n</code></pre>"},{"location":"migration/wsc53/session/#adding-multi-factor-methods","title":"Adding Multi-factor Methods","text":"<p>Adding your own multi-factor method requires the implementation of a single object type:</p> objectType.xml<pre><code><type>\n <name>com.example.multifactor.foobar</name>\n <definitionname>com.woltlab.wcf.multifactor</definitionname>\n <icon><!-- Font Awesome 4 Icon Name goes here. --></icon>\n <priority><!-- Determines the sort order, higher priority will be preferred for authentication. --></priority>\n <classname>wcf\\system\\user\\multifactor\\FoobarMultifactorMethod</classname>\n</type>\n</code></pre> <p>The given classname must implement the <code>IMultifactorMethod</code> interface.</p> <p>As a self-contained example, you can find the initial implementation of the email multi-factor method in WoltLab/WCF#3729. Please check the version history of the PHP class to make sure you do not miss important changes that were added later.</p> <p>Multi-factor authentication is security sensitive. Make sure to carefully read the remarks in <code>IMultifactorMethod</code> for possible issues. Also make sure to carefully test your implementation against all sorts of incorrect input and consider attack vectors such as race conditions. It is strongly recommended to generously check the current state by leveraging assertions and exceptions.</p>"},{"location":"migration/wsc53/session/#enforcing-multi-factor-authentication","title":"Enforcing Multi-factor Authentication","text":"<p>To enforce Multi-factor Authentication within your controller you need to:</p> <ol> <li>Use the <code>wcf\\system\\user\\multifactor\\TMultifactorRequirementEnforcer</code> trait.</li> <li>Call: <code>$this->enforceMultifactorAuthentication();</code></li> </ol> <p><code>enforceMultifactorAuthentication()</code> will check if the user is in a group that requires multi-factor authentication, but does not yet have multi-factor authentication enabled. If they did, the request proceeds as usual. Otherwise, a <code>NamedUserException</code> is thrown.</p>"},{"location":"migration/wsc53/session/#deprecations-and-removals","title":"Deprecations and Removals","text":""},{"location":"migration/wsc53/session/#sessionhandler","title":"SessionHandler","text":"<p>Most of the changes with regard to the new session handling happened in <code>SessionHandler</code>. Most notably, <code>SessionHandler</code> now is marked <code>final</code> to ensure proper encapsulation of data.</p> <p>A number of methods in <code>SessionHandler</code> are now deprecated and result in a noop. This change mostly affects methods that have been used to bootstrap the session, such as <code>setHasValidCookie()</code>.</p> <p>Additionally, accessing the following keys on the session is deprecated. They directly map to an existing method in another class and any uses can easily be updated: - <code>ipAddress</code> - <code>userAgent</code> - <code>requestURI</code> - <code>requestMethod</code> - <code>lastActivityTime</code></p> <p>Refer to the implementation for details.</p>"},{"location":"migration/wsc53/session/#acp-sessions","title":"ACP Sessions","text":"<p>The database tables related to ACP sessions have been removed. The PHP classes have been preserved due to being used within the class hierarchy of the legacy sessions.</p>"},{"location":"migration/wsc53/session/#cookies","title":"Cookies","text":"<p>The <code>_userID</code>, <code>_password</code>, <code>_cookieHash</code> and <code>_cookieHash_acp</code> cookies will no longer be created nor consumed.</p>"},{"location":"migration/wsc53/session/#virtual-sessions","title":"Virtual Sessions","text":"<p>The virtual session logic existed to support multiple devices per single session in <code>wcf1_session</code>. Virtual sessions are no longer required with the refactored session handling.</p> <p>Anything related to virtual sessions has been completely removed as they are considered an implementation detail. This removal includes PHP classes and database tables.</p>"},{"location":"migration/wsc53/session/#security-token-constants","title":"Security Token Constants","text":"<p>The security token constants are deprecated. Instead, the methods of <code>SessionHandler</code> should be used (e.g. <code>->getSecurityToken()</code>). Within templates, you should migrate to the <code>{csrfToken}</code> tag in place of <code>{@SECURITY_TOKEN_INPUT_TAG}</code>. The <code>{csrfToken}</code> tag is a drop-in replacement and was backported to WoltLab Suite 5.2+, allowing you to maintain compatibility across a broad range of versions.</p>"},{"location":"migration/wsc53/session/#passwordutil-and-double-bcrypt-hashes","title":"PasswordUtil and Double BCrypt Hashes","text":"<p>Most of the methods in PasswordUtil are deprecated in favor of the new password hashing framework.</p>"},{"location":"migration/wsc53/templates/","title":"Migrating from WoltLab Suite 5.3 - Templates and Languages","text":""},{"location":"migration/wsc53/templates/#csrftoken","title":"<code>{csrfToken}</code>","text":"<p>Going forward, any uses of the <code>SECURITY_TOKEN_*</code> constants should be avoided. To reference the CSRF token (\u201cSecurity Token\u201d) within templates, the <code>{csrfToken}</code> template plugin was added.</p> <p>Before:</p> <pre><code>{@SECURITY_TOKEN_INPUT_TAG}\n{link controller=\"Foo\"}t={@SECURITY_TOKEN}{/link}\n</code></pre> <p>After:</p> <pre><code>{csrfToken}\n{link controller=\"Foo\"}t={csrfToken type=url}{/link} {* The use of the CSRF token in URLs is discouraged.\n Modifications should happen by means of a POST request. *}\n</code></pre> <p>The <code>{csrfToken}</code> plugin was backported to WoltLab Suite 5.2 and higher, allowing compatibility with a large range of WoltLab Suite branches. See WoltLab/WCF#3612 for details.</p>"},{"location":"migration/wsc53/templates/#rss-feed-links","title":"RSS Feed Links","text":"<p>Prior to version 5.4 of WoltLab Suite, all RSS feed links contained the access token for logged-in users so that the feed shows all contents the specific user has access to. With version 5.4, links with the CSS class <code>rssFeed</code> will open a dialog when clicked that offers the feed link with the access token for personal use and an anonymous feed link that can be shared with others.</p> <pre><code>{* before *}\n<li>\n <a rel=\"alternate\" {*\n *}href=\"{if $__wcf->getUser()->userID}{link controller='ArticleFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleFeed'}{/link}{/if}\" {*\n *}title=\"{lang}wcf.global.button.rss{/lang}\" {*\n *}class=\"jsTooltip\"{*\n *}>\n <span class=\"icon icon16 fa-rss\"></span>\n <span class=\"invisible\">{lang}wcf.global.button.rss{/lang}</span>\n </a>\n</li>\n\n{* after *}\n<li>\n <a rel=\"alternate\" {*\n *}href=\"{if $__wcf->getUser()->userID}{link controller='ArticleFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleFeed'}{/link}{/if}\" {*\n *}title=\"{lang}wcf.global.button.rss{/lang}\" {*\n *}class=\"rssFeed jsTooltip\"{*\n *}>\n <span class=\"icon icon16 fa-rss\"></span>\n <span class=\"invisible\">{lang}wcf.global.button.rss{/lang}</span>\n </a>\n</li>\n</code></pre>"},{"location":"migration/wsc54/deprecations_removals/","title":"Migrating from WoltLab Suite 5.4 - Deprecations and Removals","text":"<p>With version 5.5, we have deprecated certain components and removed several other components that have been deprecated for many years.</p>"},{"location":"migration/wsc54/deprecations_removals/#deprecations","title":"Deprecations","text":""},{"location":"migration/wsc54/deprecations_removals/#php","title":"PHP","text":""},{"location":"migration/wsc54/deprecations_removals/#classes","title":"Classes","text":"<ul> <li><code>filebase\\system\\file\\FileDataHandler</code> (use <code>filebase\\system\\cache\\runtime\\FileRuntimeCache</code>)</li> <li><code>wcf\\action\\AbstractAjaxAction</code> (use PSR-7 responses, WoltLab/WCF#4437)</li> <li><code>wcf\\data\\IExtendedMessageQuickReplyAction</code> (WoltLab/WCF#4575)</li> <li><code>wcf\\form\\SearchForm</code> (see WoltLab/WCF#4605)</li> <li><code>wcf\\page\\AbstractSecurePage</code> (WoltLab/WCF#4515)</li> <li><code>wcf\\page\\SearchResultPage</code> (see WoltLab/WCF#4605)</li> <li><code>wcf\\system\\database\\table\\column\\TUnsupportedDefaultValue</code> (do not implement <code>IDefaultValueDatabaseTableColumn</code>, see WoltLab/WCF#4733)</li> <li><code>wcf\\system\\exception\\ILoggingAwareException</code> (WoltLab/WCF#4547)</li> <li><code>wcf\\system\\io\\FTP</code> (directly use the FTP extension)</li> <li><code>wcf\\system\\search\\AbstractSearchableObjectType</code> (use <code>AbstractSearchProvider</code> instead, see WoltLab/WCF#4605)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchException</code></li> <li><code>wcf\\system\\search\\ISearchableObjectType</code> (use <code>ISearchProvider</code> instead, see WoltLab/WCF#4605)</li> <li><code>wcf\\util\\PasswordUtil</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#methods","title":"Methods","text":"<ul> <li><code>wcf\\action\\MessageQuoteAction::markForRemoval()</code> (WoltLab/WCF#4452)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatarAction::fetchRemoteAvatar()</code> (WoltLab/WCF#4744)</li> <li><code>wcf\\data\\user\\notification\\UserNotificationAction::getOutstandingNotifications()</code> (WoltLab/WCF#4603)</li> <li><code>wcf\\data\\moderation\\queue\\ModerationQueueAction::getOutstandingQueues()</code> (WoltLab/WCF#4603)</li> <li><code>wcf\\system\\message\\QuickReplyManager::setTmpHash()</code> (WoltLab/WCF#4575)</li> <li><code>wcf\\system\\request\\Request::isExecuted()</code> (WoltLab/WCF#4485)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::query()</code></li> <li><code>wcf\\system\\session\\Session::getDeviceIcon()</code> (WoltLab/WCF#4525)</li> <li><code>wcf\\system\\user\\authentication\\password\\algorithm\\TPhpass::hash()</code> (WoltLab/WCF#4602)</li> <li><code>wcf\\system\\user\\authentication\\password\\algorithm\\TPhpass::needsRehash()</code> (WoltLab/WCF#4602)</li> <li><code>wcf\\system\\WCF::getAnchor()</code> (WoltLab/WCF#4580)</li> <li><code>wcf\\util\\MathUtil::getRandomValue()</code> (WoltLab/WCF#4280)</li> <li><code>wcf\\util\\StringUtil::encodeJSON()</code> (WoltLab/WCF#4645)</li> <li><code>wcf\\util\\StringUtil::endsWith()</code> (WoltLab/WCF#4509)</li> <li><code>wcf\\util\\StringUtil::getHash()</code> (WoltLab/WCF#4279)</li> <li><code>wcf\\util\\StringUtil::split()</code> (WoltLab/WCF#4513)</li> <li><code>wcf\\util\\StringUtil::startsWith()</code> (WoltLab/WCF#4509)</li> <li><code>wcf\\util\\UserUtil::isAvailableEmail()</code> (WoltLab/WCF#4602)</li> <li><code>wcf\\util\\UserUtil::isAvailableUsername()</code> (WoltLab/WCF#4602)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#properties","title":"Properties","text":"<ul> <li><code>wcf\\acp\\page\\PackagePage::$compatibleVersions</code> (WoltLab/WCF#4371)</li> <li><code>wcf\\system\\io\\GZipFile::$gzopen64</code> (WoltLab/WCF#4381)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#constants","title":"Constants","text":"<ul> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::DELETE</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::GET</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::POST</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::PUT</code></li> <li><code>wcf\\system\\visitTracker\\VisitTracker::DEFAULT_LIFETIME</code> (WoltLab/WCF#4757)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#functions","title":"Functions","text":"<ul> <li>The global <code>escapeString</code> helper (WoltLab/WCF#4506)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#options","title":"Options","text":"<ul> <li><code>HTTP_SEND_X_FRAME_OPTIONS</code> (WoltLab/WCF#4474)</li> <li><code>ELASTICSEARCH_ALLOW_LEADING_WILDCARD</code></li> <li><code>WBB_MODULE_IGNORE_BOARDS</code> (The option will be always on with WoltLab Suite Forum 5.5 and will be removed with a future version.)</li> <li><code>ENABLE_DESKTOP_NOTIFICATIONS</code> (WoltLab/WCF#4806)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#javascript","title":"JavaScript","text":"<ul> <li><code>WCF.Message.Quote.Manager.markQuotesForRemoval()</code> (WoltLab/WCF#4452)</li> <li><code>WCF.Search.Message.KeywordList</code> (WoltLab/WCF#4402)</li> <li><code>SECURITY_TOKEN</code> (use <code>Core.getXsrfToken()</code>, WoltLab/WCF#4523)</li> <li><code>WCF.Dropdown.Interactive.Handler</code> (WoltLab/WCF#4603)</li> <li><code>WCF.Dropdown.Interactive.Instance</code> (WoltLab/WCF#4603)</li> <li><code>WCF.User.Panel.Abstract</code> (WoltLab/WCF#4603)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#database-tables","title":"Database Tables","text":"<ul> <li><code>wcf1_package_compatibility</code> (WoltLab/WCF#4371)</li> <li><code>wcf1_package_update_compatibility</code> (WoltLab/WCF#4385)</li> <li><code>wcf1_package_update_optional</code> (WoltLab/WCF#4432)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#templates","title":"Templates","text":""},{"location":"migration/wsc54/deprecations_removals/#template-plugins","title":"Template Plugins","text":"<ul> <li><code>|encodeJSON</code> (WoltLab/WCF#4645)</li> <li><code>{fetch}</code> (WoltLab/WCF#4891)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#template-events","title":"Template Events","text":"<ul> <li><code>pageNavbarTop::navigationIcons</code></li> <li><code>search::queryOptions</code></li> <li><code>search::authorOptions</code></li> <li><code>search::periodOptions</code></li> <li><code>search::displayOptions</code></li> <li><code>search::generalFields</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#miscellaneous","title":"Miscellaneous","text":"<ul> <li>The global option to set a specific style with a request parameter (<code>$_REQUEST['styleID']</code>) is deprecated (WoltLab/WCF@0c0111e946)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#removals","title":"Removals","text":""},{"location":"migration/wsc54/deprecations_removals/#php_1","title":"PHP","text":""},{"location":"migration/wsc54/deprecations_removals/#classes_1","title":"Classes","text":"<ul> <li><code>gallery\\util\\ExifUtil</code></li> <li><code>wbb\\action\\BoardQuickSearchAction</code></li> <li><code>wbb\\data\\thread\\NewsList</code></li> <li><code>wbb\\data\\thread\\News</code></li> <li><code>wcf\\action\\PollAction</code> (WoltLab/WCF#4662)</li> <li><code>wcf\\form\\RecaptchaForm</code> (WoltLab/WCF#4289)</li> <li><code>wcf\\system\\background\\job\\ElasticSearchIndexBackgroundJob</code></li> <li><code>wcf\\system\\cache\\builder\\TemplateListenerCacheBuilder</code> (WoltLab/WCF#4297)</li> <li><code>wcf\\system\\log\\modification\\ModificationLogHandler</code> (WoltLab/WCF#4340)</li> <li><code>wcf\\system\\recaptcha\\RecaptchaHandlerV2</code> (WoltLab/WCF#4289)</li> <li><code>wcf\\system\\search\\SearchKeywordManager</code> (WoltLab/WCF#4313)</li> <li>The SCSS compiler\u2019s <code>Leafo</code> class aliases (WoltLab/WCF#4343, Migration Guide from 5.2 to 5.3)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#methods_1","title":"Methods","text":"<ul> <li><code>wbb\\data\\board\\BoardCache::getLabelGroups()</code></li> <li><code>wbb\\data\\post\\PostAction::jumpToExtended()</code> (this method always threw a <code>BadMethodCallException</code>)</li> <li><code>wbb\\data\\thread\\ThreadAction::countReplies()</code></li> <li><code>wbb\\data\\thread\\ThreadAction::validateCountReplies()</code></li> <li><code>wcf\\acp\\form\\UserGroupOptionForm::verifyPermissions()</code> (WoltLab/WCF#4312)</li> <li><code>wcf\\data\\conversation\\message\\ConversationMessageAction::jumpToExtended()</code> (WoltLab/com.woltlab.wcf.conversation#162)</li> <li><code>wcf\\data\\moderation\\queue\\ModerationQueueEditor::markAsDone()</code> (WoltLab/WCF#4317)</li> <li><code>wcf\\data\\tag\\TagCloudTag::getSize()</code> (WoltLab/WCF#4325)</li> <li><code>wcf\\data\\tag\\TagCloudTag::setSize()</code> (WoltLab/WCF#4325)</li> <li><code>wcf\\data\\user\\User::getSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::getSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::saveSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::validateGetSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\UserAction::validateSaveSocialNetworkPrivacySettings()</code> (WoltLab/WCF#4308)</li> <li><code>wcf\\data\\user\\avatar\\DefaultAvatar::canCrop()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\data\\user\\avatar\\DefaultAvatar::getCropImageTag()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatar::canCrop()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatar::getCropImageTag()</code> (WoltLab/WCF#4310)</li> <li><code>wcf\\system\\bbcode\\BBCodeHandler::setAllowedBBCodes()</code> (WoltLab/WCF#4319)</li> <li><code>wcf\\system\\bbcode\\BBCodeParser::validateBBCodes()</code> (WoltLab/WCF#4319)</li> <li><code>wcf\\system\\breadcrumb\\Breadcrumbs::add()</code> (WoltLab/WCF#4298)</li> <li><code>wcf\\system\\breadcrumb\\Breadcrumbs::remove()</code> (WoltLab/WCF#4298)</li> <li><code>wcf\\system\\breadcrumb\\Breadcrumbs::replace()</code> (WoltLab/WCF#4298)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::create()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::validateAttribute()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::validateClass()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\IFormNode::validateId()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\field\\IAttributeFormField::validateFieldAttribute()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\field\\dependency\\IFormFieldDependency::create()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\form\\builder\\field\\validation\\IFormFieldValidator::validateId()</code> (Removal from Interface, see WoltLab/WCF#4468)</li> <li><code>wcf\\system\\message\\embedded\\object\\MessageEmbeddedObjectManager::parseTemporaryMessage()</code> (WoltLab/WCF#4299)</li> <li><code>wcf\\system\\package\\PackageArchive::getPhpRequirements()</code> (WoltLab/WCF#4311)</li> <li><code>wcf\\system\\search\\ISearchIndexManager::add()</code> (Removal from Interface, see WoltLab/WCF#4508)</li> <li><code>wcf\\system\\search\\ISearchIndexManager::update()</code> (Removal from Interface, see WoltLab/WCF#4508)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::_add()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::_delete()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::add()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::bulkAdd()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::bulkDelete()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::delete()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::update()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchIndexManager::add()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchIndexManager::update()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchEngine::parseSearchQuery()</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#properties_1","title":"Properties","text":"<ul> <li><code>wcf\\data\\category\\Category::$permissions</code> (WoltLab/WCF#4303)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchIndexManager::$bulkTypeName</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#constants_1","title":"Constants","text":"<ul> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::HEAD</code></li> <li><code>wcf\\system\\tagging\\TagCloud::MAX_FONT_SIZE</code> (WoltLab/WCF#4325)</li> <li><code>wcf\\system\\tagging\\TagCloud::MIN_FONT_SIZE</code> (WoltLab/WCF#4325)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#options_1","title":"Options","text":"<ul> <li><code>ENABLE_CENSORSHIP</code> (always call <code>Censorship::test()</code>, see WoltLab/WCF#4567)</li> <li><code>MODULE_SYSTEM_RECAPTCHA</code> (WoltLab/WCF#4305)</li> <li><code>PROFILE_MAIL_USE_CAPTCHA</code> (WoltLab/WCF#4399)</li> <li>The <code>may</code> value for <code>MAIL_SMTP_STARTTLS</code> (WoltLab/WCF#4398)</li> <li><code>SEARCH_USE_CAPTCHA</code> (see WoltLab/WCF#4605)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#files","title":"Files","text":"<ul> <li><code>acp/dereferrer.php</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#javascript_1","title":"JavaScript","text":"<ul> <li><code>Blog.Entry.QuoteHandler</code> (use <code>WoltLabSuite/Blog/Ui/Entry/Quote</code>)</li> <li><code>Calendar.Event.QuoteHandler</code> (use <code>WoltLabSuite/Calendar/Ui/Event/Quote</code>)</li> <li><code>WBB.Board.IgnoreBoards</code> (use <code>WoltLabSuite/Forum/Ui/Board/Ignore</code>)</li> <li><code>WBB.Board.MarkAllAsRead</code> (use <code>WoltLabSuite/Forum/Ui/Board/MarkAllAsRead</code>)</li> <li><code>WBB.Board.MarkAsRead</code> (use <code>WoltLabSuite/Forum/Ui/Board/MarkAsRead</code>)</li> <li><code>WBB.Post.QuoteHandler</code> (use <code>WoltLabSuite/Forum/Ui/Post/Quote</code>)</li> <li><code>WBB.Thread.LastPageHandler</code> (use <code>WoltLabSuite/Forum/Ui/Thread/LastPageHandler</code>)</li> <li><code>WBB.Thread.MarkAsRead</code> (use <code>WoltLabSuite/Forum/Ui/Thread/MarkAsRead</code>)</li> <li><code>WBB.Thread.SimilarThreads</code> (use <code>WoltLabSuite/Forum/Ui/Thread/SimilarThreads</code>)</li> <li><code>WBB.Thread.WatchedThreadList</code> (use <code>WoltLabSuite/Forum/Controller/Thread/WatchedList</code>)</li> <li><code>WCF.ACP.Style.ImageUpload</code> (WoltLab/WCF#4323)</li> <li><code>WCF.ColorPicker</code> (see migration guide for <code>WCF.ColorPicker</code>)</li> <li><code>WCF.Conversation.Message.QuoteHandler</code> (use <code>WoltLabSuite/Core/Conversation/Ui/Message/Quote</code>, see WoltLab/com.woltlab.wcf.conversation#155)</li> <li><code>WCF.Like.js</code> (WoltLab/WCF#4300)</li> <li><code>WCF.Message.UserMention</code> (WoltLab/WCF#4324)</li> <li><code>WCF.Poll.Manager</code> (WoltLab/WCF#4662)</li> <li><code>WCF.UserPanel</code> (WoltLab/WCF#4316)</li> <li><code>WCF.User.Panel.Moderation</code> (WoltLab/WCF#4603)</li> <li><code>WCF.User.Panel.Notification</code> (WoltLab/WCF#4603)</li> <li><code>WCF.User.Panel.UserMenu</code> (WoltLab/WCF#4603)</li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#phrases","title":"Phrases","text":"<ul> <li><code>wbb.search.boards.all</code></li> <li><code>wcf.global.form.error.greaterThan.javaScript</code> (WoltLab/WCF#4306)</li> <li><code>wcf.global.form.error.lessThan.javaScript</code> (WoltLab/WCF#4306)</li> <li><code>wcf.search.type.keywords</code></li> <li><code>wcf.acp.option.search_use_captcha</code></li> <li><code>wcf.search.query.description</code></li> <li><code>wcf.search.results.change</code></li> <li><code>wcf.search.results.description</code></li> <li><code>wcf.search.general</code></li> <li><code>wcf.search.query</code></li> <li><code>wcf.search.error.noMatches</code></li> <li><code>wcf.search.error.user.noMatches</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#templates_1","title":"Templates","text":""},{"location":"migration/wsc54/deprecations_removals/#templates_2","title":"Templates","text":"<ul> <li><code>searchResult</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#template-events_1","title":"Template Events","text":"<ul> <li><code>search::tabMenuTabs</code></li> <li><code>search::sections</code></li> <li><code>tagSearch::tabMenuTabs</code></li> <li><code>tagSearch::sections</code></li> </ul>"},{"location":"migration/wsc54/deprecations_removals/#miscellaneous_1","title":"Miscellaneous","text":"<ul> <li>Object specific VisitTracker lifetimes (WoltLab/WCF#4757)</li> </ul>"},{"location":"migration/wsc54/forum_subscriptions/","title":"Migrating from WoltLab Suite 5.4 - WoltLab Suite Forum","text":""},{"location":"migration/wsc54/forum_subscriptions/#subscriptions","title":"Subscriptions","text":"<p>With WoltLab Suite Forum 5.5 we have introduced a new system for subscribing to threads and boards, which also offers the possibility to ignore threads and boards. You can learn more about this feature in our blog. The new system uses a separate mechanism to track the subscribed forums as well as the subscribed threads. The previously used object type <code>com.woltlab.wcf.user.objectWatch</code> is now discontinued, because the object watch system turned out to be too limited for the complex logic behind thread and forum subscriptions.</p>"},{"location":"migration/wsc54/forum_subscriptions/#subscribe-to-threads","title":"Subscribe to Threads","text":"<p>Previously:</p> <pre><code>$action = new UserObjectWatchAction([], 'subscribe', [\n 'data' => [\n 'objectID' => $threadID,\n 'objectType' => 'com.woltlab.wbb.thread',\n ]\n]);\n$action->executeAction();\n</code></pre> <p>Now:</p> <pre><code>ThreadStatusHandler::saveSubscriptionStatus(\n $threadID,\n ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING\n);\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#filter-ignored-threads","title":"Filter Ignored Threads","text":"<p>To filter ignored threads from a given <code>ThreadList</code>, you can use the method <code>ThreadStatusHandler::addFilterForIgnoredThreads()</code> to append the filter for ignored threads. The <code>ViewableThreadList</code> filters out ignored threads by default.</p> <p>Example:</p> <pre><code>$user = new User(123);\n$threadList = new ThreadList();\nThreadStatusHandler::addFilterForIgnoredThreads(\n $threadList,\n // This parameter specifies the target user. Defaults to the current user if the parameter\n // is omitted or `null`.\n $user\n);\n$threadList->readObjects();\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#filter-ignored-users","title":"Filter Ignored Users","text":"<p>Avoid issuing notifications to users that have ignored the target thread by filtering those out.</p> <pre><code>$userIDs = [1, 2, 3];\n$users = ThreadStatusHandler::filterIgnoredUserIDs(\n $userIDs,\n $thread->threadID\n);\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#subscribe-to-boards","title":"Subscribe to Boards","text":"<p>Previously:</p> <pre><code>$action = new UserObjectWatchAction([], 'subscribe', [\n 'data' => [\n 'objectID' => $boardID,\n 'objectType' => 'com.woltlab.wbb.board',\n ]\n]);\n$action->executeAction();\n</code></pre> <p>Now:</p> <pre><code>BoardStatusHandler::saveSubscriptionStatus(\n $boardID,\n ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING\n);\n</code></pre>"},{"location":"migration/wsc54/forum_subscriptions/#filter-ignored-boards","title":"Filter Ignored Boards","text":"<p>Similar to ignored threads you will also have to avoid issuing notifications for boards that a user has ignored.</p> <pre><code>$userIDs = [1, 2, 3];\n$users = BoardStatusHandler::filterIgnoredUserIDs(\n $userIDs,\n $board->boardID\n);\n</code></pre>"},{"location":"migration/wsc54/javascript/","title":"Migrating from WoltLab Suite 5.4 - TypeScript and JavaScript","text":""},{"location":"migration/wsc54/javascript/#ajaxdboaction","title":"<code>Ajax.dboAction()</code>","text":"<p>We have introduced a new <code>Promise</code> based API for the interaction with <code>wcf\\data\\DatabaseObjectAction</code>. It provides full IDE autocompletion support and transparent error handling, but is designed to be used with <code>DatabaseObjectAction</code> only.</p> <p>See the documentation for the new API and WoltLab/WCF#4585 for details.</p>"},{"location":"migration/wsc54/javascript/#wcfcolorpicker","title":"<code>WCF.ColorPicker</code>","text":"<p>We have replaced the old jQuery-based color picker <code>WCF.ColorPicker</code> with a more lightweight replacement <code>WoltLabSuite/Core/Ui/Color/Picker</code>, which uses the build-in <code>input[type=color]</code> field. To support transparency, which <code>input[type=color]</code> does not, we also added a slider to set the alpha value. <code>WCF.ColorPicker</code> has been adjusted to internally use <code>WoltLabSuite/Core/Ui/Color/Picker</code> and it has been deprecated.</p> <p>Be aware that the new color picker requires the following new phrases to be available in the TypeScript/JavaScript code:</p> <ul> <li><code>wcf.style.colorPicker.alpha</code>,</li> <li><code>wcf.style.colorPicker.color</code>,</li> <li><code>wcf.style.colorPicker.error.invalidColor</code>,</li> <li><code>wcf.style.colorPicker.hexAlpha</code>,</li> <li><code>wcf.style.colorPicker.new</code>.</li> </ul> <p>See WoltLab/WCF#4353 for details.</p>"},{"location":"migration/wsc54/javascript/#codemirror","title":"CodeMirror","text":"<p>The bundled version of CodeMirror was updated and should be loaded using the AMD loader going forward.</p> <p>See the third party libraries migration guide for details.</p>"},{"location":"migration/wsc54/javascript/#new-user-menu","title":"New User Menu","text":"<p>The legacy implementation <code>WCF.User.Panel.Abstract</code> was based on jQuery and has now been retired in favor of a new lightweight implementation that provides a clean interface and improved accessibility. You are strongly encouraged to migrate your existing implementation to integrate with existing menus.</p> <p>Please use <code>WoltLabSuite/Core/Ui/User/Menu/Data/ModerationQueue.ts</code> as a template for your own implementation, it contains only strictly the code you will need. It makes use of the new <code>Ajax.dboAction()</code> (see above) for improved readability and flexibility.</p> <p>You must update your trigger button to include the <code>role</code>, <code>tabindex</code> and ARIA attributes! Please take a look at the links in <code>pageHeaderUser.tpl</code> to see these four attributes in action.</p> <p>See WoltLab/WCF#4603 for details.</p>"},{"location":"migration/wsc54/libraries/","title":"Migrating from WoltLab Suite 5.4 - Third Party Libraries","text":""},{"location":"migration/wsc54/libraries/#symfony-php-polyfills","title":"Symfony PHP Polyfills","text":"<p>WoltLab Suite 5.5 ships with Symfony's PHP 7.3, 7.4, and 8.0 polyfills. These polyfills allow you to reliably use some of the PHP functions only available in PHP versions that are newer than the current minimum of PHP 7.2. Notable mentions are <code>str_starts_with</code>, <code>str_ends_with</code>, <code>array_key_first</code>, and <code>array_key_last</code>.</p> <p>Refer to the documentation within the symfony/polyfill repository for details.</p>"},{"location":"migration/wsc54/libraries/#scssphp","title":"scssphp","text":"<p>scssphp was updated from version 1.4 to 1.10.</p> <p>If you interact with scssphp only by deploying <code>.scss</code> files, then you should not experience any breaking changes, except when the improved SCSS compatibility interprets your SCSS code differently.</p> <p>If you happen to directly use scssphp in your PHP code, you should be aware that scssphp deprecated the use of the <code>compile()</code> method, non-UTF-8 processing and also adjusted the handling of pure PHP values for variable handling.</p> <p>Refer to WoltLab/WCF#4345 and the scssphp releases for details.</p>"},{"location":"migration/wsc54/libraries/#emogrifier-css-inliner","title":"Emogrifier / CSS Inliner","text":"<p>The Emogrifier library was updated from version 5.0 to 6.0.</p>"},{"location":"migration/wsc54/libraries/#codemirror","title":"CodeMirror","text":"<p>CodeMirror, the code editor we use for editing templates and SCSS, for example, has been updated to version 5.61.1 and we now also deliver all supported languages/modes. To properly support all languages/modes, CodeMirror is now loaded via the AMD module loader, which requires the original structure of the CodeMirror package, i.e. <code>codemirror.js</code> being in a <code>lib</code> folder. To preserve backward-compatibility, we also keep copies of <code>codemirror.js</code> and <code>codemirror.css</code> in version 5.61.1 directly in <code>js/3rdParty/codemirror</code>. These files are, however, considered deprecated and you should migrate to using <code>require()</code> (see <code>codemirror</code> ACP template).</p> <p>See WoltLab/WCF#4277 for details.</p>"},{"location":"migration/wsc54/libraries/#zendprogressbar","title":"Zend/ProgressBar","text":"<p>The old bundled version of Zend/ProgressBar was replaced by a current version of laminas-progressbar.</p> <p>Due to laminas-zendframework-bridge this update is a drop-in replacement. Existing code should continue to work as-is.</p> <p>It is recommended to cleanly migrate to laminas-progressbar to allow for a future removal of the bridge. Updating the <code>use</code> imports should be sufficient to switch to the laminas-progressbar.</p> <p>See WoltLab/WCF#4460 for details.</p>"},{"location":"migration/wsc54/php/","title":"Migrating from WoltLab Suite 5.4 - PHP","text":""},{"location":"migration/wsc54/php/#initial-psr-7-support","title":"Initial PSR-7 support","text":"<p>WoltLab Suite will incrementally add support for object oriented request/response handling based off the PSR-7 and PSR-15 standards in the upcoming versions.</p> <p>WoltLab Suite 5.5 adds initial support by allowing to define the response using objects implementing the PSR-7 <code>ResponseInterface</code>. If a controller returns such a response object from its <code>__run()</code> method, this response will automatically emitted to the client.</p> <p>Any PSR-7 implementation is supported, but WoltLab Suite 5.5 ships with laminas-diactoros as the recommended \u201cbatteries included\u201d implementation of PSR-7.</p> <p>Support for PSR-7 requests and PSR-15 middlewares is expected to follow in future versions.</p> <p>See WoltLab/WCF#4437 for details.</p>"},{"location":"migration/wsc54/php/#recommended-changes-for-woltlab-suite-55","title":"Recommended changes for WoltLab Suite 5.5","text":"<p>With the current support in WoltLab Suite 5.5 it is recommended to migrate the <code>*Action</code> classes to make use of PSR-7 responses. Control and data flow is typically fairly simple in <code>*Action</code> classes with most requests ending up in either a redirect or a JSON response, commonly followed by a call to <code>exit;</code>.</p> <p>Experimental support for <code>*Page</code> and <code>*Form</code> is available. It is recommended to wait for a future version before migrating these types of controllers.</p>"},{"location":"migration/wsc54/php/#migrating-redirects","title":"Migrating Redirects","text":"<p>Previously:</p> lib/action/ExampleRedirectAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse wcf\\system\\request\\LinkHandler;\nuse wcf\\util\\HeaderUtil;\n\nfinal class ExampleRedirectAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n // Redirect to the landing page.\n HeaderUtil::redirect(\n LinkHandler::getInstance()->getLink()\n );\n\n exit;\n }\n}\n</code></pre> <p>Now:</p> lib/action/ExampleRedirectAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse Laminas\\Diactoros\\Response\\RedirectResponse;\nuse wcf\\system\\request\\LinkHandler;\n\nfinal class ExampleRedirectAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n // Redirect to the landing page.\n return new RedirectResponse(\n LinkHandler::getInstance()->getLink()\n );\n }\n}\n</code></pre>"},{"location":"migration/wsc54/php/#migrating-json-responses","title":"Migrating JSON responses","text":"<p>Previously:</p> lib/action/ExampleJsonAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse wcf\\util\\JSON;\n\nfinal class ExampleJsonAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n \\header('Content-type: application/json; charset=UTF-8');\n\n echo JSON::encode([\n 'foo' => 'bar',\n ]);\n\n exit;\n }\n}\n</code></pre> <p>Now:</p> lib/action/ExampleJsonAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse Laminas\\Diactoros\\Response\\JsonResponse;\n\nfinal class ExampleJsonAction extends AbstractAction\n{\n public function execute()\n {\n parent::execute();\n\n return new JsonResponse([\n 'foo' => 'bar',\n ]);\n }\n}\n</code></pre>"},{"location":"migration/wsc54/php/#events","title":"Events","text":"<p>Historically, events were tightly coupled with a single class, with the event object being an object of this class, expecting the event listener to consume public properties and method of the event object. The <code>$parameters</code> array was introduced due to limitations of this pattern, avoiding moving all the values that might be of interest to the event listener into the state of the object. Events were still tightly coupled with the class that fired the event and using the opaque parameters array prevented IDEs from assisting with autocompletion and typing.</p> <p>WoltLab Suite 5.5 introduces the concept of dedicated, reusable event classes. Any newly introduced event will receive a dedicated class, implementing the <code>wcf\\system\\event\\IEvent</code> interface. These event classes may be fired from multiple locations, making them reusable to convey that a conceptual action happened, instead of a specific class doing something. An example for using the new event system could be a user logging in: Instead of listening on a the login form being submitted and the Facebook login action successfully running, an event <code>UserLoggedIn</code> might be fired whenever a user logs in, no matter how the login is performed.</p> <p>Additionally, these dedicated event classes will benefit from full IDE support. All the relevant values may be stored as real properties on the event object.</p> <p>Event classes should not have an <code>Event</code> suffix and should be stored in an <code>event</code> namespace in a matching location. Thus, the <code>UserLoggedIn</code> example might have a FQCN of <code>\\wcf\\system\\user\\authentication\\event\\UserLoggedIn</code>.</p> <p>Event listeners for events implementing <code>IEvent</code> need to follow PSR-14, i.e. they need to be callable. In practice, this means that the event listener class needs to implement <code>__invoke()</code>. No interface has to be implemented in this case.</p> <p>Previously:</p> <pre><code>$parameters = [\n 'value' => \\random_int(1, 1024),\n];\n\nEventHandler::getInstance()->fireAction($this, 'valueAvailable', $parameters);\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\form\\ValueForm;\n\nfinal class ValueDumpListener implements IParameterizedEventListener\n{\n /**\n * @inheritDoc\n * @param ValueForm $eventObj\n */\n public function execute($eventObj, $className, $eventName, array &$parameters)\n {\n var_dump($parameters['value']);\n }\n}\n</code></pre> <p>Now:</p> <pre><code>EventHandler::getInstance()->fire(new ValueAvailable(\\random_int(1, 1024)));\n</code></pre> lib/system/foo/event/ValueAvailable.class.php<pre><code><?php\n\nnamespace wcf\\system\\foo\\event;\n\nuse wcf\\system\\event\\IEvent;\n\nfinal class ValueAvailable implements IEvent\n{\n /**\n * @var int\n */\n private $value;\n\n public function __construct(int $value)\n {\n $this->value = $value;\n }\n\n public function getValue(): int\n {\n return $this->value;\n }\n}\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\system\\foo\\event\\ValueAvailable;\n\nfinal class ValueDumpListener\n{\n public function __invoke(ValueAvailable $event): void\n {\n \\var_dump($event->getValue());\n }\n}\n</code></pre> <p>See WoltLab/WCF#4000 and WoltLab/WCF#4265 for details.</p>"},{"location":"migration/wsc54/php/#authentication","title":"Authentication","text":"<p>The <code>UserLoggedIn</code> event was added. You should fire this event if you implement a custom login process (e.g. when adding additional external authentication providers).</p> <p>Example:</p> <pre><code>EventHandler::getInstance()->fire(\n new UserLoggedIn($user)\n);\n</code></pre> <p>See WoltLab/WCF#4356 for details.</p>"},{"location":"migration/wsc54/php/#embedded-objects-in-comments","title":"Embedded Objects in Comments","text":"<p>WoltLab/WCF#4275 added support for embedded objects like mentions for comments and comment responses. To properly render embedded objects whenever you are using comments in your packages, you have to use <code>ViewableCommentList</code>/<code>ViewableCommentResponseList</code> in these places or <code>ViewableCommentRuntimeCache</code>/<code>ViewableCommentResponseRuntimeCache</code>.</p>"},{"location":"migration/wsc54/php/#emails","title":"Emails","text":""},{"location":"migration/wsc54/php/#mailbox","title":"Mailbox","text":"<p>The <code>Mailbox</code> and <code>UserMailbox</code> classes no longer store the passed <code>Language</code> and <code>User</code> objects, but the respective ID instead. This change reduces the size of the serialized email when stored in the background queue.</p> <p>If you inherit from the <code>Mailbox</code> or <code>UserMailbox</code> classes, you might experience issues if you directly access the <code>$this->language</code> or <code>$this->user</code> properties. Adjust your class to use composition instead of inheritance if possible. Use the <code>getLanguage()</code> or <code>getUser()</code> getters if using composition is not possible.</p> <p>See WoltLab/WCF#4389 for details.</p>"},{"location":"migration/wsc54/php/#smtp","title":"SMTP","text":"<p>The <code>SmtpEmailTransport</code> no longer supports a value of <code>may</code> for the <code>$starttls</code> property.</p> <p>Using the <code>may</code> value is unsafe as it allows for undetected MITM attacks. The use of <code>encrypt</code> is recommended, unless it is certain that the SMTP server does not support TLS.</p> <p>See WoltLab/WCF#4398 for details.</p>"},{"location":"migration/wsc54/php/#search","title":"Search","text":""},{"location":"migration/wsc54/php/#search-form","title":"Search Form","text":"<p>After the overhaul of the search form, search providers are no longer bound to <code>SearchForm</code> and <code>SearchResultPage</code>. The interface <code>ISearchObjectType</code> and the abstract implementation <code>AbstractSearchableObjectType</code> have been replaced by <code>ISearchProvider</code> and <code>AbstractSearchProvider</code>.</p> <p>Please use <code>ArticleSearch</code> as a template for your own implementation</p> <p>See WoltLab/WCF#4605 for details.</p>"},{"location":"migration/wsc54/php/#exceptions","title":"Exceptions","text":"<p>A new <code>wcf\\system\\search\\exception\\SearchFailed</code> exception was added. This exception should be thrown when executing the search query fails for (mostly) temporary reasons, such as a network partition to a remote service. It is not meant as a blanket exception to wrap everything. For example it must not be returned obvious programming errors, such as an access to an undefined variable (<code>ErrorException</code>).</p> <p>Catching the <code>SearchFailed</code> exception allows consuming code to gracefully handle search requests that are not essential for proceeding, without silencing other types of error.</p> <p>See WoltLab/WCF#4476 and WoltLab/WCF#4483 for details.</p>"},{"location":"migration/wsc54/php/#package-installation-plugins","title":"Package Installation Plugins","text":""},{"location":"migration/wsc54/php/#database","title":"Database","text":"<p>WoltLab Suite 5.5 changes the factory classes for common configurations of database columns within the PHP-based DDL API to contain a private constructor, preventing object creation.</p> <p>This change affects the following classes:</p> <ul> <li><code>DefaultFalseBooleanDatabaseTableColumn</code></li> <li><code>DefaultTrueBooleanDatabaseTableColumn</code></li> <li><code>NotNullInt10DatabaseTableColumn</code></li> <li><code>NotNullVarchar191DatabaseTableColumn</code></li> <li><code>NotNullVarchar255DatabaseTableColumn</code></li> <li> <p><code>ObjectIdDatabaseTableColumn</code></p> </li> <li> <p><code>DatabaseTablePrimaryIndex</code></p> </li> </ul> <p>The static <code>create()</code> method never returned an object of the factory class, but instead in object of the base type (e.g. <code>IntDatabaseTableColumn</code> for <code>NotNullInt10DatabaseTableColumn</code>). Constructing an object of these factory classes is considered a bug, as the class name implies a specific column configuration, that might or might not hold if the object is modified afterwards.</p> <p>See WoltLab/WCF#4564 for details.</p> <p>WoltLab Suite 5.5 adds the <code>IDefaultValueDatabaseTableColumn</code> interface which is used to check whether specifying a default value is legal. For backwards compatibility this interface is implemented by <code>AbstractDatabaseTableColumn</code>. You should explicitly add this interface to custom table column type classes to avoid breakage if the interface is removed from <code>AbstractDatabaseTableColumn</code> in a future version. Likewise you should explicitly check for the interface before attempting to access the methods related to the default value of a column.</p> <p>See WoltLab/WCF#4733 for details.</p>"},{"location":"migration/wsc54/php/#file-deletion","title":"File Deletion","text":"<p>Three new package installation plugins have been added to delete ACP templates with acpTemplateDelete, files with fileDelete, and templates with templateDelete.</p>"},{"location":"migration/wsc54/php/#language","title":"Language","text":"<p>WoltLab/WCF#4261 has added support for deleting existing phrases with the <code>language</code> package installation plugin.</p> <p>The current structure of the language XML files</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\" languagename=\"English\" countrycode=\"gb\">\n <category name=\"wcf.foo\">\n <item name=\"wcf.foo.bar\"><![CDATA[Bar]]></item>\n </category>\n</language>\n</code></pre> <p>is deprecated and should be replaced with the new structure with an explicit <code><import></code> element like in the other package installation plugins:</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\" languagename=\"English\" countrycode=\"gb\">\n <import>\n <category name=\"wcf.foo\">\n <item name=\"wcf.foo.bar\"><![CDATA[Bar]]></item>\n </category>\n </import>\n</language>\n</code></pre> <p>Additionally, to now also support deleting phrases with this package installation plugin, support for a <code><delete></code> element has been added:</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\" languagename=\"English\" countrycode=\"gb\">\n <import>\n <category name=\"wcf.foo\">\n <item name=\"wcf.foo.bar\"><![CDATA[Bar]]></item>\n </category>\n </import>\n <delete>\n <item name=\"wcf.foo.barrr\"/>\n </delete>\n</language>\n</code></pre> <p>Note that when deleting phrases, the category does not have to be specified because phrase identifiers are unique globally.</p> <p>Mixing the old structure and the new structure is not supported and will result in an error message during the import!</p>"},{"location":"migration/wsc54/php/#board-and-thread-subscriptions","title":"Board and Thread Subscriptions","text":"<p>WoltLab Suite Forum 5.5 updates the subscription logic for boards and threads to properly support the ignoring of threads. See the dedicated migration guide for details.</p>"},{"location":"migration/wsc54/php/#miscellaneous-changes","title":"Miscellaneous Changes","text":""},{"location":"migration/wsc54/php/#view-counters","title":"View Counters","text":"<p>With WoltLab Suite 5.5 it is expected that view/download counters do not increase for disabled content.</p> <p>See WoltLab/WCF#4374 for details.</p>"},{"location":"migration/wsc54/php/#form-builder","title":"Form Builder","text":"<ul> <li><code>ValueIntervalFormFieldDependency</code></li> <li><code>ColorFormField</code></li> <li><code>MultipleBoardSelectionFormField</code></li> </ul>"},{"location":"migration/wsc54/templates/","title":"Migrating from WoltLab Suite 5.4 - Templates","text":""},{"location":"migration/wsc54/templates/#content-interaction-buttons","title":"Content Interaction Buttons","text":"<p>Content interactions buttons are a new way to display action buttons at the top of the page. They are intended to replace the icons in <code>pageNavigationIcons</code> for better accessibility while reducing the amount of buttons in <code>contentHeaderNavigation</code>.</p> <p>As a rule of thumb, there should be at most only one button in <code>contentHeaderNavigation</code> (primary action on this page) and three buttons in <code>contentInteractionButtons</code> (important actions on this page). Use <code>contentInteractionDropdownItems</code> for all other buttons.</p> <p>The template <code>contentInteraction</code> is included in the header and the corresponding placeholders are thus available on every page.</p> <p>See WoltLab/WCF#4315 for details.</p>"},{"location":"migration/wsc54/templates/#phrase-modifier","title":"Phrase Modifier","text":"<p>The <code>|language</code> modifier was added to allow the piping of the phrase through other functions. This has some unwanted side effects when used with plain strings that should not support variable interpolation. Another difference to <code>{lang}</code> is the evaluation on runtime rather than at compile time, allowing the phrase to be taken from a variable instead.</p> <p>We introduces the new modifier <code>|phrase</code> as a thin wrapper around <code>\\wcf\\system::WCF::getLanguage()->get()</code>. Use <code>|phrase</code> instead of <code>|language</code> unless you want to explicitly allow template scripting on a variable's output.</p> <p>See WoltLab/WCF#4657 for details.</p>"},{"location":"migration/wsc55/deprecations_removals/","title":"Migrating from WoltLab Suite 5.5 - Deprecations and Removals","text":"<p>With version 6.0, we have deprecated certain components and removed several other components that have been deprecated for many years.</p>"},{"location":"migration/wsc55/deprecations_removals/#deprecations","title":"Deprecations","text":""},{"location":"migration/wsc55/deprecations_removals/#php","title":"PHP","text":""},{"location":"migration/wsc55/deprecations_removals/#classes","title":"Classes","text":"<ul> <li><code>wcf\\action\\AbstractDialogAction</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\SensitiveArgument</code> (WoltLab/WCF#4802)</li> <li><code>wcf\\system\\cli\\command\\IArgumentedCLICommand</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\template\\plugin\\DateModifierTemplatePlugin</code> (WoltLab/WCF#5459)</li> <li><code>wcf\\system\\template\\plugin\\TimeModifierTemplatePlugin</code> (WoltLab/WCF#5459)</li> <li><code>wcf\\system\\template\\plugin\\PlainTimeModifierTemplatePlugin</code> (WoltLab/WCF#5459)</li> <li><code>wcf\\util\\CronjobUtil</code> (WoltLab/WCF#4923)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#methods","title":"Methods","text":"<ul> <li><code>wcf\\data\\cronjob\\CronjobAction::executeCronjobs()</code> (WoltLab/WCF#5171)</li> <li><code>wcf\\data\\package\\update\\server\\PackageUpdateServer::attemptSecureConnection()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\data\\package\\update\\server\\PackageUpdateServer::isValidServerURL()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\data\\page\\Page::setAsLandingPage()</code> (WoltLab/WCF#4842)</li> <li><code>wcf\\data\\style\\Style::getRelativeFavicon()</code> (WoltLab/WCF#5201)</li> <li><code>wcf\\system\\cli\\command\\CLICommandHandler::getCommands()</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\io\\RemoteFile::disableSSL()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\system\\io\\RemoteFile::supportsSSL()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\system\\request\\RequestHandler::inRescueMode()</code> (WoltLab/WCF#4831)</li> <li><code>wcf\\system\\session\\SessionHandler::getLanguageIDs()</code> (WoltLab/WCF#4839)</li> <li><code>wcf\\system\\user\\multifactor\\webauthn\\Challenge::getOptionsAsJson()</code></li> <li><code>wcf\\system\\WCF::getActivePath()</code> (WoltLab/WCF#4827)</li> <li><code>wcf\\system\\WCF::getFavicon()</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\system\\WCF::useDesktopNotifications()</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\util\\CryptoUtil::validateSignedString()</code> (WoltLab/WCF#5083)</li> <li><code>wcf\\util\\Diff::__construct()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::__toString()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::getLCS()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::getRawDiff()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\Diff::getUnixDiff()</code> (WoltLab/WCF#4918)</li> <li><code>wcf\\util\\StringUtil::convertEncoding()</code> (WoltLab/WCF#4800)</li> <li><code>wcf\\system\\bbcode\\AttachmentBBCode::setAttachmentList()</code> (WoltLab/WCF#5587)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#properties","title":"Properties","text":""},{"location":"migration/wsc55/deprecations_removals/#constants","title":"Constants","text":"<ul> <li><code>wcf\\system\\condition\\UserAvatarCondition::GRAVATAR</code> (WoltLab/WCF#4929)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#functions","title":"Functions","text":""},{"location":"migration/wsc55/deprecations_removals/#options","title":"Options","text":""},{"location":"migration/wsc55/deprecations_removals/#javascript","title":"JavaScript","text":"<ul> <li><code>WCF.Comment</code> (WoltLab/WCF#5210)</li> <li><code>WCF.Location</code> (WoltLab/WCF#4972)</li> <li><code>WCF.Message.Share.Content</code> (WoltLab/WCF/commit/624b9db73daf8030aa1c3e49d4ffc785760a283f)</li> <li><code>WCF.User.ObjectWatch.Subscribe</code> (WoltLab/WCF#4962)</li> <li><code>WCF.User.List</code> (WoltLab/WCF#5039)</li> <li><code>WoltLabSuite/Core/Controller/Map/Route/Planner</code> (WoltLab/WCF#4972)</li> <li><code>WoltLabSuite/Core/NumberUtil</code> (WoltLab/WCF#5071)</li> <li><code>WoltLabSuite/Core/Ui/User/List</code> (WoltLab/WCF#5039)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#database-tables","title":"Database Tables","text":""},{"location":"migration/wsc55/deprecations_removals/#templates","title":"Templates","text":"<ul> <li><code>__commentJavaScript</code> (WoltLab/WCF#5210)</li> <li><code>commentListAddComment</code> (WoltLab/WCF#5210)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-modifiersfunctions","title":"Template Modifiers/Functions","text":"<ul> <li><code>|date</code> (WoltLab/WCF#5459)</li> <li><code>|time</code> (WoltLab/WCF#5459)</li> <li><code>|plainTime</code> (WoltLab/WCF#5459)</li> <li><code>{pages}</code> (WoltLab/WCF#5158)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-events","title":"Template Events","text":""},{"location":"migration/wsc55/deprecations_removals/#miscellaneous","title":"Miscellaneous","text":""},{"location":"migration/wsc55/deprecations_removals/#removals","title":"Removals","text":""},{"location":"migration/wsc55/deprecations_removals/#php_1","title":"PHP","text":""},{"location":"migration/wsc55/deprecations_removals/#classes_1","title":"Classes","text":"<ul> <li><code>calendar\\data\\CALENDARDatabaseObject</code></li> <li><code>calendar\\system\\image\\EventDataHandler</code></li> <li><code>gallery\\data\\GalleryDatabaseObject</code></li> <li><code>gallery\\system\\image\\ImageDataHandler</code></li> <li><code>wbb\\system\\user\\object\\watch\\BoardUserObjectWatch</code> and the corresponding object type</li> <li><code>wbb\\system\\user\\object\\watch\\ThreadUserObjectWatch</code> and the corresponding object type</li> <li><code>wcf\\acp\\form\\ApplicationEditForm</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\action\\GravatarDownloadAction</code> (WoltLab/WCF#4929)</li> <li><code>wcf\\data\\user\\avatar\\Gravatar</code> (WoltLab/WCF#4929)</li> <li><code>wcf\\system\\bbcode\\highlighter\\*Highlighter</code> (WoltLab/WCF#4926)</li> <li><code>wcf\\system\\bbcode\\highlighter\\Highlighter</code> (WoltLab/WCF#4926)</li> <li><code>wcf\\system\\cache\\source\\MemcachedCacheSource</code> (WoltLab/WCF#4928)</li> <li><code>wcf\\system\\cli\\command\\CLICommandNameCompleter</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\cli\\command\\CommandsCLICommand</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\cli\\command\\CronjobCLICommand</code> (WoltLab/WCF#5171)</li> <li><code>wcf\\system\\cli\\command\\HelpCLICommand</code> (WoltLab/WCF#5185)</li> <li><code>wcf\\system\\cli\\command\\PackageCLICommand</code> (WoltLab/WCF#4946)</li> <li><code>wcf\\system\\cli\\DatabaseCLICommandHistory</code> (WoltLab/WCF#5058)</li> <li><code>wcf\\system\\database\\table\\column/\\UnsupportedDefaultValue</code> (WoltLab/WCF#5012)</li> <li><code>wcf\\system\\exception\\ILoggingAwareException</code> (and associated functionality) (WoltLab/WCF#5086)</li> <li><code>wcf\\system\\mail\\Mail</code> (WoltLab/WCF#4941)</li> <li><code>wcf\\system\\option\\DesktopNotificationApplicationSelectOptionType</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchException</code></li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#methods_1","title":"Methods","text":"<ul> <li>The <code>$forceHTTP</code> parameter of <code>wcf\\data\\package\\update\\server\\PackageUpdateServer::getListURL()</code> (WoltLab/WCF#4790)</li> <li>The <code>$forceHTTP</code> parameter of <code>wcf\\system\\package\\PackageUpdateDispatcher::getPackageUpdateXML()</code> (WoltLab/WCF#4790)</li> <li><code>wcf\\data\\bbcode\\BBCodeCache::getHighlighters()</code> (WoltLab/WCF#4926)</li> <li><code>wcf\\data\\conversation\\ConversationAction::getMixedConversationList()</code> (WoltLab/com.woltlab.wcf.conversation#176)</li> <li><code>wcf\\data\\moderation\\queue\\ModerationQueueAction::getOutstandingQueues()</code> (WoltLab/WCF#4944)</li> <li><code>wcf\\data\\package\\installation\\queue\\PackageInstallationQueueAction::prepareQueue()</code> (WoltLab/WCF#4997)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatarAction::enforceDimensions()</code> (WoltLab/WCF#5007)</li> <li><code>wcf\\data\\user\\avatar\\UserAvatarAction::fetchRemoteAvatar()</code> (WoltLab/WCF#5007)</li> <li><code>wcf\\data\\user\\notification\\UserNotificationAction::getOustandingNotifications()</code> (WoltLab/WCF#4944)</li> <li><code>wcf\\data\\user\\UserRegistrationAction::validatePassword()</code> (WoltLab/WCF#5244)</li> <li><code>wcf\\system\\bbcode\\BBCodeParser::getRemoveLinks()</code> (WoltLab/WCF#4986)</li> <li><code>wcf\\system\\bbcode\\HtmlBBCodeParser::setRemoveLinks()</code> (WoltLab/WCF#4986)</li> <li><code>wcf\\system\\html\\output\\node\\AbstractHtmlOutputNode::setRemoveLinks()</code> (WoltLab/WCF#4986)</li> <li><code>wcf\\system\\package\\PackageArchive::downloadArchive()</code> (WoltLab/WCF#5006)</li> <li><code>wcf\\system\\package\\PackageArchive::filterUpdateInstructions()</code> (WoltLab/WCF#5129)</li> <li><code>wcf\\system\\package\\PackageArchive::getAllExistingRequirements()</code> (WoltLab/WCF#5125)</li> <li><code>wcf\\system\\package\\PackageArchive::getInstructions()</code> (WoltLab/WCF#5120)</li> <li><code>wcf\\system\\package\\PackageArchive::getUpdateInstructions()</code> (WoltLab/WCF#5129)</li> <li><code>wcf\\system\\package\\PackageArchive::isValidInstall()</code> (WoltLab/WCF#5125)</li> <li><code>wcf\\system\\package\\PackageArchive::isValidUpdate()</code> (WoltLab/WCF#5126)</li> <li><code>wcf\\system\\package\\PackageArchive::setPackage()</code> (WoltLab/WCF#5120)</li> <li><code>wcf\\system\\package\\PackageArchive::unzipPackageArchive()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::checkPackageInstallationQueue()</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::completeSetup()</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::convertShorthandByteValue()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::functionExists()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::openQueue()</code> (WoltLab/WCF#4947)</li> <li><code>wcf\\system\\package\\PackageInstallationDispatcher::validatePHPRequirements()</code> (WoltLab/WCF#4949)</li> <li><code>wcf\\system\\package\\PackageInstallationNodeBuilder::insertNode()</code> (WoltLab/WCF#4997)</li> <li><code>wcf\\system\\package\\PackageUpdateDispatcher::prepareInstallation()</code> (WoltLab/WCF#4997)</li> <li><code>wcf\\system\\request\\Request::execute()</code> (WoltLab/WCF#4820)</li> <li><code>wcf\\system\\request\\Request::getPageType()</code> (WoltLab/WCF#4822)</li> <li><code>wcf\\system\\request\\Request::getPageType()</code> (WoltLab/WCF#4822)</li> <li><code>wcf\\system\\request\\Request::isExecuted()</code></li> <li><code>wcf\\system\\request\\Request::setIsLandingPage()</code></li> <li><code>wcf\\system\\request\\RouteHandler::getDefaultController()</code> (WoltLab/WCF#4832)</li> <li><code>wcf\\system\\request\\RouteHandler::loadDefaultControllers()</code> (WoltLab/WCF#4832)</li> <li><code>wcf\\system\\search\\AbstractSearchEngine::getFulltextMinimumWordLength()</code> (WoltLab/WCF#4933)</li> <li><code>wcf\\system\\search\\AbstractSearchEngine::parseSearchQuery()</code> (WoltLab/WCF#4933)</li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchSearchEngine::getFulltextMinimumWordLength()</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::query()</code></li> <li><code>wcf\\system\\search\\SearchIndexManager::add()</code> (WoltLab/WCF#4925)</li> <li><code>wcf\\system\\search\\SearchIndexManager::update()</code> (WoltLab/WCF#4925)</li> <li><code>wcf\\system\\session\\SessionHandler::getStyleID()</code> (WoltLab/WCF#4837)</li> <li><code>wcf\\system\\session\\SessionHandler::setStyleID()</code> (WoltLab/WCF#4837)</li> <li><code>wcf\\system\\CLIWCF::checkForUpdates()</code> (WoltLab/WCF#5058)</li> <li><code>wcf\\system\\WCFACP::checkMasterPassword()</code> (WoltLab/WCF#4977)</li> <li><code>wcf\\system\\WCFACP::getFrontendMenu()</code> (WoltLab/WCF#4812)</li> <li><code>wcf\\system\\WCFACP::initPackage()</code> (WoltLab/WCF#4794)</li> <li><code>wcf\\util\\CryptoUtil::randomBytes()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\CryptoUtil::randomInt()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\CryptoUtil::secureCompare()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\FileUtil::downloadFileFromHttp()</code> (WoltLab/WCF#4942)</li> <li><code>wcf\\util\\PasswordUtil::secureCompare()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\PasswordUtil::secureRandomNumber()</code> (WoltLab/WCF#4924)</li> <li><code>wcf\\util\\StringUtil::encodeJSON()</code> (WoltLab/WCF#5073)</li> <li><code>wcf\\util\\StyleUtil::updateStyleFile()</code> (WoltLab/WCF#4977)</li> <li><code>wcf\\util\\UserRegistrationUtil::isSecurePassword()</code> (WoltLab/WCF#4977)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#properties_1","title":"Properties","text":"<ul> <li><code>wcf\\acp\\form\\PageAddForm::$isLandingPage</code> (WoltLab/WCF#4842)</li> <li><code>wcf\\system\\appliation\\ApplicationHandler::$isMultiDomain</code> (WoltLab/WCF#4785)</li> <li><code>wcf\\system\\package\\PackageArchive::$package</code> (WoltLab/WCF#5129)</li> <li><code>wcf\\system\\request\\RequestHandler::$inRescueMode</code> (WoltLab/WCF#4831)</li> <li><code>wcf\\system\\request\\RouteHandler::$defaultControllers</code> (WoltLab/WCF#4832)</li> <li><code>wcf\\system\\template\\TemplateScriptingCompiler::$disabledPHPFunctions</code> (WoltLab/WCF#4788)</li> <li><code>wcf\\system\\template\\TemplateScriptingCompiler::$enterpriseFunctions</code> (WoltLab/WCF#4788)</li> <li><code>wcf\\system\\WCF::$forceLogout</code> (WoltLab/WCF#4799)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#events","title":"Events","text":"<ul> <li><code>beforeArgumentParsing@wcf\\system\\CLIWCF</code> (WoltLab/WCF#5058)</li> <li><code>afterArgumentParsing@wcf\\system\\CLIWCF</code> (WoltLab/WCF#5058)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#constants_1","title":"Constants","text":"<ul> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::DELETE</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::GET</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::POST</code></li> <li><code>wcf\\system\\search\\elasticsearch\\ElasticsearchHandler::PUT</code></li> <li><code>PACKAGE_NAME</code> (WoltLab/WCF#5006)</li> <li><code>PACKAGE_VERSION</code> (WoltLab/WCF#5006)</li> <li><code>SECURITY_TOKEN_INPUT_TAG</code> (WoltLab/WCF#4934)</li> <li><code>SECURITY_TOKEN</code> (WoltLab/WCF#4934)</li> <li><code>WSC_API_VERSION</code> (WoltLab/WCF#4943)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#functions_1","title":"Functions","text":"<ul> <li>The global <code>escapeString</code> helper (WoltLab/WCF#5085)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#options_1","title":"Options","text":"<ul> <li><code>CACHE_SOURCE_MEMCACHED_HOST</code> (WoltLab/WCF#4928)</li> <li><code>DESKTOP_NOTIFICATION_PACKAGE_ID</code> (WoltLab/WCF#4785)</li> <li><code>GRAVATAR_DEFAULT_TYPE</code> (WoltLab/WCF#4929)</li> <li><code>HTTP_SEND_X_FRAME_OPTIONS</code> (WoltLab/WCF#4786)</li> <li><code>MODULE_GRAVATAR</code> (WoltLab/WCF#4929)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#files","title":"Files","text":"<ul> <li>The <code>scss.inc.php</code> compatibility include. (WoltLab/WCF#4932)</li> <li>The <code>config.inc.php</code> in app directories. (WoltLab/WCF#5006)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#javascript_1","title":"JavaScript","text":"<ul> <li><code>Blog.Blog.Archive</code></li> <li><code>Blog.Category.MarkAllAsRead</code></li> <li><code>Blog.Entry.Delete</code></li> <li><code>Blog.Entry.Preview</code></li> <li><code>Blog.Entry.QuoteHandler</code></li> <li><code>Calendar.Category.MarkAllAsRead</code> (WoltLab/com.woltlab.calendar#169)</li> <li><code>Calendar.Event.Coordinates</code></li> <li><code>Calendar.Event.Date.FullDay</code> (WoltLab/com.woltlab.calendar#171)</li> <li><code>Calendar.Event.Date.Participation.RemoveParticipant</code></li> <li><code>Calendar.Event.Preview</code></li> <li><code>Calendar.Event.QuoteHandler</code></li> <li><code>Calendar.Event.Share</code></li> <li><code>Calendar.Event.TabMenu</code></li> <li><code>Calendar.Event.Thread.ShowParticipants</code></li> <li><code>Calendar.Map</code></li> <li><code>Calendar.UI.Calendar</code></li> <li><code>Calendar/Ui/Event/Date/Cancel.js</code></li> <li><code>Calendar.Export.iCal</code></li> <li><code>Filebase.Category.MarkAllAsRead</code></li> <li><code>Filebase.File.MarkAsRead</code></li> <li><code>Filebase.File.Preview</code></li> <li><code>Filebase.File.Share</code></li> <li><code>flexibleArea.js</code> (WoltLab/WCF#4945)</li> <li><code>Gallery.Album.Share</code></li> <li><code>Gallery.Category.MarkAllAsRead</code></li> <li><code>Gallery.Image.Delete</code></li> <li><code>Gallery.Image.Share</code></li> <li><code>Gallery.Map.LargeMap</code></li> <li><code>Gallery.Map.InfoWindowImageListDialog</code></li> <li><code>jQuery.browser.smartphone</code> (WoltLab/WCF#4945)</li> <li><code>Prism.wscSplitIntoLines</code> (WoltLab/WCF#4940)</li> <li><code>SID_ARG_2ND</code> (WoltLab/WCF#4998)</li> <li><code>WBB.Board.Collapsible</code></li> <li><code>WBB.Board.IgnoreBoards</code></li> <li><code>WBB.Post.IPAddressHandler</code></li> <li><code>WBB.Post.Preview</code></li> <li><code>WBB.Post.QuoteHandler</code></li> <li><code>WBB.Thread.LastPageHandler</code></li> <li><code>WBB.Thread.SimilarThreads</code></li> <li><code>WBB.Thread.UpdateHandler.Thread</code></li> <li><code>WBB.Thread.WatchedThreadList</code></li> <li><code>WCF.Action.Scroll</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Comment</code> (WoltLab/WCF@00d46429)</li> <li><code>WCF.Conversation.MarkAllAsRead</code></li> <li><code>WCF.Conversation.MarkAsRead</code></li> <li><code>WCF.Conversation.Message.QuoteHandler</code></li> <li><code>WCF.Conversation.Preview</code></li> <li><code>WCF.Conversation.RemoveParticipant</code></li> <li><code>WCF.Date.Picker</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Date.Util</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Dropdown.Interactive.Handler</code> (WoltLab/WCF#4944)</li> <li><code>WCF.Dropdown.Interactive.Instance</code> (WoltLab/WCF#4944)</li> <li><code>WCF.Label.ACPList</code></li> <li><code>WCF.Message.Share.Page</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Message.Smilies</code> (WoltLab/WCF#4945)</li> <li><code>WCF.ModeratedUserGroup.AddMembers</code></li> <li><code>WCF.Moderation.Queue.MarkAllAsRead</code></li> <li><code>WCF.Moderation.Queue.MarkAsRead</code></li> <li><code>WCF.Poll</code> (WoltLab/WCF#5465)</li> <li><code>WCF.Search.Message.KeywordList</code> (WoltLab/WCF#4945)</li> <li><code>WCF.System.FlexibleMenu</code> (WoltLab/WCF#4945)</li> <li><code>WCF.System.Fullscreen</code> (WoltLab/WCF#4945)</li> <li><code>WCF.System.PageNavigation</code> (WoltLab/WCF#4945)</li> <li><code>WCF.Template</code> (WoltLab/WCF#5070)</li> <li><code>WCF.ToggleOptions</code> (WoltLab/WCF#4945)</li> <li><code>WCF.User.LikeLoader</code></li> <li><code>WCF.User.Panel.Abstract</code> (WoltLab/WCF#4944)</li> <li><code>WCF.User.ProfilePreview</code></li> <li><code>WCF.User.Registration.Validation.Password</code> (WoltLab/WCF#5244)</li> <li><code>window.shuffle()</code> (WoltLab/WCF#4945)</li> <li><code>WSC_API_VERSION</code> (WoltLab/WCF#4943)</li> <li><code>WCF.Infraction.Warning.ShowDetails</code></li> <li><code>WoltLabSuite/Core/Ui/Comment/Add</code> (WoltLab/WCF#5210)</li> <li><code>WoltLabSuite/Core/Ui/Comment/Edit</code> (WoltLab/WCF#5210)</li> <li><code>WoltLabSuite/Core/Ui/Response/Comment/Add</code> (WoltLab/WCF#5210)</li> <li><code>WoltLabSuite/Core/Ui/Response/Comment/Edit</code> (WoltLab/WCF#5210)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#database","title":"Database","text":"<ul> <li><code>wcf1_cli_history</code> (WoltLab/WCF#5058)</li> <li><code>wcf1_package_compatibility</code> (WoltLab/WCF#4992)</li> <li><code>wcf1_package_update_compatibility</code> (WoltLab/WCF#5005)</li> <li><code>wcf1_package_update_optional</code> (WoltLab/WCF#5005)</li> <li><code>wcf1_user_notification_to_user</code> (WoltLab/WCF#5005)</li> <li><code>wcf1_user.enableGravatar</code> (WoltLab/WCF#4929)</li> <li><code>wcf1_user.gravatarFileExtension</code> (WoltLab/WCF#4929)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#templates_1","title":"Templates","text":""},{"location":"migration/wsc55/deprecations_removals/#templates_2","title":"Templates","text":"<ul> <li><code>conversationListUserPanel</code> (WoltLab/com.woltlab.wcf.conversation#176)</li> <li><code>moderationQueueList</code> (WoltLab/WCF#4944)</li> <li><code>notificationListUserPanel</code> (WoltLab/WCF#4944)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-plugins","title":"Template Plugins","text":"<ul> <li><code>{fetch}</code> (WoltLab/WCF#4892)</li> <li><code>|encodeJSON</code> (WoltLab/WCF#5073)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-events_1","title":"Template Events","text":"<ul> <li><code>headInclude::javascriptInclude</code> (WoltLab/WCF#4801)</li> <li><code>headInclude::javascriptInit</code> (WoltLab/WCF#4801)</li> <li><code>headInclude::javascriptLanguageImport</code> (WoltLab/WCF#4801)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#template-variables","title":"Template Variables","text":"<ul> <li><code>$__sessionKeepAlive</code> (WoltLab/WCF#5055)</li> <li><code>$__wcfVersion</code> (WoltLab/WCF#4927)</li> <li><code>$tpl.cookie</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.env</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.get</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.now</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.post</code> (WoltLab/WCF@7cfd5578ede22e)</li> <li><code>$tpl.server</code> (WoltLab/WCF@7cfd5578ede22e)</li> </ul>"},{"location":"migration/wsc55/deprecations_removals/#miscellaneous_1","title":"Miscellaneous","text":"<ul> <li>The use of a non-<code>1</code> <code>WCF_N</code> in WCFSetup. (WoltLab/WCF#4791)</li> <li>The global option to set a specific style with a request parameter (<code>$_REQUEST['styleID']</code>) is removed. (WoltLab/WCF#4533)</li> <li>Using non-standard ports for package servers is no longer supported. (WoltLab/WCF#4790)</li> <li>Using the insecure <code>http://</code> scheme for package servers is no longer supported. The use of <code>https://</code> is enforced. (WoltLab/WCF#4790)</li> <li>The support for AMP pages was removed. (WoltLab/WCF#5425)</li> <li>The support for style API version was removed. All styles are treated as if they are fully compatible with the latest version. (WoltLab/WCF#5036)</li> </ul>"},{"location":"migration/wsc55/dialogs/","title":"Migrating from WoltLab Suite 5.5 - Dialogs","text":""},{"location":"migration/wsc55/dialogs/#the-state-of-dialogs-in-woltlab-suite-55-and-earlier","title":"The State of Dialogs in WoltLab Suite 5.5 and earlier","text":"<p>In the past dialogs have been used for all kinds of purposes, for example, to provide more details. Dialogs make it incredibly easy to add extra information or forms to an existing page without giving much thought: A simple button is all that it takes to show a dialog.</p> <p>This has lead to an abundance of dialogs that have been used in a lot of places where dialogs are not the right choice, something we are guilty of in a lot of cases. A lot of research has gone into the accessibility of dialogs and the general recommendations towards their usage and the behavior.</p> <p>One big issue of dialogs have been their inconsistent appearance in terms of form buttons and their (lack of) keyboard support for input fields. WoltLab Suite 6.0 provides a completely redesigned API that strives to make the process of creating dialogs much easier and features a consistent keyboard support out of the box.</p>"},{"location":"migration/wsc55/dialogs/#conceptual-changes","title":"Conceptual Changes","text":"<p>Dialogs are a powerful tool, but as will all things, it is easy to go overboard and eventually one starts using dialogs out of convenience rather than necessity. In general dialogs should only be used when you need to provide information out of flow, for example, for urgent error messages.</p> <p>A common misuse that we are guilty of aswell is the use of dialogs to present content. Dialogs completely interrupt whatever the user is doing and can sometimes even hide contextual relevant content on the page. It is best to embed information into regular pages and either use deep links to refer to them or make use of flyovers to present the content in place.</p> <p>Another important change is the handling of form inputs. Previously it was required to manually craft the form submit buttons, handle button clicks and implement a proper validation. The new API provides the \u201cprompt\u201d type which implements all this for you and exposing JavaScript events to validate, submit and cancel the dialog.</p> <p>Last but not least there have been updates to the visual appearance of dialogs. The new dialogs mimic the appearance on modern desktop operating systems as well as smartphones by aligning the buttons to the bottom right. In addition the order of buttons has been changed to always show the primary button on the rightmost position. These changes were made in an effort to make it easier for users to adopt an already well known control concept and to improve the overall accessibility.</p>"},{"location":"migration/wsc55/dialogs/#migrating-to-the-dialogs-of-woltlab-suite-60","title":"Migrating to the Dialogs of WoltLab Suite 6.0","text":"<p>The old dialogs are still fully supported and have remained unchanged apart from a visual update to bring them in line with the new dialogs. We do recommend that you use the new dialog API exclusively for new components and migrate the existing dialogs whenever you see it fit, we\u2019ll continue to support the legacy dialog API for the entire 6.x series at minimum.</p>"},{"location":"migration/wsc55/dialogs/#comparison-of-the-apis","title":"Comparison of the APIs","text":"<p>The legacy API relied on implicit callbacks to initialize dialogs and to handle the entire lifecycle. The <code>_dialogSetup()</code> method was complex, offered subpar auto completition support and generally became very bloated when utilizing the events.</p>"},{"location":"migration/wsc55/dialogs/#source","title":"<code>source</code>","text":"<p>The source of a dialog is provided directly through the fluent API of <code>dialogFactory()</code> which provides methods to spawn dialogs using elements, HTML strings or completely empty.</p> <p>The major change is the removal of the AJAX support as the content source, you should use <code>dboAction()</code> instead and then create the dialog.</p>"},{"location":"migration/wsc55/dialogs/#optionsonsetupcontent-htmlelement","title":"<code>options.onSetup(content: HTMLElement)</code>","text":"<p>You can now access the content element directly, because everything happens in-place.</p> <pre><code>const dialog = dialogFactory().fromHtml(\"<p>Hello World!</p>\").asAlert();\n\n// Do something with `dialog.content` or bind event listeners.\n\ndialog.show(\"My Title\");\n</code></pre>"},{"location":"migration/wsc55/dialogs/#optionsonshowcontent-htmlelement","title":"<code>options.onShow(content: HTMLElement)</code>","text":"<p>There is no equivalent in the new API, because you can simply store a reference to your dialog and access the <code>.content</code> property at any time.</p>"},{"location":"migration/wsc55/dialogs/#_dialogsubmit","title":"<code>_dialogSubmit()</code>","text":"<p>This is the most awkward feature of the legacy dialog API: Poorly documented and cumbersome to use. Implementing it required a dedicated form submit button and the keyboard interaction required the <code>data-dialog-submit-on-enter=\"true\"</code> attribute to be set on all input elements that should submit the form through <code>Enter</code>.</p> <p>The new dialog API takes advantage of the <code>form[method=\"dialog\"]</code> functionality which behaves similar to regular forms but will signal the form submit to the surrounding dialog. As a developer you only need to listen for the <code>validate</code> and the <code>primary</code> event to implement your logic.</p> <pre><code>const dialog = dialogFactory()\n .fromId(\"myComplexDialogWithFormInputs\")\n .asPrompt();\n\ndialog.addEventListener(\"validate\", (event) => {\n // Validate the form inputs in `dialog.content`.\n\n if (validationHasFailed) {\n event.preventDefault();\n }\n});\n\ndialog.addEventListener(\"primary\", () => {\n // The dialog has been successfully validated\n // and was submitted by the user.\n // You can access form inputs through `dialog.content`.\n});\n</code></pre>"},{"location":"migration/wsc55/dialogs/#changes-to-the-template","title":"Changes to the Template","text":"<p>Both the old and the new API support the use of existing elements to create dialogs. It is recommended to use <code><template></code> in this case which will never be rendered and has a well-defined role.</p> <pre><code><!-- Previous -->\n<div id=\"myDialog\" style=\"display: none\">\n <!-- \u2026 -->\n</div>\n\n<!-- Use instead -->\n<template id=\"myDialog\">\n <!-- \u2026 -->\n</template>\n</code></pre> <p>Dialogs have historically been using the same HTML markup that regular pages do, including but not limited to the use of sections. For dialogs that use only a single container it is recommend to drop the section entirely.</p> <p>If your dialog contain multiple sections it is recommended to skip the title of the first section.</p>"},{"location":"migration/wsc55/dialogs/#formsubmit","title":"<code>.formSubmit</code>","text":"<p>Form controls are no longer defined through the template, instead those are implicitly generated by the new dialog API. Please see the explanation on the four different dialog types to learn more about form controls.</p>"},{"location":"migration/wsc55/dialogs/#migration-by-example","title":"Migration by Example","text":"<p>There is no universal pattern that fits every case, because dialogs vary greatly between each other and the required functionality causes the actual implementation to be different.</p> <p>As an example we have migrated the dialog to create a new box to use the new API. It uses a prompt dialog that automagically adds form controls and fires an event once the user submits the dialog. You can find the commit 3a9210f229f6a2cf5e800c2c4536c9774d02fc86 on GitHub.</p> <p>The changes can be summed up as follows:</p> <ol> <li>Use a <code><template></code> element for the dialog content.</li> <li>Remove the <code>.formSubmit</code> section from the HTML.</li> <li>Unwrap the contents by stripping the <code>.section</code>.</li> <li>Create and store the reference to the dialog in a property for later re-use.</li> <li>Interact with the dialog\u2019s <code>.content</code> property and make use of an event listener to handle the user interaction.</li> </ol>"},{"location":"migration/wsc55/dialogs/#creating-a-dialog-using-an-id","title":"Creating a Dialog Using an ID","text":"<pre><code>_dialogSetup() {\n return {\n // \u2026\n id: \"myDialog\",\n };\n}\n</code></pre> <p>New API</p> <pre><code>dialogFactory().fromId(\"myDialog\").withoutControls();\n</code></pre>"},{"location":"migration/wsc55/dialogs/#using-source-to-provide-the-dialog-html","title":"Using <code>source</code> to Provide the Dialog HTML","text":"<pre><code>_dialogSetup() {\n return {\n // \u2026\n source: \"<p>Hello World</p>\",\n };\n}\n</code></pre> <p>New API</p> <pre><code>dialogFactory().fromHtml(\"<p>Hello World</p>\").withoutControls();\n</code></pre>"},{"location":"migration/wsc55/dialogs/#updating-the-html-when-the-dialog-is-shown","title":"Updating the HTML When the Dialog Is Shown","text":"<pre><code>_dialogSetup() {\n return {\n // \u2026\n options: {\n // \u2026\n onShow: (content) => {\n content.querySelector(\"p\")!.textContent = \"Hello World\";\n },\n },\n };\n}\n</code></pre> <p>New API</p> <pre><code>const dialog = dialogFactory().fromHtml(\"<p></p>\").withoutControls();\n\n// Somewhere later in the code\n\ndialog.content.querySelector(\"p\")!.textContent = \"Hello World\";\n\ndialog.show(\"Some Title\");\n</code></pre>"},{"location":"migration/wsc55/dialogs/#specifying-the-title-of-a-dialog","title":"Specifying the Title of a Dialog","text":"<p>The title was previously fixed in the <code>_dialogSetup()</code> method and could only be changed on runtime using the <code>setTitle()</code> method.</p> <pre><code>_dialogSetup() {\n return {\n // \u2026\n options: {\n // \u2026\n title: \"Some Title\",\n },\n };\n}\n</code></pre> <p>The title is now provided whenever the dialog should be opened, permitting changes in place.</p> <pre><code>const dialog = dialogFactory().fromHtml(\"<p></p>\").withoutControls();\n\n// Somewhere later in the code\n\ndialog.show(\"Some Title\");\n</code></pre>"},{"location":"migration/wsc55/icons/","title":"Migrating from WoltLab Suite 5.5 - Icons","text":"<p>WoltLab Suite 6.0 introduces Font Awesome 6.0 which is a major upgrade over the previously used Font Awesome 4.7 icon library. The new version features not only many hundreds of new icons but also focused a lot more on icon consistency, namely the proper alignment of icons within the grid.</p> <p>The previous implementation of Font Awesome 4 included shims for Font Awesome 3 that was used before, the most notable one being the <code>.icon</code> notation instead of <code>.fa</code> as seen in Font Awesome 4 and later. In addition, Font Awesome 5 introduced the concept of different font weights to separate icons which was further extended in Font Awesome 6.</p> <p>In WoltLab Suite 6.0 we have made the decision to make a clean cut and drop support for the Font Awesome 3 shim as well as a Font Awesome 4 shim in order to dramatically reduce the CSS size and to clean up the implementation. Brand icons had been moved to a separate font in Font Awesome 5, but since more and more fonts are being added we have stepped back from relying on that font. We have instead made the decision to embed brand icons using inline SVGs which are much more efficient when you only need a handful of brand icons instead of loading a 100kB+ font just for a few icons.</p>"},{"location":"migration/wsc55/icons/#misuse-of-icons-as-buttons","title":"Misuse of Icons as Buttons","text":"<p>One pattern that could be found every here and then was the use of icons as buttons. Using icons in buttons is fine, as long as there is a readable title and that they are properly marked as buttons.</p> <p>A common misuse looks like this:</p> <pre><code><span class=\"icon icon16 fa-times pointer jsMyDeleteButton\" data-some-object-id=\"123\"></span>\n</code></pre> <p>This example has a few problems, for starters it is not marked as a button which would require both <code>role=\"button\"</code> and <code>tabindex=\"0\"</code> to be recognized as such. Additionally there is no title which leaves users clueless about what the option does, especially visually impaired users are possibly unable to identify the icon.</p> <p>WoltLab Suite 6.0 addresses this issue by removing all default styling from <code><button></code> elements, making them the ideal choice for button type elements.</p> <pre><code><button class=\"jsMyDeleteButton\" data-some-object-id=\"123\" title=\"descriptive title here\">{icon name='xmark'}</button>\n</code></pre> <p>The icon will appear just as before, but the button is now properly accessible.</p>"},{"location":"migration/wsc55/icons/#using-css-classes-with-icons","title":"Using CSS Classes With Icons","text":"<p>It is strongly discouraged to apply CSS classes to icons themselves. Icons inherit the text color from the surrounding context which removes the need to manually apply the color.</p> <p>If you ever need to alter the icons, such as applying a special color or transformation, you should wrap the icon in an element like <code><span></code> and apply the changes to that element instead.</p>"},{"location":"migration/wsc55/icons/#using-icons-in-templates","title":"Using Icons in Templates","text":"<p>The new template function <code>{icon}</code> was added to take care of generating the HTML code for icons, including the embedded SVGs for brand icons. Icons in HTML should not be constructed using the actual HTML element, but instead always use <code>{icon}</code>.</p> <pre><code><button class=\"button\">{icon name='bell'} I\u2019m a button with a bell icon</button>\n</code></pre> <p>Unless specified the icon will attempt to use a non-solid variant of the icon if it is available. You can explicitly request a solid version of the icon by specifying it with <code>type='solid'</code>.</p> <pre><code><button class=\"button\">{icon name='bell' type='solid'} I\u2019m a button with a solid bell icon</button>\n</code></pre> <p>Icons will implicitly assume the size <code>16</code>, but you can explicitly request a different icon size using the <code>size</code> attribute:</p> <pre><code>{icon size=24 name='bell' type='solid'}\n</code></pre>"},{"location":"migration/wsc55/icons/#brand-icons","title":"Brand Icons","text":"<p>The syntax for brand icons is very similar, but you are required to specifiy parameter <code>type='brand'</code> to access them.</p> <pre><code><button class=\"button\">{icon size=16 name='facebook' type='brand'} Share on Facebook</button>\n</code></pre>"},{"location":"migration/wsc55/icons/#using-icons-in-typescriptjavascript","title":"Using Icons in TypeScript/JavaScript","text":"<p>Buttons can be dynamically created using the native <code>document.createElement()</code> using the new <code>fa-icon</code> element.</p> <pre><code>const icon = document.createElement(\"fa-icon\");\nicon.setIcon(\"bell\", true);\n\n// This is the same as the following call in templates:\n// {icon name='bell' type='solid'}\n</code></pre> <p>You can request a size other than the default value of <code>16</code> through the <code>size</code> property:</p> <pre><code>const icon = document.createElement(\"fa-icon\");\nicon.size = 24;\nicon.setIcon(\"bell\", true);\n</code></pre>"},{"location":"migration/wsc55/icons/#creating-icons-in-html-strings","title":"Creating Icons in HTML Strings","text":"<p>You can embed icons in HTML strings by constructing the <code>fa-icon</code> element yourself.</p> <pre><code>element.innerHTML = '<fa-icon name=\"bell\" solid></fa-icon>';\n</code></pre>"},{"location":"migration/wsc55/icons/#changing-an-icon-on-runtime","title":"Changing an Icon on Runtime","text":"<p>You can alter the size by changing the <code>size</code> property which accepts the numbers <code>16</code>, <code>24</code>, <code>32</code>, <code>48</code>, <code>64</code>, <code>96</code>, <code>128</code> and <code>144</code>. The icon itself should be always set through the <code>setIcon(name: string, isSolid: boolean)</code> function which validates the values and rejects unknown icons.</p> <pre><code>const div = document.createElement(\"div\");\ndiv.innerHTML = '<fa-icon name=\"user\"></fa-icon>';\n\nconst icon = div.querySelector(\"fa-icon\");\nicon.size = 24;\nicon.setIcon(\"bell\", true);\n</code></pre>"},{"location":"migration/wsc55/icons/#migrating-icons","title":"Migrating Icons","text":"<p>We provide a helper script that eases the transition by replacing icons in templates, JavaScript and TypeScript files. The script itself is very defensive and only replaces obvious matches, it will leave icons with additional CSS classes or attributes as-is and will need to be manually adjusted.</p>"},{"location":"migration/wsc55/icons/#replacing-icons-with-the-helper-script","title":"Replacing Icons With the Helper Script","text":"<p>The helper script is part of WoltLab Suite Core and can be found in the repository at <code>extra/migrate-fa-v4.php</code>. The script must be executed from CLI and requires PHP 8.1.</p> <pre><code>$> php extra/migrate-fa-v4.php /path/to/the/target/directory/\n</code></pre> <p>The target directory will be searched recursively for files with the extension <code>tpl</code>, <code>js</code> and <code>ts</code>.</p>"},{"location":"migration/wsc55/icons/#replacing-icons-manually-by-example","title":"Replacing Icons Manually by Example","text":"<p>The helper script above is limited to only perform replacements for occurrences that it can identify without doubt. It will not replace occurrences that are formatted differently and/or make use of additional attributes, including the icon misuse as clickable elements.</p> <pre><code><li>\n <span class=\"icon icon16 fa-times pointer jsButtonFoo jsTooltip\" title=\"{lang}foo.bar.baz{/lang}\">\n</li>\n</code></pre> <p>This can be replaced using a proper button element which also provides proper accessibility for free.</p> <pre><code><li>\n <button class=\"jsButtonFoo jsTooltip\" title=\"{lang}foo.bar.baz{/lang}\">\n {icon name='xmark'}\n </button>\n</li>\n</code></pre>"},{"location":"migration/wsc55/icons/#replacing-icons-in-css","title":"Replacing Icons in CSS","text":"<p>Icons created through CSS properties are generally not supported. It was often used as a convenient way to introduce a new icon with little hassle, but has way too many downsides, including but not limited to accessibility.</p> <p>Existing icons injected through CSS properties are dysfunctional and must be converted into regular icons that are injected into the DOM. If you cannot embed them directly in the template, you should inject those using JavaScript on runtime. It is possible to inject icons using JavaScript on page load by relying entirely on native JavaScript, because the icon component is eagerly loaded ahead of time, preventing any flicker or layout shifts.</p>"},{"location":"migration/wsc55/icons/#migrating-admin-configurable-icons","title":"Migrating Admin-Configurable Icons","text":"<p>If admin-configurable icon names (e.g. created by <code>IconFormField</code>) are stored within the database, these need to be migrated with an upgrade script.</p> <p>The <code>FontAwesomeIcon::mapVersion4()</code> maps a Font Awesome 4 icon name to a string that may be passed to <code>FontAwesomeIcon::fromString()</code>. It will throw an <code>UnknownIcon</code> exception if the icon cannot be mapped. It is important to catch and handle this exception to ensure a reliable upgrade even when facing malformed data.</p> <p>See WoltLab/WCF#5288 for an example script.</p>"},{"location":"migration/wsc55/javascript/","title":"Migrating from WoltLab Suite 5.5 - TypeScript and JavaScript","text":""},{"location":"migration/wsc55/javascript/#minimum-requirements","title":"Minimum requirements","text":"<p>The ECMAScript target version has been increased to ES2022 from es2017.</p>"},{"location":"migration/wsc55/javascript/#subscribe-button-wcfuserobjectwatchsubscribe","title":"Subscribe Button (WCF.User.ObjectWatch.Subscribe)","text":"<p>We have replaced the old jQuery-based <code>WCF.User.ObjectWatch.Subscribe</code> with a more modern replacement <code>WoltLabSuite/Core/Ui/User/ObjectWatch</code>.</p> <p>The new implementation comes with a ready-to-use template (<code>__userObjectWatchButton</code>) for use within <code>contentInteractionButtons</code>: <pre><code>{include file='__userObjectWatchButton' isSubscribed=$isSubscribed objectType='foo.bar' objectID=$id}\n</code></pre></p> <p>See WoltLab/WCF#4962 for details.</p>"},{"location":"migration/wsc55/javascript/#support-for-legacy-inheritance","title":"Support for Legacy Inheritance","text":"<p>The migration from JavaScript to TypeScript was a breaking change because the previous prototype based inheritance was incompatible with ES6 classes. <code>Core.enableLegacyInheritance()</code> was added in an effort to emulate the previous behavior to aid in the migration process.</p> <p>This workaround was unstable at best and was designed as a temporary solution only. WoltLab/WCF#5041 removed the legacy inheritance, requiring all depending implementations to migrate to ES6 classes.</p>"},{"location":"migration/wsc55/libraries/","title":"Migrating from WoltLab Suite 5.5 - Third Party Libraries","text":""},{"location":"migration/wsc55/libraries/#symfony-php-polyfills","title":"Symfony PHP Polyfills","text":"<p>The Symfony Polyfills for 7.3, 7.4, and 8.0 were removed, as the minimum PHP version was increased to PHP 8.1. The Polyfills for PHP 8.2 and PHP 8.3 were added.</p> <p>Refer to the documentation within the symfony/polyfill repository for details.</p>"},{"location":"migration/wsc55/libraries/#idna-handling","title":"IDNA Handling","text":"<p>The true/punycode and pear/net_idna2 dependencies were removed, because of a lack of upstream maintenance and because the <code>intl</code> extension is now required. Instead the <code>idn_to_ascii</code> function should be used.</p>"},{"location":"migration/wsc55/libraries/#laminas-diactoros","title":"Laminas Diactoros","text":"<p>Diactoros was updated from version 2.4 to 3.0.</p>"},{"location":"migration/wsc55/libraries/#input-validation","title":"Input Validation","text":"<p>WoltLab Suite 6.0 ships with cuyz/valinor 1.6 as a reliable solution to validate untrusted external input values.</p> <p>Refer to the documentation within the CuyZ/Valinor repository for details.</p>"},{"location":"migration/wsc55/libraries/#diff","title":"Diff","text":"<p>WoltLab Suite 6.0 ships with sebastian/diff as a replacement for <code>wcf\\util\\Diff</code>. The <code>wcf\\util\\Diff::rawDiffFromSebastianDiff()</code> method was added as a compatibility helper to transform sebastian/diff's output format into Diff's output format.</p> <p>Refer to the documentation within the sebastianbergmann/diff repository for details on how to use the library.</p> <p>See WoltLab/WCF#4918 for examples on how to use the compatibility helper if you need to preserve the output format for the time being.</p>"},{"location":"migration/wsc55/libraries/#content-negotiation","title":"Content Negotiation","text":"<p>WoltLab Suite 6.0 ships with willdurand/negotiation to perform HTTP content negotiation based on the headers sent within the request. The <code>wcf\\http\\Helper::getPreferredContentType()</code> method provides a convenience interface to perform content negotiation with regard to the MIME type. It is strongly recommended to make use of this method instead of interacting with the library directly.</p> <p>In case the API provided by the helper method is insufficient, please refer to the documentation within the willdurand/Negotiation repository for details on how to use the library.</p>"},{"location":"migration/wsc55/libraries/#cronjobs","title":"Cronjobs","text":"<p>WoltLab Suite 6.0 ships with dragonmantank/cron-expression as a replacement for <code>wcf\\util\\CronjobUtil</code>.</p> <p>This library is considered an internal library / implementation detail and not covered by backwards compatibility promises of WoltLab Suite.</p>"},{"location":"migration/wsc55/libraries/#ico-converter","title":".ico converter","text":"<p>The chrisjean/php-ico dependency was removed, because of a lack of upstream maintenance. As the library was only used for Favicon generation, no replacement is made available. The favicons are now delivered as PNG files.</p>"},{"location":"migration/wsc55/php/","title":"Migrating from WoltLab Suite 5.5 - PHP","text":""},{"location":"migration/wsc55/php/#minimum-requirements","title":"Minimum requirements","text":"<p>The minimum requirements have been increased to the following:</p> <ul> <li>PHP: 8.1.2 (64 bit only); <code>intl</code> extension</li> <li>MySQL: 8.0.30</li> <li>MariaDB: 10.5.12</li> </ul> <p>It is recommended to make use of the newly introduced features whereever possible. Please refer to the PHP documentation for details.</p>"},{"location":"migration/wsc55/php/#inheritance","title":"Inheritance","text":""},{"location":"migration/wsc55/php/#parameter-return-property-types","title":"Parameter / Return / Property Types","text":"<p>Parameter, return, and property types have been added to methods of various classes/interfaces. This might cause errors during inheritance, because the types are not compatible with the newly added types in the parent class.</p> <p>Return types may already be added in package versions for older WoltLab Suite branches to be forward compatible, because return types are covariant.</p>"},{"location":"migration/wsc55/php/#final","title":"final","text":"<p>The <code>final</code> modifier was added to several classes that were not usefully set up for inheritance in the first place to make it explicit that inheriting from these classes is unsupported.</p>"},{"location":"migration/wsc55/php/#application-boot","title":"Application Boot","text":""},{"location":"migration/wsc55/php/#request-specific-logic-will-no-longer-happen-during-boot","title":"Request-specific logic will no longer happen during boot","text":"<p>Historically the application boot in <code>WCF</code>\u2019s constructor performed processing based on fundamentally request-specific values, such as the accessed URL, the request body, or cookies. This is problematic, because this makes the boot dependent on the HTTP environment which may not be be available, e.g. when using the CLI interface for maintenance jobs. The latter needs to emulate certain aspects of the HTTP environment for the boot to succeed. Furthermore one of the goals of the introduction of PSR-7/PSR-15-based request processing that was started in WoltLab Suite 5.5 is the removal of implicit global state in favor of explicitly provided values by means of a <code>ServerRequestInterface</code> and thus to achieve a cleaner architecture.</p> <p>To achieve a clean separation this type of request-specific logic will incrementally be moved out of the application boot in <code>WCF</code>\u2019s constructor and into the request processing stack that is launched by <code>RequestHandler</code>, e.g. by running appropriate PSR-15 middleware.</p> <p>An example of this type of request-specific logic that was previously happening during application boot is the check that verifies whether a user is banned and denies access otherwise. This check is based on a request-specific value, namely the user\u2019s session which in turn is based on a provided (HTTP) cookie. It is now moved into the <code>CheckUserBan</code> middleware.</p> <p>This move implies that custom scripts that include WoltLab Suite Core\u2019s <code>global.php</code>, without also invoking <code>RequestHandler</code> will no longer be able to rely on this type of access control having happened and will need to implement it themselves, e.g. by manually running the appropriate middlewares.</p> <p>Notably the following checks have been moved into a middleware:</p> <ul> <li>Denying access to banned users (WoltLab/WCF#4935)</li> <li>ACP authentication (WoltLab/WCF#4939)</li> </ul> <p>The initialization of the session itself and dependent subsystems (e.g. the user object and thus the current language) is still running during application boot for now. However it is planned to also move the session initialization into the middleware in a future version and then providing access to the session by adding an attribute on the <code>ServerRequestInterface</code>, instead of querying the session via <code>WCF::getSession()</code>. As such you should begin to stop relying on the session and user outside of <code>RequestHandler</code>\u2019s middleware stack and should also avoid calling <code>WCF::getUser()</code> and <code>WCF::getSession()</code> outside of a controller, instead adding a <code>User</code> parameter to your methods to allow an appropriate user to be passed from the outside.</p> <p>An example of a method that implicitly relies on these global values is the VisitTracker's <code>trackObjectVisit()</code> method. It only takes the object type, object ID and timestamp as the parameter and will determine the <code>userID</code> by itself. The <code>trackObjectVisitByUserIDs()</code> method on the other hand does not rely on global values. Instead the relevant user IDs need to be passed explicitly from the controller as parameters, thus making the information the method works with explicit. This also makes the method reusable for use cases where an object should be marked as visited for a user other than the active user, without needing to temporarily switch the active user in the session.</p> <p>The same is true for \u201cpermission checking\u201d methods on <code>DatabaseObject</code>s. Instead of having a <code>$myObject->canView()</code> method that uses <code>WCF::getSession()</code> or <code>WCF::getUser()</code> internally, the user should explicitly be passed to the method as a parameter, allowing for permission checks to happen in a different context, for example send sending notification emails.</p> <p>Likewise event listeners should not access these request-specific values at all, because they are unable to know whether the event was fired based on these request-specific values or whether some programmatic action fired the event for another arbitrary user. Instead they must retrieve the appropriate information from the event data only.</p>"},{"location":"migration/wsc55/php/#bootstrap-scripts","title":"Bootstrap Scripts","text":"<p>WoltLab Suite 6.0 adds package-specific bootstrap scripts allowing a package to execute logic during the application boot to prepare the environment before the request is passed through the middleware pipeline into the controller in <code>RequestHandler</code>.</p> <p>Bootstrap scripts are stored in the <code>lib/bootstrap/</code> directory of WoltLab Suite Core with the package identifier as the file name. They do not need to be registered explicitly, as one future goal of the bootstrap scripts is reducing the amount of system state that needs to be stored within the database. Instead WoltLab Suite Core will automatically create a bootstrap loader that includes all installed bootstrap scripts as part of the package installation and uninstallation process.</p> <p>Bootstrap scripts will be loaded and the bootstrap functions will executed based on a topological sorting of all installed packages. A package can rely on all bootstrap scripts of its dependencies being loaded before its own bootstrap script is loaded. It can also rely on all bootstrap functions of its dependencies having executed before its own bootstrap functions is executed. However it cannot rely on any specific loading and execution order of non-dependencies.</p> <p>As hinted at in the previous paragraph, executing the bootstrap scripts happens in two phases:</p> <ol> <li>All bootstrap scripts will be <code>include()</code>d in topological order. The script is expected to return a <code>Closure</code> that is executed in phase 2.</li> <li>Once all bootstrap scripts have been included, the returned <code>Closure</code>s will be executed in the same order the bootstrap scripts were loaded.</li> </ol> files/lib/bootstrap/com.example.foo.php<pre><code><?php\n\n// Phase (1).\n\nreturn static function (): void {\n // Phase (2).\n};\n</code></pre> <p>For the vast majority of packages it is expected that the phase (1) bootstrapping is not used, except to return the <code>Closure</code>. Instead the logic should reside in the <code>Closure</code>s body that is executed in phase (2).</p>"},{"location":"migration/wsc55/php/#registering-ievent-listeners","title":"Registering <code>IEvent</code> listeners","text":"<p>An example use case for bootstrap scripts with WoltLab Suite 6.0 is registering event listeners for <code>IEvent</code>-based events that were added with WoltLab Suite 5.5, instead of using the eventListener PIP. Registering event listeners within the bootstrap script allows you to leverage your IDE\u2019s autocompletion for class names and and prevents forgetting the explicit uninstallation of old event listeners during a package upgrade.</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\event\\listener\\ValueDumpListener;\nuse wcf\\system\\foo\\event\\ValueAvailable;\n\nreturn static function (): void {\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n ValueDumpListener::class\n );\n\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n static function (ValueAvailable $event): void {\n // For simple use cases a `Closure` instead of a class name may be used.\n \\var_dump($event->getValue());\n }\n );\n};\n</code></pre>"},{"location":"migration/wsc55/php/#request-processing","title":"Request Processing","text":"<p>As previously mentioned in the Application Boot section, WoltLab Suite 6.0 improves support for PSR-7/PSR-15-based request processing that was initially announced with WoltLab Suite 5.5.</p> <p>WoltLab Suite 5.5 added support for returning a PSR-7 <code>ResponseInterface</code> from a controller and recommended to migrate existing controllers based on <code>AbstractAction</code> to make use of <code>RedirectResponse</code> and <code>JsonResponse</code> instead of using <code>HeaderUtil::redirect()</code> or manually emitting JSON with appropriate headers. Processing the request values still used PHP\u2019s superglobals (specifically <code>$_GET</code> and <code>$_POST</code>).</p> <p>WoltLab Suite 6.0 adds support for controllers based on PSR-15\u2019s <code>RequestHandlerInterface</code>, supporting request processing based on a provided PSR-7 <code>ServerRequestInterface</code> object.</p>"},{"location":"migration/wsc55/php/#recommended-changes-for-woltlab-suite-60","title":"Recommended changes for WoltLab Suite 6.0","text":"<p>It is recommended to use <code>RequestHandlerInterface</code>-based controllers whenever an <code>AbstractAction</code> would previously be used. Furthermore any AJAX-based logic that would previously rely on <code>AJAXProxyAction</code> combined with a method in an <code>AbstractDatabaseObjectAction</code> should also be implemented using a dedicated <code>RequestHandlerInterface</code>-based controller. Both <code>AbstractAction</code> and <code>AJAXProxyAction</code>-based AJAX requests should be considered soft-deprecated going forward.</p> <p>When creating a <code>RequestHandlerInterface</code>-based controller, care should be taken to ensure no mutable state is stored in object properties of the controller itself. The state of the controller object must be identical before, during and after a request was processed. Any required values must be passed explicitly by means of method parameters and return values. Likewise any functionality called by the controller\u2019s <code>handle()</code> method should not rely on implicit global values, such as <code>WCF::getUser()</code>, as was explained in the previous section about request-specific logic.</p> <p>The recommended pattern for a <code>RequestHandlerInterface</code>-based controller looks as follows:</p> files/lib/action/MyFancyAction.class.php<pre><code><?php\n\nnamespace wcf\\action;\n\nuse Laminas\\Diactoros\\Response;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\n\nfinal class MyFancyAction implements RequestHandlerInterface\n{\n public function __construct()\n {\n /* 0. Explicitly register services used by the controller, to\n * make dependencies explicit and to avoid accidentally using\n * global state outside of a controller.\n */\n }\n\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n /* 1. Perform permission checks and input validation. */\n\n /* 2. Perform the action. The action must not rely on global state,\n * but instead only on explicitly passed values. It should assume\n * that permissions have already been validated by the controller,\n * allowing it to be reusable programmatically.\n */\n\n /* 3. Perform post processing. */\n\n /* 4. Prepare the response, e.g. by querying an updated object from\n * the database.\n */\n\n /* 5. Send the response. */\n return new Response();\n }\n}\n</code></pre> <p>It is recommended to leverage Valinor for structural validation of input values if using the FormBuilder is not a good fit, specifically for any values that are provided implicitly and are expected to be correct. WoltLab Suite includes a middleware that will automatically convert unhandled <code>MappingError</code>s into a response with status HTTP 400 Bad Request.</p> <p>XSRF validation will implicitly be performed for any request that uses a HTTP verb other than <code>GET</code>. Likewise any requests with a JSON body will automatically be decoded by a middleware and stored as the <code>ServerRequestInterface</code>\u2019s parsed body.</p>"},{"location":"migration/wsc55/php/#querying-requesthandlerinterface-based-controllers-via-javascript","title":"Querying RequestHandlerInterface-based controllers via JavaScript","text":"<p>The new <code>WoltLabSuite/Core/Ajax/Backend</code> module may be used to easily query a <code>RequestHandlerInterface</code>-based controller. The JavaScript code must not make any assumptions about the URI structure to reach the controller. Instead the endpoint must be generated using <code>LinkHandler</code> and explicitly provided, e.g. by storing it in a <code>data-endpoint</code> attribute:</p> <pre><code><button\n class=\"button fancyButton\"\n data-endpoint=\"{link controller='MyFancy'}{/link}\"\n>Click me!</button>\n</code></pre> <pre><code>const button = document.querySelector('.fancyButton');\nbutton.addEventListener('click', async (event) => {\n const request = prepareRequest(button.dataset.endpoint)\n .get(); // or: .post(\u2026)\n\n const response = await request.fetchAsResponse(); // or: .fetchAsJson()\n});\n</code></pre>"},{"location":"migration/wsc55/php/#formbuilder","title":"FormBuilder","text":"<p>The <code>Psr15DialogForm</code> class combined with the <code>usingFormBuilder()</code> method of <code>dialogFactory()</code> provides a \u201cbatteries-included\u201d solution to create a AJAX- and FormBuilder-based <code>RequestHandlerInterface</code>-based controller.</p> <p>Within the JavaScript code the endpoint is queried using:</p> <pre><code>const { ok, result } = await dialogFactory()\n .usingFormBuilder()\n .fromEndpoint(url);\n</code></pre> <p>The returned <code>Promise</code> will resolve when the dialog is closed, either by successfully submitting the form or by manually closing it and thus aborting the process. If the form was submitted successfully <code>ok</code> will be <code>true</code> and <code>result</code> will contain the controller\u2019s response. If the dialog was closed without successfully submitting the form, <code>ok</code> will be <code>false</code> and <code>result</code> will be set to <code>undefined</code>.</p> <p>Within the PHP code, the form may be created as usual, but use <code>Psr15DialogForm</code> as the form document. The controller must return <code>$dialogForm->toJsonResponse()</code> for <code>GET</code> requests and validate the <code>ServerRequestInterface</code> using <code>$dialogForm->validateRequest($request)</code> for <code>POST</code> requests. The latter will return a <code>ResponseInterface</code> to be returned if the validation fails, otherwise <code>null</code> is returned. If validation succeeded, the controller must perform the resulting action and return a <code>JsonResponse</code> with the <code>result</code> key:</p> <pre><code>if ($request->getMethod() === 'GET') {\n return $dialogForm->toResponse();\n} elseif ($request->getMethod() === 'POST') {\n $response = $dialogForm->validateRequest($request);\n if ($response !== null) {\n return $response;\n }\n\n $data = $dialogForm->getData();\n\n // Use $data.\n\n return new JsonResponse([\n 'result' => [\n 'some' => 'value',\n ],\n ]);\n} else {\n // The used method is validated by a middleware. Methods that are not\n // GET or POST need to be explicitly allowed using the 'AllowHttpMethod'\n // attribute.\n throw new \\LogicException('Unreachable');\n}\n</code></pre>"},{"location":"migration/wsc55/php/#example","title":"Example","text":"<p>A complete example, showcasing all the patterns can be found in WoltLab/WCF#5106. This example showcases how to:</p> <ul> <li>Store used services within the controller\u2019s constructor.</li> <li>Perform validation of inputs using Valinor.</li> <li>Perform permission checks.</li> <li>Use the FormBuilder.</li> <li>Delegate the actual processing to a reusable command that does not rely on global state.</li> <li>Store the request endpoint as a <code>data-*</code> attribute.</li> </ul>"},{"location":"migration/wsc55/php/#package-system","title":"Package System","text":""},{"location":"migration/wsc55/php/#required-minversion-for-required-packages","title":"Required \u201cminversion\u201d for required packages","text":"<p>The <code>minversion</code> attribute of the <code><requiredpackage></code> tag is now required.</p>"},{"location":"migration/wsc55/php/#rejection-of-pl-versions","title":"Rejection of \u201cpl\u201d versions","text":"<p>Woltlab Suite 6.0 no longer accepts package versions with the \u201cpl\u201d suffix as valid.</p>"},{"location":"migration/wsc55/php/#removal-of-api-compatibility","title":"Removal of API compatibility","text":"<p>WoltLab Suite 6.0 removes support for the deprecated API compatibility functionality. Any packages with a <code><compatibility></code> tag in their package.xml are assumed to not have been updated for WoltLab Suite 6.0 and will be rejected during installation. Furthermore any packages without an explicit requirement for <code>com.woltlab.wcf</code> in at least version <code>5.4.22</code> are also assumed to not have been updated for WoltLab Suite 6.0 and will also be rejected. The latter check is intended to reject old and most likely incompatible packages where the author forgot to add either an <code><excludedpackage></code> or a <code><compatibility></code> tag before releasing it.</p>"},{"location":"migration/wsc55/php/#package-installation-plugins","title":"Package Installation Plugins","text":""},{"location":"migration/wsc55/php/#eventlistener","title":"EventListener","text":"<p>Installing unnamed event listeners is no longer supported. The <code>name</code> attribute needs to be specified for all event listeners.</p> <p>Deleting unnamed event listeners still is possible to allow for a clean migration of existing listeners.</p>"},{"location":"migration/wsc55/php/#cronjob","title":"Cronjob","text":"<p>Installing unnamed cronjobs is no longer supported. The <code>name</code> attribute needs to be specified for all event listeners.</p> <p>Deleting unnamed cronjobs still is possible to allow for a clean migration of existing cronjobs.</p> <p>The cronjob PIP now supports the <code><expression></code> element, allowing to define the cronjob schedule using a full expression instead of specifying the five elements separately.</p>"},{"location":"migration/wsc55/php/#database","title":"Database","text":"<p>The <code>$name</code> parameter of <code>DatabaseTableIndex::create()</code> is no longer optional. Relying on the auto-generated index name is strongly discouraged, because of unfixable inconsistent behavior between the SQL PIP and the PHP DDL API. See WoltLab/WCF#4505 for further background information.</p> <p>The autogenerated name can still be requested by passing an empty string as the <code>$name</code>. This should only be done for backwards compatibility purposes and to migrate an index with an autogenerated name to an index with an explicit name. An example script can be found in WoltLab/com.woltlab.wcf.conversation@a33677ca051f.</p>"},{"location":"migration/wsc55/php/#internationalization","title":"Internationalization","text":"<p>WoltLab Suite 6.0 increases the System Requirements to require PHP\u2019s intl extension to be installed and enabled, allowing you to rely on the functionality provided by it to better match the rules and conventions of the different languages and regions of the world.</p> <p>One example would be the formatting of numbers. WoltLab Suite included a feature to group digits within large numbers since early versions using the <code>StringUtil::addThousandsSeparator()</code> method. While this method was able to account for some language-specific differences, e.g. by selecting an appropriate separator character based on a phrase, it failed to account for all the differences in number formatting across countries and cultures.</p> <p>As an example, English as written in the United States of America uses commas to create groups of three digits within large numbers: 123,456,789. English as written in India on the other hand also uses commas, but digits are not grouped into groups of three. Instead the right-most three digits form a group and then another comma is added every two digits: 12,34,56,789.</p> <p>Another example would be German as used within Germany and Switzerland. While both countries use groups of three, the separator character differs. Germany uses a dot (123.456.789), whereas Switzerland uses an apostrophe (123\u2019456\u2019789). The correct choice of separator could already be configured using the afore-mentioned phrase, but this is both inconvenient and fails to account for other differences between the two countries. It also made it hard to keep the behavior up to date when rules change.</p> <p>PHP\u2019s intl extension on the other hand builds on the official Unicode rules, by relying on the ICU library published by the Unicode consortium. As such it is aware of the rules of all relevant languages and regions of the world and it is already kept up to date by the operating system\u2019s package manager.</p> <p>For the four example regions (en_US, en_IN, de_DE, de_CH) intl\u2019s <code>NumberFormatter</code> class will format the number 123456789 as follows, correctly implementing the rules:</p> <pre><code>php > var_dump((new NumberFormatter('en_US', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(11) \"123,456,789\"\nphp > var_dump((new NumberFormatter('en_IN', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(12) \"12,34,56,789\"\nphp > var_dump((new NumberFormatter('de_DE', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(11) \"123.456.789\"\nphp > var_dump((new NumberFormatter('de_CH', \\NumberFormatter::DEFAULT_STYLE))->format(123_456_789));\nstring(15) \"123\u2019456\u2019789\"\n</code></pre> <p>WoltLab Suite\u2019s <code>StringUtil::formatNumeric()</code> method is updated to leverage the <code>NumberFormatter</code> internally. However your package might have special requirements regarding formatting, for example when formatting currencies where the position of the currency symbol differs across languages. In those cases your package should manually create an appropriately configured class from Intl\u2019s feature set. The correct locale can be queried by the new <code>Language::getLocale()</code> method.</p> <p>Another use case that showcases the <code>Language::getLocale()</code> method might be localizing a country name using <code>locale_get_display_region()</code>:</p> <pre><code>php > var_dump(\\wcf\\system\\WCF::getLanguage()->getLocale());\nstring(5) \"en_US\"\nphp > var_dump(locale_get_display_region('_DE', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(7) \"Germany\"\nphp > var_dump(locale_get_display_region('_US', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(13) \"United States\"\nphp > var_dump(locale_get_display_region('_IN', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(5) \"India\"\nphp > var_dump(locale_get_display_region('_BR', \\wcf\\system\\WCF::getLanguage()->getLocale()));\nstring(6) \"Brazil\"\n</code></pre> <p>See WoltLab/WCF#5048 for details.</p>"},{"location":"migration/wsc55/php/#indicating-parameters-that-hold-sensitive-information","title":"Indicating parameters that hold sensitive information","text":"<p>PHP 8.2 adds native support for redacting parameters holding sensitive information in stack traces. Parameters with the <code>#[\\SensitiveParameter]</code> attribute will show a placeholder value within the stack trace and the error log.</p> <p>WoltLab Suite\u2019s exception handler contains logic to manually apply the sanitization for PHP versions before 8.2.</p> <p>It is strongly recommended to add this attribute to all parameters holding sensitive information. Examples for sensitive parameters include passwords/passphrases, access tokens, plaintext values to be encrypted, or private keys.</p> <p>As attributes are fully backwards and forwards compatible it is possible to apply the attribute to packages targeting older WoltLab Suite or PHP versions without causing errors.</p> <p>Example:</p> <pre><code>function checkPassword(\n #[\\SensitiveParameter]\n $password,\n): bool {\n // \u2026\n}\n</code></pre> <p>See the PHP RFC: Redacting parameters in back traces for more details.</p>"},{"location":"migration/wsc55/php/#conditions","title":"Conditions","text":""},{"location":"migration/wsc55/php/#abstractintegercondition","title":"AbstractIntegerCondition","text":"<p>Deriving from <code>AbstractIntegerCondition</code> now requires to explicitly implement <code>protected function getIdentifier(): string</code>, instead of setting the <code>$identifier</code> property. This is to ensure that all conditions specify a unique identifier, instead of accidentally relying on a default value. The <code>$identifier</code> property will no longer be used and may be removed.</p> <p>See WoltLab/WCF#5077 for details.</p>"},{"location":"migration/wsc55/php/#rebuild-workers","title":"Rebuild Workers","text":"<p>Rebuild workers should no longer be registered using the <code>com.woltlab.wcf.rebuildData</code> object type definition. You can attach an event listener to the <code>wcf\\system\\worker\\event\\RebuildWorkerCollecting</code> event inside a bootstrap script to lazily register workers. The class name of the worker is registered using the event\u2019s <code>register()</code> method:</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\worker\\event\\RebuildWorkerCollecting;\n\nreturn static function (): void {\n $eventHandler = EventHandler::getInstance();\n\n $eventHandler->register(RebuildWorkerCollecting::class, static function (RebuildWorkerCollecting $event) {\n $event->register(\\bar\\system\\worker\\BazWorker::class, 0);\n });\n};\n</code></pre>"},{"location":"migration/wsc55/templates/","title":"Migrating from WoltLab Suite 5.5 - Templates","text":""},{"location":"migration/wsc55/templates/#template-modifiers","title":"Template Modifiers","text":"<p>WoltLab Suite featured a strict allow-list for template modifiers within the enterprise mode since 5.2. This allow-list has proved to be a reliable solution against malicious templates. To improve security and to reduce the number of differences between enterprise mode and non-enterprise mode the allow-list will always be enabled going forward.</p> <p>It is strongly recommended to keep the template logic as simple as possible by moving the heavy lifting into regular PHP code, reducing the number of (specialized) modifiers that need to be applied.</p> <p>See WoltLab/WCF#4788 for details.</p>"},{"location":"migration/wsc55/templates/#time-rendering","title":"Time Rendering","text":"<p>The <code>|time</code>, <code>|plainTime</code> and <code>|date</code> modifiers have been deprecated and replaced by a unified <code>{time}</code> function.</p> <p>The main benefit is that it is no longer necessary to specify the <code>@</code> symbol when rendering the interactive time element, making it easier to perform a security review of templates by searching for the <code>@</code> symbol.</p> <p>See WoltLab/WCF#5459 for details.</p>"},{"location":"migration/wsc55/templates/#comments","title":"Comments","text":"<p>In WoltLab Suite 6.0 the comment system has been overhauled. In the process, the integration of comments via templates has been significantly simplified:</p> <pre><code>{include file='comments' commentContainerID='someElementId' commentObjectID=$someObjectID}\n</code></pre> <p>An example for the migration of existing template integrations can be found here.</p> <p>See WoltLab/WCF#5210 for more details.</p>"},{"location":"migration/wsc55/templates/#the-button-element","title":"The <code><button></code> Element","text":"<p>The styling of the <code><button></code> has been completely removed in WoltLab Suite 6.0 and the element has no longer any kind of styling. This change allows the element to be used in a lot of places that previously had to use an <code>a[href=\"#\"][role=\"button\"]</code> to replicate the same behavior.</p> <p>If you have previously used the button element as an actual button, you should add the CSS class <code>.button</code> to it.</p> <p>It is recommended to identify an uses of the anchor element to replicate a native button and to use the proper <code><button></code> element from now on. Buttons will implicitly submit a form, therefore you should set the <code>type</code> attribute to explicitly define its behavior.</p> <pre><code><form method=\"post\">\n <!-- These two buttons will submit the form. -->\n <button>Button 1</button>\n <button type=\"submit\">Button 2</button>\n\n <!-- Clicking this button does nothing on its own. -->\n <button type=\"button\">Button 3</button>\n</form>\n</code></pre> <p>See WoltLab/WCF#4834 for more details.</p>"},{"location":"migration/wsc55/templates/#pagination","title":"Pagination","text":"<p>The <code>{pages}</code> template function has been deprecated and replaced by the new <code><woltlab-core-pagination></code> web component.</p> <p>If you continue to use the <code>{pages}</code> template function, it will automatically generate the code for the web component. </p> <p>See WoltLab/WCF#5158 for more details.</p>"},{"location":"migration/wsc60/deprecations_removals/","title":"Migrating from WoltLab Suite 6.0 - Deprecations and Removals","text":"<p>With version 6.1, we have deprecated certain components and removed several other components that have been deprecated for many years.</p>"},{"location":"migration/wsc60/deprecations_removals/#deprecations","title":"Deprecations","text":""},{"location":"migration/wsc60/deprecations_removals/#php","title":"PHP","text":""},{"location":"migration/wsc60/deprecations_removals/#classes","title":"Classes","text":"<ul> <li><code>wcf\\system\\exception\\ValidateActionException</code></li> <li><code>wcf\\system\\bbcode\\HtmlBBCodeParser</code> (WoltLab/WCF#5874)</li> <li><code>wcf\\action\\AbstractOauth2Action</code> (WoltLab/WCF#5891)</li> <li><code>wcf\\data\\user\\menu\\item\\event\\UserMenuItemIconResolving</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\cache\\event\\CacheCleared</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\event\\IEvent</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\event\\IInterruptableEvent</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\event\\TInterruptableEvent</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\LanguageContentCopying</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\LanguageImported</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\PhraseChanged</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\language\\event\\PreloadPhrasesCollecting</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\moderation\\queue\\event\\UserAssigned</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\package\\event\\PackageInstallationPluginSynced</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\package\\event\\PackageListChanged</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\package\\event\\PackageUpdateListChanged</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\user\\authentication\\event\\UserLoggedIn</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\user\\event\\UsernameValidating</code> (WoltLab/WCF#5912)</li> <li><code>wcf\\system\\worker\\event\\RebuildWorkerCollecting</code> (WoltLab/WCF#5912)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#methods","title":"Methods","text":"<ul> <li><code>wcf\\system\\session\\SessionHandler::resetSessions()</code> (WoltLab/WCF#3767)</li> <li><code>wcf\\system\\comment\\manager\\ICommentManager::canModerate()</code> (WoltLab/WCF#5852)</li> <li><code>wcf\\system\\box\\BoxHandler::createBoxCondition()</code> (WoltLab/WCF#5906)</li> <li><code>wcf\\system\\box\\BoxHandler::addBoxToPageAssignments()</code> (WoltLab/WCF#5906)</li> <li>Non-standard methods of <code>wcf\\data\\comment\\CommentAction</code> (WoltLab/WCF#5944)</li> <li>Non-standard methods of <code>wcf\\data\\comment\\response\\CommentResponseAction</code> (WoltLab/WCF#5944)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#javascript","title":"JavaScript","text":"<ul> <li><code>WCF.User.Action.Follow</code> (WoltLab/WCF#5747)</li> <li><code>WCF.User.Registration.Validation</code> (WoltLab/WCF#5716)</li> <li><code>WCF.User.Registration.Validation.Username</code> (WoltLab/WCF#5716)</li> <li><code>WCF.User.Registration.Validation.EmailAddress</code> (WoltLab/WCF#5716)</li> <li><code>WCF.User.RecentActivityLoader</code> (WoltLab/WCF#5804)</li> <li><code>WoltLabSuite/Core/Ui/User/Activity/Recent</code> (WoltLab/WCF#5804)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#removals","title":"Removals","text":""},{"location":"migration/wsc60/deprecations_removals/#php_1","title":"PHP","text":""},{"location":"migration/wsc60/deprecations_removals/#classes_1","title":"Classes","text":"<ul> <li><code>wcf\\data\\spider\\Spider</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\data\\spider\\SpiderAction</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\data\\spider\\SpiderEditor</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\data\\spider\\SpiderList</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\system\\cache\\SpiderCacheBuilder</code> (WoltLab/WCF#5823)</li> <li><code>wcf\\system\\cronjob\\RefreshSearchRobotsCronjob</code> (WoltLab/WCF#5823)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#javascript_1","title":"JavaScript","text":"<ul> <li><code>WCF.User.Registration.LostPassword</code></li> <li><code>WCF.Message.BBCode.CodeViewer</code></li> <li><code>WCF.ACL</code> (WoltLab/WCF#5860)</li> <li><code>WoltLabSuite/Core/Component/Comment/GuestDialog</code> (WoltLab/WCF#5944)</li> </ul>"},{"location":"migration/wsc60/deprecations_removals/#other","title":"Other","text":"<ul> <li>Option category <code>security.blacklist</code> and <code>security.blacklist.custom</code></li> <li>Option <code>BLACKLIST_SFS_ACTION</code> (replaced by <code>REGISTER_ANTISPAM_ACTION</code>)</li> </ul>"},{"location":"migration/wsc60/php/","title":"Migrating from WoltLab Suite 6.0 - PHP","text":""},{"location":"migration/wsc60/php/#htmlupcastprocessor","title":"HtmlUpcastProcessor","text":"<p>The <code>HtmlUpcastProcessor</code> is intended for use in all forms where the CKEditor5 is available as an input field. Its primary purpose is to inject necessary information into the HTML to ensure correct rendering within the editor. It is important to note that the <code>HtmlUpcastProcessor</code> is not designed for content storage and should be utilized within the <code>assignVariables</code> method.</p>"},{"location":"migration/wsc60/php/#example","title":"Example","text":"<pre><code>namespace wcf\\form;\n\nuse wcf\\system\\html\\upcast\\HtmlUpcastProcessor;\n\nclass MyForm extends AbstractForm {\n\n public string $messageObjectType = ''; // object type of `com.woltlab.wcf.message`\n public string $text = '';\n\n public function assignVariables() {\n parent::assignVariables();\n\n $upcastProcessor = new HtmlUpcastProcessor();\n $upcastProcessor->process($this->text ?? '', $this->messageObjectType, 0);\n WCF::getTPL()->assign('text', $upcastProcessor->getHtml());\n }\n}\n</code></pre>"},{"location":"migration/wsc60/php/#rss-feeds","title":"RSS Feeds","text":"<p>A new API for the output of content as an RSS feed has been introduced.</p>"},{"location":"migration/wsc60/php/#acp-menu-items","title":"ACP Menu Items","text":"<p>A new API for adding ACP menu items has been introduced. The previous option of adding menu entries via PIP is still supported, but is to be discontinued in the long term.</p>"},{"location":"migration/wsc60/php/#user-activity-events","title":"User Activity Events","text":"<p>The user activity events have been redesigned for a modern look and better user experience.</p> <p>This includes the following changes:</p> <ul> <li>The title now includes the author's name and forms a complete sentence. Example: <code><strong>{$author}</strong> replied to a comment by <strong>{$commentAuthor}</strong> on article <strong>{$article->getTitle()}</strong>.</code></li> <li>The title no longer contains links.</li> <li>Keywords in the title are highlighted in bold (e.g. author's name, topic title).</li> <li>The description is a simple text version of the content (no formatting) truncated to 500 characters.</li> <li>The event as a whole can be linked with a link that leads to the content (the entire area is clickable).</li> </ul> <p>The changes are backwards compatible, but we recommend to apply them for a uniform user experience.</p>"},{"location":"migration/wsc60/php/#example_1","title":"Example","text":"<pre><code>$object = new FooBarObject(1);\n$event->setTitle(WCF::getLanguage()->getDynamicVariable('com.foo.bar', [\n // variables\n]));\n$event->setDescription(\n StringUtil::encodeHTML(\n StringUtil::truncate($object->getPlainTextMessage(), 500)\n ),\n true\n);\n$event->setLink($object->getLink());\n</code></pre>"},{"location":"migration/wsc60/php/#box-configuration","title":"Box Configuration","text":"<p>The Methods <code>wcf\\system\\box\\BoxHandler::createBoxCondition()</code> and <code>wcf\\system\\box\\BoxHandler::addBoxToPageAssignments()</code> were used for the configuration of boxes during package installation. These methods were deprecated with version 6.1, as they led to an initialization of the box handler and can therefore cause undesirable side effects.</p> <p>The new commands <code>wcf\\system\\box\\command\\CreateBoxCondition</code> and <code>wcf\\system\\box\\command\\CreateBoxToPageAssignments</code> can be used instead.</p> <p>Example:</p> <pre><code>(new \\wcf\\system\\box\\command\\CreateBoxCondition(\n 'boxIdentifier',\n 'conditionDefinition',\n 'conditionObjectType',\n ['parameter' => 12345]\n))();\n\n(new \\wcf\\system\\box\\command\\CreateBoxToPageAssignments(\n 'boxIdentifier',\n ['pageIdentifier']\n))();\n</code></pre>"},{"location":"migration/wsc60/php/#psr-14-events","title":"PSR-14 Events","text":"<p>The old practice of placing events where they are used is somewhat inconsistent and worst of all highly intransparent for discovery purposes. WoltLab Suite 6.1 therefore introduces a unified directory structure grouped by the app namespace.</p> <p>All PSR-14 events now use the new <code>event</code> namespace (located under <code>lib/event</code>). See the PSR-14 event documentation for details.</p> <p>The changes are backwards compatible, the old namespaces can still be used.</p>"},{"location":"migration/wsc60/php/#comment-backend","title":"Comment Backend","text":"<p>The backend of the comment system has been revised and is now based on the new RPC controllers and commands. The previous backend (the methods of <code>CommentAction</code> and <code>CommentResponseAction</code>) remains for backward compatibility reasons, but has been deprecated. If you do not interact directly with the backend, no changes are usually required. See WoltLab/WCF#5944 for more details.</p>"},{"location":"migration/wsc60/php/#enable-the-sandbox-for-templates-inside-of-bbcodes","title":"Enable the Sandbox for Templates Inside of BBCodes","text":"<p>BBCodes can appear in a lot of different places and assigning template variables through <code>WCF::getTPL()->assign()</code> can cause variables from the ambient enviroment to be overwritten. You should not use this method in BBCodes at all and instead pass the variables as the third argument to <code>WCF::getTPL()->fetch()</code> as well as enabling the sandbox.</p> <pre><code>// Before\nWCF::getTPL()->assign([\n 'foo' => 'bar',\n]);\nreturn WCF::getTPL()->fetch('templateName', 'application');\n\n// After\nreturn WCF::getTPL()->fetch('templateName', 'application', [\n 'foo' => 'bar',\n], true);\n</code></pre> <p>See WoltLab/WCF#5910 for more details.</p>"},{"location":"migration/wsc60/php/#creating-categories-based-on-the-formbuilder","title":"Creating Categories Based on the Formbuilder","text":"<p>A new basic implementation based on the FormBuilder for creating and editing categories has been introduced. The old implementation (<code>AbstractCategoryAddForm</code>) remains for backward compatibility reasons, but has been deprecated.</p> <p>Usage (form for creating categories):</p> <pre><code>class FooBarCategoryAddForm extends CategoryAddFormBuilderForm {\n public string $objectTypeName = 'foo.bar.category';\n}\n</code></pre> <p>Usage (form for editing categories):</p> <pre><code>class FooBarCategoryEditForm extends FooBarCategoryAddForm {\n public $formAction = 'edit';\n}\n</code></pre> <p>See WoltLab/WCF#5657 for more details. </p>"},{"location":"migration/wsc60/templates/","title":"Migrating from WoltLab Suite 6.0 - Templates","text":""},{"location":"migration/wsc60/templates/#unsafe-prefix","title":"<code>unsafe</code> Prefix","text":"<p>The <code>unsafe</code> prefix is intended as a replacement for the <code>@</code> prefix in order to output the content of a variable unfiltered. The new prefix offers better readability and makes it easier to find places where the prefix is used unintentionally. The old <code>@</code> prefix is still supported, but we recommend using the new prefix for new code.</p> <p>Usage:</p> <pre><code>Old: {@$foo}\nNew: {unsafe:$foo}\n</code></pre> <p>The code listed above outputs the raw content of the variable <code>$foo</code>.</p>"},{"location":"migration/wsc60/templates/#shared-templates","title":"Shared Templates","text":"<p>Shared templates, applicable both in the frontend and the backend, are now standardized to begin with the prefix <code>shared_</code>. This naming convention enhances clarity and organization within the template system. All templates intended for shared use must adhere to this naming convention.</p> <p>It is important to note that these shared templates must reside within the template directory in the frontend. Whether they are located in the WCF template directory or in your own application's template directory.</p> <p>To facilitate migration, below is a table outlining the renaming of templates from their old names to their new <code>shared_</code> prefixed names:</p> Old Template New Template <code>__wysiwygPreviewFormButton</code> <code>shared_wysiwygPreviewFormButton</code> <code>__formButton</code> <code>shared_formButton</code> <code>__wysiwygSmileyFormContainer</code> <code>shared_wysiwygSmileyFormContainer</code> <code>__wysiwygTabMenuFormContainer</code> <code>shared_wysiwygTabMenuFormContainer</code> <code>__formContainer</code> <code>shared_formContainer</code> <code>__rowFormContainer</code> <code>shared_rowFormContainer</code> <code>__rowFormFieldContainer</code> <code>shared_rowFormFieldContainer</code> <code>__suffixFormFieldContainer</code> <code>shared_suffixFormFieldContainer</code> <code>__tabFormContainer</code> <code>shared_tabFormContainer</code> <code>__tabMenuFormContainer</code> <code>shared_tabMenuFormContainer</code> <code>__tabTabMenuFormContainer</code> <code>shared_tabTabMenuFormContainer</code> <code>__simpleAclFormField</code> <code>shared_simpleAclFormField</code> <code>__aclFormField</code> <code>shared_aclFormField</code> <code>__bbcodeAttributesFormField</code> <code>shared_bbcodeAttributesFormField</code> <code>__emptyFormFieldDependency</code> <code>shared_emptyFormFieldDependency</code> <code>__isNotClickedFormFieldDependency</code> <code>shared_isNotClickedFormFieldDependency</code> <code>__nonEmptyFormFieldDependency</code> <code>shared_nonEmptyFormFieldDependency</code> <code>__valueFormFieldDependency</code> <code>shared_valueFormFieldDependency</code> <code>__valueIntervalFormFieldDependency</code> <code>shared_valueIntervalFormFieldDependency</code> <code>__labelFormField</code> <code>shared_labelFormField</code> <code>__contentLanguageFormField</code> <code>shared_contentLanguageFormField</code> <code>__singleMediaSelectionFormField</code> <code>shared_singleMediaSelectionFormField</code> <code>__pollOptionsFormField</code> <code>shared_pollOptionsFormField</code> <code>__tagFormField</code> <code>shared_tagFormField</code> <code>__userFormField</code> <code>shared_userFormField</code> <code>__usernameFormField</code> <code>shared_usernameFormField</code> <code>__userPasswordFormField</code> <code>shared_userPasswordFormField</code> <code>__formFieldError</code> <code>shared_formFieldError</code> <code>__wysiwygAttachmentFormField</code> <code>shared_wysiwygAttachmentFormField</code> <code>__wysiwygFormField</code> <code>shared_wysiwygFormField</code> <code>__numericFormField</code> <code>shared_numericFormField</code> <code>__booleanFormField</code> <code>shared_booleanFormField</code> <code>__buttonFormField</code> <code>shared_buttonFormField</code> <code>__captchaFormField</code> <code>shared_captchaFormField</code> <code>__checkboxFormField</code> <code>shared_checkboxFormField</code> <code>__colorFormField</code> <code>shared_colorFormField</code> <code>__dateFormField</code> <code>shared_dateFormField</code> <code>__emailFormField</code> <code>shared_emailFormField</code> <code>__hiddenFormField</code> <code>shared_hiddenFormField</code> <code>__iconFormField</code> <code>shared_iconFormField</code> <code>__itemListFormField</code> <code>shared_itemListFormField</code> <code>__multilineTextFormField</code> <code>shared_multilineTextFormField</code> <code>__multipleSelectionFormField</code> <code>shared_multipleSelectionFormField</code> <code>__passwordFormField</code> <code>shared_passwordFormField</code> <code>__radioButtonFormField</code> <code>shared_radioButtonFormField</code> <code>__ratingFormField</code> <code>shared_ratingFormField</code> <code>__selectFormField</code> <code>shared_selectFormField</code> <code>__sourceCodeFormField</code> <code>shared_sourceCodeFormField</code> <code>__uploadFormField</code> <code>shared_uploadFormField</code> <code>__wysiwygSmileyFormNode</code> <code>shared_wysiwygSmileyFormNode</code> <code>__form</code> <code>shared_form</code> <code>__formContainerChildren</code> <code>shared_formContainerChildren</code> <code>__formContainerDependencies</code> <code>shared_formContainerDependencies</code> <code>__formField</code> <code>shared_formField</code> <code>__formFieldDependencies</code> <code>shared_formFieldDependencies</code> <code>__formFieldDescription</code> <code>shared_formFieldDescription</code> <code>__formFieldErrors</code> <code>shared_formFieldErrors</code> <code>__formFieldDataHandler</code> <code>shared_formFieldDataHandler</code> <code>__singleSelectionFormField</code> <code>shared_singleSelectionFormField</code> <code>__mediaSetCategoryDialog</code> <code>shared_mediaSetCategoryDialog</code> <code>__messageQuoteManager</code> <code>shared_messageQuoteManager</code> <code>__topReaction</code> <code>shared_topReaction</code> <code>__wysiwygCmsToolbar</code> <code>shared_wysiwygCmsToolbar</code> <code>aclPermissionJavaScript</code> <code>shared_aclPermissionJavaScript</code> <code>aclSimple</code> <code>shared_aclSimple</code> <code>articleAddDialog</code> <code>shared_articleAddDialog</code> <code>benchmark</code> <code>shared_benchmark</code> <code>booleanOptionType</code> <code>shared_booleanOptionType</code> <code>booleanSearchableOptionType</code> <code>shared_booleanSearchableOptionType</code> <code>captcha</code> <code>shared_captcha</code> <code>captchaQuestion</code> <code>shared_captchaQuestiona</code> <code>categoryOptionList</code> <code>shared_categoryOptionList</code> <code>checkboxesOptionType</code> <code>shared_checkboxesOptionType</code> <code>checkboxesSearchableOptionType</code> <code>shared_checkboxesSearchableOptionType</code> <code>codeMetaCode</code> <code>shared_codeMetaCode</code> <code>codemirror</code> <code>shared_codemirror</code> <code>colorPickerJavaScript</code> <code>shared_colorPickerJavaScript</code> <code>fontAwesomeJavaScript</code> <code>shared_fontAwesomeJavaScript</code> <code>formError</code> <code>shared_formError</code> <code>formNotice</code> <code>shared_formNotice</code> <code>formSuccess</code> <code>shared_formSuccess</code> <code>languageChooser</code> <code>shared_languageChooser</code> <code>lineBreakSeparatedTextOptionType</code> <code>shared_lineBreakSeparatedTextOptionType</code> <code>mediaManager</code> <code>shared_mediaManager</code> <code>messageFormAttachments</code> <code>shared_messageFormAttachments</code> <code>messageTableOfContents</code> <code>shared_messageTableOfContents</code> <code>multipleLanguageInputJavascript</code> <code>shared_multipleLanguageInputJavascript</code> <code>passwordStrengthLanguage</code> <code>shared_passwordStrengthLanguage</code> <code>quoteMetaCode</code> <code>shared_quoteMetaCode</code> <code>radioButtonSearchableOptionType</code> <code>shared_radioButtonSearchableOptionType</code> <code>recaptcha</code> <code>shared_recaptcha</code> <code>scrollablePageCheckboxList</code> <code>shared_scrollablePageCheckboxList</code> <code>sitemapEnd</code> <code>shared_sitemapEnd</code> <code>sitemapEntry</code> <code>shared_sitemapEntry</code> <code>sitemapIndex</code> <code>shared_sitemapIndex</code> <code>sitemapStart</code> <code>shared_sitemapStart</code> <code>trophyImage</code> <code>shared_trophyImage</code> <code>unfurlUrl</code> <code>shared_unfurlUrl</code> <code>uploadFieldComponent</code> <code>shared_uploadFieldComponent</code> <code>userBBCodeTag</code> <code>shared_bbcode_user</code> <code>userConditions</code> <code>shared_userConditions</code> <code>userOptionsCondition</code> <code>shared_userOptionsCondition</code> <code>worker</code> <code>shared_worker</code> <code>wysiwyg</code> <code>shared_wysiwyg</code> <code>groupBBCodeTag</code> <code>shared_bbcode_group</code> <code>__videoAttachmentBBCode</code> <code>shared_bbcode_attach_video</code> <code>__audioAttachmentBBCode</code> <code>shared_bbcode_attach_audio</code> <code>mediaBBCodeTag</code> <code>shared_bbcode_wsm</code> <code>articleBBCodeTag</code> <code>shared_bbcode_wsa</code> <code>__multiPageCondition</code> <code>shared_multiPageCondition</code> <code>__multilineItemListFormField</code> <code>shared_multilineItemListFormField</code>"},{"location":"migration/wsc60/templates/#migration","title":"Migration","text":"<p>We provide a helper script that automates the task of updating the template includes. The script will search for <code>{include file='old_template_name'}</code> and ensure that any content before or after the <code>file='old_template_name'</code> remains available within the <code>{include}</code> tag.</p> <p>The helper script is part of WoltLab Suite Core and can be found in the repository at <code>extra/migrate-shared-template.php</code>. The script must be executed from CLI and requires PHP 8.1.</p> <pre><code>$> php extra/migrate-shared-template.php /path/to/the/target/directory/\n</code></pre> <p>The script will recursively search the specified target directory for files with the <code>tpl</code> extension.</p>"},{"location":"package/acp-menu-items/","title":"ACP Menu Items","text":"<p>The API for the ACP menu items allows you to add your own menu items in the admin panel for your package.</p> <p>Since WoltLab Suite 6.1 you can attach an event listener to the <code>wcf\\event\\acp\\menu\\item\\ItemCollecting</code> event inside a bootstrap script to lazily register your ACP menu items.</p> <p>The <code>register</code> method of the event expects an object of the type <code>wcf\\system\\menu\\acp\\AcpMenuItem</code> as a parameter. An <code>AcpMenuItem</code> object consists of the following parameters:</p> Name Type Description <code>$menuItem</code> string Identifier of the item; must be unique <code>$title</code> string (Optional) title of the item; if omitted <code>$menuItem</code> is used as language variable <code>$parentMenuItem</code> string (Optional) identifier of the parent item <code>$link</code> string (Optional) URL of the linked page <code>$icon</code> ?FontAwesomeIcon (Optional) icon of the item <p>Example:</p> <pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\menu\\acp\\AcpMenuItem;\nuse wcf\\event\\acp\\menu\\item\\ItemCollecting;\nuse wcf\\system\\request\\LinkHandler;\nuse wcf\\system\\style\\FontAwesomeIcon;\n\nreturn static function (): void {\n EventHandler::getInstance()->register(ItemCollecting::class, static function (ItemCollecting $event) {\n $event->register(new AcpMenuItem(\n \"com.woltlab.foor.bar\",\n 'Example Title',\n 'wcf.acp.menu.link.application'\n ));\n\n if ($currentUserHasSomeSpecificPermission) {\n $event->register(new AcpMenuItem(\n \"com.woltlab.foor.bar.add\",\n 'Example Add Title',\n \"com.woltlab.foor.bar\",\n LinkHandler::getInstance()->getControllerLink(FooAddForm::class),\n FontAwesomeIcon::fromString('plus;false')\n ));\n }\n });\n};\n</code></pre>"},{"location":"package/bootstrap-scripts/","title":"Bootstrap Scripts","text":"<p>Package-specific bootstrap scripts allow a package to execute logic during the application boot to prepare the environment before the request is passed through the middleware pipeline into the controller in <code>RequestHandler</code>.</p> <p>Bootstrap scripts are stored in the <code>lib/bootstrap/</code> directory of WoltLab Suite Core with the package identifier as the file name. They do not need to be registered explicitly, as one future goal of the bootstrap scripts is reducing the amount of system state that needs to be stored within the database. Instead WoltLab Suite Core will automatically create a bootstrap loader that includes all installed bootstrap scripts as part of the package installation and uninstallation process.</p> <p>Bootstrap scripts will be loaded and the bootstrap functions will executed based on a topological sorting of all installed packages. A package can rely on all bootstrap scripts of its dependencies being loaded before its own bootstrap script is loaded. It can also rely on all bootstrap functions of its dependencies having executed before its own bootstrap functions is executed. However it cannot rely on any specific loading and execution order of non-dependencies.</p> <p>As hinted at in the previous paragraph, executing the bootstrap scripts happens in two phases:</p> <ol> <li>All bootstrap scripts will be <code>include()</code>d in topological order. The script is expected to return a <code>Closure</code> that is executed in phase 2.</li> <li>Once all bootstrap scripts have been included, the returned <code>Closure</code>s will be executed in the same order the bootstrap scripts were loaded.</li> </ol> files/lib/bootstrap/com.example.foo.php<pre><code><?php\n\n// Phase (1).\n\nreturn static function (): void {\n // Phase (2).\n};\n</code></pre> <p>For the vast majority of packages it is expected that the phase (1) bootstrapping is not used, except to return the <code>Closure</code>. Instead the logic should reside in the <code>Closure</code>s body that is executed in phase (2).</p>"},{"location":"package/bootstrap-scripts/#registering-ievent-listeners","title":"Registering <code>IEvent</code> listeners","text":"<p>An example use case for bootstrap scripts is registering event listeners for <code>IEvent</code>-based events, instead of using the eventListener PIP. Registering event listeners within the bootstrap script allows you to leverage your IDE\u2019s autocompletion for class names and and prevents forgetting the explicit uninstallation of old event listeners during a package upgrade.</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\event\\listener\\ValueDumpListener;\nuse wcf\\system\\foo\\event\\ValueAvailable;\n\nreturn static function (): void {\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n ValueDumpListener::class\n );\n\n EventHandler::getInstance()->register(\n ValueAvailable::class,\n static function (ValueAvailable $event): void {\n // For simple use cases a `Closure` instead of a class name may be used.\n \\var_dump($event->getValue());\n }\n );\n};\n</code></pre>"},{"location":"package/database-php-api/","title":"Database PHP API","text":"<p>While the sql package installation plugin supports adding and removing tables, columns, and indices, it is not able to handle cases where the added table, column, or index already exist. We have added a new PHP-based API to manipulate the database scheme which can be used in combination with the database package installation plugin that skips parts that already exist:</p> <pre><code>return [\n // list of `DatabaseTable` objects\n];\n</code></pre> <p>All of the relevant components can be found in the <code>wcf\\system\\database\\table</code> namespace.</p>"},{"location":"package/database-php-api/#database-tables","title":"Database Tables","text":"<p>There are two classes representing database tables: <code>DatabaseTable</code> and <code>PartialDatabaseTable</code>. If a new table should be created, use <code>DatabaseTable</code>. In all other cases, <code>PartialDatabaseTable</code> should be used as it provides an additional save-guard against accidentally creating a new table by having a typo in the table name: If the tables does not already exist, a table represented by <code>PartialDatabaseTable</code> will cause an exception (while a <code>DatabaseTable</code> table will simply be created).</p> <p>To create a table, a <code>DatabaseTable</code> object with the table's name as to be created and table's columns, foreign keys and indices have to be specified:</p> <pre><code>DatabaseTable::create('foo1_bar')\n ->columns([\n // columns\n ])\n ->foreignKeys([\n // foreign keys\n ])\n ->indices([\n // indices\n ])\n</code></pre> <p>To update a table, the same code as above can be used, except for <code>PartialDatabaseTable</code> being used instead of <code>DatabaseTable</code>.</p> <p>To drop a table, only the <code>drop()</code> method has to be called:</p> <pre><code>PartialDatabaseTable::create('foo1_bar')\n ->drop()\n</code></pre>"},{"location":"package/database-php-api/#columns","title":"Columns","text":"<p>To represent a column of a database table, you have to create an instance of the relevant column class found in the <code>wcf\\system\\database\\table\\column</code> namespace. Such instances are created similarly to database table objects using the <code>create()</code> factory method and passing the column name as the parameter.</p> <p>Every column type supports the following methods:</p> <ul> <li><code>defaultValue($defaultValue)</code> sets the default value of the column (default: none).</li> <li><code>drop()</code> to drop the column.</li> <li><code>notNull($notNull = true)</code> sets if the value of the column can be <code>NULL</code> (default: <code>false</code>).</li> </ul> <p>Depending on the specific column class implementing additional interfaces, the following methods are also available:</p> <ul> <li><code>IAutoIncrementDatabaseTableColumn::autoIncrement($autoIncrement = true)</code> sets if the value of the colum is auto-incremented.</li> <li><code>IDecimalsDatabaseTableColumn::decimals($decimals)</code> sets the number of decimals the column supports.</li> <li><code>IEnumDatabaseTableColumn::enumValues(array $values)</code> sets the predetermined set of valid values of the column.</li> <li><code>ILengthDatabaseTableColumn::length($length)</code> sets the (maximum) length of the column.</li> </ul> <p>Additionally, there are some additionally classes of commonly used columns with specific properties:</p> <ul> <li><code>DefaultFalseBooleanDatabaseTableColumn</code> (a <code>tinyint</code> column with length <code>1</code>, default value <code>0</code> and whose values cannot be <code>null</code>)</li> <li><code>DefaultTrueBooleanDatabaseTableColumn</code> (a <code>tinyint</code> column with length <code>1</code>, default value <code>1</code> and whose values cannot be <code>null</code>)</li> <li><code>NotNullInt10DatabaseTableColumn</code> (a <code>int</code> column with length <code>10</code> and whose values cannot be <code>null</code>)</li> <li><code>NotNullVarchar191DatabaseTableColumn</code> (a <code>varchar</code> column with length <code>191</code> and whose values cannot be <code>null</code>)</li> <li><code>NotNullVarchar255DatabaseTableColumn</code> (a <code>varchar</code> column with length <code>255</code> and whose values cannot be <code>null</code>)</li> <li><code>ObjectIdDatabaseTableColumn</code> (a <code>int</code> column with length <code>10</code>, whose values cannot be <code>null</code>, and whose values are auto-incremented)</li> </ul> <p>Examples:</p> <pre><code>DefaultFalseBooleanDatabaseTableColumn::create('isDisabled')\n\nNotNullInt10DatabaseTableColumn::create('fooTypeID')\n\nSmallintDatabaseTableColumn::create('bar')\n ->length(5)\n ->notNull()\n</code></pre>"},{"location":"package/database-php-api/#foreign-keys","title":"Foreign Keys","text":"<p>Foreign keys are represented by <code>DatabaseTableForeignKey</code> objects: </p> <pre><code>DatabaseTableForeignKey::create()\n ->columns(['fooID'])\n ->referencedTable('wcf1_foo')\n ->referencedColumns(['fooID'])\n ->onDelete('CASCADE')\n</code></pre> <p>The supported actions for <code>onDelete()</code> and <code>onUpdate()</code> are <code>CASCADE</code>, <code>NO ACTION</code>, and <code>SET NULL</code>. To drop a foreign key, all of the relevant data to create the foreign key has to be present and the <code>drop()</code> method has to be called.</p> <p><code>DatabaseTableForeignKey::create()</code> also supports the foreign key name as a parameter. If it is not present, <code>DatabaseTable::foreignKeys()</code> will automatically set one based on the foreign key's data.</p>"},{"location":"package/database-php-api/#indices","title":"Indices","text":"<p>Indices are represented by <code>DatabaseTableIndex</code> objects: </p> <pre><code>DatabaseTableIndex::create('fooID')\n ->type(DatabaseTableIndex::UNIQUE_TYPE)\n ->columns(['fooID'])\n</code></pre> <p>There are four different types: <code>DatabaseTableIndex::DEFAULT_TYPE</code> (default), <code>DatabaseTableIndex::PRIMARY_TYPE</code>, <code>DatabaseTableIndex::UNIQUE_TYPE</code>, and <code>DatabaseTableIndex::FULLTEXT_TYPE</code>. For primary keys, there is also the <code>DatabaseTablePrimaryIndex</code> class which automatically sets the type to <code>DatabaseTableIndex::PRIMARY_TYPE</code>. To drop a index, all of the relevant data to create the index has to be present and the <code>drop()</code> method has to be called.</p> <p>The index name is specified as the parameter to <code>DatabaseTableIndex::create()</code>. It is strongly recommended to specify an explicit name (WoltLab/WCF#4505). If no name is given, <code>DatabaseTable::indices()</code> will automatically set one based on the index data.</p>"},{"location":"package/package-xml/","title":"package.xml","text":"<p>The <code>package.xml</code> is the core component of every package. It provides the meta data (e.g. package name, description, author) and the instruction set for a new installation and/or updating from a previous version.</p>"},{"location":"package/package-xml/#example","title":"Example","text":"package.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package name=\"com.example.package\" xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/package.xsd\">\n <packageinformation>\n <packagename>Simple Package</packagename>\n <packagedescription>A simple package to demonstrate the package system of WoltLab Suite Core</packagedescription>\n <version>1.0.0</version>\n <date>2022-01-17</date>\n </packageinformation>\n\n <authorinformation>\n <author>YOUR NAME</author>\n <authorurl>http://www.example.com</authorurl>\n </authorinformation>\n\n <requiredpackages>\n <requiredpackage minversion=\"6.0.0\">com.woltlab.wcf</requiredpackage>\n </requiredpackages>\n\n <excludedpackages>\n <excludedpackage version=\"7.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n\n <instructions type=\"install\">\n <instruction type=\"file\" />\n <instruction type=\"template\">templates.tar</instruction>\n </instructions>\n</package>\n</code></pre>"},{"location":"package/package-xml/#elements","title":"Elements","text":""},{"location":"package/package-xml/#package","title":"<code><package></code>","text":"<p>The root node of every <code>package.xml</code> it contains the reference to the namespace and the location of the XML Schema Definition (XSD).</p> <p>The attribute <code>name</code> is the most important part, it holds the unique package identifier and is mandatory. It is based upon your domain name and the package name of your choice.</p> <p>For example WoltLab Suite Forum (formerly know an WoltLab Burning Board and usually abbreviated as <code>wbb</code>) is created by WoltLab which owns the domain <code>woltlab.com</code>. The resulting package identifier is <code>com.woltlab.wbb</code> (<code><tld>.<domain>.<packageName></code>).</p>"},{"location":"package/package-xml/#packageinformation","title":"<code><packageinformation></code>","text":"<p>Holds the entire meta data of the package.</p>"},{"location":"package/package-xml/#packagename","title":"<code><packagename></code>","text":"<p>This is the actual package name displayed to the end user, this can be anything you want, try to keep it short. It supports the attribute <code>language</code> which allows you to provide the package name in different languages, please be aware that if it is not present, <code>en</code> (English) is assumed:</p> <pre><code><packageinformation>\n <packagename>Simple Package</packagename>\n <packagename language=\"de\">Einfaches Paket</packagename>\n</packageinformation>\n</code></pre>"},{"location":"package/package-xml/#packagedescription","title":"<code><packagedescription></code>","text":"<p>Brief summary of the package, use it to explain what it does since the package name might not always be clear enough. The attribute <code>language</code> can also be used here, please reference to <code><packagename></code> for details.</p>"},{"location":"package/package-xml/#version","title":"<code><version></code>","text":"<p>The package's version number, this is a string consisting of three numbers separated with a dot and optionally followed by a keyword (must be followed with another number).</p> <p>The possible keywords are:</p> <ul> <li>Alpha/dev (both is regarded to be the same)</li> <li>Beta</li> <li>RC (release candidate)</li> </ul> <p>Valid examples:</p> <ul> <li>1.0.0</li> <li>1.12.13 Alpha 19</li> </ul> <p>Invalid examples:</p> <ul> <li>1.0.0 Beta (keyword Beta must be followed by a number)</li> <li>2.0 RC 3 (version number must consist of 3 blocks of numbers)</li> <li>1.2.3 dev 4.5 (4.5 is not an integer, 4 or 5 would be valid but not the fraction)</li> </ul>"},{"location":"package/package-xml/#date","title":"<code><date></code>","text":"<p>Must be a valid ISO 8601 date, e.g. <code>2013-12-27</code>.</p>"},{"location":"package/package-xml/#packageurl","title":"<code><packageurl></code>","text":"<p>(optional)</p> <p>URL to the package website that provides detailed information about the package.</p>"},{"location":"package/package-xml/#license","title":"<code><license></code>","text":"<p>(optional)</p> <p>Name of a generic license type or URL to a custom license. The attribute <code>language</code> can also be used here, please reference to <code><packagename></code> for details.</p>"},{"location":"package/package-xml/#authorinformation","title":"<code><authorinformation></code>","text":"<p>Holds meta data regarding the package's author.</p>"},{"location":"package/package-xml/#author","title":"<code><author></code>","text":"<p>Can be anything you want.</p>"},{"location":"package/package-xml/#authorurl","title":"<code><authorurl></code>","text":"<p>(optional)</p> <p>URL to the author's website.</p>"},{"location":"package/package-xml/#requiredpackages","title":"<code><requiredpackages></code>","text":"<p>A list of packages including their version required for this package to work.</p>"},{"location":"package/package-xml/#requiredpackage","title":"<code><requiredpackage></code>","text":"<p>Example:</p> <pre><code><requiredpackage minversion=\"2.7.5\" file=\"requirements/com.example.foo.tar\">com.example.foo</requiredpackage>\n</code></pre> <p>The attribute <code>minversion</code> must be a valid version number as described in <code><version></code>. The <code>file</code> attribute is optional and specifies the location of the required package's archive relative to the <code>package.xml</code>.</p>"},{"location":"package/package-xml/#optionalpackage","title":"<code><optionalpackage></code>","text":"<p>A list of optional packages which can be selected by the user at the very end of the installation process.</p>"},{"location":"package/package-xml/#optionalpackage_1","title":"<code><optionalpackage></code>","text":"<p>Example:</p> <pre><code><optionalpackage file=\"optionals/com.example.bar.tar\">com.example.bar</optionalpackage>\n</code></pre> <p>The <code>file</code> attribute specifies the location of the optional package's archive relative to the <code>package.xml</code>.</p>"},{"location":"package/package-xml/#excludedpackages","title":"<code><excludedpackages></code>","text":"<p>List of packages which conflict with this package. It is not possible to install it if any of the specified packages is installed. In return you cannot install an excluded package if this package is installed.</p>"},{"location":"package/package-xml/#excludedpackage","title":"<code><excludedpackage></code>","text":"<p>Example:</p> <pre><code><excludedpackage version=\"7.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n</code></pre> <p>The attribute <code>version</code> must be a valid version number as described in the \\<version> section. In the example above it will be impossible to install this package in WoltLab Suite Core 7.0.0 Alpha 1 or higher.</p>"},{"location":"package/package-xml/#instructions","title":"<code><instructions></code>","text":"<p>List of instructions to be executed upon install or update. The order is important, the topmost <code><instruction></code> will be executed first.</p>"},{"location":"package/package-xml/#instructions-typeinstall","title":"<code><instructions type=\"install\"></code>","text":"<p>List of instructions for a new installation of this package.</p>"},{"location":"package/package-xml/#instructions-typeupdate-fromversion","title":"<code><instructions type=\"update\" fromversion=\"\u2026\"></code>","text":"<p>The attribute <code>fromversion</code> must be a valid version number as described in the \\<version> section and specifies a possible update from that very version to the package's version.</p> <p>The installation process will pick exactly one update instruction, ignoring everything else. Please read the explanation below!</p> <p>Example:</p> <ul> <li>Installed version: <code>1.0.0</code></li> <li>Package version: <code>1.0.2</code></li> </ul> <pre><code><instructions type=\"update\" fromversion=\"1.0.0\">\n <!-- \u2026 -->\n</instructions>\n<instructions type=\"update\" fromversion=\"1.0.1\">\n <!-- \u2026 -->\n</instructions>\n</code></pre> <p>In this example WoltLab Suite Core will pick the first update block since it allows an update from <code>1.0.0 -> 1.0.2</code>. The other block is not considered, since the currently installed version is <code>1.0.0</code>. After applying the update block (<code>fromversion=\"1.0.0\"</code>), the version now reads <code>1.0.2</code>.</p>"},{"location":"package/package-xml/#instruction","title":"<code><instruction></code>","text":"<p>Example:</p> <pre><code><instruction type=\"objectTypeDefinition\">objectTypeDefinition.xml</instruction>\n</code></pre> <p>The attribute <code>type</code> specifies the instruction type which is used to determine the package installation plugin (PIP) invoked to handle its value. The value must be a valid file relative to the location of <code>package.xml</code>. Many PIPs provide default file names which are used if no value is given:</p> <pre><code><instruction type=\"objectTypeDefinition\" />\n</code></pre> <p>There is a list of all default PIPs available.</p> <p>Both the <code>type</code>-attribute and the element value are case-sensitive. Windows does not care if the file is called <code>objecttypedefinition.xml</code> but was referenced as <code>objectTypeDefinition.xml</code>, but both Linux and Mac systems will be unable to find the file.</p> <p>In addition to the <code>type</code> attribute, an optional <code>run</code> attribute (with <code>standalone</code> as the only valid value) is supported which forces the installation to execute this PIP in an isolated request, allowing a single, resource-heavy PIP to execute without encountering restrictions such as PHP\u2019s <code>memory_limit</code> or <code>max_execution_time</code>:</p> <pre><code><instruction type=\"file\" run=\"standalone\" />\n</code></pre>"},{"location":"package/package-xml/#void","title":"<code><void/></code>","text":"<p>Sometimes a package update should only adjust the metadata of the package, for example, an optional package was added. However, WoltLab Suite Core requires that the list of <code><instructions></code> is non-empty. Instead of using a dummy <code><instruction></code> that idempotently updates some PIP, the <code><void/></code> tag can be used for this use-case.</p> <p>Using the <code><void/></code> tag is only valid for <code><instructions type=\"update\"></code> and must not be accompanied by other <code><instruction></code> tags.</p> <p>Example:</p> <pre><code><instructions type=\"update\" fromversion=\"1.0.0\">\n <void/>\n</instructions>\n</code></pre>"},{"location":"package/pip/","title":"Package Installation Plugins","text":"<p>Package Installation Plugins (PIPs) are interfaces to deploy and edit content as well as components.</p> <p>For XML-based PIPs: <code><![CDATA[]]></code> must be used for language items and page contents. In all other cases it may only be used when necessary.</p>"},{"location":"package/pip/#built-in-pips","title":"Built-In PIPs","text":"Name Description aclOption Customizable permissions for individual objects acpMenu Admin panel menu categories and items acpSearchProvider Data provider for the admin panel search acpTemplate Admin panel templates acpTemplateDelete Deletes admin panel templates installed with acpTemplate bbcode BBCodes for rich message formatting box Boxes that can be placed anywhere on a page clipboardAction Perform bulk operations on marked objects coreObject Access Singletons from within the template cronjob Periodically execute code with customizable intervals database Updates the database layout using the PHP API eventListener Register listeners for the event system file Deploy any type of files with the exception of templates fileDelete Deletes files installed with file language Language items mediaProvider Detect and convert links to media providers menu Side-wide and custom per-page menus menuItem Menu items for menus created through the menu PIP objectType Flexible type registry based on definitions objectTypeDefinition Groups objects and classes by functionality option Side-wide configuration options page Register page controllers and text-based pages pip Package Installation Plugins script Execute arbitrary PHP code during installation, update and uninstallation smiley Smileys sql Execute SQL instructions using a MySQL-flavored syntax (also see database PHP API) style Style template Frontend templates templateDelete Deletes frontend templates installed with template templateListener Embed template code into templates without altering the original userGroupOption Permissions for user groups userMenu User menu categories and items userNotificationEvent Events of the user notification system userOption User settings userProfileMenu User profile tabs"},{"location":"package/pip/acl-option/","title":"ACL Option Package Installation Plugin","text":"<p>Add customizable permissions for individual objects.</p>"},{"location":"package/pip/acl-option/#option-components","title":"Option Components","text":"<p>Each acl option is described as an <code><option></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/acl-option/#categoryname","title":"<code><categoryname></code>","text":"<p>Optional</p> <p>The name of the acl option category to which the option belongs.</p>"},{"location":"package/pip/acl-option/#objecttype","title":"<code><objecttype></code>","text":"<p>The name of the acl object type (of the object type definition <code>com.woltlab.wcf.acl</code>).</p>"},{"location":"package/pip/acl-option/#category-components","title":"Category Components","text":"<p>Each acl option category is described as an <code><category></code> element with the mandatory attribute <code>name</code> that should follow the naming pattern <code><permissionName></code> or <code><permissionType>.<permissionName></code>, with <code><permissionType></code> generally having <code>user</code> or <code>mod</code> as value.</p>"},{"location":"package/pip/acl-option/#objecttype_1","title":"<code><objecttype></code>","text":"<p>The name of the acl object type (of the object type definition <code>com.woltlab.wcf.acl</code>).</p>"},{"location":"package/pip/acl-option/#example","title":"Example","text":"aclOption.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/aclOption.xsd\">\n <import>\n <categories>\n <category name=\"user.example\">\n <objecttype>com.example.wcf.example</objecttype>\n </category>\n <category name=\"mod.example\">\n <objecttype>com.example.wcf.example</objecttype>\n </category>\n </categories>\n\n <options>\n <option name=\"canAddExample\">\n <categoryname>user.example</categoryname>\n <objecttype>com.example.wcf.example</objecttype>\n </option>\n <option name=\"canDeleteExample\">\n <categoryname>mod.example</categoryname>\n <objecttype>com.example.wcf.example</objecttype>\n </option>\n </options>\n </import>\n\n <delete>\n <optioncategory name=\"old.example\">\n <objecttype>com.example.wcf.example</objecttype>\n </optioncategory>\n <option name=\"canDoSomethingWithExample\">\n <objecttype>com.example.wcf.example</objecttype>\n </option>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/acp-menu/","title":"ACP Menu Package Installation Plugin","text":"<p>Registers new ACP menu items.</p>"},{"location":"package/pip/acp-menu/#components","title":"Components","text":"<p>Each item is described as an <code><acpmenuitem></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/acp-menu/#parent","title":"<code><parent></code>","text":"<p>Optional</p> <p>The item\u2019s parent item.</p>"},{"location":"package/pip/acp-menu/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this item within the parent item.</p>"},{"location":"package/pip/acp-menu/#controller","title":"<code><controller></code>","text":"<p>The fully qualified class name of the target controller. If not specified this item serves as a category.</p>"},{"location":"package/pip/acp-menu/#link","title":"<code><link></code>","text":"<p>Additional components if <code><controller></code> is set, the full external link otherwise.</p>"},{"location":"package/pip/acp-menu/#icon","title":"<code><icon></code>","text":"<p>Use an icon only for top-level and 4th-level items.</p> <p>Name of the Font Awesome icon class.</p>"},{"location":"package/pip/acp-menu/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the tab to be shown.</p>"},{"location":"package/pip/acp-menu/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the tab to be shown.</p>"},{"location":"package/pip/acp-menu/#example","title":"Example","text":"acpMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/acpMenu.xsd\">\n <import>\n <acpmenuitem name=\"foo.acp.menu.link.example\">\n <parent>wcf.acp.menu.link.application</parent>\n </acpmenuitem>\n\n <acpmenuitem name=\"foo.acp.menu.link.example.list\">\n <controller>foo\\acp\\page\\ExampleListPage</controller>\n <parent>foo.acp.menu.link.example</parent>\n <permissions>admin.foo.canManageExample</permissions>\n <showorder>1</showorder>\n </acpmenuitem>\n\n <acpmenuitem name=\"foo.acp.menu.link.example.add\">\n <controller>foo\\acp\\form\\ExampleAddForm</controller>\n <parent>foo.acp.menu.link.example.list</parent>\n <permissions>admin.foo.canManageExample</permissions>\n <icon>plus</icon>\n </acpmenuitem>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/acp-search-provider/","title":"ACP Search Provider Package Installation Plugin","text":"<p>Registers data provider for the admin panel search.</p>"},{"location":"package/pip/acp-search-provider/#components","title":"Components","text":"<p>Each acp search result provider is described as an <code><acpsearchprovider></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/acp-search-provider/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the search results, the class has to implement the <code>wcf\\system\\search\\acp\\IACPSearchResultProvider</code> interface.</p>"},{"location":"package/pip/acp-search-provider/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the search result list the provided results are shown.</p>"},{"location":"package/pip/acp-search-provider/#example","title":"Example","text":"acpSearchProvider.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/acpSearchProvider.xsd\">\n <import>\n <acpsearchprovider name=\"com.woltlab.wcf.example\">\n <classname>wcf\\system\\search\\acp\\ExampleACPSearchResultProvider</classname>\n <showorder>1</showorder>\n </acpsearchprovider>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/acp-template-delete/","title":"ACP Template Delete Package Installation Plugin","text":"<p>Deletes admin panel templates installed with the acpTemplate package installation plugin.</p> <p>You cannot delete acp templates provided by other packages.</p>"},{"location":"package/pip/acp-template-delete/#components","title":"Components","text":"<p>Each item is described as a <code><template></code> element with an optional <code>application</code>, which behaves like it does for acp templates. The templates are identified by their name like when adding template listeners, i.e. by the file name without the <code>.tpl</code> file extension.</p>"},{"location":"package/pip/acp-template-delete/#example","title":"Example","text":"acpTemplateDelete.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/acpTemplateDelete.xsd\">\n <delete>\n <template>fouAdd</template>\n <template application=\"app\">__appAdd</template>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/acp-template/","title":"ACP Template Installation Plugin","text":"<p>Add templates for acp pages and forms by providing an archive containing the template files.</p> <p>You cannot overwrite acp templates provided by other packages.</p>"},{"location":"package/pip/acp-template/#archive","title":"Archive","text":"<p>The <code>acpTemplate</code> package installation plugins expects a <code>.tar</code> (recommended) or <code>.tar.gz</code> archive. The templates must all be in the root of the archive. Do not include any directories in the archive. The file path given in the <code>instruction</code> element as its value must be relative to the <code>package.xml</code> file.</p>"},{"location":"package/pip/acp-template/#attributes","title":"Attributes","text":""},{"location":"package/pip/acp-template/#application","title":"<code>application</code>","text":"<p>The <code>application</code> attribute determines to which application the installed acp templates belong and thus in which directory the templates are installed. The value of the <code>application</code> attribute has to be the abbreviation of an installed application. If no <code>application</code> attribute is given, the following rules are applied:</p> <ul> <li>If the package installing the acp templates is an application, then the templates will be installed in this application's directory.</li> <li>If the package installing the acp templates is no application, then the templates will be installed in WoltLab Suite Core's directory.</li> </ul>"},{"location":"package/pip/acp-template/#example-in-packagexml","title":"Example in <code>package.xml</code>","text":"<pre><code><instruction type=\"acpTemplate\" />\n<!-- is the same as -->\n<instruction type=\"acpTemplate\">acptemplates.tar</instruction>\n\n<!-- if an application \"com.woltlab.example\" is being installed, the following lines are equivalent -->\n<instruction type=\"acpTemplate\" />\n<instruction type=\"acpTemplate\" application=\"example\" />\n</code></pre>"},{"location":"package/pip/bbcode/","title":"BBCode Package Installation Plugin","text":"<p>Registers new BBCodes.</p>"},{"location":"package/pip/bbcode/#components","title":"Components","text":"<p>Each bbcode is described as an <code><bbcode></code> element with the mandatory attribute <code>name</code>. The <code>name</code> attribute must contain alphanumeric characters only and is exposed to the user.</p>"},{"location":"package/pip/bbcode/#htmlopen","title":"<code><htmlopen></code>","text":"<p>Optional: Must not be provided if the BBCode is being processed a PHP class (<code><classname></code>).</p> <p>The contents of this tag are literally copied into the opening tag of the bbcode.</p>"},{"location":"package/pip/bbcode/#htmlclose","title":"<code><htmlclose></code>","text":"<p>Optional: Must not be provided if <code><htmlopen></code> is not given.</p> <p>Must match the <code><htmlopen></code> tag. Do not provide for self-closing tags.</p>"},{"location":"package/pip/bbcode/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the bbcode output, the class has to implement the <code>wcf\\system\\bbcode\\IBBCode</code> interface.</p> <p>BBCodes can be statically converted to HTML during input processing using a <code>wcf\\system\\html\\metacode\\converter\\*MetaConverter</code> class. This class does not need to be registered.</p>"},{"location":"package/pip/bbcode/#wysiwygicon","title":"<code><wysiwygicon></code>","text":"<p>Optional</p> <p>Name of the Font Awesome icon class or path to a <code>gif</code>, <code>jpg</code>, <code>jpeg</code>, <code>png</code>, or <code>svg</code> image (placed inside the <code>icon/</code> directory) to show in the editor toolbar.</p>"},{"location":"package/pip/bbcode/#buttonlabel","title":"<code><buttonlabel></code>","text":"<p>Optional: Must be provided if an icon is given.</p> <p>Explanatory text to show when hovering the icon.</p>"},{"location":"package/pip/bbcode/#sourcecode","title":"<code><sourcecode></code>","text":"<p>Do not set this to <code>1</code> if you don't specify a PHP class for processing. You must perform XSS sanitizing yourself!</p> <p>If set to <code>1</code> contents of this BBCode will not be interpreted, but literally passed through instead.</p>"},{"location":"package/pip/bbcode/#isblockelement","title":"<code><isBlockElement></code>","text":"<p>Set to <code>1</code> if the output of this BBCode is a HTML block element (according to the HTML specification).</p>"},{"location":"package/pip/bbcode/#attributes","title":"<code><attributes></code>","text":"<p>Each bbcode is described as an <code><attribute></code> element with the mandatory attribute <code>name</code>. The <code>name</code> attribute is a 0-indexed integer.</p>"},{"location":"package/pip/bbcode/#html","title":"<code><html></code>","text":"<p>Optional: Must not be provided if the BBCode is being processed a PHP class (<code><classname></code>).</p> <p>The contents of this tag are copied into the opening tag of the bbcode. <code>%s</code> is replaced by the attribute value.</p>"},{"location":"package/pip/bbcode/#validationpattern","title":"<code><validationpattern></code>","text":"<p>Optional</p> <p>Defines a regular expression that is used to validate the value of the attribute.</p>"},{"location":"package/pip/bbcode/#required","title":"<code><required></code>","text":"<p>Optional</p> <p>Specifies whether this attribute must be provided.</p>"},{"location":"package/pip/bbcode/#usetext","title":"<code><usetext></code>","text":"<p>Optional</p> <p>Should only be set to <code>1</code> for the attribute with name <code>0</code>.</p> <p>Specifies whether the text content of the BBCode should become this attribute's value.</p>"},{"location":"package/pip/bbcode/#example","title":"Example","text":"bbcode.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/bbcode.xsd\">\n <import>\n <bbcode name=\"foo\">\n <classname>wcf\\system\\bbcode\\FooBBCode</classname>\n <attributes>\n <attribute name=\"0\">\n <validationpattern>^\\d+$</validationpattern>\n <required>1</required>\n </attribute>\n </attributes>\n </bbcode>\n\n <bbcode name=\"example\">\n <htmlopen>div</htmlopen>\n <htmlclose>div</htmlclose>\n <isBlockElement>1</isBlockElement>\n <wysiwygicon>bath</wysiwygicon>\n <buttonlabel>wcf.editor.button.example</buttonlabel>\n </bbcode>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/box/","title":"Box Package Installation Plugin","text":"<p>Deploy and manage boxes that can be placed anywhere on the site, they come in two flavors: system and content-based.</p>"},{"location":"package/pip/box/#components","title":"Components","text":"<p>Each item is described as a <code><box></code> element with the mandatory attribute <code>name</code> that should follow the naming pattern <code><packageIdentifier>.<BoxName></code>, e.g. <code>com.woltlab.wcf.RecentActivity</code>.</p>"},{"location":"package/pip/box/#name","title":"<code><name></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The internal name displayed in the admin panel only, can be fully customized by the administrator and is immutable. Only one value is accepted and will be picked based on the site's default language, but you can provide localized values by including multiple <code><name></code> elements.</p>"},{"location":"package/pip/box/#boxtype","title":"<code><boxType></code>","text":""},{"location":"package/pip/box/#system","title":"<code>system</code>","text":"<p>The special <code>system</code> type is reserved for boxes that pull their properties and content from a registered PHP class. Requires the <code><objectType></code> element.</p>"},{"location":"package/pip/box/#html-text-or-tpl","title":"<code>html</code>, <code>text</code> or <code>tpl</code>","text":"<p>Provide arbitrary content, requires the <code><content></code> element.</p>"},{"location":"package/pip/box/#objecttype","title":"<code><objectType></code>","text":"<p>Required for boxes with <code>boxType = system</code>, must be registered through the objectType PIP for the definition <code>com.woltlab.wcf.boxController</code>.</p>"},{"location":"package/pip/box/#position","title":"<code><position></code>","text":"<p>The default display position of this box, can be any of the following:</p> <ul> <li>bottom</li> <li>contentBottom</li> <li>contentTop</li> <li>footer</li> <li>footerBoxes</li> <li>headerBoxes</li> <li>hero</li> <li>sidebarLeft</li> <li>sidebarRight</li> <li>top</li> </ul>"},{"location":"package/pip/box/#placeholder-positions","title":"Placeholder Positions","text":""},{"location":"package/pip/box/#showheader","title":"<code><showHeader></code>","text":"<p>Setting this to <code>0</code> will suppress display of the box title, useful for boxes containing advertisements or similar. Defaults to <code>1</code>.</p>"},{"location":"package/pip/box/#visibleeverywhere","title":"<code><visibleEverywhere></code>","text":"<p>Controls the display on all pages (<code>1</code>) or none (<code>0</code>), can be used in conjunction with <code><visibilityExceptions></code>.</p>"},{"location":"package/pip/box/#visibilityexceptions","title":"<code><visibilityExceptions></code>","text":"<p>Inverts the <code><visibleEverywhere></code> setting for the listed pages only.</p>"},{"location":"package/pip/box/#cssclassname","title":"<code><cssClassName></code>","text":"<p>Provide a custom CSS class name that is added to the menu container, allowing further customization of the menu's appearance.</p>"},{"location":"package/pip/box/#content","title":"<code><content></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p>"},{"location":"package/pip/box/#title","title":"<code><title></code>","text":"<p>The title element is required and controls the box title shown to the end users.</p>"},{"location":"package/pip/box/#content_1","title":"<code><content></code>","text":"<p>The content that should be used to populate the box, only used and required if the <code>boxType</code> equals <code>text</code>, <code>html</code> and <code>tpl</code>.</p>"},{"location":"package/pip/box/#example","title":"Example","text":"box.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/box.xsd\">\n <import>\n <box identifier=\"com.woltlab.wcf.RecentActivity\">\n <name language=\"de\">Letzte Aktivit\u00e4ten</name>\n <name language=\"en\">Recent Activities</name>\n <boxType>system</boxType>\n <objectType>com.woltlab.wcf.recentActivityList</objectType>\n <position>contentBottom</position>\n <showHeader>0</showHeader>\n <visibleEverywhere>0</visibleEverywhere>\n <visibilityExceptions>\n <page>com.woltlab.wcf.Dashboard</page>\n </visibilityExceptions>\n <limit>10</limit>\n\n <content language=\"de\">\n <title>Letzte Aktivit\u00e4ten</title>\n </content>\n <content language=\"en\">\n <title>Recent Activities</title>\n </content>\n </box>\n </import>\n\n <delete>\n <box identifier=\"com.woltlab.wcf.RecentActivity\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/clipboard-action/","title":"Clipboard Action Package Installation Plugin","text":"<p>Registers clipboard actions.</p>"},{"location":"package/pip/clipboard-action/#components","title":"Components","text":"<p>Each clipboard action is described as an <code><action></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/clipboard-action/#actionclassname","title":"<code><actionclassname></code>","text":"<p>The name of the class used by the clipboard API to process the concrete action. The class has to implement the <code>wcf\\system\\clipboard\\action\\IClipboardAction</code> interface, best by extending <code>wcf\\system\\clipboard\\action\\AbstractClipboardAction</code>.</p>"},{"location":"package/pip/clipboard-action/#pages","title":"<code><pages></code>","text":"<p>Element with <code><page></code> children whose value contains the class name of the controller of the page on which the clipboard action is available.</p>"},{"location":"package/pip/clipboard-action/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the clipboard action list the action is shown.</p>"},{"location":"package/pip/clipboard-action/#example","title":"Example","text":"clipboardAction.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/clipboardAction.xsd\">\n <import>\n <action name=\"delete\">\n <actionclassname>wcf\\system\\clipboard\\action\\ExampleClipboardAction</actionclassname>\n <showorder>1</showorder>\n <pages>\n <page>wcf\\acp\\page\\ExampleListPage</page>\n </pages>\n </action>\n <action name=\"foo\">\n <actionclassname>wcf\\system\\clipboard\\action\\ExampleClipboardAction</actionclassname>\n <showorder>2</showorder>\n <pages>\n <page>wcf\\acp\\page\\ExampleListPage</page>\n </pages>\n </action>\n <action name=\"bar\">\n <actionclassname>wcf\\system\\clipboard\\action\\ExampleClipboardAction</actionclassname>\n <showorder>3</showorder>\n <pages>\n <page>wcf\\acp\\page\\ExampleListPage</page>\n </pages>\n </action>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/core-object/","title":"Core Object Package Installation Plugin","text":"<p>Registers <code>wcf\\system\\SingletonFactory</code> objects to be accessible in templates.</p>"},{"location":"package/pip/core-object/#components","title":"Components","text":"<p>Each item is described as a <code><coreobject></code> element with the mandatory element <code>objectname</code>.</p>"},{"location":"package/pip/core-object/#objectname","title":"<code><objectname></code>","text":"<p>The fully qualified class name of the class.</p>"},{"location":"package/pip/core-object/#example","title":"Example","text":"coreObject.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/coreObject.xsd\">\n <import>\n <coreobject>\n <objectname>wcf\\system\\example\\ExampleHandler</objectname>\n </coreobject>\n </import>\n</data>\n</code></pre> <p>This object can be accessed in templates via <code>$__wcf->getExampleHandler()</code> (in general: the method name begins with <code>get</code> and ends with the unqualified class name).</p>"},{"location":"package/pip/cronjob/","title":"Cronjob Package Installation Plugin","text":"<p>Registers new cronjobs. The cronjob schedular works similar to the <code>cron(8)</code> daemon, which might not available to web applications on regular webspaces. The main difference is that WoltLab Suite\u2019s cronjobs do not guarantee execution at the specified points in time: WoltLab Suite\u2019s cronjobs are triggered by regular visitors in an AJAX request, once the next execution point lies in the past.</p>"},{"location":"package/pip/cronjob/#components","title":"Components","text":"<p>Each cronjob is described as an <code><cronjob></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/cronjob/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the cronjob's behaviour, the class has to implement the <code>wcf\\system\\cronjob\\ICronjob</code> interface.</p>"},{"location":"package/pip/cronjob/#description","title":"<code><description></code>","text":"<p>The <code>language</code> attribute is optional and should specify the ISO-639-1 language code.</p> <p>Provides a human readable description for the administrator.</p>"},{"location":"package/pip/cronjob/#expression","title":"<code><expression></code>","text":"<p>The cronjob schedule. The expression accepts the same syntax as described in <code>crontab(5)</code> of a cron daemon.</p>"},{"location":"package/pip/cronjob/#canbeedited","title":"<code><canbeedited></code>","text":"<p>Controls whether the administrator may edit the fields of the cronjob. Defaults to <code>1</code>.</p>"},{"location":"package/pip/cronjob/#canbedisabled","title":"<code><canbedisabled></code>","text":"<p>Controls whether the administrator may disable the cronjob. Defaults to <code>1</code>.</p>"},{"location":"package/pip/cronjob/#isdisabled","title":"<code><isdisabled></code>","text":"<p>Controls whether the cronjob is disabled by default. Defaults to <code>0</code>.</p>"},{"location":"package/pip/cronjob/#options","title":"<code><options></code>","text":"<p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the template listener to be executed.</p>"},{"location":"package/pip/cronjob/#example","title":"Example","text":"cronjob.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/cronjob.xsd\">\n <import>\n <cronjob name=\"com.example.package.example\">\n <classname>wcf\\system\\cronjob\\ExampleCronjob</classname>\n <description>Serves as an example</description>\n <description language=\"de\">Stellt ein Beispiel dar</description>\n <expression>0 2 */2 * *</expression>\n <canbeedited>1</canbeedited>\n <canbedisabled>1</canbedisabled>\n </cronjob>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/database/","title":"Database Package Installation Plugin","text":"<p>Update the database layout using the PHP API.</p> <p>You must install the PHP script through the file package installation plugin.</p> <p>The installation will attempt to delete the script after successful execution.</p>"},{"location":"package/pip/database/#attributes","title":"Attributes","text":""},{"location":"package/pip/database/#application","title":"<code>application</code>","text":"<p>The <code>application</code> attribute must have the same value as the <code>application</code> attribute of the <code>file</code> package installation plugin instruction so that the correct file in the intended application directory is executed. For further information about the <code>application</code> attribute, refer to its documentation on the acpTemplate package installation plugin page.</p>"},{"location":"package/pip/database/#expected-value","title":"Expected value","text":"<p>The <code>database</code>-PIP expects a relative path to a <code>.php</code> file that returns an array of <code>DatabaseTable</code> objects.</p>"},{"location":"package/pip/database/#naming-convention","title":"Naming convention","text":"<p>The PHP script is deployed by using the file package installation plugin. To prevent it from colliding with other install script (remember: You cannot overwrite files created by another plugin), we highly recommend to make use of these naming conventions:</p> <ul> <li>Installation: <code>acp/database/install_<package>.php</code> (example: <code>acp/database/install_com.woltlab.wbb.php</code>)</li> <li>Update: <code>acp/database/update_<package>_<targetVersion>.php</code> (example: <code>acp/database/update_com.woltlab.wbb_5.4.1.php</code>)</li> </ul> <p><code><targetVersion></code> equals the version number of the current package being installed. If you're updating from <code>1.0.0</code> to <code>1.0.1</code>, <code><targetVersion></code> should read <code>1.0.1</code>.</p> <p>If you run multiple update scripts, you can append additional information in the filename.</p>"},{"location":"package/pip/database/#execution-environment","title":"Execution environment","text":"<p>The script is included using <code>include()</code> within DatabasePackageInstallationPlugin::updateDatabase().</p>"},{"location":"package/pip/event-listener/","title":"Event Listener Package Installation Plugin","text":"<p>Registers event listeners. An explanation of events and event listeners can be found here.</p>"},{"location":"package/pip/event-listener/#components","title":"Components","text":"<p>Each event listener is described as an <code><eventlistener></code> element with a <code>name</code> attribute. As the <code>name</code> attribute has only be introduced with WSC 3.0, it is not yet mandatory to allow backwards compatibility. If <code>name</code> is not given, the system automatically sets the name based on the id of the event listener in the database.</p>"},{"location":"package/pip/event-listener/#eventclassname","title":"<code><eventclassname></code>","text":"<p>The event class name is the name of the class in which the event is fired.</p>"},{"location":"package/pip/event-listener/#eventname","title":"<code><eventname></code>","text":"<p>The event name is the name given when the event is fired to identify different events within the same class. You can either give a single event name or a comma-separated list of event names in which case the event listener listens to all of the listed events.</p> <p>Since the introduction of the new event system with version 5.5, the event name is optional and defaults to <code>:default</code>.</p>"},{"location":"package/pip/event-listener/#listenerclassname","title":"<code><listenerclassname></code>","text":"<p>The listener class name is the name of the class which is triggered if the relevant event is fired. The PHP class has to implement the <code>wcf\\system\\event\\listener\\IParameterizedEventListener</code> interface.</p> <p>Legacy event listeners are only required to implement the deprecated <code>wcf\\system\\event\\IEventListener</code> interface. When writing new code or update existing code, you should always implement the <code>wcf\\system\\event\\listener\\IParameterizedEventListener</code> interface!</p>"},{"location":"package/pip/event-listener/#inherit","title":"<code><inherit></code>","text":"<p>The inherit value can either be <code>0</code> (default value if the element is omitted) or <code>1</code> and determines if the event listener is also triggered for child classes of the given event class name. This is the case if <code>1</code> is used as the value.</p>"},{"location":"package/pip/event-listener/#environment","title":"<code><environment></code>","text":"<p>The value of the environment element must be one of <code>user</code>, <code>admin</code> or <code>all</code> and defaults to <code>user</code> if no value is given. The value determines if the event listener will be executed in the frontend (<code>user</code>), the backend (<code>admin</code>) or both (<code>all</code>).</p>"},{"location":"package/pip/event-listener/#nice","title":"<code><nice></code>","text":"<p>The nice value element can contain an integer value out of the interval <code>[-128,127]</code> with <code>0</code> being the default value if the element is omitted. The nice value determines the execution order of event listeners. Event listeners with smaller nice values are executed first. If the nice value of two event listeners is equal, they are sorted by the listener class name.</p> <p>If you pass a value out of the mentioned interval, the value will be adjusted to the closest value in the interval.</p>"},{"location":"package/pip/event-listener/#options","title":"<code><options></code>","text":"<p>The use of <code><options></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the event listener to be executed.</p>"},{"location":"package/pip/event-listener/#permissions","title":"<code><permissions></code>","text":"<p>The use of <code><permissions></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the event listener to be executed.</p>"},{"location":"package/pip/event-listener/#example","title":"Example","text":"eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/eventListener.xsd\">\n <import>\n <eventlistener name=\"inheritedAdminExample\">\n <eventclassname>wcf\\acp\\form\\UserAddForm</eventclassname>\n <eventname>assignVariables,readFormParameters,save,validate</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\InheritedAdminExampleListener</listenerclassname>\n <inherit>1</inherit>\n <environment>admin</environment>\n </eventlistener>\n\n <eventlistener name=\"nonInheritedUserExample\">\n <eventclassname>wcf\\form\\SettingsForm</eventclassname>\n <eventname>assignVariables</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\NonInheritedUserExampleListener</listenerclassname>\n </eventlistener>\n </import>\n\n <delete>\n <eventlistener name=\"oldEventListenerName\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/file-delete/","title":"File Delete Package Installation Plugin","text":"<p>Deletes files installed with the file package installation plugin.</p> <p>You cannot delete files provided by other packages.</p>"},{"location":"package/pip/file-delete/#components","title":"Components","text":"<p>Each item is described as a <code><file></code> element with an optional <code>application</code>, which behaves like it does for acp templates. The file path is relative to the installation of the app to which the file belongs.</p>"},{"location":"package/pip/file-delete/#example","title":"Example","text":"fileDelete.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/fileDelete.xsd\">\n <delete>\n <file>path/file.ext</file>\n <file application=\"app\">lib/data/foo/Fou.class.php</file>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/file/","title":"File Package Installation Plugin","text":"<p>Adds any type of files with the exception of templates.</p> <p>You cannot overwrite files provided by other packages.</p> <p>The <code>application</code> attribute behaves like it does for acp templates.</p>"},{"location":"package/pip/file/#archive","title":"Archive","text":"<p>The <code>acpTemplate</code> package installation plugins expects a <code>.tar</code> (recommended) or <code>.tar.gz</code> archive. The file path given in the <code>instruction</code> element as its value must be relative to the <code>package.xml</code> file.</p>"},{"location":"package/pip/file/#example-in-packagexml","title":"Example in <code>package.xml</code>","text":"<pre><code><instruction type=\"file\" />\n<!-- is the same as -->\n<instruction type=\"file\">files.tar</instruction>\n\n<!-- if an application \"com.woltlab.example\" is being installed, the following lines are equivalent -->\n<instruction type=\"file\" />\n<instruction type=\"file\" application=\"example\" />\n\n<!-- if the same application wants to install additional files, in WoltLab Suite Core's directory: -->\n<instruction type=\"file\" application=\"wcf\">files_wcf.tar</instruction>\n</code></pre>"},{"location":"package/pip/language/","title":"Language Package Installation Plugin","text":"<p>Registers new language items.</p>"},{"location":"package/pip/language/#components","title":"Components","text":"<p>The <code>languagecode</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The top level <code><language></code> node must contain a <code>languagecode</code> attribute.</p>"},{"location":"package/pip/language/#category","title":"<code><category></code>","text":"<p>Each category must contain a <code>name</code> attribute containing two or three components consisting of alphanumeric character only, separated by a single full stop (<code>.</code>, U+002E).</p>"},{"location":"package/pip/language/#item","title":"<code><item></code>","text":"<p>Each language item must contain a <code>name</code> attribute containing at least three components consisting of alphanumeric character only, separated by a single full stop (<code>.</code>, U+002E). The <code>name</code> of the parent <code><category></code> node followed by a full stop must be a prefix of the <code><item></code>\u2019s <code>name</code>.</p> <p>Wrap the text content inside a CDATA to avoid escaping of special characters.</p> <p>Do not use the <code>{lang}</code> tag inside a language item.</p> <p>The text content of the <code><item></code> node is the value of the language item. Language items that are not in the <code>wcf.global</code> category support template scripting.</p>"},{"location":"package/pip/language/#example","title":"Example","text":"<p>Prior to version 5.5, there was no support for deleting language items and the <code>category</code> elements had to be placed directly as children of the <code>language</code> element, see the migration guide to version 5.5.</p> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/language.xsd\" languagecode=\"en\">\n <import>\n <category name=\"wcf.example\">\n <item name=\"wcf.example.foo\"><![CDATA[<strong>Look!</strong>]]></item>\n </category>\n </import>\n <delete>\n <item name=\"wcf.example.obsolete\"/>\n </delete>\n</language>\n</code></pre>"},{"location":"package/pip/media-provider/","title":"Media Provider Package Installation Plugin","text":"<p>Media providers are responsible to detect and convert links to a 3rd party service inside messages.</p>"},{"location":"package/pip/media-provider/#components","title":"Components","text":"<p>Each item is described as a <code><provider></code> element with the mandatory attribute <code>name</code> that should equal the lower-cased provider name. If a provider provides multiple components that are (largely) unrelated to each other, it is recommended to use a dash to separate the name and the component, e. g. <code>youtube-playlist</code>.</p>"},{"location":"package/pip/media-provider/#title","title":"<code><title></code>","text":"<p>The title is displayed in the administration control panel and is only used there, the value is neither localizable nor is it ever exposed to regular users.</p>"},{"location":"package/pip/media-provider/#regex","title":"<code><regex></code>","text":"<p>The regular expression used to identify links to this provider, it must not contain anchors or delimiters. It is strongly recommended to capture the primary object id using the <code>(?P<ID>...)</code> group.</p>"},{"location":"package/pip/media-provider/#classname","title":"<code><className></code>","text":"<p><code><className></code> and <code><html></code> are mutually exclusive.</p> <p>PHP-Callback-Class that is invoked to process the matched link in case that additional logic must be applied that cannot be handled through a simple replacement as defined by the <code><html></code> element.</p> <p>The callback-class must implement the interface <code>\\wcf\\system\\bbcode\\media\\provider\\IBBCodeMediaProvider</code>.</p>"},{"location":"package/pip/media-provider/#html","title":"<code><html></code>","text":"<p><code><className></code> and <code><html></code> are mutually exclusive.</p> <p>Replacement HTML that gets populated using the captured matches in <code><regex></code>, variables are accessed as <code>{$VariableName}</code>. For example, the capture group <code>(?P<ID>...)</code> is accessed using <code>{$ID}</code>.</p>"},{"location":"package/pip/media-provider/#example","title":"Example","text":"mediaProvider.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/mediaProvider.xsd\">\n <import>\n <provider name=\"youtube\">\n <title>YouTube</title>\n <regex><![CDATA[https?://(?:.+?\\.)?youtu(?:\\.be/|be\\.com/(?:#/)?watch\\?(?:.*?&)?v=)(?P<ID>[a-zA-Z0-9_-]+)(?:(?:\\?|&)t=(?P<start>[0-9hms]+)$)?]]></regex>\n <!-- advanced PHP callback -->\n <className><![CDATA[wcf\\system\\bbcode\\media\\provider\\YouTubeBBCodeMediaProvider]]></className>\n </provider>\n\n <provider name=\"youtube-playlist\">\n <title>YouTube Playlist</title>\n <regex><![CDATA[https?://(?:.+?\\.)?youtu(?:\\.be/|be\\.com/)playlist\\?(?:.*?&)?list=(?P<ID>[a-zA-Z0-9_-]+)]]></regex>\n <!-- uses a simple HTML replacement -->\n <html><![CDATA[<div class=\"videoContainer\"><iframe src=\"https://www.youtube.com/embed/videoseries?list={$ID}\" allowfullscreen></iframe></div>]]></html>\n </provider>\n </import>\n\n <delete>\n <provider name=\"example\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/menu-item/","title":"Menu Item Package Installation Plugin","text":"<p>Adds menu items to existing menus.</p>"},{"location":"package/pip/menu-item/#components","title":"Components","text":"<p>Each item is described as an <code><item></code> element with the mandatory attribute <code>identifier</code> that should follow the naming pattern <code><packageIdentifier>.<PageName></code>, e.g. <code>com.woltlab.wcf.Dashboard</code>.</p>"},{"location":"package/pip/menu-item/#menu","title":"<code><menu></code>","text":"<p>The target menu that the item should be added to, requires the internal identifier set by creating a menu through the menu.xml.</p>"},{"location":"package/pip/menu-item/#title","title":"<code><title></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The title is displayed as the link title of the menu item and can be fully customized by the administrator, thus is immutable after deployment. Supports multiple <code><title></code> elements to provide localized values.</p>"},{"location":"package/pip/menu-item/#page","title":"<code><page></code>","text":"<p>The page that the link should point to, requires the internal identifier set by creating a page through the page.xml.</p>"},{"location":"package/pip/menu-item/#example","title":"Example","text":"menuItem.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/menuItem.xsd\">\n <import>\n <item identifier=\"com.woltlab.wcf.Dashboard\">\n <menu>com.woltlab.wcf.MainMenu</menu>\n <title language=\"de\">Dashboard</title>\n <title language=\"en\">Dashboard</title>\n <page>com.woltlab.wcf.Dashboard</page>\n </item>\n </import>\n\n <delete>\n <item identifier=\"com.woltlab.wcf.FooterLinks\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/menu/","title":"Menu Package Installation Plugin","text":"<p>Deploy and manage menus that can be placed anywhere on the site.</p>"},{"location":"package/pip/menu/#components","title":"Components","text":"<p>Each item is described as a <code><menu></code> element with the mandatory attribute <code>identifier</code> that should follow the naming pattern <code><packageIdentifier>.<MenuName></code>, e.g. <code>com.woltlab.wcf.MainMenu</code>.</p>"},{"location":"package/pip/menu/#title","title":"<code><title></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The internal name displayed in the admin panel only, can be fully customized by the administrator and is immutable. Only one value is accepted and will be picked based on the site's default language, but you can provide localized values by including multiple <code><title></code> elements.</p>"},{"location":"package/pip/menu/#box","title":"<code><box></code>","text":"<p>The following elements of the box PIP are supported, please refer to the documentation to learn more about them:</p> <ul> <li><code><position></code></li> <li><code><showHeader></code></li> <li><code><visibleEverywhere></code></li> <li><code><visibilityExceptions></code></li> <li><code>cssClassName</code></li> </ul>"},{"location":"package/pip/menu/#example","title":"Example","text":"menu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/menu.xsd\">\n <import>\n <menu identifier=\"com.woltlab.wcf.FooterLinks\">\n <title language=\"de\">Footer-Links</title>\n <title language=\"en\">Footer Links</title>\n\n <box>\n <position>footer</position>\n <cssClassName>boxMenuLinkGroup</cssClassName>\n <showHeader>0</showHeader>\n <visibleEverywhere>1</visibleEverywhere>\n </box>\n </menu>\n </import>\n\n <delete>\n <menu identifier=\"com.woltlab.wcf.FooterLinks\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/object-type-definition/","title":"Object Type Definition Package Installation Plugin","text":"<p>Registers an object type definition. An object type definition is a blueprint for a certain behaviour that is particularized by objectTypes. As an example: Tags can be attached to different types of content (such as forum posts or gallery images). The bulk of the work is implemented in a generalized fashion, with all the tags stored in a single database table. Certain things, such as permission checking, need to be particularized for the specific type of content, though. Thus tags (or rather \u201ctaggable content\u201d) are registered as an object type definition. Posts are then registered as an object type, implementing the \u201ctaggable content\u201d behaviour.</p> <p>Other types of object type definitions include attachments, likes, polls, subscriptions, or even the category system.</p>"},{"location":"package/pip/object-type-definition/#components","title":"Components","text":"<p>Each item is described as a <code><definition></code> element with the mandatory child <code><name></code> that should follow the naming pattern <code><packageIdentifier>.<definition></code>, e.g. <code>com.woltlab.wcf.example</code>.</p>"},{"location":"package/pip/object-type-definition/#interfacename","title":"<code><interfacename></code>","text":"<p>Optional</p> <p>The name of the PHP interface objectTypes have to implement.</p>"},{"location":"package/pip/object-type-definition/#example","title":"Example","text":"objectTypeDefinition.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/objectTypeDefinition.xsd\">\n <import>\n <definition>\n <name>com.woltlab.wcf.example</name>\n <interfacename>wcf\\system\\example\\IExampleObjectType</interfacename>\n </definition>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/object-type/","title":"Object Type Package Installation Plugin","text":"<p>Registers an object type. Read about object types in the objectTypeDefinition PIP.</p>"},{"location":"package/pip/object-type/#components","title":"Components","text":"<p>Each item is described as a <code><type></code> element with the mandatory child <code><name></code> that should follow the naming pattern <code><packageIdentifier>.<definition></code>, e.g. <code>com.woltlab.wcf.example</code>.</p>"},{"location":"package/pip/object-type/#definitionname","title":"<code><definitionname></code>","text":"<p>The <code><name></code> of the objectTypeDefinition.</p>"},{"location":"package/pip/object-type/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the object types's behaviour, the class has to implement the <code><interfacename></code> interface of the object type definition.</p>"},{"location":"package/pip/object-type/#_1","title":"<code><*></code>","text":"<p>Optional</p> <p>Additional fields may be defined for specific definitions of object types. Refer to the documentation of these for further explanation.</p>"},{"location":"package/pip/object-type/#example","title":"Example","text":"objectType.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/objectType.xsd\">\n <import>\n <type>\n <name>com.woltlab.wcf.example</name>\n <definitionname>com.woltlab.wcf.bulkProcessing.user.condition</definitionname>\n <classname>wcf\\system\\condition\\UserIntegerPropertyCondition</classname>\n <conditiongroup>contents</conditiongroup>\n <propertyname>example</propertyname>\n <minvalue>0</minvalue>\n </type>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/option/","title":"Option Package Installation Plugin","text":"<p>Registers new options. Options allow the administrator to configure the behaviour of installed packages. The specified values are exposed as PHP constants.</p>"},{"location":"package/pip/option/#category-components","title":"Category Components","text":"<p>Each category is described as an <code><category></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/option/#parent","title":"<code><parent></code>","text":"<p>Optional</p> <p>The category\u2019s parent category.</p>"},{"location":"package/pip/option/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this option within the parent category.</p>"},{"location":"package/pip/option/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the category to be shown to the administrator.</p>"},{"location":"package/pip/option/#option-components","title":"Option Components","text":"<p>Each option is described as an <code><option></code> element with the mandatory attribute <code>name</code>. The <code>name</code> is transformed into a PHP constant name by uppercasing it.</p>"},{"location":"package/pip/option/#categoryname","title":"<code><categoryname></code>","text":"<p>The option\u2019s category.</p>"},{"location":"package/pip/option/#optiontype","title":"<code><optiontype></code>","text":"<p>The type of input to be used for this option. Valid types are defined by the <code>wcf\\system\\option\\*OptionType</code> classes.</p>"},{"location":"package/pip/option/#defaultvalue","title":"<code><defaultvalue></code>","text":"<p>The value that is set after installation of a package. Valid values are defined by the <code>optiontype</code>.</p>"},{"location":"package/pip/option/#validationpattern","title":"<code><validationpattern></code>","text":"<p>Optional</p> <p>Defines a regular expression that is used to validate the value of a free form option (such as <code>text</code>).</p>"},{"location":"package/pip/option/#showorder_1","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this option within the category.</p>"},{"location":"package/pip/option/#selectoptions","title":"<code><selectoptions></code>","text":"<p>Optional</p> <p>Defined only for <code>select</code>, <code>multiSelect</code> and <code>radioButton</code> types.</p> <p>Specifies a newline-separated list of selectable values. Each line consists of an internal handle, followed by a colon (<code>:</code>, U+003A), followed by a language item. The language item is shown to the administrator, the internal handle is what is saved and exposed to the code.</p>"},{"location":"package/pip/option/#enableoptions","title":"<code><enableoptions></code>","text":"<p>Optional</p> <p>Defined only for <code>boolean</code>, <code>select</code> and <code>radioButton</code> types.</p> <p>Specifies a comma-separated list of options which should be visually enabled when this option is enabled. A leading exclamation mark (<code>!</code>, U+0021) will disable the specified option when this option is enabled. For <code>select</code> and <code>radioButton</code> types the list should be prefixed by the internal <code>selectoptions</code> handle followed by a colon (<code>:</code>, U+003A).</p> <p>This setting is a visual helper for the administrator only. It does not have an effect on the server side processing of the option.</p>"},{"location":"package/pip/option/#hidden","title":"<code><hidden></code>","text":"<p>Optional</p> <p>If <code>hidden</code> is set to <code>1</code> the option will not be shown to the administrator. It still can be modified programmatically.</p>"},{"location":"package/pip/option/#options_1","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the option to be shown to the administrator.</p>"},{"location":"package/pip/option/#supporti18n","title":"<code><supporti18n></code>","text":"<p>Optional</p> <p>Specifies whether this option supports localized input.</p>"},{"location":"package/pip/option/#requirei18n","title":"<code><requirei18n></code>","text":"<p>Optional</p> <p>Specifies whether this option requires localized input (i.e. the administrator must specify a value for every installed language).</p>"},{"location":"package/pip/option/#_1","title":"<code><*></code>","text":"<p>Optional</p> <p>Additional fields may be defined by specific types of options. Refer to the documentation of these for further explanation.</p>"},{"location":"package/pip/option/#language-items","title":"Language Items","text":"<p>All relevant language items have to be put into the <code>wcf.acp.option</code> language item category.</p>"},{"location":"package/pip/option/#categories","title":"Categories","text":"<p>If you install a category named <code>example.sub</code>, you have to provide the language item <code>wcf.acp.option.category.example.sub</code>, which is used when displaying the options. If you want to provide an optional description of the category, you have to provide the language item <code>wcf.acp.option.category.example.sub.description</code>. Descriptions are only relevant for categories whose parent has a parent itself, i.e. categories on the third level.</p>"},{"location":"package/pip/option/#options_2","title":"Options","text":"<p>If you install an option named <code>module_example</code>, you have to provide the language item <code>wcf.acp.option.module_example</code>, which is used as a label for setting the option value. If you want to provide an optional description of the option, you have to provide the language item <code>wcf.acp.option.module_example.description</code>.</p>"},{"location":"package/pip/option/#example","title":"Example","text":"option.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/option.xsd\">\n <import>\n <categories>\n <category name=\"example\" />\n <category name=\"example.sub\">\n <parent>example</parent>\n <options>module_example</options>\n </category>\n </categories>\n\n <options>\n <option name=\"module_example\">\n <categoryname>module.community</categoryname>\n <optiontype>boolean</optiontype>\n <defaultvalue>1</defaultvalue>\n </option>\n\n <option name=\"example_integer\">\n <categoryname>example.sub</categoryname>\n <optiontype>integer</optiontype>\n <defaultvalue>10</defaultvalue>\n <minvalue>5</minvalue>\n <maxvalue>40</maxvalue>\n </option>\n\n <option name=\"example_select\">\n <categoryname>example.sub</categoryname>\n <optiontype>select</optiontype>\n <defaultvalue>DESC</defaultvalue>\n <selectoptions>ASC:wcf.global.sortOrder.ascending\n DESC:wcf.global.sortOrder.descending</selectoptions>\n </option>\n </options>\n </import>\n\n <delete>\n <option name=\"outdated_example\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/page/","title":"Page Package Installation Plugin","text":"<p>Registers page controllers, making them available for selection and configuration, including but not limited to boxes and menus.</p>"},{"location":"package/pip/page/#components","title":"Components","text":"<p>Each item is described as a <code><page></code> element with the mandatory attribute <code>identifier</code> that should follow the naming pattern <code><packageIdentifier>.<PageName></code>, e.g. <code>com.woltlab.wcf.MembersList</code>.</p>"},{"location":"package/pip/page/#pagetype","title":"<code><pageType></code>","text":""},{"location":"package/pip/page/#system","title":"<code>system</code>","text":"<p>The special <code>system</code> type is reserved for pages that pull their properties and content from a registered PHP class. Requires the <code><controller></code> element.</p>"},{"location":"package/pip/page/#html-text-or-tpl","title":"<code>html</code>, <code>text</code> or <code>tpl</code>","text":"<p>Provide arbitrary content, requires the <code><content></code> element.</p>"},{"location":"package/pip/page/#controller","title":"<code><controller></code>","text":"<p>Fully qualified class name for the controller, must implement <code>wcf\\page\\IPage</code> or <code>wcf\\form\\IForm</code>.</p>"},{"location":"package/pip/page/#handler","title":"<code><handler></code>","text":"<p>Fully qualified class name that can be optionally set to provide additional methods, such as displaying a badge for unread content and verifying permissions per page object id.</p>"},{"location":"package/pip/page/#name","title":"<code><name></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p> <p>The internal name displayed in the admin panel only, can be fully customized by the administrator and is immutable. Only one value is accepted and will be picked based on the site's default language, but you can provide localized values by including multiple <code><name></code> elements.</p>"},{"location":"package/pip/page/#parent","title":"<code><parent></code>","text":"<p>Sets the default parent page using its internal identifier, this setting controls the breadcrumbs and active menu item hierarchy.</p>"},{"location":"package/pip/page/#hasfixedparent","title":"<code><hasFixedParent></code>","text":"<p>Pages can be assigned any other page as parent page by default, set to <code>1</code> to make the parent setting immutable.</p>"},{"location":"package/pip/page/#permissions","title":"<code><permissions></code>","text":"<p>The comma represents a logical <code>or</code>, the check is successful if at least one permission is set.</p> <p>Comma separated list of permission names that will be checked one after another until at least one permission is set.</p>"},{"location":"package/pip/page/#options","title":"<code><options></code>","text":"<p>The comma represents a logical <code>or</code>, the check is successful if at least one option is enabled.</p> <p>Comma separated list of options that will be checked one after another until at least one option is set.</p>"},{"location":"package/pip/page/#excludefromlandingpage","title":"<code><excludeFromLandingPage></code>","text":"<p>Some pages should not be used as landing page, because they may not always be available and/or accessible to the user. For example, the account management page is available to logged-in users only and any guest attempting to visit that page would be presented with a permission denied message.</p> <p>Set this to <code>1</code> to prevent this page from becoming a landing page ever.</p>"},{"location":"package/pip/page/#requireobjectid","title":"<code><requireObjectID></code>","text":"<p>If the page requires an id of a specific object, like the user profile page requires the id of the user whose profile page is requested, <code><requireObjectID>1</requireObjectID></code> has to be added. If this item is not present, <code>requireObjectID</code> defaults to <code>0</code>.</p>"},{"location":"package/pip/page/#availableduringofflinemode","title":"<code><availableDuringOfflineMode></code>","text":"<p>During offline mode, most pages should generally not be available. Certain pages, however, might still have to be accessible due to, for example, legal reasons. To make a page available during offline mode, <code><availableDuringOfflineMode>1</availableDuringOfflineMode></code> has to be added. If this item is not present, <code>availableDuringOfflineMode</code> defaults to <code>0</code>.</p>"},{"location":"package/pip/page/#allowspiderstoindex","title":"<code><allowSpidersToIndex></code>","text":"<p>Administrators are able to set in the admin panel for each page, whether or not spiders are allowed to index it. The default value for this option can be set with the <code>allowSpidersToIndex</code> item whose value defaults to <code>0</code>.</p>"},{"location":"package/pip/page/#cssclassname","title":"<code><cssClassName></code>","text":"<p>To add custom CSS classes to a page\u2019s <code><body></code> HTML element, you can specify them via the <code>cssClassName</code> item.</p> <p>If you want to add multiple CSS classes, separate them with spaces!</p>"},{"location":"package/pip/page/#content","title":"<code><content></code>","text":"<p>The <code>language</code> attribute is required and should specify the ISO-639-1 language code.</p>"},{"location":"package/pip/page/#title","title":"<code><title></code>","text":"<p>The title element is required and controls the page title shown to the end users.</p>"},{"location":"package/pip/page/#content_1","title":"<code><content></code>","text":"<p>The content that should be used to populate the page, only used and required if the <code>pageType</code> equals <code>text</code>, <code>html</code> and <code>tpl</code>.</p>"},{"location":"package/pip/page/#example","title":"Example","text":"page.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/page.xsd\">\n <import>\n <page identifier=\"com.woltlab.wcf.MembersList\">\n <pageType>system</pageType>\n <controller>wcf\\page\\MembersListPage</controller>\n <name language=\"de\">Mitglieder</name>\n <name language=\"en\">Members</name>\n <options>module_members_list</options>\n <permissions>user.profile.canViewMembersList</permissions>\n <allowSpidersToIndex>1</allowSpidersToIndex>\n <content language=\"en\">\n <title>Members</title>\n </content>\n <content language=\"de\">\n <title>Mitglieder</title>\n </content>\n </page>\n </import>\n\n <delete>\n <page identifier=\"com.woltlab.wcf.MembersList\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/pip/","title":"Package Installation Plugin Package Installation Plugin","text":"<p>Registers new package installation plugins.</p>"},{"location":"package/pip/pip/#components","title":"Components","text":"<p>Each package installation plugin is described as an <code><pip></code> element with a <code>name</code> attribute and a PHP classname as the text content.</p> <p>The package installation plugin\u2019s class file must be installed into the <code>wcf</code> application and must not include classes outside the <code>\\wcf\\*</code> hierarchy to allow for proper uninstallation!</p>"},{"location":"package/pip/pip/#example","title":"Example","text":"packageInstallationPlugin.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/packageInstallationPlugin.xsd\">\n <import>\n <pip name=\"custom\">wcf\\system\\package\\plugin\\CustomPackageInstallationPlugin</pip>\n </import>\n <delete>\n <pip name=\"outdated\" />\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/script/","title":"Script Package Installation Plugin","text":"<p>Execute arbitrary PHP code during installation, update and uninstallation of the package.</p> <p>You must install the PHP script through the file package installation plugin.</p> <p>The installation will attempt to delete the script after successful execution.</p>"},{"location":"package/pip/script/#attributes","title":"Attributes","text":""},{"location":"package/pip/script/#application","title":"<code>application</code>","text":"<p>The <code>application</code> attribute must have the same value as the <code>application</code> attribute of the <code>file</code> package installation plugin instruction so that the correct file in the intended application directory is executed. For further information about the <code>application</code> attribute, refer to its documentation on the acpTemplate package installation plugin page.</p>"},{"location":"package/pip/script/#expected-value","title":"Expected value","text":"<p>The <code>script</code>-PIP expects a relative path to a <code>.php</code> file.</p>"},{"location":"package/pip/script/#naming-convention","title":"Naming convention","text":"<p>The PHP script is deployed by using the file package installation plugin. To prevent it from colliding with other install script (remember: You cannot overwrite files created by another plugin), we highly recommend to make use of these naming conventions:</p> <ul> <li>Installation: <code>install_<package>.php</code> (example: <code>install_com.woltlab.wbb.php</code>)</li> <li>Update: <code>update_<package>_<targetVersion>.php</code> (example: <code>update_com.woltlab.wbb_5.0.0_pl_1.php</code>)</li> </ul> <p><code><targetVersion></code> equals the version number of the current package being installed. If you're updating from <code>1.0.0</code> to <code>1.0.1</code>, <code><targetVersion></code> should read <code>1.0.1</code>.</p>"},{"location":"package/pip/script/#execution-environment","title":"Execution environment","text":"<p>The script is included using <code>include()</code> within ScriptPackageInstallationPlugin::run(). This grants you access to the class members, including <code>$this->installation</code>.</p> <p>You can retrieve the package id of the current package through <code>$this->installation->getPackageID()</code>.</p>"},{"location":"package/pip/smiley/","title":"Smiley Package Installation Plugin","text":"<p>Installs new smileys.</p>"},{"location":"package/pip/smiley/#components","title":"Components","text":"<p>Each smiley is described as an <code><smiley></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/smiley/#title","title":"<code><title></code>","text":"<p>Short human readable description of the smiley.</p>"},{"location":"package/pip/smiley/#path2x","title":"<code><path(2x)?></code>","text":"<p>The files must be installed using the file PIP.</p> <p>File path relative to the root of WoltLab Suite Core. <code>path2x</code> is optional and being used for High-DPI screens.</p>"},{"location":"package/pip/smiley/#aliases","title":"<code><aliases></code>","text":"<p>Optional</p> <p>List of smiley aliases. Aliases must be separated by a line feed character (<code>\\n</code>, U+000A).</p>"},{"location":"package/pip/smiley/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the smiley list the smiley is shown.</p>"},{"location":"package/pip/smiley/#example","title":"Example","text":"smiley.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/smiley.xsd\">\n <import>\n <smiley name=\":example:\">\n <title>example</title>\n <path>images/smilies/example.png</path>\n <path2x>images/smilies/example@2x.png</path2x>\n <aliases><![CDATA[:alias:\n:more_aliases:]]></aliases>\n </smiley>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/sql/","title":"SQL Package Installation Plugin","text":"<p>Execute SQL instructions using a MySQL-flavored syntax.</p> <p>This file is parsed by WoltLab Suite Core to allow reverting of certain changes, but not every syntax MySQL supports is recognized by the parser. To avoid any troubles, you should always use statements relying on the SQL standard.</p>"},{"location":"package/pip/sql/#expected-value","title":"Expected Value","text":"<p>The <code>sql</code> package installation plugin expects a relative path to a <code>.sql</code> file.</p>"},{"location":"package/pip/sql/#features","title":"Features","text":""},{"location":"package/pip/sql/#logging","title":"Logging","text":"<p>WoltLab Suite Core uses a SQL parser to extract queries and log certain actions. This allows WoltLab Suite Core to revert some of the changes you apply upon package uninstallation.</p> <p>The logged changes are:</p> <ul> <li><code>CREATE TABLE</code></li> <li><code>ALTER TABLE \u2026 ADD COLUMN</code></li> <li><code>ALTER TABLE \u2026 ADD \u2026 KEY</code></li> </ul>"},{"location":"package/pip/sql/#instance-number","title":"Instance Number","text":"<p>It is possible to use different instance numbers, e.g. two separate WoltLab Suite Core installations within one database. WoltLab Suite Core requires you to always use <code>wcf1_<tableName></code> or <code><app>1_<tableName></code> (e.g. <code>blog1_blog</code> in WoltLab Suite Blog), the number (<code>1</code>) will be automatically replaced prior to execution. If you every use anything other but <code>1</code>, you will eventually break things, thus always use <code>1</code>!</p>"},{"location":"package/pip/sql/#table-type","title":"Table Type","text":"<p>WoltLab Suite Core will determine the type of database tables on its own: If the table contains a <code>FULLTEXT</code> index, it uses <code>MyISAM</code>, otherwise <code>InnoDB</code> is used.</p>"},{"location":"package/pip/sql/#limitations","title":"Limitations","text":""},{"location":"package/pip/sql/#logging_1","title":"Logging","text":"<p>WoltLab Suite Core cannot revert changes to the database structure which would cause to the data to be either changed or new data to be incompatible with the original format. Additionally, WoltLab Suite Core does not track regular SQL queries such as <code>DELETE</code> or <code>UPDATE</code>.</p>"},{"location":"package/pip/sql/#triggers","title":"Triggers","text":"<p>WoltLab Suite Core does not support trigger since MySQL does not support execution of triggers if the event was fired by a cascading foreign key action. If you really need triggers, you should consider adding them by custom SQL queries using a script.</p>"},{"location":"package/pip/sql/#example","title":"Example","text":"<p><code>package.xml</code>:</p> <pre><code><instruction type=\"sql\">install.sql</instruction>\n</code></pre> <p>Example content:</p> install.sql <pre><code>CREATE TABLE wcf1_foo_bar (\n fooID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n packageID INT(10) NOT NULL,\n bar VARCHAR(255) NOT NULL DEFAULT '',\n foobar VARCHAR(50) NOT NULL DEFAULT '',\n\n UNIQUE KEY baz (bar, foobar)\n);\n\nALTER TABLE wcf1_foo_bar ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;\n</code></pre>"},{"location":"package/pip/style/","title":"Style Package Installation Plugin","text":"<p>Install styles during package installation.</p> <p>The <code>style</code> package installation plugins expects a relative path to a <code>.tar</code> file, a<code>.tar.gz</code> file or a <code>.tgz</code> file. Please use the ACP's export mechanism to export styles.</p>"},{"location":"package/pip/style/#example-in-packagexml","title":"Example in <code>package.xml</code>","text":"<pre><code><instruction type=\"style\">style.tgz</instruction>\n</code></pre>"},{"location":"package/pip/template-delete/","title":"Template Delete Package Installation Plugin","text":"<p>Deletes frontend templates installed with the template package installation plugin.</p> <p>You cannot delete templates provided by other packages.</p>"},{"location":"package/pip/template-delete/#components","title":"Components","text":"<p>Each item is described as a <code><template></code> element with an optional <code>application</code>, which behaves like it does for acp templates. The templates are identified by their name like when adding template listeners, i.e. by the file name without the <code>.tpl</code> file extension.</p>"},{"location":"package/pip/template-delete/#example","title":"Example","text":"templateDelete.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/templateDelete.xsd\">\n <delete>\n <template>fouAdd</template>\n <template application=\"app\">__appAdd</template>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/template-listener/","title":"Template Listener Package Installation Plugin","text":"<p>Registers template listeners. Template listeners supplement event listeners, which modify server side behaviour, by adding additional template code to display additional elements. The added template code behaves as if it was part of the original template (i.e. it has access to all local variables).</p>"},{"location":"package/pip/template-listener/#components","title":"Components","text":"<p>Each event listener is described as an <code><templatelistener></code> element with a <code>name</code> attribute. As the <code>name</code> attribute has only be introduced with WSC 3.0, it is not yet mandatory to allow backwards compatibility. If <code>name</code> is not given, the system automatically sets the name based on the id of the event listener in the database.</p>"},{"location":"package/pip/template-listener/#templatename","title":"<code><templatename></code>","text":"<p>The template name is the name of the template in which the event is fired. It correspondes to the <code>eventclassname</code> field of event listeners.</p>"},{"location":"package/pip/template-listener/#eventname","title":"<code><eventname></code>","text":"<p>The event name is the name given when the event is fired to identify different events within the same template.</p>"},{"location":"package/pip/template-listener/#templatecode","title":"<code><templatecode></code>","text":"<p>The given template code is literally copied into the target template during compile time. The original template is not modified. If multiple template listeners listen to a single event their output is concatenated using the line feed character (<code>\\n</code>, U+000A) in the order defined by the <code>niceValue</code>.</p> <p>It is recommend that the only code is an <code>{include}</code> of a template to enable changes by the administrator. Names of templates included by a template listener start with two underscores by convention.</p>"},{"location":"package/pip/template-listener/#environment","title":"<code><environment></code>","text":"<p>The value of the environment element can either be <code>admin</code> or <code>user</code> and is <code>user</code> if no value is given. The value determines if the template listener will be executed in the frontend (<code>user</code>) or the backend (<code>admin</code>).</p>"},{"location":"package/pip/template-listener/#nice","title":"<code><nice></code>","text":"<p>Optional</p> <p>The nice value element can contain an integer value out of the interval <code>[-128,127]</code> with <code>0</code> being the default value if the element is omitted. The nice value determines the execution order of template listeners. Template listeners with smaller nice values are executed first. If the nice value of two template listeners is equal, the order is undefined.</p> <p>If you pass a value out of the mentioned interval, the value will be adjusted to the closest value in the interval.</p>"},{"location":"package/pip/template-listener/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The use of <code><options></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the template listener to be executed.</p>"},{"location":"package/pip/template-listener/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The use of <code><permissions></code> has been deprecated in WoltLab Suite 6.0. Use a regular <code>{if}</code> statement in the template instead.</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the template listener to be executed.</p>"},{"location":"package/pip/template-listener/#example","title":"Example","text":"templateListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/templatelistener.xsd\">\n <import>\n <templatelistener name=\"example\">\n <environment>user</environment>\n <templatename>headIncludeJavaScript</templatename>\n <eventname>javascriptInclude</eventname>\n <templatecode><![CDATA[{include file='__myCustomJavaScript'}]]></templatecode>\n </templatelistener>\n </import>\n\n <delete>\n <templatelistener name=\"oldTemplateListenerName\">\n <environment>user</environment>\n <templatename>headIncludeJavaScript</templatename>\n <eventname>javascriptInclude</eventname>\n </templatelistener>\n </delete>\n</data>\n</code></pre>"},{"location":"package/pip/template/","title":"Template Package Installation Plugin","text":"<p>Add templates for frontend pages and forms by providing an archive containing the template files.</p> <p>You cannot overwrite templates provided by other packages.</p> <p>This package installation plugin behaves exactly like the acpTemplate package installation plugin except for installing frontend templates instead of backend/acp templates.</p>"},{"location":"package/pip/user-group-option/","title":"User Group Option Package Installation Plugin","text":"<p>Registers new user group options (\u201cpermissions\u201d). The behaviour of this package installation plugin closely follows the option PIP.</p>"},{"location":"package/pip/user-group-option/#category-components","title":"Category Components","text":"<p>The category definition works exactly like the option PIP.</p>"},{"location":"package/pip/user-group-option/#option-components","title":"Option Components","text":"<p>The fields <code>hidden</code>, <code>supporti18n</code> and <code>requirei18n</code> do not apply. The following extra fields are defined:</p>"},{"location":"package/pip/user-group-option/#adminmoduserdefaultvalue","title":"<code><(admin|mod|user)defaultvalue></code>","text":"<p>Defines the <code>defaultvalue</code>s for subsets of the groups:</p> Type Description admin Groups where the <code>admin.user.accessibleGroups</code> user group option includes every group. mod Groups where the <code>mod.general.canUseModeration</code> is set to <code>true</code>. user Groups where the internal group type is neither <code>UserGroup::EVERYONE</code> nor <code>UserGroup::GUESTS</code>."},{"location":"package/pip/user-group-option/#usersonly","title":"<code><usersonly></code>","text":"<p>Makes the option unavailable for groups with the group type <code>UserGroup::GUESTS</code>.</p>"},{"location":"package/pip/user-group-option/#language-items","title":"Language Items","text":"<p>All relevant language items have to be put into the <code>wcf.acp.group</code> language item category.</p>"},{"location":"package/pip/user-group-option/#categories","title":"Categories","text":"<p>If you install a category named <code>user.foo</code>, you have to provide the language item <code>wcf.acp.group.option.category.user.foo</code>, which is used when displaying the options. If you want to provide an optional description of the category, you have to provide the language item <code>wcf.acp.group.option.category.user.foo.description</code>. Descriptions are only relevant for categories whose parent has a parent itself, i.e. categories on the third level.</p>"},{"location":"package/pip/user-group-option/#options","title":"Options","text":"<p>If you install an option named <code>user.foo.canBar</code>, you have to provide the language item <code>wcf.acp.group.option.user.foo.canBar</code>, which is used as a label for setting the option value. If you want to provide an optional description of the option, you have to provide the language item <code>wcf.acp.group.option.user.foo.canBar.description</code>.</p>"},{"location":"package/pip/user-menu/","title":"User Menu Package Installation Plugin","text":"<p>Registers new user menu items.</p>"},{"location":"package/pip/user-menu/#components","title":"Components","text":"<p>Each item is described as an <code><usermenuitem></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/user-menu/#parent","title":"<code><parent></code>","text":"<p>Optional</p> <p>The item\u2019s parent item.</p>"},{"location":"package/pip/user-menu/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Specifies the order of this item within the parent item.</p>"},{"location":"package/pip/user-menu/#controller","title":"<code><controller></code>","text":"<p>The fully qualified class name of the target controller. If not specified this item serves as a category.</p>"},{"location":"package/pip/user-menu/#link","title":"<code><link></code>","text":"<p>Additional components if <code><controller></code> is set, the full external link otherwise.</p>"},{"location":"package/pip/user-menu/#iconclassname","title":"<code><iconclassname></code>","text":"<p>Use an icon only for top-level items.</p> <p>Specifiy the name of the Font Awesome icon. For regular icons, the solid variant can be requested with the attribute <code>solid=\"true\"</code>.</p> <p>Brand icons are supported using the separate attribute <code>type=\"brand\"</code>.</p>"},{"location":"package/pip/user-menu/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the menu item to be shown.</p>"},{"location":"package/pip/user-menu/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the menu item to be shown.</p>"},{"location":"package/pip/user-menu/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the user menu item\u2019s behaviour, the class has to implement the <code>wcf\\system\\menu\\user\\IUserMenuItemProvider</code> interface.</p>"},{"location":"package/pip/user-menu/#example","title":"Example","text":"userMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userMenu.xsd\">\n <import>\n <usermenuitem name=\"wcf.user.menu.foo\">\n <iconclassname>home</iconclassname>\n </usermenuitem>\n\n <usermenuitem name=\"wcf.user.menu.foo.bar\">\n <controller>wcf\\page\\FooBarListPage</controller>\n <parent>wcf.user.menu.foo</parent>\n <permissions>user.foo.canBar</permissions>\n <classname>wcf\\system\\menu\\user\\FooBarMenuItemProvider</classname>\n </usermenuitem>\n\n <usermenuitem name=\"wcf.user.menu.foo.baz\">\n <controller>wcf\\page\\FooBazListPage</controller>\n <parent>wcf.user.menu.foo</parent>\n <permissions>user.foo.canBaz</permissions>\n <options>module_foo_bar</options>\n </usermenuitem>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/user-notification-event/","title":"User Notification Event Package Installation Plugin","text":"<p>Registers new user notification events.</p>"},{"location":"package/pip/user-notification-event/#components","title":"Components","text":"<p>Each package installation plugin is described as an <code><event></code> element with the mandatory child <code><name></code>.</p>"},{"location":"package/pip/user-notification-event/#objecttype","title":"<code><objectType></code>","text":"<p>The <code>(name, objectType)</code> pair must be unique.</p> <p>The given object type must implement the <code>com.woltlab.wcf.notification.objectType</code> definition.</p>"},{"location":"package/pip/user-notification-event/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the event's behaviour, the class has to implement the <code>wcf\\system\\user\\notification\\event\\IUserNotificationEvent</code> interface.</p>"},{"location":"package/pip/user-notification-event/#preset","title":"<code><preset></code>","text":"<p>Defines whether this event is enabled by default.</p>"},{"location":"package/pip/user-notification-event/#presetmailnotificationtype","title":"<code><presetmailnotificationtype></code>","text":"<p>Avoid using this option, as sending unsolicited mail can be seen as spamming.</p> <p>One of <code>instant</code> or <code>daily</code>. Defines whether this type of email notifications is enabled by default.</p>"},{"location":"package/pip/user-notification-event/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the notification type to be available.</p>"},{"location":"package/pip/user-notification-event/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the notification type to be available.</p>"},{"location":"package/pip/user-notification-event/#example","title":"Example","text":"userNotificationEvent.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userNotificationEvent.xsd\">\n <import>\n <event>\n <name>like</name>\n <objecttype>com.woltlab.example.comment.like.notification</objecttype>\n <classname>wcf\\system\\user\\notification\\event\\ExampleCommentLikeUserNotificationEvent</classname>\n <preset>1</preset>\n <options>module_like</options>\n </event>\n </import>\n</data>\n</code></pre>"},{"location":"package/pip/user-option/","title":"User Option Package Installation Plugin","text":"<p>Registers new user options (profile fields / user settings). The behaviour of this package installation plugin closely follows the option PIP.</p>"},{"location":"package/pip/user-option/#category-components","title":"Category Components","text":"<p>The category definition works exactly like the option PIP.</p>"},{"location":"package/pip/user-option/#option-components","title":"Option Components","text":"<p>The fields <code>hidden</code>, <code>supporti18n</code> and <code>requirei18n</code> do not apply. The following extra fields are defined:</p>"},{"location":"package/pip/user-option/#required","title":"<code><required></code>","text":"<p>Requires that a value is provided.</p>"},{"location":"package/pip/user-option/#askduringregistration","title":"<code><askduringregistration></code>","text":"<p>If set to <code>1</code> the field is shown during user registration in the frontend.</p>"},{"location":"package/pip/user-option/#editable","title":"<code><editable></code>","text":"<p>Bitfield with the following options (constants in <code>wcf\\data\\user\\option\\UserOption</code>)</p> Name Value EDITABILITY_OWNER 1 EDITABILITY_ADMINISTRATOR 2 EDITABILITY_OWNER_DURING_REGISTRATION 4"},{"location":"package/pip/user-option/#visible","title":"<code><visible></code>","text":"<p>Bitfield with the following options (constants in <code>wcf\\data\\user\\option\\UserOption</code>)</p> Name Value VISIBILITY_OWNER 1 VISIBILITY_ADMINISTRATOR 2 VISIBILITY_REGISTERED 4 VISIBILITY_GUEST 8"},{"location":"package/pip/user-option/#searchable","title":"<code><searchable></code>","text":"<p>If set to <code>1</code> the field is searchable.</p>"},{"location":"package/pip/user-option/#outputclass","title":"<code><outputclass></code>","text":"<p>PHP class responsible for output formatting of this field. the class has to implement the <code>wcf\\system\\option\\user\\IUserOptionOutput</code> interface.</p>"},{"location":"package/pip/user-option/#language-items","title":"Language Items","text":"<p>All relevant language items have to be put into the <code>wcf.user.option</code> language item category.</p>"},{"location":"package/pip/user-option/#categories","title":"Categories","text":"<p>If you install a category named <code>example</code>, you have to provide the language item <code>wcf.user.option.category.example</code>, which is used when displaying the options. If you want to provide an optional description of the category, you have to provide the language item <code>wcf.user.option.category.example.description</code>. Descriptions are only relevant for categories whose parent has a parent itself, i.e. categories on the third level.</p>"},{"location":"package/pip/user-option/#options","title":"Options","text":"<p>If you install an option named <code>exampleOption</code>, you have to provide the language item <code>wcf.user.option.exampleOption</code>, which is used as a label for setting the option value. If you want to provide an optional description of the option, you have to provide the language item <code>wcf.user.option.exampleOption.description</code>.</p>"},{"location":"package/pip/user-profile-menu/","title":"User Profile Menu Package Installation Plugin","text":"<p>Registers new user profile tabs.</p>"},{"location":"package/pip/user-profile-menu/#components","title":"Components","text":"<p>Each tab is described as an <code><userprofilemenuitem></code> element with the mandatory attribute <code>name</code>.</p>"},{"location":"package/pip/user-profile-menu/#classname","title":"<code><classname></code>","text":"<p>The name of the class providing the tab\u2019s behaviour, the class has to implement the <code>wcf\\system\\menu\\user\\profile\\content\\IUserProfileMenuContent</code> interface.</p>"},{"location":"package/pip/user-profile-menu/#showorder","title":"<code><showorder></code>","text":"<p>Optional</p> <p>Determines at which position of the tab list the tab is shown.</p>"},{"location":"package/pip/user-profile-menu/#options","title":"<code><options></code>","text":"<p>Optional</p> <p>The options element can contain a comma-separated list of options of which at least one needs to be enabled for the tab to be shown.</p>"},{"location":"package/pip/user-profile-menu/#permissions","title":"<code><permissions></code>","text":"<p>Optional</p> <p>The permissions element can contain a comma-separated list of permissions of which the active user needs to have at least one for the tab to be shown.</p>"},{"location":"package/pip/user-profile-menu/#example","title":"Example","text":"userProfileMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"utf-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userProfileMenu.xsd\">\n <import>\n <userprofilemenuitem name=\"example\">\n <classname>wcf\\system\\menu\\user\\profile\\content\\ExampleProfileMenuContent</classname>\n <showorder>3</showorder>\n <options>module_example</options>\n </userprofilemenuitem>\n </import>\n</data>\n</code></pre>"},{"location":"php/apps/","title":"Apps for WoltLab Suite","text":""},{"location":"php/apps/#introduction","title":"Introduction","text":"<p>Apps are among the most powerful components in WoltLab Suite. Unlike plugins that extend an existing functionality and pages, apps have their own frontend with a dedicated namespace, database table prefixes and template locations.</p> <p>However, apps are meant to be a logical (and to some extent physical) separation from other parts of the framework, including other installed apps. They offer an additional layer of isolation and enable you to re-use class and template names that are already in use by the Core itself.</p> <p>If you've come here, thinking about the question if your next package should be an app instead of a regular plugin, the result is almost always: No.</p>"},{"location":"php/apps/#differences-to-plugins","title":"Differences to Plugins","text":"<p>Apps do offer a couple of unique features that are not available to plugins and there are valid reasons to use one instead of a plugin, but they also increase both the code and system complexity. There is a performance penalty for each installed app, regardless if it is actively used in a request or not, simplying being there forces the Core to include it in many places, for example, class resolution or even simple tasks such as constructing a link.</p>"},{"location":"php/apps/#unique-namespace","title":"Unique Namespace","text":"<p>Each app has its own unique namespace that is entirely separated from the Core and any other installed apps. The namespace is derived from the last part of the package identifier, for example, <code>com.example.foo</code> will yield the namespace <code>foo</code>.</p> <p>The namespace is always relative to the installation directory of the app, it doesn't matter if the app is installed on <code>example.com/foo/</code> or in <code>example.com/bar/</code>, the namespace will always resolve to the right directory.</p> <p>This app namespace is also used for ACP templates, frontend templates and files:</p> <pre><code><!-- somewhere in the package.xml -->\n<instructions type=\"file\" application=\"foo\" />\n</code></pre>"},{"location":"php/apps/#unique-database-table-prefix","title":"Unique Database Table Prefix","text":"<p>All database tables make use of a generic prefix that is derived from one of the installed apps, including <code>wcf</code> which resolves to the Core itself. Following the aforementioned example, the new prefix <code>fooN_</code> will be automatically registered and recognized in any generated statement.</p> <p>Any <code>DatabaseObject</code> that uses the app's namespace is automatically assumed to use the app's database prefix. For instance, <code>foo\\data\\bar\\Bar</code> is implicitly mapped to the database table <code>fooN_bar</code>.</p> <p>The app prefix is recognized in SQL-PIPs and statements that reference one of its database tables are automatically rewritten to use the Core's instance number.</p>"},{"location":"php/apps/#separate-domain-and-path-configuration","title":"Separate Domain and Path Configuration","text":"<p>Any controller that is provided by a plugin is served from the configured domain and path of the corresponding app, such as plugins for the Core are always served from the Core's directory. Apps are different and use their own domain and/or path to present their content, additionally, this allows the app to re-use a controller name that is already provided by the Core or any other app itself.</p>"},{"location":"php/apps/#creating-an-app","title":"Creating an App","text":"<p>This is a non-reversible operation! Once a package has been installed, its type cannot be changed without uninstalling and reinstalling the entire package, an app will always be an app and vice versa.</p>"},{"location":"php/apps/#packagexml","title":"<code>package.xml</code>","text":"<p>The <code>package.xml</code> supports two additional elements in the <code><packageinformation></code> block that are unique to applications.</p>"},{"location":"php/apps/#isapplication1isapplication","title":"<code><isapplication>1</isapplication></code>","text":"<p>This element is responsible to flag a package as an app.</p>"},{"location":"php/apps/#applicationdirectoryexampleapplicationdirectory","title":"<code><applicationdirectory>example</applicationdirectory></code>","text":"<p>Sets the suggested name of the application directory when installing it, the path result in <code><path-to-the-core>/example/</code>. If you leave this element out, the app identifier (<code>com.example.foo -> foo</code>) will be used instead.</p>"},{"location":"php/apps/#minimum-required-files","title":"Minimum Required Files","text":"<p>An example project with the source code can be found on GitHub, it includes everything that is required for a basic app.</p>"},{"location":"php/code-style-documentation/","title":"Documentation","text":"<p>The following documentation conventions are used by us for our own packages. While you do not have to follow every rule, you are encouraged to do so.</p>"},{"location":"php/code-style-documentation/#database-objects","title":"Database Objects","text":""},{"location":"php/code-style-documentation/#database-table-columns-as-properties","title":"Database Table Columns as Properties","text":"<p>As the database table columns are not explicit properties of the classes extending <code>wcf\\data\\DatabaseObject</code> but rather stored in <code>DatabaseObject::$data</code> and accessible via <code>DatabaseObject::__get($name)</code>, the IDE we use, PhpStorm, is neither able to autocomplete such property access nor to interfere the type of the property.</p> <p>To solve this problem, <code>@property-read</code> tags must be added to the class documentation which registers the database table columns as public read-only properties:</p> <pre><code> * @property-read propertyType $propertyName property description\n</code></pre> <p>The properties have to be in the same order as the order in the database table.</p> <p>The following table provides templates for common description texts so that similar database table columns have similar description texts.</p> property description template and example unique object id <code>unique id of the {object name}</code>example: <code>unique id of the acl option</code> id of the delivering package <code>id of the package which delivers the {object name}</code>example: <code>id of the package which delivers the acl option</code> show order for nested structure <code>position of the {object name} in relation to its siblings</code>example: <code>position of the ACP menu item in relation to its siblings</code> show order within different object <code>position of the {object name} in relation to the other {object name}s in the {parent object name}</code>example: <code>position of the label in relation to the other labels in the label group</code> required permissions <code>comma separated list of user group permissions of which the active user needs to have at least one to see (access, \u2026) the {object name}</code>example:<code>comma separated list of user group permissions of which the active user needs to have at least one to see the ACP menu item</code> required options <code>comma separated list of options of which at least one needs to be enabled for the {object name} to be shown (accessible, \u2026)</code>example:<code>comma separated list of options of which at least one needs to be enabled for the ACP menu item to be shown</code> id of the user who has created the object <code>id of the user who created (wrote, \u2026) the {object name} (or `null` if the user does not exist anymore (or if the {object name} has been created by a guest))</code>example:<code>id of the user who wrote the comment or `null` if the user does not exist anymore or if the comment has been written by a guest</code> name of the user who has created the object <code>name of the user (or guest) who created (wrote, \u2026) the {object name}</code>example:<code>name of the user or guest who wrote the comment</code> additional data <code>array with additional data of the {object name}</code>example:<code>array with additional data of the user activity event</code> time-related columns <code>timestamp at which the {object name} has been created (written, \u2026)</code>example:<code>timestamp at which the comment has been written</code> boolean options <code>is `1` (or `0`) if the {object name} \u2026 (and thus \u2026), otherwise `0` (or `1`)</code>example:<code>is `1` if the ad is disabled and thus not shown, otherwise `0`</code> <code>$cumulativeLikes</code> <code>cumulative result of likes (counting `+1`) and dislikes (counting `-1`) for the {object name}</code>example:<code>cumulative result of likes (counting `+1`) and dislikes (counting `-1`) for the article</code> <code>$comments</code> <code>number of comments on the {object name}</code>example:<code>number of comments on the article</code> <code>$views</code> <code>number of times the {object name} has been viewed</code>example:<code>number of times the article has been viewed</code> text field with potential language item name as value <code>{text type} of the {object name} or name of language item which contains the {text type}</code>example:<code>description of the cronjob or name of language item which contains the description</code> <code>$objectTypeID</code> <code>id of the `{object type definition name}` object type</code>example:<code>id of the `com.woltlab.wcf.modifiableContent` object type</code>"},{"location":"php/code-style-documentation/#database-object-editors","title":"Database Object Editors","text":""},{"location":"php/code-style-documentation/#class-tags","title":"Class Tags","text":"<p>Any database object editor class comment must have to following tags to properly support autocompletion by IDEs:</p> <pre><code>/**\n * \u2026\n * @method static {DBO class name} create(array $parameters = [])\n * @method {DBO class name} getDecoratedObject()\n * @mixin {DBO class name}\n */\n</code></pre> <p>The only exception to this rule is if the class overwrites the <code>create()</code> method which itself has to be properly documentation then.</p> <p>The first and second line makes sure that when calling the <code>create()</code> or <code>getDecoratedObject()</code> method, the return value is correctly recognized and not just a general <code>DatabaseObject</code> instance. The third line tells the IDE (if <code>@mixin</code> is supported) that the database object editor decorates the database object and therefore offers autocompletion for properties and methods from the database object class itself.</p>"},{"location":"php/code-style-documentation/#runtime-caches","title":"Runtime Caches","text":""},{"location":"php/code-style-documentation/#class-tags_1","title":"Class Tags","text":"<p>Any class implementing the IRuntimeCache interface must have the following class tags:</p> <pre><code>/**\n * \u2026\n * @method {DBO class name}[] getCachedObjects()\n * @method {DBO class name} getObject($objectID)\n * @method {DBO class name}[] getObjects(array $objectIDs)\n */\n</code></pre> <p>These tags ensure that when calling any of the mentioned methods, the return value refers to the concrete database object and not just generically to DatabaseObject.</p>"},{"location":"php/code-style/","title":"Code Style","text":"<p>The following code style conventions are used by us for our own packages. While you do not have to follow every rule, you are encouraged to do so.</p> <p>For information about how to document your code, please refer to the documentation page.</p>"},{"location":"php/code-style/#general-code-style","title":"General Code Style","text":""},{"location":"php/code-style/#naming-conventions","title":"Naming conventions","text":"<p>The relevant naming conventions are:</p> <ul> <li>Upper camel case: The first letters of all compound words are written in upper case.</li> <li>Lower camel case: The first letters of compound words are written in upper case, except for the first letter which is written in lower case.</li> <li>Screaming snake case: All letters are written in upper case and compound words are separated by underscores.</li> </ul> Type Convention Example Variable lower camel case <code>$variableName</code> Class upper camel case <code>class UserGroupEditor</code> Properties lower camel case <code>public $propertyName</code> Method lower camel case <code>public function getObjectByName()</code> Constant screaming snake case <code>MODULE_USER_THING</code>"},{"location":"php/code-style/#arrays","title":"Arrays","text":"<p>For arrays, use the short array syntax introduced with PHP 5.4. The following example illustrates the different cases that can occur when working with arrays and how to format them:</p> <pre><code><?php\n\n$empty = [];\n\n$oneElement = [1];\n$multipleElements = [1, 2, 3];\n\n$oneElementWithKey = ['firstElement' => 1];\n$multipleElementsWithKey = [\n 'firstElement' => 1,\n 'secondElement' => 2,\n 'thirdElement' => 3\n];\n</code></pre>"},{"location":"php/code-style/#ternary-operator","title":"Ternary Operator","text":"<p>The ternary operator can be used for short conditioned assignments:</p> <pre><code><?php\n\n$name = isset($tagArgs['name']) ? $tagArgs['name'] : 'default';\n</code></pre> <p>The condition and the values should be short so that the code does not result in a very long line which thus decreases the readability compared to an <code>if-else</code> statement.</p> <p>Parentheses may only be used around the condition and not around the whole statement:</p> <pre><code><?php\n\n// do not do it like this\n$name = (isset($tagArgs['name']) ? $tagArgs['name'] : 'default');\n</code></pre> <p>Parentheses around the conditions may not be used to wrap simple function calls:</p> <pre><code><?php\n\n// do not do it like this\n$name = (isset($tagArgs['name'])) ? $tagArgs['name'] : 'default';\n</code></pre> <p>but have to be used for comparisons or other binary operators:</p> <pre><code><?php\n\n$value = ($otherValue > $upperLimit) ? $additionalValue : $otherValue;\n</code></pre> <p>If you need to use more than one binary operator, use an <code>if-else</code> statement.</p> <p>The same rules apply to assigning array values:</p> <pre><code><?php\n\n$values = [\n 'first' => $firstValue,\n 'second' => $secondToggle ? $secondValueA : $secondValueB,\n 'third' => ($thirdToogle > 13) ? $thirdToogleA : $thirdToogleB\n];\n</code></pre> <p>or return values:</p> <pre><code><?php\n\nreturn isset($tagArgs['name']) ? $tagArgs['name'] : 'default';\n</code></pre>"},{"location":"php/code-style/#whitespaces","title":"Whitespaces","text":"<p>You have to put a whitespace in front of the following things:</p> <ul> <li>equal sign in assignments: <code>$x = 1;</code></li> <li>comparison operators: <code>$x == 1</code></li> <li>opening bracket of a block <code>public function test() {</code></li> </ul> <p>You have to put a whitespace behind the following things:</p> <ul> <li>equal sign in assignments: <code>$x = 1;</code></li> <li>comparison operators: <code>$x == 1</code></li> <li>comma in a function/method parameter list if the comma is not followed by a line break: <code>public function test($a, $b) {</code></li> <li><code>if</code>, <code>for</code>, <code>foreach</code>, <code>while</code>: <code>if ($x == 1)</code></li> </ul>"},{"location":"php/code-style/#classes","title":"Classes","text":""},{"location":"php/code-style/#referencing-class-names","title":"Referencing Class Names","text":"<p>If you have to reference a class name inside a php file, you have to use the <code>class</code> keyword.</p> <pre><code><?php\n\n// not like this\n$className = 'wcf\\data\\example\\Example';\n\n// like this\nuse wcf\\data\\example\\Example;\n$className = Example::class;\n</code></pre>"},{"location":"php/code-style/#static-getters-of-databaseobject-classes","title":"Static Getters (of <code>DatabaseObject</code> Classes)","text":"<p>Some database objects provide static getters, either if they are decorators or for a unique combination of database table columns, like <code>wcf\\data\\box\\Box::getBoxByIdentifier()</code>:</p> files/lib/data/box/Box.class.php <pre><code><?php\nnamespace wcf\\data\\box;\nuse wcf\\data\\DatabaseObject;\nuse wcf\\system\\WCF;\n\nclass Box extends DatabaseObject {\n /**\n * Returns the box with the given identifier.\n *\n * @param string $identifier\n * @return Box|null\n */\n public static function getBoxByIdentifier($identifier) {\n $sql = \"SELECT *\n FROM wcf1_box\n WHERE identifier = ?\";\n $statement = WCF::getDB()->prepare($sql);\n $statement->execute([$identifier]);\n\n return $statement->fetchObject(self::class);\n }\n}\n</code></pre> <p>Such methods should always either return the desired object or <code>null</code> if the object does not exist. <code>wcf\\system\\database\\statement\\PreparedStatement::fetchObject()</code> already takes care of this distinction so that its return value can simply be returned by such methods.</p> <p>The name of such getters should generally follow the convention <code>get{object type}By{column or other description}</code>.</p>"},{"location":"php/code-style/#long-method-calls","title":"Long method calls","text":"<p>In some instances, methods with many argument have to be called which can result in lines of code like this one:</p> <pre><code><?php\n\n\\wcf\\system\\search\\SearchIndexManager::getInstance()->set('com.woltlab.wcf.article', $articleContent->articleContentID, $articleContent->content, $articleContent->title, $articles[$articleContent->articleID]->time, $articles[$articleContent->articleID]->userID, $articles[$articleContent->articleID]->username, $articleContent->languageID, $articleContent->teaser);\n</code></pre> <p>which is hardly readable. Therefore, the line must be split into multiple lines with each argument in a separate line:</p> <pre><code><?php\n\n\\wcf\\system\\search\\SearchIndexManager::getInstance()->set(\n 'com.woltlab.wcf.article',\n $articleContent->articleContentID,\n $articleContent->content,\n $articleContent->title,\n $articles[$articleContent->articleID]->time,\n $articles[$articleContent->articleID]->userID,\n $articles[$articleContent->articleID]->username,\n $articleContent->languageID,\n $articleContent->teaser\n);\n</code></pre> <p>In general, this rule applies to the following methods:</p> <ul> <li><code>wcf\\system\\edit\\EditHistoryManager::add()</code></li> <li><code>wcf\\system\\message\\quote\\MessageQuoteManager::addQuote()</code></li> <li><code>wcf\\system\\message\\quote\\MessageQuoteManager::getQuoteID()</code></li> <li><code>wcf\\system\\search\\SearchIndexManager::set()</code></li> <li><code>wcf\\system\\user\\object\\watch\\UserObjectWatchHandler::updateObject()</code></li> <li><code>wcf\\system\\user\\notification\\UserNotificationHandler::fireEvent()</code></li> </ul>"},{"location":"php/database-access/","title":"Database Access","text":"<p>Database Objects provide a convenient and object-oriented approach to work with the database, but there can be use-cases that require raw access including writing methods for model classes. This section assumes that you have either used prepared statements before or at least understand how it works.</p>"},{"location":"php/database-access/#the-preparedstatement-object","title":"The PreparedStatement Object","text":"<p>The database access is designed around PreparedStatement, built on top of PHP's <code>PDOStatement</code> so that you call all of <code>PDOStatement</code>'s methods, and each query requires you to obtain a statement object.</p> <pre><code><?php\n$statement = \\wcf\\system\\WCF::getDB()->prepare(\"SELECT * FROM wcf1_example\");\n$statement->execute();\nwhile ($row = $statement->fetchArray()) {\n // handle result\n}\n</code></pre>"},{"location":"php/database-access/#query-parameters","title":"Query Parameters","text":"<p>The example below illustrates the usage of parameters where each value is replaced with the generic <code>?</code>-placeholder. Values are provided by calling <code>$statement->execute()</code> with a continuous, one-dimensional array that exactly match the number of question marks.</p> <pre><code><?php\n$sql = \"SELECT *\n FROM wcf1_example\n WHERE exampleID = ?\n OR bar IN (?, ?, ?, ?, ?)\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute([\n $exampleID,\n $list, $of, $values, $for, $bar\n]);\nwhile ($row = $statement->fetchArray()) {\n // handle result\n}\n</code></pre>"},{"location":"php/database-access/#fetching-a-single-result","title":"Fetching a Single Result","text":"<p>Do not attempt to use <code>fetchSingleRow()</code> or <code>fetchSingleColumn()</code> if the result contains more than one row.</p> <p>You can opt-in to retrieve only a single row from database and make use of shortcut methods to reduce the code that you have to write.</p> <pre><code><?php\n$sql = \"SELECT *\n FROM wcf1_example\n WHERE exampleID = ?\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql, 1);\n$statement->execute([$exampleID]);\n$row = $statement->fetchSingleRow();\n</code></pre> <p>There are two distinct differences when comparing with the example on query parameters above:</p> <ol> <li>The method <code>prepare()</code> receives a secondary parameter that will be appended to the query as <code>LIMIT 1</code>.</li> <li>Data is read using <code>fetchSingleRow()</code> instead of <code>fetchArray()</code> or similar methods, that will read one result and close the cursor.</li> </ol>"},{"location":"php/database-access/#fetch-by-column","title":"Fetch by Column","text":"<p>There is no way to return another column from the same row if you use <code>fetchColumn()</code> to retrieve data.</p> <p>Fetching an array is only useful if there is going to be more than one column per result row, otherwise accessing the column directly is much more convenient and increases the code readability.</p> <pre><code><?php\n$sql = \"SELECT bar\n FROM wcf1_example\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\nwhile ($bar = $statement->fetchColumn()) {\n // handle result\n}\n$bar = $statement->fetchSingleColumn();\n</code></pre> <p>Similar to fetching a single row, you can also issue a query that will select a single row, but reads only one column from the result row.</p> <pre><code><?php\n$sql = \"SELECT bar\n FROM wcf1_example\n WHERE exampleID = ?\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql, 1);\n$statement->execute([$exampleID]);\n$bar = $statement->fetchSingleColumn();\n</code></pre>"},{"location":"php/database-access/#fetching-all-results","title":"Fetching All Results","text":"<p>If you want to fetch all results of a query but only store them in an array without directly processing them, in most cases, you can rely on built-in methods.</p> <p>To fetch all rows of query, you can use <code>PDOStatement::fetchAll()</code> with <code>\\PDO::FETCH_ASSOC</code> as the first parameter:</p> <pre><code><?php\n$sql = \"SELECT *\n FROM wcf1_example\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$rows = $statement->fetchAll(\\PDO::FETCH_ASSOC);\n</code></pre> <p>As a result, you get an array containing associative arrays with the rows of the <code>wcf{WCF_N}_example</code> database table as content.</p> <p>If you only want to fetch a list of the values of a certain column, you can use <code>\\PDO::FETCH_COLUMN</code> as the first parameter:</p> <pre><code><?php\n$sql = \"SELECT exampleID\n FROM wcf1_example\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$exampleIDs = $statement->fetchAll(\\PDO::FETCH_COLUMN);\n</code></pre> <p>As a result, you get an array with all <code>exampleID</code> values.</p> <p>The <code>PreparedStatement</code> class adds an additional methods that covers another common use case in our code: Fetching two columns and using the first column's value as the array key and the second column's value as the array value. This case is covered by <code>PreparedStatement::fetchMap()</code>:</p> <pre><code><?php\n$sql = \"SELECT exampleID, userID\n FROM wcf1_example_mapping\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$map = $statement->fetchMap('exampleID', 'userID');\n</code></pre> <p><code>$map</code> is a one-dimensional array where each <code>exampleID</code> value maps to the corresponding <code>userID</code> value.</p> <p>If there are multiple entries for a certain <code>exampleID</code> value with different <code>userID</code> values, the existing entry in the array will be overwritten and contain the last read value from the database table. Therefore, this method should generally only be used for unique combinations.</p> <p>If you do not have a combination of columns with unique pairs of values, but you want to get a list of <code>userID</code> values with the same <code>exampleID</code>, you can set the third parameter of <code>fetchMap()</code> to <code>false</code> and get a list:</p> <pre><code><?php\n$sql = \"SELECT exampleID, userID\n FROM wcf1_example_mapping\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n$statement->execute();\n$map = $statement->fetchMap('exampleID', 'userID', false);\n</code></pre> <p>Now, as a result, you get a two-dimensional array with the array keys being the <code>exampleID</code> values and the array values being arrays with all <code>userID</code> values from rows with the respective <code>exampleID</code> value.</p>"},{"location":"php/database-access/#building-complex-conditions","title":"Building Complex Conditions","text":"<p>Building conditional conditions can turn out to be a real mess and it gets even worse with SQL's <code>IN (\u2026)</code> which requires as many placeholders as there will be values. The solutions is <code>PreparedStatementConditionBuilder</code>, a simple but useful helper class with a bulky name, it is also the class used when accessing <code>DatabaseObjecList::getConditionBuilder()</code>.</p> <pre><code><?php\n$conditions = new \\wcf\\system\\database\\util\\PreparedStatementConditionBuilder();\n$conditions->add(\"exampleID = ?\", [$exampleID]);\nif (!empty($valuesForBar)) {\n $conditions->add(\"(bar IN (?) OR baz = ?)\", [$valuesForBar, $baz]);\n}\n</code></pre> <p>The <code>IN (?)</code> in the example above is automatically expanded to match the number of items contained in <code>$valuesForBar</code>. Be aware that the method will generate an invalid query if <code>$valuesForBar</code> is empty!</p>"},{"location":"php/database-access/#insert-or-update-in-bulk","title":"INSERT or UPDATE in Bulk","text":"<p>Prepared statements not only protect against SQL injection by separating the logical query and the actual data, but also provides the ability to reuse the same query with different values. This leads to a performance improvement as the code does not have to transmit the query with for every data set and only has to parse and analyze the query once.</p> <pre><code><?php\n$data = ['abc', 'def', 'ghi'];\n\n$sql = \"INSERT INTO wcf1_example\n (bar)\n VALUES (?)\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n\n\\wcf\\system\\WCF::getDB()->beginTransaction();\nforeach ($data as $bar) {\n $statement->execute([$bar]);\n}\n\\wcf\\system\\WCF::getDB()->commitTransaction();\n</code></pre> <p>It is generally advised to wrap bulk operations in a transaction as it allows the database to optimize the process, including fewer I/O operations.</p> <pre><code><?php\n$data = [\n 1 => 'abc',\n 3 => 'def',\n 4 => 'ghi'\n];\n\n$sql = \"UPDATE wcf1_example\n SET bar = ?\n WHERE exampleID = ?\";\n$statement = \\wcf\\system\\WCF::getDB()->prepare($sql);\n\n\\wcf\\system\\WCF::getDB()->beginTransaction();\nforeach ($data as $exampleID => $bar) {\n $statement->execute([\n $bar,\n $exampleID\n ]);\n}\n\\wcf\\system\\WCF::getDB()->commitTransaction();\n</code></pre>"},{"location":"php/database-objects/","title":"Database Objects","text":"<p>WoltLab Suite uses a unified interface to work with database rows using an object based approach instead of using native arrays holding arbitrary data. Each database table is mapped to a model class that is designed to hold a single record from that table and expose methods to work with the stored data, for example providing assistance when working with normalized datasets.</p> <p>Developers are required to provide the proper DatabaseObject implementations themselves, they're not automatically generated, all though the actual code that needs to be written is rather small. The following examples assume the fictional database table <code>wcf1_example</code>, <code>exampleID</code> as the auto-incrementing primary key and the column <code>bar</code> to store some text.</p>"},{"location":"php/database-objects/#databaseobject","title":"DatabaseObject","text":"<p>The basic model derives from <code>wcf\\data\\DatabaseObject</code> and provides a convenient constructor to fetch a single row or construct an instance using pre-loaded rows.</p> files/lib/data/example/Example.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObject;\n\nclass Example extends DatabaseObject {}\n</code></pre> <p>The class is intended to be empty by default and there only needs to be code if you want to add additional logic to your model. Both the class name and primary key are determined by <code>DatabaseObject</code> using the namespace and class name of the derived class. The example above uses the namespace <code>wcf\\\u2026</code> which is used as table prefix and the class name <code>Example</code> is converted into <code>exampleID</code>, resulting in the database table name <code>wcfN_example</code> with the primary key <code>exampleID</code>.</p> <p>You can prevent this automatic guessing by setting the class properties <code>$databaseTableName</code> and <code>$databaseTableIndexName</code> manually.</p>"},{"location":"php/database-objects/#databaseobjectdecorator","title":"DatabaseObjectDecorator","text":"<p>If you already have a <code>DatabaseObject</code> class and would like to extend it with additional data or methods, for example by providing a class <code>ViewableExample</code> which features view-related changes without polluting the original object, you can use <code>DatabaseObjectDecorator</code> which a default implementation of a decorator for database objects.</p> files/lib/data/example/ViewableExample.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObjectDecorator;\n\nclass ViewableExample extends DatabaseObjectDecorator {\n protected static $baseClass = Example::class;\n\n public function getOutput() {\n $output = '';\n\n // [determine output]\n\n return $output;\n }\n}\n</code></pre> <p>It is mandatory to set the static <code>$baseClass</code> property to the name of the decorated class.</p> <p>Like for any decorator, you can directly access the decorated object's properties and methods for a decorated object by accessing the property or calling the method on the decorated object. You can access the decorated objects directly via <code>DatabaseObjectDecorator::getDecoratedObject()</code>.</p>"},{"location":"php/database-objects/#databaseobjecteditor","title":"DatabaseObjectEditor","text":"<p>This is the low-level interface to manipulate data rows, it is recommended to use <code>AbstractDatabaseObjectAction</code>.</p> <p>Adding, editing and deleting models is done using the <code>DatabaseObjectEditor</code> class that decorates a <code>DatabaseObject</code> and uses its data to perform the actions.</p> files/lib/data/example/ExampleEditor.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObjectEditor;\n\nclass ExampleEditor extends DatabaseObjectEditor {\n protected static $baseClass = Example::class;\n}\n</code></pre> <p>The editor class requires you to provide the fully qualified name of the model, that is the class name including the complete namespace. Database table name and index key will be pulled directly from the model.</p>"},{"location":"php/database-objects/#create-a-new-row","title":"Create a new row","text":"<p>Inserting a new row into the database table is provided through <code>DatabaseObjectEditor::create()</code> which yields a <code>DatabaseObject</code> instance after creation.</p> <pre><code><?php\n$example = \\wcf\\data\\example\\ExampleEditor::create([\n 'bar' => 'Hello World!'\n]);\n\n// output: Hello World!\necho $example->bar;\n</code></pre>"},{"location":"php/database-objects/#updating-an-existing-row","title":"Updating an existing row","text":"<p>The internal state of the decorated <code>DatabaseObject</code> is not altered at any point, the values will still be the same after editing or deleting the represented row. If you need an object with the latest data, you'll have to discard the current object and refetch the data from database.</p> <pre><code><?php\n$example = new \\wcf\\data\\example\\Example($id);\n$exampleEditor = new \\wcf\\data\\example\\ExampleEditor($example);\n$exampleEditor->update([\n 'bar' => 'baz'\n]);\n\n// output: Hello World!\necho $example->bar;\n\n// re-creating the object will query the database again and retrieve the updated value\n$example = new \\wcf\\data\\example\\Example($example->id);\n\n// output: baz\necho $example->bar;\n</code></pre>"},{"location":"php/database-objects/#deleting-a-row","title":"Deleting a row","text":"<p>Similar to the update process, the decorated <code>DatabaseObject</code> is not altered and will then point to an inexistent row.</p> <pre><code><?php\n$example = new \\wcf\\data\\example\\Example($id);\n$exampleEditor = new \\wcf\\data\\example\\ExampleEditor($example);\n$exampleEditor->delete();\n</code></pre>"},{"location":"php/database-objects/#databaseobjectlist","title":"DatabaseObjectList","text":"<p>Every row is represented as a single instance of the model, but the instance creation deals with single rows only. Retrieving larger sets of rows would be quite inefficient due to the large amount of queries that will be dispatched. This is solved with the <code>DatabaseObjectList</code> object that exposes an interface to query the database table using arbitrary conditions for data selection. All rows will be fetched using a single query and the resulting rows are automatically loaded into separate models.</p> files/lib/data/example/ExampleList.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\DatabaseObjectList;\n\nclass ExampleList extends DatabaseObjectList {\n public $className = Example::class;\n}\n</code></pre> <p>The following code listing illustrates loading a large set of examples and iterating over the list to retrieve the objects.</p> <pre><code><?php\n$exampleList = new \\wcf\\data\\example\\ExampleList();\n// add constraints using the condition builder\n$exampleList->getConditionBuilder()->add('bar IN (?)', [['Hello World!', 'bar', 'baz']]);\n// actually read the rows\n$exampleList->readObjects();\nforeach ($exampleList as $example) {\n echo $example->bar;\n}\n\n// retrieve the models directly instead of iterating over them\n$examples = $exampleList->getObjects();\n\n// just retrieve the number of rows\n$exampleCount = $exampleList->countObjects();\n</code></pre> <p><code>DatabaseObjectList</code> implements both SeekableIterator and Countable.</p> <p>Additionally, <code>DatabaseObjectList</code> objects has the following three public properties that are useful when fetching data with lists:</p> <ul> <li><code>$sqlLimit</code> determines how many rows are fetched. If its value is <code>0</code> (which is the default value), all results are fetched. So be careful when dealing with large tables and you only want a limited number of rows: Set <code>$sqlLimit</code> to a value larger than zero!</li> <li><code>$sqlOffset</code>: Paginated pages like a thread list use this feature a lot, it allows you to skip a given number of results. Imagine you want to display 20 threads per page but there are a total of 60 threads available. In this case you would specify <code>$sqlLimit = 20</code> and <code>$sqlOffset = 20</code> which will skip the first 20 threads, effectively displaying thread 21 to 40.</li> <li><code>$sqlOrderBy</code> determines by which column(s) the rows are sorted in which order. Using our example in <code>$sqlOffset</code> you might want to display the 20 most recent threads on page 1, thus you should specify the order field and its direction, e.g. <code>$sqlOrderBy = 'thread.lastPostTime DESC'</code> which returns the most recent thread first.</li> </ul> <p>For more advanced usage, there two additional fields that deal with the type of objects returned. First, let's go into a bit more detail what setting the <code>$className</code> property actually does:</p> <ol> <li>It is the type of database object in which the rows are wrapped.</li> <li>It determines which database table is actually queried and which index is used (see the <code>$databaseTableName</code> and <code>$databaseTableIndexName</code> properties of <code>DatabaseObject</code>).</li> </ol> <p>Sometimes you might use the database table of some database object but wrap the rows in another database object. This can be achieved by setting the <code>$objectClassName</code> property to the desired class name.</p> <p>In other cases, you might want to wrap the created objects in a database object decorator which can be done by setting the <code>$decoratorClassName</code> property to the desired class name:</p> <pre><code><?php\n$exampleList = new \\wcf\\data\\example\\ExampleList();\n$exampleList->decoratorClassName = \\wcf\\data\\example\\ViewableExample::class;\n</code></pre> <p>Of course, you do not have to set the property after creating the list object, you can also set it by creating a dedicated class:</p> files/lib/data/example/ViewableExampleList.class.php <pre><code><?php\nnamespace wcf\\data\\example;\n\nclass ViewableExampleList extends ExampleList {\n public $decoratorClassName = ViewableExample::class;\n}\n</code></pre>"},{"location":"php/database-objects/#abstractdatabaseobjectaction","title":"AbstractDatabaseObjectAction","text":"<p>Row creation and manipulation can be performed using the aforementioned <code>DatabaseObjectEditor</code> class, but this approach has two major issues:</p> <ol> <li>Row creation, update and deletion takes place silently without notifying any other components.</li> <li>Data is passed to the database adapter without any further processing.</li> </ol> <p>The <code>AbstractDatabaseObjectAction</code> solves both problems by wrapping around the editor class and thus provide an additional layer between the action that should be taken and the actual process. The first problem is solved by a fixed set of events being fired, the second issue is addressed by having a single entry point for all data editing.</p> files/lib/data/example/ExampleAction.class.php <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\AbstractDatabaseObjectAction;\n\nclass ExampleAction extends AbstractDatabaseObjectAction {\n public $className = ExampleEditor::class;\n}\n</code></pre>"},{"location":"php/database-objects/#executing-an-action","title":"Executing an Action","text":"<p>The method <code>AbstractDatabaseObjectAction::validateAction()</code> is internally used for AJAX method invocation and must not be called programmatically.</p> <p>The next example represents the same functionality as seen for <code>DatabaseObjectEditor</code>:</p> <pre><code><?php\nuse wcf\\data\\example\\ExampleAction;\n\n// create a row\n$exampleAction = new ExampleAction([], 'create', [\n 'data' => ['bar' => 'Hello World']\n]);\n$example = $exampleAction->executeAction()['returnValues'];\n\n// update a row using the id\n$exampleAction = new ExampleAction([1], 'update', [\n 'data' => ['bar' => 'baz']\n]);\n$exampleAction->executeAction();\n\n// delete a row using a model\n$exampleAction = new ExampleAction([$example], 'delete');\n$exampleAction->executeAction();\n</code></pre> <p>You can access the return values both by storing the return value of <code>executeAction()</code> or by retrieving it via <code>getReturnValues()</code>.</p> <p>Events <code>initializeAction</code>, <code>validateAction</code> and <code>finalizeAction</code></p>"},{"location":"php/database-objects/#custom-method-with-ajax-support","title":"Custom Method with AJAX Support","text":"<p>The AJAX interface of database object actions is considered soft-deprecated in WoltLab Suite 6.0. Instead a dedicated PSR-15 controller should be used. Please refer to the migration guide.</p> <p>This section is about adding the method <code>baz()</code> to <code>ExampleAction</code> and calling it via AJAX.</p>"},{"location":"php/database-objects/#ajax-validation","title":"AJAX Validation","text":"<p>Methods of an action cannot be called via AJAX, unless they have a validation method. This means that <code>ExampleAction</code> must define both a <code>public function baz()</code> and <code>public function validateBaz()</code>, the name for the validation method is constructed by upper-casing the first character of the method name and prepending <code>validate</code>.</p> <p>The lack of the companion <code>validate*</code> method will cause the AJAX proxy to deny the request instantaneously. Do not add a validation method if you don't want it to be callable via AJAX ever!</p>"},{"location":"php/database-objects/#create-update-and-delete","title":"create, update and delete","text":"<p>The methods <code>create</code>, <code>update</code> and <code>delete</code> are available for all classes deriving from <code>AbstractDatabaseObjectAction</code> and directly pass the input data to the <code>DatabaseObjectEditor</code>. These methods deny access to them via AJAX by default, unless you explicitly enable access. Depending on your case, there are two different strategies to enable AJAX access to them.</p> <pre><code><?php\nnamespace wcf\\data\\example;\nuse wcf\\data\\AbstractDatabaseObjectAction;\n\nclass ExampleAction extends AbstractDatabaseObjectAction {\n // `create()` can now be called via AJAX if the requesting user posses the listed permissions\n protected $permissionsCreate = ['admin.example.canManageExample'];\n\n public function validateUpdate() {\n // your very own validation logic that does not make use of the\n // built-in `$permissionsUpdate` property\n\n // you can still invoke the built-in permissions check if you like to\n parent::validateUpdate();\n }\n}\n</code></pre>"},{"location":"php/database-objects/#allow-invokation-by-guests","title":"Allow Invokation by Guests","text":"<p>Invoking methods is restricted to logged-in users by default and the only way to override this behavior is to alter the property <code>$allowGuestAccess</code>. It is a simple string array that is expected to hold all methods that should be accessible by users, excluding their companion validation methods.</p>"},{"location":"php/database-objects/#acp-access-only","title":"ACP Access Only","text":"<p>Method access is usually limited by permissions, but sometimes there might be the need for some added security to avoid mistakes. The <code>$requireACP</code> property works similar to <code>$allowGuestAccess</code>, but enforces the request to originate from the ACP together with a valid ACP session, ensuring that only users able to access the ACP can actually invoke these methods.</p>"},{"location":"php/exceptions/","title":"Exceptions","text":""},{"location":"php/exceptions/#spl-exceptions","title":"SPL Exceptions","text":"<p>The Standard PHP Library (SPL) provides some exceptions that should be used whenever possible.</p>"},{"location":"php/exceptions/#custom-exceptions","title":"Custom Exceptions","text":"<p>Do not use <code>wcf\\system\\exception\\SystemException</code> anymore, use specific exception classes!</p> <p>The following table contains a list of custom exceptions that are commonly used. All of the exceptions are found in the <code>wcf\\system\\exception</code> namespace.</p> Class name (examples) when to use <code>IllegalLinkException</code> access to a page that belongs to a non-existing object, executing actions on specific non-existing objects (is shown as http 404 error to the user) <code>ImplementationException</code> a class does not implement an expected interface <code>InvalidObjectArgument</code> 5.4+ API method support generic objects but specific implementation requires objects of specific (sub)class and different object is given <code>InvalidObjectTypeException</code> object type is not of an expected object type definition <code>InvalidSecurityTokenException</code> given security token does not match the security token of the active user's session <code>ParentClassException</code> a class does not extend an expected (parent) class <code>PermissionDeniedException</code> page access without permission, action execution without permission (is shown as http 403 error to the user) <code>UserInputException</code> user input does not pass validation"},{"location":"php/exceptions/#sensitive-arguments-in-stack-traces","title":"Sensitive Arguments in Stack Traces","text":"<p>Sometimes sensitive values are passed as a function or method argument. If the callee throws an Exception, these values will be part of the Exception\u2019s stack trace and logged, unless the Exception is caught and ignored.</p> <p>WoltLab Suite will automatically suppress the values of parameters named like they might contain sensitive values, namely arguments matching the regular expression <code>/(?:^(?:password|passphrase|secret)|(?:Password|Passphrase|Secret))/</code>.</p> <p>If you need to suppress additional arguments from appearing in the stack trace, you can add the <code>\\wcf\\SensitiveArgument</code> attribute to such parameters. Arguments are only supported as of PHP 8 and ignored as comments in lower PHP versions. In PHP 7, such arguments will not be suppressed, but the code will continue to work. Make sure to insert a linebreak between the attribute and the parameter name.</p> <p>Example:</p> wcfsetup/install/files/lib/data/user/User.class.php<pre><code><?php\n\nnamespace wcf\\data\\user;\n\n// \u2026\n\nfinal class User extends DatabaseObject implements IPopoverObject, IRouteController, IUserContent\n{\n // \u2026\n\n public function checkPassword(\n #[\\wcf\\SensitiveArgument()]\n $password\n ) {\n // \u2026\n }\n\n // \u2026\n}\n</code></pre>"},{"location":"php/gdpr/","title":"General Data Protection Regulation (GDPR)","text":""},{"location":"php/gdpr/#introduction","title":"Introduction","text":"<p>The General Data Protection Regulation (GDPR) of the European Union enters into force on May 25, 2018. It comes with a set of restrictions when handling users' personal data as well as to provide an interface to export this data on demand.</p> <p>If you're looking for a guide on the implications of the GDPR and what you will need or consider to do, please read the article Implementation of the GDPR on woltlab.com.</p>"},{"location":"php/gdpr/#including-data-in-the-export","title":"Including Data in the Export","text":"<p>The <code>wcf\\acp\\action\\UserExportGdprAction</code> already includes WoltLab Suite Core itself as well as all official apps, but you'll need to include any personal data stored for your plugin or app by yourself.</p> <p>The event <code>export</code> is fired before any data is sent out, but after any Core data has been dumped to the <code>$data</code> property.</p>"},{"location":"php/gdpr/#example-code","title":"Example code","text":"files/lib/system/event/listener/MyUserExportGdprActionListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\nuse wcf\\acp\\action\\UserExportGdprAction;\nuse wcf\\data\\user\\UserProfile;\n\nclass MyUserExportGdprActionListener implements IParameterizedEventListener {\n public function execute(/** @var UserExportGdprAction $eventObj */$eventObj, $className, $eventName, array &$parameters) {\n /** @var UserProfile $user */\n $user = $eventObj->user;\n\n $eventObj->data['my.fancy.plugin'] = [\n 'superPersonalData' => \"This text is super personal and should be included in the output\",\n 'weirdIpAddresses' => $eventObj->exportIpAddresses('app'.WCF_N.'_non_standard_column_names_for_ip_addresses', 'ipAddressColumnName', 'timeColumnName', 'userIDColumnName')\n ];\n $eventObj->exportUserProperties[] = 'shouldAlwaysExportThisField';\n $eventObj->exportUserPropertiesIfNotEmpty[] = 'myFancyField';\n $eventObj->exportUserOptionSettings[] = 'thisSettingIsAlwaysExported';\n $eventObj->exportUserOptionSettingsIfNotEmpty[] = 'someSettingContainingPersonalData';\n $eventObj->ipAddresses['my.fancy.plugin'] = ['wcf'.WCF_N.'_my_fancy_table', 'wcf'.WCF_N.'_i_also_store_ipaddresses_here'];\n $eventObj->skipUserOptions[] = 'thisLooksLikePersonalDataButItIsNot';\n $eventObj->skipUserOptions[] = 'thisIsAlsoNotPersonalDataPleaseIgnoreIt';\n }\n}\n</code></pre>"},{"location":"php/gdpr/#data","title":"<code>$data</code>","text":"<p>Contains the entire data that will be included in the exported JSON file, some fields may already exist (such as <code>'com.woltlab.wcf'</code>) and while you may add or edit any fields within, you should restrict yourself to only append data from your plugin or app.</p>"},{"location":"php/gdpr/#exportuserproperties","title":"<code>$exportUserProperties</code>","text":"<p>Only a whitelist of columns in <code>wcfN_user</code> is exported by default, if your plugin or app adds one or more columns to this table that do hold personal data, then you will have to append it to this array. The listed properties will always be included regardless of their content.</p>"},{"location":"php/gdpr/#exportuserpropertiesifnotempty","title":"<code>$exportUserPropertiesIfNotEmpty</code>","text":"<p>Only a whitelist of columns in <code>wcfN_user</code> is exported by default, if your plugin or app adds one or more columns to this table that do hold personal data, then you will have to append it to this array. Empty values will not be added to the output.</p>"},{"location":"php/gdpr/#exportuseroptionsettings","title":"<code>$exportUserOptionSettings</code>","text":"<p>Any user option that exists within a <code>settings.*</code> category is automatically excluded from the export, with the notable exception of the <code>timezone</code> option. You can opt-in to include your setting by appending to this array, if it contains any personal data. The listed settings are always included regardless of their content.</p>"},{"location":"php/gdpr/#exportuseroptionsettingsifnotempty","title":"<code>$exportUserOptionSettingsIfNotEmpty</code>","text":"<p>Any user option that exists within a <code>settings.*</code> category is automatically excluded from the export, with the notable exception of the <code>timezone</code> option. You can opt-in to include your setting by appending to this array, if it contains any personal data.</p>"},{"location":"php/gdpr/#ipaddresses","title":"<code>$ipAddresses</code>","text":"<p>List of database table names per package identifier that contain ip addresses. The contained ip addresses will be exported when the ip logging module is enabled.</p> <p>It expects the database table to use the column names <code>ipAddress</code>, <code>time</code> and <code>userID</code>. If your table does not match this pattern for whatever reason, you'll need to manually probe for <code>LOG_IP_ADDRESS</code> and then call <code>exportIpAddresses()</code> to retrieve the list. Afterwards you are responsible to append these ip addresses to the <code>$data</code> array to have it exported.</p>"},{"location":"php/gdpr/#skipuseroptions","title":"<code>$skipUserOptions</code>","text":"<p>All user options are included in the export by default, unless they start with <code>can*</code> or <code>admin*</code>, or are blacklisted using this array. You should append any of your plugin's or app's user option that should not be exported, for example because it does not contain personal data, such as internal data.</p>"},{"location":"php/pages/","title":"Page Types","text":""},{"location":"php/pages/#abstractpage","title":"AbstractPage","text":"<p>The default implementation for pages to present any sort of content, but are designed to handle <code>GET</code> requests only. They usually follow a fixed method chain that will be invoked one after another, adding logical sections to the request flow.</p>"},{"location":"php/pages/#method-chain","title":"Method Chain","text":""},{"location":"php/pages/#__run","title":"__run()","text":"<p>This is the only method being invoked from the outside and starts the whole chain.</p>"},{"location":"php/pages/#readparameters","title":"readParameters()","text":"<p>Reads and sanitizes request parameters, this should be the only method to ever read user-supplied input. Read data should be stored in class properties to be accessible at a later point, allowing your code to safely assume that the data has been sanitized and is safe to work with.</p> <p>A typical example is the board page from the forum app that reads the id and attempts to identify the request forum.</p> <pre><code>public function readParameters() {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) $this->boardID = intval($_REQUEST['id']);\n $this->board = BoardCache::getInstance()->getBoard($this->boardID);\n if ($this->board === null) {\n throw new IllegalLinkException();\n }\n\n // check permissions\n if (!$this->board->canEnter()) {\n throw new PermissionDeniedException();\n }\n}\n</code></pre> <p>Events <code>readParameters</code></p>"},{"location":"php/pages/#show","title":"show()","text":"<p>Used to be the method of choice to handle permissions and module option checks, but has been used almost entirely as an internal method since the introduction of the properties <code>$loginRequired</code>, <code>$neededModules</code> and <code>$neededPermissions</code>.</p> <p>Events <code>checkModules</code>, <code>checkPermissions</code> and <code>show</code></p>"},{"location":"php/pages/#readdata","title":"readData()","text":"<p>Central method for data retrieval based on class properties including those populated with user data in <code>readParameters()</code>. It is strongly recommended to use this method to read data in order to properly separate the business logic present in your class.</p> <p>Events <code>readData</code></p>"},{"location":"php/pages/#assignvariables","title":"assignVariables()","text":"<p>Last method call before the template engine kicks in and renders the template. All though some properties are bound to the template automatically, you still need to pass any custom variables and class properties to the engine to make them available in templates.</p> <p>Following the example in <code>readParameters()</code>, the code below adds the board data to the template.</p> <pre><code>public function assignVariables() {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'board' => $this->board,\n 'boardID' => $this->boardID\n ]);\n}\n</code></pre> <p>Events <code>assignVariables</code></p>"},{"location":"php/pages/#abstractform","title":"AbstractForm","text":"<p>Extends the AbstractPage implementation with additional methods designed to handle form submissions properly.</p>"},{"location":"php/pages/#method-chain_1","title":"Method Chain","text":""},{"location":"php/pages/#__run_1","title":"__run()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#readparameters_1","title":"readParameters()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#show_1","title":"show()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#submit","title":"submit()","text":"<p>The methods <code>submit()</code> up until <code>save()</code> are only invoked if either <code>$_POST</code> or <code>$_FILES</code> are not empty, otherwise they won't be invoked and the execution will continue with <code>readData()</code>.</p> <p>This is an internal method that is responsible of input processing and validation.</p> <p>Events <code>submit</code></p>"},{"location":"php/pages/#readformparameters","title":"readFormParameters()","text":"<p>This method is quite similar to <code>readParameters()</code> that is being called earlier, but is designed around reading form data submitted through POST requests. You should avoid accessing <code>$_GET</code> or <code>$_REQUEST</code> in this context to avoid mixing up parameters evaluated when retrieving the page on first load and when submitting to it.</p> <p>Events <code>readFormParameters</code></p>"},{"location":"php/pages/#validate","title":"validate()","text":"<p>Deals with input validation and automatically catches exceptions deriving from <code>wcf\\system\\exception\\UserInputException</code>, resulting in a clean and consistent error handling for the user.</p> <p>Events <code>validate</code></p>"},{"location":"php/pages/#save","title":"save()","text":"<p>Saves the processed data to database or any other source of your choice. Please keep in mind to invoke <code>$this->saved()</code> before resetting the form data.</p> <p>Events <code>save</code></p>"},{"location":"php/pages/#saved","title":"saved()","text":"<p>This method is not called automatically and must be invoked manually by executing <code>$this->saved()</code> inside <code>save()</code>.</p> <p>The only purpose of this method is to fire the event <code>saved</code> that signals that the form data has been processed successfully and data has been saved. It is somewhat special as it is dispatched after the data has been saved, but before the data is purged during form reset. This is by default the last event that has access to the processed data.</p> <p>Events <code>saved</code></p>"},{"location":"php/pages/#readdata_1","title":"readData()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/pages/#assignvariables_1","title":"assignVariables()","text":"<p>Inherited from AbstractPage.</p>"},{"location":"php/api/acp_dashboard_boxes/","title":"ACP Dashboard Boxes","text":"<p>ACP Dashboard Boxes are displayed on the landing page of the admin panel and can provide the user with useful information. A box consists of an internal identifier, a name and the content of the box. The content can contain HTML code.</p>"},{"location":"php/api/acp_dashboard_boxes/#create-a-custom-box","title":"Create a Custom Box","text":"<p>A custom box can be created with a custom PHP class that needs to implement the <code>wcf\\system\\acp\\dashboard\\box\\IAcpDashboardBox</code> interface. It is recommended to extend the class <code>wcf\\system\\acp\\dashboard\\box\\AbstractAcpDashboardBox</code>, which already provides a basic implementation of the interface.</p> <p>Example:</p> <pre><code><?php\nnamespace wcf\\system\\acp\\dashboard\\box;\n\nfinal class FooBox extends AbstractAcpDashboardBox {\n public function getTitle(): string\n {\n return 'title of the box';\n }\n\n public function getContent(): string\n {\n return 'content of the box';\n }\n\n public function getName(): string\n {\n return 'com.foo.bar'; // identifier of the box; must be unique\n }\n}\n</code></pre>"},{"location":"php/api/acp_dashboard_boxes/#register-a-custom-box","title":"Register a Custom Box","text":"<p>You can attach an event listener to the <code>wcf\\event\\acp\\dashboard\\box\\BoxCollecting</code> event inside a bootstrap script to lazily register custom boxes. The class name of the box is registered using the event\u2019s <code>register()</code> method:</p> files/lib/bootstrap/com.example.bar.php<pre><code><?php\n\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\event\\acp\\dashboard\\box\\BoxCollecting;\n\nreturn static function (): void {\n $eventHandler = EventHandler::getInstance();\n\n $eventHandler->register(BoxCollecting::class, static function (BoxCollecting $event) {\n $event->register(\\wcf\\system\\acp\\dashboard\\box\\FooBox::class);\n });\n};\n</code></pre>"},{"location":"php/api/caches/","title":"Caches","text":"<p>WoltLab Suite offers two distinct types of caches:</p> <ol> <li>Persistent caches created by cache builders whose data can be stored using different cache sources.</li> <li>Runtime caches store objects for the duration of a single request.</li> </ol>"},{"location":"php/api/caches/#understanding-caching","title":"Understanding Caching","text":"<p>Every so often, plugins make use of cache builders or runtime caches to store their data, even if there is absolutely no need for them to do so. Usually, this involves a strong opinion about the total number of SQL queries on a page, including but not limited to some magic treshold numbers, which should not be exceeded for \"performance reasons\".</p> <p>This misconception can easily lead into thinking that SQL queries should be avoided or at least written to a cache, so that it doesn't need to be executed so often. Unfortunately, this completely ignores the fact that both a single query can take down your app (e. g. full table scan on millions of rows), but 10 queries using a primary key on a table with a few hundred rows will not slow down your page.</p> <p>There are some queries that should go into caches by design, but most of the cache builders weren't initially there, but instead have been added because they were required to reduce the load significantly. You need to understand that caches always come at a cost, even a runtime cache does! In particular, they will always consume memory that is not released over the duration of the request lifecycle and potentially even leak memory by holding references to objects and data structures that are no longer required.</p> <p>Caching should always be a solution for a problem.</p>"},{"location":"php/api/caches/#when-to-use-a-cache","title":"When to Use a Cache","text":"<p>It's difficult to provide a definite answer or checklist when to use a cache and why it is required at this point, because the answer is: It depends. The permission cache for user groups is a good example for a valid cache, where we can achieve significant performance improvement compared to processing this data on every request.</p> <p>Its caches are build for each permutation of user group memberships that are encountered for a page request. Building this data is an expensive process that involves both inheritance and specific rules in regards to when a value for a permission overrules another value. The added benefit of this cache is that one cache usually serves a large number of users with the same group memberships and by computing these permissions once, we can serve many different requests. Also, the permissions are rather static values that change very rarely and thus we can expect a very high cache lifetime before it gets rebuild.</p>"},{"location":"php/api/caches/#when-not-to-use-a-cache","title":"When not to Use a Cache","text":"<p>I remember, a few years ago, there was a plugin that displayed a user's character from an online video game. The character sheet not only included a list of basic statistics, but also displayed the items that this character was wearing and or holding at the time.</p> <p>The data for these items were downloaded in bulk from the game's vendor servers and stored in a persistent cache file that periodically gets renewed. There is nothing wrong with the idea of caching the data on your own server rather than requesting them everytime from the vendor's servers - not only because they imposed a limit on the number of requests per hour.</p> <p>Unfortunately, the character sheet had a sub-par performance and the users were upset by the significant loading times compared to literally every other page on the same server. The author of the plugin was working hard to resolve this issue and was evaluating all kind of methods to improve the page performance, including deep-diving into the realm of micro-optimizations to squeeze out every last bit of performance that is possible.</p> <p>The real problem was the cache file itself, it turns out that it was holding the data for several thousand items with a total file size of about 13 megabytes. It doesn't look that much at first glance, after all this isn't the '90s anymore, but unserializing a 13 megabyte array is really slow and looking up items in such a large array isn't exactly fast either.</p> <p>The solution was rather simple, the data that was fetched from the vendor's API was instead written into a separate database table. Next, the persistent cache was removed and the character sheet would now request the item data for that specific character straight from the database. Previously, the character sheet took several seconds to load and after the change it was done in a fraction of a second. Although quite extreme, this illustrates a situation where the cache file was introduced in the design process, without evaluating if the cache - at least how it was implemented - was really necessary.</p> <p>Caching should always be a solution for a problem. Not the other way around.</p>"},{"location":"php/api/caches_persistent-caches/","title":"Persistent Caches","text":"<p>Relational databases are designed around the principle of normalized data that is organized across clearly separated tables with defined releations between data rows. While this enables you to quickly access and modify individual rows and columns, it can create the problem that re-assembling this data into a more complex structure can be quite expensive.</p> <p>For example, the user group permissions are stored for each user group and each permissions separately, but in order to be applied, they need to be fetched and the cumulative values across all user groups of an user have to be calculated. These repetitive tasks on barely ever changing data make them an excellent target for caching, where all sub-sequent requests are accelerated because they no longer have to perform the same expensive calculations every time.</p> <p>It is easy to get lost in the realm of caching, especially when it comes to the decision if you should use a cache or not. When in doubt, you should opt to not use them, because they also come at a hidden cost that cannot be expressed through simple SQL query counts. If you haven't already, it is recommended that you read the introduction article on caching first, it provides a bit of background on caches and examples that should help you in your decision.</p>"},{"location":"php/api/caches_persistent-caches/#abstractcachebuilder","title":"<code>AbstractCacheBuilder</code>","text":"<p>Every cache builder should derive from the base class AbstractCacheBuilder that already implements the mandatory interface ICacheBuilder.</p> files/lib/system/cache/builder/ExampleCacheBuilder.class.php <pre><code><?php\nnamespace wcf\\system\\cache\\builder;\n\nclass ExampleCacheBuilder extends AbstractCacheBuilder {\n // 3600 = 1hr\n protected $maxLifetime = 3600;\n\n public function rebuild(array $parameters) {\n $data = [];\n\n // fetch and process your data and assign it to `$data`\n\n return $data;\n }\n}\n</code></pre> <p>Reading data from your cache builder is quite simple and follows a consistent pattern. The callee only needs to know the name of the cache builder, which parameters it requires and how the returned data looks like. It does not need to know how the data is retrieve, where it was stored, nor if it had to be rebuild due to the maximum lifetime.</p> <pre><code><?php\nuse wcf\\system\\cache\\builder\\ExampleCacheBuilder;\n\n$data = ExampleCacheBuilder::getInstance()->getData($parameters);\n</code></pre>"},{"location":"php/api/caches_persistent-caches/#getdataarray-parameters-string-arrayindex-array","title":"<code>getData(array $parameters = [], string $arrayIndex = ''): array</code>","text":"<p>Retrieves the data from the cache builder, the <code>$parameters</code> array is automatically sorted to allow sub-sequent requests for the same parameters to be recognized, even if their parameters are mixed. For example, <code>getData([1, 2])</code> and <code>getData([2, 1])</code> will have the same exact result.</p> <p>The optional <code>$arrayIndex</code> will instruct the cache builder to retrieve the data and examine if the returned data is an array that has the index <code>$arrayIndex</code>. If it is set, the potion below this index is returned instead.</p>"},{"location":"php/api/caches_persistent-caches/#getmaxlifetime-int","title":"<code>getMaxLifetime(): int</code>","text":"<p>Returns the maximum lifetime of a cache in seconds. It can be controlled through the <code>protected $maxLifetime</code> property which defaults to <code>0</code>. Any cache that has a lifetime greater than 0 is automatically discarded when exceeding this age, otherwise it will remain forever until it is explicitly removed or invalidated.</p>"},{"location":"php/api/caches_persistent-caches/#resetarray-parameters-void","title":"<code>reset(array $parameters = []): void</code>","text":"<p>Invalidates a cache, the <code>$parameters</code> array will again be ordered using the same rules that are applied for <code>getData()</code>.</p>"},{"location":"php/api/caches_persistent-caches/#rebuildarray-parameters-array","title":"<code>rebuild(array $parameters): array</code>","text":"<p>This method is protected.</p> <p>This is the only method that a cache builder deriving from <code>AbstractCacheBuilder</code> has to implement and it will be invoked whenever the cache is required to be rebuild for whatever reason.</p>"},{"location":"php/api/caches_runtime-caches/","title":"Runtime Caches","text":"<p>Runtime caches store objects created during the runtime of the script and are automatically discarded after the script terminates. Runtime caches are especially useful when objects are fetched by different APIs, each requiring separate requests. By using a runtime cache, you have two advantages:</p> <ol> <li>If the API allows it, you can delay fetching the actual objects and initially only tell the runtime cache that at some point in the future of the current request, you need the objects with the given ids. If multiple APIs do this one after another, all objects can be fetched using only one query instead of each API querying the database on its own.</li> <li>If an object with the same ID has already been fetched from database, this object is simply returned and can be reused instead of being fetched from database again.</li> </ol>"},{"location":"php/api/caches_runtime-caches/#iruntimecache","title":"<code>IRuntimeCache</code>","text":"<p>Every runtime cache has to implement the IRuntimeCache interface. It is recommended, however, that you extend AbstractRuntimeCache, the default implementation of the runtime cache interface. In most instances, you only need to set the <code>AbstractRuntimeCache::$listClassName</code> property to the name of database object list class which fetches the cached objects from database (see example).</p>"},{"location":"php/api/caches_runtime-caches/#usage","title":"Usage","text":"<pre><code><?php\nuse wcf\\system\\cache\\runtime\\UserRuntimeCache;\n\n$userIDs = [1, 2];\n\n// first (optional) step: tell runtime cache to remember user ids\nUserRuntimeCache::getInstance()->cacheObjectIDs($userIDs);\n\n// [\u2026]\n\n// second step: fetch the objects from database\n$users = UserRuntimeCache::getInstance()->getObjects($userIDs);\n\n// somewhere else: fetch only one user\n$userID = 1;\n\nUserRuntimeCache::getInstance()->cacheObjectID($userID);\n\n// [\u2026]\n\n// get user without the cache actually fetching it from database because it has already been loaded\n$user = UserRuntimeCache::getInstance()->getObject($userID);\n\n// somewhere else: fetch users directly without caching user ids first\n$users = UserRuntimeCache::getInstance()->getObjects([3, 4]);\n</code></pre>"},{"location":"php/api/caches_runtime-caches/#example","title":"Example","text":"files/lib/system/cache/runtime/UserRuntimeCache.class.php <pre><code><?php\nnamespace wcf\\system\\cache\\runtime;\nuse wcf\\data\\user\\User;\nuse wcf\\data\\user\\UserList;\n\n/**\n * Runtime cache implementation for users.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2016 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Cache\\Runtime\n * @since 3.0\n *\n * @method User[] getCachedObjects()\n * @method User getObject($objectID)\n * @method User[] getObjects(array $objectIDs)\n */\nclass UserRuntimeCache extends AbstractRuntimeCache {\n /**\n * @inheritDoc\n */\n protected $listClassName = UserList::class;\n}\n</code></pre>"},{"location":"php/api/comments/","title":"Comments","text":""},{"location":"php/api/comments/#user-group-options","title":"User Group Options","text":"<p>You need to create the following permissions:</p> user group type permission type naming user creating comments <code>user.foo.canAddComment</code> user editing own comments <code>user.foo.canEditComment</code> user deleting own comments <code>user.foo.canDeleteComment</code> moderator moderating comments <code>mod.foo.canModerateComment</code> moderator editing comments <code>mod.foo.canEditComment</code> moderator deleting comments <code>mod.foo.canDeleteComment</code> <p>Within their respective user group option category, the options should be listed in the same order as in the table above.</p>"},{"location":"php/api/comments/#language-items","title":"Language Items","text":""},{"location":"php/api/comments/#user-group-options_1","title":"User Group Options","text":"<p>The language items for the comment-related user group options generally have the same values:</p> <ul> <li><code>wcf.acp.group.option.user.foo.canAddComment</code></li> </ul> <p>German: <code>Kann Kommentare erstellen</code></p> <p>English: <code>Can create comments</code></p> <ul> <li><code>wcf.acp.group.option.user.foo.canEditComment</code></li> </ul> <p>German: <code>Kann eigene Kommentare bearbeiten</code></p> <p>English: <code>Can edit their comments</code></p> <ul> <li><code>wcf.acp.group.option.user.foo.canDeleteComment</code></li> </ul> <p>German: <code>Kann eigene Kommentare l\u00f6schen</code></p> <p>English: <code>Can delete their comments</code></p> <ul> <li><code>wcf.acp.group.option.mod.foo.canModerateComment</code></li> </ul> <p>German: <code>Kann Kommentare moderieren</code></p> <p>English: <code>Can moderate comments</code></p> <ul> <li><code>wcf.acp.group.option.mod.foo.canEditComment</code></li> </ul> <p>German: <code>Kann Kommentare bearbeiten</code></p> <p>English: <code>Can edit comments</code></p> <ul> <li><code>wcf.acp.group.option.mod.foo.canDeleteComment</code></li> </ul> <p>German: <code>Kann Kommentare l\u00f6schen</code></p> <p>English: <code>Can delete comments</code></p>"},{"location":"php/api/cronjobs/","title":"Cronjobs","text":"<p>Cronjobs offer an easy way to execute actions periodically, like cleaning up the database.</p> <p>The execution of cronjobs is not guaranteed but requires someone to access the page with JavaScript enabled.</p> <p>This page focuses on the technical aspects of cronjobs, the cronjob package installation plugin page covers how you can actually register a cronjob.</p>"},{"location":"php/api/cronjobs/#example","title":"Example","text":"files/lib/system/cronjob/LastActivityCronjob.class.php <pre><code><?php\nnamespace wcf\\system\\cronjob;\nuse wcf\\data\\cronjob\\Cronjob;\nuse wcf\\system\\WCF;\n\n/**\n * Updates the last activity timestamp in the user table.\n *\n * @author Marcel Werk\n * @copyright 2001-2016 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Cronjob\n */\nclass LastActivityCronjob extends AbstractCronjob {\n /**\n * @inheritDoc\n */\n public function execute(Cronjob $cronjob) {\n parent::execute($cronjob);\n\n $sql = \"UPDATE wcf1_user user_table,\n wcf1_session session\n SET user_table.lastActivityTime = session.lastActivityTime\n WHERE user_table.userID = session.userID\n AND session.userID <> 0\";\n $statement = WCF::getDB()->prepare($sql);\n $statement->execute();\n }\n}\n</code></pre>"},{"location":"php/api/cronjobs/#icronjob-interface","title":"<code>ICronjob</code> Interface","text":"<p>Every cronjob needs to implement the <code>wcf\\system\\cronjob\\ICronjob</code> interface which requires the <code>execute(Cronjob $cronjob)</code> method to be implemented. This method is called by wcf\\system\\cronjob\\CronjobScheduler when executing the cronjobs.</p> <p>In practice, however, you should extend the <code>AbstractCronjob</code> class and also call the <code>AbstractCronjob::execute()</code> method as it fires an event which makes cronjobs extendable by plugins (see event documentation).</p>"},{"location":"php/api/event_list/","title":"Event List","text":"<p>Events whose name is marked with an asterisk are called from a static method and thus do not provide any object, just the class name. </p>"},{"location":"php/api/event_list/#woltlab-suite-core","title":"WoltLab Suite Core","text":"Class Event Name <code>wcf\\acp\\action\\UserExportGdprAction</code> <code>export</code> <code>wcf\\acp\\form\\StyleAddForm</code> <code>setVariables</code> <code>wcf\\acp\\form\\UserSearchForm</code> <code>search</code> <code>wcf\\action\\AbstractAction</code> <code>checkModules</code> <code>wcf\\action\\AbstractAction</code> <code>checkPermissions</code> <code>wcf\\action\\AbstractAction</code> <code>execute</code> <code>wcf\\action\\AbstractAction</code> <code>executed</code> <code>wcf\\action\\AbstractAction</code> <code>readParameters</code> <code>wcf\\data\\attachment\\AttachmentAction</code> <code>generateThumbnail</code> <code>wcf\\data\\session\\SessionAction</code> <code>keepAlive</code> <code>wcf\\data\\session\\SessionAction</code> <code>poll</code> <code>wcf\\data\\trophy\\Trophy</code> <code>renderTrophy</code> <code>wcf\\data\\user\\online\\UserOnline</code> <code>getBrowser</code> <code>wcf\\data\\user\\online\\UsersOnlineList</code> <code>isVisible</code> <code>wcf\\data\\user\\online\\UsersOnlineList</code> <code>isVisibleUser</code> <code>wcf\\data\\user\\trophy\\UserTrophy</code> <code>getReplacements</code> <code>wcf\\data\\user\\UserAction</code> <code>beforeFindUsers</code> <code>wcf\\data\\user\\UserAction</code> <code>rename</code> <code>wcf\\data\\user\\UserProfile</code> <code>getAvatar</code> <code>wcf\\data\\user\\UserProfile</code> <code>isAccessible</code> <code>wcf\\data\\AbstractDatabaseObjectAction</code> <code>finalizeAction</code> <code>wcf\\data\\AbstractDatabaseObjectAction</code> <code>initializeAction</code> <code>wcf\\data\\AbstractDatabaseObjectAction</code> <code>validateAction</code> <code>wcf\\data\\DatabaseObjectList</code> <code>init</code> <code>wcf\\form\\AbstractForm</code> <code>readFormParameters</code> <code>wcf\\form\\AbstractForm</code> <code>save</code> <code>wcf\\form\\AbstractForm</code> <code>saved</code> <code>wcf\\form\\AbstractForm</code> <code>submit</code> <code>wcf\\form\\AbstractForm</code> <code>validate</code> <code>wcf\\form\\AbstractFormBuilderForm</code> <code>createForm</code> <code>wcf\\form\\AbstractFormBuilderForm</code> <code>buildForm</code> <code>wcf\\form\\AbstractModerationForm</code> <code>prepareSave</code> <code>wcf\\page\\AbstractPage</code> <code>assignVariables</code> <code>wcf\\page\\AbstractPage</code> <code>checkModules</code> <code>wcf\\page\\AbstractPage</code> <code>checkPermissions</code> <code>wcf\\page\\AbstractPage</code> <code>readData</code> <code>wcf\\page\\AbstractPage</code> <code>readParameters</code> <code>wcf\\page\\AbstractPage</code> <code>show</code> <code>wcf\\page\\MultipleLinkPage</code> <code>beforeReadObjects</code> <code>wcf\\page\\MultipleLinkPage</code> <code>insteadOfReadObjects</code> <code>wcf\\page\\MultipleLinkPage</code> <code>afterInitObjectList</code> <code>wcf\\page\\MultipleLinkPage</code> <code>calculateNumberOfPages</code> <code>wcf\\page\\MultipleLinkPage</code> <code>countItems</code> <code>wcf\\page\\SortablePage</code> <code>validateSortField</code> <code>wcf\\page\\SortablePage</code> <code>validateSortOrder</code> <code>wcf\\system\\bbcode\\MessageParser</code> <code>afterParsing</code> <code>wcf\\system\\bbcode\\MessageParser</code> <code>beforeParsing</code> <code>wcf\\system\\bbcode\\SimpleMessageParser</code> <code>afterParsing</code> <code>wcf\\system\\bbcode\\SimpleMessageParser</code> <code>beforeParsing</code> <code>wcf\\system\\box\\BoxHandler</code> <code>loadBoxes</code> <code>wcf\\system\\box\\AbstractBoxController</code> <code>__construct</code> <code>wcf\\system\\box\\AbstractBoxController</code> <code>afterLoadContent</code> <code>wcf\\system\\box\\AbstractBoxController</code> <code>beforeLoadContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>afterLoadContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>beforeLoadContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>hasContent</code> <code>wcf\\system\\box\\AbstractDatabaseObjectListBoxController</code> <code>readObjects</code> <code>wcf\\system\\cronjob\\AbstractCronjob</code> <code>execute</code> <code>wcf\\system\\email\\Email</code> <code>getJobs</code> <code>wcf\\system\\form\\builder\\container\\wysiwyg\\WysiwygFormContainer</code> <code>populate</code> <code>wcf\\system\\html\\input\\filter\\MessageHtmlInputFilter</code> <code>setAttributeDefinitions</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>afterProcess</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>beforeEmbeddedProcess</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>beforeProcess</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>convertPlainLinks</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>getTextContent</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeProcessor</code> <code>parseEmbeddedContent</code> <code>wcf\\system\\html\\input\\node\\HtmlInputNodeWoltlabMetacodeMarker</code> <code>filterGroups</code> <code>wcf\\system\\html\\output\\node\\HtmlOutputNodePre</code> <code>selectHighlighter</code> <code>wcf\\system\\html\\output\\node\\HtmlOutputNodeProcessor</code> <code>beforeProcess</code> <code>wcf\\system\\image\\adapter\\ImagickImageAdapter</code> <code>getResizeFilter</code> <code>wcf\\system\\menu\\user\\profile\\UserProfileMenu</code> <code>init</code> <code>wcf\\system\\menu\\user\\profile\\UserProfileMenu</code> <code>loadCache</code> <code>wcf\\system\\menu\\TreeMenu</code> <code>init</code> <code>wcf\\system\\menu\\TreeMenu</code> <code>loadCache</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>addFullQuote</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>allowedDataParameters</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>beforeRenderQuote</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>createMessage</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>createdMessage</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>getMessage</code> <code>wcf\\system\\message\\QuickReplyManager</code> <code>validateParameters</code> <code>wcf\\system\\message\\quote\\MessageQuoteManager</code> <code>addFullQuote</code> <code>wcf\\system\\message\\quote\\MessageQuoteManager</code> <code>beforeRenderQuote</code> <code>wcf\\system\\option\\OptionHandler</code> <code>afterReadCache</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>construct</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>hasUninstall</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>install</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>uninstall</code> <code>wcf\\system\\package\\plugin\\AbstractPackageInstallationPlugin</code> <code>update</code> <code>wcf\\system\\package\\plugin\\ObjectTypePackageInstallationPlugin</code> <code>addConditionFields</code> <code>wcf\\system\\package\\PackageInstallationDispatcher</code> <code>postInstall</code> <code>wcf\\system\\package\\PackageUninstallationDispatcher</code> <code>postUninstall</code> <code>wcf\\system\\reaction\\ReactionHandler</code> <code>getDataAttributes</code> <code>wcf\\system\\request\\RouteHandler</code> <code>didInit</code> <code>wcf\\system\\session\\ACPSessionFactory</code> <code>afterInit</code> <code>wcf\\system\\session\\ACPSessionFactory</code> <code>beforeInit</code> <code>wcf\\system\\session\\SessionHandler</code> <code>afterChangeUser</code> <code>wcf\\system\\session\\SessionHandler</code> <code>beforeChangeUser</code> <code>wcf\\system\\style\\StyleCompiler</code> <code>compile</code> <code>wcf\\system\\template\\TemplateEngine</code> <code>afterDisplay</code> <code>wcf\\system\\template\\TemplateEngine</code> <code>beforeDisplay</code> <code>wcf\\system\\upload\\DefaultUploadFileSaveStrategy</code> <code>generateThumbnails</code> <code>wcf\\system\\upload\\DefaultUploadFileSaveStrategy</code> <code>save</code> <code>wcf\\system\\user\\authentication\\UserAuthenticationFactory</code> <code>init</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>createdNotification</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>fireEvent</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>markAsConfirmed</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>markAsConfirmedByIDs</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>removeNotifications</code> <code>wcf\\system\\user\\notification\\UserNotificationHandler</code> <code>updateTriggerCount</code> <code>wcf\\system\\user\\UserBirthdayCache</code> <code>loadMonth</code> <code>wcf\\system\\worker\\AbstractRebuildDataWorker</code> <code>execute</code> <code>wcf\\system\\WCF</code> <code>initialized</code> <code>wcf\\util\\HeaderUtil</code> <code>parseOutput</code>*"},{"location":"php/api/event_list/#woltlab-suite-core-conversations","title":"WoltLab Suite Core: Conversations","text":"Class Event Name <code>wcf\\data\\conversation\\ConversationAction</code> <code>addParticipants_validateParticipants</code> <code>wcf\\data\\conversation\\message\\ConversationMessageAction</code> <code>afterQuickReply</code>"},{"location":"php/api/event_list/#woltlab-suite-core-infractions","title":"WoltLab Suite Core: Infractions","text":"Class Event Name <code>wcf\\system\\infraction\\suspension\\BanSuspensionAction</code> <code>suspend</code> <code>wcf\\system\\infraction\\suspension\\BanSuspensionAction</code> <code>unsuspend</code>"},{"location":"php/api/event_list/#woltlab-suite-forum","title":"WoltLab Suite Forum","text":"Class Event Name <code>wbb\\data\\board\\BoardAction</code> <code>cloneBoard</code> <code>wbb\\data\\post\\PostAction</code> <code>quickReplyShouldMerge</code> <code>wbb\\system\\thread\\ThreadHandler</code> <code>didInit</code>"},{"location":"php/api/event_list/#woltlab-suite-filebase","title":"WoltLab Suite Filebase","text":"Class Event Name <code>filebase\\data\\file\\File</code> <code>getPrice</code> <code>filebase\\data\\file\\ViewableFile</code> <code>getUnreadFiles</code>"},{"location":"php/api/events/","title":"Events","text":"<p>WoltLab Suite's event system allows manipulation of program flows and data without having to change any of the original source code. At many locations throughout the PHP code of WoltLab Suite Core and mainly through inheritance also in the applications and plugins, so called events are fired which trigger registered event listeners that get access to the object firing the event (or at least the class name if the event has been fired in a static method).</p> <p>This page focuses on the technical aspects of events and event listeners, the eventListener package installation plugin page covers how you can actually register an event listener. A comprehensive list of all available events is provided here.</p>"},{"location":"php/api/events/#introductory-example","title":"Introductory Example","text":"<p>Let's start with a simple example to illustrate how the event system works. Consider this pre-existing class:</p> files/lib/system/example/ExampleComponent.class.php <pre><code><?php\nnamespace wcf\\system\\example;\nuse wcf\\system\\event\\EventHandler;\n\nclass ExampleComponent {\n public $var = 1;\n\n public function getVar() {\n EventHandler::getInstance()->fireAction($this, 'getVar');\n\n return $this->var;\n }\n}\n</code></pre> <p>where an event with event name <code>getVar</code> is fired in the <code>getVar()</code> method.</p> <p>If you create an object of this class and call the <code>getVar()</code> method, the return value will be <code>1</code>, of course:</p> <pre><code><?php\n\n$example = new wcf\\system\\example\\ExampleComponent();\nif ($example->getVar() == 1) {\n echo \"var is 1!\";\n}\nelse if ($example->getVar() == 2) {\n echo \"var is 2!\";\n}\nelse {\n echo \"No, var is neither 1 nor 2.\";\n}\n\n// output: var is 1!\n</code></pre> <p>Now, consider that we have registered the following event listener to this event:</p> files/lib/system/event/listener/ExampleEventListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\n\nclass ExampleEventListener implements IParameterizedEventListener {\n public function execute($eventObj, $className, $eventName, array &$parameters) {\n $eventObj->var = 2;\n }\n}\n</code></pre> <p>Whenever the event in the <code>getVar()</code> method is called, this method (of the same event listener object) is called. In this case, the value of the method's first parameter is the <code>ExampleComponent</code> object passed as the first argument of the <code>EventHandler::fireAction()</code> call in <code>ExampleComponent::getVar()</code>. As <code>ExampleComponent::$var</code> is a public property, the event listener code can change it and set it to <code>2</code>.</p> <p>If you now execute the example code from above again, the output will change from <code>var is 1!</code> to <code>var is 2!</code> because prior to returning the value, the event listener code changes the value from <code>1</code> to <code>2</code>.</p> <p>This introductory example illustrates how event listeners can change data in a non-intrusive way. Program flow can be changed, for example, by throwing a <code>wcf\\system\\exception\\PermissionDeniedException</code> if some additional constraint to access a page is not fulfilled.</p>"},{"location":"php/api/events/#listening-to-events","title":"Listening to Events","text":"<p>In order to listen to events, you need to register the event listener and the event listener itself needs to implement the interface <code>wcf\\system\\event\\listener\\IParameterizedEventListener</code> which only contains the <code>execute</code> method (see example above).</p> <p>The first parameter <code>$eventObj</code> of the method contains the passed object where the event is fired or the name of the class in which the event is fired if it is fired from a static method. The second parameter <code>$className</code> always contains the name of the class where the event has been fired. The third parameter <code>$eventName</code> provides the name of the event within a class to uniquely identify the exact location in the class where the event has been fired. The last parameter <code>$parameters</code> is a reference to the array which contains additional data passed by the method firing the event. If no additional data is passed, <code>$parameters</code> is empty.</p>"},{"location":"php/api/events/#firing-events","title":"Firing Events","text":"<p>If you write code and want plugins to have access at certain points, you can fire an event on your own. The only thing to do is to call the <code>wcf\\system\\event\\EventHandler::fireAction($eventObj, $eventName, array &$parameters = [])</code> method and pass the following parameters:</p> <ol> <li><code>$eventObj</code> should be <code>$this</code> if you fire from an object context, otherwise pass the class name <code>static::class</code>.</li> <li><code>$eventName</code> identifies the event within the class and generally has the same name as the method. In cases, were you might fire more than one event in a method, for example before and after a certain piece of code, you can use the prefixes <code>before*</code> and <code>after*</code> in your event names.</li> <li><code>$parameters</code> is an optional array which allows you to pass additional data to the event listeners without having to make this data accessible via a property explicitly only created for this purpose. This additional data can either be just additional information for the event listeners about the context of the method call or allow the event listener to manipulate local data if the code, where the event has been fired, uses the passed data afterwards. </li> </ol>"},{"location":"php/api/events/#example-using-parameters-argument","title":"Example: Using <code>$parameters</code> argument","text":"<p>Consider the following method which gets some text that the methods parses.</p> files/lib/system/example/ExampleParser.class.php <pre><code><?php\nnamespace wcf\\system\\example;\nuse wcf\\system\\event\\EventHandler;\n\nclass ExampleParser {\n public function parse($text) {\n // [some parsing done by default]\n\n $parameters = ['text' => $text];\n EventHandler::getInstance()->fireAction($this, 'parse', $parameters);\n\n return $parameters['text'];\n }\n}\n</code></pre> <p>After the default parsing by the method itself, the author wants to enable plugins to do additional parsing and thus fires an event and passes the parsed text as an additional parameter. Then, a plugin can deliver the following event listener</p> files/lib/system/event/listener/ExampleParserEventListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\n\nclass ExampleParserEventListener implements IParameterizedEventListener {\n public function execute($eventObj, $className, $eventName, array &$parameters) {\n $text = $parameters['text'];\n\n // [some additional parsing which changes $text]\n\n $parameters['text'] = $text;\n }\n}\n</code></pre> <p>which can access the text via <code>$parameters['text']</code>.</p> <p>This example can also be perfectly used to illustrate how to name multiple events in the same method. Let's assume that the author wants to enable plugins to change the text before and after the method does its own parsing and thus fires two events:</p> files/lib/system/example/ExampleParser.class.php <pre><code><?php\nnamespace wcf\\system\\example;\nuse wcf\\system\\event\\EventHandler;\n\nclass ExampleParser {\n public function parse($text) {\n $parameters = ['text' => $text];\n EventHandler::getInstance()->fireAction($this, 'beforeParsing', $parameters);\n $text = $parameters['text'];\n\n // [some parsing done by default]\n\n $parameters = ['text' => $text];\n EventHandler::getInstance()->fireAction($this, 'afterParsing', $parameters);\n\n return $parameters['text'];\n }\n}\n</code></pre>"},{"location":"php/api/events/#advanced-example-additional-form-field","title":"Advanced Example: Additional Form Field","text":"<p>One common reason to use event listeners is to add an additional field to a pre-existing form (in combination with template listeners, which we will not cover here). We will assume that users are able to do both, create and edit the objects via this form. The points in the program flow of AbstractForm that are relevant here are:</p> <ul> <li>adding object (after the form has been submitted):</li> <li>reading the value of the field</li> <li>validating the read value</li> <li> <p>saving the additional value after successful validation and resetting locally stored value or assigning the current value of the field to the template after unsuccessful validation</p> </li> <li> <p>editing object:</p> </li> <li>on initial form request:<ol> <li>reading the pre-existing value of the edited object</li> <li>assigning the field value to the template</li> </ol> </li> <li>after the form has been submitted:<ol> <li>reading the value of the field</li> <li>validating the read value</li> <li>saving the additional value after successful validation</li> <li>assigning the current value of the field to the template</li> </ol> </li> </ul> <p>All of these cases can be covered the by following code in which we assume that <code>wcf\\form\\ExampleAddForm</code> is the form to create example objects and that <code>wcf\\form\\ExampleEditForm</code> extends <code>wcf\\form\\ExampleAddForm</code> and is used for editing existing example objects.</p> files/lib/system/event/listener/ExampleAddFormListener.class.php <pre><code><?php\nnamespace wcf\\system\\event\\listener;\nuse wcf\\form\\ExampleAddForm;\nuse wcf\\form\\ExampleEditForm;\nuse wcf\\system\\exception\\UserInputException;\nuse wcf\\system\\WCF;\n\nclass ExampleAddFormListener implements IParameterizedEventListener {\n protected $var = 0;\n\n public function execute($eventObj, $className, $eventName, array &$parameters) {\n $this->$eventName($eventObj);\n }\n\n protected function assignVariables() {\n WCF::getTPL()->assign('var', $this->var);\n }\n\n protected function readData(ExampleEditForm $eventObj) {\n if (empty($_POST)) {\n $this->var = $eventObj->example->var;\n }\n }\n\n protected function readFormParameters() {\n if (isset($_POST['var'])) $this->var = intval($_POST['var']);\n }\n\n protected function save(ExampleAddForm $eventObj) {\n $eventObj->additionalFields = array_merge($eventObj->additionalFields, ['var' => $this->var]);\n }\n\n protected function saved() {\n $this->var = 0;\n }\n\n protected function validate() {\n if ($this->var < 0) {\n throw new UserInputException('var', 'isNegative');\n }\n }\n}\n</code></pre> <p>The <code>execute</code> method in this example just delegates the call to a method with the same name as the event so that this class mimics the structure of a form class itself. The form object is passed to the methods but is only given in the method signatures as a parameter here whenever the form object is actually used. Furthermore, the type-hinting of the parameter illustrates in which contexts the method is actually called which will become clear in the following discussion of the individual methods:</p> <ul> <li><code>assignVariables()</code> is called for the add and the edit form and simply assigns the current value of the variable to the template.</li> <li><code>readData()</code> reads the pre-existing value of <code>$var</code> if the form has not been submitted and thus is only relevant when editing objects which is illustrated by the explicit type-hint of <code>ExampleEditForm</code>.</li> <li><code>readFormParameters()</code> reads the value for both, the add and the edit form.</li> <li><code>save()</code> is, of course, also relevant in both cases but requires the form object to store the additional value in the <code>wcf\\form\\AbstractForm::$additionalFields</code> array which can be used if a <code>var</code> column has been added to the database table in which the example objects are stored.</li> <li><code>saved()</code> is only called for the add form as it clears the internal value so that in the <code>assignVariables()</code> call, the default value will be assigned to the template to create an \"empty\" form. During edits, this current value is the actual value that should be shown.</li> <li><code>validate()</code> also needs to be called in both cases as the input data always has to be validated.</li> </ul> <p>Lastly, the following XML file has to be used to register the event listeners (you can find more information about how to register event listeners on the eventListener package installation plugin page):</p> eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/eventListener.xsd\">\n <import>\n <eventlistener name=\"exampleAddInherited\">\n <eventclassname>wcf\\form\\ExampleAddForm</eventclassname>\n <eventname>assignVariables,readFormParameters,save,validate</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\ExampleAddFormListener</listenerclassname>\n <inherit>1</inherit>\n </eventlistener>\n\n <eventlistener name=\"exampleAdd\">\n <eventclassname>wcf\\form\\ExampleAddForm</eventclassname>\n <eventname>saved</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\ExampleAddFormListener</listenerclassname>\n </eventlistener>\n\n <eventlistener name=\"exampleEdit\">\n <eventclassname>wcf\\form\\ExampleEditForm</eventclassname>\n <eventname>readData</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\ExampleAddFormListener</listenerclassname>\n </eventlistener>\n </import>\n</data>\n</code></pre>"},{"location":"php/api/events/#psr-14-events","title":"PSR-14 Events","text":"<p>WoltLab Suite 5.5 introduces the concept of dedicated, reusable event classes. Any newly introduced event will receive a dedicated class, implementing the <code>wcf\\event\\IPsr14Event</code> interface. These event classes may be fired from multiple locations, making them reusable to convey that a conceptual action happened, instead of a specific class doing something. An example for using the new event system could be a user logging in: Instead of listening on a the login form being submitted and the Facebook login action successfully running, an event <code>UserLoggedIn</code> might be fired whenever a user logs in, no matter how the login is performed.</p> <p>Additionally, these dedicated event classes will benefit from full IDE support. All the relevant values may be stored as real properties on the event object.</p> <p>Event classes should not have an <code>Event</code> suffix and should be stored in an <code>event</code> namespace in a matching location. Thus, the <code>UserLoggedIn</code> example might have a FQCN of <code>\\wcf\\event\\user\\authentication\\UserLoggedIn</code>.</p> <p>Event listeners for events implementing <code>IPsr14Event</code> need to follow PSR-14, i.e. they need to be callable. In practice, this means that the event listener class needs to implement <code>__invoke()</code>. No interface has to be implemented in this case.</p> <p>Previously:</p> <pre><code>$parameters = [\n 'value' => \\random_int(1, 1024),\n];\n\nEventHandler::getInstance()->fireAction($this, 'valueAvailable', $parameters);\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\form\\ValueForm;\n\nfinal class ValueDumpListener implements IParameterizedEventListener\n{\n /**\n * @inheritDoc\n * @param ValueForm $eventObj\n */\n public function execute($eventObj, $className, $eventName, array &$parameters)\n {\n var_dump($parameters['value']);\n }\n}\n</code></pre> <p>Now:</p> <pre><code>EventHandler::getInstance()->fire(new ValueAvailable(\\random_int(1, 1024)));\n</code></pre> lib/event/foo/ValueAvailable.class.php<pre><code><?php\n\nnamespace wcf\\event\\foo;\n\nuse wcf\\event\\IPsr14Event;\n\nfinal class ValueAvailable implements IPsr14Event\n{\n /**\n * @var int\n */\n private $value;\n\n public function __construct(int $value)\n {\n $this->value = $value;\n }\n\n public function getValue(): int\n {\n return $this->value;\n }\n}\n</code></pre> lib/system/event/listener/ValueDumpListener.class.php<pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\event\\foo\\ValueAvailable;\n\nfinal class ValueDumpListener\n{\n public function __invoke(ValueAvailable $event): void\n {\n \\var_dump($event->getValue());\n }\n}\n</code></pre>"},{"location":"php/api/events/#available-psr-14-events","title":"Available PSR-14 Events","text":"Class Description <code>wcf\\event\\acp\\dashboard\\box\\BoxCollecting</code> Requests the collection of boxes for the acp dashboard. <code>wcf\\event\\acp\\dashboard\\box\\PHPExtensionCollecting</code> Requests the collection of PHP extensions for the system info ACP dashboard box. <code>wcf\\event\\acp\\dashboard\\box\\StatusMessageCollecting</code> Requests the collection of status messages for the status message dashboard box. <code>wcf\\event\\acp\\menu\\item\\ItemCollecting</code> Requests the collection of acp menu items. <code>wcf\\event\\cache\\CacheCleared</code> Indicates that a full cache clear was performed. <code>wcf\\event\\comment\\CommentCreated</code> Indicates that a new comment has been created. <code>wcf\\event\\comment\\CommentPublished</code> Indicates that a new comment has been published. This can happen directly when a comment is created or be delayed if a comment has first been checked and approved by a moderator. <code>wcf\\event\\comment\\CommentUpdated</code> Indicates that a comment has been updated. <code>wcf\\event\\comment\\CommentsDeleted</code> Indicates that multiple comments have been deleted. <code>wcf\\event\\comment\\response\\ResponseCreated</code> Indicates that a new comment response has been created. <code>wcf\\event\\comment\\response\\ResponsePublished</code> Indicates that a new comment response has been published. This can happen directly when a comment is created or be delayed if a response has first been checked and approved by a moderator. <code>wcf\\event\\comment\\response\\ResponseUpdated</code> Indicates that a response has been updated. <code>wcf\\event\\comment\\response\\ResponsesDeleted</code> Indicates that multiple responses have been deleted. <code>wcf\\event\\endpoint\\ControllerCollecting</code> Collects the list of API controllers. <code>wcf\\event\\language\\LanguageContentCopying</code> Indicates that the contents of a language should be copied to another one. <code>wcf\\event\\language\\LanguageImported</code> Indicates that a language was created or updated through a manual import. <code>wcf\\event\\language\\PhraseChanged</code> Indicates that a phrase has been modified by the user. <code>wcf\\event\\language\\PreloadPhrasesCollecting</code> Requests the collection of phrases that should be included in the preload cache. <code>wcf\\event\\message\\MessageSpamChecking</code> Indicates that a new message by a user is currently validated. If this event is interrupted, the message is considered to be spam. <code>wcf\\event\\moderation\\queue\\UserAssigned</code> Indicates that a user was assigned or reassigned to a moderation queue entry. <code>wcf\\event\\package\\PackageInstallationPluginSynced</code> Indicates that the a package installation plugin was executed through the developer tools. <code>wcf\\event\\package\\PackageListChanged</code> Indicates that the there have been changes to the package list. These changes include the installation, removal or update of existing packages. The event is fired at the end of the overall process and not for each package that has been modified. <code>wcf\\event\\package\\PackageUpdateListChanged</code> Indicates that the there have been changes to the package update list. <code>wcf\\event\\page\\ContactFormSpamChecking</code> Indicates that a new contact form message is currently validated. If this event is interrupted, the message is considered to be spam. <code>wcf\\event\\request\\ActivePageResolving</code> Indicates that the <code>RequestHandler</code> could not determine the active page. <code>wcf\\event\\session\\PreserveVariablesCollecting</code> This event allows the configuration of session variables that are to be preserved when the user changes. <code>wcf\\event\\spider\\SpiderCollecting</code> Requests the collection of spiders. <code>wcf\\event\\user\\RegistrationSpamChecking</code> Indicates that a registration by a new user is currently validated. If $matches is not empty, the registration is considered to be a spammer or an undesirable user. <code>wcf\\event\\user\\UsernameValidating</code> Indicates that a username is currently validated. If this event is interrupted, the username is considered to be invalid. This event will not be fired for usernames changed by an administrator. <code>wcf\\event\\user\\authentication\\UserLoggedIn</code> Indicates that the user actively logged in, i.e. that a user change happened in response to a user's request based off proper authentication. This event specifically must not be used if the active user is changed for technical reasons, e.g. when switching back to the real user after executing some logic with guest permissions. <code>wcf\\event\\user\\authentication\\configuration\\ConfigurationLoading</code> Indicates the loading of the user auth configuration. <code>wcf\\event\\user\\menu\\item\\IconResolving</code> Resolves the icon of a user menu item. <code>wcf\\event\\worker\\RebuildWorkerCollecting</code> Requests the collection of workers that should be included in the list of rebuild workers."},{"location":"php/api/package_installation_plugins/","title":"Package Installation Plugins","text":"<p>A package installation plugin (PIP) defines the behavior to handle a specific instruction during package installation, update or uninstallation.</p>"},{"location":"php/api/package_installation_plugins/#abstractpackageinstallationplugin","title":"<code>AbstractPackageInstallationPlugin</code>","text":"<p>Any package installation plugin has to implement the IPackageInstallationPlugin interface. It is recommended however, to extend the abstract implementation AbstractPackageInstallationPlugin of this interface instead of directly implementing the interface. The abstract implementation will always provide sane methods in case of any API changes.</p>"},{"location":"php/api/package_installation_plugins/#class-members","title":"Class Members","text":"<p>Package Installation Plugins have a few notable class members easing your work:</p>"},{"location":"php/api/package_installation_plugins/#installation","title":"<code>$installation</code>","text":"<p>This member contains an instance of PackageInstallationDispatcher which provides you with all meta data related to the current package being processed. The most common usage is the retrieval of the package ID via <code>$this->installation->getPackageID()</code>.</p>"},{"location":"php/api/package_installation_plugins/#application","title":"<code>$application</code>","text":"<p>Represents the abbreviation of the target application, e.g. <code>wbb</code> (default value: <code>wcf</code>), used for the name of database table in which the installed data is stored.</p>"},{"location":"php/api/package_installation_plugins/#abstractxmlpackageinstallationplugin","title":"<code>AbstractXMLPackageInstallationPlugin</code>","text":"<p>AbstractPackageInstallationPlugin is the default implementation for all package installation plugins based upon a single XML document. It handles the evaluation of the document and provide you an object-orientated approach to handle its data.</p>"},{"location":"php/api/package_installation_plugins/#class-members_1","title":"Class Members","text":""},{"location":"php/api/package_installation_plugins/#classname","title":"<code>$className</code>","text":"<p>Value must be the qualified name of a class deriving from DatabaseObjectEditor which is used to create and update objects.</p>"},{"location":"php/api/package_installation_plugins/#tagname","title":"<code>$tagName</code>","text":"<p>Specifies the tag name within a <code><import></code> or <code><delete></code> section of the XML document used for each installed object.</p>"},{"location":"php/api/package_installation_plugins/#prepareimportarray-data","title":"<code>prepareImport(array $data)</code>","text":"<p>The passed array <code>$data</code> contains the parsed value from each evaluated tag in the <code><import></code> section:</p> <ul> <li><code>$data['elements']</code> contains a list of tag names and their value.</li> <li><code>$data['attributes']</code> contains a list of attributes present on the tag identified by $tagName.</li> </ul> <p>This method should return an one-dimensional array, where each key maps to the corresponding database column name (key names are case-sensitive). It will be passed to either <code>DatabaseObjectEditor::create()</code> or <code>DatabaseObjectEditor::update()</code>.</p> <p>Example:</p> <pre><code><?php\nreturn [\n 'environment' => $data['elements']['environment'],\n 'eventName' => $data['elements']['eventname'],\n 'name' => $data['attributes']['name']\n];\n</code></pre>"},{"location":"php/api/package_installation_plugins/#validateimportarray-data","title":"<code>validateImport(array $data)</code>","text":"<p>The passed array <code>$data</code> equals the data returned by prepareImport(). This method has no return value, instead you should throw an exception if the passed data is invalid.</p>"},{"location":"php/api/package_installation_plugins/#findexistingitemarray-data","title":"<code>findExistingItem(array $data)</code>","text":"<p>The passed array <code>$data</code> equals the data returned by prepareImport(). This method is expected to return an array with two keys:</p> <ul> <li><code>sql</code> contains the SQL query with placeholders.</li> <li><code>parameters</code> contains an array with values used for the SQL query.</li> </ul>"},{"location":"php/api/package_installation_plugins/#example","title":"Example","text":"<pre><code><?php\n$sql = \"SELECT *\n FROM wcf\".WCF_N.\"_\".$this->tableName.\"\n WHERE packageID = ?\n AND name = ?\n AND templateName = ?\n AND eventName = ?\n AND environment = ?\";\n$parameters = [\n $this->installation->getPackageID(),\n $data['name'],\n $data['templateName'],\n $data['eventName'],\n $data['environment']\n];\n\nreturn [\n 'sql' => $sql,\n 'parameters' => $parameters\n];\n</code></pre>"},{"location":"php/api/package_installation_plugins/#handledeletearray-items","title":"<code>handleDelete(array $items)</code>","text":"<p>The passed array <code>$items</code> contains the original node data, similar to prepareImport(). You should make use of this data to remove the matching element from database.</p> <p>Example: <pre><code><?php\n$sql = \"DELETE FROM wcf1_{$this->tableName}\n WHERE packageID = ?\n AND environment = ?\n AND eventName = ?\n AND name = ?\n AND templateName = ?\";\n$statement = WCF::getDB()->prepare($sql);\nforeach ($items as $item) {\n $statement->execute([\n $this->installation->getPackageID(),\n $item['elements']['environment'],\n $item['elements']['eventname'],\n $item['attributes']['name'],\n $item['elements']['templatename']\n ]);\n}\n</code></pre></p>"},{"location":"php/api/package_installation_plugins/#postimport","title":"<code>postImport()</code>","text":"<p>Allows you to (optionally) run additionally actions after all elements were processed.</p>"},{"location":"php/api/package_installation_plugins/#abstractoptionpackageinstallationplugin","title":"<code>AbstractOptionPackageInstallationPlugin</code>","text":"<p>AbstractOptionPackageInstallationPlugin is an abstract implementation for options, used for:</p> <ul> <li>ACL Options</li> <li>Options</li> <li>User Options</li> <li>User Group Options</li> </ul>"},{"location":"php/api/package_installation_plugins/#differences-to-abstractxmlpackageinstallationplugin","title":"Differences to <code>AbstractXMLPackageInstallationPlugin</code>","text":""},{"location":"php/api/package_installation_plugins/#reservedtags","title":"<code>$reservedTags</code>","text":"<p><code>$reservedTags</code> is a list of reserved tag names so that any tag encountered but not listed here will be added to the database column <code>additionalData</code>. This allows options to store arbitrary data which can be accessed but were not initially part of the PIP specifications.</p>"},{"location":"php/api/rpc_api/","title":"RPC API","text":"<p>The RPC API provides a consistent and predictable JSON API for the interaction with the server. Authentication is entirely handled through the existing cookie-backed session system.</p> <p>The current implementation covers a few reference endpoints that replaced existing PSR-based actions. It is designed to be a replacement for the existing <code>AbstractDatabaseObjectAction</code> actions in the mid to long term. You are more than welcome to share any feedback, including but not limited to suggestions for improvements, on GitHub.</p> <p>The implementation of the RPC API is built in a way that it could support a token based authentication in the future but this is entirely out of scope for the current iteration.</p>"},{"location":"php/api/rpc_api/#predictable-api","title":"Predictable API","text":""},{"location":"php/api/rpc_api/#idempotency-whenever-reasonably-possible","title":"Idempotency Whenever Reasonably Possible","text":"<p>Some endpoints will perform a specific action, such as following a user or reacting to a message. These endpoints SHOULD be idempotent whenever possible, treating the request to be the \u201cshould\u201d state.</p> <p>For example, following a user for the first time should produce the same response as attempting to follow them again while still following. Reacting to a message that has already been reacted to using a difference reaction should implicitly revoke the previous reaction. If the user has already reacted using the same reaction then no change should be made. However, in both cases the response should be indistinguishable from reacting to a message for the first time.</p>"},{"location":"php/api/rpc_api/#http-verbs","title":"HTTP Verbs","text":"<p>We will only support three basic verbs: <code>GET</code>, <code>POST</code> and <code>DELETE</code>.</p> <p>Some implementations also make use of <code>PATCH</code> and <code>PUT</code>, but this would make it much more complex and adds little benefit plus its quite verbose since the verb implies the semantics of the endpoint. The same can be achieved by using distinct endpoints and using <code>POST</code> instead. Plus historically the support for <code>PATCH</code> and <code>PUT</code> was rather poor.</p>"},{"location":"php/api/rpc_api/#response-format","title":"Response Format","text":"<p>The PSR messaging interface allows for a host of useful response types, such as <code>204 No Content</code>, returning a plain \u201cHTML\u201d response or any format that is suitable. While this is more efficient, it also makes the API much more complicated and less predictable, requiring different response handling based on the endpoint being targeted.</p>"},{"location":"php/api/rpc_api/#http-status-codes","title":"HTTP Status Codes","text":"Code Name Meaning 200 OK The request was successful. 400 Bad Request The provided parameters are insufficient. 403 Permission Denied The callee is not authorized to execute this request. 404 Not Found The requested endpoint does not exist. 405 Method Not Allowed Using any HTTP verb other than <code>GET</code>, <code>POST</code> or <code>DELETE</code>. 500 Internal Server Error The server failed to process the request. 503 Service Unavailable The API is currently unavailable."},{"location":"php/api/rpc_api/#error-format","title":"Error Format","text":"<p>Whenever a request is rejected with the error code 400, the response will match the following data structure:</p> <pre><code>type ErrorResponse = {\n type: \"api_error\" | \"invalid_request_error\";\n code: string;\n message: string;\n param: string;\n};\n</code></pre> <p>A typical response could look like this:</p> <pre><code>{\n \"type\": \"invalid_request_error\",\n \"code\": \"value_too_short\",\n \"message\": \"\",\n \"param\": \"username\"\n}\n</code></pre>"},{"location":"php/api/rpc_api/#type","title":"<code>type</code>","text":"<p>The error type is used to tell apart issues caused by the request being made by the client or by unexpected errors taking place on the server side processing.</p>"},{"location":"php/api/rpc_api/#code","title":"<code>code</code>","text":"<p>The error code is all lowercase and using snake case to describe the type of error, for example, <code>missing_api_key</code>.</p>"},{"location":"php/api/rpc_api/#message","title":"<code>message</code>","text":"<p>The message can be empty but when present contains a non-localized string explaining the cause of the error with the intention of assisting a developer to resolve the issue.</p> <p>You MUST NOT present this message to the end user.</p>"},{"location":"php/api/rpc_api/#param","title":"<code>param</code>","text":"<p>Validation errors may refer to a specific parameter that has caused the request to be rejected. A common use case is to point to a specific input field, allowing for contextual error message presented to the user.</p>"},{"location":"php/api/rpc_api/#examples","title":"Examples","text":"<p>The endpoints below may or may not exist at any point and are only used for illustration purposes.</p> Verb Endpoint Explanation <code>GET</code> <code>/core/users</code> Retrieve a list of users, may include query parameters to control the response. <code>GET</code> <code>/core/users/{id:\\d+}</code> Retrieve a user, may include query parameters to control the response. <code>GET</code> <code>/core/users/{id:\\d+}/following</code> Retrieve a list of users that the target user is following. - - - <code>POST</code> <code>/core/users</code> Creates a new user, parameters are always presented in the body. <code>POST</code> <code>/core/users/{id:\\d+}</code> (Partially) updates a user. <code>POST</code> <code>/core/moderationqueues/{id:\\d+}/assign</code> Assigns a user. - - - <code>DELETE</code> <code>/forum/threads/{id:\\d+}</code> Deletes a thread."},{"location":"php/api/rpc_api/#implementation-of-an-endpoint","title":"Implementation of an Endpoint","text":""},{"location":"php/api/rpc_api/#namespaces-for-endpoints","title":"Namespaces for Endpoints","text":"<p>Endpoints are defined using a strict rule set:</p> <ul> <li>The first path segment is a namespace that holds other objects.</li> <li>The namespaces <code>core</code>, <code>forum</code>, <code>blog</code>, <code>filebase</code> and <code>gallery</code> are reserved and MUST NOT be used by third parties.</li> <li>Segments MUST be lowercase ASCII and use the plural form.</li> <li>Parameters MAY appear starting with the third path segment and are defined with a leading colon.</li> <li>The name of a parameter MUST be unique within one endpoint.</li> </ul>"},{"location":"php/api/rpc_api/#convention-for-file-name-and-location","title":"Convention for File Name and Location","text":"<p>It is strongly recommended to place the files in <code>lib/system/endpoint/<namespace>/<objects>/<nameOfTheAction>.class.php</code>. The file name should reflect the action itself, following the pattern <code><Verb><Object></code>, for example, <code>DeleteFile</code> or <code>CreatePost</code>.</p>"},{"location":"php/api/rpc_api/#registering-the-route-of-an-endpoint","title":"Registering the Route of an Endpoint","text":"<p>Every endpoint needs to implement <code>wcf\\system\\endpoint\\IController</code> which defines the <code>__invoke()</code> method that will receive the <code>ServerRequestInterface</code> and an array containing any defined route parameters.</p> <p>Any endpoint can only ever serve a single verb, registered through the use of the <code>wcf\\system\\endpoint\\GetRequest</code>, <code>wcf\\system\\endpoint\\PostRequest</code> or <code>wcf\\system\\endpoint\\DeleteRequest</code> class attribute. The attribute expects a single parameter to define the endpoint\u2019s route.</p>"},{"location":"php/api/rpc_api/#placeholders","title":"Placeholders","text":"<p>The route implementation uses FastRoute which supports named placeholders through the <code>{name}</code> syntax. Optionally, a validation pattern can be specified to further narrow down the valid value of the placeholder: <code>{id:\\d+}</code></p>"},{"location":"php/api/rpc_api/#available-helper-methods","title":"Available Helper Methods","text":"<p>The <code>wcf\\http\\Helper</code> class offers a few helpful methods that simplify the validation and processing of request parameters.</p>"},{"location":"php/api/rpc_api/#mapapiparametersserverrequestinterface-request-string-classname","title":"<code>mapApiParameters(ServerRequestInterface $request, string $className)</code>","text":"<p>Takes the <code>$request</code> from the <code>__invoke()</code> call and maps the parameters against the provided class name. By convention it is recommended to use an internal class that is defined at the end of the class file and uses a <code>Parameters</code> suffix.</p> <p>For <code>GET</code> and <code>DELETE</code> requests the query string is used as the source. For <code>POST</code> requests the request body is mapped to the parameters.</p>"},{"location":"php/api/rpc_api/#fetchobjectfromrequestparameterintstring-objectid-string-classname","title":"<code>fetchObjectFromRequestParameter(int|string $objectID, string $className)</code>","text":"<p>Expects <code>$className</code> to be derived from <code>wcf\\data\\DatabaseObject</code> and attempts to fetch it using the <code>$objectID</code> parameter. Afterwards the object is tested to have a non-falsy object id, otherwise a <code>UserInputException</code> is raised.</p> <p>Returns the fetched object on success.</p>"},{"location":"php/api/rpc_api/#interacting-with-the-php-rpc-api-in-typescript","title":"Interacting with the PHP RPC API in TypeScript","text":"<p>You can find an introduction to the TypeScript API for the RPC API in the documentation.</p>"},{"location":"php/api/rss_feeds/","title":"RSS Feeds","text":"<p>The RSS feed API makes it possible to output content in the RSS format in accordance with the RSS 2.0 specifications. The ArticleRssFeedPage is available as a reference implementation.</p>"},{"location":"php/api/rss_feeds/#rssfeed","title":"<code>RssFeed</code>","text":"<p>RssFeed represents an RSS feed.</p> <p>After content has been added to the RSS feed, the feed can be output as XML using the <code>render</code> method.</p> <p>Example:</p> <pre><code>$feed = new RssFeed();\n...\n$output = $feed->render();\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedcategory","title":"<code>RssFeedCategory</code>","text":"<p>RssFeedCategory represents a category of a feed item. A feed item can have multiple categories.</p> <p>An instance of <code>RssFeedCategory</code> is created implicitly when a category is assigned to a feed item.</p> <p>Example:</p> <pre><code>$item = new RssFeedItem();\n$item->category('title', 'domain');\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedchannel","title":"<code>RssFeedChannel</code>","text":"<p>RssFeedChannel represents a channel within an RSS feed.</p> <p>Example:</p> <pre><code>$feed = new RssFeed();\n$channel = new RssFeedChannel();\n$channel\n ->title('title')\n ->description('description')\n ->link('https://www.example.net');\n$feed->channel($channel);\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedenclosure","title":"<code>RssFeedEnclosure</code>","text":"<p>RssFeedEnclosure represents an enclosure of a feed item. A feed item can only have one enclosure.</p> <p>An instance of <code>RssFeedEnclosure</code> is created implicitly when an enclosure is assigned to a feed item.</p> <p>Example:</p> <pre><code>$item = new RssFeedItem();\n$item->enclosure('url', /*size*/1024, 'mime/type');\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeeditem","title":"<code>RssFeedItem</code>","text":"<p>RssFeedItem represents an item in an RSS feed.</p> <p>Example:</p> <pre><code>$feed = new RssFeed();\n$channel = new RssFeedChannel();\n$feed->channel($channel);\n\n$item = new RssFeedItem();\n$item\n ->title('title')\n ->link('url');\n$channel->item($item);\n</code></pre>"},{"location":"php/api/rss_feeds/#rssfeedsource","title":"<code>RssFeedSource</code>","text":"<p>RssFeedSource represents the source of a feed item. A feed item can only have one source.</p> <p>An instance of <code>RssFeedSource</code> is created implicitly when an source is assigned to a feed item.</p> <p>Example:</p> <pre><code>$item = new RssFeedItem();\n$item->source('title', 'url');\n</code></pre>"},{"location":"php/api/sitemaps/","title":"Sitemaps","text":"<p>WoltLab Suite is capable of automatically creating a sitemap. This sitemap contains all static pages registered via the page package installation plugin and which may be indexed by search engines (checking the <code>allowSpidersToIndex</code> parameter and page permissions) and do not expect an object ID. Other pages have to be added to the sitemap as a separate object.</p> <p>The only prerequisite for sitemap objects is that the objects are instances of <code>wcf\\data\\DatabaseObject</code> and that there is a <code>wcf\\data\\DatabaseObjectList</code> implementation.</p> <p>First, we implement the PHP class, which provides us all database objects and optionally checks the permissions for a single object. The class must implement the interface <code>wcf\\system\\sitemap\\object\\ISitemapObjectObjectType</code>. However, in order to have some methods already implemented and ensure backwards compatibility, you should use the abstract class <code>wcf\\system\\sitemap\\object\\AbstractSitemapObjectObjectType</code>. The abstract class takes care of generating the <code>DatabaseObjectList</code> class name and list directly and implements optional methods with the default values. The only method that you have to implement yourself is the <code>getObjectClass()</code> method which returns the fully qualified name of the <code>DatabaseObject</code> class. The <code>DatabaseObject</code> class must implement the interface <code>wcf\\data\\ILinkableObject</code>.</p> <p>Other optional methods are:</p> <ul> <li>The <code>getLastModifiedColumn()</code> method returns the name of the column in the database where the last modification date is stored. If there is none, this method must return <code>null</code>.</li> <li>The <code>canView()</code> method checks whether the passed <code>DatabaseObject</code> is visible to the current user with the current user always being a guest.</li> <li>The <code>getObjectListClass()</code> method returns a non-standard <code>DatabaseObjectList</code> class name.</li> <li>The <code>getObjectList()</code> method returns the <code>DatabaseObjectList</code> instance. You can, for example, specify additional query conditions in the method.</li> </ul> <p>As an example, the implementation for users looks like this:</p> files/lib/system/sitemap/object/UserSitemapObject.class.php <pre><code><?php\nnamespace wcf\\system\\sitemap\\object;\nuse wcf\\data\\user\\User;\nuse wcf\\data\\DatabaseObject;\nuse wcf\\system\\WCF;\n\n/**\n * User sitemap implementation.\n *\n * @author Joshua Ruesweg\n * @copyright 2001-2017 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Sitemap\\Object\n * @since 3.1\n */\nclass UserSitemapObject extends AbstractSitemapObjectObjectType {\n /**\n * @inheritDoc\n */\n public function getObjectClass() {\n return User::class;\n }\n\n /**\n * @inheritDoc\n */\n public function getLastModifiedColumn() {\n return 'lastActivityTime';\n }\n\n /**\n * @inheritDoc\n */\n public function canView(DatabaseObject $object) {\n return WCF::getSession()->getPermission('user.profile.canViewUserProfile');\n }\n}\n</code></pre> <p>Next, the sitemap object must be registered as an object type:</p> <pre><code><type>\n <name>com.example.plugin.sitemap.object.user</name>\n <definitionname>com.woltlab.wcf.sitemap.object</definitionname>\n <classname>wcf\\system\\sitemap\\object\\UserSitemapObject</classname>\n <priority>0.5</priority>\n <changeFreq>monthly</changeFreq>\n <rebuildTime>259200</rebuildTime>\n</type>\n</code></pre> <p>In addition to the fully qualified class name, the object type definition <code>com.woltlab.wcf.sitemap.object</code> and the object type name, the parameters <code>priority</code>, <code>changeFreq</code> and <code>rebuildTime</code> must also be specified. <code>priority</code> (https://www.sitemaps.org/protocol.html#prioritydef) and <code>changeFreq</code> (https://www.sitemaps.org/protocol.html#changefreqdef) are specifications in the sitemaps protocol and can be changed by the user in the ACP. The <code>priority</code> should be <code>0.5</code> by default, unless there is an important reason to change it. The parameter <code>rebuildTime</code> specifies the number of seconds after which the sitemap should be regenerated.</p> <p>Finally, you have to create the language variable for the sitemap object. The language variable follows the pattern <code>wcf.acp.sitemap.objectType.{objectTypeName}</code> and is in the category <code>wcf.acp.sitemap</code>.</p>"},{"location":"php/api/user_activity_events/","title":"User Activity Events","text":"<p>User activity events provide content from different sources for the list of recent activities. Entries in the last activities consist of a title, optionally a description, the author and the date.</p>"},{"location":"php/api/user_activity_events/#registration-of-user-activity-events","title":"Registration of User Activity Events","text":"<p>To integrate user activity events into your package, you have to register object types for the defintion <code>com.woltlab.wcf.user.recentActivityEvent</code> and specify a class that implements the <code>wcf\\system\\user\\activity\\event\\IUserActivityEvent</code> interface:</p> <pre><code><type>\n <name>foo.bar.recentActivityEvent</name>\n <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>\n <classname>wcf\\system\\user\\activity\\event\\FooUserActivityEvent</classname>\n</type>\n</code></pre> <p>Specify multiple object types if you want to provide multiple types of user activity events. </p> <p>Example of the implementation of the <code>wcf\\system\\user\\activity\\event\\IUserActivityEvent</code> interface:</p> <pre><code><?php\n\nnamespace wcf\\system\\user\\activity\\event;\n\nuse wcf\\data\\user\\activity\\event\\ViewableUserActivityEvent;\nuse wcf\\system\\user\\activity\\event\\IUserActivityEvent;\nuse wcf\\system\\WCF;\nuse wcf\\util\\StringUtil;\n\nfinal class FooUserActivityEvent implements IUserActivityEvent\n{\n public function prepare(array $events)\n {\n foreach ($events as $event) {\n $this->handleEvent($event);\n }\n }\n\n private function handleEvent(ViewableUserActivityEvent $event): void\n {\n $foo = new FooObject($event->objectID);\n if ($foo === null) {\n $event->setIsOrphaned();\n return;\n }\n\n $event->setIsAccessible();\n $event->setTitle(WCF::getLanguage()->getDynamicVariable('foo.bar.recentActivity', [\n 'foo' => $foo,\n 'author' => $event->getUserProfile(),\n ]));\n $event->setDescription(\n StringUtil::encodeHTML(\n StringUtil::truncate($foo->getPlainTextDescription(), 500)\n ),\n true\n );\n $event->setLink($foo->getLink());\n }\n}\n</code></pre>"},{"location":"php/api/user_activity_events/#creating-user-activity-events","title":"Creating User Activity Events","text":"<p>If a relevant object is created, you have to use <code>UserActivityEventHandler::fireEvent()</code> which expects the name of the object type, the id of the object and optionally the language id, user id and the date.</p> <pre><code>UserActivityEventHandler::getInstance()->fireEvent(\n 'foo.bar.recentActivityEvent',\n 1, // object id\n 2, // language id\n 3, // user id\n \\TIME_NOW // date\n);\n</code></pre>"},{"location":"php/api/user_activity_events/#removing-user-activity-events","title":"Removing User Activity Events","text":"<p>To remove user activity events once objects are deleted, you have to use <code>UserActivityEventHandler::removeEvents()</code> which also expects the name of the object type and additionally an array with object ids:</p> <pre><code>UserActivityEventHandler::getInstance()->removeEvents(\n 'foo.bar.recentActivityEvent',\n [1, 2]\n);\n</code></pre>"},{"location":"php/api/user_activity_points/","title":"User Activity Points","text":"<p>Users get activity points whenever they create content to award them for their contribution. Activity points are used to determine the rank of a user and can also be used for user conditions, for example for automatic user group assignments.</p> <p>To integrate activity points into your package, you have to register an object type for the defintion <code>com.woltlab.wcf.user.activityPointEvent</code> and specify a default number of points:</p> <pre><code><type>\n <name>com.example.foo.activityPointEvent.bar</name>\n <definitionname>com.woltlab.wcf.user.activityPointEvent</definitionname>\n <points>10</points>\n</type>\n</code></pre> <p>The number of points awarded for this type of activity point event can be changed by the administrator in the admin control panel. For this form and the user activity point list shown in the frontend, you have to provide the language item</p> <pre><code>wcf.user.activityPoint.objectType.com.example.foo.activityPointEvent.bar\n</code></pre> <p>that contains the name of the content for which the activity points are awarded.</p> <p>If a relevant object is created, you have to use <code>UserActivityPointHandler::fireEvent()</code> which expects the name of the activity point event object type, the id of the object for which the points are awarded (though the object id is not used at the moment) and the user who gets the points:</p> <pre><code>UserActivityPointHandler::getInstance()->fireEvent(\n 'com.example.foo.activityPointEvent.bar',\n $bar->barID,\n $bar->userID\n);\n</code></pre> <p>To remove activity points once objects are deleted, you have to use <code>UserActivityPointHandler::removeEvents()</code> which also expects the name of the activity point event object type and additionally an array mapping the id of the user whose activity points will be reduced to the number of objects that are removed for the relevant user:</p> <pre><code>UserActivityPointHandler::getInstance()->removeEvents(\n 'com.example.foo.activityPointEvent.bar',\n [\n 1 => 1, // remove points for one object for user with id `1`\n 4 => 2 // remove points for two objects for user with id `4`\n ]\n);\n</code></pre>"},{"location":"php/api/user_notifications/","title":"User Notifications","text":"<p>WoltLab Suite includes a powerful user notification system that supports notifications directly shown on the website and emails sent immediately or on a daily basis.</p>"},{"location":"php/api/user_notifications/#objecttypexml","title":"<code>objectType.xml</code>","text":"<p>For any type of object related to events, you have to define an object type for the object type definition <code>com.woltlab.wcf.notification.objectType</code>:</p> objectType.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/objectType.xsd\">\n <import>\n <type>\n <name>com.woltlab.example.foo</name>\n <definitionname>com.woltlab.wcf.notification.objectType</definitionname>\n <classname>example\\system\\user\\notification\\object\\type\\FooUserNotificationObjectType</classname>\n <category>com.woltlab.example</category>\n </type>\n </import>\n</data>\n</code></pre> <p>The referenced class <code>FooUserNotificationObjectType</code> has to implement the IUserNotificationObjectType interface, which should be done by extending AbstractUserNotificationObjectType.</p> files/lib/system/user/notification/object/type/FooUserNotificationObjectType.class.php <pre><code><?php\nnamespace example\\system\\user\\notification\\object\\type;\nuse example\\data\\foo\\Foo;\nuse example\\data\\foo\\FooList;\nuse example\\system\\user\\notification\\object\\FooUserNotificationObject;\nuse wcf\\system\\user\\notification\\object\\type\\AbstractUserNotificationObjectType;\n\n/**\n * Represents a foo as a notification object type.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2017 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Example\\System\\User\\Notification\\Object\\Type\n */\nclass FooUserNotificationObjectType extends AbstractUserNotificationObjectType {\n /**\n * @inheritDoc\n */\n protected static $decoratorClassName = FooUserNotificationObject::class;\n\n /**\n * @inheritDoc\n */\n protected static $objectClassName = Foo::class;\n\n /**\n * @inheritDoc\n */\n protected static $objectListClassName = FooList::class;\n}\n</code></pre> <p>You have to set the class names of the database object (<code>$objectClassName</code>) and the related list (<code>$objectListClassName</code>). Additionally, you have to create a class that implements the IUserNotificationObject whose name you have to set as the value of the <code>$decoratorClassName</code> property.</p> files/lib/system/user/notification/object/FooUserNotificationObject.class.php <pre><code><?php\n\nnamespace example\\system\\user\\notification\\object;\n\nuse example\\data\\foo\\Foo;\nuse wcf\\data\\DatabaseObjectDecorator;\nuse wcf\\system\\user\\notification\\object\\IUserNotificationObject;\n\n/**\n * Represents a foo as a notification object.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2017 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Example\\System\\User\\Notification\\Object\n *\n * @method Foo getDecoratedObject()\n * @mixin Foo\n */\nclass FooUserNotificationObject extends DatabaseObjectDecorator implements IUserNotificationObject\n{\n /**\n * @inheritDoc\n */\n protected static $baseClass = Foo::class;\n\n /**\n * @inheritDoc\n */\n public function getTitle(): string\n {\n return $this->getDecoratedObject()->getTitle();\n }\n\n /**\n * @inheritDoc\n */\n public function getURL()\n {\n return $this->getDecoratedObject()->getLink();\n }\n\n /**\n * @inheritDoc\n */\n public function getAuthorID()\n {\n return $this->getDecoratedObject()->userID;\n }\n}\n</code></pre> <ul> <li>The <code>getTitle()</code> method returns the title of the object. In this case, we assume that the <code>Foo</code> class has implemented the ITitledObject interface so that the decorated <code>Foo</code> can handle this method call itself.</li> <li>The <code>getURL()</code> method returns the link to the object. As for the <code>getTitle()</code>, we assume that the <code>Foo</code> class has implemented the ILinkableObject interface so that the decorated <code>Foo</code> can also handle this method call itself.</li> <li>The <code>getAuthorID()</code> method returns the id of the user who created the decorated <code>Foo</code> object. We assume that <code>Foo</code> objects have a <code>userID</code> property that contains this id.</li> </ul>"},{"location":"php/api/user_notifications/#usernotificationeventxml","title":"<code>userNotificationEvent.xml</code>","text":"<p>Each event that you fire in your package needs to be registered using the user notification event package installation plugin. An example file might look like this:</p> userNotificationEvent.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/2019/userNotificationEvent.xsd\">\n <import>\n <event>\n <name>bar</name>\n <objecttype>com.woltlab.example.foo</objecttype>\n <classname>example\\system\\user\\notification\\event\\FooUserNotificationEvent</classname>\n <preset>1</preset>\n </event>\n </import>\n</data>\n</code></pre> <p>Here, you reference the user notification object type created via <code>objectType.xml</code>. The referenced class in the <code><classname></code> element has to implement the IUserNotificationEvent interface by extending the AbstractUserNotificationEvent class or the AbstractSharedUserNotificationEvent class if you want to pre-load additional data before processing notifications. In <code>AbstractSharedUserNotificationEvent::prepare()</code>, you can, for example, tell runtime caches to prepare to load certain objects which then are loaded all at once when the objects are needed.</p> files/lib/system/user/notification/event/FooUserNotificationEvent.class.php <pre><code><?php\n\nnamespace example\\system\\user\\notification\\event;\n\nuse example\\system\\cache\\runtime\\BazRuntimeCache;\nuse example\\system\\user\\notification\\object\\FooUserNotificationObject;\nuse wcf\\system\\email\\Email;\nuse wcf\\system\\request\\LinkHandler;\nuse wcf\\system\\user\\notification\\event\\AbstractSharedUserNotificationEvent;\n\n/**\n * Notification event for foos.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2017 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Example\\System\\User\\Notification\\Event\n *\n * @method FooUserNotificationObject getUserNotificationObject()\n */\nclass FooUserNotificationEvent extends AbstractSharedUserNotificationEvent\n{\n /**\n * @inheritDoc\n */\n protected $stackable = true;\n\n /** @noinspection PhpMissingParentCallCommonInspection */\n /**\n * @inheritDoc\n */\n public function checkAccess()\n {\n $this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));\n\n if (!$this->getUserNotificationObject()->isAccessible()) {\n // do some cleanup, if necessary\n\n return false;\n }\n\n return true;\n }\n\n /** @noinspection PhpMissingParentCallCommonInspection */\n /**\n * @inheritDoc\n */\n public function getEmailMessage($notificationType = 'instant')\n {\n $this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));\n\n $messageID = '<com.woltlab.example.baz/' . $this->getUserNotificationObject()->bazID . '@' . Email::getHost() . '>';\n\n return [\n 'application' => 'example',\n 'in-reply-to' => [$messageID],\n 'message-id' => 'com.woltlab.example.foo/' . $this->getUserNotificationObject()->fooID,\n 'references' => [$messageID],\n 'template' => 'email_notification_foo'\n ];\n }\n\n /**\n * @inheritDoc\n * @since 5.0\n */\n public function getEmailTitle()\n {\n $this->getUserNotificationObject()->setBaz(BazRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->bazID));\n\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.mail.title', [\n 'userNotificationObject' => $this->getUserNotificationObject()\n ]);\n }\n\n /** @noinspection PhpMissingParentCallCommonInspection */\n /**\n * @inheritDoc\n */\n public function getEventHash()\n {\n return sha1($this->eventID . '-' . $this->getUserNotificationObject()->bazID);\n }\n\n /**\n * @inheritDoc\n */\n public function getLink(): string\n {\n return LinkHandler::getInstance()->getLink('Foo', [\n 'application' => 'example',\n 'object' => $this->getUserNotificationObject()->getDecoratedObject()\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function getMessage()\n {\n $authors = $this->getAuthors();\n $count = count($authors);\n\n if ($count > 1) {\n if (isset($authors[0])) {\n unset($authors[0]);\n }\n $count = count($authors);\n\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.message.stacked', [\n 'author' => $this->author,\n 'authors' => array_values($authors),\n 'count' => $count,\n 'guestTimesTriggered' => $this->notification->guestTimesTriggered,\n 'message' => $this->getUserNotificationObject(),\n 'others' => $count - 1\n ]);\n }\n\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.message', [\n 'author' => $this->author,\n 'userNotificationObject' => $this->getUserNotificationObject()\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function getTitle(): string\n {\n $count = count($this->getAuthors());\n if ($count > 1) {\n return $this->getLanguage()->getDynamicVariable('example.foo.notification.title.stacked', [\n 'count' => $count,\n 'timesTriggered' => $this->notification->timesTriggered\n ]);\n }\n\n return $this->getLanguage()->get('example.foo.notification.title');\n }\n\n /**\n * @inheritDoc\n */\n protected function prepare()\n {\n BazRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->bazID);\n }\n}\n</code></pre> <ul> <li>The <code>$stackable</code> property is <code>false</code> by default and has to be explicitly set to <code>true</code> if stacking of notifications should be enabled. Stacking of notification does not create new notifications for the same event for a certain object if the related action as been triggered by different users. For example, if something is liked by one user and then liked again by another user before the recipient of the notification has confirmed it, the existing notification will be amended to include both users who liked the content. Stacking can thus be used to avoid cluttering the notification list of users.</li> <li>The <code>checkAccess()</code> method makes sure that the active user still has access to the object related to the notification. If that is not the case, the user notification system will automatically deleted the user notification based on the return value of the method. If you have any cached values related to notifications, you should also reset these values here.</li> <li>The <code>getEmailMessage()</code> method return data to create the instant email or the daily summary email. For instant emails (<code>$notificationType = 'instant'</code>), you have to return an array like the one shown in the code above with the following components:</li> <li><code>application</code>: abbreviation of application</li> <li><code>in-reply-to</code> (optional): message id of the notification for the parent item and used to improve the ordering in threaded email clients</li> <li><code>message-id</code> (optional): message id of the notification mail and has to be used in <code>in-reply-to</code> and <code>references</code> for follow up mails</li> <li><code>references</code> (optional): all of the message ids of parent items (i.e. recursive in-reply-to)</li> <li><code>template</code>: name of the template used to render the email body, should start with <code>email_</code></li> <li><code>variables</code> (optional): template variables passed to the email template where they can be accessed via <code>$notificationContent[variables]</code></li> </ul> <p>For daily emails (<code>$notificationType = 'daily'</code>), only <code>application</code>, <code>template</code>, and <code>variables</code> are supported. - The <code>getEmailTitle()</code> returns the title of the instant email sent to the user. By default, <code>getEmailTitle()</code> simply calls <code>getTitle()</code>. - The <code>getEventHash()</code> method returns a hash by which user notifications are grouped. Here, we want to group them not by the actual <code>Foo</code> object but by its parent <code>Baz</code> object and thus overwrite the default implementation provided by <code>AbstractUserNotificationEvent</code>. - The <code>getLink()</code> returns the link to the <code>Foo</code> object the notification belongs to. - The <code>getMessage()</code> method and the <code>getTitle()</code> return the message and the title of the user notification respectively. By checking the value of <code>count($this->getAuthors())</code>, we check if the notification is stacked, thus if the event has been triggered for multiple users so that different languages items are used. If your notification event does not support stacking, this distinction is not necessary. - The <code>prepare()</code> method is called for each user notification before all user notifications are rendered. This allows to tell runtime caches to prepare to load objects later on (see Runtime Caches).</p>"},{"location":"php/api/user_notifications/#firing-events","title":"Firing Events","text":"<p>When the action related to a user notification is executed, you can use <code>UserNotificationHandler::fireEvent()</code> to create the notifications:</p> <pre><code>$recipientIDs = []; // fill with user ids of the recipients of the notification\nUserNotificationHandler::getInstance()->fireEvent(\n 'bar', // event name\n 'com.woltlab.example.foo', // event object type name\n new FooUserNotificationObject(new Foo($fooID)), // object related to the event\n $recipientIDs\n);\n</code></pre>"},{"location":"php/api/user_notifications/#marking-notifications-as-confirmed","title":"Marking Notifications as Confirmed","text":"<p>In some instances, you might want to manually mark user notifications as confirmed without the user manually confirming them, for example when they visit the page that is related to the user notification. In this case, you can use <code>UserNotificationHandler::markAsConfirmed()</code>:</p> <pre><code>$recipientIDs = []; // fill with user ids of the recipients of the notification\n$fooIDs = []; // fill with ids of related foo objects\nUserNotificationHandler::getInstance()->markAsConfirmed(\n 'bar', // event name\n 'com.woltlab.example.foo', // event object type name\n $recipientIDs,\n $fooIDs\n);\n</code></pre>"},{"location":"php/api/form_builder/dependencies/","title":"Form Node Dependencies","text":"<p>Form node dependencies allow to make parts of a form dynamically available or unavailable depending on the values of form fields. Dependencies are always added to the object whose visibility is determined by certain form fields. They are not added to the form field\u2019s whose values determine the visibility! An example is a text form field that should only be available if a certain option from a single selection form field is selected. Form builder\u2019s dependency system supports such scenarios and also automatically making form containers unavailable once all of its children are unavailable.</p> <p>If a form node has multiple dependencies and one of them is not met, the form node is unavailable. A form node not being available due to dependencies has to the following consequences:</p> <ul> <li>The form field value is not validated. It is, however, read from the request data as all request data needs to be read first so that the dependencies can determine whether they are met or not.</li> <li>No data is collected for the form field and returned by <code>IFormDocument::getData()</code>.</li> <li>In the actual form, the form field will be hidden via JavaScript.</li> </ul>"},{"location":"php/api/form_builder/dependencies/#iformfielddependency","title":"<code>IFormFieldDependency</code>","text":"<p>The basis of the dependencies is the <code>IFormFieldDependency</code> interface that has to be implemented by every dependency class. The interface requires the following methods:</p> <ul> <li><code>checkDependency()</code> checks if the dependency is met, thus if the dependant form field should be considered available.</li> <li><code>dependentNode(IFormNode $node)</code> and <code>getDependentNode()</code> can be used to set and get the node whose availability depends on the referenced form field. <code>TFormNode::addDependency()</code> automatically calls <code>dependentNode(IFormNode $node)</code> with itself as the dependent node, thus the dependent node is automatically set by the API.</li> <li><code>field(IFormField $field)</code> and <code>getField()</code> can be used to set and get the form field that influences the availability of the dependent node.</li> <li><code>fieldId($fieldId)</code> and <code>getFieldId()</code> can be used to set and get the id of the form field that influences the availability of the dependent node.</li> <li><code>getHtml()</code> returns JavaScript code required to ensure the dependency in the form output.</li> <li><code>getId()</code> returns the id of the dependency used to identify multiple dependencies of the same form node.</li> <li><code>static create($id)</code> is the factory method that has to be used to create new dependencies with the given id.</li> </ul> <p><code>AbstractFormFieldDependency</code> provides default implementations for all methods except for <code>checkDependency()</code>.</p> <p>Using <code>fieldId($fieldId)</code> instead of <code>field(IFormField $field)</code> makes sense when adding the dependency directly when setting up the form:</p> <pre><code>$container->appendChildren([\n FooField::create('a'),\n\n BarField::create('b')\n ->addDependency(\n BazDependency::create('a')\n ->fieldId('a')\n )\n]);\n</code></pre> <p>Here, without an additional assignment, the first field with id <code>a</code> cannot be accessed thus <code>fieldId($fieldId)</code> should be used as the id of the relevant field is known. When the form is built, all dependencies that only know the id of the relevant field and do not have a reference for the actual object are populated with the actual form field objects.</p>"},{"location":"php/api/form_builder/dependencies/#default-dependencies","title":"Default Dependencies","text":"<p>WoltLab Suite Core delivers the following default dependency classes by default:</p>"},{"location":"php/api/form_builder/dependencies/#nonemptyformfielddependency","title":"<code>NonEmptyFormFieldDependency</code>","text":"<p><code>NonEmptyFormFieldDependency</code> can be used to ensure that a node is only shown if the value of the referenced form field is not empty (being empty is determined using PHP\u2019s <code>empty()</code> language construct).</p>"},{"location":"php/api/form_builder/dependencies/#emptyformfielddependency","title":"<code>EmptyFormFieldDependency</code>","text":"<p>This is the inverse of <code>NonEmptyFormFieldDependency</code>, checking for <code>!empty()</code>.</p>"},{"location":"php/api/form_builder/dependencies/#valueformfielddependency","title":"<code>ValueFormFieldDependency</code>","text":"<p><code>ValueFormFieldDependency</code> can be used to ensure that a node is only shown if the value of the referenced form field is from a specified list of of values (see methods <code>values($values)</code> and <code>getValues()</code>). Additionally, via <code>negate($negate = true)</code> and <code>isNegated()</code>, the logic can also be inverted by requiring the value of the referenced form field not to be from a specified list of values.</p>"},{"location":"php/api/form_builder/dependencies/#valueintervalformfielddependency","title":"<code>ValueIntervalFormFieldDependency</code>","text":"<p><code>ValueIntervalFormFieldDependency</code> can be used to ensure that a node is only shown if the value of the referenced form field is in a specific interval whose boundaries are set via <code>minimum(?float $minimum = null)</code> and <code>maximum(?float $maximum = null)</code>.</p>"},{"location":"php/api/form_builder/dependencies/#isnotclickedformfielddependency","title":"<code>IsNotClickedFormFieldDependency</code>","text":"<p><code>IsNotClickedFormFieldDependency</code> is a special dependency for <code>ButtonFormField</code>s. Refer to the documentation of <code>ButtomFormField</code> for details.</p>"},{"location":"php/api/form_builder/dependencies/#javascript-implementation","title":"JavaScript Implementation","text":"<p>To ensure that dependent node are correctly shown and hidden when changing the value of referenced form fields, every PHP dependency class has a corresponding JavaScript module that checks the dependency in the browser. Every JavaScript dependency has to extend <code>WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract</code> and implement the <code>checkDependency()</code> function, the JavaScript version of <code>IFormFieldDependency::checkDependency()</code>.</p> <p>All of the JavaScript dependency objects automatically register themselves during initialization with the <code>WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager</code> which takes care of checking the dependencies at the correct points in time.</p> <p>Additionally, the dependency manager also ensures that form containers in which all children are hidden due to dependencies are also hidden and, once any child becomes available again, makes the container also available again. Every form container has to create a matching form container dependency object from a module based on <code>WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract</code>.</p>"},{"location":"php/api/form_builder/dependencies/#examples","title":"Examples","text":"<p>If <code>$booleanFormField</code> is an instance of <code>BooleanFormField</code> and the text form field <code>$textFormField</code> should only be available if \u201cYes\u201d has been selected, the following condition has to be set up:</p> <pre><code>$textFormField->addDependency(\n NonEmptyFormFieldDependency::create('booleanFormField')\n ->field($booleanFormField)\n);\n</code></pre> <p>If <code>$singleSelectionFormField</code> is an instance of <code>SingleSelectionFormField</code> that offers the options <code>1</code>, <code>2</code>, and <code>3</code> and <code>$textFormField</code> should only be available if <code>1</code> or <code>3</code> is selected, the following condition has to be set up:</p> <pre><code>$textFormField->addDependency(\n ValueFormFieldDependency::create('singleSelectionFormField')\n ->field($singleSelectionFormField)\n ->values([1, 3])\n);\n</code></pre> <p>If, in contrast, <code>$singleSelectionFormField</code> has many available options and <code>7</code> is the only option for which <code>$textFormField</code> should not be available, <code>negate()</code> should be used:</p> <pre><code>$textFormField->addDependency(\n ValueFormFieldDependency::create('singleSelectionFormField')\n ->field($singleSelectionFormField)\n ->values([7])\n ->negate()\n);\n</code></pre>"},{"location":"php/api/form_builder/form_fields/","title":"Form Builder Fields","text":""},{"location":"php/api/form_builder/form_fields/#abstract-form-fields","title":"Abstract Form Fields","text":"<p>The following form field classes cannot be instantiated directly because they are abstract, but they can/must be used when creating own form field classes. </p>"},{"location":"php/api/form_builder/form_fields/#abstractformfield","title":"<code>AbstractFormField</code>","text":"<p><code>AbstractFormField</code> is the abstract default implementation of the <code>IFormField</code> interface and it is expected that every implementation of <code>IFormField</code> implements the interface by extending this class.</p>"},{"location":"php/api/form_builder/form_fields/#abstractnumericformfield","title":"<code>AbstractNumericFormField</code>","text":"<p><code>AbstractNumericFormField</code> is the abstract implementation of a form field handling a single numeric value. The class implements <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, <code>IInputModeFormField</code>, <code>IMaximumFormField</code>, <code>IMinimumFormField</code>, <code>INullableFormField</code>, <code>IPlaceholderFormField</code> and <code>ISuffixedFormField</code>. If the property <code>$integerValues</code> is <code>true</code>, the form field works with integer values, otherwise it works with floating point numbers. The methods <code>step($step = null)</code> and <code>getStep()</code> can be used to set and get the step attribute of the <code>input</code> element. The default step for form fields with integer values is <code>1</code>. Otherwise, the default step is <code>any</code>.</p>"},{"location":"php/api/form_builder/form_fields/#abstractformfielddecorator","title":"<code>AbstractFormFieldDecorator</code>","text":"<p><code>AbstractFormFieldDecorator</code> is a default implementation of a decorator for form fields that forwards calls to all methods defined in <code>IFormField</code> to the respective method of the decorated object. The class implements <code>IFormfield</code>. If the implementation of a more specific interface is required then the remaining methods must be implemented in the concrete decorator derived from <code>AbstractFormFieldDecorator</code> and the type of the <code>$field</code> property must be narrowed appropriately.</p>"},{"location":"php/api/form_builder/form_fields/#general-form-fields","title":"General Form Fields","text":"<p>The following form fields are general reusable fields without any underlying context.</p>"},{"location":"php/api/form_builder/form_fields/#booleanformfield","title":"<code>BooleanFormField</code>","text":"<p><code>BooleanFormField</code> is used for boolean (<code>0</code> or <code>1</code>, <code>yes</code> or <code>no</code>) values. Objects of this class require a label. The return value of <code>getSaveValue()</code> is the integer representation of the boolean value, i.e. <code>0</code> or <code>1</code>. The class implements <code>IAttributeFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, and <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>BooleanFormField::create('example')\n ->label('foo.bar.example')\n ->value(true)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#checkboxformfield","title":"<code>CheckboxFormField</code>","text":"<p><code>CheckboxFormField</code> extends <code>BooleanFormField</code> and offers a simple HTML checkbox.</p> <p>Example:</p> <pre><code>CheckboxFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#classnameformfield","title":"<code>ClassNameFormField</code>","text":"<p><code>ClassNameFormField</code> is a text form field that supports additional settings, specific to entering a PHP class name:</p> <ul> <li><code>classExists($classExists = true)</code> and <code>getClassExists()</code> can be used to ensure that the entered class currently exists in the installation. By default, the existance of the entered class is required.</li> <li><code>implementedInterface($interface)</code> and <code>getImplementedInterface()</code> can be used to ensure that the entered class implements the specified interface. By default, no interface is required.</li> <li><code>parentClass($parentClass)</code> and <code>getParentClass()</code> can be used to ensure that the entered class extends the specified class. By default, no parent class is required.</li> <li><code>instantiable($instantiable = true)</code> and <code>isInstantiable()</code> can be used to ensure that the entered class is instantiable. By default, entered classes have to instantiable.</li> </ul> <p>Additionally, the default id of a <code>ClassNameFormField</code> object is <code>className</code>, the default label is <code>wcf.form.field.className</code>, and if either an interface or a parent class is required, a default description is set if no description has already been set (<code>wcf.form.field.className.description.interface</code> and <code>wcf.form.field.className.description.parentClass</code>, respectively).</p> <p>Example:</p> <pre><code>ClassNameFormField::create('example')\n ->label('foo.bar.example')\n ->classExists()\n ->implementedInterface(ExampleInterface::class)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#currencyformfield","title":"<code>CurrencyFormField</code>","text":"<p><code>CurrencyFormField</code> is an implementation designed for two-decimal currencies like EUR or USD. The API expect amounts to be provided in the smallest unit. For example, to set a value to 10 USD, provide an amount value of 1000 (i.e., 1000 cents).</p> <p>Example:</p> <pre><code>CurrencyFormField::create('name')\n ->currency('USD')\n ->value(1000); // = USD 10\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#dateformfield","title":"<code>DateFormField</code>","text":"<p><code>DateFormField</code> is a form field to enter a date (and optionally a time). The class implements <code>IAttributeFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, and <code>INullableFormField</code>. The following methods are specific to this form field class:</p> <ul> <li><code>earliestDate($earliestDate)</code> and <code>getEarliestDate()</code> can be used to get and set the earliest selectable/valid date and <code>latestDate($latestDate)</code> and <code>getLatestDate()</code> can be used to get and set the latest selectable/valid date. The date passed to the setters must have the same format as set via <code>saveValueFormat()</code>. If a custom format is used, that format has to be set via <code>saveValueFormat()</code> before calling any of the setters.</li> <li><code>saveValueFormat($saveValueFormat)</code> and <code>getSaveValueFormat()</code> can be used to specify the date format of the value returned by <code>getSaveValue()</code>. By default, <code>U</code> is used as format. The PHP manual provides an overview of supported formats.</li> <li><code>supportTime($supportsTime = true)</code> and <code>supportsTime()</code> can be used to toggle whether, in addition to a date, a time can also be specified. By default, specifying a time is disabled.</li> </ul> <p>Example:</p> <pre><code>DateFormField::create('example')\n ->label('foo.bar.example')\n ->saveValueFormat('Y-m-d')\n ->value(DateUtil::format(DateUtil::getDateTimeByTimestamp(TIME_NOW), 'Y-m-d'))\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#descriptionformfield","title":"<code>DescriptionFormField</code>","text":"<p><code>DescriptionFormField</code> is a multi-line text form field with <code>description</code> as the default id and <code>wcf.global.description</code> as the default label.</p> <p>Example:</p> <pre><code>DescriptionFormField::create('example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#emailformfield","title":"<code>EmailFormField</code>","text":"<p><code>EmailFormField</code> is a form field to enter an email address which is internally validated using <code>UserUtil::isValidEmail()</code>. The class implements <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, <code>II18nFormField</code>, <code>IImmutableFormField</code>, <code>IInputModeFormField</code>, <code>IPatternFormField</code>, and <code>IPlaceholderFormField</code>.</p> <p>Example:</p> <pre><code>EmailFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#floatformfield","title":"<code>FloatFormField</code>","text":"<p><code>FloatFormField</code> is an implementation of AbstractNumericFormField for floating point numbers.</p> <p>Example:</p> <pre><code>FloatFormField::create('example')\n ->label('foo.bar.example')\n ->value(0.5)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#hiddenformfield","title":"<code>HiddenFormField</code>","text":"<p><code>HiddenFormField</code> is a form field without any user-visible UI. Even though the form field is invisible to the user, the value can still be modified by the user, e.g. by leveraging the web browsers developer tools. The <code>HiddenFormField</code> must not be used to transfer sensitive information or information that the user should not be able to modify.</p> <p>Example:</p> <pre><code>HiddenFormField::create('example')\n ->value('hidden value')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#iconformfield","title":"<code>IconFormField</code>","text":"<p><code>IconFormField</code> is a form field to select a FontAwesome icon.</p> <p>Example:</p> <pre><code>IconFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#integerformfield","title":"<code>IntegerFormField</code>","text":"<p><code>IntegerFormField</code> is an implementation of AbstractNumericFormField for integers.</p> <p>Example:</p> <pre><code>IntegerFormField::create('example')\n ->label('foo.bar.example')\n ->value(10)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#isdisabledformfield","title":"<code>IsDisabledFormField</code>","text":"<p><code>IsDisabledFormField</code> is a boolean form field with <code>isDisabled</code> as the default id.</p> <p>Example:</p> <pre><code>IsDisabledFormField::create()\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#itemlistformfield","title":"<code>ItemListFormField</code>","text":"<p><code>ItemListFormField</code> is a form field in which multiple values can be entered and returned in different formats as save value. The class implements <code>IAttributeFormField</code>, <code>IAutoFocusFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, and <code>IMultipleFormField</code>. The <code>saveValueType($saveValueType)</code> and <code>getSaveValueType()</code> methods are specific to this form field class and determine the format of the save value. The following save value types are supported:</p> <ul> <li><code>ItemListFormField::SAVE_VALUE_TYPE_ARRAY</code> adds a custom data processor that writes the form field data directly in the parameters array and not in the data sub-array of the parameters array.</li> <li><code>ItemListFormField::SAVE_VALUE_TYPE_CSV</code> lets the value be returned as a string in which the values are concatenated by commas.</li> <li><code>ItemListFormField::SAVE_VALUE_TYPE_NSV</code> lets the value be returned as a string in which the values are concatenated by <code>\\n</code>.</li> <li><code>ItemListFormField::SAVE_VALUE_TYPE_SSV</code> lets the value be returned as a string in which the values are concatenated by spaces.</li> </ul> <p>By default, <code>ItemListFormField::SAVE_VALUE_TYPE_CSV</code> is used.</p> <p>If <code>ItemListFormField::SAVE_VALUE_TYPE_ARRAY</code> is used as save value type, <code>ItemListFormField</code> objects register a custom form field data processor to add the relevant array into the <code>$parameters</code> array directly using the object property as the array key.</p> <p>Example:</p> <pre><code>ItemListFormField::create('example')\n ->label('foo.bar.example')\n ->saveValueType(ItemListFormField::SAVE_VALUE_TYPE_CSV)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#languageitemformnode","title":"<code>LanguageItemFormNode</code>","text":"<p><code>LanguageItemFormNode</code> is a form node that shows a language item without any surrounding HTML code.</p> <p>Example:</p> <pre><code>LanguageItemFormNode::create('name')\n ->languageItem('name_of_language_item');\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#multilinetextformfield","title":"<code>MultilineTextFormField</code>","text":"<p><code>MultilineTextFormField</code> is a text form field that supports multiple rows of text. The methods <code>rows($rows)</code> and <code>getRows()</code> can be used to set and get the number of rows of the <code>textarea</code> elements. The default number of rows is <code>10</code>. These methods do not, however, restrict the number of text rows that can be entered.</p> <p>Example:</p> <pre><code>MultilineTextFormField::create('example')\n ->label('foo.bar.example')\n ->maximumLength(5000)\n ->rows(5)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#multipleselectionformfield","title":"<code>MultipleSelectionFormField</code>","text":"<p><code>MultipleSelectionFormField</code> is a form fields that allows the selection of multiple options out of a predefined list of available options. The class implements <code>IAttributeFormField</code>, <code>ICssClassFormField</code>, <code>IFilterableSelectionFormField</code>, and <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>MultipleSelectionFormField::create('example')\n ->label('foo.bar.example')\n ->options([\n 1 => 'one',\n 2 => 'two',\n ])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#noticeformnode","title":"<code>NoticeFormNode</code>","text":"<p><code>NoticeFormNode</code> is a form node that shows a notice without any surrounding HTML code.</p> <p>Example:</p> <pre><code>NoticeFormNode::create('name')\n ->type(NoticeFormNodeType::Success)\n ->languageItem('name_of_language_item');\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#radiobuttonformfield","title":"<code>RadioButtonFormField</code>","text":"<p><code>RadioButtonFormField</code> is a form fields that allows the selection of a single option out of a predefined list of available options using radiobuttons. The class implements <code>IAttributeFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, and <code>ISelectionFormField</code>.</p> <p>Example:</p> <pre><code>RadioButtonFormField::create('example')\n ->label('foo.bar.example')\n ->options([\n 1 => 'one',\n 2 => 'two',\n ])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#ratingformfield","title":"<code>RatingFormField</code>","text":"<p><code>RatingFormField</code> is a form field to set a rating for an object. The class implements <code>IImmutableFormField</code>, <code>IMaximumFormField</code>, <code>IMinimumFormField</code>, and <code>INullableFormField</code>. Form fields of this class have <code>rating</code> as their default id, <code>wcf.form.field.rating</code> as their default label, <code>1</code> as their default minimum, and <code>5</code> as their default maximum. For this field, the minimum and maximum refer to the minimum and maximum rating an object can get. When the field is shown, there will be <code>maximum() - minimum() + 1</code> icons be shown with additional CSS classes that can be set and gotten via <code>defaultCssClasses(array $cssClasses)</code> and <code>getDefaultCssClasses()</code>. If a rating values is set, the first <code>getValue()</code> icons will instead use the classes that can be set and gotten via <code>activeCssClasses(array $cssClasses)</code> and <code>getActiveCssClasses()</code>. By default, the only default class is <code>star-o</code> and the active classes are <code>star</code> and <code>orange</code>. </p> <p>Example:</p> <pre><code>RatingFormField::create('example')\n ->label('foo.bar.example')\n ->minimum(1)\n ->maximum(5)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#selectformfield","title":"<code>SelectFormField</code>","text":"<p><code>SelectFormField</code> is a form fields that allows the selection of a single option out of a predefined list of available options. The class implements <code>ICssClassFormField</code> and <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>SelectFormField::create('select')\n ->options(['option1', 'option2', 'option3']);\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#showorderformfield","title":"<code>ShowOrderFormField</code>","text":"<p><code>ShowOrderFormField</code> is a single selection form field for which the selected value determines the position at which an object is shown. The show order field provides a list of all siblings and the object will be positioned after the selected sibling. To insert objects at the very beginning, the <code>options()</code> automatically method prepends an additional option for that case so that only the existing siblings need to be passed. The default id of instances of this class is <code>showOrder</code> and their default label is <code>wcf.form.field.showOrder</code>.</p> <p>It is important that the relevant object property is always kept updated. Whenever a new object is added or an existing object is edited or delete, the values of the other objects have to be adjusted to ensure consecutive numbering.</p> <p>Example:</p> <pre><code>ShowOrderFormField::create('example')\n ->options(new FooList())\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#singleselectionformfield","title":"<code>SingleSelectionFormField</code>","text":"<p><code>SingleSelectionFormField</code> is a form fields that allows the selection of a single option out of a predefined list of available options. The class implements <code>ICssClassFormField</code>, <code>IFilterableSelectionFormField</code>, <code>IImmutableFormField</code>, and <code>INullableFormField</code>. If the field is nullable and the current form field value is considered <code>empty</code> by PHP, <code>null</code> is returned as the save value.</p> <p>Example:</p> <pre><code>SingleSelectionFormField::create('example')\n ->options(['option1', 'option2', 'option3'])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#sortorderformfield","title":"<code>SortOrderFormField</code>","text":"<p><code>SingleSelectionFormField</code> is a single selection form field with default id <code>sortOrder</code>, default label <code>wcf.global.showOrder</code> and default options <code>ASC: wcf.global.sortOrder.ascending</code> and <code>DESC: wcf.global.sortOrder.descending</code>.</p> <p>Example:</p> <pre><code>SingleSelectionFormField::create('example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#textformfield","title":"<code>TextFormField</code>","text":"<p><code>TextFormField</code> is a form field that allows entering a single line of text. The class implements <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>ICssClassFormField</code>, <code>IImmutableFormField</code>, <code>II18nFormField</code>, <code>IInputModeFormField</code>, <code>IMaximumLengthFormField</code>, <code>IMinimumLengthFormField</code>, <code>IPatternFormField</code>, and <code>IPlaceholderFormField</code>.</p> <p>Example:</p> <pre><code>TextFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#titleformfield","title":"<code>TitleFormField</code>","text":"<p><code>TitleFormField</code> is a text form field with <code>title</code> as the default id and <code>wcf.global.title</code> as the default label.</p> <p>Example:</p> <pre><code>TitleFormField::create()\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#urlformfield","title":"<code>UrlFormField</code>","text":"<p><code>UrlFormField</code> is a text form field whose values are checked via <code>Url::is()</code>.</p> <p>Example:</p> <pre><code>UrlFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#specific-fields","title":"Specific Fields","text":"<p>The following form fields are reusable fields that generally are bound to a certain API or <code>DatabaseObject</code> implementation.</p>"},{"location":"php/api/form_builder/form_fields/#aclformfield","title":"<code>AclFormField</code>","text":"<p><code>AclFormField</code> is used for setting up acl values for specific objects. The class implements <code>IObjectTypeFormField</code> and requires an object type of the object type definition <code>com.woltlab.wcf.acl</code>. Additionally, the class provides the methods <code>categoryName($categoryName)</code> and <code>getCategoryName()</code> that allow setting a specific name or filter for the acl option categories whose acl options are shown. A category name of <code>null</code> signals that no category filter is used.</p> <p>Since version 5.5, the category name also supports filtering using a wildcard like <code>user.*</code>, see WoltLab/WCF#4355.</p> <p><code>AclFormField</code> objects register a custom form field data processor to add the relevant ACL object type id into the <code>$parameters</code> array directly using <code>{$objectProperty}_aclObjectTypeID</code> as the array key. The relevant database object action method is expected, based on the given ACL object type id, to save the ACL option values appropriately.</p>"},{"location":"php/api/form_builder/form_fields/#example","title":"Example","text":"<p>The following source code creates an <code>AclFormField</code> with the object type <code>foo.bar.acl</code>:</p> <pre><code>FormContainer::create('aclContainer')\n ->label('foo.bar.acl')\n ->appendChildren([\n AclFormField::create('acl')\n ->objectType('foo.bar.acl')\n ])\n</code></pre> <p>After submitting the form, the id of the object type is passed to the DatabaseObjectAction and can be used there to process the data with the help of the <code>ACLHandler</code>.</p> <pre><code>use wcf\\data\\AbstractDatabaseObjectAction;\nuse wcf\\system\\acl\\ACLHandler;\n\nclass FooAction extends AbstractDatabaseObjectAction {\n public function create() {\n $object = parent::create();\n\n if (!empty($this->parameters['acl_aclObjectTypeID'])) {\n ACLHandler::getInstance()->save($object->getObjectID(), $this->parameters['acl_aclObjectTypeID']);\n }\n }\n}\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#buttonformfield","title":"<code>ButtonFormField</code>","text":"<p><code>ButtonFormField</code> shows a submit button as part of the form. The class implements <code>IAttributeFormField</code> and <code>ICssClassFormField</code>.</p> <p>Specifically for this form field, there is the <code>IsNotClickedFormFieldDependency</code> dependency with which certain parts of the form will only be processed if the relevent button has not clicked. </p> <p>Example:</p> <pre><code>ButtonFormField::create('example')\n ->buttonLabel('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#captchaformfield","title":"<code>CaptchaFormField</code>","text":"<p><code>CaptchaFormField</code> is used to add captcha protection to the form.</p> <p>You must specify a captcha object type (<code>com.woltlab.wcf.captcha</code>) using the <code>objectType()</code> method.</p> <p>Example:</p> <pre><code>CaptchaFormField::create('captcha')\n ->objectType(CAPTCHA_TYPE)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#colorformfield","title":"<code>ColorFormField</code>","text":"<p><code>ColorFormField</code> is used to specify RGBA colors using the <code>rgba(r, g, b, a)</code> format. The class implements <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>ColorFormField::create('example')\n ->label('foo.bar.example')\n ->value('rgba(1,1,1,1)')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#contentlanguageformfield","title":"<code>ContentLanguageFormField</code>","text":"<p><code>ContentLanguageFormField</code> is used to select the content language of an object. Fields of this class are only available if multilingualism is enabled and if there are content languages. The class implements <code>IImmutableFormField</code>.</p> <p>Example:</p> <pre><code>ContentLanguageFormField::create()\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#labelformfield","title":"<code>LabelFormField</code>","text":"<p><code>LabelFormField</code> is used to select a label from a specific label group. The class implements <code>IObjectTypeFormNode</code>.</p> <p>The <code>labelGroup(ViewableLabelGroup $labelGroup)</code> and <code>getLabelGroup()</code> methods are specific to this form field class and can be used to set and get the label group whose labels can be selected. Additionally, there is the static method <code>createFields($objectType, array $labelGroups, $objectProperty = 'labelIDs)</code> that can be used to create all relevant label form fields for a given list of label groups. In most cases, <code>LabelFormField::createFields()</code> should be used.</p> <p>Example:</p> <pre><code>LabelFormField::create('example')\n ->objectType('foo.bar.example.object.type')\n ->labelGroup(LabelHandler::getInstance()->getLabelGroup($groupID))\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#optionformfield","title":"<code>OptionFormField</code>","text":"<p><code>OptionFormField</code> is an item list form field to set a list of options. The class implements <code>IPackagesFormField</code> and only options of the set packages are considered available. The default label of instances of this class is <code>wcf.form.field.option</code> and their default id is <code>options</code>.</p> <p>Example:</p> <pre><code>OptionFormField::create()\n ->description('foo.bar.example')\n ->packageIDs([1, 2])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#simpleaclformfield","title":"<code>SimpleAclFormField</code>","text":"<p><code>SimpleAclFormField</code> is used for setting up simple acl values (one <code>yes</code>/<code>no</code> option per user and user group) for specific objects.</p> <p><code>SimpleAclFormField</code> objects register a custom form field data processor to add the relevant simple ACL data array into the <code>$parameters</code> array directly using the object property as the array key.</p> <p>Since version 5.5, the field also supports inverted permissions, see WoltLab/WCF#4570.</p> <p>The <code>SimpleAclFormField</code> supports inverted permissions, allowing the administrator to grant access to all non-selected users and groups. If this behavior is desired, it needs to be enabled by calling <code>supportInvertedPermissions</code>. An <code>invertPermissions</code> key containing a boolean value with the users selection will be provided together with the ACL values when saving the field.</p> <p>Example:</p> <pre><code>SimpleAclFormField::create('example')\n ->label('foo.bar.example')\n ->supportInvertedPermissions(true)\n ->value([\n 'allowAll' => false,\n 'user' => [1, 2],\n ])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#singlemediaselectionformfield","title":"<code>SingleMediaSelectionFormField</code>","text":"<p><code>SingleMediaSelectionFormField</code> is used to select a specific media file. The class implements <code>IImmutableFormField</code>.</p> <p>The following methods are specific to this form field class:</p> <ul> <li><code>imageOnly($imageOnly = true)</code> and <code>isImageOnly()</code> can be used to set and check if only images may be selected.</li> <li><code>getMedia()</code> returns the media file based on the current field value if a field is set.</li> </ul> <p>Example:</p> <pre><code>SingleMediaSelectionFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#tagformfield","title":"<code>TagFormField</code>","text":"<p><code>TagFormField</code> is a form field to enter tags. The class implements <code>IAttributeFormField</code> and <code>IObjectTypeFormNode</code>. Arrays passed to <code>TagFormField::values()</code> can contain tag names as strings and <code>Tag</code> objects. The default label of instances of this class is <code>wcf.tagging.tags</code> and their default description is <code>wcf.tagging.tags.description</code>.</p> <p><code>TagFormField</code> objects register a custom form field data processor to add the array with entered tag names into the <code>$parameters</code> array directly using the object property as the array key.</p> <p>Example:</p> <pre><code>TagFormField::create()\n ->objectType('foo.bar.example.object.type')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#uploadformfield","title":"<code>UploadFormField</code>","text":"<p><code>UploadFormField</code> is a form field that allows uploading files by the user.</p> <p><code>UploadFormField</code> objects register a custom form field data processor to add the array of <code>wcf\\system\\file\\upload\\UploadFile\\UploadFile</code> into the <code>$parameters</code> array directly using the object property as the array key. Also it registers the removed files as an array of <code>wcf\\system\\file\\upload\\UploadFile\\UploadFile</code> into the <code>$parameters</code> array directly using the object property with the suffix <code>_removedFiles</code> as the array key. </p> <p>The field supports additional settings:</p> <ul> <li><code>imageOnly($imageOnly = true)</code> and <code>isImageOnly()</code> can be used to ensure that the uploaded files are only images.</li> <li><code>allowSvgImage($allowSvgImages = true)</code> and <code>svgImageAllowed()</code> can be used to allow SVG images, if the image only mode is enabled (otherwise, the method will throw an exception). By default, SVG images are not allowed.</li> </ul> <p>Example:</p> <pre><code>UploadFormField::create('example')\n ->label('foo.bar.example')\n ->maximum(1)\n ->imageOnly(true)\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#provide-value-from-database-object","title":"Provide value from database object","text":"<p>To provide values from a database object, you should implement the method <code>get{$objectProperty}UploadFileLocations()</code> to your database object class. This method must return an array of strings with the locations of the files.</p>"},{"location":"php/api/form_builder/form_fields/#process-files","title":"Process files","text":"<p>To process files in the database object action class, you must <code>rename</code> the file to the final destination. You get the temporary location, by calling the method <code>getLocation()</code> on the given <code>UploadFile</code> objects. After that, you call <code>setProcessed($location)</code> with <code>$location</code> contains the new file location. This method sets the <code>isProcessed</code> flag to true and saves the new location. For updating files, it is relevant, whether a given file is already processed or not. For this case, the <code>UploadFile</code> object has an method <code>isProcessed()</code> which indicates, whether a file is already processed or new uploaded.</p>"},{"location":"php/api/form_builder/form_fields/#userformfield","title":"<code>UserFormField</code>","text":"<p><code>UserFormField</code> is a form field to enter existing users. The class implements <code>IAutoCompleteFormField</code>, <code>IAutoFocusFormField</code>, <code>IImmutableFormField</code>, <code>IMultipleFormField</code>, and <code>INullableFormField</code>. While the user is presented the names of the specified users in the user interface, the field returns the ids of the users as data. The relevant <code>UserProfile</code> objects can be accessed via the <code>getUsers()</code> method.</p> <p>Example:</p> <pre><code>UserFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#userpasswordfield","title":"<code>UserPasswordField</code>","text":"<p><code>UserPasswordField</code> is a form field for users' to enter their current password. The class implements <code>IAttributeFormField</code>, <code>IAttributeFormField</code>, <code>IAutoCompleteFormField</code>, <code>IAutoFocusFormField</code>, and <code>IPlaceholderFormField</code></p> <p>Example:</p> <pre><code>UserPasswordField::create()\n ->autocomplete('current-password')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#usergroupoptionformfield","title":"<code>UserGroupOptionFormField</code>","text":"<p><code>UserGroupOptionFormField</code> is an item list form field to set a list of user group options/permissions. The class implements <code>IPackagesFormField</code> and only user group options of the set packages are considered available. The default label of instances of this class is <code>wcf.form.field.userGroupOption</code> and their default id is <code>permissions</code>.</p> <p>Example:</p> <pre><code>UserGroupOptionFormField::create()\n ->packageIDs([1, 2])\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#usernameformfield","title":"<code>UsernameFormField</code>","text":"<p><code>UsernameFormField</code> is used for entering one non-existing username. The class implements <code>IAttributeFormField</code>, <code>IImmutableFormField</code>, <code>IMaximumLengthFormField</code>, <code>IMinimumLengthFormField</code>, <code>INullableFormField</code>, and <code>IPlaceholderFormField</code>. As usernames have a system-wide restriction of a minimum length of 3 and a maximum length of 100 characters, these values are also used as the default value for the field\u2019s minimum and maximum length.</p> <p>Example:</p> <pre><code>UsernameFormField::create('example')\n ->label('foo.bar.example')\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#wysiwyg-form-container","title":"Wysiwyg form container","text":"<p>To integrate a wysiwyg editor into a form, you have to create a <code>WysiwygFormContainer</code> object. This container takes care of creating all necessary form nodes listed below for a wysiwyg editor.</p> <p>When creating the container object, its id has to be the id of the form field that will manage the actual text.</p> <p>The following methods are specific to this form container class:</p> <ul> <li><code>addSettingsNode(IFormChildNode $settingsNode)</code> and <code>addSettingsNodes(array $settingsNodes)</code> can be used to add nodes to the settings tab container.</li> <li><code>attachmentData($objectType, $parentObjectID)</code> can be used to set the data relevant for attachment support. By default, not attachment data is set, thus attachments are not supported.</li> <li><code>getAttachmentField()</code>, <code>getPollContainer()</code>, <code>getSettingsContainer()</code>, <code>getSmiliesContainer()</code>, and <code>getWysiwygField()</code> can be used to get the different components of the wysiwyg form container once the form has been built.</li> <li><code>enablePreviewButton($enablePreviewButton)</code> can be used to set whether the preview button for the message is shown or not. By default, the preview button is shown. This method is only relevant before the form is built. Afterwards, the preview button availability can not be changed.</li> <li><code>getObjectId()</code> returns the id of the edited object or <code>0</code> if no object is edited.</li> <li><code>getPreselect()</code>, <code>preselect($preselect)</code> can be used to set the value of the wysiwyg tab menu's <code>data-preselect</code> attribute used to determine which tab is preselected. By default, the preselect is <code>'true'</code> which is used to pre-select the first tab.</li> <li><code>messageObjectType($messageObjectType)</code> can be used to set the message object type.</li> <li><code>pollObjectType($pollObjectType)</code> can be used to set the poll object type. By default, no poll object type is set, thus the poll form field container is not available.</li> <li><code>supportMentions($supportMentions)</code> can be used to set if mentions are supported. By default, mentions are not supported. This method is only relevant before the form is built. Afterwards, mention support can only be changed via the wysiwyg form field.</li> <li><code>supportSmilies($supportSmilies)</code> can be used to set if smilies are supported. By default, smilies are supported. This method is only relevant before the form is built. Afterwards, smiley availability can only be changed via changing the availability of the smilies form container.</li> </ul>"},{"location":"php/api/form_builder/form_fields/#wysiwygattachmentformfield","title":"<code>WysiwygAttachmentFormField</code>","text":"<p><code>WysiwygAttachmentFormField</code> provides attachment support for a wysiwyg editor via a tab in the menu below the editor. This class should not be used directly but only via <code>WysiwygFormContainer</code>. The methods <code>attachmentHandler(AttachmentHandler $attachmentHandler)</code> and <code>getAttachmentHandler()</code> can be used to set and get the <code>AttachmentHandler</code> object that is used for uploaded attachments.</p>"},{"location":"php/api/form_builder/form_fields/#wysiwygpollformcontainer","title":"<code>WysiwygPollFormContainer</code>","text":"<p><code>WysiwygPollFormContainer</code> provides poll support for a wysiwyg editor via a tab in the menu below the editor. This class should not be used directly but only via <code>WysiwygFormContainer</code>. <code>WysiwygPollFormContainer</code> contains all form fields that are required to create polls and requires edited objects to implement <code>IPollContainer</code>.</p> <p>The following methods are specific to this form container class:</p> <ul> <li><code>getEndTimeField()</code> returns the form field to set the end time of the poll once the form has been built.</li> <li><code>getIsChangeableField()</code> returns the form field to set if poll votes can be changed once the form has been built.</li> <li><code>getIsPublicField()</code> returns the form field to set if poll results are public once the form has been built.</li> <li><code>getMaxVotesField()</code> returns the form field to set the maximum number of votes once the form has been built.</li> <li><code>getOptionsField()</code> returns the form field to set the poll options once the form has been built.</li> <li><code>getQuestionField()</code> returns the form field to set the poll question once the form has been built.</li> <li><code>getResultsRequireVoteField()</code> returns the form field to set if viewing the poll results requires voting once the form has been built.</li> <li><code>getSortByVotesField()</code> returns the form field to set if the results are sorted by votes once the form has been built.</li> </ul>"},{"location":"php/api/form_builder/form_fields/#wysiwygsmileyformcontainer","title":"<code>WysiwygSmileyFormContainer</code>","text":"<p><code>WysiwygSmileyFormContainer</code> provides smiley support for a wysiwyg editor via a tab in the menu below the editor. This class should not be used directly but only via <code>WysiwygFormContainer</code>. <code>WysiwygSmileyFormContainer</code> creates a sub-tab for each smiley category.</p>"},{"location":"php/api/form_builder/form_fields/#wysiwygsmileyformnode","title":"<code>WysiwygSmileyFormNode</code>","text":"<p><code>WysiwygSmileyFormNode</code> is contains the smilies of a specific category. This class should not be used directly but only via <code>WysiwygSmileyFormContainer</code>.</p>"},{"location":"php/api/form_builder/form_fields/#example_1","title":"Example","text":"<p>The following code creates a WYSIWYG editor component for a <code>message</code> object property. As smilies are supported by default and an attachment object type is given, the tab menu below the editor has two tabs: \u201cSmilies\u201d and \u201cAttachments\u201d. Additionally, mentions and quotes are supported.</p> <pre><code>WysiwygFormContainer::create('message')\n ->label('foo.bar.message')\n ->messageObjectType('com.example.foo.bar')\n ->attachmentData('com.example.foo.bar')\n ->supportMentions()\n ->supportQuotes()\n</code></pre>"},{"location":"php/api/form_builder/form_fields/#wysiwygformfield","title":"<code>WysiwygFormField</code>","text":"<p><code>WysiwygFormField</code> is used for wysiwyg editor form fields. This class should, in general, not be used directly but only via <code>WysiwygFormContainer</code>. The class implements <code>IAttributeFormField</code>, <code>IMaximumLengthFormField</code>, <code>IMinimumLengthFormField</code>, and <code>IObjectTypeFormNode</code> and requires an object type of the object type definition <code>com.woltlab.wcf.message</code>. The following methods are specific to this form field class:</p> <ul> <li><code>autosaveId($autosaveId)</code> and <code>getAutosaveId()</code> can be used enable automatically saving the current editor contents in the browser using the given id. An empty string signals that autosaving is disabled.</li> <li><code>lastEditTime($lastEditTime)</code> and <code>getLastEditTime()</code> can be used to set the last time the contents have been edited and saved so that the JavaScript can determine if the contents stored in the browser are older or newer. <code>0</code> signals that no last edit time has been set.</li> <li> <p><code>supportAttachments($supportAttachments)</code> and <code>supportsAttachments()</code> can be used to set and check if the form field supports attachments.</p> <p>It is not sufficient to simply signal attachment support via these methods for attachments to work. These methods are relevant internally to signal the Javascript code that the editor supports attachments. Actual attachment support is provided by <code>WysiwygAttachmentFormField</code>.</p> </li> <li> <p><code>supportMentions($supportMentions)</code> and <code>supportsMentions()</code> can be used to set and check if the form field supports mentions of other users.</p> </li> </ul> <p><code>WysiwygFormField</code> objects register a custom form field data processor to add the relevant simple ACL data array into the <code>$parameters</code> array directly using the object property as the array key.</p>"},{"location":"php/api/form_builder/form_fields/#twysiwygformnode","title":"<code>TWysiwygFormNode</code>","text":"<p>All form nodes that need to know the id of the <code>WysiwygFormField</code> field should use <code>TWysiwygFormNode</code>. This trait provides <code>getWysiwygId()</code> and <code>wysiwygId($wysiwygId)</code> to get and set the relevant wysiwyg editor id.</p>"},{"location":"php/api/form_builder/form_fields/#application-specific-form-fields","title":"Application-Specific Form Fields","text":""},{"location":"php/api/form_builder/form_fields/#woltlab-suite-forum","title":"WoltLab Suite Forum","text":""},{"location":"php/api/form_builder/form_fields/#multipleboardselectionformfield","title":"<code>MultipleBoardSelectionFormField</code>","text":"<p><code>MultipleBoardSelectionFormField</code> is used to select multiple forums. The class implements <code>IAttributeFormField</code>, <code>ICssClassFormField</code>, and <code>IImmutableFormField</code>.</p> <p>The field supports additional settings:</p> <ul> <li><code>boardNodeList(BoardNodeList $boardNodeList): self</code> and <code>getBoardNodeList(): BoardNodeList</code> are used to set and get the list of board nodes used to render the board selection. <code>boardNodeList(BoardNodeList $boardNodeList): self</code> will automatically call <code>readNodeTree()</code> on the given board node list.</li> <li><code>categoriesSelectable(bool $categoriesSelectable = true): self</code> and <code>areCategoriesSelectable(): bool</code> are used to set and check if the categories in the board node list are selectable. By default, categories are selectable. This option is useful if only actual boards, in which threads can be posted, should be selectable but the categories must still be shown so that the overall forum structure is still properly shown.</li> <li><code>supportExternalLinks(bool $supportExternalLinks): self</code> and <code>supportsExternalLinks(): bool</code> are used to set and check if external links will be shown in the selection list. By default, external links are shown. Like in the example given before, in cases where only actual boards, in which threads can be posted, are relevant, this option allows to exclude external links.</li> </ul>"},{"location":"php/api/form_builder/form_fields/#single-use-form-fields","title":"Single-Use Form Fields","text":"<p>The following form fields are specific for certain forms and hardly reusable in other contexts.</p>"},{"location":"php/api/form_builder/form_fields/#bbcodeattributesformfield","title":"<code>BBCodeAttributesFormField</code>","text":"<p><code>BBCodeAttributesFormField</code> is a form field for setting the attributes of a BBCode.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectexcludedpackagesformfield","title":"<code>DevtoolsProjectExcludedPackagesFormField</code>","text":"<p><code>DevtoolsProjectExcludedPackagesFormField</code> is a form field for setting the excluded packages of a devtools project.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectinstructionsformfield","title":"<code>DevtoolsProjectInstructionsFormField</code>","text":"<p><code>DevtoolsProjectInstructionsFormField</code> is a form field for setting the installation and update instructions of a devtools project.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectoptionalpackagesformfield","title":"<code>DevtoolsProjectOptionalPackagesFormField</code>","text":"<p><code>DevtoolsProjectOptionalPackagesFormField</code> is a form field for setting the optional packages of a devtools project.</p>"},{"location":"php/api/form_builder/form_fields/#devtoolsprojectrequiredpackagesformfield","title":"<code>DevtoolsProjectRequiredPackagesFormField</code>","text":"<p><code>DevtoolsProjectRequiredPackagesFormField</code> is a form field for setting the required packages of a devtools project.</p>"},{"location":"php/api/form_builder/overview/","title":"Form Builder","text":"<p>WoltLab Suite includes a powerful way of creating forms: Form Builder. Form builder allows you to easily define all the fields and their constraints and interdependencies within PHP with full IDE support. It will then automatically generate the necessary HTML with full interactivity to render all the fields and also validate the fields\u2019 contents upon submission.</p> <p>The migration guide for WoltLab Suite Core 5.2 provides some examples of how to migrate existing forms to form builder that can also help in understanding form builder if the old way of creating forms is familiar.</p>"},{"location":"php/api/form_builder/overview/#form-builder-components","title":"Form Builder Components","text":"<p>Form builder consists of several components that are presented on the following pages:</p> <ol> <li>Structure of form builder</li> <li>Form validation and form data</li> <li>Form node dependencies</li> </ol> <p>In general, form builder provides default implementation of interfaces by providing either abstract classes or traits. It is expected that the interfaces are always implemented using these abstract classes and traits! This way, if new methods are added to the interfaces, default implementations can be provided by the abstract classes and traits without causing backwards compatibility problems.</p>"},{"location":"php/api/form_builder/overview/#abstractformbuilderform","title":"<code>AbstractFormBuilderForm</code>","text":"<p>To make using form builder easier, <code>AbstractFormBuilderForm</code> extends <code>AbstractForm</code> and provides most of the code needed to set up a form (of course without specific fields, those have to be added by the concrete form class), like reading and validating form values and using a database object action to use the form data to create or update a database object.</p> <p>In addition to the existing methods inherited by <code>AbstractForm</code>, <code>AbstractFormBuilderForm</code> provides the following methods:</p> <ul> <li> <p><code>buildForm()</code> builds the form in the following steps:</p> </li> <li> <p>Call <code>AbtractFormBuilderForm::createForm()</code> to create the <code>IFormDocument</code> object and add the form fields.</p> </li> <li>Call <code>IFormDocument::build()</code> to build the form.</li> <li>Call <code>AbtractFormBuilderForm::finalizeForm()</code> to finalize the form like adding dependencies.</li> </ul> <p>Additionally, between steps 1 and 2 and after step 3, the method provides two events, <code>createForm</code> and <code>buildForm</code> to allow plugins to register event listeners to execute additional code at the right point in time. - <code>createForm()</code> creates the <code>FormDocument</code> object and sets the form mode. Classes extending <code>AbstractFormBuilderForm</code> have to override this method (and call <code>parent::createForm()</code> as the first line in the overridden method) to add concrete form containers and form fields to the bare form document. - <code>finalizeForm()</code> is called after the form has been built and the complete form hierarchy has been established. This method should be overridden to add dependencies, for example. - <code>setFormAction()</code> is called at the end of <code>readData()</code> and sets the form document\u2019s action based on the controller class name and whether an object is currently edited. - If an object is edited, at the beginning of <code>readData()</code>, <code>setFormObjectData()</code> is called which calls <code>IFormDocument::loadValuesFromObject()</code>. If values need to be loaded from additional sources, this method should be used for that.</p> <p><code>AbstractFormBuilderForm</code> also provides the following (public) properties:</p> <ul> <li><code>$form</code> contains the <code>IFormDocument</code> object created in <code>createForm()</code>.</li> <li><code>$formAction</code> is either <code>create</code> (default) or <code>edit</code> and handles which method of the database object is called by default (<code>create</code> is called for <code>$formAction = 'create'</code> and <code>update</code> is called for <code>$formAction = 'edit'</code>) and is used to set the value of the <code>action</code> template variable.</li> <li><code>$formObject</code> contains the <code>IStorableObject</code> if the form is used to edit an existing object. For forms used to create objects, <code>$formObject</code> is always <code>null</code>. Edit forms have to manually identify the edited object based on the request data and set the value of <code>$formObject</code>. </li> <li><code>$objectActionName</code> can be used to set an alternative action to be executed by the database object action that deviates from the default action determined by the value of <code>$formAction</code>.</li> <li><code>$objectActionClass</code> is the name of the database object action class that is used to create or update the database object.</li> </ul> <p>Example:</p> <pre><code><?php\n\nnamespace wcf\\acp\\form;\n\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\field\\BooleanFormField;\nuse wcf\\system\\form\\builder\\field\\TextFormField;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidationError;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidator;\n\nclass FooAddForm extends AbstractFormBuilderForm\n{\n /**\n * @inheritDoc\n */\n public $objectActionClass = FooAction::class;\n\n #[\\Override]\n protected function createForm()\n {\n parent::createForm();\n\n $this->form->appendChildren([\n TextFormField::create('name')\n ->label('wcf.foo.name')\n ->description('wcf.foo.name.description')\n ->required()\n ->maximumLength(255)\n ->addValidator(new FormFieldValidator('notFoo', function (TextFormField $formField) {\n if ($formField->getValue() === 'foo') {\n $formField->addValidationError(\n new FormFieldValidationError(\n 'isFoo',\n 'wcf.foo.name.error.isFoo'\n )\n );\n }\n })),\n BooleanFormField::create('isCool')\n ->label('wcf.foo.isCool')\n ->value(true)\n ]);\n }\n}\n</code></pre>"},{"location":"php/api/form_builder/overview/#psr15dialogform","title":"<code>Psr15DialogForm</code>","text":"<p>Form builder forms can also be used in dialogs. For such forms, <code>Psr15DialogForm</code> should be used which provides the additional methods <code>validateRequest(ServerRequestInterface $request)</code> and <code>toResponse()</code> to enable processing of the form via an AJAX request.</p> <p>Example:</p> <pre><code><?php\n\nnamespace wcf\\action;\n\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidationError;\nuse wcf\\system\\form\\builder\\field\\validation\\FormFieldValidator;\nuse wcf\\system\\form\\builder\\Psr15DialogForm;\nuse wcf\\system\\WCF;\n\nfinal class FooAction implements RequestHandlerInterface\n{\n /**\n * @inheritDoc\n */\n public function handle(ServerRequestInterface $request): ResponseInterface\n {\n $form = $this->getForm();\n\n if ($request->getMethod() === 'GET') {\n return $form->toResponse();\n } elseif ($request->getMethod() === 'POST') {\n $response = $form->validateRequest($request);\n if ($response !== null) {\n return $response;\n }\n\n $data = $form->getData()['data'];\n\n // process data\n } else {\n throw new \\LogicException('Unreachable');\n }\n }\n\n private function getForm(): Psr15DialogForm\n {\n $form = new Psr15DialogForm(\n static::class,\n WCF::getLanguage()->get('wcf.foo.dialog.name')\n );\n $form->appendChildren([\n TextFormField::create('name')\n ->label('wcf.foo.name')\n ->description('wcf.foo.name.description')\n ->required()\n ->maximumLength(255)\n ->addValidator(new FormFieldValidator('notFoo', function (TextFormField $formField) {\n if ($formField->getValue() === 'foo') {\n $formField->addValidationError(\n new FormFieldValidationError(\n 'isFoo',\n 'wcf.foo.name.error.isFoo'\n )\n );\n }\n })),\n BooleanFormField::create('isCool')\n ->label('wcf.foo.isCool')\n ->value(true)\n ]);\n $form->build();\n\n return $form;\n }\n}\n</code></pre> <p>On the client side, the dialog is loaded using the dialog API. A tuple is made available as a return, which provides the status of the successful form submission (<code>ok: boolean</code>) and the server-side return (<code>result: any</code>).</p> <p>Example:</p> <pre><code>require(['WoltLabSuite/Core/Component/Dialog'], async ({ dialogFactory }) => {\n const { ok, result } = await dialogFactory().usingFormBuilder().fromEndpoint('endpoint_url');\n\n if (ok) {\n // Form submission was successful\n }\n});\n</code></pre>"},{"location":"php/api/form_builder/structure/","title":"Structure of Form Builder","text":"<p>Forms built with form builder consist of three major structural elements listed from top to bottom:</p> <ol> <li>form document,</li> <li>form container,</li> <li>form field.</li> </ol> <p>The basis for all three elements are form nodes.</p> <p>The form builder API uses fluent interfaces heavily, meaning that unless a method is a getter, it generally returns the objects itself to support method chaining.</p>"},{"location":"php/api/form_builder/structure/#form-nodes","title":"Form Nodes","text":"<ul> <li><code>IFormNode</code> is the base interface that any node of a form has to implement.</li> <li><code>IFormChildNode</code> extends <code>IFormNode</code> for such elements of a form that can be a child node to a parent node.</li> <li><code>IFormParentNode</code> extends <code>IFormNode</code> for such elements of a form that can be a parent to child nodes.</li> <li><code>IFormElement</code> extends <code>IFormNode</code> for such elements of a form that can have a description and a label.</li> </ul>"},{"location":"php/api/form_builder/structure/#iformnode","title":"<code>IFormNode</code>","text":"<p><code>IFormNode</code> is the base interface that any node of a form has to implement and it requires the following methods:</p> <ul> <li><code>addClass($class)</code>, <code>addClasses(array $classes)</code>, <code>removeClass($class)</code>, <code>getClasses()</code>, and <code>hasClass($class)</code> add, remove, get, and check for CSS classes of the HTML element representing the form node. If the form node consists of multiple (nested) HTML elements, the classes are generally added to the top element. <code>static validateClass($class)</code> is used to check if a given CSS class is valid. By default, a form node has no CSS classes.</li> <li><code>addDependency(IFormFieldDependency $dependency)</code>, <code>removeDependency($dependencyId)</code>, <code>getDependencies()</code>, and <code>hasDependency($dependencyId)</code> add, remove, get, and check for dependencies of this form node on other form fields. <code>checkDependencies()</code> checks if all of the node\u2019s dependencies are met and returns a boolean value reflecting the check\u2019s result. The form builder dependency documentation provides more detailed information about dependencies and how they work. By default, a form node has no dependencies.</li> <li><code>attribute($name, $value = null)</code>, <code>removeAttribute($name)</code>, <code>getAttribute($name)</code>, <code>getAttributes()</code>, <code>hasAttribute($name)</code> add, remove, get, and check for attributes of the HTML element represting the form node. The attributes are added to the same element that the CSS classes are added to. <code>static validateAttribute($name)</code> is used to check if a given attribute is valid. By default, a form node has no attributes.</li> <li><code>available($available = true)</code> and <code>isAvailable()</code> can be used to set and check if the node is available. The availability functionality can be used to easily toggle form nodes based, for example, on options without having to create a condition to append the relevant. This way of checking availability makes it easier to set up forms. By default, every form node is available.</li> </ul> <p>The following aspects are important when working with availability:</p> <ul> <li>Unavailable fields produce no output, their value is not read, they are not validated and they are not checked for save values.</li> <li>Form fields are also able to mark themselves as unavailable, for example, a selection field without any options.</li> <li>Form containers are automatically unavailable if they contain no available children.</li> </ul> <p>Availability sets the static availability for form nodes that does not change during the lifetime of a form. In contrast, dependencies represent a dynamic availability for form nodes that depends on the current value of certain form fields. - <code>cleanup()</code> is called after the whole form is not used anymore to reset other APIs if the form fields depends on them and they expect such a reset. This method is not intended to clean up the form field\u2019s value as a new form document object is created to show a clean form. - <code>getDocument()</code> returns the <code>IFormDocument</code> object the node belongs to. (As <code>IFormDocument</code> extends <code>IFormNode</code>, form document objects simply return themselves.) - <code>getHtml()</code> returns the HTML representation of the node. <code>getHtmlVariables()</code> return template variables (in addition to the form node itself) to render the node\u2019s HTML representation. - <code>id($id)</code> and <code>getId()</code> set and get the id of the form node. Every id has to be unique within a form. <code>getPrefixedId()</code> returns the prefixed version of the node\u2019s id (see <code>IFormDocument::getPrefix()</code> and <code>IFormDocument::prefix()</code>). <code>static validateId($id)</code> is used to check if a given id is valid. - <code>populate()</code> is called by <code>IFormDocument::build()</code> after all form nodes have been added. This method should finilize the initialization of the form node after all parent-child relations of the form document have been established. This method is needed because during the construction of a form node, it neither knows the form document it will belong to nor does it know its parent. - <code>validate()</code> checks, after the form is submitted, if the form node is valid. A form node with children is valid if all of its child nodes are valid. A form field is valid if its value is valid. - <code>static create($id)</code> is the factory method that has to be used to create new form nodes with the given id.</p> <p><code>TFormNode</code> provides a default implementation of most of these methods.</p>"},{"location":"php/api/form_builder/structure/#iformchildnode","title":"<code>IFormChildNode</code>","text":"<p><code>IFormChildNode</code> extends <code>IFormNode</code> for such elements of a form that can be a child node to a parent node and it requires the <code>parent(IFormParentNode $parentNode)</code> and <code>getParent()</code> methods used to set and get the node\u2019s parent node. <code>TFormChildNode</code> provides a default implementation of these two methods and also of <code>IFormNode::getDocument()</code>.</p>"},{"location":"php/api/form_builder/structure/#iformparentnode","title":"<code>IFormParentNode</code>","text":"<p><code>IFormParentNode</code> extends <code>IFormNode</code> for such elements of a form that can be a parent to child nodes. Additionally, the interface also extends <code>\\Countable</code> and <code>\\RecursiveIterator</code>. The interface requires the following methods:</p> <ul> <li><code>appendChild(IFormChildNode $child)</code>, <code>appendChildren(array $children)</code>, <code>insertAfter(IFormChildNode $child, $referenceNodeId)</code>, and <code>insertBefore(IFormChildNode $child, $referenceNodeId)</code> are used to insert new children either at the end or at specific positions. <code>validateChild(IFormChildNode $child)</code> is used to check if a given child node can be added. A child node cannot be added if it would cause an id to be used twice.</li> <li><code>children()</code> returns the direct children of a form node.</li> <li><code>getIterator()</code> return a recursive iterator for a form node.</li> <li><code>getNodeById($nodeId)</code> returns the node with the given id by searching for it in the node\u2019s children and recursively in all of their children. <code>contains($nodeId)</code> can be used to simply check if a node with the given id exists.</li> <li><code>hasValidationErrors()</code> checks if a form node or any of its children has a validation error (see <code>IFormField::getValidationErrors()</code>).</li> <li><code>readValues()</code> recursively calls <code>IFormParentNode::readValues()</code> and <code>IFormField::readValue()</code> on its children.</li> </ul>"},{"location":"php/api/form_builder/structure/#iformelement","title":"<code>IFormElement</code>","text":"<p><code>IFormElement</code> extends <code>IFormNode</code> for such elements of a form that can have a description and a label and it requires the following methods:</p> <ul> <li><code>label($languageItem = null, array $variables = [])</code> and <code>getLabel()</code> can be used to set and get the label of the form element. <code>requiresLabel()</code> can be checked if the form element requires a label. A label-less form element that requires a label will prevent the form from being rendered by throwing an exception.</li> <li><code>description($languageItem = null, array $variables = [])</code> and <code>getDescription()</code> can be used to set and get the description of the form element.</li> </ul>"},{"location":"php/api/form_builder/structure/#iobjecttypeformnode","title":"<code>IObjectTypeFormNode</code>","text":"<p><code>IObjectTypeFormField</code> has to be implemented by form nodes that rely on a object type of a specific object type definition in order to function. The implementing class has to implement the methods <code>objectType($objectType)</code>, <code>getObjectType()</code>, and <code>getObjectTypeDefinition()</code>. <code>TObjectTypeFormNode</code> provides a default implementation of these three methods.</p>"},{"location":"php/api/form_builder/structure/#customformnode","title":"<code>CustomFormNode</code>","text":"<p><code>CustomFormNode</code> is a form node whose contents can be set directly via <code>content($content)</code>.</p> <p>This class should generally not be relied on. Instead, <code>TemplateFormNode</code> should be used.</p> <p>Example:</p> <pre><code>CustomFormNode::create('example')\n ->content('html code')\n</code></pre>"},{"location":"php/api/form_builder/structure/#templateformnode","title":"<code>TemplateFormNode</code>","text":"<p><code>TemplateFormNode</code> is a form node whose contents are read from a template. <code>TemplateFormNode</code> has the following additional methods:</p> <ul> <li><code>application($application)</code> and <code>getApplicaton()</code> can be used to set and get the abbreviation of the application the shown template belongs to. If no template has been set explicitly, <code>getApplicaton()</code> returns <code>wcf</code>.</li> <li><code>templateName($templateName)</code> and <code>getTemplateName()</code> can be used to set and get the name of the template containing the node contents. If no template has been set and the node is rendered, an exception will be thrown.</li> <li><code>variables(array $variables)</code> and <code>getVariables()</code> can be used to set and get additional variables passed to the template.</li> </ul> <p>Example:</p> <pre><code>TemplateFormNode::create('example')\n ->templateName('example_template_name')\n</code></pre>"},{"location":"php/api/form_builder/structure/#form-document","title":"Form Document","text":"<p>A form document object represents the form as a whole and has to implement the <code>IFormDocument</code> interface. WoltLab Suite provides a default implementation with the <code>FormDocument</code> class. <code>IFormDocument</code> should not be implemented directly but instead <code>FormDocument</code> should be extended to avoid issues if the <code>IFormDocument</code> interface changes in the future.</p> <p><code>IFormDocument</code> extends <code>IFormParentNode</code> and requires the following additional methods:</p> <ul> <li><code>action($action)</code> and <code>getAction()</code> can be used set and get the <code>action</code> attribute of the <code><form></code> HTML element.</li> <li><code>addButton(IFormButton $button)</code> and <code>getButtons()</code> can be used add and get form buttons that are shown at the bottom of the form. <code>addDefaultButton($addDefaultButton)</code> and <code>hasDefaultButton()</code> can be used to set and check if the form has the default button which is added by default unless specified otherwise. Each implementing class may define its own default button. <code>FormDocument</code> has a button with id <code>submitButton</code>, label <code>wcf.global.button.submit</code>, access key <code>s</code>, and CSS class <code>buttonPrimary</code> as its default button. </li> <li><code>ajax($ajax)</code> and <code>isAjax()</code> can be used to set and check if the form document is requested via an AJAX request or processes data via an AJAX request. These methods are helpful for form fields that behave differently when providing data via AJAX.</li> <li><code>build()</code> has to be called once after all nodes have been added to this document to trigger <code>IFormNode::populate()</code>.</li> <li> <p><code>formMode($formMode)</code> and <code>getFormMode()</code> sets the form mode. Possible form modes are:</p> </li> <li> <p><code>IFormDocument::FORM_MODE_CREATE</code> has to be used when the form is used to create a new object.</p> </li> <li><code>IFormDocument::FORM_MODE_UPDATE</code> has to be used when the form is used to edit an existing object.</li> <li><code>getData()</code> returns the array containing the form data and which is passed as the <code>$parameters</code> argument of the constructor of a database object action object.</li> <li><code>getDataHandler()</code> returns the data handler for this document that is used to process the field data into a parameters array for the constructor of a database object action object.</li> <li><code>getEnctype()</code> returns the encoding type of the form. If the form contains a <code>IFileFormField</code>, <code>multipart/form-data</code> is returned, otherwise <code>null</code> is returned.</li> <li><code>loadValues(array $data, IStorableObject $object)</code> is used when editing an existing object to set the form field values by calling <code>IFormField::loadValue()</code> for all form fields. Additionally, the form mode is set to <code>IFormDocument::FORM_MODE_UPDATE</code>.</li> <li>5.4+ <code>markRequiredFields(bool $markRequiredFields = true): self</code> and <code>marksRequiredFields(): bool</code> can be used to set and check whether fields that are required are marked (with an asterisk in the label) in the output.</li> <li><code>method($method)</code> and <code>getMethod()</code> can be used to set and get the <code>method</code> attribute of the <code><form></code> HTML element. By default, the method is <code>post</code>.</li> <li><code>prefix($prefix)</code> and <code>getPrefix()</code> can be used to set and get a global form prefix that is prepended to form elements\u2019 names and ids to avoid conflicts with other forms. By default, the prefix is an empty string. If a prefix of <code>foo</code> is set, <code>getPrefix()</code> returns <code>foo_</code> (additional trailing underscore).</li> <li><code>requestData(array $requestData)</code>, <code>getRequestData($index = null)</code>, and <code>hasRequestData($index = null)</code> can be used to set, get and check for specific request data. In most cases, the relevant request data is the <code>$_POST</code> array. In default AJAX requests handled by database object actions, however, the request data generally is in <code>AbstractDatabaseObjectAction::$parameters</code>. By default, <code>$_POST</code> is the request data.</li> </ul> <p>The last aspect is relevant for <code>DialogFormDocument</code> objects. <code>DialogFormDocument</code> is a specialized class for forms in dialogs that, in contrast to <code>FormDocument</code> do not require an <code>action</code> to be set. Additionally, <code>DialogFormDocument</code> provides the <code>cancelable($cancelable = true)</code> and <code>isCancelable()</code> methods used to determine if the dialog from can be canceled. By default, dialog forms are cancelable.</p>"},{"location":"php/api/form_builder/structure/#form-button","title":"Form Button","text":"<p>A form button object represents a button shown at the end of the form that, for example, submits the form. Every form button has to implement the <code>IFormButton</code> interface that extends <code>IFormChildNode</code> and <code>IFormElement</code>. <code>IFormButton</code> requires four methods to be implemented:</p> <ul> <li><code>accessKey($accessKey)</code> and <code>getAccessKey()</code> can be used to set and get the access key with which the form button can be activated. By default, form buttons have no access key set.</li> <li><code>submit($submitButton)</code> and <code>isSubmit()</code> can be used to set and check if the form button is a submit button. A submit button is an <code>input[type=submit]</code> element. Otherwise, the button is a <code>button</code> element. </li> </ul>"},{"location":"php/api/form_builder/structure/#form-container","title":"Form Container","text":"<p>A form container object represents a container for other form containers or form field directly. Every form container has to implement the <code>IFormContainer</code> interface which requires the following method:</p> <ul> <li><code>loadValues(array $data, IStorableObject $object)</code> is called by <code>IFormDocument::loadValuesFromObject()</code> to inform the container that object data is loaded. This method is not intended to generally call <code>IFormField::loadValues()</code> on its form field children as these methods are already called by <code>IFormDocument::loadValuesFromObject()</code>. This method is intended for specialized form containers with more complex logic.</li> </ul> <p>There are multiple default container implementations:</p> <ol> <li><code>FormContainer</code> is the default implementation of <code>IFormContainer</code>.</li> <li><code>TabMenuFormContainer</code> represents the container of tab menu, while</li> <li><code>TabFormContainer</code> represents a tab of a tab menu and</li> <li><code>TabTabMenuFormContainer</code> represents a tab of a tab menu that itself contains a tab menu.</li> <li>The children of <code>RowFormContainer</code> are shown in a row and should use <code>col-*</code> classes.</li> <li>The children of <code>RowFormFieldContainer</code> are also shown in a row but does not show the labels and descriptions of the individual form fields. Instead of the individual labels and descriptions, the container's label and description is shown and both span all of fields.</li> <li><code>SuffixFormFieldContainer</code> can be used for one form field with a second selection form field used as a suffix.</li> </ol> <p>The methods of the interfaces that <code>FormContainer</code> is implementing are well documented, but here is a short overview of the most important methods when setting up a form or extending a form with an event listener:</p> <ul> <li><code>appendChild(IFormChildNode $child)</code>, <code>appendChildren(array $children)</code>, and <code>insertBefore(IFormChildNode $child, $referenceNodeId)</code> are used to insert new children into the form container.</li> <li><code>description($languageItem = null, array $variables = [])</code> and <code>label($languageItem = null, array $variables = [])</code> are used to set the description and the label or title of the form container.</li> </ul> <p>Example:</p> <pre><code>$form->appendChild(\n FormContainer::create('example')\n ->appendChildren([ ... ])\n );\n</code></pre>"},{"location":"php/api/form_builder/structure/#form-field","title":"Form Field","text":"<p>A form field object represents a concrete form field that allows entering data. Every form field has to implement the <code>IFormField</code> interface which extends <code>IFormChildNode</code> and <code>IFormElement</code>.</p> <p><code>IFormField</code> requires the following additional methods:</p> <ul> <li><code>addValidationError(IFormFieldValidationError $error)</code> and <code>getValidationErrors()</code> can be used to get and set validation errors of the form field (see form validation).</li> <li><code>addValidator(IFormFieldValidator $validator)</code>, <code>getValidators()</code>, <code>removeValidator($validatorId)</code>, and <code>hasValidator($validatorId)</code> can be used to get, set, remove, and check for validators for the form field (see form validation).</li> <li><code>getFieldHtml()</code> returns the field's HTML output without the surrounding <code>dl</code> structure.</li> <li><code>objectProperty($objectProperty)</code> and <code>getObjectProperty()</code> can be used to get and set the object property that the field represents. When setting the object property is set to an empty string, the previously set object property is unset. If no object property has been set, the field\u2019s (non-prefixed) id is returned.</li> </ul> <p>The object property allows having different fields (requiring different ids) that represent the same object property which is handy when available options of the field\u2019s value depend on another field. Having object property allows to define different fields for each value of the other field and to use form field dependencies to only show the appropriate field. - <code>readValue()</code> reads the form field value from the request data after the form is submitted. - <code>required($required = true)</code> and <code>isRequired()</code> can be used to determine if the form field has to be filled out. By default, form fields do not have to be filled out. - <code>value($value)</code> and <code>getSaveValue()</code> can be used to get and set the value of the form field to be used outside of the context of forms. <code>getValue()</code>, in contrast, returns the internal representation of the form field\u2019s value. In general, the internal representation is only relevant when validating the value in additional validators. <code>loadValue(array $data, IStorableObject $object)</code> extracts the form field value from the given data array (and additional, non-editable data from the object if the field needs them).</p> <p><code>AbstractFormField</code> provides default implementations of many of the listed methods above and should be extended instead of implementing <code>IFormField</code> directly.</p> <p>An overview of the form fields provided by default can be found here.</p>"},{"location":"php/api/form_builder/structure/#form-field-interfaces-and-traits","title":"Form Field Interfaces and Traits","text":"<p>WoltLab Suite Core provides a variety of interfaces and matching traits with default implementations for several common features of form fields:</p>"},{"location":"php/api/form_builder/structure/#iattributeformfield","title":"<code>IAttributeFormField</code>","text":"<p><code>IAttributeFormField</code> has to be implemented by form fields for which attributes can be added to the actual form element (in addition to adding attributes to the surrounding element via the attribute-related methods of <code>IFormNode</code>). The implementing class has to implement the methods <code>fieldAttribute(string $name, string $value = null): self</code> and <code>getFieldAttribute(string $name): self</code>/<code>getFieldAttributes(): array</code>, which are used to add and get the attributes, respectively. Additionally, <code>hasFieldAttribute(string $name): bool</code> has to implemented to check if a certain attribute is present, <code>removeFieldAttribute(string $name): self</code> to remove an attribute, and <code>static validateFieldAttribute(string $name)</code> to check if the attribute is valid for this specific class. <code>TAttributeFormField</code> provides a default implementation of these methods and <code>TInputAttributeFormField</code> specializes the trait for <code>input</code>-based form fields. These two traits also ensure that if a specific interface that handles a specific attribute is implemented, like <code>IAutoCompleteFormField</code> handling <code>autocomplete</code>, this attribute cannot be set with this API. Instead, the dedicated API provided by the relevant interface has to be used.</p>"},{"location":"php/api/form_builder/structure/#iautocompleteformfield","title":"<code>IAutoCompleteFormField</code>","text":"<p><code>IAutoCompleteFormField</code> has to be implemented by form fields that support the <code>autocomplete</code> attribute. The implementing class has to implement the methods <code>autoComplete(?string $autoComplete): self</code> and <code>getAutoComplete(): ?string</code>, which are used to set and get the autocomplete value, respectively. <code>TAutoCompleteFormField</code> provides a default implementation of these two methods and <code>TTextAutoCompleteFormField</code> specializes the trait for text form fields. When using <code>TAutoCompleteFormField</code>, you have to implement the <code>getValidAutoCompleteTokens(): array</code> method which returns all valid <code>autocomplete</code> tokens.</p>"},{"location":"php/api/form_builder/structure/#iautofocusformfield","title":"<code>IAutoFocusFormField</code>","text":"<p><code>IAutoFocusFormField</code> has to be implemented by form fields that can be auto-focused. The implementing class has to implement the methods <code>autoFocus($autoFocus = true)</code> and <code>isAutoFocused()</code>. By default, form fields are not auto-focused. <code>TAutoFocusFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#icssclassformfield","title":"<code>ICssClassFormField</code>","text":"<p><code>ICssClassFormField</code> has to be implemented by form fields for which CSS classes can be added to the actual form element (in addition to adding CSS classes to the surrounding element via the class-related methods of <code>IFormNode</code>). The implementing class has to implement the methods <code>addFieldClass(string $class): self</code>/<code>addFieldClasses(array $classes): self</code> and <code>getFieldClasses(): array</code>, which are used to add and get the CSS classes, respectively. Additionally, <code>hasFieldClass(string $class): bool</code> has to implemented to check if a certain CSS class is present and <code>removeFieldClass(string $class): self</code> to remove a CSS class. <code>TCssClassFormField</code> provides a default implementation of these methods.</p>"},{"location":"php/api/form_builder/structure/#ifileformfield","title":"<code>IFileFormField</code>","text":"<p><code>IFileFormField</code> has to be implemented by every form field that uploads files so that the <code>enctype</code> attribute of the form document is <code>multipart/form-data</code> (see <code>IFormDocument::getEnctype()</code>).</p>"},{"location":"php/api/form_builder/structure/#ifilterableselectionformfield","title":"<code>IFilterableSelectionFormField</code>","text":"<p><code>IFilterableSelectionFormField</code> extends <code>ISelectionFormField</code> by the possibilty for users when selecting the value(s) to filter the list of available options. The implementing class has to implement the methods <code>filterable($filterable = true)</code> and <code>isFilterable()</code>. <code>TFilterableSelectionFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#ii18nformfield","title":"<code>II18nFormField</code>","text":"<p><code>II18nFormField</code> has to be implemented by form fields if the form field value can be entered separately for all available languages. The implementing class has to implement the following methods:</p> <ul> <li><code>i18n($i18n = true)</code> and <code>isI18n()</code> can be used to set whether a specific instance of the class actually supports multilingual input.</li> <li><code>i18nRequired($i18nRequired = true)</code> and <code>isI18nRequired()</code> can be used to set whether a specific instance of the class requires separate values for all languages.</li> <li><code>languageItemPattern($pattern)</code> and <code>getLanguageItemPattern()</code> can be used to set the pattern/regular expression for the language item used to save the multilingual values.</li> <li><code>hasI18nValues()</code> and <code>hasPlainValue()</code> check if the current value is a multilingual or monolingual value.</li> </ul> <p><code>TI18nFormField</code> provides a default implementation of these eight methods and additional default implementations of some of the <code>IFormField</code> methods. If multilingual input is enabled for a specific form field, classes using <code>TI18nFormField</code> register a custom form field data processor to add the array with multilingual input into the <code>$parameters</code> array directly using <code>{$objectProperty}_i18n</code> as the array key. If multilingual input is enabled but only a monolingual value is entered, the custom form field data processor does nothing and the form field\u2019s value is added by the <code>DefaultFormDataProcessor</code> into the <code>data</code> sub-array of the <code>$parameters</code> array.</p> <p><code>TI18nFormField</code> already provides a default implementation of <code>IFormField::validate()</code>.</p>"},{"location":"php/api/form_builder/structure/#iimmutableformfield","title":"<code>IImmutableFormField</code>","text":"<p><code>IImmutableFormField</code> has to be implemented by form fields that support being displayed but whose value cannot be changed. The implementing class has to implement the methods <code>immutable($immutable = true)</code> and <code>isImmutable()</code> that can be used to determine if the value of the form field is mutable or immutable. By default, form field are mutable.</p>"},{"location":"php/api/form_builder/structure/#iinputmodeformfield","title":"<code>IInputModeFormField</code>","text":"<p><code>IInputModeFormField</code> has to be implemented by form fields that support the <code>inputmode</code> attribute. The implementing class has to implement the methods <code>inputMode(?string $inputMode): self</code> and <code>getInputMode(): ?string</code>, which are used to set and get the input mode, respectively. <code>TInputModeFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#imaximumformfield","title":"<code>IMaximumFormField</code>","text":"<p><code>IMaximumFormField</code> has to be implemented by form fields if the entered value must have a maximum value. The implementing class has to implement the methods <code>maximum($maximum = null)</code> and <code>getMaximum()</code>. A maximum of <code>null</code> signals that no maximum value has been set. <code>TMaximumFormField</code> provides a default implementation of these two methods.</p> <p>The implementing class has to validate the entered value against the maximum value manually.</p>"},{"location":"php/api/form_builder/structure/#imaximumlengthformfield","title":"<code>IMaximumLengthFormField</code>","text":"<p><code>IMaximumLengthFormField</code> has to be implemented by form fields if the entered value must have a maximum length. The implementing class has to implement the methods <code>maximumLength($maximumLength = null)</code>, <code>getMaximumLength()</code>, and <code>validateMaximumLength($text, Language $language = null)</code>. A maximum length of <code>null</code> signals that no maximum length has been set. <code>TMaximumLengthFormField</code> provides a default implementation of these two methods.</p> <p>The implementing class has to validate the entered value against the maximum value manually by calling <code>validateMaximumLength()</code>.</p>"},{"location":"php/api/form_builder/structure/#iminimumformfield","title":"<code>IMinimumFormField</code>","text":"<p><code>IMinimumFormField</code> has to be implemented by form fields if the entered value must have a minimum value. The implementing class has to implement the methods <code>minimum($minimum = null)</code> and <code>getMinimum()</code>. A minimum of <code>null</code> signals that no minimum value has been set. <code>TMinimumFormField</code> provides a default implementation of these three methods.</p> <p>The implementing class has to validate the entered value against the minimum value manually.</p>"},{"location":"php/api/form_builder/structure/#iminimumlengthformfield","title":"<code>IMinimumLengthFormField</code>","text":"<p><code>IMinimumLengthFormField</code> has to be implemented by form fields if the entered value must have a minimum length. The implementing class has to implement the methods <code>minimumLength($minimumLength = null)</code>, <code>getMinimumLength()</code>, and <code>validateMinimumLength($text, Language $language = null)</code>. A minimum length of <code>null</code> signals that no minimum length has been set. <code>TMinimumLengthFormField</code> provides a default implementation of these three methods.</p> <p>The implementing class has to validate the entered value against the minimum value manually by calling <code>validateMinimumLength()</code>.</p>"},{"location":"php/api/form_builder/structure/#imultipleformfield","title":"<code>IMultipleFormField</code>","text":"<p><code>IMinimumLengthFormField</code> has to be implemented by form fields that support selecting or setting multiple values. The implementing class has to implement the following methods:</p> <ul> <li><code>multiple($multiple = true)</code> and <code>allowsMultiple()</code> can be used to set whether a specific instance of the class actually should support multiple values. By default, multiple values are not supported.</li> <li><code>minimumMultiples($minimum)</code> and <code>getMinimumMultiples()</code> can be used to set the minimum number of values that have to be selected/entered. By default, there is no required minimum number of values.</li> <li><code>maximumMultiples($minimum)</code> and <code>getMaximumMultiples()</code> can be used to set the maximum number of values that have to be selected/entered. By default, there is no maximum number of values. <code>IMultipleFormField::NO_MAXIMUM_MULTIPLES</code> is returned if no maximum number of values has been set and it can also be used to unset a previously set maximum number of values.</li> </ul> <p><code>TMultipleFormField</code> provides a default implementation of these six methods and classes using <code>TMultipleFormField</code> register a custom form field data processor to add the <code>HtmlInputProcessor</code> object with the text into the <code>$parameters</code> array directly using <code>{$objectProperty}_htmlInputProcessor</code> as the array key.</p> <p>The implementing class has to validate the values against the minimum and maximum number of values manually.</p>"},{"location":"php/api/form_builder/structure/#inullableformfield","title":"<code>INullableFormField</code>","text":"<p><code>INullableFormField</code> has to be implemented by form fields that support <code>null</code> as their (empty) value. The implementing class has to implement the methods <code>nullable($nullable = true)</code> and <code>isNullable()</code>. <code>TNullableFormField</code> provides a default implementation of these two methods.</p> <p><code>null</code> should be returned by <code>IFormField::getSaveValue()</code> is the field is considered empty and the form field has been set as nullable.</p>"},{"location":"php/api/form_builder/structure/#ipackagesformfield","title":"<code>IPackagesFormField</code>","text":"<p><code>IPackagesFormField</code> has to be implemented by form fields that, in some way, considers packages whose ids may be passed to the field object. The implementing class has to implement the methods <code>packageIDs(array $packageIDs)</code> and <code>getPackageIDs()</code>. <code>TPackagesFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#ipatternformfield","title":"<code>IPatternFormField</code>","text":"<p><code>IPatternFormField</code> has to be implemented by form fields that support the <code>pattern</code> attribute. The implementing class has to implement the methods <code>pattern(?string $pattern): self</code> and <code>getPattern(): ?string</code>, which are used to set and get the pattern, respectively. <code>TPatternFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#iplaceholderformfield","title":"<code>IPlaceholderFormField</code>","text":"<p><code>IPlaceholderFormField</code> has to be implemented by form fields that support a placeholder value for empty fields. The implementing class has to implement the methods <code>placeholder($languageItem = null, array $variables = [])</code> and <code>getPlaceholder()</code>. <code>TPlaceholderFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#iselectionformfield","title":"<code>ISelectionFormField</code>","text":"<p><code>ISelectionFormField</code> has to be implemented by form fields with a predefined set of possible values. The implementing class has to implement the getter and setter methods <code>options($options, $nestedOptions = false, $labelLanguageItems = true)</code> and <code>getOptions()</code> and additionally two methods related to nesting, i.e. whether the selectable options have a hierarchy: <code>supportsNestedOptions()</code> and <code>getNestedOptions()</code>. <code>TSelectionFormField</code> provides a default implementation of these four methods.</p>"},{"location":"php/api/form_builder/structure/#isuffixedformfield","title":"<code>ISuffixedFormField</code>","text":"<p><code>ISuffixedFormField</code> has to be implemented by form fields that support supports displaying a suffix behind the actual input field. The implementing class has to implement the methods <code>suffix($languageItem = null, array $variables = [])</code> and <code>getSuffix()</code>. <code>TSuffixedFormField</code> provides a default implementation of these two methods.</p>"},{"location":"php/api/form_builder/structure/#tdefaultidformfield","title":"<code>TDefaultIdFormField</code>","text":"<p>Form fields that have a default id have to use <code>TDefaultIdFormField</code> and have to implement the method <code>getDefaultId()</code>.</p>"},{"location":"php/api/form_builder/structure/#displaying-forms","title":"Displaying Forms","text":"<p>The only thing to do in a template to display the whole form including all of the necessary JavaScript is to put</p> <pre><code>{unsafe:$form->getHtml()}\n</code></pre> <p>into the template file at the relevant position.</p>"},{"location":"php/api/form_builder/validation_data/","title":"Form Validation and Form Data","text":""},{"location":"php/api/form_builder/validation_data/#form-validation","title":"Form Validation","text":"<p>Every form field class has to implement <code>IFormField::validate()</code> according to their internal logic of what constitutes a valid value. If a certain constraint for the value is not met, a form field validation error object is added to the form field. Form field validation error classes have to implement the interface <code>IFormFieldValidationError</code>.</p> <p>In addition to intrinsic validations like checking the length of the value of a text form field, in many cases, there are additional constraints specific to the form like ensuring that the text is not already used by a different object of the same database object class. Such additional validations can be added to (and removed from) the form field via implementations of the <code>IFormFieldValidator</code> interface.</p>"},{"location":"php/api/form_builder/validation_data/#iformfieldvalidationerror-formfieldvalidationerror","title":"<code>IFormFieldValidationError</code> / <code>FormFieldValidationError</code>","text":"<p><code>IFormFieldValidationError</code> requires the following methods:</p> <ul> <li><code>__construct($type, $languageItem = null, array $information = [])</code> creates a new validation error object for an error with the given type and message stored in the given language items. The information array is used when generating the error message.</li> <li><code>getHtml()</code> returns the HTML element representing the error that is shown to the user.</li> <li><code>getMessage()</code> returns the error message based on the language item and information array given in the constructor.</li> <li><code>getInformation()</code> and <code>getType()</code> are getters for the first and third parameter of the constructor.</li> </ul> <p><code>FormFieldValidationError</code> is a default implementation of the interface that shows the error in an <code>small.innerError</code> HTML element below the form field.</p> <p>Form field validation errors are added to form fields via the <code>IFormField::addValidationError(IFormFieldValidationError $error)</code> method.</p>"},{"location":"php/api/form_builder/validation_data/#iformfieldvalidator-formfieldvalidator","title":"<code>IFormFieldValidator</code> / <code>FormFieldValidator</code>","text":"<p><code>IFormFieldValidator</code> requires the following methods:</p> <ul> <li><code>__construct($id, callable $validator)</code> creates a new validator with the given id that passes the validated form field to the given callable that does the actual validation. <code>static validateId($id)</code> is used to check if the given id is valid.</li> <li><code>__invoke(IFormField $field)</code> is used when the form field is validated to execute the validator.</li> <li><code>getId()</code> returns the id of the validator.</li> </ul> <p><code>FormFieldValidator</code> is a default implementation of the interface.</p> <p>Form field validators are added to form fields via the <code>addValidator(IFormFieldValidator $validator)</code> method.</p>"},{"location":"php/api/form_builder/validation_data/#example","title":"Example","text":"<p>The following source code adds a validator that validates whether the value in the input field matches a specific value.</p> <pre><code>$container->appendChildren([\n FooField::create('a')\n ->addValidator(new FormFieldValidator('b', function (FooField $formField) {\n if ($formField->getValue() != 'value') {\n $formField->addValidationError(\n new FormFieldValidationError(\n 'type',\n 'phrase'\n )\n );\n }\n })),\n]);\n</code></pre>"},{"location":"php/api/form_builder/validation_data/#form-data","title":"Form Data","text":"<p>After a form is successfully validated, the data of the form fields (returned by <code>IFormDocument::getData()</code>) have to be extracted which is the job of the <code>IFormDataHandler</code> object returned by <code>IFormDocument::getDataHandler()</code>. Form data handlers themselves, however, are only iterating through all <code>IFormDataProcessor</code> instances that have been registered with the data handler.</p>"},{"location":"php/api/form_builder/validation_data/#iformdatahandler-formdatahandler","title":"<code>IFormDataHandler</code> / <code>FormDataHandler</code>","text":"<p><code>IFormDataHandler</code> requires the following methods:</p> <ul> <li><code>addProcessor(IFormDataProcessor $processor)</code> adds a new data processor to the data handler.</li> <li><code>getFormData(IFormDocument $document)</code> returns the data of the given form by applying all registered data handlers on the form.</li> <li><code>getObjectData(IFormDocument $document, IStorableObject $object)</code> returns the data of the given object which will be used to populate the form field values of the given form.</li> </ul> <p><code>FormDataHandler</code> is the default implementation of this interface and should also be extended instead of implementing the interface directly.</p>"},{"location":"php/api/form_builder/validation_data/#iformdataprocessor-defaultformdataprocessor","title":"<code>IFormDataProcessor</code> / <code>DefaultFormDataProcessor</code>","text":"<p><code>IFormDataProcessor</code> requires the following methods:</p> <ul> <li><code>processFormData(IFormDocument $document, array $parameters)</code> is called by <code>IFormDataHandler::getFormData()</code>. The method processes the given parameters array and returns the processed version.</li> <li><code>processObjectData(IFormDocument $document, array $data, IStorableObject $object)</code> is called by <code>IFormDataHandler::getObjectData()</code>. The method processes the given object data array and returns the processed version.</li> </ul> <p>When <code>FormDocument</code> creates its <code>FormDataHandler</code> instance, it automatically registers an <code>DefaultFormDataProcessor</code> object as the first data processor. <code>DefaultFormDataProcessor</code> puts the save value of all form fields that are available and have a save value into <code>$parameters['data']</code> using the form field\u2019s object property as the array key.</p> <p><code>IFormDataProcessor</code> should not be implemented directly. Instead, <code>AbstractFormDataProcessor</code> should be extended.</p> <p>All form data is put into the <code>data</code> sub-array so that the whole <code>$parameters</code> array can be passed to a database object action object that requires the actual database object data to be in the <code>data</code> sub-array.</p> <p>When adding a data processor to a form, make sure to add the data processor after the form has been built.</p>"},{"location":"php/api/form_builder/validation_data/#additional-data-processors","title":"Additional Data Processors","text":""},{"location":"php/api/form_builder/validation_data/#customformdataprocessor","title":"<code>CustomFormDataProcessor</code>","text":"<p>As mentioned above, the data in the <code>data</code> sub-array is intended to directly create or update the database object with. As these values are used in the database query directly, these values cannot contain arrays. Several form fields, however, store and return their data in form of arrays. Thus, this data cannot be returned by <code>IFormField::getSaveValue()</code> so that <code>IFormField::hasSaveValue()</code> returns <code>false</code> and the form field\u2019s data is not collected by the standard <code>DefaultFormDataProcessor</code> object.</p> <p>Instead, such form fields register a <code>CustomFormDataProcessor</code> in their <code>IFormField::populate()</code> method that inserts the form field value into the <code>$parameters</code> array directly. This way, the relevant database object action method has access to the data to save it appropriately.</p> <p>The constructor of <code>CustomFormDataProcessor</code> requires an id (that is primarily used in error messages during the validation of the second parameter) and callables for <code>IFormDataProcessor::processFormData()</code> and <code>IFormDataProcessor::processObjectData()</code> which are passed the same parameters as the <code>IFormDataProcessor</code> methods. Only one of the callables has to be given, the other one then defaults to simply returning the relevant array unchanged.</p>"},{"location":"php/api/form_builder/validation_data/#example_1","title":"Example","text":"<p>The following source code adds a custom processor that handles the return of <code>MultilineItemListFormField</code> and converts the content of an array into a multiline string in order to store it in the database.</p> <pre><code>$form->getDataHandler()->addProcessor(\n new CustomFormDataProcessor(\n 'additionalItems',\n static function (IFormDocument $document, array $parameters) {\n $additionalItems = $document->getNodeById('additionalItems');\n \\assert($additionalItems instanceof MultilineItemListFormField);\n\n $value = $additionalItems->getValue();\n if ($value === null || $value === []) {\n $parameters['data']['additionalItems'] = null;\n } else {\n $parameters['data']['additionalItems'] = \\implode(\"\\n\", $value);\n }\n\n return $parameters;\n },\n static function (IFormDocument $document, array $data, IStorableObject $object) {\n if ($object->additionalItems !== null) {\n $data['additionalItems'] = \\explode(\"\\n\", $data['additionalItems']);\n }\n\n return $data;\n }\n )\n);\n</code></pre>"},{"location":"php/api/form_builder/validation_data/#voidformdataprocessor","title":"<code>VoidFormDataProcessor</code>","text":"<p>Some form fields might only exist to toggle the visibility of other form fields (via dependencies) but the data of form field itself is irrelevant. As <code>DefaultFormDataProcessor</code> collects the data of all form fields, an additional data processor in the form of a <code>VoidFormDataProcessor</code> can be added whose constructor <code>__construct($property, $isDataProperty = true)</code> requires the name of the relevant object property/form id and whether the form field value is stored in the <code>data</code> sub-array or directory in the <code>$parameters</code> array. When the data processor is invoked, it checks whether the relevant entry in the <code>$parameters</code> array exists and voids it by removing it from the array.</p>"},{"location":"tutorial/series/overview/","title":"Tutorial Series","text":"<p>In this tutorial series, we will code a package that allows administrators to create a registry of people. In this context, \"people\" does not refer to users registered on the website but anybody living, dead or fictional.</p> <p>We will start this tutorial series by creating a base structure for the package and then continue by adding further features step by step using different APIs. Note that in the context of this example, not every added feature might make perfect sense but the goal of this tutorial is not to create a useful package but to introduce you to WoltLab Suite.</p> <ul> <li>Part 1: Base Structure</li> <li>Part 2: Event and Template Listeners</li> <li>Part 3: Person Page and Comments</li> <li>Part 4: Box and Box Conditions</li> <li>Part 5: Person Information</li> <li>Part 6: Activity Points and Activity Events</li> </ul>"},{"location":"tutorial/series/part_1/","title":"Tutorial Series Part 1: Base Structure","text":"<p>In the first part of this tutorial series, we will lay out what the basic version of package should be able to do and how to implement these functions.</p>"},{"location":"tutorial/series/part_1/#package-functionality","title":"Package Functionality","text":"<p>The package should provide the following possibilities/functions:</p> <ul> <li>Sortable list of all people in the ACP</li> <li>Ability to add, edit and delete people in the ACP</li> <li>Restrict the ability to add, edit and delete people (in short: manage people) in the ACP</li> <li>Sortable list of all people in the front end</li> </ul>"},{"location":"tutorial/series/part_1/#used-components","title":"Used Components","text":"<p>We will use the following package installation plugins:</p> <ul> <li>acpTemplate package installation plugin,</li> <li>acpMenu package installation plugin,</li> <li>database package installation plugin,</li> <li>file package installation plugin,</li> <li>language package installation plugin,</li> <li>menuItem package installation plugin,</li> <li>page package installation plugin,</li> <li>template package installation plugin,</li> <li>userGroupOption package installation plugin,</li> </ul> <p>use database objects, create pages and use templates.</p>"},{"location":"tutorial/series/part_1/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure:</p> <pre><code>\u251c\u2500\u2500 acpMenu.xml\n\u251c\u2500\u2500 acptemplates\n\u2502 \u251c\u2500\u2500 personAdd.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.php\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u251c\u2500\u2500 form\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 PersonAddForm.class.php\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 PersonEditForm.class.php\n\u2502 \u2502 \u2514\u2500\u2500 page\n\u2502 \u2502 \u2514\u2500\u2500 PersonListPage.class.php\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 Person.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonAction.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonEditor.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonList.class.php\n\u2502 \u2514\u2500\u2500 page\n\u2502 \u2514\u2500\u2500 PersonListPage.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 menuItem.xml\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 page.xml\n\u251c\u2500\u2500 templates\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u2514\u2500\u2500 userGroupOption.xml\n</code></pre>"},{"location":"tutorial/series/part_1/#person-modeling","title":"Person Modeling","text":""},{"location":"tutorial/series/part_1/#database-table","title":"Database Table","text":"<p>As the first step, we have to model the people we want to manage with this package. As this is only an introductory tutorial, we will keep things simple and only consider the first and last name of a person. Thus, the database table we will store the people in only contains three columns:</p> <ol> <li><code>personID</code> is the unique numeric identifier of each person created,</li> <li><code>firstName</code> contains the first name of the person,</li> <li><code>lastName</code> contains the last name of the person.</li> </ol> <p>The first file for our package is the <code>install_com.woltlab.wcf.people.php</code> file used to create such a database table during package installation:</p> files/acp/database/install_com.woltlab.wcf.people.php <pre><code><?php\n\nuse wcf\\system\\database\\table\\column\\NotNullVarchar255DatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\ObjectIdDatabaseTableColumn;\nuse wcf\\system\\database\\table\\DatabaseTable;\nuse wcf\\system\\database\\table\\index\\DatabaseTablePrimaryIndex;\n\nreturn [\n DatabaseTable::create('wcf1_person')\n ->columns([\n ObjectIdDatabaseTableColumn::create('personID'),\n NotNullVarchar255DatabaseTableColumn::create('firstName'),\n NotNullVarchar255DatabaseTableColumn::create('lastName'),\n ])\n ->indices([\n DatabaseTablePrimaryIndex::create()\n ->columns(['personID']),\n ]),\n];\n</code></pre>"},{"location":"tutorial/series/part_1/#database-object","title":"Database Object","text":""},{"location":"tutorial/series/part_1/#person","title":"<code>Person</code>","text":"<p>In our PHP code, each person will be represented by an object of the following class:</p> files/lib/data/person/Person.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\DatabaseObject;\nuse wcf\\system\\request\\IRouteController;\n\n/**\n * Represents a person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @property-read int $personID unique id of the person\n * @property-read string $firstName first name of the person\n * @property-read string $lastName last name of the person\n */\nclass Person extends DatabaseObject implements IRouteController\n{\n /**\n * Returns the first and last name of the person if a person object is treated as a string.\n *\n * @return string\n */\n public function __toString()\n {\n return $this->getTitle();\n }\n\n /**\n * @inheritDoc\n */\n public function getTitle(): string\n {\n return $this->firstName . ' ' . $this->lastName;\n }\n}\n</code></pre> <p>The important thing here is that <code>Person</code> extends <code>DatabaseObject</code>. Additionally, we implement the <code>IRouteController</code> interface, which allows us to use <code>Person</code> objects to create links, and we implement PHP's magic __toString() method for convenience.</p> <p>For every database object, you need to implement three additional classes: an action class, an editor class and a list class.</p>"},{"location":"tutorial/series/part_1/#personaction","title":"<code>PersonAction</code>","text":"files/lib/data/person/PersonAction.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\AbstractDatabaseObjectAction;\n\n/**\n * Executes person-related actions.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @method Person create()\n * @method PersonEditor[] getObjects()\n * @method PersonEditor getSingleObject()\n */\nclass PersonAction extends AbstractDatabaseObjectAction\n{\n /**\n * @inheritDoc\n */\n protected $permissionsDelete = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n protected $requireACP = ['delete'];\n}\n</code></pre> <p>This implementation of <code>AbstractDatabaseObjectAction</code> is very basic and only sets the <code>$permissionsDelete</code> and <code>$requireACP</code> properties. This is done so that later on, when implementing the people list for the ACP, we can delete people simply via AJAX. <code>$permissionsDelete</code> has to be set to the permission needed in order to delete a person. We will later use the userGroupOption package installation plugin to create the <code>admin.content.canManagePeople</code> permission. <code>$requireACP</code> restricts deletion of people to the ACP.</p>"},{"location":"tutorial/series/part_1/#personeditor","title":"<code>PersonEditor</code>","text":"files/lib/data/person/PersonEditor.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\DatabaseObjectEditor;\n\n/**\n * Provides functions to edit people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @method static Person create(array $parameters = [])\n * @method Person getDecoratedObject()\n * @mixin Person\n */\nclass PersonEditor extends DatabaseObjectEditor\n{\n /**\n * @inheritDoc\n */\n protected static $baseClass = Person::class;\n}\n</code></pre> <p>This implementation of <code>DatabaseObjectEditor</code> fulfills the minimum requirement for a database object editor: setting the static <code>$baseClass</code> property to the database object class name.</p>"},{"location":"tutorial/series/part_1/#personlist","title":"<code>PersonList</code>","text":"files/lib/data/person/PersonList.class.php <pre><code><?php\n\nnamespace wcf\\data\\person;\n\nuse wcf\\data\\DatabaseObjectList;\n\n/**\n * Represents a list of people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\n *\n * @method Person current()\n * @method Person[] getObjects()\n * @method Person|null search($objectID)\n * @property Person[] $objects\n */\nclass PersonList extends DatabaseObjectList\n{\n}\n</code></pre> <p>Due to the default implementation of <code>DatabaseObjectList</code>, our <code>PersonList</code> class just needs to extend it and everything else is either automatically set by the code of <code>DatabaseObjectList</code> or, in the case of properties and methods, provided by that class.</p>"},{"location":"tutorial/series/part_1/#acp","title":"ACP","text":"<p>Next, we will take care of the controllers and views for the ACP. In total, we need three each:</p> <ol> <li>page to list people,</li> <li>form to add people, and</li> <li>form to edit people.</li> </ol> <p>Before we create the controllers and views, let us first create the menu items for the pages in the ACP menu.</p>"},{"location":"tutorial/series/part_1/#acp-menu","title":"ACP Menu","text":"<p>We need to create three menu items:</p> <ol> <li>a \u201cparent\u201d menu item on the second level of the ACP menu item tree,</li> <li>a third level menu item for the people list page, and</li> <li>a fourth level menu item for the form to add new people.</li> </ol> acpMenu.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/acpMenu.xsd\">\n <import>\n <acpmenuitem name=\"wcf.acp.menu.link.person\">\n <parent>wcf.acp.menu.link.content</parent>\n </acpmenuitem>\n <acpmenuitem name=\"wcf.acp.menu.link.person.list\">\n <controller>wcf\\acp\\page\\PersonListPage</controller>\n <parent>wcf.acp.menu.link.person</parent>\n <permissions>admin.content.canManagePeople</permissions>\n </acpmenuitem>\n <acpmenuitem name=\"wcf.acp.menu.link.person.add\">\n <controller>wcf\\acp\\form\\PersonAddForm</controller>\n <parent>wcf.acp.menu.link.person.list</parent>\n <permissions>admin.content.canManagePeople</permissions>\n <icon>plus</icon>\n </acpmenuitem>\n </import>\n</data>\n</code></pre> <p>We choose <code>wcf.acp.menu.link.content</code> as the parent menu item for the first menu item <code>wcf.acp.menu.link.person</code> because the people we are managing is just one form of content. The fourth level menu item <code>wcf.acp.menu.link.person.add</code> will only be shown as an icon and thus needs an additional element <code>icon</code> which takes a FontAwesome icon class as value.</p>"},{"location":"tutorial/series/part_1/#people-list","title":"People List","text":"<p>To list the people in the ACP, we need a <code>PersonListPage</code> class and a <code>personList</code> template.</p>"},{"location":"tutorial/series/part_1/#personlistpage","title":"<code>PersonListPage</code>","text":"files/lib/acp/page/PersonListPage.class.php <pre><code><?php\n\nnamespace wcf\\acp\\page;\n\nuse wcf\\data\\person\\PersonList;\nuse wcf\\page\\SortablePage;\n\n/**\n * Shows the list of people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Page\n */\nclass PersonListPage extends SortablePage\n{\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.list';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public $objectListClassName = PersonList::class;\n\n /**\n * @inheritDoc\n */\n public $validSortFields = ['personID', 'firstName', 'lastName'];\n}\n</code></pre> <p>As WoltLab Suite Core already provides a powerful default implementation of a sortable page, our work here is minimal:</p> <ol> <li>We need to set the active ACP menu item via the <code>$activeMenuItem</code>.</li> <li><code>$neededPermissions</code> contains a list of permissions of which the user needs to have at least one in order to see the person list. We use the same permission for both the menu item and the page.</li> <li>The database object list class whose name is provided via <code>$objectListClassName</code> and that handles fetching the people from database is the <code>PersonList</code> class, which we have already created.</li> <li>To validate the sort field passed with the request, we set <code>$validSortFields</code> to the available database table columns.</li> </ol>"},{"location":"tutorial/series/part_1/#personlisttpl","title":"<code>personList.tpl</code>","text":"acptemplates/personList.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.list'}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.list{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonAdd'}{/link}\" class=\"button\">{icon name='plus'} <span>{lang}wcf.acp.menu.link.person.add{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{if $pages > 1}\n <div class=\"paginationTop\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n{/if}\n\n{if $objects|count}\n <div class=\"section tabularBox\">\n <table class=\"table jsObjectActionContainer\" data-object-action-class-name=\"wcf\\data\\person\\PersonAction\">\n <thead>\n <tr>\n <th class=\"columnID columnPersonID{if $sortField == 'personID'} active {$sortOrder}{/if}\" colspan=\"2\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=personID&sortOrder={if $sortField == 'personID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.global.objectID{/lang}</a></th>\n <th class=\"columnTitle columnFirstName{if $sortField == 'firstName'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=firstName&sortOrder={if $sortField == 'firstName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.firstName{/lang}</a></th>\n <th class=\"columnTitle columnLastName{if $sortField == 'lastName'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=lastName&sortOrder={if $sortField == 'lastName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.lastName{/lang}</a></th>\n\n {event name='columnHeads'}\n </tr>\n </thead>\n\n <tbody class=\"jsReloadPageWhenEmpty\">\n {foreach from=$objects item=person}\n <tr class=\"jsObjectActionObject\" data-object-id=\"{$person->getObjectID()}\">\n <td class=\"columnIcon\">\n <a href=\"{link controller='PersonEdit' object=$person}{/link}\" title=\"{lang}wcf.global.button.edit{/lang}\" class=\"jsTooltip\">{icon name='pencil'}</a>\n {objectAction action=\"delete\" objectTitle=$person->getTitle()}\n\n {event name='rowButtons'}\n </td>\n <td class=\"columnID\">{#$person->personID}</td>\n <td class=\"columnTitle columnFirstName\"><a href=\"{link controller='PersonEdit' object=$person}{/link}\">{$person->firstName}</a></td>\n <td class=\"columnTitle columnLastName\"><a href=\"{link controller='PersonEdit' object=$person}{/link}\">{$person->lastName}</a></td>\n\n {event name='columns'}\n </tr>\n {/foreach}\n </tbody>\n </table>\n </div>\n\n <footer class=\"contentFooter\">\n {if $pages > 1}\n <div class=\"paginationBottom\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n {/if}\n\n <nav class=\"contentFooterNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonAdd'}{/link}\" class=\"button\">{icon name='plus'} <span>{lang}wcf.acp.menu.link.person.add{/lang}</span></a></li>\n\n {event name='contentFooterNavigation'}\n </ul>\n </nav>\n </footer>\n{else}\n <p class=\"info\">{lang}wcf.global.noItems{/lang}</p>\n{/if}\n\n{include file='footer'}\n</code></pre> <p>We will go piece by piece through the template code:</p> <ol> <li>We include the <code>header</code> template and set the page title <code>wcf.acp.person.list</code>. You have to include this template for every page!</li> <li>We set the content header and additional provide a button to create a new person in the content header navigation.</li> <li>As not all people are listed on the same page if many people have been created, we need a pagination for which we use the <code>pages</code> template plugin. The <code>{hascontent}{content}{/content}{/hascontent}</code> construct ensures the <code>.paginationTop</code> element is only shown if the <code>pages</code> template plugin has a return value, thus if a pagination is necessary.</li> <li>Now comes the main part of the page, the list of the people, which will only be displayed if any people exist. Otherwise, an info box is displayed using the generic <code>wcf.global.noItems</code> language item. The <code>$objects</code> template variable is automatically assigned by <code>wcf\\page\\MultipleLinkPage</code> and contains the <code>PersonList</code> object used to read the people from database. The table itself consists of a <code>thead</code> and a <code>tbody</code> element and is extendable with more columns using the template events <code>columnHeads</code> and <code>columns</code>. In general, every table should provide these events. The default structure of a table is used here so that the first column of the content rows contains icons to edit and to delete the row (and provides another standard event <code>rowButtons</code>) and that the second column contains the ID of the person. The table can be sorted by clicking on the head of each column. The used variables <code>$sortField</code> and <code>$sortOrder</code> are automatically assigned to the template by <code>SortablePage</code>.</li> <li>The <code>.contentFooter</code> element is only shown if people exist as it basically repeats the <code>.contentHeaderNavigation</code> and <code>.paginationTop</code> element.</li> <li>The delete button for each person shown in the <code>.columnIcon</code> element relies on the global <code>WoltLabSuite/Core/Ui/Object/Action</code> module which only requires the <code>jsObjectActionContainer</code> CSS class in combination with the <code>data-object-action-class-name</code> attribute for the <code>table</code> element, the <code>jsObjectActionObject</code> CSS class for each person's <code>tr</code> element in combination with the <code>data-object-id</code> attribute, and lastly the delete button itself, which is created with the <code>objectAction</code> template plugin.</li> <li>The <code>.jsReloadPageWhenEmpty</code> CSS class on the <code>tbody</code> element ensures that once all persons on the page have been deleted, the page is reloaded.</li> <li>Lastly, the <code>footer</code> template is included that terminates the page. You also have to include this template for every page!</li> </ol> <p>Now, we have finished the page to manage the people so that we can move on to the forms with which we actually create and edit the people.</p>"},{"location":"tutorial/series/part_1/#person-add-form","title":"Person Add Form","text":"<p>Like the person list, the form to add new people requires a controller class and a template.</p>"},{"location":"tutorial/series/part_1/#personaddform","title":"<code>PersonAddForm</code>","text":"files/lib/acp/form/PersonAddForm.class.php <pre><code><?php\n\nnamespace wcf\\acp\\form;\n\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\container\\FormContainer;\nuse wcf\\system\\form\\builder\\field\\TextFormField;\n\n/**\n * Shows the form to create a new person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonAddForm extends AbstractFormBuilderForm\n{\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person.add';\n\n /**\n * @inheritDoc\n */\n public $formAction = 'create';\n\n /**\n * @inheritDoc\n */\n public $neededPermissions = ['admin.content.canManagePeople'];\n\n /**\n * @inheritDoc\n */\n public $objectActionClass = PersonAction::class;\n\n /**\n * @inheritDoc\n */\n public $objectEditLinkController = PersonEditForm::class;\n\n /**\n * @inheritDoc\n */\n protected function createForm()\n {\n parent::createForm();\n\n $this->form->appendChild(\n FormContainer::create('data')\n ->label('wcf.global.form.data')\n ->appendChildren([\n TextFormField::create('firstName')\n ->label('wcf.person.firstName')\n ->required()\n ->autoFocus()\n ->maximumLength(255),\n\n TextFormField::create('lastName')\n ->label('wcf.person.lastName')\n ->required()\n ->maximumLength(255),\n ])\n );\n }\n}\n</code></pre> <p>The properties here consist of three types: the \u201chousekeeping\u201d properties <code>$activeMenuItem</code> and <code>$neededPermissions</code>, which fulfill the same roles as for <code>PersonListPage</code>, and the <code>$objectEditLinkController</code> property, which is used to generate a link to edit the newly created person after submitting the form, and finally <code>$formAction</code> and <code>$objectActionClass</code> required by the PHP form builder API used to generate the form.</p> <p>Because of using form builder, we only have to set up the two form fields for entering the first and last name, respectively:</p> <ol> <li>Each field is a simple single-line text field, thus we use <code>TextFormField</code>.</li> <li>The parameter of the <code>create()</code> method expects the id of the field/name of the database object property, which is <code>firstName</code> and <code>lastName</code>, respectively, here.</li> <li>The language item of the label shown in the ouput above the input field is set via the <code>label()</code> method.</li> <li>As both fields have to be filled out, <code>required()</code> is called, and the maximum length is set via <code>maximumLength()</code>.</li> <li>Lastly, to make it easier to fill out the form more quickly, the first field is auto-focused by calling <code>autoFocus()</code>.</li> </ol>"},{"location":"tutorial/series/part_1/#personaddtpl","title":"<code>personAdd.tpl</code>","text":"acptemplates/personAdd.tpl <pre><code>{include file='header' pageTitle='wcf.acp.person.'|concat:$action}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">{lang}wcf.acp.person.{$action}{/lang}</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n <li><a href=\"{link controller='PersonList'}{/link}\" class=\"button\">{icon name='list'} <span>{lang}wcf.acp.menu.link.person.list{/lang}</span></a></li>\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{unsafe:$form->getHtml()}\n\n{include file='footer'}\n</code></pre> <p>We will now only concentrate on the new parts compared to <code>personList.tpl</code>:</p> <ol> <li>We use the <code>$action</code> variable to distinguish between the languages items used for adding a person and for creating a person.</li> <li>Because of form builder, we only have to call <code>{unsafe:$form->getHtml()}</code> to generate all relevant output for the form.</li> </ol>"},{"location":"tutorial/series/part_1/#person-edit-form","title":"Person Edit Form","text":"<p>As mentioned before, for the form to edit existing people, we only need a new controller as the template has already been implemented in a way that it handles both, adding and editing.</p>"},{"location":"tutorial/series/part_1/#personeditform","title":"<code>PersonEditForm</code>","text":"files/lib/acp/form/PersonEditForm.class.php <pre><code><?php\n\nnamespace wcf\\acp\\form;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\exception\\IllegalLinkException;\n\n/**\n * Shows the form to edit an existing person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Acp\\Form\n */\nclass PersonEditForm extends PersonAddForm\n{\n /**\n * @inheritDoc\n */\n public $activeMenuItem = 'wcf.acp.menu.link.person';\n\n /**\n * @inheritDoc\n */\n public $formAction = 'update';\n\n /**\n * @inheritDoc\n */\n public function readParameters()\n {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) {\n $this->formObject = new Person($_REQUEST['id']);\n\n if (!$this->formObject->getObjectID()) {\n throw new IllegalLinkException();\n }\n }\n }\n}\n</code></pre> <p>In general, edit forms extend the associated add form so that the code to read and to validate the input data is simply inherited.</p> <p>After setting a different active menu item, we have to change the value of <code>$formAction</code> because this form, in contrast to <code>PersonAddForm</code>, does not create but update existing persons.</p> <p>As we rely on form builder, the only thing necessary in this controller is to read and validate the edit object, i.e. the edited person, which is done in <code>readParameters()</code>.</p>"},{"location":"tutorial/series/part_1/#frontend","title":"Frontend","text":"<p>For the front end, that means the part with which the visitors of a website interact, we want to implement a simple sortable page that lists the people. This page should also be directly linked in the main menu.</p>"},{"location":"tutorial/series/part_1/#pagexml","title":"<code>page.xml</code>","text":"<p>First, let us register the page with the system because every front end page or form needs to be explicitly registered using the page package installation plugin:</p> page.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/page.xsd\">\n <import>\n <page identifier=\"com.woltlab.wcf.people.PersonList\">\n <pageType>system</pageType>\n <controller>wcf\\page\\PersonListPage</controller>\n <name language=\"de\">Personen-Liste</name>\n <name language=\"en\">Person List</name>\n\n <content language=\"de\">\n <title>Personen</title>\n </content>\n <content language=\"en\">\n <title>People</title>\n </content>\n </page>\n </import>\n</data>\n</code></pre> <p>For more information about what each of the elements means, please refer to the page package installation plugin page.</p>"},{"location":"tutorial/series/part_1/#menuitemxml","title":"<code>menuItem.xml</code>","text":"<p>Next, we register the menu item using the menuItem package installation plugin:</p> menuItem.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/menuItem.xsd\">\n <import>\n <item identifier=\"com.woltlab.wcf.people.PersonList\">\n <menu>com.woltlab.wcf.MainMenu</menu>\n <title language=\"de\">Personen</title>\n <title language=\"en\">People</title>\n <page>com.woltlab.wcf.people.PersonList</page>\n </item>\n </import>\n</data>\n</code></pre> <p>Here, the import parts are that we register the menu item for the main menu <code>com.woltlab.wcf.MainMenu</code> and link the menu item with the page <code>com.woltlab.wcf.people.PersonList</code>, which we just registered.</p>"},{"location":"tutorial/series/part_1/#people-list_1","title":"People List","text":"<p>As in the ACP, we need a controller and a template. You might notice that both the controller\u2019s (unqualified) class name and the template name are the same for the ACP and the front end. This is no problem because the qualified names of the classes differ and the files are stored in different directories and because the templates are installed by different package installation plugins and are also stored in different directories.</p>"},{"location":"tutorial/series/part_1/#personlistpage_1","title":"<code>PersonListPage</code>","text":"files/lib/page/PersonListPage.class.php <pre><code><?php\n\nnamespace wcf\\page;\n\nuse wcf\\data\\person\\PersonList;\n\n/**\n * Shows the list of people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Page\n */\nclass PersonListPage extends SortablePage\n{\n /**\n * @inheritDoc\n */\n public $defaultSortField = 'lastName';\n\n /**\n * @inheritDoc\n */\n public $objectListClassName = PersonList::class;\n\n /**\n * @inheritDoc\n */\n public $validSortFields = ['personID', 'firstName', 'lastName'];\n}\n</code></pre> <p>This class is almost identical to the ACP version. In the front end, we do not need to set the active menu item manually because the system determines the active menu item automatically based on the requested page. Furthermore, <code>$neededPermissions</code> has not been set because in the front end, users do not need any special permission to access the page. In the front end, we explicitly set the <code>$defaultSortField</code> so that the people listed on the page are sorted by their last name (in ascending order) by default.</p>"},{"location":"tutorial/series/part_1/#personlisttpl_1","title":"<code>personList.tpl</code>","text":"templates/personList.tpl <pre><code>{capture assign='contentTitle'}{lang}wcf.person.list{/lang} <span class=\"badge\">{#$items}</span>{/capture}\n\n{capture assign='headContent'}\n {if $pageNo < $pages}\n <link rel=\"next\" href=\"{link controller='PersonList'}pageNo={$pageNo+1}{/link}\">\n {/if}\n {if $pageNo > 1}\n <link rel=\"prev\" href=\"{link controller='PersonList'}{if $pageNo > 2}pageNo={$pageNo-1}{/if}{/link}\">\n {/if}\n <link rel=\"canonical\" href=\"{link controller='PersonList'}{if $pageNo > 1}pageNo={$pageNo}{/if}{/link}\">\n{/capture}\n\n{capture assign='sidebarRight'}\n <section class=\"box\">\n <form method=\"post\" action=\"{link controller='PersonList'}{/link}\">\n <h2 class=\"boxTitle\">{lang}wcf.global.sorting{/lang}</h2>\n\n <div class=\"boxContent\">\n <dl>\n <dt></dt>\n <dd>\n <select id=\"sortField\" name=\"sortField\">\n <option value=\"firstName\"{if $sortField == 'firstName'} selected{/if}>{lang}wcf.person.firstName{/lang}</option>\n <option value=\"lastName\"{if $sortField == 'lastName'} selected{/if}>{lang}wcf.person.lastName{/lang}</option>\n {event name='sortField'}\n </select>\n <select name=\"sortOrder\">\n <option value=\"ASC\"{if $sortOrder == 'ASC'} selected{/if}>{lang}wcf.global.sortOrder.ascending{/lang}</option>\n <option value=\"DESC\"{if $sortOrder == 'DESC'} selected{/if}>{lang}wcf.global.sortOrder.descending{/lang}</option>\n </select>\n </dd>\n </dl>\n\n <div class=\"formSubmit\">\n <input type=\"submit\" value=\"{lang}wcf.global.button.submit{/lang}\" accesskey=\"s\">\n </div>\n </div>\n </form>\n </section>\n{/capture}\n\n{include file='header'}\n\n{if $pages > 1}\n <div class=\"paginationTop\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n{/if}\n\n{if $items}\n <div class=\"section sectionContainerList\">\n <ol class=\"containerList personList\">\n {foreach from=$objects item=person}\n <li>\n <div class=\"box48\">\n {icon name='user' size=48}\n\n <div class=\"details personInformation\">\n <div class=\"containerHeadline\">\n <h3>{$person}</h3>\n </div>\n\n {hascontent}\n <ul class=\"inlineList commaSeparated\">\n {content}{event name='personData'}{/content}\n </ul>\n {/hascontent}\n\n {hascontent}\n <dl class=\"plain inlineDataList small\">\n {content}{event name='personStatistics'}{/content}\n </dl>\n {/hascontent}\n </div>\n </div>\n </li>\n {/foreach}\n </ol>\n </div>\n{else}\n <p class=\"info\">{lang}wcf.global.noItems{/lang}</p>\n{/if}\n\n<footer class=\"contentFooter\">\n {if $pages > 1}\n <div class=\"paginationBottom\">\n <woltlab-core-pagination\n page=\"{$pageNo}\"\n count=\"{$pages}\"\n url=\"{link controller='PersonList'}sortField={$sortField}&sortOrder={$sortOrder}{/link}\"\n ></woltlab-core-pagination>\n </div>\n {/if}\n\n {hascontent}\n <nav class=\"contentFooterNavigation\">\n <ul>\n {content}{event name='contentFooterNavigation'}{/content}\n </ul>\n </nav>\n {/hascontent}\n</footer>\n\n{include file='footer'}\n</code></pre> <p>If you compare this template to the one used in the ACP, you will recognize similar elements like the <code>.paginationTop</code> element, the <code>p.info</code> element if no people exist, and the <code>.contentFooter</code> element. Furthermore, we include a template called <code>header</code> before actually showing any of the page contents and terminate the template by including the <code>footer</code> template.</p> <p>Now, let us take a closer look at the differences:</p> <ul> <li>We do not explicitly create a <code>.contentHeader</code> element but simply assign the title to the <code>contentTitle</code> variable. The value of the assignment is simply the title of the page and a badge showing the number of listed people. The <code>header</code> template that we include later will handle correctly displaying the content header on its own based on the <code>$contentTitle</code> variable.</li> <li>Next, we create additional element for the HTML document\u2019s <code><head></code> element. In this case, we define the canonical link of the page and, because we are showing paginated content, add links to the previous and next page (if they exist).</li> <li>We want the page to be sortable but as we will not be using a table for listing the people like in the ACP, we are not able to place links to sort the people into the table head. Instead, usually a box is created in the sidebar on the right-hand side that contains <code>select</code> elements to determine sort field and sort order.</li> <li>The main part of the page is the listing of the people. We use a structure similar to the one used for displaying registered users. Here, for each person, we simply display a FontAwesome icon representing a person and show the person\u2019s full name relying on <code>Person::__toString()</code>. Additionally, like in the user list, we provide the initially empty <code>ul.inlineList.commaSeparated</code> and <code>dl.plain.inlineDataList.small</code> elements that can be filled by plugins using the templates events. </li> </ul>"},{"location":"tutorial/series/part_1/#usergroupoptionxml","title":"<code>userGroupOption.xml</code>","text":"<p>We have already used the <code>admin.content.canManagePeople</code> permissions several times, now we need to install it using the userGroupOption package installation plugin:</p> userGroupOption.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/userGroupOption.xsd\">\n <import>\n <options>\n <option name=\"admin.content.canManagePeople\">\n <categoryname>admin.content</categoryname>\n <optiontype>boolean</optiontype>\n <defaultvalue>0</defaultvalue>\n <admindefaultvalue>1</admindefaultvalue>\n <usersonly>1</usersonly>\n </option>\n </options>\n </import>\n</data>\n</code></pre> <p>We use the existing <code>admin.content</code> user group option category for the permission as the people are \u201ccontent\u201d (similar the the ACP menu item). As the permission is for administrators only, we set <code>defaultvalue</code> to <code>0</code> and <code>admindefaultvalue</code> to <code>1</code>. This permission is only relevant for registered users so that it should not be visible when editing the guest user group. This is achieved by setting <code>usersonly</code> to <code>1</code>.</p>"},{"location":"tutorial/series/part_1/#packagexml","title":"<code>package.xml</code>","text":"<p>Lastly, we need to create the <code>package.xml</code> file. For more information about this kind of file, please refer to the <code>package.xml</code> page.</p> package.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package name=\"com.woltlab.wcf.people\" xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/package.xsd\">\n <packageinformation>\n <packagename>WoltLab Suite Core Tutorial: People</packagename>\n <packagedescription>Adds a simple management system for people as part of a tutorial to create packages.</packagedescription>\n <version>5.4.0</version>\n <date>2022-01-17</date>\n </packageinformation>\n\n <authorinformation>\n <author>WoltLab GmbH</author>\n <authorurl>http://www.woltlab.com</authorurl>\n </authorinformation>\n\n <requiredpackages>\n <requiredpackage minversion=\"5.4.10\">com.woltlab.wcf</requiredpackage>\n </requiredpackages>\n\n <excludedpackages>\n <excludedpackage version=\"6.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n\n <instructions type=\"install\">\n <instruction type=\"acpTemplate\" />\n <instruction type=\"file\" />\n <instruction type=\"database\">acp/database/install_com.woltlab.wcf.people.php</instruction>\n <instruction type=\"template\" />\n <instruction type=\"language\" />\n\n <instruction type=\"acpMenu\" />\n <instruction type=\"page\" />\n <instruction type=\"menuItem\" />\n <instruction type=\"userGroupOption\" />\n </instructions>\n</package>\n</code></pre> <p>As this is a package for WoltLab Suite Core 3, we need to require it using <code><requiredpackage></code>. We require the latest version (when writing this tutorial) <code>5.4.0 Alpha 1</code>. Additionally, we disallow installation of the package in the next major version <code>6.0</code> by excluding the <code>6.0.0 Alpha 1</code> version.</p> <p>The most important part are to installation instructions. First, we install the ACP templates, files and templates, create the database table and import the language item. Afterwards, the ACP menu items and the permission are added. Now comes the part of the instructions where the order of the instructions is crucial: In <code>menuItem.xml</code>, we refer to the <code>com.woltlab.wcf.people.PersonList</code> page that is delivered by <code>page.xml</code>. As the menu item package installation plugin validates the given page and throws an exception if the page does not exist, we need to install the page before the menu item! </p> <p>This concludes the first part of our tutorial series after which you now have a working simple package with which you can manage people in the ACP and show the visitors of your website a simple list of all created people in the front end.</p> <p>The complete source code of this part can be found on GitHub.</p>"},{"location":"tutorial/series/part_2/","title":"Part 2: Event and Template Listeners","text":"<p>In the first part of this tutorial series, we have created the base structure of our people management package. In further parts, we will use the package of the first part as a basis to directly add new features. In order to explain how event listeners and template works, however, we will not directly adding a new feature to the package by altering it in this part, but we will assume that somebody else created the package and that we want to extend it the \u201ccorrect\u201d way by creating a plugin.</p> <p>The goal of the small plugin that will be created in this part is to add the birthday of the managed people. As in the first part, we will not bother with careful validation of the entered date but just make sure that it is a valid date.</p>"},{"location":"tutorial/series/part_2/#package-functionality","title":"Package Functionality","text":"<p>The package should provide the following possibilities/functions:</p> <ul> <li>List person\u2019s birthday (if set) in people list in the ACP</li> <li>Sort people list by birthday in the ACP</li> <li>Add or remove birthday when adding or editing person</li> <li>List person\u2019s birthday (if set) in people list in the front end</li> <li>Sort people list by birthday in the front end</li> </ul>"},{"location":"tutorial/series/part_2/#used-components","title":"Used Components","text":"<p>We will use the following package installation plugins:</p> <ul> <li>database package installation plugin,</li> <li>eventListener package installation plugin,</li> <li>file package installation plugin,</li> <li>language package installation plugin,</li> <li>template package installation plugin,</li> <li>templateListener package installation plugin.</li> </ul> <p>For more information about the event system, please refer to the dedicated page on events.</p>"},{"location":"tutorial/series/part_2/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure:</p> <pre><code>\u251c\u2500\u2500 eventListener.xml\n\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.birthday.php\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u2514\u2500\u2500 event\n\u2502 \u2514\u2500\u2500 listener\n\u2502 \u251c\u2500\u2500 BirthdayPersonAddFormListener.class.php\n\u2502 \u2514\u2500\u2500 BirthdaySortFieldPersonListPageListener.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 templateListener.xml\n\u2514\u2500\u2500 templates\n \u251c\u2500\u2500 __personListBirthday.tpl\n \u2514\u2500\u2500 __personListBirthdaySortField.tpl\n</code></pre>"},{"location":"tutorial/series/part_2/#extending-person-model","title":"Extending Person Model","text":"<p>The existing model of a person only contains the person\u2019s first name and their last name (in additional to the id used to identify created people). To add the birthday to the model, we need to create an additional database table column using the <code>database</code> package installation plugin:</p> files/acp/database/install_com.woltlab.wcf.people.birthday.php <pre><code><?php\n\nuse wcf\\system\\database\\table\\column\\DateDatabaseTableColumn;\nuse wcf\\system\\database\\table\\PartialDatabaseTable;\n\nreturn [\n PartialDatabaseTable::create('wcf1_person')\n ->columns([\n DateDatabaseTableColumn::create('birthday'),\n ]),\n];\n</code></pre> <p>If we have a <code>Person</code> object, this new property can be accessed the same way as the <code>personID</code> property, the <code>firstName</code> property, or the <code>lastName</code> property from the base package: <code>$person->birthday</code>.</p>"},{"location":"tutorial/series/part_2/#setting-birthday-in-acp","title":"Setting Birthday in ACP","text":"<p>To set the birthday of a person, we only have to add another form field with an event listener:</p> files/lib/system/event/listener/BirthdayPersonAddFormListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\acp\\form\\PersonAddForm;\nuse wcf\\form\\AbstractFormBuilderForm;\nuse wcf\\system\\form\\builder\\container\\FormContainer;\nuse wcf\\system\\form\\builder\\field\\DateFormField;\n\n/**\n * Handles setting the birthday when adding and editing people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class BirthdayPersonAddFormListener extends AbstractEventListener\n{\n /**\n * @see AbstractFormBuilderForm::createForm()\n */\n protected function onCreateForm(PersonAddForm $form): void\n {\n $dataContainer = $form->form->getNodeById('data');\n \\assert($dataContainer instanceof FormContainer);\n $dataContainer->appendChild(\n DateFormField::create('birthday')\n ->label('wcf.person.birthday')\n ->saveValueFormat('Y-m-d')\n ->nullable()\n );\n }\n}\n</code></pre> <p>registered via</p> <pre><code><eventlistener name=\"createForm@wcf\\acp\\form\\PersonAddForm\">\n <environment>admin</environment>\n <eventclassname>wcf\\acp\\form\\PersonAddForm</eventclassname>\n <eventname>createForm</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdayPersonAddFormListener</listenerclassname>\n <inherit>1</inherit>\n</eventlistener>\n</code></pre> <p>in <code>eventListener.xml</code>, see below.</p> <p>As <code>BirthdayPersonAddFormListener</code> extends <code>AbstractEventListener</code> and as the name of relevant event is <code>createForm</code>, <code>AbstractEventListener</code> internally automatically calls <code>onCreateForm()</code> with the event object as the parameter. It is important to set <code><inherit>1</inherit></code> so that the event listener is also executed for <code>PersonEditForm</code>, which extends <code>PersonAddForm</code>.</p> <p>The language item <code>wcf.person.birthday</code> used in the label is the only new one for this package:</p> language/de.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"de\">\n <category name=\"wcf.person\">\n <item name=\"wcf.person.birthday\"><![CDATA[Geburtstag]]></item>\n </category>\n</language>\n</code></pre> language/en.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/language.xsd\" languagecode=\"en\">\n <category name=\"wcf.person\">\n <item name=\"wcf.person.birthday\"><![CDATA[Birthday]]></item>\n </category>\n</language>\n</code></pre>"},{"location":"tutorial/series/part_2/#adding-birthday-table-column-in-acp","title":"Adding Birthday Table Column in ACP","text":"<p>To add a birthday column to the person list page in the ACP, we need three parts:</p> <ol> <li>an event listener that makes the <code>birthday</code> database table column a valid sort field,</li> <li>a template listener that adds the birthday column to the table\u2019s head, and</li> <li>a template listener that adds the birthday column to the table\u2019s rows.</li> </ol> <p>The first part is a very simple class:</p> files/lib/system/event/listener/BirthdaySortFieldPersonListPageListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\page\\SortablePage;\n\n/**\n * Makes people's birthday a valid sort field in the ACP and the front end.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class BirthdaySortFieldPersonListPageListener extends AbstractEventListener\n{\n /**\n * @see SortablePage::validateSortField()\n */\n public function onValidateSortField(SortablePage $page): void\n {\n $page->validSortFields[] = 'birthday';\n }\n}\n</code></pre> <p>We use <code>SortablePage</code> as a type hint instead of <code>wcf\\acp\\page\\PersonListPage</code> because we will be using the same event listener class in the front end to also allow sorting that list by birthday.</p> <p>As the relevant template codes are only one line each, we will simply put them directly in the <code>templateListener.xml</code> file that will be shown later on. The code for the table head is similar to the other <code>th</code> elements:</p> <pre><code><th class=\"columnDate columnBirthday{if $sortField == 'birthday'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=birthday&sortOrder={if $sortField == 'birthday' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.birthday{/lang}</a></th>\n</code></pre> <p>For the table body\u2019s column, we need to make sure that the birthday is only show if it is actually set:</p> <pre><code><td class=\"columnDate columnBirthday\">{if $person->birthday}{$person->birthday|strtotime|date}{/if}</td>\n</code></pre>"},{"location":"tutorial/series/part_2/#adding-birthday-in-front-end","title":"Adding Birthday in Front End","text":"<p>In the front end, we also want to make the list sortable by birthday and show the birthday as part of each person\u2019s \u201cstatistics\u201d.</p> <p>To add the birthday as a valid sort field, we use <code>BirthdaySortFieldPersonListPageListener</code> just as in the ACP. In the front end, we will now use a template (<code>__personListBirthdaySortField.tpl</code>) instead of a directly putting the template code in the <code>templateListener.xml</code> file:</p> templates/__personListBirthdaySortField.tpl <pre><code><option value=\"birthday\"{if $sortField == 'birthday'} selected{/if}>{lang}wcf.person.birthday{/lang}</option>\n</code></pre> <p>You might have noticed the two underscores at the beginning of the template file. For templates that are included via template listeners, this is the naming convention we use.</p> <p>Putting the template code into a file has the advantage that in the administrator is able to edit the code directly via a custom template group, even though in this case this might not be very probable.</p> <p>To show the birthday, we use the following template code for the <code>personStatistics</code> template event, which again makes sure that the birthday is only shown if it is actually set:</p> templates/__personListBirthday.tpl <pre><code>{if $person->birthday}\n <dt>{lang}wcf.person.birthday{/lang}</dt>\n <dd>{$person->birthday|strtotime|date}</dd>\n{/if}\n</code></pre>"},{"location":"tutorial/series/part_2/#templatelistenerxml","title":"<code>templateListener.xml</code>","text":"<p>The following code shows the <code>templateListener.xml</code> file used to install all mentioned template listeners:</p> templateListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/tornado/5.4/templateListener.xsd\">\n <import>\n <!-- admin -->\n <templatelistener name=\"personListBirthdayColumnHead\">\n <eventname>columnHeads</eventname>\n <environment>admin</environment>\n <templatecode><![CDATA[<th class=\"columnDate columnBirthday{if $sortField == 'birthday'} active {$sortOrder}{/if}\"><a href=\"{link controller='PersonList'}pageNo={$pageNo}&sortField=birthday&sortOrder={if $sortField == 'birthday' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}\">{lang}wcf.person.birthday{/lang}</a></th>]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <templatelistener name=\"personListBirthdayColumn\">\n <eventname>columns</eventname>\n <environment>admin</environment>\n <templatecode><![CDATA[<td class=\"columnDate columnBirthday\">{if $person->birthday}{$person->birthday|strtotime|date}{/if}</td>]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <!-- /admin -->\n\n <!-- user -->\n <templatelistener name=\"personListBirthday\">\n <eventname>personStatistics</eventname>\n <environment>user</environment>\n <templatecode><![CDATA[{include file='__personListBirthday'}]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <templatelistener name=\"personListBirthdaySortField\">\n <eventname>sortField</eventname>\n <environment>user</environment>\n <templatecode><![CDATA[{include file='__personListBirthdaySortField'}]]></templatecode>\n <templatename>personList</templatename>\n </templatelistener>\n <!-- /user -->\n </import>\n</data>\n</code></pre> <p>In cases where a template is used, we simply use the <code>include</code> syntax to load the template.</p>"},{"location":"tutorial/series/part_2/#eventlistenerxml","title":"<code>eventListener.xml</code>","text":"<p>There are two event listeners that make <code>birthday</code> a valid sort field in the ACP and the front end, respectively, and the third event listener takes care of setting the birthday.</p> eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/eventListener.xsd\">\n <import>\n <!-- admin -->\n <eventlistener name=\"validateSortField@wcf\\acp\\page\\PersonListPage\">\n <environment>admin</environment>\n <eventclassname>wcf\\acp\\page\\PersonListPage</eventclassname>\n <eventname>validateSortField</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdaySortFieldPersonListPageListener</listenerclassname>\n </eventlistener>\n <eventlistener name=\"createForm@wcf\\acp\\form\\PersonAddForm\">\n <environment>admin</environment>\n <eventclassname>wcf\\acp\\form\\PersonAddForm</eventclassname>\n <eventname>createForm</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdayPersonAddFormListener</listenerclassname>\n <inherit>1</inherit>\n </eventlistener>\n <!-- /admin -->\n\n <!-- user -->\n <eventlistener name=\"validateSortField@wcf\\page\\PersonListPage\">\n <environment>user</environment>\n <eventclassname>wcf\\page\\PersonListPage</eventclassname>\n <eventname>validateSortField</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\BirthdaySortFieldPersonListPageListener</listenerclassname>\n </eventlistener>\n <!-- /user -->\n </import>\n</data>\n</code></pre>"},{"location":"tutorial/series/part_2/#packagexml","title":"<code>package.xml</code>","text":"<p>The only relevant difference between the <code>package.xml</code> file of the base page from part 1 and the <code>package.xml</code> file of this package is that this package requires the base package <code>com.woltlab.wcf.people</code> (see <code><requiredpackages></code>):</p> package.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package name=\"com.woltlab.wcf.people.birthday\" xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/package.xsd\">\n <packageinformation>\n <packagename>WoltLab Suite Core Tutorial: People (Birthday)</packagename>\n <packagedescription>Adds a birthday field to the people management system as part of a tutorial to create packages.</packagedescription>\n <version>5.4.0</version>\n <date>2022-01-17</date>\n </packageinformation>\n\n <authorinformation>\n <author>WoltLab GmbH</author>\n <authorurl>http://www.woltlab.com</authorurl>\n </authorinformation>\n\n <requiredpackages>\n <requiredpackage minversion=\"5.4.10\">com.woltlab.wcf</requiredpackage>\n <requiredpackage minversion=\"5.4.0\">com.woltlab.wcf.people</requiredpackage>\n </requiredpackages>\n\n <excludedpackages>\n <excludedpackage version=\"6.0.0 Alpha 1\">com.woltlab.wcf</excludedpackage>\n </excludedpackages>\n\n <instructions type=\"install\">\n <instruction type=\"file\" />\n <instruction type=\"database\">acp/database/install_com.woltlab.wcf.people.birthday.php</instruction>\n <instruction type=\"template\" />\n <instruction type=\"language\" />\n\n <instruction type=\"eventListener\" />\n <instruction type=\"templateListener\" />\n </instructions>\n</package>\n</code></pre> <p>This concludes the second part of our tutorial series after which you now have extended the base package using event listeners and template listeners that allow you to enter the birthday of the people.</p> <p>The complete source code of this part can be found on GitHub.</p>"},{"location":"tutorial/series/part_3/","title":"Part 3: Person Page and Comments","text":"<p>In this part of our tutorial series, we will add a new front end page to our package that is dedicated to each person and shows their personal details. To make good use of this new page and introduce a new API of WoltLab Suite, we will add the opportunity for users to comment on the person using WoltLab Suite\u2019s reusable comment functionality.</p>"},{"location":"tutorial/series/part_3/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 1, the package will provide the following possibilities/functions after this part of the tutorial:</p> <ul> <li>Details page for each person linked in the front end person list</li> <li>Comment on people on their respective page (can be disabled per person)</li> <li>User online location for person details page with name and link to person details page</li> <li>Create menu items linking to specific person details pages</li> </ul>"},{"location":"tutorial/series/part_3/#used-components","title":"Used Components","text":"<p>In addition to the components used in part 1, we will use the objectType package installation plugin, use the comment API, create a runtime cache, and create a page handler.</p>"},{"location":"tutorial/series/part_3/#package-structure","title":"Package Structure","text":"<p>The complete package will have the following file structure (including the files from part 1):</p> <pre><code>\u251c\u2500\u2500 acpMenu.xml\n\u251c\u2500\u2500 acptemplates\n\u2502 \u251c\u2500\u2500 personAdd.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.php\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u251c\u2500\u2500 form\n\u2502 \u2502 \u2502 \u251c\u2500\u2500 PersonAddForm.class.php\n\u2502 \u2502 \u2502 \u2514\u2500\u2500 PersonEditForm.class.php\n\u2502 \u2502 \u2514\u2500\u2500 page\n\u2502 \u2502 \u2514\u2500\u2500 PersonListPage.class.php\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 Person.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonAction.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonEditor.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonList.class.php\n\u2502 \u251c\u2500\u2500 page\n\u2502 \u2502 \u251c\u2500\u2500 PersonListPage.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonPage.class.php\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u251c\u2500\u2500 cache\n\u2502 \u2502 \u2514\u2500\u2500 runtime\n\u2502 \u2502 \u2514\u2500\u2500 PersonRuntimeCache.class.php\n\u2502 \u251c\u2500\u2500 comment\n\u2502 \u2502 \u2514\u2500\u2500 manager\n\u2502 \u2502 \u2514\u2500\u2500 PersonCommentManager.class.php\n\u2502 \u2514\u2500\u2500 page\n\u2502 \u2514\u2500\u2500 handler\n\u2502 \u2514\u2500\u2500 PersonPageHandler.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 menuItem.xml\n\u251c\u2500\u2500 objectType.xml\n\u251c\u2500\u2500 package.xml\n\u251c\u2500\u2500 page.xml\n\u251c\u2500\u2500 templates\n\u2502 \u251c\u2500\u2500 person.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u2514\u2500\u2500 userGroupOption.xml\n</code></pre> <p>We will not mention every code change between the first part and this part, as we only want to focus on the important, new parts of the code. For example, there is a new <code>Person::getLink()</code> method and new language items have been added. For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_3/#runtime-cache","title":"Runtime Cache","text":"<p>To reduce the number of database queries when different APIs require person objects, we implement a runtime cache for people:</p> files/lib/system/cache/runtime/PersonRuntimeCache.class.php <pre><code><?php\n\nnamespace wcf\\system\\cache\\runtime;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\person\\PersonList;\n\n/**\n * Runtime cache implementation for people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Cache\\Runtime\n *\n * @method Person[] getCachedObjects()\n * @method Person getObject($objectID)\n * @method Person[] getObjects(array $objectIDs)\n */\nfinal class PersonRuntimeCache extends AbstractRuntimeCache\n{\n /**\n * @inheritDoc\n */\n protected $listClassName = PersonList::class;\n}\n</code></pre>"},{"location":"tutorial/series/part_3/#comments","title":"Comments","text":"<p>To allow users to comment on people, we need to tell the system that people support comments. This is done by registering a <code>com.woltlab.wcf.comment.commentableContent</code> object type whose processor implements ICommentManager:</p> objectType.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/objectType.xsd\">\n <import>\n <type>\n <name>com.woltlab.wcf.person.personComment</name>\n <definitionname>com.woltlab.wcf.comment.commentableContent</definitionname>\n <classname>wcf\\system\\comment\\manager\\PersonCommentManager</classname>\n </type>\n </import>\n</data>\n</code></pre> <p>The <code>PersonCommentManager</code> class extended <code>ICommentManager</code>\u2019s default implementation AbstractCommentManager:</p> files/lib/system/comment/manager/PersonCommentManager.class.php <pre><code><?php\n\nnamespace wcf\\system\\comment\\manager;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\person\\PersonEditor;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\WCF;\n\n/**\n * Comment manager implementation for people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Comment\\Manager\n */\nfinal class PersonCommentManager extends AbstractCommentManager\n{\n /**\n * @inheritDoc\n */\n protected $permissionAdd = 'user.person.canAddComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionAddWithoutModeration = 'user.person.canAddCommentWithoutModeration';\n\n /**\n * @inheritDoc\n */\n protected $permissionCanModerate = 'mod.person.canModerateComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionDelete = 'user.person.canDeleteComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionEdit = 'user.person.canEditComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionModDelete = 'mod.person.canDeleteComment';\n\n /**\n * @inheritDoc\n */\n protected $permissionModEdit = 'mod.person.canEditComment';\n\n /**\n * @inheritDoc\n */\n public function getLink($objectTypeID, $objectID)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID)->getLink();\n }\n\n /**\n * @inheritDoc\n */\n public function isAccessible($objectID, $validateWritePermission = false)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID) !== null;\n }\n\n /**\n * @inheritDoc\n */\n public function getTitle($objectTypeID, $objectID, $isResponse = false)\n {\n if ($isResponse) {\n return WCF::getLanguage()->get('wcf.person.commentResponse');\n }\n\n return WCF::getLanguage()->getDynamicVariable('wcf.person.comment');\n }\n\n /**\n * @inheritDoc\n */\n public function updateCounter($objectID, $value)\n {\n (new PersonEditor(new Person($objectID)))->updateCounters(['comments' => $value]);\n }\n}\n</code></pre> <ul> <li>First, the system is told the names of the permissions via the <code>$permission*</code> properties. More information about comment permissions can be found here.</li> <li>The <code>getLink()</code> method returns the link to the person with the passed comment id. As in <code>isAccessible()</code>, <code>PersonRuntimeCache</code> is used to potentially save database queries.</li> <li>The <code>isAccessible()</code> method checks if the active user can access the relevant person. As we do not have any special restrictions for accessing people, we only need to check if the person exists.</li> <li>The <code>getTitle()</code> method returns the title used for comments and responses, which is just a generic language item in this case.</li> <li>The <code>updateCounter()</code> updates the comments\u2019 counter of the person. We have added a new <code>comments</code> database table column to the <code>wcf1_person</code> database table in order to keep track on the number of comments.</li> </ul> <p>Additionally, we have added a new <code>enableComments</code> database table column to the <code>wcf1_person</code> database table whose value can be set when creating or editing a person in the ACP. With this option, comments on individual people can be disabled.</p> <p>Liking comments is already built-in and only requires some extra code in the <code>PersonPage</code> class for showing the likes of pre-loaded comments.</p>"},{"location":"tutorial/series/part_3/#person-page","title":"Person Page","text":""},{"location":"tutorial/series/part_3/#personpage","title":"<code>PersonPage</code>","text":"files/lib/page/PersonPage.class.php <pre><code><?php\n\nnamespace wcf\\page;\n\nuse wcf\\data\\comment\\StructuredCommentList;\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\comment\\CommentHandler;\nuse wcf\\system\\comment\\manager\\PersonCommentManager;\nuse wcf\\system\\exception\\IllegalLinkException;\nuse wcf\\system\\WCF;\n\n/**\n * Shows the details of a certain person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Page\n */\nclass PersonPage extends AbstractPage\n{\n /**\n * list of comments\n * @var StructuredCommentList\n */\n public $commentList;\n\n /**\n * person comment manager object\n * @var PersonCommentManager\n */\n public $commentManager;\n\n /**\n * id of the person comment object type\n * @var int\n */\n public $commentObjectTypeID = 0;\n\n /**\n * shown person\n * @var Person\n */\n public $person;\n\n /**\n * id of the shown person\n * @var int\n */\n public $personID = 0;\n\n /**\n * @inheritDoc\n */\n public function assignVariables()\n {\n parent::assignVariables();\n\n WCF::getTPL()->assign([\n 'commentCanAdd' => WCF::getSession()->getPermission('user.person.canAddComment'),\n 'commentList' => $this->commentList,\n 'commentObjectTypeID' => $this->commentObjectTypeID,\n 'lastCommentTime' => $this->commentList ? $this->commentList->getMinCommentTime() : 0,\n 'likeData' => MODULE_LIKE && $this->commentList ? $this->commentList->getLikeData() : [],\n 'person' => $this->person,\n ]);\n }\n\n /**\n * @inheritDoc\n */\n public function readData()\n {\n parent::readData();\n\n if ($this->person->enableComments) {\n $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID(\n 'com.woltlab.wcf.person.personComment'\n );\n $this->commentManager = CommentHandler::getInstance()->getObjectType(\n $this->commentObjectTypeID\n )->getProcessor();\n $this->commentList = CommentHandler::getInstance()->getCommentList(\n $this->commentManager,\n $this->commentObjectTypeID,\n $this->person->personID\n );\n }\n }\n\n /**\n * @inheritDoc\n */\n public function readParameters()\n {\n parent::readParameters();\n\n if (isset($_REQUEST['id'])) {\n $this->personID = \\intval($_REQUEST['id']);\n }\n $this->person = new Person($this->personID);\n if (!$this->person->personID) {\n throw new IllegalLinkException();\n }\n }\n}\n</code></pre> <p>The <code>PersonPage</code> class is similar to the <code>PersonEditForm</code> in the ACP in that it reads the id of the requested person from the request data and validates the id in <code>readParameters()</code>. The rest of the code only handles fetching the list of comments on the requested person. In <code>readData()</code>, this list is fetched using <code>CommentHandler::getCommentList()</code> if comments are enabled for the person. The <code>assignVariables()</code> method assigns some additional template variables like <code>$commentCanAdd</code>, which is <code>1</code> if the active person can add comments and is <code>0</code> otherwise, <code>$lastCommentTime</code>, which contains the UNIX timestamp of the last comment, and <code>$likeData</code>, which contains data related to the likes for the disabled comments.</p>"},{"location":"tutorial/series/part_3/#persontpl","title":"<code>person.tpl</code>","text":"templates/person.tpl <pre><code>{capture assign='pageTitle'}{$person} - {lang}wcf.person.list{/lang}{/capture}\n\n{capture assign='contentTitle'}{$person}{/capture}\n\n{include file='header'}\n\n{if $person->enableComments}\n {if $commentList|count || $commentCanAdd}\n <section id=\"comments\" class=\"section sectionContainerList\">\n <header class=\"sectionHeader\">\n <h2 class=\"sectionTitle\">\n {lang}wcf.person.comments{/lang}\n {if $person->comments}<span class=\"badge\">{#$person->comments}</span>{/if}\n </h2>\n </header>\n\n {include file='__commentJavaScript' commentContainerID='personCommentList'}\n\n <div class=\"personComments\">\n <ul id=\"personCommentList\" class=\"commentList containerList\" {*\n *}data-can-add=\"{if $commentCanAdd}true{else}false{/if}\" {*\n *}data-object-id=\"{$person->personID}\" {*\n *}data-object-type-id=\"{$commentObjectTypeID}\" {*\n *}data-comments=\"{if $person->comments}{$commentList->countObjects()}{else}0{/if}\" {*\n *}data-last-comment-time=\"{$lastCommentTime}\" {*\n *}>\n {include file='commentListAddComment' wysiwygSelector='personCommentListAddComment'}\n {include file='commentList'}\n </ul>\n </div>\n </section>\n {/if}\n{/if}\n\n<footer class=\"contentFooter\">\n {hascontent}\n <nav class=\"contentFooterNavigation\">\n <ul>\n {content}{event name='contentFooterNavigation'}{/content}\n </ul>\n </nav>\n {/hascontent}\n</footer>\n\n{include file='footer'}\n</code></pre> <p>For now, the <code>person</code> template is still very empty and only shows the comments in the content area. The template code shown for comments is very generic and used in this form in many locations as it only sets the header of the comment list and the container <code>ul#personCommentList</code> element for the comments shown by <code>commentList</code> template. The <code>ul#personCommentList</code> elements has five additional <code>data-</code> attributes required by the JavaScript API for comments for loading more comments or creating new ones. The <code>commentListAddComment</code> template adds the WYSIWYG support. The attribute <code>wysiwygSelector</code> should be the id of the comment list <code>personCommentList</code> with an additional <code>AddComment</code> suffix.</p>"},{"location":"tutorial/series/part_3/#pagexml","title":"<code>page.xml</code>","text":"page.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/page.xsd\">\n <import>\n <page identifier=\"com.woltlab.wcf.people.PersonList\">\n <pageType>system</pageType>\n <controller>wcf\\page\\PersonListPage</controller>\n <name language=\"de\">Personen-Liste</name>\n <name language=\"en\">Person List</name>\n\n <content language=\"de\">\n <title>Personen</title>\n </content>\n <content language=\"en\">\n <title>People</title>\n </content>\n </page>\n <page identifier=\"com.woltlab.wcf.people.Person\">\n <pageType>system</pageType>\n <controller>wcf\\page\\PersonPage</controller>\n <handler>wcf\\system\\page\\handler\\PersonPageHandler</handler>\n <name language=\"de\">Person</name>\n <name language=\"en\">Person</name>\n <requireObjectID>1</requireObjectID>\n <parent>com.woltlab.wcf.people.PersonList</parent>\n </page>\n </import>\n</data>\n</code></pre> <p>The <code>page.xml</code> file has been extended for the new person page with identifier <code>com.woltlab.wcf.people.Person</code>. Compared to the pre-existing <code>com.woltlab.wcf.people.PersonList</code> page, there are four differences:</p> <ol> <li>It has a <code><handler></code> element with a class name as value. This aspect will be discussed in more detail in the next section.</li> <li>There are no <code><content></code> elements because, both, the title and the content of the page are dynamically generated in the template.</li> <li>The <code><requireObjectID></code> tells the system that this page requires an object id to properly work, in this case a valid person id.</li> <li>This page has a <code><parent></code> page, the person list page. In general, the details page for any type of object that is listed on a different page has the list page as its parent.</li> </ol>"},{"location":"tutorial/series/part_3/#personpagehandler","title":"<code>PersonPageHandler</code>","text":"files/lib/system/page/handler/PersonPageHandler.class.php <pre><code><?php\n\nnamespace wcf\\system\\page\\handler;\n\nuse wcf\\data\\page\\Page;\nuse wcf\\data\\person\\PersonList;\nuse wcf\\data\\user\\online\\UserOnline;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\database\\util\\PreparedStatementConditionBuilder;\nuse wcf\\system\\WCF;\n\n/**\n * Page handler implementation for person page.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Page\\Handler\n */\nfinal class PersonPageHandler extends AbstractLookupPageHandler implements IOnlineLocationPageHandler\n{\n use TOnlineLocationPageHandler;\n\n /**\n * @inheritDoc\n */\n public function getLink($objectID)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID)->getLink();\n }\n\n /**\n * Returns the textual description if a user is currently online viewing this page.\n *\n * @see IOnlineLocationPageHandler::getOnlineLocation()\n *\n * @param Page $page visited page\n * @param UserOnline $user user online object with request data\n * @return string\n */\n public function getOnlineLocation(Page $page, UserOnline $user)\n {\n if ($user->pageObjectID === null) {\n return '';\n }\n\n $person = PersonRuntimeCache::getInstance()->getObject($user->pageObjectID);\n if ($person === null) {\n return '';\n }\n\n return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.' . $page->identifier, ['person' => $person]);\n }\n\n /**\n * @inheritDoc\n */\n public function isValid($objectID = null)\n {\n return PersonRuntimeCache::getInstance()->getObject($objectID) !== null;\n }\n\n /**\n * @inheritDoc\n */\n public function lookup($searchString)\n {\n $conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR');\n $conditionBuilder->add('person.firstName LIKE ?', ['%' . $searchString . '%']);\n $conditionBuilder->add('person.lastName LIKE ?', ['%' . $searchString . '%']);\n\n $personList = new PersonList();\n $personList->getConditionBuilder()->add($conditionBuilder, $conditionBuilder->getParameters());\n $personList->readObjects();\n\n $results = [];\n foreach ($personList as $person) {\n $results[] = [\n 'image' => 'user',\n 'link' => $person->getLink(),\n 'objectID' => $person->personID,\n 'title' => $person->getTitle(),\n ];\n }\n\n return $results;\n }\n\n /**\n * Prepares fetching all necessary data for the textual description if a user is currently online\n * viewing this page.\n *\n * @see IOnlineLocationPageHandler::prepareOnlineLocation()\n *\n * @param Page $page visited page\n * @param UserOnline $user user online object with request data\n */\n public function prepareOnlineLocation(Page $page, UserOnline $user)\n {\n if ($user->pageObjectID !== null) {\n PersonRuntimeCache::getInstance()->cacheObjectID($user->pageObjectID);\n }\n }\n}\n</code></pre> <p>Like any page handler, the <code>PersonPageHandler</code> class has to implement the IMenuPageHandler interface, which should be done by extending the AbstractMenuPageHandler class. As we want administrators to link to specific people in menus, for example, we have to also implement the ILookupPageHandler interface by extending the AbstractLookupPageHandler class.</p> <p>For the <code>ILookupPageHandler</code> interface, we need to implement three methods:</p> <ol> <li><code>getLink($objectID)</code> returns the link to the person page with the given id. In this case, we simply delegate this method call to the <code>Person</code> object returned by <code>PersonRuntimeCache::getObject()</code>.</li> <li><code>isValid($objectID)</code> returns <code>true</code> if the person with the given id exists, otherwise <code>false</code>. Here, we use <code>PersonRuntimeCache::getObject()</code> again and check if the return value is <code>null</code>, which is the case for non-existing people.</li> <li><code>lookup($searchString)</code> is used when setting up an internal link and when searching for the linked person. This method simply searches the first and last name of the people and returns an array with the person data. While the <code>link</code>, the <code>objectID</code>, and the <code>title</code> element are self-explanatory, the <code>image</code> element can either contain an HTML <code><img></code> tag, which is displayed next to the search result (WoltLab Suite uses an image tag for users showing their avatar, for example), or a FontAwesome icon class.</li> </ol> <p>Additionally, the class also implements IOnlineLocationPageHandler which is used to determine the online location of users. To ensure upwards-compatibility if the <code>IOnlineLocationPageHandler</code> interface changes, the TOnlineLocationPageHandler trait is used. The <code>IOnlineLocationPageHandler</code> interface requires two methods to be implemented:</p> <ol> <li><code>getOnlineLocation(Page $page, UserOnline $user)</code> returns the textual description of the online location. The language item for the user online locations should use the pattern <code>wcf.page.onlineLocation.{page identifier}</code>.</li> <li><code>prepareOnlineLocation(Page $page, UserOnline $user)</code> is called for each user online before the <code>getOnlineLocation()</code> calls. In this case, calling <code>prepareOnlineLocation()</code> first enables us to add all relevant person ids to the person runtime cache so that for all <code>getOnlineLocation()</code> calls combined, only one database query is necessary to fetch all person objects.</li> </ol> <p>This concludes the third part of our tutorial series after which each person has a dedicated page on which people can comment on the person.</p> <p>The complete source code of this part can be found on GitHub.</p>"},{"location":"tutorial/series/part_4/","title":"Part 4: Box and Box Conditions","text":"<p>In this part of our tutorial series, we add support for creating boxes listing people.</p>"},{"location":"tutorial/series/part_4/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 3, the package will provide the following functionality after this part of the tutorial:</p> <ul> <li>Creating boxes dynamically listing people</li> <li>Filtering the people listed in boxes using conditions</li> </ul>"},{"location":"tutorial/series/part_4/#used-components","title":"Used Components","text":"<p>In addition to the components used in previous parts, we will use the <code>objectTypeDefinition</code> package installation plugin and use the box and condition APIs.</p> <p>To pre-install a specific person list box, we refer to the documentation of the <code>box</code> package installation plugin.</p>"},{"location":"tutorial/series/part_4/#package-structure","title":"Package Structure","text":"<p>The complete package will have the following file structure (excluding unchanged files from part 3):</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u251c\u2500\u2500 box\n\u2502 \u2502 \u2514\u2500\u2500 PersonListBoxController.class.php\n\u2502 \u2514\u2500\u2500 condition\n\u2502 \u2514\u2500\u2500 person\n\u2502 \u251c\u2500\u2500 PersonFirstNameTextPropertyCondition.class.php\n\u2502 \u2514\u2500\u2500 PersonLastNameTextPropertyCondition.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 objectType.xml\n\u251c\u2500\u2500 objectTypeDefinition.xml\n\u2514\u2500\u2500 templates\n \u2514\u2500\u2500 boxPersonList.tpl\n</code></pre> <p>For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_4/#box-controller","title":"Box Controller","text":"<p>In addition to static boxes with fixed contents, administrators are able to create dynamic boxes with contents from the database. In our case here, we want administrators to be able to create boxes listing people. To do so, we first have to register a new object type for this person list box controller for the object type definition <code>com.woltlab.wcf.boxController</code>:</p> <pre><code><type>\n <name>com.woltlab.wcf.personList</name>\n <definitionname>com.woltlab.wcf.boxController</definitionname>\n <classname>wcf\\system\\box\\PersonListBoxController</classname>\n</type>\n</code></pre> <p>The <code>com.woltlab.wcf.boxController</code> object type definition requires the provided class to implement <code>wcf\\system\\box\\IBoxController</code>:</p> files/lib/system/box/PersonListBoxController.class.php <pre><code><?php\n\nnamespace wcf\\system\\box;\n\nuse wcf\\data\\person\\PersonList;\nuse wcf\\system\\WCF;\n\n/**\n * Dynamic box controller implementation for a list of persons.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Box\n */\nfinal class PersonListBoxController extends AbstractDatabaseObjectListBoxController\n{\n /**\n * @inheritDoc\n */\n protected $conditionDefinition = 'com.woltlab.wcf.box.personList.condition';\n\n /**\n * @inheritDoc\n */\n public $defaultLimit = 5;\n\n /**\n * @inheritDoc\n */\n protected $sortFieldLanguageItemPrefix = 'wcf.person';\n\n /**\n * @inheritDoc\n */\n protected static $supportedPositions = [\n 'sidebarLeft',\n 'sidebarRight',\n ];\n\n /**\n * @inheritDoc\n */\n public $validSortFields = [\n 'firstName',\n 'lastName',\n 'comments',\n ];\n\n /**\n * @inheritDoc\n */\n protected function getObjectList()\n {\n return new PersonList();\n }\n\n /**\n * @inheritDoc\n */\n protected function getTemplate()\n {\n return WCF::getTPL()->fetch('boxPersonList', 'wcf', [\n 'boxPersonList' => $this->objectList,\n 'boxSortField' => $this->sortField,\n 'boxPosition' => $this->box->position,\n ], true);\n }\n}\n</code></pre> <p>By extending <code>AbstractDatabaseObjectListBoxController</code>, we only have to provide minimal data ourself and rely mostly on the default implementation provided by <code>AbstractDatabaseObjectListBoxController</code>:</p> <ol> <li>As we will support conditions for the listed people, we have to set the relevant condition definition via <code>$conditionDefinition</code>.</li> <li><code>AbstractDatabaseObjectListBoxController</code> already supports restricting the number of listed objects. To do so, you only have to specify the default number of listed objects via <code>$defaultLimit</code>.</li> <li><code>AbstractDatabaseObjectListBoxController</code> also supports setting the sort order of the listed objects. You have to provide the supported sort fields via <code>$validSortFields</code> and specify the prefix used for the language items of the sort fields via <code>$sortFieldLanguageItemPrefix</code> so that for every <code>$validSortField</code> in <code>$validSortFields</code>, the language item <code>{$sortFieldLanguageItemPrefix}.{$validSortField}</code> must exist.</li> <li>The box system supports different positions. Each box controller specifies the positions it supports via <code>$supportedPositions</code>. To keep the implementation simple here as different positions might require different output in the template, we restrict ourselves to sidebars.</li> <li><code>getObjectList()</code> returns an instance of <code>DatabaseObjectList</code> that is used to read the listed objects. <code>getObjectList()</code> itself must not call <code>readObjects()</code>, as <code>AbstractDatabaseObjectListBoxController</code> takes care of calling the method after adding the conditions and setting the sort order.</li> <li><code>getTemplate()</code> returns the contents of the box relying on the <code>boxPersonList</code> template here:</li> </ol> templates/boxPersonList.tpl <pre><code><ul class=\"sidebarItemList\">\n {foreach from=$boxPersonList item=boxPerson}\n <li class=\"box24\">\n {icon name='user' size=24}\n\n <div class=\"sidebarItemTitle\">\n <h3>{anchor object=$boxPerson}</h3>\n {capture assign='__boxPersonDescription'}{lang __optional=true}wcf.person.boxList.description.{$boxSortField}{/lang}{/capture}\n {if $__boxPersonDescription}\n <small>{unsafe:$__boxPersonDescription}</small>\n {/if}\n </div>\n </li>\n {/foreach}\n</ul>\n</code></pre> <p>The template relies on a <code>.sidebarItemList</code> element, which is generally used for sidebar listings. (If different box positions were supported, we either have to generate different output by considering the value of <code>$boxPosition</code> in the template or by using different templates in <code>getTemplate()</code>.) One specific piece of code is the <code>$__boxPersonDescription</code> variable, which supports an optional description below the person's name relying on the optional language item <code>wcf.person.boxList.description.{$boxSortField}</code>. We only add one such language item when sorting the people by comments: In such a case, the number of comments will be shown. (When sorting by first and last name, there are no additional useful information that could be shown here, though the plugin from part 2 adding support for birthdays might also show the birthday when sorting by first or last name.)</p> <p>Lastly, we also provide the language item <code>wcf.acp.box.boxController.com.woltlab.wcf.personList</code>, which is used in the list of available box controllers.</p>"},{"location":"tutorial/series/part_4/#conditions","title":"Conditions","text":"<p>The condition system can be used to generally filter a list of objects. In our case, the box system supports conditions to filter the objects shown in a specific box. Admittedly, our current person implementation only contains minimal data so that filtering might not make the most sense here but it will still show how to use the condition system for boxes. We will support filtering the people by their first and last name so that, for example, a box can be created listing all people with a specific first name.</p> <p>The first step for condition support is to register a object type definition for the relevant conditions requiring the <code>IObjectListCondition</code> interface:</p> objectTypeDefinition.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/objectTypeDefinition.xsd\">\n <import>\n <definition>\n <name>com.woltlab.wcf.box.personList.condition</name>\n <interfacename>wcf\\system\\condition\\IObjectListCondition</interfacename>\n </definition>\n </import>\n</data>\n</code></pre> <p>Next, we register the specific conditions for filtering by the first and last name using this object type condition:</p> <pre><code><type>\n <name>com.woltlab.wcf.people.firstName</name>\n <definitionname>com.woltlab.wcf.box.personList.condition</definitionname>\n <classname>wcf\\system\\condition\\person\\PersonFirstNameTextPropertyCondition</classname>\n</type>\n<type>\n <name>com.woltlab.wcf.people.lastName</name>\n <definitionname>com.woltlab.wcf.box.personList.condition</definitionname>\n <classname>wcf\\system\\condition\\person\\PersonLastNameTextPropertyCondition</classname>\n</type>\n</code></pre> <p><code>PersonFirstNameTextPropertyCondition</code> and <code>PersonLastNameTextPropertyCondition</code> only differ minimally so that we only focus on <code>PersonFirstNameTextPropertyCondition</code> here, which relies on the default implementation <code>AbstractObjectTextPropertyCondition</code> and only requires specifying different object properties:</p> files/lib/system/condition/person/PersonFirstNameTextPropertyCondition.class.php <pre><code><?php\n\nnamespace wcf\\system\\condition\\person;\n\nuse wcf\\data\\person\\Person;\nuse wcf\\system\\condition\\AbstractObjectTextPropertyCondition;\n\n/**\n * Condition implementation for the first name of a person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license WoltLab License <http://www.woltlab.com/license-agreement.html>\n * @package WoltLabSuite\\Core\\System\\Condition\n */\nfinal class PersonFirstNameTextPropertyCondition extends AbstractObjectTextPropertyCondition\n{\n /**\n * @inheritDoc\n */\n protected $className = Person::class;\n\n /**\n * @inheritDoc\n */\n protected $description = 'wcf.person.condition.firstName.description';\n\n /**\n * @inheritDoc\n */\n protected $fieldName = 'personFirstName';\n\n /**\n * @inheritDoc\n */\n protected $label = 'wcf.person.firstName';\n\n /**\n * @inheritDoc\n */\n protected $propertyName = 'firstName';\n\n /**\n * @inheritDoc\n */\n protected $supportsMultipleValues = true;\n}\n</code></pre> <ol> <li><code>$className</code> contains the class name of the relevant database object from which the class name of the database object list is derived and <code>$propertyName</code> is the name of the database object's property that contains the value used for filtering.</li> <li>By setting <code>$supportsMultipleValues</code> to <code>true</code>, multiple comma-separated values can be specified so that, for example, a box can also only list people with either of two specific first names.</li> <li><code>$description</code> (optional), <code>$fieldName</code>, and <code>$label</code> are used in the output of the form field.</li> </ol> <p>(The implementation here is specific for <code>AbstractObjectTextPropertyCondition</code>. The <code>wcf\\system\\condition</code> namespace also contains several other default condition implementations.)</p>"},{"location":"tutorial/series/part_5/","title":"Part 5: Person Information","text":"<p>This part of our tutorial series lays the foundation for future parts in which we will be using additional APIs, which we have not used in this series yet. To make use of those APIs, we need content generated by users in the frontend.</p>"},{"location":"tutorial/series/part_5/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 4, the package will provide the following functionality after this part of the tutorial:</p> <ul> <li>Users are able to add information on the people in the frontend.</li> <li>Users are able to edit and delete the pieces of information they added.</li> <li>Moderators are able to edit and delete all pieces of information.</li> </ul>"},{"location":"tutorial/series/part_5/#used-components","title":"Used Components","text":"<p>In addition to the components used in previous parts, we will use the form builder API to create forms shown in dialogs instead of dedicated pages and we will, for the first time, add TypeScript code.</p>"},{"location":"tutorial/series/part_5/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure excluding unchanged files from previous parts:</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u251c\u2500\u2500 acp\n\u2502 \u2502 \u2514\u2500\u2500 database\n\u2502 \u2502 \u2514\u2500\u2500 install_com.woltlab.wcf.people.php\n\u2502 \u251c\u2500\u2500 js\n\u2502 \u2502 \u2514\u2500\u2500 WoltLabSuite\n\u2502 \u2502 \u2514\u2500\u2500 Core\n\u2502 \u2502 \u2514\u2500\u2500 Controller\n\u2502 \u2502 \u2514\u2500\u2500 Person.js\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 Person.class.php\n\u2502 \u2502 \u2514\u2500\u2500 information\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformation.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformationAction.class.php\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformationEditor.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonInformationList.class.php\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u2514\u2500\u2500 worker\n\u2502 \u2514\u2500\u2500 PersonRebuildDataWorker.class.php\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u251c\u2500\u2500 objectType.xml\n\u251c\u2500\u2500 templates\n\u2502 \u251c\u2500\u2500 person.tpl\n\u2502 \u2514\u2500\u2500 personList.tpl\n\u251c\u2500\u2500 ts\n\u2502 \u2514\u2500\u2500 WoltLabSuite\n\u2502 \u2514\u2500\u2500 Core\n\u2502 \u2514\u2500\u2500 Controller\n\u2502 \u2514\u2500\u2500 Person.ts\n\u2514\u2500\u2500 userGroupOption.xml\n</code></pre> <p>For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_5/#miscellaneous","title":"Miscellaneous","text":"<p>Before we focus on the main aspects of this part, we mention some minor aspects that will be used later on:</p> <ul> <li>Several new user group options and the relevant language items have been added related to creating, editing, and deleting information:<ul> <li><code>mod.person.canEditInformation</code> and <code>mod.person.canDeleteInformation</code> are moderative permissions to edit and delete any piece of information, regardless of who created it.</li> <li><code>user.person.canAddInformation</code> is the permission for users to add new pieces of information.</li> <li><code>user.person.canEditInformation</code> and <code>user.person.canDeleteInformation</code> are the user permissions to edit and the piece of information they created.</li> </ul> </li> <li>The actual information text will be entered via a WYSIWYG editor, which requires an object type of the definition <code>com.woltlab.wcf.message</code>: <code>com.woltlab.wcf.people.information</code>.</li> <li><code>personList.tpl</code> has been adjusted to show the number of pieces of information in the person statistics section.</li> <li>We have not updated the person list box to also support sorting by the number of pieces of information added for each person.</li> </ul>"},{"location":"tutorial/series/part_5/#person-information-model","title":"Person Information Model","text":"<p>The PHP file with the database layout has been updated as follows:</p> files/acp/database/install_com.woltlab.wcf.people.php <pre><code><?php\n\nuse wcf\\system\\database\\table\\column\\DefaultTrueBooleanDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\IntDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\NotNullInt10DatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\NotNullVarchar255DatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\ObjectIdDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\SmallintDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\TextDatabaseTableColumn;\nuse wcf\\system\\database\\table\\column\\VarcharDatabaseTableColumn;\nuse wcf\\system\\database\\table\\DatabaseTable;\nuse wcf\\system\\database\\table\\index\\DatabaseTableForeignKey;\nuse wcf\\system\\database\\table\\index\\DatabaseTablePrimaryIndex;\n\nreturn [\n DatabaseTable::create('wcf1_person')\n ->columns([\n ObjectIdDatabaseTableColumn::create('personID'),\n NotNullVarchar255DatabaseTableColumn::create('firstName'),\n NotNullVarchar255DatabaseTableColumn::create('lastName'),\n NotNullInt10DatabaseTableColumn::create('informationCount')\n ->defaultValue(0),\n SmallintDatabaseTableColumn::create('comments')\n ->length(5)\n ->notNull()\n ->defaultValue(0),\n DefaultTrueBooleanDatabaseTableColumn::create('enableComments'),\n ])\n ->indices([\n DatabaseTablePrimaryIndex::create()\n ->columns(['personID']),\n ]),\n\n DatabaseTable::create('wcf1_person_information')\n ->columns([\n ObjectIdDatabaseTableColumn::create('informationID'),\n NotNullInt10DatabaseTableColumn::create('personID'),\n TextDatabaseTableColumn::create('information'),\n IntDatabaseTableColumn::create('userID')\n ->length(10),\n NotNullVarchar255DatabaseTableColumn::create('username'),\n VarcharDatabaseTableColumn::create('ipAddress')\n ->length(39)\n ->notNull(true)\n ->defaultValue(''),\n NotNullInt10DatabaseTableColumn::create('time'),\n ])\n ->indices([\n DatabaseTablePrimaryIndex::create()\n ->columns(['informationID']),\n ])\n ->foreignKeys([\n DatabaseTableForeignKey::create()\n ->columns(['personID'])\n ->referencedTable('wcf1_person')\n ->referencedColumns(['personID'])\n ->onDelete('CASCADE'),\n DatabaseTableForeignKey::create()\n ->columns(['userID'])\n ->referencedTable('wcf1_user')\n ->referencedColumns(['userID'])\n ->onDelete('SET NULL'),\n ]),\n];\n</code></pre> <ul> <li>The number of pieces of information per person is tracked via the new <code>informationCount</code> column.</li> <li>The <code>wcf1_person_information</code> table has been added for the <code>PersonInformation</code> model. The meaning of the different columns is explained in the property documentation part of <code>PersonInformation</code>'s documentation (see below). The two foreign keys ensure that if a person is deleted, all of their information is also deleted, and that if a user is deleted, the <code>userID</code> column is set to <code>NULL</code>.</li> </ul> files/lib/data/person/information/PersonInformation.class.php <pre><code><?php\n\nnamespace wcf\\data\\person\\information;\n\nuse wcf\\data\\DatabaseObject;\nuse wcf\\data\\person\\Person;\nuse wcf\\data\\user\\UserProfile;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\cache\\runtime\\UserProfileRuntimeCache;\nuse wcf\\system\\html\\output\\HtmlOutputProcessor;\nuse wcf\\system\\WCF;\n\n/**\n * Represents a piece of information for a person.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\\Information\n *\n * @property-read int $informationID unique id of the information\n * @property-read int $personID id of the person the information belongs to\n * @property-read string $information information text\n * @property-read int|null $userID id of the user who added the information or `null` if the user no longer exists\n * @property-read string $username name of the user who added the information\n * @property-read int $time timestamp at which the information was created\n */\nclass PersonInformation extends DatabaseObject\n{\n /**\n * Returns `true` if the active user can delete this piece of information and `false` otherwise.\n */\n public function canDelete(): bool\n {\n if (\n WCF::getUser()->userID\n && WCF::getUser()->userID == $this->userID\n && WCF::getSession()->getPermission('user.person.canDeleteInformation')\n ) {\n return true;\n }\n\n return WCF::getSession()->getPermission('mod.person.canDeleteInformation');\n }\n\n /**\n * Returns `true` if the active user can edit this piece of information and `false` otherwise.\n */\n public function canEdit(): bool\n {\n if (\n WCF::getUser()->userID\n && WCF::getUser()->userID == $this->userID\n && WCF::getSession()->getPermission('user.person.canEditInformation')\n ) {\n return true;\n }\n\n return WCF::getSession()->getPermission('mod.person.canEditInformation');\n }\n\n /**\n * Returns the formatted information.\n */\n public function getFormattedInformation(): string\n {\n $processor = new HtmlOutputProcessor();\n $processor->process(\n $this->information,\n 'com.woltlab.wcf.people.information',\n $this->informationID\n );\n\n return $processor->getHtml();\n }\n\n /**\n * Returns the person the information belongs to.\n */\n public function getPerson(): Person\n {\n return PersonRuntimeCache::getInstance()->getObject($this->personID);\n }\n\n /**\n * Returns the user profile of the user who added the information.\n */\n public function getUserProfile(): UserProfile\n {\n if ($this->userID) {\n return UserProfileRuntimeCache::getInstance()->getObject($this->userID);\n } else {\n return UserProfile::getGuestUserProfile($this->username);\n }\n }\n}\n</code></pre> <p><code>PersonInformation</code> provides two methods, <code>canDelete()</code> and <code>canEdit()</code>, to check whether the active user can delete or edit a specific piece of information. In both cases, it is checked if the current user has created the relevant piece of information to check the user-specific permissions or to fall back to the moderator-specific permissions.</p> <p>There also two getter methods for the person, the piece of information belongs to (<code>getPerson()</code>), and for the user profile of the user who created the information (<code>getUserProfile()</code>). In both cases, we use runtime caches, though in <code>getUserProfile()</code>, we also have to consider the case of the user who created the information being deleted, i.e. <code>userID</code> being <code>null</code>. For such a case, we also save the name of the user who created the information in <code>username</code>, so that we can return a guest user profile object in this case. The most interesting method is <code>getFormattedInformation()</code>, which returns the HTML code of the information text meant for output. To generate such an output, <code>HtmlOutputProcessor::process()</code> is used and here is where we first use the associated message object type <code>com.woltlab.wcf.people.information</code> mentioned before.</p> <p>While <code>PersonInformationEditor</code> is simply the default implementation and thus not explicitly shown here, <code>PersonInformationList::readObjects()</code> caches the relevant ids of the associated people and users who created the pieces of information using runtime caches:</p> files/lib/data/person/information/PersonInformationList.class.php <pre><code><?php\n\nnamespace wcf\\data\\person\\information;\n\nuse wcf\\data\\DatabaseObjectList;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\cache\\runtime\\UserProfileRuntimeCache;\n\n/**\n * Represents a list of person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\PersonInformation\n *\n * @method PersonInformation current()\n * @method PersonInformation[] getObjects()\n * @method PersonInformation|null search($objectID)\n * @property PersonInformation[] $objects\n */\nclass PersonInformationList extends DatabaseObjectList\n{\n public function readObjects()\n {\n parent::readObjects();\n\n UserProfileRuntimeCache::getInstance()->cacheObjectIDs(\\array_unique(\\array_filter(\\array_column(\n $this->objects,\n 'userID'\n ))));\n PersonRuntimeCache::getInstance()->cacheObjectIDs(\\array_unique(\\array_column(\n $this->objects,\n 'personID'\n )));\n }\n}\n</code></pre>"},{"location":"tutorial/series/part_5/#listing-and-deleting-person-information","title":"Listing and Deleting Person Information","text":"<p>The <code>person.tpl</code> template has been updated to include a block for listing the information at the beginning:</p> templates/person.tpl <pre><code>{capture assign='pageTitle'}{$person} - {lang}wcf.person.list{/lang}{/capture}\n\n{capture assign='contentTitle'}{$person}{/capture}\n\n{include file='header'}\n\n{if $person->informationCount || $__wcf->session->getPermission('user.person.canAddInformation')}\n <section class=\"section sectionContainerList\">\n <header class=\"sectionHeader\">\n <h2 class=\"sectionTitle\">\n {lang}wcf.person.information.list{/lang}\n {if $person->informationCount}\n <span class=\"badge\">{#$person->informationCount}</span>\n {/if}\n </h2>\n </header>\n\n <ul class=\"commentList containerList personInformationList jsObjectActionContainer\" {*\n *}data-object-action-class-name=\"wcf\\data\\person\\information\\PersonInformationAction\"{*\n *}>\n {if $__wcf->session->getPermission('user.person.canAddInformation')}\n <li class=\"containerListButtonGroup\">\n <ul class=\"buttonGroup\">\n <li>\n <a href=\"#\" class=\"button\" id=\"personInformationAddButton\">\n {icon name='plus'}\n <span>{lang}wcf.person.information.add{/lang}</span>\n </a>\n </li>\n </ul>\n </li>\n {/if}\n\n {foreach from=$person->getInformation() item=$information}\n <li class=\"comment personInformation jsObjectActionObject\" data-object-id=\"{$information->getObjectID()}\">\n <div class=\"box48{if $__wcf->getUserProfileHandler()->isIgnoredUser($information->userID, 2)} ignoredUserContent{/if}\">\n {user object=$information->getUserProfile() type='avatar48' ariaHidden='true' tabindex='-1'}\n\n <div class=\"commentContentContainer\">\n <div class=\"commentContent\">\n <div class=\"containerHeadline\">\n <h3>\n {if $information->userID}\n {user object=$information->getUserProfile()}\n {else}\n <span>{$information->username}</span>\n {/if}\n\n <small class=\"separatorLeft\">{unsafe:$information->time|time}</small>\n </h3>\n </div>\n\n <div class=\"htmlContent userMessage\" id=\"personInformation{$information->getObjectID()}\">\n {unsafe:$information->getFormattedInformation()}\n </div>\n\n <nav class=\"jsMobileNavigation buttonGroupNavigation\">\n <ul class=\"buttonList iconList\">\n {if $information->canEdit()}\n <li class=\"jsOnly\">\n <a href=\"#\" title=\"{lang}wcf.global.button.edit{/lang}\" class=\"jsEditInformation jsTooltip\">\n {icon name='pencil'}\n <span class=\"invisible\">{lang}wcf.global.button.edit{/lang}</span>\n </a>\n </li>\n {/if}\n {if $information->canDelete()}\n <li class=\"jsOnly\">\n <a href=\"#\" title=\"{lang}wcf.global.button.delete{/lang}\" class=\"jsObjectAction jsTooltip\" data-object-action=\"delete\" data-confirm-message=\"{lang}wcf.person.information.delete.confirmMessage{/lang}\">\n {icon name='times'}\n <span class=\"invisible\">{lang}wcf.global.button.edit{/lang}</span>\n </a>\n </li>\n {/if}\n\n {event name='informationOptions'}\n </ul>\n </nav>\n </div>\n </div>\n </div>\n </li>\n {/foreach}\n </ul>\n </section>\n{/if}\n\n{if $person->enableComments}\n {if $commentList|count || $commentCanAdd}\n <section id=\"comments\" class=\"section sectionContainerList\">\n <header class=\"sectionHeader\">\n <h2 class=\"sectionTitle\">\n {lang}wcf.person.comments{/lang}\n {if $person->comments}<span class=\"badge\">{#$person->comments}</span>{/if}\n </h2>\n </header>\n\n {include file='__commentJavaScript' commentContainerID='personCommentList'}\n\n <div class=\"personComments\">\n <ul id=\"personCommentList\" class=\"commentList containerList\" {*\n *}data-can-add=\"{if $commentCanAdd}true{else}false{/if}\" {*\n *}data-object-id=\"{$person->personID}\" {*\n *}data-object-type-id=\"{$commentObjectTypeID}\" {*\n *}data-comments=\"{if $person->comments}{$commentList->countObjects()}{else}0{/if}\" {*\n *}data-last-comment-time=\"{$lastCommentTime}\" {*\n *}>\n {include file='commentListAddComment' wysiwygSelector='personCommentListAddComment'}\n {include file='commentList'}\n </ul>\n </div>\n </section>\n {/if}\n{/if}\n\n<footer class=\"contentFooter\">\n {hascontent}\n <nav class=\"contentFooterNavigation\">\n <ul>\n {content}{event name='contentFooterNavigation'}{/content}\n </ul>\n </nav>\n {/hascontent}\n</footer>\n\n<script data-relocate=\"true\">\n require(['Language', 'WoltLabSuite/Core/Controller/Person'], (Language, ControllerPerson) => {\n Language.addObject({\n 'wcf.person.information.add': '{jslang}wcf.person.information.add{/jslang}',\n 'wcf.person.information.add.success': '{jslang}wcf.person.information.add.success{/jslang}',\n 'wcf.person.information.edit': '{jslang}wcf.person.information.edit{/jslang}',\n 'wcf.person.information.edit.success': '{jslang}wcf.person.information.edit.success{/jslang}',\n });\n\n ControllerPerson.init({$person->personID}, {\n canAddInformation: {if $__wcf->session->getPermission('user.person.canAddInformation')}true{else}false{/if},\n });\n });\n</script>\n\n{include file='footer'}\n</code></pre> <p>To keep things simple here, we reuse the structure and CSS classes used for comments. Additionally, we always list all pieces of information. If there are many pieces of information, a nicer solution would be a pagination or loading more pieces of information with JavaScript.</p> <p>First, we note the <code>jsObjectActionContainer</code> class in combination with the <code>data-object-action-class-name</code> attribute, which are needed for the delete button for each piece of information, as explained here. In <code>PersonInformationAction</code>, we have overridden the default implementations of <code>validateDelete()</code> and <code>delete()</code> which are called after clicking on a delete button. In <code>validateDelete()</code>, we call <code>PersonInformation::canDelete()</code> on all pieces of information to be deleted for proper permission validation, and in <code>delete()</code>, we update the <code>informationCount</code> values of the people the deleted pieces of information belong to (see below).</p> <p>The button to add a new piece of information, <code>#personInformationAddButton</code>, and the buttons to edit existing pieces of information, <code>.jsEditInformation</code>, are controlled with JavaScript code initialized at the very end of the template.</p> <p>Lastly, in <code>create()</code> we provide default values for the <code>time</code>, <code>userID</code>, <code>username</code>, and <code>ipAddress</code> for cases like here when creating a new piece of information, where do not explicitly provide this data. Additionally, we extract the information text from the <code>information_htmlInputProcessor</code> parameter provided by the associated WYSIWYG form field and update the number of pieces of information created for the relevant person.</p>"},{"location":"tutorial/series/part_5/#creating-and-editing-person-information","title":"Creating and Editing Person Information","text":"<p>To create new pieces of information or editing existing ones, we do not add new form controllers but instead use dialogs generated by the form builder API so that the user does not have to leave the person page.</p> <p>When clicking on the add button or on any of the edit buttons, a dialog opens with the relevant form:</p> ts/WoltLabSuite/Core/Controller/Person.ts <pre><code>/**\n * Provides the JavaScript code for the person page.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @module WoltLabSuite/Core/Controller/Person\n */\n\nimport FormBuilderDialog from \"WoltLabSuite/Core/Form/Builder/Dialog\";\nimport * as Language from \"WoltLabSuite/Core/Language\";\nimport * as UiNotification from \"WoltLabSuite/Core/Ui/Notification\";\n\nlet addDialog: FormBuilderDialog;\nconst editDialogs = new Map<string, FormBuilderDialog>();\n\ninterface EditReturnValues {\n formattedInformation: string;\n informationID: number;\n}\n\ninterface Options {\n canAddInformation: true;\n}\n\n/**\n * Opens the edit dialog after clicking on the edit button for a piece of information.\n */\nfunction editInformation(event: Event): void {\n event.preventDefault();\n\n const currentTarget = event.currentTarget as HTMLElement;\n const information = currentTarget.closest(\".jsObjectActionObject\") as HTMLElement;\n const informationId = information.dataset.objectId!;\n\n if (!editDialogs.has(informationId)) {\n editDialogs.set(\n informationId,\n new FormBuilderDialog(\n `personInformationEditDialog${informationId}`,\n \"wcf\\\\data\\\\person\\\\information\\\\PersonInformationAction\",\n \"getEditDialog\",\n {\n actionParameters: {\n informationID: informationId,\n },\n dialog: {\n title: Language.get(\"wcf.person.information.edit\"),\n },\n submitActionName: \"submitEditDialog\",\n successCallback(returnValues: EditReturnValues) {\n document.getElementById(`personInformation${returnValues.informationID}`)!.innerHTML =\n returnValues.formattedInformation;\n\n UiNotification.show(Language.get(\"wcf.person.information.edit.success\"));\n },\n },\n ),\n );\n }\n\n editDialogs.get(informationId)!.open();\n}\n\n/**\n * Initializes the JavaScript code for the person page.\n */\nexport function init(personId: number, options: Options): void {\n if (options.canAddInformation) {\n // Initialize the dialog to add new information.\n addDialog = new FormBuilderDialog(\n \"personInformationAddDialog\",\n \"wcf\\\\data\\\\person\\\\information\\\\PersonInformationAction\",\n \"getAddDialog\",\n {\n actionParameters: {\n personID: personId,\n },\n dialog: {\n title: Language.get(\"wcf.person.information.add\"),\n },\n submitActionName: \"submitAddDialog\",\n successCallback() {\n UiNotification.show(Language.get(\"wcf.person.information.add.success\"), () => window.location.reload());\n },\n },\n );\n\n document.getElementById(\"personInformationAddButton\")!.addEventListener(\"click\", (event) => {\n event.preventDefault();\n\n addDialog.open();\n });\n }\n\n document\n .querySelectorAll(\".jsEditInformation\")\n .forEach((el) => el.addEventListener(\"click\", (ev) => editInformation(ev)));\n}\n</code></pre> <p>We use the <code>WoltLabSuite/Core/Form/Builder/Dialog</code> module, which takes care of the internal handling with regard to these dialogs. We only have to provide some data during for initializing these objects and call the <code>open()</code> function after a button has been clicked.</p> <p>Explanation of the initialization arguments for <code>WoltLabSuite/Core/Form/Builder/Dialog</code> used here:</p> <ul> <li>The first argument is the id of the dialog used to identify it.</li> <li>The second argument is the PHP class name which provides the contents of the dialog's form and handles the data after the form is submitted.</li> <li>The third argument is the name of the method in the referenced PHP class in the previous argument that returns the dialog form.</li> <li>The fourth argument contains additional options:<ul> <li><code>actionParameters</code> are additional parameters send during each AJAX request. Here, we either pass the id of the person for who a new piece of information is added or the id of the edited piece of information.</li> <li><code>dialog</code> contains the options for the dialog, see the <code>DialogOptions</code> interface. Here, we only provide the title of the dialog.</li> <li><code>submitActionName</code> is the name of the method in the referenced PHP class that is called with the form data after submitting the form.</li> <li><code>successCallback</code> is called after the submit AJAX request was successful. After adding a new piece of information, we reload the page, and after editing an existing piece of information, we update the existing information text with the updated text. (Dynamically inserting a newly added piece of information instead of reloading the page would also be possible, of course, but for this tutorial series, we kept things simple.)</li> </ul> </li> </ul> <p>Next, we focus on <code>PersonInformationAction</code>, which actually provides the contents of these dialogs and creates and edits the information:</p> files/lib/data/person/information/PersonInformationAction.class.php <pre><code><?php\n\nnamespace wcf\\data\\person\\information;\n\nuse wcf\\data\\AbstractDatabaseObjectAction;\nuse wcf\\data\\person\\PersonAction;\nuse wcf\\data\\person\\PersonEditor;\nuse wcf\\system\\cache\\runtime\\PersonRuntimeCache;\nuse wcf\\system\\event\\EventHandler;\nuse wcf\\system\\exception\\IllegalLinkException;\nuse wcf\\system\\exception\\PermissionDeniedException;\nuse wcf\\system\\exception\\UserInputException;\nuse wcf\\system\\form\\builder\\container\\wysiwyg\\WysiwygFormContainer;\nuse wcf\\system\\form\\builder\\DialogFormDocument;\nuse wcf\\system\\html\\input\\HtmlInputProcessor;\nuse wcf\\system\\WCF;\nuse wcf\\util\\UserUtil;\n\n/**\n * Executes person information-related actions.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2021 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\Data\\Person\\Information\n *\n * @method PersonInformationEditor[] getObjects()\n * @method PersonInformationEditor getSingleObject()\n */\nclass PersonInformationAction extends AbstractDatabaseObjectAction\n{\n /**\n * @var DialogFormDocument\n */\n public $dialog;\n\n /**\n * @var PersonInformation\n */\n public $information;\n\n /**\n * @return PersonInformation\n */\n public function create()\n {\n if (!isset($this->parameters['data']['time'])) {\n $this->parameters['data']['time'] = TIME_NOW;\n }\n if (!isset($this->parameters['data']['userID'])) {\n $this->parameters['data']['userID'] = WCF::getUser()->userID;\n $this->parameters['data']['username'] = WCF::getUser()->username;\n }\n\n if (LOG_IP_ADDRESS) {\n if (!isset($this->parameters['data']['ipAddress'])) {\n $this->parameters['data']['ipAddress'] = UserUtil::getIpAddress();\n }\n } else {\n unset($this->parameters['data']['ipAddress']);\n }\n\n if (!empty($this->parameters['information_htmlInputProcessor'])) {\n /** @var HtmlInputProcessor $htmlInputProcessor */\n $htmlInputProcessor = $this->parameters['information_htmlInputProcessor'];\n $this->parameters['data']['information'] = $htmlInputProcessor->getHtml();\n }\n\n /** @var PersonInformation $information */\n $information = parent::create();\n\n (new PersonAction([$information->personID], 'update', [\n 'counters' => [\n 'informationCount' => 1,\n ],\n ]))->executeAction();\n\n return $information;\n }\n\n /**\n * @inheritDoc\n */\n public function update()\n {\n if (!empty($this->parameters['information_htmlInputProcessor'])) {\n /** @var HtmlInputProcessor $htmlInputProcessor */\n $htmlInputProcessor = $this->parameters['information_htmlInputProcessor'];\n $this->parameters['data']['information'] = $htmlInputProcessor->getHtml();\n }\n\n parent::update();\n }\n\n /**\n * @inheritDoc\n */\n public function validateDelete()\n {\n if (empty($this->objects)) {\n $this->readObjects();\n\n if (empty($this->objects)) {\n throw new UserInputException('objectIDs');\n }\n }\n\n foreach ($this->getObjects() as $informationEditor) {\n if (!$informationEditor->canDelete()) {\n throw new PermissionDeniedException();\n }\n }\n }\n\n /**\n * @inheritDoc\n */\n public function delete()\n {\n $deleteCount = parent::delete();\n\n if (!$deleteCount) {\n return $deleteCount;\n }\n\n $counterUpdates = [];\n foreach ($this->getObjects() as $informationEditor) {\n if (!isset($counterUpdates[$informationEditor->personID])) {\n $counterUpdates[$informationEditor->personID] = 0;\n }\n\n $counterUpdates[$informationEditor->personID]--;\n }\n\n WCF::getDB()->beginTransaction();\n foreach ($counterUpdates as $personID => $counterUpdate) {\n (new PersonEditor(PersonRuntimeCache::getInstance()->getObject($personID)))->updateCounters([\n 'informationCount' => $counterUpdate,\n ]);\n }\n WCF::getDB()->commitTransaction();\n\n return $deleteCount;\n }\n\n /**\n * Validates the `getAddDialog` action.\n */\n public function validateGetAddDialog(): void\n {\n WCF::getSession()->checkPermissions(['user.person.canAddInformation']);\n\n $this->readInteger('personID');\n if (PersonRuntimeCache::getInstance()->getObject($this->parameters['personID']) === null) {\n throw new UserInputException('personID');\n }\n }\n\n /**\n * Returns the data to show the dialog to add a new piece of information on a person.\n *\n * @return string[]\n */\n public function getAddDialog(): array\n {\n $this->buildDialog();\n\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n /**\n * Validates the `submitAddDialog` action.\n */\n public function validateSubmitAddDialog(): void\n {\n $this->validateGetAddDialog();\n\n $this->buildDialog();\n $this->dialog->requestData($_POST['parameters']['data'] ?? []);\n $this->dialog->readValues();\n $this->dialog->validate();\n }\n\n /**\n * Creates a new piece of information on a person after submitting the dialog.\n *\n * @return string[]\n */\n public function submitAddDialog(): array\n {\n // If there are any validation errors, show the form again.\n if ($this->dialog->hasValidationErrors()) {\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n (new static([], 'create', \\array_merge($this->dialog->getData(), [\n 'data' => [\n 'personID' => $this->parameters['personID'],\n ],\n ])))->executeAction();\n\n return [];\n }\n\n /**\n * Validates the `getEditDialog` action.\n */\n public function validateGetEditDialog(): void\n {\n WCF::getSession()->checkPermissions(['user.person.canAddInformation']);\n\n $this->readInteger('informationID');\n $this->information = new PersonInformation($this->parameters['informationID']);\n if (!$this->information->getObjectID()) {\n throw new UserInputException('informationID');\n }\n if (!$this->information->canEdit()) {\n throw new IllegalLinkException();\n }\n }\n\n /**\n * Returns the data to show the dialog to edit a piece of information on a person.\n *\n * @return string[]\n */\n public function getEditDialog(): array\n {\n $this->buildDialog();\n $this->dialog->updatedObject($this->information);\n\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n /**\n * Validates the `submitEditDialog` action.\n */\n public function validateSubmitEditDialog(): void\n {\n $this->validateGetEditDialog();\n\n $this->buildDialog();\n $this->dialog->updatedObject($this->information, false);\n $this->dialog->requestData($_POST['parameters']['data'] ?? []);\n $this->dialog->readValues();\n $this->dialog->validate();\n }\n\n /**\n * Updates a piece of information on a person after submitting the edit dialog.\n *\n * @return string[]\n */\n public function submitEditDialog(): array\n {\n // If there are any validation errors, show the form again.\n if ($this->dialog->hasValidationErrors()) {\n return [\n 'dialog' => $this->dialog->getHtml(),\n 'formId' => $this->dialog->getId(),\n ];\n }\n\n (new static([$this->information], 'update', $this->dialog->getData()))->executeAction();\n\n // Reload the information with the updated data.\n $information = new PersonInformation($this->information->getObjectID());\n\n return [\n 'formattedInformation' => $information->getFormattedInformation(),\n 'informationID' => $this->information->getObjectID(),\n ];\n }\n\n /**\n * Builds the dialog to create or edit person information.\n */\n protected function buildDialog(): void\n {\n if ($this->dialog !== null) {\n return;\n }\n\n $this->dialog = DialogFormDocument::create('personInformationAddDialog')\n ->appendChild(\n WysiwygFormContainer::create('information')\n ->messageObjectType('com.woltlab.wcf.people.information')\n ->required()\n );\n\n EventHandler::getInstance()->fireAction($this, 'buildDialog');\n\n $this->dialog->build();\n }\n}\n</code></pre> <p>When setting up the <code>WoltLabSuite/Core/Form/Builder/Dialog</code> object for adding new pieces of information, we specified <code>getAddDialog</code> and <code>submitAddDialog</code> as the names of the dialog getter and submit handler. In addition to these two methods, the matching validation methods <code>validateGetAddDialog()</code> and <code>validateGetAddDialog()</code> are also added. As the forms for adding and editing pieces of information have the same structure, this form is created in <code>buildDialog()</code> using a <code>DialogFormDocument</code> object, which is intended for forms in dialogs. We fire an event in <code>buildDialog()</code> so that plugins are able to easily extend the dialog with additional data.</p> <p><code>validateGetAddDialog()</code> checks if the user has the permission to create new pieces of information and if a valid id for the person, the information will belong to, is given. The method configured in the <code>WoltLabSuite/Core/Form/Builder/Dialog</code> object returning the dialog is expected to return two values: the id of the form (<code>formId</code>) and the contents of form shown in the dialog (<code>dialog</code>). This data is returned by <code>getAddDialog</code> using the dialog build previously by <code>buildDialog()</code>.</p> <p>After the form is submitted, <code>validateSubmitAddDialog()</code> has to do the same basic validation as <code>validateGetAddDialog()</code> so that <code>validateGetAddDialog()</code> is simply called. Additionally, the form data is read and validated. In <code>submitAddDialog()</code>, we first check if there have been any validation errors: If any error occured during validation, we return the same data as in <code>getAddDialog()</code> so that the dialog is shown again with the erroneous fields marked as such. Otherwise, if the validation succeeded, the form data is used to create the new piece of information. In addition to the form data, we manually add the id of the person to whom the information belongs to. Lastly, we could return some data that we could access in the JavaScript callback function after successfully submitting the dialog. As we will simply be reloading the page, no such data is returned. An alternative to reloading to the page would be dynamically inserting the new piece of information in the list so that we would have to return the rendered list item for the new piece of information.</p> <p>The process for getting and submitting the dialog to edit existing pieces of information is similar to the process for adding new pieces of information. Instead of the id of the person, however, we now pass the id of the edited piece of information and in <code>submitEditDialog()</code>, we update the edited information instead of creating a new one like in <code>submitAddDialog()</code>. After editing a piece of information, we do not reload the page but dynamically update the text of the information in the TypeScript code so that we return the updated rendered information text and id of the edited pieced of information in <code>submitAddDialog()</code>.</p>"},{"location":"tutorial/series/part_5/#rebuild-data-worker","title":"Rebuild Data Worker","text":"<p>To ensure the integrity of the person data, <code>PersonRebuildDataWorker</code> updates the <code>informationCount</code> counter:</p> files/lib/system/worker/PersonRebuildDataWorker.class.php <pre><code><?php\n\nnamespace wcf\\system\\worker;\n\nuse wcf\\data\\person\\PersonList;\nuse wcf\\system\\WCF;\n\n/**\n * Worker implementation for updating people.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Worker\n *\n * @method PersonList getObjectList()\n */\nfinal class PersonRebuildDataWorker extends AbstractRebuildDataWorker\n{\n /**\n * @inheritDoc\n */\n protected $limit = 500;\n\n /**\n * @inheritDoc\n */\n protected $objectListClassName = PersonList::class;\n\n /**\n * @inheritDoc\n */\n protected function initObjectList()\n {\n parent::initObjectList();\n\n $this->objectList->sqlOrderBy = 'person.personID';\n }\n\n /**\n * @inheritDoc\n */\n public function execute()\n {\n parent::execute();\n\n if (!\\count($this->objectList)) {\n return;\n }\n\n $sql = \"UPDATE wcf1_person person\n SET informationCount = (\n SELECT COUNT(*)\n FROM wcf1_person_information person_information\n WHERE person_information.personID = person.personID\n )\n WHERE person.personID = ?\";\n $statement = WCF::getDB()->prepare($sql);\n\n WCF::getDB()->beginTransaction();\n foreach ($this->getObjectList() as $person) {\n $statement->execute([$person->personID]);\n }\n WCF::getDB()->commitTransaction();\n }\n}\n</code></pre>"},{"location":"tutorial/series/part_5/#username-and-ip-address-event-listeners","title":"Username and IP Address Event Listeners","text":"<p>As we store the name of the user who create a new piece of information and store their IP address, we have to add event listeners to properly handle the following scenarios:</p> <ol> <li>If the user is renamed, the value of <code>username</code> stored with the person information has to be updated, which can be achieved by a simple event listener that only has to specify the name of relevant database table if <code>AbstractUserActionRenameListener</code> is extended:</li> </ol> files/lib/system/event/listener/PersonUserActionRenameListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\n/**\n * Updates person information during user renaming.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserActionRenameListener extends AbstractUserActionRenameListener\n{\n /**\n * @inheritDoc\n */\n protected $databaseTables = [\n 'wcf{WCF_N}_person_information',\n ];\n}\n</code></pre> <ol> <li>If users are merged, all pieces of information need to be assigned to the target user of the merging. Again, we only have to specify the name of relevant database table if <code>AbstractUserMergeListener</code> is extended:</li> </ol> files/lib/system/event/listener/PersonUserMergeListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\n/**\n * Updates person information during user merging.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserMergeListener extends AbstractUserMergeListener\n{\n /**\n * @inheritDoc\n */\n protected $databaseTables = [\n 'wcf{WCF_N}_person_information',\n ];\n}\n</code></pre> <ol> <li>If the option to prune stored ip addresses after a certain period of time is enabled, we also have to prune them in the person information database table. Here we also only have to specify the name of the relevant database table and provide the mapping from the <code>ipAddress</code> column to the <code>time</code> column:</li> </ol> files/lib/system/event/listener/PersonPruneIpAddressesCronjobListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\system\\cronjob\\PruneIpAddressesCronjob;\n\n/**\n * Prunes old ip addresses.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonPruneIpAddressesCronjobListener extends AbstractEventListener\n{\n protected function onExecute(PruneIpAddressesCronjob $cronjob): void\n {\n $cronjob->columns['wcf' . WCF_N . '_person_information']['ipAddress'] = 'time';\n }\n}\n</code></pre> <ol> <li>The ip addresses in the person information database table also have to be considered for the user data export which can also be done with minimal effort by providing the name of the relevant database table:</li> </ol> files/lib/system/event/listener/PersonUserExportGdprListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\acp\\action\\UserExportGdprAction;\n\n/**\n * Adds the ip addresses stored with the person information during user data export.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserExportGdprListener extends AbstractEventListener\n{\n protected function onExport(UserExportGdprAction $action): void\n {\n $action->ipAddresses['com.woltlab.wcf.people'] = ['wcf' . WCF_N . '_person_information'];\n }\n}\n</code></pre> <p>Lastly, we present the updated <code>eventListener.xml</code> file with new entries for all of these event listeners:</p> eventListener.xml <pre><code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com http://www.woltlab.com/XSD/5.4/eventListener.xsd\">\n <import>\n <eventlistener name=\"rename@wcf\\data\\user\\UserAction\">\n <eventclassname>wcf\\data\\user\\UserAction</eventclassname>\n <eventname>rename</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserActionRenameListener</listenerclassname>\n <environment>all</environment>\n </eventlistener>\n <eventlistener name=\"save@wcf\\acp\\form\\UserMergeForm\">\n <eventclassname>wcf\\acp\\form\\UserMergeForm</eventclassname>\n <eventname>save</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserMergeListener</listenerclassname>\n <environment>admin</environment>\n </eventlistener>\n <eventlistener name=\"execute@wcf\\system\\cronjob\\PruneIpAddressesCronjob\">\n <eventclassname>wcf\\system\\cronjob\\PruneIpAddressesCronjob</eventclassname>\n <eventname>execute</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonPruneIpAddressesCronjobListener</listenerclassname>\n <environment>all</environment>\n </eventlistener>\n <eventlistener name=\"export@wcf\\acp\\action\\UserExportGdprAction\">\n <eventclassname>wcf\\acp\\action\\UserExportGdprAction</eventclassname>\n <eventname>export</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserExportGdprListener</listenerclassname>\n <environment>admin</environment>\n </eventlistener>\n </import>\n</data>\n</code></pre>"},{"location":"tutorial/series/part_6/","title":"Part 6: Activity Points and Activity Events","text":"<p>In this part of our tutorial series, we use the person information added in the previous part to award activity points to users adding new pieces of information and to also create activity events for these pieces of information.</p>"},{"location":"tutorial/series/part_6/#package-functionality","title":"Package Functionality","text":"<p>In addition to the existing functions from part 5, the package will provide the following functionality after this part of the tutorial:</p> <ul> <li>Users are awarded activity points for adding new pieces of information for people.</li> <li>If users add new pieces of information for people, activity events are added which are then shown in the list of recent activities.</li> </ul>"},{"location":"tutorial/series/part_6/#used-components","title":"Used Components","text":"<p>In addition to the components used in previous parts, we will use the user activity points API and the user activity events API.</p>"},{"location":"tutorial/series/part_6/#package-structure","title":"Package Structure","text":"<p>The package will have the following file structure excluding unchanged files from previous parts:</p> <pre><code>\u251c\u2500\u2500 files\n\u2502 \u2514\u2500\u2500 lib\n\u2502 \u251c\u2500\u2500 data\n\u2502 \u2502 \u2514\u2500\u2500 person\n\u2502 \u2502 \u251c\u2500\u2500 PersonAction.class.php\n\u2502 \u2502 \u2514\u2500\u2500 information\n\u2502 \u2502 \u251c\u2500\u2500 PersonInformation.class.php\n\u2502 \u2502 \u2514\u2500\u2500 PersonInformationAction.class.php\n\u2502 \u2514\u2500\u2500 system\n\u2502 \u251c\u2500\u2500 user\n\u2502 \u2502 \u2514\u2500\u2500 activity\n\u2502 \u2502 \u2514\u2500\u2500 event\n\u2502 \u2502 \u2514\u2500\u2500 PersonInformationUserActivityEvent.class.php\n\u2502 \u2514\u2500\u2500 worker\n\u2502 \u251c\u2500\u2500 PersonInformationRebuildDataWorker.class.php\n\u2502 \u2514\u2500\u2500 PersonRebuildDataWorker.class.php\n\u251c\u2500\u2500 eventListener.xml\n\u251c\u2500\u2500 language\n\u2502 \u251c\u2500\u2500 de.xml\n\u2502 \u2514\u2500\u2500 en.xml\n\u2514\u2500\u2500 objectType.xml\n</code></pre> <p>For all changes, please refer to the source code on GitHub.</p>"},{"location":"tutorial/series/part_6/#user-activity-points","title":"User Activity Points","text":"<p>The first step to support activity points is to register an object type for the <code>com.woltlab.wcf.user.activityPointEvent</code> object type definition for created person information and specify the default number of points awarded per piece of information:</p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.people.information</name>\n <definitionname>com.woltlab.wcf.user.activityPointEvent</definitionname>\n <points>2</points>\n</type>\n</code></pre> <p>Additionally, the phrase <code>wcf.user.activityPoint.objectType.com.woltlab.wcf.people.information</code> (in general: <code>wcf.user.activityPoint.objectType.{objectType}</code>) has to be added.</p> <p>The activity points are awarded when new pieces are created via <code>PersonInformation::create()</code> using <code>UserActivityPointHandler::fireEvent()</code> and removed in <code>PersonInformation::create()</code> via <code>UserActivityPointHandler::removeEvents()</code> if pieces of information are deleted.</p> <p>Lastly, we have to add two components for updating data: First, we register a new rebuild data worker</p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.people.information</name>\n <definitionname>com.woltlab.wcf.rebuildData</definitionname>\n <classname>wcf\\system\\worker\\PersonInformationRebuildDataWorker</classname>\n</type>\n</code></pre> files/lib/system/worker/PersonInformationRebuildDataWorker.class.php <pre><code><?php\n\nnamespace wcf\\system\\worker;\n\nuse wcf\\data\\person\\information\\PersonInformationList;\nuse wcf\\system\\user\\activity\\point\\UserActivityPointHandler;\n\n/**\n * Worker implementation for updating person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Worker\n *\n * @method PersonInformationList getObjectList()\n */\nfinal class PersonInformationRebuildDataWorker extends AbstractRebuildDataWorker\n{\n /**\n * @inheritDoc\n */\n protected $objectListClassName = PersonInformationList::class;\n\n /**\n * @inheritDoc\n */\n protected $limit = 500;\n\n /**\n * @inheritDoc\n */\n protected function initObjectList()\n {\n parent::initObjectList();\n\n $this->objectList->sqlOrderBy = 'person_information.personID';\n }\n\n /**\n * @inheritDoc\n */\n public function execute()\n {\n parent::execute();\n\n if (!$this->loopCount) {\n UserActivityPointHandler::getInstance()->reset('com.woltlab.wcf.people.information');\n }\n\n if (!\\count($this->objectList)) {\n return;\n }\n\n $itemsToUser = [];\n foreach ($this->getObjectList() as $personInformation) {\n if ($personInformation->userID) {\n if (!isset($itemsToUser[$personInformation->userID])) {\n $itemsToUser[$personInformation->userID] = 0;\n }\n\n $itemsToUser[$personInformation->userID]++;\n }\n }\n\n UserActivityPointHandler::getInstance()->fireEvents(\n 'com.woltlab.wcf.people.information',\n $itemsToUser,\n false\n );\n }\n}\n</code></pre> <p>which updates the number of instances for which any user received person information activity points. (This data worker also requires the phrases <code>wcf.acp.rebuildData.com.woltlab.wcf.people.information</code> and <code>wcf.acp.rebuildData.com.woltlab.wcf.people.information.description</code>).</p> <p>Second, we add an event listener for <code>UserActivityPointItemsRebuildDataWorker</code> to update the total user activity points awarded for person information:</p> eventListener.xml<pre><code><eventlistener name=\"execute@wcf\\system\\worker\\UserActivityPointItemsRebuildDataWorker\">\n <eventclassname>wcf\\system\\worker\\UserActivityPointItemsRebuildDataWorker</eventclassname>\n <eventname>execute</eventname>\n <listenerclassname>wcf\\system\\event\\listener\\PersonUserActivityPointItemsRebuildDataWorkerListener</listenerclassname>\n <environment>admin</environment>\n</eventlistener>\n</code></pre> files/lib/system/event/listener/PersonUserActivityPointItemsRebuildDataWorkerListener.class.php <pre><code><?php\n\nnamespace wcf\\system\\event\\listener;\n\nuse wcf\\system\\database\\util\\PreparedStatementConditionBuilder;\nuse wcf\\system\\user\\activity\\point\\UserActivityPointHandler;\nuse wcf\\system\\WCF;\nuse wcf\\system\\worker\\UserActivityPointItemsRebuildDataWorker;\n\n/**\n * Updates the user activity point items counter for person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\Event\\Listener\n */\nfinal class PersonUserActivityPointItemsRebuildDataWorkerListener extends AbstractEventListener\n{\n protected function onExecute(UserActivityPointItemsRebuildDataWorker $worker): void\n {\n $objectType = UserActivityPointHandler::getInstance()\n ->getObjectTypeByName('com.woltlab.wcf.people.information');\n\n $conditionBuilder = new PreparedStatementConditionBuilder();\n $conditionBuilder->add('user_activity_point.objectTypeID = ?', [$objectType->objectTypeID]);\n $conditionBuilder->add('user_activity_point.userID IN (?)', [$worker->getObjectList()->getObjectIDs()]);\n\n $sql = \"UPDATE wcf1_user_activity_point user_activity_point\n SET user_activity_point.items = (\n SELECT COUNT(*)\n FROM wcf1_person_information person_information\n WHERE person_information.userID = user_activity_point.userID\n ),\n user_activity_point.activityPoints = user_activity_point.items * ?\n {$conditionBuilder}\";\n $statement = WCF::getDB()->prepare($sql);\n $statement->execute([\n $objectType->points,\n ...$conditionBuilder->getParameters()\n ]);\n }\n}\n</code></pre>"},{"location":"tutorial/series/part_6/#user-activity-events","title":"User Activity Events","text":"<p>To support user activity events, an object type for <code>com.woltlab.wcf.user.recentActivityEvent</code> has to be registered with a class implementing <code>wcf\\system\\user\\activity\\event\\IUserActivityEvent</code>:</p> objectType.xml<pre><code><type>\n <name>com.woltlab.wcf.people.information</name>\n <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>\n <classname>wcf\\system\\user\\activity\\event\\PersonInformationUserActivityEvent</classname>\n</type>\n</code></pre> files/lib/system/user/activity/event/PersonInformationUserActivityEvent.class.php <pre><code><?php\n\nnamespace wcf\\system\\user\\activity\\event;\n\nuse wcf\\data\\person\\information\\PersonInformationList;\nuse wcf\\system\\SingletonFactory;\nuse wcf\\system\\WCF;\n\n/**\n * User activity event implementation for person information.\n *\n * @author Matthias Schmidt\n * @copyright 2001-2022 WoltLab GmbH\n * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\n * @package WoltLabSuite\\Core\\System\\User\\Activity\\Event\n */\nfinal class PersonInformationUserActivityEvent extends SingletonFactory implements IUserActivityEvent\n{\n /**\n * @inheritDoc\n */\n public function prepare(array $events)\n {\n $objectIDs = \\array_column($events, 'objectID');\n\n $informationList = new PersonInformationList();\n $informationList->setObjectIDs($objectIDs);\n $informationList->readObjects();\n $information = $informationList->getObjects();\n\n foreach ($events as $event) {\n if (isset($information[$event->objectID])) {\n $personInformation = $information[$event->objectID];\n\n $event->setIsAccessible();\n $event->setTitle(\n WCF::getLanguage()->getDynamicVariable(\n 'wcf.user.profile.recentActivity.personInformation',\n [\n 'person' => $personInformation->getPerson(),\n 'personInformation' => $personInformation,\n ]\n )\n );\n $event->setDescription($personInformation->getFormattedExcerpt());\n }\n }\n }\n}\n</code></pre> <p><code>PersonInformationUserActivityEvent::prepare()</code> must check for all events whether the associated piece of information still exists and if it is the case, mark the event as accessible via the <code>setIsAccessible()</code> method, set the title of the activity event via <code>setTitle()</code>, and set a description of the event via <code>setDescription()</code> for which we use the newly added <code>PersonInformation::getFormattedExcerpt()</code> method.</p> <p>Lastly, we have to add the phrase <code>wcf.user.recentActivity.com.woltlab.wcf.people.information</code>, which is shown in the list of activity events as the type of activity event.</p>"},{"location":"view/css/","title":"CSS","text":""},{"location":"view/css/#scss-and-css","title":"SCSS and CSS","text":"<p>SCSS is a scripting language that features a syntax similar to CSS and compiles into native CSS at runtime. It provides many great additions to CSS such as declaration nesting and variables, it is recommended to read the official guide to learn more.</p> <p>You can create <code>.scss</code> files containing only pure CSS code and it will work just fine, you are at no point required to write actual SCSS code.</p>"},{"location":"view/css/#file-location","title":"File Location","text":"<p>Please place your style files in a subdirectory of the <code>style/</code> directory of the target application or the Core's style directory, for example <code>style/layout/pageHeader.scss</code>.</p>"},{"location":"view/css/#variables","title":"Variables","text":"<p>You can access variables with <code>$myVariable</code>, variable interpolation (variables inside strings) is accomplished with <code>#{$myVariable}</code>.</p>"},{"location":"view/css/#linking-images","title":"Linking images","text":"<p>Images used within a style must be located in the style's image folder. To get the folder name within the CSS the SCSS variable <code>#{$style_image_path}</code> can be used. The value will contain a trailing slash.</p>"},{"location":"view/css/#media-breakpoints","title":"Media Breakpoints","text":"<p>Media breakpoints instruct the browser to apply different CSS depending on the viewport dimensions, e.g. serving a desktop PC a different view than when viewed on a smartphone.</p> <pre><code>/* red background color for desktop pc */\n@include screen-lg {\n body {\n background-color: red;\n }\n}\n\n/* green background color on smartphones and tablets */\n@include screen-md-down {\n body {\n background-color: green;\n }\n}\n</code></pre>"},{"location":"view/css/#available-breakpoints","title":"Available Breakpoints","text":"<p>Some very large smartphones, for example the Apple iPhone 7 Plus, do match the media query for <code>Tablets (portrait)</code> when viewed in landscape mode.</p> Name Devices <code>@media</code> equivalent <code>screen-xs</code> Smartphones only <code>(max-width: 544px)</code> <code>screen-sm</code> Tablets (portrait) <code>(min-width: 545px) and (max-width: 768px)</code> <code>screen-sm-down</code> Tablets (portrait) and smartphones <code>(max-width: 768px)</code> <code>screen-sm-up</code> Tablets and desktop PC <code>(min-width: 545px)</code> <code>screen-sm-md</code> Tablets only <code>(min-width: 545px) and (max-width: 1024px)</code> <code>screen-md</code> Tablets (landscape) <code>(min-width: 769px) and (max-width: 1024px)</code> <code>screen-md-down</code> Smartphones and tablets <code>(max-width: 1024px)</code> <code>screen-md-up</code> Tablets (landscape) and desktop PC <code>(min-width: 769px)</code> <code>screen-lg</code> Desktop PC <code>(min-width: 1025px)</code> <code>screen-lg-only</code> Desktop PC <code>(min-width: 1025px) and (max-width: 1280px)</code> <code>screen-lg-down</code> Smartphones, tablets, and desktop PC <code>(max-width: 1280px)</code> <code>screen-xl</code> Desktop PC <code>(min-width: 1281px)</code>"},{"location":"view/css/#asset-preloading","title":"Asset Preloading","text":"<p>WoltLab Suite\u2019s SCSS compiler supports adding preloading metadata to the CSS. To communicate the preloading intent to the compiler, the <code>--woltlab-suite-preload</code> CSS variable is set to the result of the <code>preload()</code> function:</p> <pre><code>.fooBar {\n --woltlab-suite-preload: #{preload(\n '#{$style_image_path}custom/background.png',\n $as: \"image\",\n $crossorigin: false,\n $type: \"image/png\"\n )};\n\n background: url('#{$style_image_path}custom/background.png');\n}\n</code></pre> <p>The parameters of the <code>preload()</code> function map directly to the preloading properties that are used within the <code><link></code> tag and the <code>link:</code> HTTP response header.</p> <p>The above example will result in a <code><link></code> similar to the following being added to the generated HTML:</p> <pre><code><link rel=\"preload\" href=\"https://example.com/images/style-1/custom/background.png\" as=\"image\" type=\"image/png\">\n</code></pre> <p>Use preloading sparingly for the most important resources where you can be certain that the browser will need them. Unused preloaded resources will unnecessarily waste bandwidth.</p>"},{"location":"view/languages-naming-conventions/","title":"Language Naming Conventions","text":"<p>This page contains general rules for naming language items and for their values. API-specific rules are listed on the relevant API page:</p> <ul> <li>Comments</li> </ul>"},{"location":"view/languages-naming-conventions/#forms","title":"Forms","text":""},{"location":"view/languages-naming-conventions/#fields","title":"Fields","text":"<p>If you have an application <code>foo</code> and a database object <code>foo\\data\\bar\\Bar</code> with a property <code>baz</code> that can be set via a form field, the name of the corresponding language item has to be <code>foo.bar.baz</code>. If you want to add an additional description below the field, use the language item <code>foo.bar.baz.description</code>.</p>"},{"location":"view/languages-naming-conventions/#error-texts","title":"Error Texts","text":"<p>If an error of type <code>{error type}</code> for the previously mentioned form field occurs during validation, you have to use the language item <code>foo.bar.baz.error.{error type}</code> for the language item describing the error.</p> <p>Exception to this rule: There are several general error messages like <code>wcf.global.form.error.empty</code> that have to be used for general errors like an empty field that may not be empty to avoid duplication of the same error message text over and over again in different language items.</p>"},{"location":"view/languages-naming-conventions/#naming-conventions","title":"Naming Conventions","text":"<ul> <li>If the entered text does not conform to some special rules, i.e. if the text is invalid, use <code>invalid</code> as error type.</li> <li>If the entered text is required to be unique but is already used for another object, use <code>notUnique</code> as error type.</li> </ul>"},{"location":"view/languages-naming-conventions/#confirmation-messages","title":"Confirmation messages","text":"<p>If the language item for an action is <code>foo.bar.action</code>, the language item for the confirmation message has to be <code>foo.bar.action.confirmMessage</code> instead of <code>foo.bar.action.sure</code> which is still used by some older language items.</p>"},{"location":"view/languages-naming-conventions/#type-specific-deletion-confirmation-message","title":"Type-Specific Deletion Confirmation Message","text":""},{"location":"view/languages-naming-conventions/#german","title":"German","text":"<pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} {element type} wirklich l\u00f6schen?\n</code></pre> <p>Example:</p> <pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} das Icon wirklich l\u00f6schen?\n</code></pre>"},{"location":"view/languages-naming-conventions/#english","title":"English","text":"<pre><code>Do you really want delete the {element type}?\n</code></pre> <p>Example:</p> <pre><code>Do you really want delete the icon?\n</code></pre>"},{"location":"view/languages-naming-conventions/#object-specific-deletion-confirmation-message","title":"Object-Specific Deletion Confirmation Message","text":""},{"location":"view/languages-naming-conventions/#german_1","title":"German","text":"<pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} {element type} <span class=\"confirmationObject\">{object name}</span> wirklich l\u00f6schen?\n</code></pre> <p>Example:</p> <pre><code>{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Artikel <span class=\"confirmationObject\">{$article->getTitle()}</span> wirklich l\u00f6schen?\n</code></pre>"},{"location":"view/languages-naming-conventions/#english_1","title":"English","text":"<pre><code>Do you really want to delete the {element type} <span class=\"confirmationObject\">{object name}</span>?\n</code></pre> <p>Example:</p> <pre><code>Do you really want to delete the article <span class=\"confirmationObject\">{$article->getTitle()}</span>?\n</code></pre>"},{"location":"view/languages-naming-conventions/#user-group-options","title":"User Group Options","text":""},{"location":"view/languages-naming-conventions/#comments","title":"Comments","text":""},{"location":"view/languages-naming-conventions/#german_2","title":"German","text":"group type action example permission name language item user adding <code>user.foo.canAddComment</code> <code>Kann Kommentare erstellen</code> user deleting <code>user.foo.canDeleteComment</code> <code>Kann eigene Kommentare l\u00f6schen</code> user editing <code>user.foo.canEditComment</code> <code>Kann eigene Kommentare bearbeiten</code> moderator deleting <code>mod.foo.canDeleteComment</code> <code>Kann Kommentare l\u00f6schen</code> moderator editing <code>mod.foo.canEditComment</code> <code>Kann Kommentare bearbeiten</code> moderator moderating <code>mod.foo.canModerateComment</code> <code>Kann Kommentare moderieren</code>"},{"location":"view/languages-naming-conventions/#english_2","title":"English","text":"group type action example permission name language item user adding <code>user.foo.canAddComment</code> <code>Can create comments</code> user deleting <code>user.foo.canDeleteComment</code> <code>Can delete their comments</code> user editing <code>user.foo.canEditComment</code> <code>Can edit their comments</code> moderator deleting <code>mod.foo.canDeleteComment</code> <code>Can delete comments</code> moderator editing <code>mod.foo.canEditComment</code> <code>Can edit comments</code> moderator moderating <code>mod.foo.canModerateComment</code> <code>Can moderate comments</code>"},{"location":"view/languages/","title":"Languages","text":"<p>WoltLab Suite offers full i18n support with its integrated language system, including but not limited to dynamic phrases using template scripting and the built-in support for right-to-left languages.</p> <p>Phrases are deployed using the language package installation plugin, please also read the naming conventions for language items.</p>"},{"location":"view/languages/#special-phrases","title":"Special Phrases","text":""},{"location":"view/languages/#wcfdatedateformat","title":"<code>wcf.date.dateFormat</code>","text":"<p>Many characters in the format have a special meaning and will be replaced with date fragments. If you want to include a literal character, you'll have to use the backslash <code>\\</code> as an escape sequence to indicate that the character should be output as-is rather than being replaced. For example, <code>Y-m-d</code> will be output as <code>2018-03-30</code>, but <code>\\Y-m-d</code> will result in <code>Y-03-30</code>.</p> <p>Defaults to <code>M jS Y</code>.</p> <p>The date format without time using PHP's format characters for the <code>date()</code> function. This value is also used inside the JavaScript implementation, where the characters are mapped to an equivalent representation.</p>"},{"location":"view/languages/#wcfdatetimeformat","title":"<code>wcf.date.timeFormat</code>","text":"<p>Defaults to <code>g:i a</code>.</p> <p>The date format that is used to represent a time, but not a date. Please see the explanation on <code>wcf.date.dateFormat</code> to learn more about the format characters.</p>"},{"location":"view/languages/#wcfdatefirstdayoftheweek","title":"<code>wcf.date.firstDayOfTheWeek</code>","text":"<p>Defaults to <code>0</code>.</p> <p>Sets the first day of the week: * <code>0</code> - Sunday * <code>1</code> - Monday</p>"},{"location":"view/languages/#wcfglobalpagedirection-rtl-support","title":"<code>wcf.global.pageDirection</code> - RTL support","text":"<p>Defaults to <code>ltr</code>.</p> <p>Changing this value to <code>rtl</code> will reverse the page direction and enable the right-to-left support for phrases. Additionally, a special version of the stylesheet is loaded that contains all necessary adjustments for the reverse direction.</p>"},{"location":"view/template-modifiers/","title":"Template Modifiers","text":"<p>Variable modifiers are used to modify the output of variables within templates. These modifiers allow you to perform various operations on the variables before displaying them. The general syntax for applying a variable modifier is <code>{$variable|modifier}</code>.</p> <p>Modifiers can be chained together to perform multiple operations on a variable. In such cases, the modifiers are applied from left to right. For example: <pre><code>{$variable|modifier1|modifier2|modifier3}\n</code></pre></p> <p>A modifier may accept additional parameters that affect its behavior. These parameters follow the modifier name and are separated by a <code>:</code>. For example: <pre><code>{$variable|modifier:'param1':'param2'}\n</code></pre></p>"},{"location":"view/template-modifiers/#build-in-modifiers","title":"Build-in Modifiers","text":""},{"location":"view/template-modifiers/#concat","title":"<code>|concat</code>","text":"<p><code>concat</code> is a modifier used to concatenate multiple strings:</p> <pre><code>{assign var=foo value='foo'}\n\n{assign var=templateVariable value='bar'|concat:$foo}\n\n{$templateVariable} {* prints 'foobar *}\n</code></pre>"},{"location":"view/template-modifiers/#currency","title":"<code>|currency</code>","text":"<p><code>currency</code> is a modifier used to format currency values with two decimals using language dependent thousands separators and decimal point:</p> <pre><code>{assign var=currencyValue value=12.345}\n\n{$currencyValue|currency} {* prints '12.34' *}\n</code></pre>"},{"location":"view/template-modifiers/#date","title":"<code>|date</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0. Use <code>{time type='plainDate'}</code> or <code>{time type='custom'}</code> instead.</p> <p><code>date</code> generated a formatted date using <code>wcf\\util\\DateUtil::format()</code> with <code>DateUtil::DATE_FORMAT</code> internally.</p> <pre><code>{$timestamp|date}\n</code></pre>"},{"location":"view/template-modifiers/#encodejs","title":"<code>|encodeJS</code>","text":"<p><code>encodeJS</code> encodes a string to be used as a single-quoted string in JavaScript by replacing <code>\\\\</code> with <code>\\\\\\\\</code>, <code>'</code> with <code>\\'</code>, linebreaks with <code>\\n</code>, and <code>/</code> with <code>\\/</code>.</p> <pre><code><script>\n var foo = '{unsafe:$foo|encodeJS}';\n</script>\n</code></pre>"},{"location":"view/template-modifiers/#escapecdata","title":"<code>|escapeCDATA</code>","text":"<p><code>escapeCDATA</code> encodes a string to be used in a <code>CDATA</code> element by replacing <code>]]></code> with <code>]]]]><![CDATA[></code>.</p> <pre><code><![CDATA[{unsafe:$foo|encodeCDATA}]]>\n</code></pre>"},{"location":"view/template-modifiers/#filesizebinary","title":"<code>|filesizeBinary</code>","text":"<p><code>filesizeBinary</code> formats the filesize using binary filesize (in bytes).</p> <pre><code>{$filesize|filesizeBinary}\n</code></pre>"},{"location":"view/template-modifiers/#filesize","title":"<code>|filesize</code>","text":"<p><code>filesize</code> formats the filesize using filesize (in bytes).</p> <pre><code>{$filesize|filesize}\n</code></pre>"},{"location":"view/template-modifiers/#ipsearch","title":"<code>|ipSearch</code>","text":"<p><code>ipSearch</code> generates a link to search for an IP address.</p> <pre><code>{\"127.0.0.1\"|ipSearch}\n</code></pre>"},{"location":"view/template-modifiers/#json","title":"<code>|json</code>","text":"<p><code>json</code> JSON-encodes the given value.</p> <pre><code><script>\nlet data = { \"title\": {unsafe:$foo->getTitle()|json} };\n</script>\n</code></pre>"},{"location":"view/template-modifiers/#language","title":"<code>|language</code>","text":"<p><code>language</code> replaces a language items with its value. If the template variable <code>__language</code> exists, this language object will be used instead of <code>WCF::getLanguage()</code>. This modifier is useful when assigning the value directly to a variable.</p> <p>Note that template scripting is applied to the output of the variable, which can lead to unwanted side effects. Use <code>phrase</code> instead if you don't want to use template scripting.</p> <pre><code>{$languageItem|language}\n\n{assign var=foo value=$languageItem|language}\n</code></pre>"},{"location":"view/template-modifiers/#newlinetobreak","title":"<code>|newlineToBreak</code>","text":"<p><code>newlineToBreak</code> transforms newlines into HTML <code><br></code> elements after encoding the content via <code>wcf\\util\\StringUtil::encodeHTML()</code>.</p> <pre><code>{$foo|newlineToBreak}\n</code></pre>"},{"location":"view/template-modifiers/#phrase","title":"<code>|phrase</code>","text":"<p><code>phrase</code> replaces a language items with its value. If the template variable <code>__language</code> exists, this language object will be used instead of <code>WCF::getLanguage()</code>. This modifier is useful when assigning the value directly to a variable.</p> <p><code>phrase</code> should be used instead of <code>language</code> unless you want to explicitly allow template scripting on a variable's output.</p> <pre><code>{$languageItem|phrase}\n\n{assign var=foo value=$languageItem|phrase}\n</code></pre>"},{"location":"view/template-modifiers/#plaintime","title":"<code>|plainTime</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0. Use <code>{time type='plainTime'}</code> instead.</p> <p><code>plainTime</code> formats a timestamp to include year, month, day, hour, and minutes. The exact formatting depends on the current language (via the language items <code>wcf.date.dateTimeFormat</code>, <code>wcf.date.dateFormat</code>, and <code>wcf.date.timeFormat</code>).</p> <pre><code>{$timestamp|plainTime}\n</code></pre>"},{"location":"view/template-modifiers/#shortunit","title":"<code>|shortUnit</code>","text":"<p><code>shortUnit</code> shortens numbers larger than 1000 by using unit suffixes:</p> <pre><code>{10000|shortUnit} {* prints 10k *}\n{5400000|shortUnit} {* prints 5.4M *}\n</code></pre>"},{"location":"view/template-modifiers/#tablewordwrap","title":"<code>|tableWordwrap</code>","text":"<p><code>tableWordwrap</code> inserts zero width spaces every 30 characters in words longer than 30 characters.</p> <pre><code>{$foo|tableWordwrap}\n</code></pre>"},{"location":"view/template-modifiers/#time","title":"<code>|time</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0. Use <code>{time}</code> instead.</p> <p><code>time</code> generates an HTML <code>time</code> elements based on a timestamp that shows a relative time or the absolute time if the timestamp more than six days ago.</p> <pre><code>{$timestamp|time} {* prints a '<time>' element *}\n</code></pre>"},{"location":"view/template-modifiers/#truncate","title":"<code>|truncate</code>","text":"<p><code>truncate</code> truncates a long string into a shorter one:</p> <pre><code>{$foo|truncate:35}\n\n{$foo|truncate:35:'_':true}\n</code></pre> Parameter Number Description 0 truncated string 1 truncated length; <code>80</code> by default 2 ellipsis symbol; <code>wcf\\util\\StringUtil::HELLIP</code> by default 3 if <code>true</code>, words can be broken up in the middle; <code>false</code> by default"},{"location":"view/template-modifiers/#php-functions","title":"PHP Functions","text":"<p>A limited number of safe native PHP functions may also be used as variable modifiers:</p> <ul> <li><code>abs</code></li> <li><code>addslashes</code></li> <li><code>array_diff</code></li> <li><code>array_fill</code></li> <li><code>array_key_exists</code></li> <li><code>array_keys</code></li> <li><code>array_pop</code></li> <li><code>array_slice</code></li> <li><code>array_values</code></li> <li><code>base64_decode</code></li> <li><code>base64_encode</code></li> <li><code>basename</code></li> <li><code>ceil</code></li> <li><code>concat</code></li> <li><code>constant</code></li> <li><code>count</code></li> <li><code>currency</code></li> <li><code>current</code></li> <li><code>date</code></li> <li><code>defined</code></li> <li><code>doubleval</code></li> <li><code>empty</code></li> <li><code>end</code></li> <li><code>explode</code></li> <li><code>file_exists</code></li> <li><code>filesize</code></li> <li><code>floatval</code></li> <li><code>floor</code></li> <li><code>function_exists</code></li> <li><code>get_class</code></li> <li><code>gmdate</code></li> <li><code>hash</code></li> <li><code>htmlspecialchars</code></li> <li><code>html_entity_decode</code></li> <li><code>http_build_query</code></li> <li><code>implode</code></li> <li><code>in_array</code></li> <li><code>is_array</code></li> <li><code>is_null</code></li> <li><code>is_numeric</code></li> <li><code>is_object</code></li> <li><code>is_string</code></li> <li><code>iterator_count</code></li> <li><code>intval</code></li> <li><code>is_subclass_of</code></li> <li><code>isset</code></li> <li><code>json_encode</code></li> <li><code>key</code></li> <li><code>lcfirst</code></li> <li><code>ltrim</code></li> <li><code>max</code></li> <li><code>mb_strpos</code></li> <li><code>mb_strlen</code></li> <li><code>mb_strpos</code></li> <li><code>mb_strtolower</code></li> <li><code>mb_strtoupper</code></li> <li><code>mb_substr</code></li> <li><code>md5</code></li> <li><code>method_exists</code></li> <li><code>microtime</code></li> <li><code>min</code></li> <li><code>nl2br</code></li> <li><code>number_format</code></li> <li><code>parse_url</code></li> <li><code>preg_match</code></li> <li><code>preg_replace</code></li> <li><code>print_r</code></li> <li><code>random_int</code></li> <li><code>rawurlencode</code></li> <li><code>reset</code></li> <li><code>round</code></li> <li><code>sha1</code></li> <li><code>spl_object_hash</code></li> <li><code>sprintf</code></li> <li><code>strip_tags</code></li> <li><code>strlen</code></li> <li><code>strpos</code></li> <li><code>strtolower</code></li> <li><code>strtotime</code></li> <li><code>strtoupper</code></li> <li><code>str_contains</code></li> <li><code>str_ends_with</code></li> <li><code>str_ireplace</code></li> <li><code>str_pad</code></li> <li><code>str_repeat</code></li> <li><code>str_replace</code></li> <li><code>str_starts_with</code></li> <li><code>substr</code></li> <li><code>trim</code></li> <li><code>ucfirst</code></li> <li><code>uniqid</code></li> <li><code>urlencode</code></li> <li><code>var_dump</code></li> <li><code>version_compare</code></li> <li><code>wcfDebug</code></li> <li><code>wordwrap</code></li> </ul>"},{"location":"view/template-plugins/","title":"Template Plugins","text":""},{"location":"view/template-plugins/#anchor","title":"<code>{anchor}</code>","text":"<p>The <code>anchor</code> template plugin creates <code>a</code> HTML elements. The easiest way to use the template plugin is to pass it an instance of <code>ITitledLinkObject</code>:</p> <pre><code>{anchor object=$object}\n</code></pre> <p>generates the same output as</p> <pre><code><a href=\"{$object->getLink()}\">{$object->getTitle()}</a>\n</code></pre> <p>Instead of an <code>object</code> parameter, a <code>link</code> and <code>content</code> parameter can be used:</p> <pre><code>{anchor link=$linkObject content=$content}\n</code></pre> <p>where <code>$linkObject</code> implements <code>ILinkableObject</code> and <code>$content</code> is either an object implementing <code>ITitledObject</code> or having a <code>__toString()</code> method or <code>$content</code> is a string or a number.</p> <p>The last special attribute is <code>append</code> whose contents are appended to the <code>href</code> attribute of the generated anchor element.</p> <p>All of the other attributes matching <code>~^[a-z]+([A-z]+)+$~</code>, expect for <code>href</code> which is disallowed, are added as attributes to the anchor element.</p> <p>If an <code>object</code> attribute is present, the object also implements <code>IPopoverObject</code> and if the return value of <code>IPopoverObject::getPopoverLinkClass()</code> is included in the <code>class</code> attribute of the <code>anchor</code> tag, <code>data-object-id</code> is automatically added. This functionality makes it easy to generate links with popover support. Instead of</p> <pre><code><a href=\"{$entry->getLink()}\" class=\"blogEntryLink\" data-object-id=\"{$entry->entryID}\">{$entry->subject}</a>\n</code></pre> <p>using</p> <pre><code>{anchor object=$entry class='blogEntryLink'}\n</code></pre> <p>is sufficient if <code>Entry::getPopoverLinkClass()</code> returns <code>blogEntryLink</code>.</p>"},{"location":"view/template-plugins/#anchorattributes","title":"<code>{anchorAttributes}</code>","text":"<p><code>anchorAttributes</code> compliments the <code>StringUtil::getAnchorTagAttributes(string, bool): string</code> method. It allows to easily generate the necessary attributes for an anchor tag based off the destination URL.</p> <pre><code><a href=\"https://www.example.com\" {anchorAttributes url='https://www.example.com' appendHref=false appendClassname=true isUgc=true}>\n</code></pre> Attribute Description <code>url</code> destination URL <code>appendHref</code> whether the <code>href</code> attribute should be generated; <code>true</code> by default <code>isUgc</code> whether the <code>rel=\"ugc\"</code> attribute should be generated; <code>false</code> by default <code>appendClassname</code> whether the <code>class=\"externalURL\"</code> attribute should be generated; <code>true</code> by default"},{"location":"view/template-plugins/#append","title":"<code>{append}</code>","text":"<p>If a string should be appended to the value of a variable, <code>append</code> can be used:</p> <pre><code>{assign var=templateVariable value='newValue'}\n\n{$templateVariable} {* prints 'newValue *}\n\n{append var=templateVariable value='2'}\n\n{$templateVariable} {* now prints 'newValue2 *}\n</code></pre> <p>If the variables does not exist yet, <code>append</code> creates a new one with the given value. If <code>append</code> is used on an array as the variable, the value is appended to all elements of the array.</p>"},{"location":"view/template-plugins/#assign","title":"<code>{assign}</code>","text":"<p>New template variables can be declared and new values can be assigned to existing template variables using <code>assign</code>:</p> <pre><code>{assign var=templateVariable value='newValue'}\n\n{$templateVariable} {* prints 'newValue *}\n</code></pre>"},{"location":"view/template-plugins/#capture","title":"<code>{capture}</code>","text":"<p>In some situations, <code>assign</code> is not sufficient to assign values to variables in templates if the value is complex. Instead, <code>capture</code> can be used:</p> <pre><code>{capture var=templateVariable}\n {if $foo}\n <p>{$bar}</p>\n {else}\n <small>{$baz}</small>\n {/if}\n{/capture}\n</code></pre>"},{"location":"view/template-plugins/#counter","title":"<code>{counter}</code>","text":"<p><code>counter</code> can be used to generate and optionally print a counter:</p> <pre><code>{counter name=fooCounter print=true} {* prints '1' *}\n\n{counter name=fooCounter print=true} {* prints '2' now *}\n\n{counter name=fooCounter} {* prints nothing, but counter value is '3' now internally *}\n\n{counter name=fooCounter print=true} {* prints '4' *}\n</code></pre> <p>Counter supports the following attributes:</p> Attribute Description <code>assign</code> optional name of the template variable the current counter value is assigned to <code>direction</code> counting direction, either <code>up</code> or <code>down</code>; <code>up</code> by default <code>name</code> name of the counter, relevant if multiple counters are used simultaneously <code>print</code> if <code>true</code>, the current counter value is printed; <code>false</code> by default <code>skip</code> positive counting increment; <code>1</code> by default <code>start</code> start counter value; <code>1</code> by default"},{"location":"view/template-plugins/#54-csrftoken","title":"5.4+ <code>csrfToken</code>","text":"<p><code>{csrfToken}</code> prints out the session's CSRF token (\u201cSecurity Token\u201d).</p> <pre><code><form action=\"{link controller=\"Foo\"}{/link}\" method=\"post\">\n {* snip *}\n\n {csrfToken}\n</form>\n</code></pre> <p>The <code>{csrfToken}</code> template plugin supports a <code>type</code> parameter. Specifying this parameter might be required in rare situations. Please check the implementation for details.</p>"},{"location":"view/template-plugins/#cycle","title":"<code>{cycle}</code>","text":"<p><code>cycle</code> can be used to cycle between different values:</p> <pre><code>{cycle name=fooCycle values='bar,baz'} {* prints 'bar' *}\n\n{cycle name=fooCycle} {* prints 'baz' *}\n\n{cycle name=fooCycle advance=false} {* prints 'baz' again *}\n\n{cycle name=fooCycle} {* prints 'bar' *}\n</code></pre> <p>The values attribute only has to be present for the first call. If <code>cycle</code> is used in a loop, the presence of the same values in consecutive calls has no effect. Only once the values change, the cycle is reset.</p> Attribute Description <code>advance</code> if <code>true</code>, the current cycle value is advanced to the next value; <code>true</code> by default <code>assign</code> optional name of the template variable the current cycle value is assigned to; if used, <code>print</code> is set to <code>false</code> <code>delimiter</code> delimiter between the different cycle values; <code>,</code> by default <code>name</code> name of the cycle, relevant if multiple cycles are used simultaneously <code>print</code> if <code>true</code>, the current cycle value is printed, <code>false</code> by default <code>reset</code> if <code>true</code>, the current cycle value is set to the first value, <code>false</code> by default <code>values</code> string containing the different cycles values, also see <code>delimiter</code>"},{"location":"view/template-plugins/#dateinterval","title":"<code>{dateInterval}</code>","text":"<p><code>dateInterval</code> calculates the difference between two unix timestamps and generated a textual date interval.</p> <pre><code>{dateInterval start=$startTimestamp end=$endTimestamp full=true format='sentence'}\n</code></pre> Attribute Description <code>end</code> end of the time interval; current timestamp by default (though either <code>start</code> or <code>end</code> has to be set) <code>format</code> output format, either <code>default</code>, <code>sentence</code>, or <code>plain</code>; defaults to <code>default</code>, see <code>wcf\\util\\DateUtil::FORMAT_*</code> constants <code>full</code> if <code>true</code>, full difference in minutes is shown; if <code>false</code>, only the longest time interval is shown; <code>false</code> by default <code>start</code> start of the time interval; current timestamp by default (though either <code>start</code> or <code>end</code> has to be set)"},{"location":"view/template-plugins/#event","title":"<code>{event}</code>","text":"<p><code>event</code> provides extension points in templates that template listeners can use.</p> <pre><code>{event name='foo'}\n</code></pre>"},{"location":"view/template-plugins/#hascontent","title":"<code>{hascontent}</code>","text":"<p>In many cases, conditional statements can be used to determine if a certain section of a template is shown:</p> <pre><code>{if $foo === 'bar'}\n only shown if $foo is bar\n{/if}\n</code></pre> <p>In some situations, however, such conditional statements are not sufficient. One prominent example is a template event:</p> <pre><code>{if $foo === 'bar'}\n <ul>\n {if $foo === 'bar'}\n <li>Bar</li>\n {/if}\n\n {event name='listItems'}\n </li>\n{/if}\n</code></pre> <p>In this example, if <code>$foo !== 'bar'</code>, the list will not be shown, regardless of the additional template code provided by template listeners. In such a situation, <code>hascontent</code> has to be used:</p> <pre><code>{hascontent}\n <ul>\n {content}\n {if $foo === 'bar'}\n <li>Bar</li>\n {/if}\n\n {event name='listItems'}\n {/content}\n </ul>\n{/hascontent}\n</code></pre> <p>If the part of the template wrapped in the <code>content</code> tags has any (trimmed) content, the part of the template wrapped by <code>hascontent</code> tags is shown (including the part wrapped by the <code>content</code> tags), otherwise nothing is shown. Thus, this construct avoids an empty list compared to the <code>if</code> solution above.</p> <p>Like <code>foreach</code>, <code>hascontent</code> also supports an <code>else</code> part:</p> <pre><code>{hascontent}\n <ul>\n {content}\n {* \u2026 *}\n {/content}\n </ul>\n{hascontentelse}\n no list\n{/hascontent}\n</code></pre>"},{"location":"view/template-plugins/#htmlcheckboxes","title":"<code>{htmlCheckboxes}</code>","text":"<p><code>htmlCheckboxes</code> generates a list of HTML checkboxes.</p> <pre><code>{htmlCheckboxes name=foo options=$fooOptions selected=$currentFoo}\n\n{htmlCheckboxes name=bar output=$barLabels values=$barValues selected=$currentBar}\n</code></pre> Attribute Description <code>disabled</code> if <code>true</code>, all checkboxes are disabled <code>disableEncoding</code> if <code>true</code>, the values are not passed through <code>wcf\\util\\StringUtil::encodeHTML()</code>; <code>false</code> by default <code>name</code> <code>name</code> attribute of the <code>input</code> checkbox element <code>output</code> array used as keys and values for <code>options</code> if present; not present by default <code>options</code> array selectable options with the key used as <code>value</code> attribute and the value as the checkbox label <code>selected</code> current selected value(s) <code>separator</code> separator between the different checkboxes in the generated output; empty string by default <code>values</code> array with values used in combination with <code>output</code>, where <code>output</code> is only used as keys for <code>options</code>"},{"location":"view/template-plugins/#htmloptions","title":"<code>{htmlOptions}</code>","text":"<p><code>htmlOptions</code> generates an <code>select</code> HTML element.</p> <pre><code>{htmlOptions name='foo' options=$options selected=$selected}\n\n<select name=\"bar\">\n <option value=\"\"{if !$selected} selected{/if}>{lang}foo.bar.default{/lang}</option>\n {htmlOptions options=$options selected=$selected} {* no `name` attribute *}\n</select>\n</code></pre> Attribute Description <code>disableEncoding</code> if <code>true</code>, the values are not passed through <code>wcf\\util\\StringUtil::encodeHTML()</code>; <code>false</code> by default <code>object</code> optional instance of <code>wcf\\data\\DatabaseObjectList</code> that provides the selectable options (overwrites <code>options</code> attribute internally) <code>name</code> <code>name</code> attribute of the <code>select</code> element; if not present, only the contents of the <code>select</code> element are printed <code>output</code> array used as keys and values for <code>options</code> if present; not present by default <code>values</code> array with values used in combination with <code>output</code>, where <code>output</code> is only used as keys for <code>options</code> <code>options</code> array selectable options with the key used as <code>value</code> attribute and the value as the option label; if a value is an array, an <code>optgroup</code> is generated with the array key as the <code>optgroup</code> label <code>selected</code> current selected value(s) <p>All additional attributes are added as attributes of the <code>select</code> HTML element.</p>"},{"location":"view/template-plugins/#icon","title":"<code>{icon}</code>","text":"<p><code>{icon}</code> renders a \u201cFont Awesome\u201d icon with support for brand icons.</p> <pre><code>{icon name='magnifying-glass'}\n{icon size=24 name='github' type='brand'}\n{icon size=32 name='user' type='solid'}\n{icon size=64 name='bell'}\n</code></pre> Attribute Description <code>size</code> the size of the icon, possible values are <code>16</code>, <code>24</code>, <code>32</code>, <code>48</code>, <code>64</code>, <code>96</code>, <code>128</code> and <code>144</code>; defaults to <code>16</code> <code>type</code> requests the least \u201cthick\u201d icon when omitted, the solid variant with <code>'solid'</code> and a brand icon with <code>'brand'</code>"},{"location":"view/template-plugins/#implode","title":"<code>{implode}</code>","text":"<p><code>implodes</code> transforms an array into a string and prints it.</p> <pre><code>{implode from=$array key=key item=item glue=\";\"}{$key}: {$value}{/implode}\n</code></pre> Attribute Description <code>from</code> array with the imploded values <code>glue</code> separator between the different array values; <code>', '</code> by default <code>item</code> template variable name where the current array value is stored during the iteration <code>key</code> optional template variable name where the current array key is stored during the iteration"},{"location":"view/template-plugins/#js","title":"<code>{js}</code>","text":"<p><code>js</code> generates script tags based on whether <code>ENABLE_DEBUG_MODE</code> and <code>VISITOR_USE_TINY_BUILD</code> are enabled.</p> <pre><code>{js application='wbb' file='WBB'} {* generates 'http://example.com/js/WBB.js' *}\n\n{js application='wcf' file='WCF.User' bundle='WCF.Combined'}\n {* generates 'http://example.com/wcf/js/WCF.User.js' if ENABLE_DEBUG_MODE=1 *}\n {* generates 'http://example.com/wcf/js/WCF.Combined.min.js' if ENABLE_DEBUG_MODE=0 *}\n\n{js application='wcf' lib='jquery'}\n {* generates 'http://example.com/wcf/js/3rdParty/jquery.js' *}\n\n{js application='wcf' lib='jquery-ui' file='awesomeWidget'}\n {* generates 'http://example.com/wcf/js/3rdParty/jquery-ui/awesomeWidget.js' *}\n\n{js application='wcf' file='WCF.User' bundle='WCF.Combined' hasTiny=true}\n {* generates 'http://example.com/wcf/js/WCF.User.js' if ENABLE_DEBUG_MODE=1 *}\n {* generates 'http://example.com/wcf/js/WCF.Combined.min.js' (ENABLE_DEBUG_MODE=0 *}\n {* generates 'http://example.com/wcf/js/WCF.Combined.tiny.min.js' if ENABLE_DEBUG_MODE=0 and VISITOR_USE_TINY_BUILD=1 *}\n</code></pre>"},{"location":"view/template-plugins/#jslang","title":"<code>{jslang}</code>","text":"<p><code>jslang</code> works like <code>lang</code> with the difference that the resulting string is automatically passed through <code>encodeJS</code>.</p> <pre><code>require(['Language', /* \u2026 */], function(Language, /* \u2026 */) {\n Language.addObject({\n 'app.foo.bar': '{jslang}app.foo.bar{/jslang}',\n });\n\n // \u2026\n});\n</code></pre>"},{"location":"view/template-plugins/#60-jsphrase","title":"6.0+ <code>{jsphrase}</code>","text":"<p><code>jsphrase</code> generates the necessary JavaScript code to register a phrase in the JavaScript language store. This plugin only supports static phrase names. If a dynamic phrase should be registered, the <code>jslang</code> plugin needs to be used.</p> <pre><code><script data-relocate=\"true\">\n{jsphrase name='app.foo.bar'}\n\n// \u2026\n</script>\n</code></pre>"},{"location":"view/template-plugins/#lang","title":"<code>{lang}</code>","text":"<p><code>lang</code> replaces a language items with its value.</p> <pre><code>{lang}foo.bar.baz{/lang}\n\n{lang __literal=true}foo.bar.baz{/lang}\n\n{lang foo='baz'}foo.bar.baz{/lang}\n\n{lang}foo.bar.baz.{$action}{/lang}\n</code></pre> Attribute Description <code>__encode</code> if <code>true</code>, the output will be passed through <code>StringUtil::encodeHTML()</code> <code>__literal</code> if <code>true</code>, template variables will not resolved but printed as they are in the language item; <code>false</code> by default <code>__optional</code> if <code>true</code> and the language item does not exist, an empty string is printed; <code>false</code> by default <p>All additional attributes are available when parsing the language item.</p>"},{"location":"view/template-plugins/#link","title":"<code>{link}</code>","text":"<p><code>link</code> generates internal links using <code>LinkHandler</code>.</p> <pre><code><a href=\"{link controller='FooList' application='bar'}param1=2&param2=A{/link}\">Foo</a>\n</code></pre> Attribute Description <code>application</code> abbreviation of the application the controller belongs to; <code>wcf</code> by default <code>controller</code> name of the controller; if not present, the landing page is linked in the frontend and the index page in the ACP <code>encode</code> if <code>true</code>, the generated link is passed through <code>wcf\\util\\StringUtil::encodeHTML()</code>; <code>true</code> by default <code>isEmail</code> sets <code>encode=false</code> and forces links to link to the frontend <p>Additional attributes are passed to <code>LinkHandler::getLink()</code>.</p>"},{"location":"view/template-plugins/#54-objectaction","title":"5.4+ <code>objectAction</code>","text":"<p><code>objectAction</code> generates action buttons to be used in combination with the <code>WoltLabSuite/Core/Ui/Object/Action</code> API. For detailed information on its usage, we refer to the extensive documentation in the <code>ObjectActionFunctionTemplatePlugin</code> class itself.</p>"},{"location":"view/template-plugins/#page","title":"<code>{page}</code>","text":"<p><code>page</code> generates an internal link to a CMS page.</p> <pre><code>{page}com.woltlab.wcf.CookiePolicy{/page}\n\n{page pageID=1}{/page}\n\n{page language='de'}com.woltlab.wcf.CookiePolicy{/page}\n\n{page languageID=2}com.woltlab.wcf.CookiePolicy{/page}\n</code></pre> Attribute Description <code>pageID</code> unique id of the page (cannot be used together with a page identifier as value) <code>languageID</code> id of the page language (cannot be used together with <code>language</code>) <code>language</code> language code of the page language (cannot be used together with <code>languageID</code>)"},{"location":"view/template-plugins/#pages","title":"<code>{pages}</code>","text":"<p>This template plugin has been deprecated in WoltLab Suite 6.0.</p> <p><code>pages</code> generates a pagination.</p> <pre><code>{pages controller='FooList' link=\"pageNo=%d\" print=true assign=pagesLinks} {* prints pagination *}\n\n{unsafe:$pagesLinks} {* prints same pagination again *}\n</code></pre> Attribute Description <code>assign</code> optional name of the template variable the pagination is assigned to <code>controller</code> controller name of the generated links <code>link</code> additional link parameter where <code>%d</code> will be replaced with the relevant page number <code>pages</code> maximum number of of pages; by default, the template variable <code>$pages</code> is used <code>print</code> if <code>false</code> and <code>assign=true</code>, the pagination is not printed <code>application</code>, <code>id</code>, <code>object</code>, <code>title</code> additional parameters passed to <code>LinkHandler::getLink()</code> to generate page links"},{"location":"view/template-plugins/#plural","title":"<code>{plural}</code>","text":"<p><code>plural</code> allows to easily select the correct plural form of a phrase based on a given <code>value</code>. The pluralization logic follows the Unicode Language Plural Rules for cardinal numbers.</p> <p>The <code>#</code> placeholder within the resulting phrase is replaced by the <code>value</code>. It is automatically formatted using <code>StringUtil::formatNumeric</code>.</p> <p>English:</p> <p>Note the use of <code>1</code> if the number (<code>#</code>) is not used within the phrase and the use of <code>one</code> otherwise. They are equivalent for English, but following this rule generalizes better to other languages, helping the translator. <pre><code>{assign var=numberOfWorlds value=2}\n<h1>Hello {plural value=$numberOfWorlds 1='World' other='Worlds'}!</h1>\n<p>There {plural value=$numberOfWorlds 1='is one world' other='are # worlds'}!</p>\n<p>There {plural value=$numberOfWorlds one='is # world' other='are # worlds'}!</p>\n</code></pre></p> <p>German: <pre><code>{assign var=numberOfWorlds value=2}\n<h1>Hallo {plural value=$numberOfWorlds 1='Welt' other='Welten'}!</h1>\n<p>Es gibt {plural value=$numberOfWorlds 1='eine Welt' other='# Welten'}!</p>\n<p>Es gibt {plural value=$numberOfWorlds one='# Welt' other='# Welten'}!</p>\n</code></pre></p> <p>Romanian:</p> <p>Note the additional use of <code>few</code> which is not required in English or German. <pre><code>{assign var=numberOfWorlds value=2}\n<h1>Salut {plural value=$numberOfWorlds 1='lume' other='lumi'}!</h1>\n<p>Exist\u0103 {plural value=$numberOfWorlds 1='o lume' few='# lumi' other='# de lumi'}!</p>\n<p>Exist\u0103 {plural value=$numberOfWorlds one='# lume' few='# lumi' other='# de lumi'}!</p>\n</code></pre></p> <p>Russian:</p> <p>Note the difference between <code>1</code> (exactly <code>1</code>) and <code>one</code> (ending in <code>1</code>, except ending in <code>11</code>). <pre><code>{assign var=numberOfWorlds value=2}\n<h1>\u041f\u0440\u0438\u0432\u0435\u0442 {plural value=$numberOfWorld 1='\u043c\u0438\u0440' other='\u043c\u0438\u0440\u044b'}!</h1>\n<p>\u0415\u0441\u0442\u044c {plural value=$numberOfWorlds 1='\u043c\u0438\u0440' one='# \u043c\u0438\u0440' few='# \u043c\u0438\u0440\u0430' many='# \u043c\u0438\u0440\u043e\u0432' other='# \u043c\u0438\u0440\u043e\u0432'}!</p>\n</code></pre></p> Attribute Description value The value that is used to select the proper phrase. other The phrase that is used when no other selector matches. Any Category Name The phrase that is used when <code>value</code> belongs to the named category. Available categories depend on the language. Any Integer The phrase that is used when <code>value</code> is that exact integer."},{"location":"view/template-plugins/#prepend","title":"<code>{prepend}</code>","text":"<p>If a string should be prepended to the value of a variable, <code>prepend</code> can be used:</p> <pre><code>{assign var=templateVariable value='newValue'}\n\n{$templateVariable} {* prints 'newValue *}\n\n{prepend var=templateVariable value='2'}\n\n{$templateVariable} {* now prints '2newValue' *}\n</code></pre> <p>If the variables does not exist yet, <code>prepend</code> creates a new one with the given value. If <code>prepend</code> is used on an array as the variable, the value is prepended to all elements of the array.</p>"},{"location":"view/template-plugins/#time","title":"<code>{time}</code>","text":"<p><code>time</code> allows to output times in different (human readable) formats. Acceptables inputs are either a <code>\\DateTimeInterface</code> or an integer representing a Unix timestamp.</p> <pre><code>{time time=$time}\n{time time=$time type='plainTime'}\n{time time=$time type='plainDate'}\n{time time=$time type='machine'}\n{time time=$time type='custom' format='Y-m-d'}\n</code></pre> Attribute Description time The <code>\\DateTimeInterface</code> or Unix timestamp to format. type The output format. Type Description \u2013 An interactive <code><woltlab-core-date-time></code> element that renders as dynamically updated relative times. plainTime Date with time in the user\u2019s locale and timezone as a plain string. plainDate Date without time in the user\u2019s locale and timezone as a plain string. machine A machine readable string in ISO-8601 format. custom A custom format that is passed to <code>\\DateTimeInterface::format()</code>. The timezone will be the user\u2019s timezone."},{"location":"view/template-plugins/#user","title":"<code>{user}</code>","text":"<p><code>user</code> generates links to user profiles. The mandatory <code>object</code> parameter requires an instances of <code>UserProfile</code>. The optional <code>type</code> parameter is responsible for what the generated link contains:</p> <ul> <li><code>type='default'</code> (also applies if no <code>type</code> is given) outputs the formatted username relying on the \u201cUser Marking\u201d setting of the relevant user group. Additionally, the user popover card will be shown when hovering over the generated link.</li> <li><code>type='plain'</code> outputs the username without additional formatting.</li> <li><code>type='avatar(\\d+)'</code> outputs the user\u2019s avatar in the specified size, i.e., <code>avatar48</code> outputs the avatar with a width and height of 48 pixels.</li> </ul> <p>The last special attribute is <code>append</code> whose contents are appended to the <code>href</code> attribute of the generated anchor element.</p> <p>All of the other attributes matching <code>~^[a-z]+([A-z]+)+$~</code>, except for <code>href</code> which may not be added, are added as attributes to the anchor element.</p> <p>Examples:</p> <pre><code>{user object=$user}\n</code></pre> <p>generates</p> <pre><code><a href=\"{$user->getLink()}\" data-object-id=\"{$user->userID}\" class=\"userLink\">{unsafe:$user->getFormattedUsername()}</a>\n</code></pre> <p>and</p> <pre><code>{user object=$user type='avatar48' foo='bar'}\n</code></pre> <p>generates</p> <pre><code><a href=\"{$user->getLink()}\" foo=\"bar\">{unsafe:$object->getAvatar()->getImageTag(48)}</a>\n</code></pre>"},{"location":"view/templates/","title":"Templates","text":"<p>Templates are responsible for the output a user sees when requesting a page (while the PHP code is responsible for providing the data that will be shown). Templates are text files with <code>.tpl</code> as the file extension. WoltLab Suite Core compiles the template files once into a PHP file that is executed when a user requests the page. In subsequent request, as the PHP file containing the compiled template already exists, compiling the template is not necessary anymore.</p>"},{"location":"view/templates/#template-types-and-conventions","title":"Template Types and Conventions","text":"<p>WoltLab Suite Core supports two types of templates: frontend templates (or simply templates) and backend templates (ACP templates). Each type of template is only available in its respective domain, thus frontend templates cannot be included or used in the ACP and vice versa.</p> <p>For pages and forms, the name of the template matches the unqualified name of the PHP class except for the <code>Page</code> or <code>Form</code> suffix:</p> <ul> <li><code>RegisterForm.class.php</code> \u2192 <code>register.tpl</code></li> <li><code>UserPage.class.php</code> \u2192 <code>user.tpl</code></li> </ul> <p>If you follow this convention, WoltLab Suite Core will automatically determine the template name so that you do not have to explicitly set it.</p> <p>For forms that handle creating and editing objects, in general, there are two form classes: <code>FooAddForm</code> and <code>FooEditForm</code>. WoltLab Suite Core, however, generally only uses one template <code>fooAdd.tpl</code> and the template variable <code>$action</code> to distinguish between creating a new object (<code>$action = 'add'</code>) and editing an existing object (<code>$action = 'edit'</code>) as the differences between templates for adding and editing an object are minimal.</p>"},{"location":"view/templates/#installing-templates","title":"Installing Templates","text":"<p>Templates and ACP templates are installed by two different package installation plugins: the template PIP and the ACP template PIP. More information about installing templates can be found on those pages. </p>"},{"location":"view/templates/#base-templates","title":"Base Templates","text":""},{"location":"view/templates/#frontend","title":"Frontend","text":"<pre><code>{include file='header'}\n\n{* content *}\n\n{include file='footer'}\n</code></pre>"},{"location":"view/templates/#backend","title":"Backend","text":"<pre><code>{include file='header' pageTitle='foo.bar.baz'}\n\n<header class=\"contentHeader\">\n <div class=\"contentHeaderTitle\">\n <h1 class=\"contentTitle\">Title</h1>\n </div>\n\n <nav class=\"contentHeaderNavigation\">\n <ul>\n {* your default content header navigation buttons *}\n\n {event name='contentHeaderNavigation'}\n </ul>\n </nav>\n</header>\n\n{* content *}\n\n{include file='footer'}\n</code></pre> <p><code>foo.bar.baz</code> is the language item that contains the title of the page.</p>"},{"location":"view/templates/#common-template-components","title":"Common Template Components","text":""},{"location":"view/templates/#forms","title":"Forms","text":"<p>For new forms, use the form builder API.</p> <pre><code><form method=\"post\" action=\"{link controller='FooBar'}{/link}\">\n <div class=\"section\">\n <dl{if $errorField == 'baz'} class=\"formError\"{/if}>\n <dt><label for=\"baz\">{lang}foo.bar.baz{/lang}</label></dt>\n <dd>\n <input type=\"text\" id=\"baz\" name=\"baz\" value=\"{$baz}\" class=\"long\" required autofocus>\n {if $errorField == 'baz'}\n <small class=\"innerError\">\n {if $errorType == 'empty'}\n {lang}wcf.global.form.error.empty{/lang}\n {else}\n {lang}foo.bar.baz.error.{$errorType}{/lang}\n {/if}\n </small>\n {/if}\n </dd>\n </dl>\n\n <dl>\n <dt><label for=\"bar\">{lang}foo.bar.bar{/lang}</label></dt>\n <dd>\n <textarea name=\"bar\" id=\"bar\" cols=\"40\" rows=\"10\">{$bar}</textarea>\n {if $errorField == 'bar'}\n <small class=\"innerError\">{lang}foo.bar.bar.error.{$errorType}{/lang}</small>\n {/if}\n </dd>\n </dl>\n\n {* other fields *}\n\n {event name='dataFields'}\n </div>\n\n {* other sections *}\n\n {event name='sections'}\n\n <div class=\"formSubmit\">\n <input type=\"submit\" value=\"{lang}wcf.global.button.submit{/lang}\" accesskey=\"s\">\n {csrfToken}\n </div>\n</form>\n</code></pre>"},{"location":"view/templates/#tab-menus","title":"Tab Menus","text":"<pre><code><div class=\"section tabMenuContainer\">\n <nav class=\"tabMenu\">\n <ul>\n <li><a href=\"#tab1\">Tab 1</a></li>\n <li><a href=\"#tab2\">Tab 2</a></li>\n\n {event name='tabMenuTabs'}\n </ul>\n </nav>\n\n <div id=\"tab1\" class=\"tabMenuContent\">\n <div class=\"section\">\n {* contents of first tab *}\n </div>\n </div>\n\n <div id=\"tab2\" class=\"tabMenuContainer tabMenuContent\">\n <nav class=\"menu\">\n <ul>\n <li><a href=\"#tab2A\">Tab 2A</a></li>\n <li><a href=\"#tab2B\">Tab 2B</a></li>\n\n {event name='tabMenuTab2Subtabs'}\n </ul>\n </nav>\n\n <div id=\"tab2A\" class=\"tabMenuContent\">\n <div class=\"section\">\n {* contents of first subtab for second tab *}\n </div>\n </div>\n\n <div id=\"tab2B\" class=\"tabMenuContent\">\n <div class=\"section\">\n {* contents of second subtab for second tab *}\n </div>\n </div>\n\n {event name='tabMenuTab2Contents'}\n </div>\n\n {event name='tabMenuContents'}\n</div>\n</code></pre>"},{"location":"view/templates/#template-scripting","title":"Template Scripting","text":""},{"location":"view/templates/#template-variables","title":"Template Variables","text":"<p>Template variables can be assigned via <code>WCF::getTPL()->assign('foo', 'bar')</code> and accessed in templates via <code>$foo</code>:</p> <ul> <li><code>{$foo}</code> will result in the contents of <code>$foo</code> to be passed to <code>StringUtil::encodeHTML()</code> before being printed.</li> <li><code>{#$foo}</code> will result in the contents of <code>$foo</code> to be passed to <code>StringUtil::formatNumeric()</code> before being printed. Thus, this method is relevant when printing numbers and having them formatted correctly according the the user\u2019s language.</li> <li><code>{unsafe:$foo}</code> will result in the contents of <code>$foo</code> to be printed directly. This method should only be used if you want to output the content of the variable directly and unfiltered. Never use this method for user-generated input that has not already been sanitized by other means.</li> </ul> <p>Multiple template variables can be assigned by passing an array:</p> <pre><code>WCF::getTPL()->assign([\n 'foo' => 'bar',\n 'baz' => false \n]);\n</code></pre>"},{"location":"view/templates/#modifiers","title":"Modifiers","text":"<p>Variable modifiers are used to modify the output of variables within templates. These modifiers allow you to perform various operations on the variables before displaying them. The general syntax for applying a variable modifier is <code>{$variable|modifier}</code>.</p> <p>Modifiers can be chained together to perform multiple operations on a variable. In such cases, the modifiers are applied from left to right. For example: <pre><code>{$variable|modifier1|modifier2|modifier3}\n</code></pre></p> <p>A modifier may accept additional parameters that affect its behavior. These parameters follow the modifier name and are separated by a <code>:</code>. For example: <pre><code>{$variable|modifier:'param1':'param2'}\n</code></pre></p> <p>An overview of all available modifiers is available on a dedicated page.</p>"},{"location":"view/templates/#system-template-variable","title":"System Template Variable","text":"<ul> <li><code>$__wcf</code> contains the <code>WCF</code> object (or <code>WCFACP</code> object in the backend).</li> </ul>"},{"location":"view/templates/#comments","title":"Comments","text":"<p>Comments are wrapped in <code>{*</code> and <code>*}</code> and can span multiple lines:</p> <pre><code>{* some\n comment *}\n</code></pre> <p>The template compiler discards the comments, so that they not included in the compiled template.</p>"},{"location":"view/templates/#conditions","title":"Conditions","text":"<p>Conditions follow a similar syntax to PHP code:</p> <pre><code>{if $foo === 'bar'}\n foo is bar\n{elseif $foo === 'baz'}\n foo is baz\n{else}\n foo is neither bar nor baz\n{/if}\n</code></pre> <p>The supported operators in conditions are <code>===</code>, <code>!==</code>, <code>==</code>, <code>!=</code>, <code><=</code>, <code><</code>, <code>>=</code>, <code>></code>, <code>||</code>, <code>&&</code>, <code>!</code>, and <code>=</code>.</p> <p>More examples:</p> <pre><code>{if $bar|isset}\u2026{/if}\n\n{if $bar|count > 3 && $bar|count < 100}\u2026{/if}\n</code></pre>"},{"location":"view/templates/#foreach-loops","title":"Foreach Loops","text":"<p>Foreach loops allow to iterate over arrays or iterable objects:</p> <pre><code><ul>\n {foreach from=$array key=key item=value}\n <li>{$key}: {$value}</li>\n {/foreach}\n</ul>\n</code></pre> <p>While the <code>from</code> attribute containing the iterated structure and the <code>item</code> attribute containg the current value are mandatory, the <code>key</code> attribute is optional. If the foreach loop has a name assigned to it via the <code>name</code> attribute, the <code>$tpl</code> template variable provides additional data about the loop:</p> <pre><code><ul>\n {foreach from=$array key=key item=value name=foo}\n {if $tpl[foreach][foo][first]}\n something special for the first iteration\n {elseif $tpl[foreach][foo][last]}\n something special for the last iteration\n {/if}\n\n <li>iteration {#$tpl[foreach][foo][iteration]+1} out of {#$tpl[foreach][foo][total]} {$key}: {$value}</li>\n {/foreach}\n</ul>\n</code></pre> <p>In contrast to PHP\u2019s foreach loop, templates also support <code>foreachelse</code>:</p> <pre><code>{foreach from=$array item=value}\n \u2026\n{foreachelse}\n there is nothing to iterate over\n{/foreach}\n</code></pre>"},{"location":"view/templates/#including-other-templates","title":"Including Other Templates","text":"<p>To include template named <code>foo</code> from the same domain (frontend/backend), you can use</p> <pre><code>{include file='foo'}\n</code></pre> <p>If the template belongs to an application, you have to specify that application using the <code>application</code> attribute:</p> <pre><code>{include file='foo' application='app'}\n</code></pre> <p>Additional template variables can be passed to the included template as additional attributes:</p> <pre><code>{include file='foo' application='app' var1='foo1' var2='foo2'}\n</code></pre>"},{"location":"view/templates/#template-plugins","title":"Template Plugins","text":"<p>An overview of all available template plugins can be found here.</p>"}]}
\ No newline at end of file